pdf.worker.js 1.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2020 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. (function webpackUniversalModuleDefinition(root, factory) {
  23. if(typeof exports === 'object' && typeof module === 'object')
  24. module.exports = factory();
  25. else if(typeof define === 'function' && define.amd)
  26. define("pdfjs-dist/build/pdf.worker", [], factory);
  27. else if(typeof exports === 'object')
  28. exports["pdfjs-dist/build/pdf.worker"] = factory();
  29. else
  30. root["pdfjs-dist/build/pdf.worker"] = root.pdfjsWorker = factory();
  31. })(this, function() {
  32. return /******/ (function(modules) { // webpackBootstrap
  33. /******/ // The module cache
  34. /******/ var installedModules = {};
  35. /******/
  36. /******/ // The require function
  37. /******/ function __w_pdfjs_require__(moduleId) {
  38. /******/
  39. /******/ // Check if module is in cache
  40. /******/ if(installedModules[moduleId]) {
  41. /******/ return installedModules[moduleId].exports;
  42. /******/ }
  43. /******/ // Create a new module (and put it into the cache)
  44. /******/ var module = installedModules[moduleId] = {
  45. /******/ i: moduleId,
  46. /******/ l: false,
  47. /******/ exports: {}
  48. /******/ };
  49. /******/
  50. /******/ // Execute the module function
  51. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  52. /******/
  53. /******/ // Flag the module as loaded
  54. /******/ module.l = true;
  55. /******/
  56. /******/ // Return the exports of the module
  57. /******/ return module.exports;
  58. /******/ }
  59. /******/
  60. /******/
  61. /******/ // expose the modules object (__webpack_modules__)
  62. /******/ __w_pdfjs_require__.m = modules;
  63. /******/
  64. /******/ // expose the module cache
  65. /******/ __w_pdfjs_require__.c = installedModules;
  66. /******/
  67. /******/ // define getter function for harmony exports
  68. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  69. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  70. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  71. /******/ }
  72. /******/ };
  73. /******/
  74. /******/ // define __esModule on exports
  75. /******/ __w_pdfjs_require__.r = function(exports) {
  76. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  77. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  78. /******/ }
  79. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  80. /******/ };
  81. /******/
  82. /******/ // create a fake namespace object
  83. /******/ // mode & 1: value is a module id, require it
  84. /******/ // mode & 2: merge all properties of value into the ns
  85. /******/ // mode & 4: return value when already ns object
  86. /******/ // mode & 8|1: behave like require
  87. /******/ __w_pdfjs_require__.t = function(value, mode) {
  88. /******/ if(mode & 1) value = __w_pdfjs_require__(value);
  89. /******/ if(mode & 8) return value;
  90. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  91. /******/ var ns = Object.create(null);
  92. /******/ __w_pdfjs_require__.r(ns);
  93. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  94. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __w_pdfjs_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  95. /******/ return ns;
  96. /******/ };
  97. /******/
  98. /******/ // getDefaultExport function for compatibility with non-harmony modules
  99. /******/ __w_pdfjs_require__.n = function(module) {
  100. /******/ var getter = module && module.__esModule ?
  101. /******/ function getDefault() { return module['default']; } :
  102. /******/ function getModuleExports() { return module; };
  103. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  104. /******/ return getter;
  105. /******/ };
  106. /******/
  107. /******/ // Object.prototype.hasOwnProperty.call
  108. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  109. /******/
  110. /******/ // __webpack_public_path__
  111. /******/ __w_pdfjs_require__.p = "";
  112. /******/
  113. /******/
  114. /******/ // Load entry module and return exports
  115. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 0);
  116. /******/ })
  117. /************************************************************************/
  118. /******/ ([
  119. /* 0 */
  120. /***/ (function(module, exports, __w_pdfjs_require__) {
  121. "use strict";
  122. Object.defineProperty(exports, "__esModule", {
  123. value: true
  124. });
  125. Object.defineProperty(exports, "WorkerMessageHandler", {
  126. enumerable: true,
  127. get: function () {
  128. return _worker.WorkerMessageHandler;
  129. }
  130. });
  131. var _worker = __w_pdfjs_require__(1);
  132. const pdfjsVersion = '2.6.347';
  133. const pdfjsBuild = '3be9c65f';
  134. /***/ }),
  135. /* 1 */
  136. /***/ (function(module, exports, __w_pdfjs_require__) {
  137. "use strict";
  138. Object.defineProperty(exports, "__esModule", {
  139. value: true
  140. });
  141. exports.WorkerMessageHandler = exports.WorkerTask = void 0;
  142. var _util = __w_pdfjs_require__(2);
  143. var _primitives = __w_pdfjs_require__(5);
  144. var _pdf_manager = __w_pdfjs_require__(6);
  145. var _writer = __w_pdfjs_require__(27);
  146. var _is_node = __w_pdfjs_require__(4);
  147. var _message_handler = __w_pdfjs_require__(46);
  148. var _worker_stream = __w_pdfjs_require__(47);
  149. var _core_utils = __w_pdfjs_require__(8);
  150. class WorkerTask {
  151. constructor(name) {
  152. this.name = name;
  153. this.terminated = false;
  154. this._capability = (0, _util.createPromiseCapability)();
  155. }
  156. get finished() {
  157. return this._capability.promise;
  158. }
  159. finish() {
  160. this._capability.resolve();
  161. }
  162. terminate() {
  163. this.terminated = true;
  164. }
  165. ensureNotTerminated() {
  166. if (this.terminated) {
  167. throw new Error("Worker task was terminated");
  168. }
  169. }
  170. }
  171. exports.WorkerTask = WorkerTask;
  172. class WorkerMessageHandler {
  173. static setup(handler, port) {
  174. var testMessageProcessed = false;
  175. handler.on("test", function wphSetupTest(data) {
  176. if (testMessageProcessed) {
  177. return;
  178. }
  179. testMessageProcessed = true;
  180. if (!(data instanceof Uint8Array)) {
  181. handler.send("test", null);
  182. return;
  183. }
  184. const supportTransfers = data[0] === 255;
  185. handler.postMessageTransfers = supportTransfers;
  186. handler.send("test", {
  187. supportTransfers
  188. });
  189. });
  190. handler.on("configure", function wphConfigure(data) {
  191. (0, _util.setVerbosityLevel)(data.verbosity);
  192. });
  193. handler.on("GetDocRequest", function wphSetupDoc(data) {
  194. return WorkerMessageHandler.createDocumentHandler(data, port);
  195. });
  196. }
  197. static createDocumentHandler(docParams, port) {
  198. var pdfManager;
  199. var terminated = false;
  200. var cancelXHRs = null;
  201. var WorkerTasks = [];
  202. const verbosity = (0, _util.getVerbosityLevel)();
  203. const apiVersion = docParams.apiVersion;
  204. const workerVersion = '2.6.347';
  205. if (apiVersion !== workerVersion) {
  206. throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
  207. }
  208. const enumerableProperties = [];
  209. for (const property in []) {
  210. enumerableProperties.push(property);
  211. }
  212. if (enumerableProperties.length) {
  213. throw new Error("The `Array.prototype` contains unexpected enumerable properties: " + enumerableProperties.join(", ") + "; thus breaking e.g. `for...in` iteration of `Array`s.");
  214. }
  215. if (typeof ReadableStream === "undefined" || typeof Promise.allSettled === "undefined") {
  216. throw new Error("The browser/environment lacks native support for critical " + "functionality used by the PDF.js library (e.g. " + "`ReadableStream` and/or `Promise.allSettled`); " + "please use an ES5-compatible build instead.");
  217. }
  218. var docId = docParams.docId;
  219. var docBaseUrl = docParams.docBaseUrl;
  220. var workerHandlerName = docParams.docId + "_worker";
  221. var handler = new _message_handler.MessageHandler(workerHandlerName, docId, port);
  222. handler.postMessageTransfers = docParams.postMessageTransfers;
  223. function ensureNotTerminated() {
  224. if (terminated) {
  225. throw new Error("Worker was terminated");
  226. }
  227. }
  228. function startWorkerTask(task) {
  229. WorkerTasks.push(task);
  230. }
  231. function finishWorkerTask(task) {
  232. task.finish();
  233. var i = WorkerTasks.indexOf(task);
  234. WorkerTasks.splice(i, 1);
  235. }
  236. async function loadDocument(recoveryMode) {
  237. await pdfManager.ensureDoc("checkHeader");
  238. await pdfManager.ensureDoc("parseStartXRef");
  239. await pdfManager.ensureDoc("parse", [recoveryMode]);
  240. if (!recoveryMode) {
  241. await pdfManager.ensureDoc("checkFirstPage");
  242. }
  243. const [numPages, fingerprint] = await Promise.all([pdfManager.ensureDoc("numPages"), pdfManager.ensureDoc("fingerprint")]);
  244. return {
  245. numPages,
  246. fingerprint
  247. };
  248. }
  249. function getPdfManager(data, evaluatorOptions) {
  250. var pdfManagerCapability = (0, _util.createPromiseCapability)();
  251. let newPdfManager;
  252. var source = data.source;
  253. if (source.data) {
  254. try {
  255. newPdfManager = new _pdf_manager.LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  256. pdfManagerCapability.resolve(newPdfManager);
  257. } catch (ex) {
  258. pdfManagerCapability.reject(ex);
  259. }
  260. return pdfManagerCapability.promise;
  261. }
  262. var pdfStream,
  263. cachedChunks = [];
  264. try {
  265. pdfStream = new _worker_stream.PDFWorkerStream(handler);
  266. } catch (ex) {
  267. pdfManagerCapability.reject(ex);
  268. return pdfManagerCapability.promise;
  269. }
  270. var fullRequest = pdfStream.getFullReader();
  271. fullRequest.headersReady.then(function () {
  272. if (!fullRequest.isRangeSupported) {
  273. return;
  274. }
  275. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  276. newPdfManager = new _pdf_manager.NetworkPdfManager(docId, pdfStream, {
  277. msgHandler: handler,
  278. password: source.password,
  279. length: fullRequest.contentLength,
  280. disableAutoFetch,
  281. rangeChunkSize: source.rangeChunkSize
  282. }, evaluatorOptions, docBaseUrl);
  283. for (let i = 0; i < cachedChunks.length; i++) {
  284. newPdfManager.sendProgressiveData(cachedChunks[i]);
  285. }
  286. cachedChunks = [];
  287. pdfManagerCapability.resolve(newPdfManager);
  288. cancelXHRs = null;
  289. }).catch(function (reason) {
  290. pdfManagerCapability.reject(reason);
  291. cancelXHRs = null;
  292. });
  293. var loaded = 0;
  294. var flushChunks = function () {
  295. var pdfFile = (0, _util.arraysToBytes)(cachedChunks);
  296. if (source.length && pdfFile.length !== source.length) {
  297. (0, _util.warn)("reported HTTP length is different from actual");
  298. }
  299. try {
  300. newPdfManager = new _pdf_manager.LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  301. pdfManagerCapability.resolve(newPdfManager);
  302. } catch (ex) {
  303. pdfManagerCapability.reject(ex);
  304. }
  305. cachedChunks = [];
  306. };
  307. var readPromise = new Promise(function (resolve, reject) {
  308. var readChunk = function ({
  309. value,
  310. done
  311. }) {
  312. try {
  313. ensureNotTerminated();
  314. if (done) {
  315. if (!newPdfManager) {
  316. flushChunks();
  317. }
  318. cancelXHRs = null;
  319. return;
  320. }
  321. loaded += (0, _util.arrayByteLength)(value);
  322. if (!fullRequest.isStreamingSupported) {
  323. handler.send("DocProgress", {
  324. loaded,
  325. total: Math.max(loaded, fullRequest.contentLength || 0)
  326. });
  327. }
  328. if (newPdfManager) {
  329. newPdfManager.sendProgressiveData(value);
  330. } else {
  331. cachedChunks.push(value);
  332. }
  333. fullRequest.read().then(readChunk, reject);
  334. } catch (e) {
  335. reject(e);
  336. }
  337. };
  338. fullRequest.read().then(readChunk, reject);
  339. });
  340. readPromise.catch(function (e) {
  341. pdfManagerCapability.reject(e);
  342. cancelXHRs = null;
  343. });
  344. cancelXHRs = function (reason) {
  345. pdfStream.cancelAllRequests(reason);
  346. };
  347. return pdfManagerCapability.promise;
  348. }
  349. function setupDoc(data) {
  350. function onSuccess(doc) {
  351. ensureNotTerminated();
  352. handler.send("GetDoc", {
  353. pdfInfo: doc
  354. });
  355. }
  356. function onFailure(ex) {
  357. ensureNotTerminated();
  358. if (ex instanceof _util.PasswordException) {
  359. var task = new WorkerTask(`PasswordException: response ${ex.code}`);
  360. startWorkerTask(task);
  361. handler.sendWithPromise("PasswordRequest", ex).then(function ({
  362. password
  363. }) {
  364. finishWorkerTask(task);
  365. pdfManager.updatePassword(password);
  366. pdfManagerReady();
  367. }).catch(function () {
  368. finishWorkerTask(task);
  369. handler.send("DocException", ex);
  370. });
  371. } else if (ex instanceof _util.InvalidPDFException || ex instanceof _util.MissingPDFException || ex instanceof _util.UnexpectedResponseException || ex instanceof _util.UnknownErrorException) {
  372. handler.send("DocException", ex);
  373. } else {
  374. handler.send("DocException", new _util.UnknownErrorException(ex.message, ex.toString()));
  375. }
  376. }
  377. function pdfManagerReady() {
  378. ensureNotTerminated();
  379. loadDocument(false).then(onSuccess, function (reason) {
  380. ensureNotTerminated();
  381. if (!(reason instanceof _core_utils.XRefParseException)) {
  382. onFailure(reason);
  383. return;
  384. }
  385. pdfManager.requestLoadedStream();
  386. pdfManager.onLoadedStream().then(function () {
  387. ensureNotTerminated();
  388. loadDocument(true).then(onSuccess, onFailure);
  389. });
  390. });
  391. }
  392. ensureNotTerminated();
  393. var evaluatorOptions = {
  394. maxImageSize: data.maxImageSize,
  395. disableFontFace: data.disableFontFace,
  396. ignoreErrors: data.ignoreErrors,
  397. isEvalSupported: data.isEvalSupported,
  398. fontExtraProperties: data.fontExtraProperties
  399. };
  400. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  401. if (terminated) {
  402. newPdfManager.terminate(new _util.AbortException("Worker was terminated."));
  403. throw new Error("Worker was terminated");
  404. }
  405. pdfManager = newPdfManager;
  406. pdfManager.onLoadedStream().then(function (stream) {
  407. handler.send("DataLoaded", {
  408. length: stream.bytes.byteLength
  409. });
  410. });
  411. }).then(pdfManagerReady, onFailure);
  412. }
  413. handler.on("GetPage", function wphSetupGetPage(data) {
  414. return pdfManager.getPage(data.pageIndex).then(function (page) {
  415. return Promise.all([pdfManager.ensure(page, "rotate"), pdfManager.ensure(page, "ref"), pdfManager.ensure(page, "userUnit"), pdfManager.ensure(page, "view")]).then(function ([rotate, ref, userUnit, view]) {
  416. return {
  417. rotate,
  418. ref,
  419. userUnit,
  420. view
  421. };
  422. });
  423. });
  424. });
  425. handler.on("GetPageIndex", function wphSetupGetPageIndex({
  426. ref
  427. }) {
  428. const pageRef = _primitives.Ref.get(ref.num, ref.gen);
  429. return pdfManager.ensureCatalog("getPageIndex", [pageRef]);
  430. });
  431. handler.on("GetDestinations", function wphSetupGetDestinations(data) {
  432. return pdfManager.ensureCatalog("destinations");
  433. });
  434. handler.on("GetDestination", function wphSetupGetDestination(data) {
  435. return pdfManager.ensureCatalog("getDestination", [data.id]);
  436. });
  437. handler.on("GetPageLabels", function wphSetupGetPageLabels(data) {
  438. return pdfManager.ensureCatalog("pageLabels");
  439. });
  440. handler.on("GetPageLayout", function wphSetupGetPageLayout(data) {
  441. return pdfManager.ensureCatalog("pageLayout");
  442. });
  443. handler.on("GetPageMode", function wphSetupGetPageMode(data) {
  444. return pdfManager.ensureCatalog("pageMode");
  445. });
  446. handler.on("GetViewerPreferences", function (data) {
  447. return pdfManager.ensureCatalog("viewerPreferences");
  448. });
  449. handler.on("GetOpenAction", function (data) {
  450. return pdfManager.ensureCatalog("openAction");
  451. });
  452. handler.on("GetAttachments", function wphSetupGetAttachments(data) {
  453. return pdfManager.ensureCatalog("attachments");
  454. });
  455. handler.on("GetJavaScript", function wphSetupGetJavaScript(data) {
  456. return pdfManager.ensureCatalog("javaScript");
  457. });
  458. handler.on("GetOutline", function wphSetupGetOutline(data) {
  459. return pdfManager.ensureCatalog("documentOutline");
  460. });
  461. handler.on("GetOptionalContentConfig", function (data) {
  462. return pdfManager.ensureCatalog("optionalContentConfig");
  463. });
  464. handler.on("GetPermissions", function (data) {
  465. return pdfManager.ensureCatalog("permissions");
  466. });
  467. handler.on("GetMetadata", function wphSetupGetMetadata(data) {
  468. return Promise.all([pdfManager.ensureDoc("documentInfo"), pdfManager.ensureCatalog("metadata")]);
  469. });
  470. handler.on("GetData", function wphSetupGetData(data) {
  471. pdfManager.requestLoadedStream();
  472. return pdfManager.onLoadedStream().then(function (stream) {
  473. return stream.bytes;
  474. });
  475. });
  476. handler.on("GetStats", function wphSetupGetStats(data) {
  477. return pdfManager.ensureXRef("stats");
  478. });
  479. handler.on("GetAnnotations", function ({
  480. pageIndex,
  481. intent
  482. }) {
  483. return pdfManager.getPage(pageIndex).then(function (page) {
  484. return page.getAnnotationsData(intent);
  485. });
  486. });
  487. handler.on("SaveDocument", function ({
  488. numPages,
  489. annotationStorage,
  490. filename
  491. }) {
  492. pdfManager.requestLoadedStream();
  493. const promises = [pdfManager.onLoadedStream()];
  494. const document = pdfManager.pdfDocument;
  495. for (let pageIndex = 0; pageIndex < numPages; pageIndex++) {
  496. promises.push(pdfManager.getPage(pageIndex).then(function (page) {
  497. const task = new WorkerTask(`Save: page ${pageIndex}`);
  498. return page.save(handler, task, annotationStorage);
  499. }));
  500. }
  501. return Promise.all(promises).then(([stream, ...refs]) => {
  502. let newRefs = [];
  503. for (const ref of refs) {
  504. newRefs = ref.filter(x => x !== null).reduce((a, b) => a.concat(b), newRefs);
  505. }
  506. if (newRefs.length === 0) {
  507. return stream.bytes;
  508. }
  509. const xref = document.xref;
  510. let newXrefInfo = Object.create(null);
  511. if (xref.trailer) {
  512. const _info = Object.create(null);
  513. const xrefInfo = xref.trailer.get("Info") || null;
  514. if (xrefInfo) {
  515. xrefInfo.forEach((key, value) => {
  516. if ((0, _util.isString)(key) && (0, _util.isString)(value)) {
  517. _info[key] = (0, _util.stringToPDFString)(value);
  518. }
  519. });
  520. }
  521. newXrefInfo = {
  522. rootRef: xref.trailer.getRaw("Root") || null,
  523. encrypt: xref.trailer.getRaw("Encrypt") || null,
  524. newRef: xref.getNewRef(),
  525. infoRef: xref.trailer.getRaw("Info") || null,
  526. info: _info,
  527. fileIds: xref.trailer.getRaw("ID") || null,
  528. startXRef: document.startXRef,
  529. filename
  530. };
  531. }
  532. xref.resetNewRef();
  533. return (0, _writer.incrementalUpdate)(stream.bytes, newXrefInfo, newRefs);
  534. });
  535. });
  536. handler.on("GetOperatorList", function wphSetupRenderPage(data, sink) {
  537. var pageIndex = data.pageIndex;
  538. pdfManager.getPage(pageIndex).then(function (page) {
  539. var task = new WorkerTask(`GetOperatorList: page ${pageIndex}`);
  540. startWorkerTask(task);
  541. const start = verbosity >= _util.VerbosityLevel.INFOS ? Date.now() : 0;
  542. page.getOperatorList({
  543. handler,
  544. sink,
  545. task,
  546. intent: data.intent,
  547. renderInteractiveForms: data.renderInteractiveForms,
  548. annotationStorage: data.annotationStorage
  549. }).then(function (operatorListInfo) {
  550. finishWorkerTask(task);
  551. if (start) {
  552. (0, _util.info)(`page=${pageIndex + 1} - getOperatorList: time=` + `${Date.now() - start}ms, len=${operatorListInfo.length}`);
  553. }
  554. sink.close();
  555. }, function (reason) {
  556. finishWorkerTask(task);
  557. if (task.terminated) {
  558. return;
  559. }
  560. handler.send("UnsupportedFeature", {
  561. featureId: _util.UNSUPPORTED_FEATURES.errorOperatorList
  562. });
  563. sink.error(reason);
  564. });
  565. });
  566. }, this);
  567. handler.on("GetTextContent", function wphExtractText(data, sink) {
  568. var pageIndex = data.pageIndex;
  569. sink.onPull = function (desiredSize) {};
  570. sink.onCancel = function (reason) {};
  571. pdfManager.getPage(pageIndex).then(function (page) {
  572. var task = new WorkerTask("GetTextContent: page " + pageIndex);
  573. startWorkerTask(task);
  574. const start = verbosity >= _util.VerbosityLevel.INFOS ? Date.now() : 0;
  575. page.extractTextContent({
  576. handler,
  577. task,
  578. sink,
  579. normalizeWhitespace: data.normalizeWhitespace,
  580. combineTextItems: data.combineTextItems
  581. }).then(function () {
  582. finishWorkerTask(task);
  583. if (start) {
  584. (0, _util.info)(`page=${pageIndex + 1} - getTextContent: time=` + `${Date.now() - start}ms`);
  585. }
  586. sink.close();
  587. }, function (reason) {
  588. finishWorkerTask(task);
  589. if (task.terminated) {
  590. return;
  591. }
  592. sink.error(reason);
  593. });
  594. });
  595. });
  596. handler.on("FontFallback", function (data) {
  597. return pdfManager.fontFallback(data.id, handler);
  598. });
  599. handler.on("Cleanup", function wphCleanup(data) {
  600. return pdfManager.cleanup(true);
  601. });
  602. handler.on("Terminate", function wphTerminate(data) {
  603. terminated = true;
  604. const waitOn = [];
  605. if (pdfManager) {
  606. pdfManager.terminate(new _util.AbortException("Worker was terminated."));
  607. const cleanupPromise = pdfManager.cleanup();
  608. waitOn.push(cleanupPromise);
  609. pdfManager = null;
  610. } else {
  611. (0, _primitives.clearPrimitiveCaches)();
  612. }
  613. if (cancelXHRs) {
  614. cancelXHRs(new _util.AbortException("Worker was terminated."));
  615. }
  616. WorkerTasks.forEach(function (task) {
  617. waitOn.push(task.finished);
  618. task.terminate();
  619. });
  620. return Promise.all(waitOn).then(function () {
  621. handler.destroy();
  622. handler = null;
  623. });
  624. });
  625. handler.on("Ready", function wphReady(data) {
  626. setupDoc(docParams);
  627. docParams = null;
  628. });
  629. return workerHandlerName;
  630. }
  631. static initializeFromPort(port) {
  632. var handler = new _message_handler.MessageHandler("worker", "main", port);
  633. WorkerMessageHandler.setup(handler, port);
  634. handler.send("ready", null);
  635. }
  636. }
  637. exports.WorkerMessageHandler = WorkerMessageHandler;
  638. function isMessagePort(maybePort) {
  639. return typeof maybePort.postMessage === "function" && "onmessage" in maybePort;
  640. }
  641. if (typeof window === "undefined" && !_is_node.isNodeJS && typeof self !== "undefined" && isMessagePort(self)) {
  642. WorkerMessageHandler.initializeFromPort(self);
  643. }
  644. /***/ }),
  645. /* 2 */
  646. /***/ (function(module, exports, __w_pdfjs_require__) {
  647. "use strict";
  648. Object.defineProperty(exports, "__esModule", {
  649. value: true
  650. });
  651. exports.arrayByteLength = arrayByteLength;
  652. exports.arraysToBytes = arraysToBytes;
  653. exports.assert = assert;
  654. exports.bytesToString = bytesToString;
  655. exports.createPromiseCapability = createPromiseCapability;
  656. exports.escapeString = escapeString;
  657. exports.getModificationDate = getModificationDate;
  658. exports.getVerbosityLevel = getVerbosityLevel;
  659. exports.info = info;
  660. exports.isArrayBuffer = isArrayBuffer;
  661. exports.isArrayEqual = isArrayEqual;
  662. exports.isBool = isBool;
  663. exports.isNum = isNum;
  664. exports.isString = isString;
  665. exports.isSameOrigin = isSameOrigin;
  666. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  667. exports.removeNullCharacters = removeNullCharacters;
  668. exports.setVerbosityLevel = setVerbosityLevel;
  669. exports.shadow = shadow;
  670. exports.string32 = string32;
  671. exports.stringToBytes = stringToBytes;
  672. exports.stringToPDFString = stringToPDFString;
  673. exports.stringToUTF8String = stringToUTF8String;
  674. exports.utf8StringToString = utf8StringToString;
  675. exports.warn = warn;
  676. exports.unreachable = unreachable;
  677. exports.IsEvalSupportedCached = exports.IsLittleEndianCached = exports.createObjectURL = exports.FormatError = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.MissingPDFException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationStateModelType = exports.AnnotationReviewState = exports.AnnotationReplyType = exports.AnnotationMarkedState = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = exports.BaseException = void 0;
  678. __w_pdfjs_require__(3);
  679. const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
  680. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  681. const FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
  682. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  683. const PermissionFlag = {
  684. PRINT: 0x04,
  685. MODIFY_CONTENTS: 0x08,
  686. COPY: 0x10,
  687. MODIFY_ANNOTATIONS: 0x20,
  688. FILL_INTERACTIVE_FORMS: 0x100,
  689. COPY_FOR_ACCESSIBILITY: 0x200,
  690. ASSEMBLE: 0x400,
  691. PRINT_HIGH_QUALITY: 0x800
  692. };
  693. exports.PermissionFlag = PermissionFlag;
  694. const TextRenderingMode = {
  695. FILL: 0,
  696. STROKE: 1,
  697. FILL_STROKE: 2,
  698. INVISIBLE: 3,
  699. FILL_ADD_TO_PATH: 4,
  700. STROKE_ADD_TO_PATH: 5,
  701. FILL_STROKE_ADD_TO_PATH: 6,
  702. ADD_TO_PATH: 7,
  703. FILL_STROKE_MASK: 3,
  704. ADD_TO_PATH_FLAG: 4
  705. };
  706. exports.TextRenderingMode = TextRenderingMode;
  707. const ImageKind = {
  708. GRAYSCALE_1BPP: 1,
  709. RGB_24BPP: 2,
  710. RGBA_32BPP: 3
  711. };
  712. exports.ImageKind = ImageKind;
  713. const AnnotationType = {
  714. TEXT: 1,
  715. LINK: 2,
  716. FREETEXT: 3,
  717. LINE: 4,
  718. SQUARE: 5,
  719. CIRCLE: 6,
  720. POLYGON: 7,
  721. POLYLINE: 8,
  722. HIGHLIGHT: 9,
  723. UNDERLINE: 10,
  724. SQUIGGLY: 11,
  725. STRIKEOUT: 12,
  726. STAMP: 13,
  727. CARET: 14,
  728. INK: 15,
  729. POPUP: 16,
  730. FILEATTACHMENT: 17,
  731. SOUND: 18,
  732. MOVIE: 19,
  733. WIDGET: 20,
  734. SCREEN: 21,
  735. PRINTERMARK: 22,
  736. TRAPNET: 23,
  737. WATERMARK: 24,
  738. THREED: 25,
  739. REDACT: 26
  740. };
  741. exports.AnnotationType = AnnotationType;
  742. const AnnotationStateModelType = {
  743. MARKED: "Marked",
  744. REVIEW: "Review"
  745. };
  746. exports.AnnotationStateModelType = AnnotationStateModelType;
  747. const AnnotationMarkedState = {
  748. MARKED: "Marked",
  749. UNMARKED: "Unmarked"
  750. };
  751. exports.AnnotationMarkedState = AnnotationMarkedState;
  752. const AnnotationReviewState = {
  753. ACCEPTED: "Accepted",
  754. REJECTED: "Rejected",
  755. CANCELLED: "Cancelled",
  756. COMPLETED: "Completed",
  757. NONE: "None"
  758. };
  759. exports.AnnotationReviewState = AnnotationReviewState;
  760. const AnnotationReplyType = {
  761. GROUP: "Group",
  762. REPLY: "R"
  763. };
  764. exports.AnnotationReplyType = AnnotationReplyType;
  765. const AnnotationFlag = {
  766. INVISIBLE: 0x01,
  767. HIDDEN: 0x02,
  768. PRINT: 0x04,
  769. NOZOOM: 0x08,
  770. NOROTATE: 0x10,
  771. NOVIEW: 0x20,
  772. READONLY: 0x40,
  773. LOCKED: 0x80,
  774. TOGGLENOVIEW: 0x100,
  775. LOCKEDCONTENTS: 0x200
  776. };
  777. exports.AnnotationFlag = AnnotationFlag;
  778. const AnnotationFieldFlag = {
  779. READONLY: 0x0000001,
  780. REQUIRED: 0x0000002,
  781. NOEXPORT: 0x0000004,
  782. MULTILINE: 0x0001000,
  783. PASSWORD: 0x0002000,
  784. NOTOGGLETOOFF: 0x0004000,
  785. RADIO: 0x0008000,
  786. PUSHBUTTON: 0x0010000,
  787. COMBO: 0x0020000,
  788. EDIT: 0x0040000,
  789. SORT: 0x0080000,
  790. FILESELECT: 0x0100000,
  791. MULTISELECT: 0x0200000,
  792. DONOTSPELLCHECK: 0x0400000,
  793. DONOTSCROLL: 0x0800000,
  794. COMB: 0x1000000,
  795. RICHTEXT: 0x2000000,
  796. RADIOSINUNISON: 0x2000000,
  797. COMMITONSELCHANGE: 0x4000000
  798. };
  799. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  800. const AnnotationBorderStyleType = {
  801. SOLID: 1,
  802. DASHED: 2,
  803. BEVELED: 3,
  804. INSET: 4,
  805. UNDERLINE: 5
  806. };
  807. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  808. const StreamType = {
  809. UNKNOWN: "UNKNOWN",
  810. FLATE: "FLATE",
  811. LZW: "LZW",
  812. DCT: "DCT",
  813. JPX: "JPX",
  814. JBIG: "JBIG",
  815. A85: "A85",
  816. AHX: "AHX",
  817. CCF: "CCF",
  818. RLX: "RLX"
  819. };
  820. exports.StreamType = StreamType;
  821. const FontType = {
  822. UNKNOWN: "UNKNOWN",
  823. TYPE1: "TYPE1",
  824. TYPE1C: "TYPE1C",
  825. CIDFONTTYPE0: "CIDFONTTYPE0",
  826. CIDFONTTYPE0C: "CIDFONTTYPE0C",
  827. TRUETYPE: "TRUETYPE",
  828. CIDFONTTYPE2: "CIDFONTTYPE2",
  829. TYPE3: "TYPE3",
  830. OPENTYPE: "OPENTYPE",
  831. TYPE0: "TYPE0",
  832. MMTYPE1: "MMTYPE1"
  833. };
  834. exports.FontType = FontType;
  835. const VerbosityLevel = {
  836. ERRORS: 0,
  837. WARNINGS: 1,
  838. INFOS: 5
  839. };
  840. exports.VerbosityLevel = VerbosityLevel;
  841. const CMapCompressionType = {
  842. NONE: 0,
  843. BINARY: 1,
  844. STREAM: 2
  845. };
  846. exports.CMapCompressionType = CMapCompressionType;
  847. const OPS = {
  848. dependency: 1,
  849. setLineWidth: 2,
  850. setLineCap: 3,
  851. setLineJoin: 4,
  852. setMiterLimit: 5,
  853. setDash: 6,
  854. setRenderingIntent: 7,
  855. setFlatness: 8,
  856. setGState: 9,
  857. save: 10,
  858. restore: 11,
  859. transform: 12,
  860. moveTo: 13,
  861. lineTo: 14,
  862. curveTo: 15,
  863. curveTo2: 16,
  864. curveTo3: 17,
  865. closePath: 18,
  866. rectangle: 19,
  867. stroke: 20,
  868. closeStroke: 21,
  869. fill: 22,
  870. eoFill: 23,
  871. fillStroke: 24,
  872. eoFillStroke: 25,
  873. closeFillStroke: 26,
  874. closeEOFillStroke: 27,
  875. endPath: 28,
  876. clip: 29,
  877. eoClip: 30,
  878. beginText: 31,
  879. endText: 32,
  880. setCharSpacing: 33,
  881. setWordSpacing: 34,
  882. setHScale: 35,
  883. setLeading: 36,
  884. setFont: 37,
  885. setTextRenderingMode: 38,
  886. setTextRise: 39,
  887. moveText: 40,
  888. setLeadingMoveText: 41,
  889. setTextMatrix: 42,
  890. nextLine: 43,
  891. showText: 44,
  892. showSpacedText: 45,
  893. nextLineShowText: 46,
  894. nextLineSetSpacingShowText: 47,
  895. setCharWidth: 48,
  896. setCharWidthAndBounds: 49,
  897. setStrokeColorSpace: 50,
  898. setFillColorSpace: 51,
  899. setStrokeColor: 52,
  900. setStrokeColorN: 53,
  901. setFillColor: 54,
  902. setFillColorN: 55,
  903. setStrokeGray: 56,
  904. setFillGray: 57,
  905. setStrokeRGBColor: 58,
  906. setFillRGBColor: 59,
  907. setStrokeCMYKColor: 60,
  908. setFillCMYKColor: 61,
  909. shadingFill: 62,
  910. beginInlineImage: 63,
  911. beginImageData: 64,
  912. endInlineImage: 65,
  913. paintXObject: 66,
  914. markPoint: 67,
  915. markPointProps: 68,
  916. beginMarkedContent: 69,
  917. beginMarkedContentProps: 70,
  918. endMarkedContent: 71,
  919. beginCompat: 72,
  920. endCompat: 73,
  921. paintFormXObjectBegin: 74,
  922. paintFormXObjectEnd: 75,
  923. beginGroup: 76,
  924. endGroup: 77,
  925. beginAnnotations: 78,
  926. endAnnotations: 79,
  927. beginAnnotation: 80,
  928. endAnnotation: 81,
  929. paintJpegXObject: 82,
  930. paintImageMaskXObject: 83,
  931. paintImageMaskXObjectGroup: 84,
  932. paintImageXObject: 85,
  933. paintInlineImageXObject: 86,
  934. paintInlineImageXObjectGroup: 87,
  935. paintImageXObjectRepeat: 88,
  936. paintImageMaskXObjectRepeat: 89,
  937. paintSolidColorImageMask: 90,
  938. constructPath: 91
  939. };
  940. exports.OPS = OPS;
  941. const UNSUPPORTED_FEATURES = {
  942. unknown: "unknown",
  943. forms: "forms",
  944. javaScript: "javaScript",
  945. smask: "smask",
  946. shadingPattern: "shadingPattern",
  947. font: "font",
  948. errorTilingPattern: "errorTilingPattern",
  949. errorExtGState: "errorExtGState",
  950. errorXObject: "errorXObject",
  951. errorFontLoadType3: "errorFontLoadType3",
  952. errorFontState: "errorFontState",
  953. errorFontMissing: "errorFontMissing",
  954. errorFontTranslate: "errorFontTranslate",
  955. errorColorSpace: "errorColorSpace",
  956. errorOperatorList: "errorOperatorList",
  957. errorFontToUnicode: "errorFontToUnicode",
  958. errorFontLoadNative: "errorFontLoadNative",
  959. errorFontGetPath: "errorFontGetPath",
  960. errorMarkedContent: "errorMarkedContent"
  961. };
  962. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  963. const PasswordResponses = {
  964. NEED_PASSWORD: 1,
  965. INCORRECT_PASSWORD: 2
  966. };
  967. exports.PasswordResponses = PasswordResponses;
  968. let verbosity = VerbosityLevel.WARNINGS;
  969. function setVerbosityLevel(level) {
  970. if (Number.isInteger(level)) {
  971. verbosity = level;
  972. }
  973. }
  974. function getVerbosityLevel() {
  975. return verbosity;
  976. }
  977. function info(msg) {
  978. if (verbosity >= VerbosityLevel.INFOS) {
  979. console.log(`Info: ${msg}`);
  980. }
  981. }
  982. function warn(msg) {
  983. if (verbosity >= VerbosityLevel.WARNINGS) {
  984. console.log(`Warning: ${msg}`);
  985. }
  986. }
  987. function unreachable(msg) {
  988. throw new Error(msg);
  989. }
  990. function assert(cond, msg) {
  991. if (!cond) {
  992. unreachable(msg);
  993. }
  994. }
  995. function isSameOrigin(baseUrl, otherUrl) {
  996. let base;
  997. try {
  998. base = new URL(baseUrl);
  999. if (!base.origin || base.origin === "null") {
  1000. return false;
  1001. }
  1002. } catch (e) {
  1003. return false;
  1004. }
  1005. const other = new URL(otherUrl, base);
  1006. return base.origin === other.origin;
  1007. }
  1008. function _isValidProtocol(url) {
  1009. if (!url) {
  1010. return false;
  1011. }
  1012. switch (url.protocol) {
  1013. case "http:":
  1014. case "https:":
  1015. case "ftp:":
  1016. case "mailto:":
  1017. case "tel:":
  1018. return true;
  1019. default:
  1020. return false;
  1021. }
  1022. }
  1023. function createValidAbsoluteUrl(url, baseUrl) {
  1024. if (!url) {
  1025. return null;
  1026. }
  1027. try {
  1028. const absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  1029. if (_isValidProtocol(absoluteUrl)) {
  1030. return absoluteUrl;
  1031. }
  1032. } catch (ex) {}
  1033. return null;
  1034. }
  1035. function shadow(obj, prop, value) {
  1036. Object.defineProperty(obj, prop, {
  1037. value,
  1038. enumerable: true,
  1039. configurable: true,
  1040. writable: false
  1041. });
  1042. return value;
  1043. }
  1044. const BaseException = function BaseExceptionClosure() {
  1045. function BaseException(message) {
  1046. if (this.constructor === BaseException) {
  1047. unreachable("Cannot initialize BaseException.");
  1048. }
  1049. this.message = message;
  1050. this.name = this.constructor.name;
  1051. }
  1052. BaseException.prototype = new Error();
  1053. BaseException.constructor = BaseException;
  1054. return BaseException;
  1055. }();
  1056. exports.BaseException = BaseException;
  1057. class PasswordException extends BaseException {
  1058. constructor(msg, code) {
  1059. super(msg);
  1060. this.code = code;
  1061. }
  1062. }
  1063. exports.PasswordException = PasswordException;
  1064. class UnknownErrorException extends BaseException {
  1065. constructor(msg, details) {
  1066. super(msg);
  1067. this.details = details;
  1068. }
  1069. }
  1070. exports.UnknownErrorException = UnknownErrorException;
  1071. class InvalidPDFException extends BaseException {}
  1072. exports.InvalidPDFException = InvalidPDFException;
  1073. class MissingPDFException extends BaseException {}
  1074. exports.MissingPDFException = MissingPDFException;
  1075. class UnexpectedResponseException extends BaseException {
  1076. constructor(msg, status) {
  1077. super(msg);
  1078. this.status = status;
  1079. }
  1080. }
  1081. exports.UnexpectedResponseException = UnexpectedResponseException;
  1082. class FormatError extends BaseException {}
  1083. exports.FormatError = FormatError;
  1084. class AbortException extends BaseException {}
  1085. exports.AbortException = AbortException;
  1086. const NullCharactersRegExp = /\x00/g;
  1087. function removeNullCharacters(str) {
  1088. if (typeof str !== "string") {
  1089. warn("The argument for removeNullCharacters must be a string.");
  1090. return str;
  1091. }
  1092. return str.replace(NullCharactersRegExp, "");
  1093. }
  1094. function bytesToString(bytes) {
  1095. assert(bytes !== null && typeof bytes === "object" && bytes.length !== undefined, "Invalid argument for bytesToString");
  1096. const length = bytes.length;
  1097. const MAX_ARGUMENT_COUNT = 8192;
  1098. if (length < MAX_ARGUMENT_COUNT) {
  1099. return String.fromCharCode.apply(null, bytes);
  1100. }
  1101. const strBuf = [];
  1102. for (let i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  1103. const chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  1104. const chunk = bytes.subarray(i, chunkEnd);
  1105. strBuf.push(String.fromCharCode.apply(null, chunk));
  1106. }
  1107. return strBuf.join("");
  1108. }
  1109. function stringToBytes(str) {
  1110. assert(typeof str === "string", "Invalid argument for stringToBytes");
  1111. const length = str.length;
  1112. const bytes = new Uint8Array(length);
  1113. for (let i = 0; i < length; ++i) {
  1114. bytes[i] = str.charCodeAt(i) & 0xff;
  1115. }
  1116. return bytes;
  1117. }
  1118. function arrayByteLength(arr) {
  1119. if (arr.length !== undefined) {
  1120. return arr.length;
  1121. }
  1122. assert(arr.byteLength !== undefined, "arrayByteLength - invalid argument.");
  1123. return arr.byteLength;
  1124. }
  1125. function arraysToBytes(arr) {
  1126. const length = arr.length;
  1127. if (length === 1 && arr[0] instanceof Uint8Array) {
  1128. return arr[0];
  1129. }
  1130. let resultLength = 0;
  1131. for (let i = 0; i < length; i++) {
  1132. resultLength += arrayByteLength(arr[i]);
  1133. }
  1134. let pos = 0;
  1135. const data = new Uint8Array(resultLength);
  1136. for (let i = 0; i < length; i++) {
  1137. let item = arr[i];
  1138. if (!(item instanceof Uint8Array)) {
  1139. if (typeof item === "string") {
  1140. item = stringToBytes(item);
  1141. } else {
  1142. item = new Uint8Array(item);
  1143. }
  1144. }
  1145. const itemLength = item.byteLength;
  1146. data.set(item, pos);
  1147. pos += itemLength;
  1148. }
  1149. return data;
  1150. }
  1151. function string32(value) {
  1152. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  1153. }
  1154. function isLittleEndian() {
  1155. const buffer8 = new Uint8Array(4);
  1156. buffer8[0] = 1;
  1157. const view32 = new Uint32Array(buffer8.buffer, 0, 1);
  1158. return view32[0] === 1;
  1159. }
  1160. const IsLittleEndianCached = {
  1161. get value() {
  1162. return shadow(this, "value", isLittleEndian());
  1163. }
  1164. };
  1165. exports.IsLittleEndianCached = IsLittleEndianCached;
  1166. function isEvalSupported() {
  1167. try {
  1168. new Function("");
  1169. return true;
  1170. } catch (e) {
  1171. return false;
  1172. }
  1173. }
  1174. const IsEvalSupportedCached = {
  1175. get value() {
  1176. return shadow(this, "value", isEvalSupported());
  1177. }
  1178. };
  1179. exports.IsEvalSupportedCached = IsEvalSupportedCached;
  1180. const rgbBuf = ["rgb(", 0, ",", 0, ",", 0, ")"];
  1181. class Util {
  1182. static makeCssRgb(r, g, b) {
  1183. rgbBuf[1] = r;
  1184. rgbBuf[3] = g;
  1185. rgbBuf[5] = b;
  1186. return rgbBuf.join("");
  1187. }
  1188. static transform(m1, m2) {
  1189. 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]];
  1190. }
  1191. static applyTransform(p, m) {
  1192. const xt = p[0] * m[0] + p[1] * m[2] + m[4];
  1193. const yt = p[0] * m[1] + p[1] * m[3] + m[5];
  1194. return [xt, yt];
  1195. }
  1196. static applyInverseTransform(p, m) {
  1197. const d = m[0] * m[3] - m[1] * m[2];
  1198. const xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  1199. const yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  1200. return [xt, yt];
  1201. }
  1202. static getAxialAlignedBoundingBox(r, m) {
  1203. const p1 = Util.applyTransform(r, m);
  1204. const p2 = Util.applyTransform(r.slice(2, 4), m);
  1205. const p3 = Util.applyTransform([r[0], r[3]], m);
  1206. const p4 = Util.applyTransform([r[2], r[1]], m);
  1207. 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])];
  1208. }
  1209. static inverseTransform(m) {
  1210. const d = m[0] * m[3] - m[1] * m[2];
  1211. 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];
  1212. }
  1213. static apply3dTransform(m, v) {
  1214. 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]];
  1215. }
  1216. static singularValueDecompose2dScale(m) {
  1217. const transpose = [m[0], m[2], m[1], m[3]];
  1218. const a = m[0] * transpose[0] + m[1] * transpose[2];
  1219. const b = m[0] * transpose[1] + m[1] * transpose[3];
  1220. const c = m[2] * transpose[0] + m[3] * transpose[2];
  1221. const d = m[2] * transpose[1] + m[3] * transpose[3];
  1222. const first = (a + d) / 2;
  1223. const second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  1224. const sx = first + second || 1;
  1225. const sy = first - second || 1;
  1226. return [Math.sqrt(sx), Math.sqrt(sy)];
  1227. }
  1228. static normalizeRect(rect) {
  1229. const r = rect.slice(0);
  1230. if (rect[0] > rect[2]) {
  1231. r[0] = rect[2];
  1232. r[2] = rect[0];
  1233. }
  1234. if (rect[1] > rect[3]) {
  1235. r[1] = rect[3];
  1236. r[3] = rect[1];
  1237. }
  1238. return r;
  1239. }
  1240. static intersect(rect1, rect2) {
  1241. function compare(a, b) {
  1242. return a - b;
  1243. }
  1244. const orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare);
  1245. const orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare);
  1246. const result = [];
  1247. rect1 = Util.normalizeRect(rect1);
  1248. rect2 = Util.normalizeRect(rect2);
  1249. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  1250. result[0] = orderedX[1];
  1251. result[2] = orderedX[2];
  1252. } else {
  1253. return null;
  1254. }
  1255. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  1256. result[1] = orderedY[1];
  1257. result[3] = orderedY[2];
  1258. } else {
  1259. return null;
  1260. }
  1261. return result;
  1262. }
  1263. }
  1264. exports.Util = Util;
  1265. const 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];
  1266. function stringToPDFString(str) {
  1267. const length = str.length,
  1268. strBuf = [];
  1269. if (str[0] === "\xFE" && str[1] === "\xFF") {
  1270. for (let i = 2; i < length; i += 2) {
  1271. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  1272. }
  1273. } else if (str[0] === "\xFF" && str[1] === "\xFE") {
  1274. for (let i = 2; i < length; i += 2) {
  1275. strBuf.push(String.fromCharCode(str.charCodeAt(i + 1) << 8 | str.charCodeAt(i)));
  1276. }
  1277. } else {
  1278. for (let i = 0; i < length; ++i) {
  1279. const code = PDFStringTranslateTable[str.charCodeAt(i)];
  1280. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  1281. }
  1282. }
  1283. return strBuf.join("");
  1284. }
  1285. function escapeString(str) {
  1286. return str.replace(/([\(\)\\])/g, "\\$1");
  1287. }
  1288. function stringToUTF8String(str) {
  1289. return decodeURIComponent(escape(str));
  1290. }
  1291. function utf8StringToString(str) {
  1292. return unescape(encodeURIComponent(str));
  1293. }
  1294. function isBool(v) {
  1295. return typeof v === "boolean";
  1296. }
  1297. function isNum(v) {
  1298. return typeof v === "number";
  1299. }
  1300. function isString(v) {
  1301. return typeof v === "string";
  1302. }
  1303. function isArrayBuffer(v) {
  1304. return typeof v === "object" && v !== null && v.byteLength !== undefined;
  1305. }
  1306. function isArrayEqual(arr1, arr2) {
  1307. if (arr1.length !== arr2.length) {
  1308. return false;
  1309. }
  1310. return arr1.every(function (element, index) {
  1311. return element === arr2[index];
  1312. });
  1313. }
  1314. function getModificationDate(date = new Date(Date.now())) {
  1315. const buffer = [date.getUTCFullYear().toString(), (date.getUTCMonth() + 1).toString().padStart(2, "0"), (date.getUTCDate() + 1).toString().padStart(2, "0"), date.getUTCHours().toString().padStart(2, "0"), date.getUTCMinutes().toString().padStart(2, "0"), date.getUTCSeconds().toString().padStart(2, "0")];
  1316. return buffer.join("");
  1317. }
  1318. function createPromiseCapability() {
  1319. const capability = Object.create(null);
  1320. let isSettled = false;
  1321. Object.defineProperty(capability, "settled", {
  1322. get() {
  1323. return isSettled;
  1324. }
  1325. });
  1326. capability.promise = new Promise(function (resolve, reject) {
  1327. capability.resolve = function (data) {
  1328. isSettled = true;
  1329. resolve(data);
  1330. };
  1331. capability.reject = function (reason) {
  1332. isSettled = true;
  1333. reject(reason);
  1334. };
  1335. });
  1336. return capability;
  1337. }
  1338. const createObjectURL = function createObjectURLClosure() {
  1339. const digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  1340. return function createObjectURL(data, contentType, forceDataSchema = false) {
  1341. if (!forceDataSchema && URL.createObjectURL) {
  1342. const blob = new Blob([data], {
  1343. type: contentType
  1344. });
  1345. return URL.createObjectURL(blob);
  1346. }
  1347. let buffer = `data:${contentType};base64,`;
  1348. for (let i = 0, ii = data.length; i < ii; i += 3) {
  1349. const b1 = data[i] & 0xff;
  1350. const b2 = data[i + 1] & 0xff;
  1351. const b3 = data[i + 2] & 0xff;
  1352. const d1 = b1 >> 2,
  1353. d2 = (b1 & 3) << 4 | b2 >> 4;
  1354. const d3 = i + 1 < ii ? (b2 & 0xf) << 2 | b3 >> 6 : 64;
  1355. const d4 = i + 2 < ii ? b3 & 0x3f : 64;
  1356. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  1357. }
  1358. return buffer;
  1359. };
  1360. }();
  1361. exports.createObjectURL = createObjectURL;
  1362. /***/ }),
  1363. /* 3 */
  1364. /***/ (function(module, exports, __w_pdfjs_require__) {
  1365. "use strict";
  1366. var _is_node = __w_pdfjs_require__(4);
  1367. ;
  1368. /***/ }),
  1369. /* 4 */
  1370. /***/ (function(module, exports, __w_pdfjs_require__) {
  1371. "use strict";
  1372. Object.defineProperty(exports, "__esModule", {
  1373. value: true
  1374. });
  1375. exports.isNodeJS = void 0;
  1376. const isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
  1377. exports.isNodeJS = isNodeJS;
  1378. /***/ }),
  1379. /* 5 */
  1380. /***/ (function(module, exports, __w_pdfjs_require__) {
  1381. "use strict";
  1382. Object.defineProperty(exports, "__esModule", {
  1383. value: true
  1384. });
  1385. exports.clearPrimitiveCaches = clearPrimitiveCaches;
  1386. exports.isEOF = isEOF;
  1387. exports.isCmd = isCmd;
  1388. exports.isDict = isDict;
  1389. exports.isName = isName;
  1390. exports.isRef = isRef;
  1391. exports.isRefsEqual = isRefsEqual;
  1392. exports.isStream = isStream;
  1393. exports.RefSetCache = exports.RefSet = exports.Ref = exports.Name = exports.Dict = exports.Cmd = exports.EOF = void 0;
  1394. var _util = __w_pdfjs_require__(2);
  1395. var EOF = {};
  1396. exports.EOF = EOF;
  1397. var Name = function NameClosure() {
  1398. let nameCache = Object.create(null);
  1399. function Name(name) {
  1400. this.name = name;
  1401. }
  1402. Name.prototype = {};
  1403. Name.get = function Name_get(name) {
  1404. var nameValue = nameCache[name];
  1405. return nameValue ? nameValue : nameCache[name] = new Name(name);
  1406. };
  1407. Name._clearCache = function () {
  1408. nameCache = Object.create(null);
  1409. };
  1410. return Name;
  1411. }();
  1412. exports.Name = Name;
  1413. var Cmd = function CmdClosure() {
  1414. let cmdCache = Object.create(null);
  1415. function Cmd(cmd) {
  1416. this.cmd = cmd;
  1417. }
  1418. Cmd.prototype = {};
  1419. Cmd.get = function Cmd_get(cmd) {
  1420. var cmdValue = cmdCache[cmd];
  1421. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  1422. };
  1423. Cmd._clearCache = function () {
  1424. cmdCache = Object.create(null);
  1425. };
  1426. return Cmd;
  1427. }();
  1428. exports.Cmd = Cmd;
  1429. var Dict = function DictClosure() {
  1430. var nonSerializable = function nonSerializableClosure() {
  1431. return nonSerializable;
  1432. };
  1433. function Dict(xref) {
  1434. this._map = Object.create(null);
  1435. this.xref = xref;
  1436. this.objId = null;
  1437. this.suppressEncryption = false;
  1438. this.__nonSerializable__ = nonSerializable;
  1439. }
  1440. Dict.prototype = {
  1441. assignXref: function Dict_assignXref(newXref) {
  1442. this.xref = newXref;
  1443. },
  1444. get size() {
  1445. return Object.keys(this._map).length;
  1446. },
  1447. get(key1, key2, key3) {
  1448. let value = this._map[key1];
  1449. if (value === undefined && key2 !== undefined) {
  1450. value = this._map[key2];
  1451. if (value === undefined && key3 !== undefined) {
  1452. value = this._map[key3];
  1453. }
  1454. }
  1455. if (value instanceof Ref && this.xref) {
  1456. return this.xref.fetch(value, this.suppressEncryption);
  1457. }
  1458. return value;
  1459. },
  1460. async getAsync(key1, key2, key3) {
  1461. let value = this._map[key1];
  1462. if (value === undefined && key2 !== undefined) {
  1463. value = this._map[key2];
  1464. if (value === undefined && key3 !== undefined) {
  1465. value = this._map[key3];
  1466. }
  1467. }
  1468. if (value instanceof Ref && this.xref) {
  1469. return this.xref.fetchAsync(value, this.suppressEncryption);
  1470. }
  1471. return value;
  1472. },
  1473. getArray(key1, key2, key3) {
  1474. let value = this.get(key1, key2, key3);
  1475. if (!Array.isArray(value) || !this.xref) {
  1476. return value;
  1477. }
  1478. value = value.slice();
  1479. for (let i = 0, ii = value.length; i < ii; i++) {
  1480. if (!(value[i] instanceof Ref)) {
  1481. continue;
  1482. }
  1483. value[i] = this.xref.fetch(value[i], this.suppressEncryption);
  1484. }
  1485. return value;
  1486. },
  1487. getRaw: function Dict_getRaw(key) {
  1488. return this._map[key];
  1489. },
  1490. getKeys: function Dict_getKeys() {
  1491. return Object.keys(this._map);
  1492. },
  1493. getRawValues: function Dict_getRawValues() {
  1494. return Object.values(this._map);
  1495. },
  1496. set: function Dict_set(key, value) {
  1497. this._map[key] = value;
  1498. },
  1499. has: function Dict_has(key) {
  1500. return this._map[key] !== undefined;
  1501. },
  1502. forEach: function Dict_forEach(callback) {
  1503. for (var key in this._map) {
  1504. callback(key, this.get(key));
  1505. }
  1506. }
  1507. };
  1508. Dict.empty = new Dict(null);
  1509. Dict.merge = function ({
  1510. xref,
  1511. dictArray,
  1512. mergeSubDicts = false
  1513. }) {
  1514. const mergedDict = new Dict(xref);
  1515. if (!mergeSubDicts) {
  1516. for (const dict of dictArray) {
  1517. if (!(dict instanceof Dict)) {
  1518. continue;
  1519. }
  1520. for (const [key, value] of Object.entries(dict._map)) {
  1521. if (mergedDict._map[key] === undefined) {
  1522. mergedDict._map[key] = value;
  1523. }
  1524. }
  1525. }
  1526. return mergedDict.size > 0 ? mergedDict : Dict.empty;
  1527. }
  1528. const properties = new Map();
  1529. for (const dict of dictArray) {
  1530. if (!(dict instanceof Dict)) {
  1531. continue;
  1532. }
  1533. for (const [key, value] of Object.entries(dict._map)) {
  1534. let property = properties.get(key);
  1535. if (property === undefined) {
  1536. property = [];
  1537. properties.set(key, property);
  1538. }
  1539. property.push(value);
  1540. }
  1541. }
  1542. for (const [name, values] of properties) {
  1543. if (values.length === 1 || !(values[0] instanceof Dict)) {
  1544. mergedDict._map[name] = values[0];
  1545. continue;
  1546. }
  1547. const subDict = new Dict(xref);
  1548. for (const dict of values) {
  1549. if (!(dict instanceof Dict)) {
  1550. continue;
  1551. }
  1552. for (const [key, value] of Object.entries(dict._map)) {
  1553. if (subDict._map[key] === undefined) {
  1554. subDict._map[key] = value;
  1555. }
  1556. }
  1557. }
  1558. if (subDict.size > 0) {
  1559. mergedDict._map[name] = subDict;
  1560. }
  1561. }
  1562. properties.clear();
  1563. return mergedDict.size > 0 ? mergedDict : Dict.empty;
  1564. };
  1565. return Dict;
  1566. }();
  1567. exports.Dict = Dict;
  1568. var Ref = function RefClosure() {
  1569. let refCache = Object.create(null);
  1570. function Ref(num, gen) {
  1571. this.num = num;
  1572. this.gen = gen;
  1573. }
  1574. Ref.prototype = {
  1575. toString: function Ref_toString() {
  1576. if (this.gen === 0) {
  1577. return `${this.num}R`;
  1578. }
  1579. return `${this.num}R${this.gen}`;
  1580. }
  1581. };
  1582. Ref.get = function (num, gen) {
  1583. const key = gen === 0 ? `${num}R` : `${num}R${gen}`;
  1584. const refValue = refCache[key];
  1585. return refValue ? refValue : refCache[key] = new Ref(num, gen);
  1586. };
  1587. Ref._clearCache = function () {
  1588. refCache = Object.create(null);
  1589. };
  1590. return Ref;
  1591. }();
  1592. exports.Ref = Ref;
  1593. class RefSet {
  1594. constructor() {
  1595. this._set = new Set();
  1596. }
  1597. has(ref) {
  1598. return this._set.has(ref.toString());
  1599. }
  1600. put(ref) {
  1601. this._set.add(ref.toString());
  1602. }
  1603. remove(ref) {
  1604. this._set.delete(ref.toString());
  1605. }
  1606. }
  1607. exports.RefSet = RefSet;
  1608. class RefSetCache {
  1609. constructor() {
  1610. this._map = new Map();
  1611. }
  1612. get size() {
  1613. return this._map.size;
  1614. }
  1615. get(ref) {
  1616. return this._map.get(ref.toString());
  1617. }
  1618. has(ref) {
  1619. return this._map.has(ref.toString());
  1620. }
  1621. put(ref, obj) {
  1622. this._map.set(ref.toString(), obj);
  1623. }
  1624. putAlias(ref, aliasRef) {
  1625. this._map.set(ref.toString(), this.get(aliasRef));
  1626. }
  1627. forEach(callback) {
  1628. for (const value of this._map.values()) {
  1629. callback(value);
  1630. }
  1631. }
  1632. clear() {
  1633. this._map.clear();
  1634. }
  1635. }
  1636. exports.RefSetCache = RefSetCache;
  1637. function isEOF(v) {
  1638. return v === EOF;
  1639. }
  1640. function isName(v, name) {
  1641. return v instanceof Name && (name === undefined || v.name === name);
  1642. }
  1643. function isCmd(v, cmd) {
  1644. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  1645. }
  1646. function isDict(v, type) {
  1647. return v instanceof Dict && (type === undefined || isName(v.get("Type"), type));
  1648. }
  1649. function isRef(v) {
  1650. return v instanceof Ref;
  1651. }
  1652. function isRefsEqual(v1, v2) {
  1653. return v1.num === v2.num && v1.gen === v2.gen;
  1654. }
  1655. function isStream(v) {
  1656. return typeof v === "object" && v !== null && v.getBytes !== undefined;
  1657. }
  1658. function clearPrimitiveCaches() {
  1659. Cmd._clearCache();
  1660. Name._clearCache();
  1661. Ref._clearCache();
  1662. }
  1663. /***/ }),
  1664. /* 6 */
  1665. /***/ (function(module, exports, __w_pdfjs_require__) {
  1666. "use strict";
  1667. Object.defineProperty(exports, "__esModule", {
  1668. value: true
  1669. });
  1670. exports.NetworkPdfManager = exports.LocalPdfManager = void 0;
  1671. var _util = __w_pdfjs_require__(2);
  1672. var _chunked_stream = __w_pdfjs_require__(7);
  1673. var _core_utils = __w_pdfjs_require__(8);
  1674. var _document = __w_pdfjs_require__(9);
  1675. var _stream = __w_pdfjs_require__(12);
  1676. class BasePdfManager {
  1677. constructor() {
  1678. if (this.constructor === BasePdfManager) {
  1679. (0, _util.unreachable)("Cannot initialize BasePdfManager.");
  1680. }
  1681. }
  1682. get docId() {
  1683. return this._docId;
  1684. }
  1685. get password() {
  1686. return this._password;
  1687. }
  1688. get docBaseUrl() {
  1689. let docBaseUrl = null;
  1690. if (this._docBaseUrl) {
  1691. const absoluteUrl = (0, _util.createValidAbsoluteUrl)(this._docBaseUrl);
  1692. if (absoluteUrl) {
  1693. docBaseUrl = absoluteUrl.href;
  1694. } else {
  1695. (0, _util.warn)(`Invalid absolute docBaseUrl: "${this._docBaseUrl}".`);
  1696. }
  1697. }
  1698. return (0, _util.shadow)(this, "docBaseUrl", docBaseUrl);
  1699. }
  1700. onLoadedStream() {
  1701. (0, _util.unreachable)("Abstract method `onLoadedStream` called");
  1702. }
  1703. ensureDoc(prop, args) {
  1704. return this.ensure(this.pdfDocument, prop, args);
  1705. }
  1706. ensureXRef(prop, args) {
  1707. return this.ensure(this.pdfDocument.xref, prop, args);
  1708. }
  1709. ensureCatalog(prop, args) {
  1710. return this.ensure(this.pdfDocument.catalog, prop, args);
  1711. }
  1712. getPage(pageIndex) {
  1713. return this.pdfDocument.getPage(pageIndex);
  1714. }
  1715. fontFallback(id, handler) {
  1716. return this.pdfDocument.fontFallback(id, handler);
  1717. }
  1718. cleanup(manuallyTriggered = false) {
  1719. return this.pdfDocument.cleanup(manuallyTriggered);
  1720. }
  1721. async ensure(obj, prop, args) {
  1722. (0, _util.unreachable)("Abstract method `ensure` called");
  1723. }
  1724. requestRange(begin, end) {
  1725. (0, _util.unreachable)("Abstract method `requestRange` called");
  1726. }
  1727. requestLoadedStream() {
  1728. (0, _util.unreachable)("Abstract method `requestLoadedStream` called");
  1729. }
  1730. sendProgressiveData(chunk) {
  1731. (0, _util.unreachable)("Abstract method `sendProgressiveData` called");
  1732. }
  1733. updatePassword(password) {
  1734. this._password = password;
  1735. }
  1736. terminate(reason) {
  1737. (0, _util.unreachable)("Abstract method `terminate` called");
  1738. }
  1739. }
  1740. class LocalPdfManager extends BasePdfManager {
  1741. constructor(docId, data, password, evaluatorOptions, docBaseUrl) {
  1742. super();
  1743. this._docId = docId;
  1744. this._password = password;
  1745. this._docBaseUrl = docBaseUrl;
  1746. this.evaluatorOptions = evaluatorOptions;
  1747. const stream = new _stream.Stream(data);
  1748. this.pdfDocument = new _document.PDFDocument(this, stream);
  1749. this._loadedStreamPromise = Promise.resolve(stream);
  1750. }
  1751. async ensure(obj, prop, args) {
  1752. const value = obj[prop];
  1753. if (typeof value === "function") {
  1754. return value.apply(obj, args);
  1755. }
  1756. return value;
  1757. }
  1758. requestRange(begin, end) {
  1759. return Promise.resolve();
  1760. }
  1761. requestLoadedStream() {}
  1762. onLoadedStream() {
  1763. return this._loadedStreamPromise;
  1764. }
  1765. terminate(reason) {}
  1766. }
  1767. exports.LocalPdfManager = LocalPdfManager;
  1768. class NetworkPdfManager extends BasePdfManager {
  1769. constructor(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  1770. super();
  1771. this._docId = docId;
  1772. this._password = args.password;
  1773. this._docBaseUrl = docBaseUrl;
  1774. this.msgHandler = args.msgHandler;
  1775. this.evaluatorOptions = evaluatorOptions;
  1776. this.streamManager = new _chunked_stream.ChunkedStreamManager(pdfNetworkStream, {
  1777. msgHandler: args.msgHandler,
  1778. length: args.length,
  1779. disableAutoFetch: args.disableAutoFetch,
  1780. rangeChunkSize: args.rangeChunkSize
  1781. });
  1782. this.pdfDocument = new _document.PDFDocument(this, this.streamManager.getStream());
  1783. }
  1784. async ensure(obj, prop, args) {
  1785. try {
  1786. const value = obj[prop];
  1787. if (typeof value === "function") {
  1788. return value.apply(obj, args);
  1789. }
  1790. return value;
  1791. } catch (ex) {
  1792. if (!(ex instanceof _core_utils.MissingDataException)) {
  1793. throw ex;
  1794. }
  1795. await this.requestRange(ex.begin, ex.end);
  1796. return this.ensure(obj, prop, args);
  1797. }
  1798. }
  1799. requestRange(begin, end) {
  1800. return this.streamManager.requestRange(begin, end);
  1801. }
  1802. requestLoadedStream() {
  1803. this.streamManager.requestAllChunks();
  1804. }
  1805. sendProgressiveData(chunk) {
  1806. this.streamManager.onReceiveData({
  1807. chunk
  1808. });
  1809. }
  1810. onLoadedStream() {
  1811. return this.streamManager.onLoadedStream();
  1812. }
  1813. terminate(reason) {
  1814. this.streamManager.abort(reason);
  1815. }
  1816. }
  1817. exports.NetworkPdfManager = NetworkPdfManager;
  1818. /***/ }),
  1819. /* 7 */
  1820. /***/ (function(module, exports, __w_pdfjs_require__) {
  1821. "use strict";
  1822. Object.defineProperty(exports, "__esModule", {
  1823. value: true
  1824. });
  1825. exports.ChunkedStreamManager = exports.ChunkedStream = void 0;
  1826. var _util = __w_pdfjs_require__(2);
  1827. var _core_utils = __w_pdfjs_require__(8);
  1828. class ChunkedStream {
  1829. constructor(length, chunkSize, manager) {
  1830. this.bytes = new Uint8Array(length);
  1831. this.start = 0;
  1832. this.pos = 0;
  1833. this.end = length;
  1834. this.chunkSize = chunkSize;
  1835. this._loadedChunks = new Set();
  1836. this.numChunks = Math.ceil(length / chunkSize);
  1837. this.manager = manager;
  1838. this.progressiveDataLength = 0;
  1839. this.lastSuccessfulEnsureByteChunk = -1;
  1840. }
  1841. getMissingChunks() {
  1842. const chunks = [];
  1843. for (let chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  1844. if (!this._loadedChunks.has(chunk)) {
  1845. chunks.push(chunk);
  1846. }
  1847. }
  1848. return chunks;
  1849. }
  1850. getBaseStreams() {
  1851. return [this];
  1852. }
  1853. get numChunksLoaded() {
  1854. return this._loadedChunks.size;
  1855. }
  1856. allChunksLoaded() {
  1857. return this.numChunksLoaded === this.numChunks;
  1858. }
  1859. onReceiveData(begin, chunk) {
  1860. const chunkSize = this.chunkSize;
  1861. if (begin % chunkSize !== 0) {
  1862. throw new Error(`Bad begin offset: ${begin}`);
  1863. }
  1864. const end = begin + chunk.byteLength;
  1865. if (end % chunkSize !== 0 && end !== this.bytes.length) {
  1866. throw new Error(`Bad end offset: ${end}`);
  1867. }
  1868. this.bytes.set(new Uint8Array(chunk), begin);
  1869. const beginChunk = Math.floor(begin / chunkSize);
  1870. const endChunk = Math.floor((end - 1) / chunkSize) + 1;
  1871. for (let curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  1872. this._loadedChunks.add(curChunk);
  1873. }
  1874. }
  1875. onReceiveProgressiveData(data) {
  1876. let position = this.progressiveDataLength;
  1877. const beginChunk = Math.floor(position / this.chunkSize);
  1878. this.bytes.set(new Uint8Array(data), position);
  1879. position += data.byteLength;
  1880. this.progressiveDataLength = position;
  1881. const endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  1882. for (let curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  1883. this._loadedChunks.add(curChunk);
  1884. }
  1885. }
  1886. ensureByte(pos) {
  1887. if (pos < this.progressiveDataLength) {
  1888. return;
  1889. }
  1890. const chunk = Math.floor(pos / this.chunkSize);
  1891. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  1892. return;
  1893. }
  1894. if (!this._loadedChunks.has(chunk)) {
  1895. throw new _core_utils.MissingDataException(pos, pos + 1);
  1896. }
  1897. this.lastSuccessfulEnsureByteChunk = chunk;
  1898. }
  1899. ensureRange(begin, end) {
  1900. if (begin >= end) {
  1901. return;
  1902. }
  1903. if (end <= this.progressiveDataLength) {
  1904. return;
  1905. }
  1906. const chunkSize = this.chunkSize;
  1907. const beginChunk = Math.floor(begin / chunkSize);
  1908. const endChunk = Math.floor((end - 1) / chunkSize) + 1;
  1909. for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
  1910. if (!this._loadedChunks.has(chunk)) {
  1911. throw new _core_utils.MissingDataException(begin, end);
  1912. }
  1913. }
  1914. }
  1915. nextEmptyChunk(beginChunk) {
  1916. const numChunks = this.numChunks;
  1917. for (let i = 0; i < numChunks; ++i) {
  1918. const chunk = (beginChunk + i) % numChunks;
  1919. if (!this._loadedChunks.has(chunk)) {
  1920. return chunk;
  1921. }
  1922. }
  1923. return null;
  1924. }
  1925. hasChunk(chunk) {
  1926. return this._loadedChunks.has(chunk);
  1927. }
  1928. get length() {
  1929. return this.end - this.start;
  1930. }
  1931. get isEmpty() {
  1932. return this.length === 0;
  1933. }
  1934. getByte() {
  1935. const pos = this.pos;
  1936. if (pos >= this.end) {
  1937. return -1;
  1938. }
  1939. if (pos >= this.progressiveDataLength) {
  1940. this.ensureByte(pos);
  1941. }
  1942. return this.bytes[this.pos++];
  1943. }
  1944. getUint16() {
  1945. const b0 = this.getByte();
  1946. const b1 = this.getByte();
  1947. if (b0 === -1 || b1 === -1) {
  1948. return -1;
  1949. }
  1950. return (b0 << 8) + b1;
  1951. }
  1952. getInt32() {
  1953. const b0 = this.getByte();
  1954. const b1 = this.getByte();
  1955. const b2 = this.getByte();
  1956. const b3 = this.getByte();
  1957. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  1958. }
  1959. getBytes(length, forceClamped = false) {
  1960. const bytes = this.bytes;
  1961. const pos = this.pos;
  1962. const strEnd = this.end;
  1963. if (!length) {
  1964. if (strEnd > this.progressiveDataLength) {
  1965. this.ensureRange(pos, strEnd);
  1966. }
  1967. const subarray = bytes.subarray(pos, strEnd);
  1968. return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
  1969. }
  1970. let end = pos + length;
  1971. if (end > strEnd) {
  1972. end = strEnd;
  1973. }
  1974. if (end > this.progressiveDataLength) {
  1975. this.ensureRange(pos, end);
  1976. }
  1977. this.pos = end;
  1978. const subarray = bytes.subarray(pos, end);
  1979. return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
  1980. }
  1981. peekByte() {
  1982. const peekedByte = this.getByte();
  1983. if (peekedByte !== -1) {
  1984. this.pos--;
  1985. }
  1986. return peekedByte;
  1987. }
  1988. peekBytes(length, forceClamped = false) {
  1989. const bytes = this.getBytes(length, forceClamped);
  1990. this.pos -= bytes.length;
  1991. return bytes;
  1992. }
  1993. getByteRange(begin, end) {
  1994. if (begin < 0) {
  1995. begin = 0;
  1996. }
  1997. if (end > this.end) {
  1998. end = this.end;
  1999. }
  2000. if (end > this.progressiveDataLength) {
  2001. this.ensureRange(begin, end);
  2002. }
  2003. return this.bytes.subarray(begin, end);
  2004. }
  2005. skip(n) {
  2006. if (!n) {
  2007. n = 1;
  2008. }
  2009. this.pos += n;
  2010. }
  2011. reset() {
  2012. this.pos = this.start;
  2013. }
  2014. moveStart() {
  2015. this.start = this.pos;
  2016. }
  2017. makeSubStream(start, length, dict) {
  2018. if (length) {
  2019. if (start + length > this.progressiveDataLength) {
  2020. this.ensureRange(start, start + length);
  2021. }
  2022. } else {
  2023. if (start >= this.progressiveDataLength) {
  2024. this.ensureByte(start);
  2025. }
  2026. }
  2027. function ChunkedStreamSubstream() {}
  2028. ChunkedStreamSubstream.prototype = Object.create(this);
  2029. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  2030. const chunkSize = this.chunkSize;
  2031. const beginChunk = Math.floor(this.start / chunkSize);
  2032. const endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  2033. const missingChunks = [];
  2034. for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
  2035. if (!this._loadedChunks.has(chunk)) {
  2036. missingChunks.push(chunk);
  2037. }
  2038. }
  2039. return missingChunks;
  2040. };
  2041. ChunkedStreamSubstream.prototype.allChunksLoaded = function () {
  2042. if (this.numChunksLoaded === this.numChunks) {
  2043. return true;
  2044. }
  2045. return this.getMissingChunks().length === 0;
  2046. };
  2047. const subStream = new ChunkedStreamSubstream();
  2048. subStream.pos = subStream.start = start;
  2049. subStream.end = start + length || this.end;
  2050. subStream.dict = dict;
  2051. return subStream;
  2052. }
  2053. }
  2054. exports.ChunkedStream = ChunkedStream;
  2055. class ChunkedStreamManager {
  2056. constructor(pdfNetworkStream, args) {
  2057. this.length = args.length;
  2058. this.chunkSize = args.rangeChunkSize;
  2059. this.stream = new ChunkedStream(this.length, this.chunkSize, this);
  2060. this.pdfNetworkStream = pdfNetworkStream;
  2061. this.disableAutoFetch = args.disableAutoFetch;
  2062. this.msgHandler = args.msgHandler;
  2063. this.currRequestId = 0;
  2064. this._chunksNeededByRequest = new Map();
  2065. this._requestsByChunk = new Map();
  2066. this._promisesByRequest = new Map();
  2067. this.progressiveDataLength = 0;
  2068. this.aborted = false;
  2069. this._loadedStreamCapability = (0, _util.createPromiseCapability)();
  2070. }
  2071. onLoadedStream() {
  2072. return this._loadedStreamCapability.promise;
  2073. }
  2074. sendRequest(begin, end) {
  2075. const rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  2076. if (!rangeReader.isStreamingSupported) {
  2077. rangeReader.onProgress = this.onProgress.bind(this);
  2078. }
  2079. let chunks = [],
  2080. loaded = 0;
  2081. const promise = new Promise((resolve, reject) => {
  2082. const readChunk = chunk => {
  2083. try {
  2084. if (!chunk.done) {
  2085. const data = chunk.value;
  2086. chunks.push(data);
  2087. loaded += (0, _util.arrayByteLength)(data);
  2088. if (rangeReader.isStreamingSupported) {
  2089. this.onProgress({
  2090. loaded
  2091. });
  2092. }
  2093. rangeReader.read().then(readChunk, reject);
  2094. return;
  2095. }
  2096. const chunkData = (0, _util.arraysToBytes)(chunks);
  2097. chunks = null;
  2098. resolve(chunkData);
  2099. } catch (e) {
  2100. reject(e);
  2101. }
  2102. };
  2103. rangeReader.read().then(readChunk, reject);
  2104. });
  2105. promise.then(data => {
  2106. if (this.aborted) {
  2107. return;
  2108. }
  2109. this.onReceiveData({
  2110. chunk: data,
  2111. begin
  2112. });
  2113. });
  2114. }
  2115. requestAllChunks() {
  2116. const missingChunks = this.stream.getMissingChunks();
  2117. this._requestChunks(missingChunks);
  2118. return this._loadedStreamCapability.promise;
  2119. }
  2120. _requestChunks(chunks) {
  2121. const requestId = this.currRequestId++;
  2122. const chunksNeeded = new Set();
  2123. this._chunksNeededByRequest.set(requestId, chunksNeeded);
  2124. for (const chunk of chunks) {
  2125. if (!this.stream.hasChunk(chunk)) {
  2126. chunksNeeded.add(chunk);
  2127. }
  2128. }
  2129. if (chunksNeeded.size === 0) {
  2130. return Promise.resolve();
  2131. }
  2132. const capability = (0, _util.createPromiseCapability)();
  2133. this._promisesByRequest.set(requestId, capability);
  2134. const chunksToRequest = [];
  2135. for (const chunk of chunksNeeded) {
  2136. let requestIds = this._requestsByChunk.get(chunk);
  2137. if (!requestIds) {
  2138. requestIds = [];
  2139. this._requestsByChunk.set(chunk, requestIds);
  2140. chunksToRequest.push(chunk);
  2141. }
  2142. requestIds.push(requestId);
  2143. }
  2144. if (chunksToRequest.length > 0) {
  2145. const groupedChunksToRequest = this.groupChunks(chunksToRequest);
  2146. for (const groupedChunk of groupedChunksToRequest) {
  2147. const begin = groupedChunk.beginChunk * this.chunkSize;
  2148. const end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  2149. this.sendRequest(begin, end);
  2150. }
  2151. }
  2152. return capability.promise.catch(reason => {
  2153. if (this.aborted) {
  2154. return;
  2155. }
  2156. throw reason;
  2157. });
  2158. }
  2159. getStream() {
  2160. return this.stream;
  2161. }
  2162. requestRange(begin, end) {
  2163. end = Math.min(end, this.length);
  2164. const beginChunk = this.getBeginChunk(begin);
  2165. const endChunk = this.getEndChunk(end);
  2166. const chunks = [];
  2167. for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
  2168. chunks.push(chunk);
  2169. }
  2170. return this._requestChunks(chunks);
  2171. }
  2172. requestRanges(ranges = []) {
  2173. const chunksToRequest = [];
  2174. for (const range of ranges) {
  2175. const beginChunk = this.getBeginChunk(range.begin);
  2176. const endChunk = this.getEndChunk(range.end);
  2177. for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
  2178. if (!chunksToRequest.includes(chunk)) {
  2179. chunksToRequest.push(chunk);
  2180. }
  2181. }
  2182. }
  2183. chunksToRequest.sort(function (a, b) {
  2184. return a - b;
  2185. });
  2186. return this._requestChunks(chunksToRequest);
  2187. }
  2188. groupChunks(chunks) {
  2189. const groupedChunks = [];
  2190. let beginChunk = -1;
  2191. let prevChunk = -1;
  2192. for (let i = 0, ii = chunks.length; i < ii; ++i) {
  2193. const chunk = chunks[i];
  2194. if (beginChunk < 0) {
  2195. beginChunk = chunk;
  2196. }
  2197. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  2198. groupedChunks.push({
  2199. beginChunk,
  2200. endChunk: prevChunk + 1
  2201. });
  2202. beginChunk = chunk;
  2203. }
  2204. if (i + 1 === chunks.length) {
  2205. groupedChunks.push({
  2206. beginChunk,
  2207. endChunk: chunk + 1
  2208. });
  2209. }
  2210. prevChunk = chunk;
  2211. }
  2212. return groupedChunks;
  2213. }
  2214. onProgress(args) {
  2215. this.msgHandler.send("DocProgress", {
  2216. loaded: this.stream.numChunksLoaded * this.chunkSize + args.loaded,
  2217. total: this.length
  2218. });
  2219. }
  2220. onReceiveData(args) {
  2221. const chunk = args.chunk;
  2222. const isProgressive = args.begin === undefined;
  2223. const begin = isProgressive ? this.progressiveDataLength : args.begin;
  2224. const end = begin + chunk.byteLength;
  2225. const beginChunk = Math.floor(begin / this.chunkSize);
  2226. const endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  2227. if (isProgressive) {
  2228. this.stream.onReceiveProgressiveData(chunk);
  2229. this.progressiveDataLength = end;
  2230. } else {
  2231. this.stream.onReceiveData(begin, chunk);
  2232. }
  2233. if (this.stream.allChunksLoaded()) {
  2234. this._loadedStreamCapability.resolve(this.stream);
  2235. }
  2236. const loadedRequests = [];
  2237. for (let curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  2238. const requestIds = this._requestsByChunk.get(curChunk);
  2239. if (!requestIds) {
  2240. continue;
  2241. }
  2242. this._requestsByChunk.delete(curChunk);
  2243. for (const requestId of requestIds) {
  2244. const chunksNeeded = this._chunksNeededByRequest.get(requestId);
  2245. if (chunksNeeded.has(curChunk)) {
  2246. chunksNeeded.delete(curChunk);
  2247. }
  2248. if (chunksNeeded.size > 0) {
  2249. continue;
  2250. }
  2251. loadedRequests.push(requestId);
  2252. }
  2253. }
  2254. if (!this.disableAutoFetch && this._requestsByChunk.size === 0) {
  2255. let nextEmptyChunk;
  2256. if (this.stream.numChunksLoaded === 1) {
  2257. const lastChunk = this.stream.numChunks - 1;
  2258. if (!this.stream.hasChunk(lastChunk)) {
  2259. nextEmptyChunk = lastChunk;
  2260. }
  2261. } else {
  2262. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  2263. }
  2264. if (Number.isInteger(nextEmptyChunk)) {
  2265. this._requestChunks([nextEmptyChunk]);
  2266. }
  2267. }
  2268. for (const requestId of loadedRequests) {
  2269. const capability = this._promisesByRequest.get(requestId);
  2270. this._promisesByRequest.delete(requestId);
  2271. capability.resolve();
  2272. }
  2273. this.msgHandler.send("DocProgress", {
  2274. loaded: this.stream.numChunksLoaded * this.chunkSize,
  2275. total: this.length
  2276. });
  2277. }
  2278. onError(err) {
  2279. this._loadedStreamCapability.reject(err);
  2280. }
  2281. getBeginChunk(begin) {
  2282. return Math.floor(begin / this.chunkSize);
  2283. }
  2284. getEndChunk(end) {
  2285. return Math.floor((end - 1) / this.chunkSize) + 1;
  2286. }
  2287. abort(reason) {
  2288. this.aborted = true;
  2289. if (this.pdfNetworkStream) {
  2290. this.pdfNetworkStream.cancelAllRequests(reason);
  2291. }
  2292. for (const capability of this._promisesByRequest.values()) {
  2293. capability.reject(reason);
  2294. }
  2295. }
  2296. }
  2297. exports.ChunkedStreamManager = ChunkedStreamManager;
  2298. /***/ }),
  2299. /* 8 */
  2300. /***/ (function(module, exports, __w_pdfjs_require__) {
  2301. "use strict";
  2302. Object.defineProperty(exports, "__esModule", {
  2303. value: true
  2304. });
  2305. exports.getLookupTableFactory = getLookupTableFactory;
  2306. exports.getInheritableProperty = getInheritableProperty;
  2307. exports.toRomanNumerals = toRomanNumerals;
  2308. exports.log2 = log2;
  2309. exports.readInt8 = readInt8;
  2310. exports.readUint16 = readUint16;
  2311. exports.readUint32 = readUint32;
  2312. exports.isWhiteSpace = isWhiteSpace;
  2313. exports.XRefParseException = exports.XRefEntryException = exports.MissingDataException = void 0;
  2314. var _util = __w_pdfjs_require__(2);
  2315. function getLookupTableFactory(initializer) {
  2316. let lookup;
  2317. return function () {
  2318. if (initializer) {
  2319. lookup = Object.create(null);
  2320. initializer(lookup);
  2321. initializer = null;
  2322. }
  2323. return lookup;
  2324. };
  2325. }
  2326. class MissingDataException extends _util.BaseException {
  2327. constructor(begin, end) {
  2328. super(`Missing data [${begin}, ${end})`);
  2329. this.begin = begin;
  2330. this.end = end;
  2331. }
  2332. }
  2333. exports.MissingDataException = MissingDataException;
  2334. class XRefEntryException extends _util.BaseException {}
  2335. exports.XRefEntryException = XRefEntryException;
  2336. class XRefParseException extends _util.BaseException {}
  2337. exports.XRefParseException = XRefParseException;
  2338. function getInheritableProperty({
  2339. dict,
  2340. key,
  2341. getArray = false,
  2342. stopWhenFound = true
  2343. }) {
  2344. const LOOP_LIMIT = 100;
  2345. let loopCount = 0;
  2346. let values;
  2347. while (dict) {
  2348. const value = getArray ? dict.getArray(key) : dict.get(key);
  2349. if (value !== undefined) {
  2350. if (stopWhenFound) {
  2351. return value;
  2352. }
  2353. if (!values) {
  2354. values = [];
  2355. }
  2356. values.push(value);
  2357. }
  2358. if (++loopCount > LOOP_LIMIT) {
  2359. (0, _util.warn)(`getInheritableProperty: maximum loop count exceeded for "${key}"`);
  2360. break;
  2361. }
  2362. dict = dict.get("Parent");
  2363. }
  2364. return values;
  2365. }
  2366. const 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"];
  2367. function toRomanNumerals(number, lowerCase = false) {
  2368. (0, _util.assert)(Number.isInteger(number) && number > 0, "The number should be a positive integer.");
  2369. const romanBuf = [];
  2370. let pos;
  2371. while (number >= 1000) {
  2372. number -= 1000;
  2373. romanBuf.push("M");
  2374. }
  2375. pos = number / 100 | 0;
  2376. number %= 100;
  2377. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  2378. pos = number / 10 | 0;
  2379. number %= 10;
  2380. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  2381. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  2382. const romanStr = romanBuf.join("");
  2383. return lowerCase ? romanStr.toLowerCase() : romanStr;
  2384. }
  2385. function log2(x) {
  2386. if (x <= 0) {
  2387. return 0;
  2388. }
  2389. return Math.ceil(Math.log2(x));
  2390. }
  2391. function readInt8(data, offset) {
  2392. return data[offset] << 24 >> 24;
  2393. }
  2394. function readUint16(data, offset) {
  2395. return data[offset] << 8 | data[offset + 1];
  2396. }
  2397. function readUint32(data, offset) {
  2398. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  2399. }
  2400. function isWhiteSpace(ch) {
  2401. return ch === 0x20 || ch === 0x09 || ch === 0x0d || ch === 0x0a;
  2402. }
  2403. /***/ }),
  2404. /* 9 */
  2405. /***/ (function(module, exports, __w_pdfjs_require__) {
  2406. "use strict";
  2407. Object.defineProperty(exports, "__esModule", {
  2408. value: true
  2409. });
  2410. exports.PDFDocument = exports.Page = void 0;
  2411. var _util = __w_pdfjs_require__(2);
  2412. var _obj = __w_pdfjs_require__(10);
  2413. var _primitives = __w_pdfjs_require__(5);
  2414. var _core_utils = __w_pdfjs_require__(8);
  2415. var _stream = __w_pdfjs_require__(12);
  2416. var _annotation = __w_pdfjs_require__(25);
  2417. var _crypto = __w_pdfjs_require__(22);
  2418. var _parser = __w_pdfjs_require__(11);
  2419. var _operator_list = __w_pdfjs_require__(26);
  2420. var _evaluator = __w_pdfjs_require__(28);
  2421. const DEFAULT_USER_UNIT = 1.0;
  2422. const LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
  2423. function isAnnotationRenderable(annotation, intent) {
  2424. return intent === "display" && annotation.viewable || intent === "print" && annotation.printable;
  2425. }
  2426. class Page {
  2427. constructor({
  2428. pdfManager,
  2429. xref,
  2430. pageIndex,
  2431. pageDict,
  2432. ref,
  2433. globalIdFactory,
  2434. fontCache,
  2435. builtInCMapCache,
  2436. globalImageCache
  2437. }) {
  2438. this.pdfManager = pdfManager;
  2439. this.pageIndex = pageIndex;
  2440. this.pageDict = pageDict;
  2441. this.xref = xref;
  2442. this.ref = ref;
  2443. this.fontCache = fontCache;
  2444. this.builtInCMapCache = builtInCMapCache;
  2445. this.globalImageCache = globalImageCache;
  2446. this.evaluatorOptions = pdfManager.evaluatorOptions;
  2447. this.resourcesPromise = null;
  2448. const idCounters = {
  2449. obj: 0
  2450. };
  2451. this._localIdFactory = class extends globalIdFactory {
  2452. static createObjId() {
  2453. return `p${pageIndex}_${++idCounters.obj}`;
  2454. }
  2455. };
  2456. }
  2457. _getInheritableProperty(key, getArray = false) {
  2458. const value = (0, _core_utils.getInheritableProperty)({
  2459. dict: this.pageDict,
  2460. key,
  2461. getArray,
  2462. stopWhenFound: false
  2463. });
  2464. if (!Array.isArray(value)) {
  2465. return value;
  2466. }
  2467. if (value.length === 1 || !(0, _primitives.isDict)(value[0])) {
  2468. return value[0];
  2469. }
  2470. return _primitives.Dict.merge({
  2471. xref: this.xref,
  2472. dictArray: value
  2473. });
  2474. }
  2475. get content() {
  2476. return this.pageDict.get("Contents");
  2477. }
  2478. get resources() {
  2479. return (0, _util.shadow)(this, "resources", this._getInheritableProperty("Resources") || _primitives.Dict.empty);
  2480. }
  2481. _getBoundingBox(name) {
  2482. const box = this._getInheritableProperty(name, true);
  2483. if (Array.isArray(box) && box.length === 4) {
  2484. if (box[2] - box[0] !== 0 && box[3] - box[1] !== 0) {
  2485. return box;
  2486. }
  2487. (0, _util.warn)(`Empty /${name} entry.`);
  2488. }
  2489. return null;
  2490. }
  2491. get mediaBox() {
  2492. return (0, _util.shadow)(this, "mediaBox", this._getBoundingBox("MediaBox") || LETTER_SIZE_MEDIABOX);
  2493. }
  2494. get cropBox() {
  2495. return (0, _util.shadow)(this, "cropBox", this._getBoundingBox("CropBox") || this.mediaBox);
  2496. }
  2497. get userUnit() {
  2498. let obj = this.pageDict.get("UserUnit");
  2499. if (!(0, _util.isNum)(obj) || obj <= 0) {
  2500. obj = DEFAULT_USER_UNIT;
  2501. }
  2502. return (0, _util.shadow)(this, "userUnit", obj);
  2503. }
  2504. get view() {
  2505. const {
  2506. cropBox,
  2507. mediaBox
  2508. } = this;
  2509. let view;
  2510. if (cropBox === mediaBox || (0, _util.isArrayEqual)(cropBox, mediaBox)) {
  2511. view = mediaBox;
  2512. } else {
  2513. const box = _util.Util.intersect(cropBox, mediaBox);
  2514. if (box && box[2] - box[0] !== 0 && box[3] - box[1] !== 0) {
  2515. view = box;
  2516. } else {
  2517. (0, _util.warn)("Empty /CropBox and /MediaBox intersection.");
  2518. }
  2519. }
  2520. return (0, _util.shadow)(this, "view", view || mediaBox);
  2521. }
  2522. get rotate() {
  2523. let rotate = this._getInheritableProperty("Rotate") || 0;
  2524. if (rotate % 90 !== 0) {
  2525. rotate = 0;
  2526. } else if (rotate >= 360) {
  2527. rotate = rotate % 360;
  2528. } else if (rotate < 0) {
  2529. rotate = (rotate % 360 + 360) % 360;
  2530. }
  2531. return (0, _util.shadow)(this, "rotate", rotate);
  2532. }
  2533. getContentStream() {
  2534. const content = this.content;
  2535. let stream;
  2536. if (Array.isArray(content)) {
  2537. const xref = this.xref;
  2538. const streams = [];
  2539. for (const subStream of content) {
  2540. streams.push(xref.fetchIfRef(subStream));
  2541. }
  2542. stream = new _stream.StreamsSequenceStream(streams);
  2543. } else if ((0, _primitives.isStream)(content)) {
  2544. stream = content;
  2545. } else {
  2546. stream = new _stream.NullStream();
  2547. }
  2548. return stream;
  2549. }
  2550. save(handler, task, annotationStorage) {
  2551. const partialEvaluator = new _evaluator.PartialEvaluator({
  2552. xref: this.xref,
  2553. handler,
  2554. pageIndex: this.pageIndex,
  2555. idFactory: this._localIdFactory,
  2556. fontCache: this.fontCache,
  2557. builtInCMapCache: this.builtInCMapCache,
  2558. globalImageCache: this.globalImageCache,
  2559. options: this.evaluatorOptions
  2560. });
  2561. return this._parsedAnnotations.then(function (annotations) {
  2562. const newRefsPromises = [];
  2563. for (const annotation of annotations) {
  2564. if (!isAnnotationRenderable(annotation, "print")) {
  2565. continue;
  2566. }
  2567. newRefsPromises.push(annotation.save(partialEvaluator, task, annotationStorage).catch(function (reason) {
  2568. (0, _util.warn)("save - ignoring annotation data during " + `"${task.name}" task: "${reason}".`);
  2569. return null;
  2570. }));
  2571. }
  2572. return Promise.all(newRefsPromises);
  2573. });
  2574. }
  2575. loadResources(keys) {
  2576. if (!this.resourcesPromise) {
  2577. this.resourcesPromise = this.pdfManager.ensure(this, "resources");
  2578. }
  2579. return this.resourcesPromise.then(() => {
  2580. const objectLoader = new _obj.ObjectLoader(this.resources, keys, this.xref);
  2581. return objectLoader.load();
  2582. });
  2583. }
  2584. getOperatorList({
  2585. handler,
  2586. sink,
  2587. task,
  2588. intent,
  2589. renderInteractiveForms,
  2590. annotationStorage
  2591. }) {
  2592. const contentStreamPromise = this.pdfManager.ensure(this, "getContentStream");
  2593. const resourcesPromise = this.loadResources(["ExtGState", "ColorSpace", "Pattern", "Shading", "XObject", "Font"]);
  2594. const partialEvaluator = new _evaluator.PartialEvaluator({
  2595. xref: this.xref,
  2596. handler,
  2597. pageIndex: this.pageIndex,
  2598. idFactory: this._localIdFactory,
  2599. fontCache: this.fontCache,
  2600. builtInCMapCache: this.builtInCMapCache,
  2601. globalImageCache: this.globalImageCache,
  2602. options: this.evaluatorOptions
  2603. });
  2604. const dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
  2605. const pageListPromise = dataPromises.then(([contentStream]) => {
  2606. const opList = new _operator_list.OperatorList(intent, sink);
  2607. handler.send("StartRenderPage", {
  2608. transparency: partialEvaluator.hasBlendModes(this.resources),
  2609. pageIndex: this.pageIndex,
  2610. intent
  2611. });
  2612. return partialEvaluator.getOperatorList({
  2613. stream: contentStream,
  2614. task,
  2615. resources: this.resources,
  2616. operatorList: opList
  2617. }).then(function () {
  2618. return opList;
  2619. });
  2620. });
  2621. return Promise.all([pageListPromise, this._parsedAnnotations]).then(function ([pageOpList, annotations]) {
  2622. if (annotations.length === 0) {
  2623. pageOpList.flush(true);
  2624. return {
  2625. length: pageOpList.totalLength
  2626. };
  2627. }
  2628. const opListPromises = [];
  2629. for (const annotation of annotations) {
  2630. if (isAnnotationRenderable(annotation, intent)) {
  2631. opListPromises.push(annotation.getOperatorList(partialEvaluator, task, renderInteractiveForms, annotationStorage).catch(function (reason) {
  2632. (0, _util.warn)("getOperatorList - ignoring annotation data during " + `"${task.name}" task: "${reason}".`);
  2633. return null;
  2634. }));
  2635. }
  2636. }
  2637. return Promise.all(opListPromises).then(function (opLists) {
  2638. pageOpList.addOp(_util.OPS.beginAnnotations, []);
  2639. for (const opList of opLists) {
  2640. pageOpList.addOpList(opList);
  2641. }
  2642. pageOpList.addOp(_util.OPS.endAnnotations, []);
  2643. pageOpList.flush(true);
  2644. return {
  2645. length: pageOpList.totalLength
  2646. };
  2647. });
  2648. });
  2649. }
  2650. extractTextContent({
  2651. handler,
  2652. task,
  2653. normalizeWhitespace,
  2654. sink,
  2655. combineTextItems
  2656. }) {
  2657. const contentStreamPromise = this.pdfManager.ensure(this, "getContentStream");
  2658. const resourcesPromise = this.loadResources(["ExtGState", "XObject", "Font"]);
  2659. const dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
  2660. return dataPromises.then(([contentStream]) => {
  2661. const partialEvaluator = new _evaluator.PartialEvaluator({
  2662. xref: this.xref,
  2663. handler,
  2664. pageIndex: this.pageIndex,
  2665. idFactory: this._localIdFactory,
  2666. fontCache: this.fontCache,
  2667. builtInCMapCache: this.builtInCMapCache,
  2668. globalImageCache: this.globalImageCache,
  2669. options: this.evaluatorOptions
  2670. });
  2671. return partialEvaluator.getTextContent({
  2672. stream: contentStream,
  2673. task,
  2674. resources: this.resources,
  2675. normalizeWhitespace,
  2676. combineTextItems,
  2677. sink
  2678. });
  2679. });
  2680. }
  2681. getAnnotationsData(intent) {
  2682. return this._parsedAnnotations.then(function (annotations) {
  2683. const annotationsData = [];
  2684. for (let i = 0, ii = annotations.length; i < ii; i++) {
  2685. if (!intent || isAnnotationRenderable(annotations[i], intent)) {
  2686. annotationsData.push(annotations[i].data);
  2687. }
  2688. }
  2689. return annotationsData;
  2690. });
  2691. }
  2692. get annotations() {
  2693. return (0, _util.shadow)(this, "annotations", this._getInheritableProperty("Annots") || []);
  2694. }
  2695. get _parsedAnnotations() {
  2696. const parsedAnnotations = this.pdfManager.ensure(this, "annotations").then(() => {
  2697. const annotationPromises = [];
  2698. for (const annotationRef of this.annotations) {
  2699. annotationPromises.push(_annotation.AnnotationFactory.create(this.xref, annotationRef, this.pdfManager, this._localIdFactory).catch(function (reason) {
  2700. (0, _util.warn)(`_parsedAnnotations: "${reason}".`);
  2701. return null;
  2702. }));
  2703. }
  2704. return Promise.all(annotationPromises).then(function (annotations) {
  2705. return annotations.filter(annotation => !!annotation);
  2706. });
  2707. });
  2708. return (0, _util.shadow)(this, "_parsedAnnotations", parsedAnnotations);
  2709. }
  2710. }
  2711. exports.Page = Page;
  2712. const PDF_HEADER_SIGNATURE = new Uint8Array([0x25, 0x50, 0x44, 0x46, 0x2d]);
  2713. const STARTXREF_SIGNATURE = new Uint8Array([0x73, 0x74, 0x61, 0x72, 0x74, 0x78, 0x72, 0x65, 0x66]);
  2714. const ENDOBJ_SIGNATURE = new Uint8Array([0x65, 0x6e, 0x64, 0x6f, 0x62, 0x6a]);
  2715. const FINGERPRINT_FIRST_BYTES = 1024;
  2716. const EMPTY_FINGERPRINT = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
  2717. const PDF_HEADER_VERSION_REGEXP = /^[1-9]\.[0-9]$/;
  2718. function find(stream, signature, limit = 1024, backwards = false) {
  2719. const signatureLength = signature.length;
  2720. const scanBytes = stream.peekBytes(limit);
  2721. const scanLength = scanBytes.length - signatureLength;
  2722. if (scanLength <= 0) {
  2723. return false;
  2724. }
  2725. if (backwards) {
  2726. const signatureEnd = signatureLength - 1;
  2727. let pos = scanBytes.length - 1;
  2728. while (pos >= signatureEnd) {
  2729. let j = 0;
  2730. while (j < signatureLength && scanBytes[pos - j] === signature[signatureEnd - j]) {
  2731. j++;
  2732. }
  2733. if (j >= signatureLength) {
  2734. stream.pos += pos - signatureEnd;
  2735. return true;
  2736. }
  2737. pos--;
  2738. }
  2739. } else {
  2740. let pos = 0;
  2741. while (pos <= scanLength) {
  2742. let j = 0;
  2743. while (j < signatureLength && scanBytes[pos + j] === signature[j]) {
  2744. j++;
  2745. }
  2746. if (j >= signatureLength) {
  2747. stream.pos += pos;
  2748. return true;
  2749. }
  2750. pos++;
  2751. }
  2752. }
  2753. return false;
  2754. }
  2755. class PDFDocument {
  2756. constructor(pdfManager, arg) {
  2757. let stream;
  2758. if ((0, _primitives.isStream)(arg)) {
  2759. stream = arg;
  2760. } else if ((0, _util.isArrayBuffer)(arg)) {
  2761. stream = new _stream.Stream(arg);
  2762. } else {
  2763. throw new Error("PDFDocument: Unknown argument type");
  2764. }
  2765. if (stream.length <= 0) {
  2766. throw new _util.InvalidPDFException("The PDF file is empty, i.e. its size is zero bytes.");
  2767. }
  2768. this.pdfManager = pdfManager;
  2769. this.stream = stream;
  2770. this.xref = new _obj.XRef(stream, pdfManager);
  2771. this._pagePromises = [];
  2772. this._version = null;
  2773. const idCounters = {
  2774. font: 0
  2775. };
  2776. this._globalIdFactory = class {
  2777. static getDocId() {
  2778. return `g_${pdfManager.docId}`;
  2779. }
  2780. static createFontId() {
  2781. return `f${++idCounters.font}`;
  2782. }
  2783. static createObjId() {
  2784. (0, _util.unreachable)("Abstract method `createObjId` called.");
  2785. }
  2786. };
  2787. }
  2788. parse(recoveryMode) {
  2789. this.xref.parse(recoveryMode);
  2790. this.catalog = new _obj.Catalog(this.pdfManager, this.xref);
  2791. if (this.catalog.version) {
  2792. this._version = this.catalog.version;
  2793. }
  2794. }
  2795. get linearization() {
  2796. let linearization = null;
  2797. try {
  2798. linearization = _parser.Linearization.create(this.stream);
  2799. } catch (err) {
  2800. if (err instanceof _core_utils.MissingDataException) {
  2801. throw err;
  2802. }
  2803. (0, _util.info)(err);
  2804. }
  2805. return (0, _util.shadow)(this, "linearization", linearization);
  2806. }
  2807. get startXRef() {
  2808. const stream = this.stream;
  2809. let startXRef = 0;
  2810. if (this.linearization) {
  2811. stream.reset();
  2812. if (find(stream, ENDOBJ_SIGNATURE)) {
  2813. startXRef = stream.pos + 6 - stream.start;
  2814. }
  2815. } else {
  2816. const step = 1024;
  2817. const startXRefLength = STARTXREF_SIGNATURE.length;
  2818. let found = false,
  2819. pos = stream.end;
  2820. while (!found && pos > 0) {
  2821. pos -= step - startXRefLength;
  2822. if (pos < 0) {
  2823. pos = 0;
  2824. }
  2825. stream.pos = pos;
  2826. found = find(stream, STARTXREF_SIGNATURE, step, true);
  2827. }
  2828. if (found) {
  2829. stream.skip(9);
  2830. let ch;
  2831. do {
  2832. ch = stream.getByte();
  2833. } while ((0, _core_utils.isWhiteSpace)(ch));
  2834. let str = "";
  2835. while (ch >= 0x20 && ch <= 0x39) {
  2836. str += String.fromCharCode(ch);
  2837. ch = stream.getByte();
  2838. }
  2839. startXRef = parseInt(str, 10);
  2840. if (isNaN(startXRef)) {
  2841. startXRef = 0;
  2842. }
  2843. }
  2844. }
  2845. return (0, _util.shadow)(this, "startXRef", startXRef);
  2846. }
  2847. checkHeader() {
  2848. const stream = this.stream;
  2849. stream.reset();
  2850. if (!find(stream, PDF_HEADER_SIGNATURE)) {
  2851. return;
  2852. }
  2853. stream.moveStart();
  2854. const MAX_PDF_VERSION_LENGTH = 12;
  2855. let version = "",
  2856. ch;
  2857. while ((ch = stream.getByte()) > 0x20) {
  2858. if (version.length >= MAX_PDF_VERSION_LENGTH) {
  2859. break;
  2860. }
  2861. version += String.fromCharCode(ch);
  2862. }
  2863. if (!this._version) {
  2864. this._version = version.substring(5);
  2865. }
  2866. }
  2867. parseStartXRef() {
  2868. this.xref.setStartXRef(this.startXRef);
  2869. }
  2870. get numPages() {
  2871. const linearization = this.linearization;
  2872. const num = linearization ? linearization.numPages : this.catalog.numPages;
  2873. return (0, _util.shadow)(this, "numPages", num);
  2874. }
  2875. _hasOnlyDocumentSignatures(fields, recursionDepth = 0) {
  2876. const RECURSION_LIMIT = 10;
  2877. return fields.every(field => {
  2878. field = this.xref.fetchIfRef(field);
  2879. if (field.has("Kids")) {
  2880. if (++recursionDepth > RECURSION_LIMIT) {
  2881. (0, _util.warn)("_hasOnlyDocumentSignatures: maximum recursion depth reached");
  2882. return false;
  2883. }
  2884. return this._hasOnlyDocumentSignatures(field.get("Kids"), recursionDepth);
  2885. }
  2886. const isSignature = (0, _primitives.isName)(field.get("FT"), "Sig");
  2887. const rectangle = field.get("Rect");
  2888. const isInvisible = Array.isArray(rectangle) && rectangle.every(value => value === 0);
  2889. return isSignature && isInvisible;
  2890. });
  2891. }
  2892. get formInfo() {
  2893. const formInfo = {
  2894. hasAcroForm: false,
  2895. hasXfa: false
  2896. };
  2897. const acroForm = this.catalog.acroForm;
  2898. if (!acroForm) {
  2899. return (0, _util.shadow)(this, "formInfo", formInfo);
  2900. }
  2901. try {
  2902. const xfa = acroForm.get("XFA");
  2903. const hasXfa = Array.isArray(xfa) && xfa.length > 0 || (0, _primitives.isStream)(xfa) && !xfa.isEmpty;
  2904. formInfo.hasXfa = hasXfa;
  2905. const fields = acroForm.get("Fields");
  2906. const hasFields = Array.isArray(fields) && fields.length > 0;
  2907. const sigFlags = acroForm.get("SigFlags");
  2908. const hasOnlyDocumentSignatures = !!(sigFlags & 0x1) && this._hasOnlyDocumentSignatures(fields);
  2909. formInfo.hasAcroForm = hasFields && !hasOnlyDocumentSignatures;
  2910. } catch (ex) {
  2911. if (ex instanceof _core_utils.MissingDataException) {
  2912. throw ex;
  2913. }
  2914. (0, _util.info)("Cannot fetch form information.");
  2915. }
  2916. return (0, _util.shadow)(this, "formInfo", formInfo);
  2917. }
  2918. get documentInfo() {
  2919. const DocumentInfoValidators = {
  2920. Title: _util.isString,
  2921. Author: _util.isString,
  2922. Subject: _util.isString,
  2923. Keywords: _util.isString,
  2924. Creator: _util.isString,
  2925. Producer: _util.isString,
  2926. CreationDate: _util.isString,
  2927. ModDate: _util.isString,
  2928. Trapped: _primitives.isName
  2929. };
  2930. let version = this._version;
  2931. if (typeof version !== "string" || !PDF_HEADER_VERSION_REGEXP.test(version)) {
  2932. (0, _util.warn)(`Invalid PDF header version number: ${version}`);
  2933. version = null;
  2934. }
  2935. const docInfo = {
  2936. PDFFormatVersion: version,
  2937. IsLinearized: !!this.linearization,
  2938. IsAcroFormPresent: this.formInfo.hasAcroForm,
  2939. IsXFAPresent: this.formInfo.hasXfa,
  2940. IsCollectionPresent: !!this.catalog.collection
  2941. };
  2942. let infoDict;
  2943. try {
  2944. infoDict = this.xref.trailer.get("Info");
  2945. } catch (err) {
  2946. if (err instanceof _core_utils.MissingDataException) {
  2947. throw err;
  2948. }
  2949. (0, _util.info)("The document information dictionary is invalid.");
  2950. }
  2951. if ((0, _primitives.isDict)(infoDict)) {
  2952. for (const key of infoDict.getKeys()) {
  2953. const value = infoDict.get(key);
  2954. if (DocumentInfoValidators[key]) {
  2955. if (DocumentInfoValidators[key](value)) {
  2956. docInfo[key] = typeof value !== "string" ? value : (0, _util.stringToPDFString)(value);
  2957. } else {
  2958. (0, _util.info)(`Bad value in document info for "${key}".`);
  2959. }
  2960. } else if (typeof key === "string") {
  2961. let customValue;
  2962. if ((0, _util.isString)(value)) {
  2963. customValue = (0, _util.stringToPDFString)(value);
  2964. } else if ((0, _primitives.isName)(value) || (0, _util.isNum)(value) || (0, _util.isBool)(value)) {
  2965. customValue = value;
  2966. } else {
  2967. (0, _util.info)(`Unsupported value in document info for (custom) "${key}".`);
  2968. continue;
  2969. }
  2970. if (!docInfo.Custom) {
  2971. docInfo.Custom = Object.create(null);
  2972. }
  2973. docInfo.Custom[key] = customValue;
  2974. }
  2975. }
  2976. }
  2977. return (0, _util.shadow)(this, "documentInfo", docInfo);
  2978. }
  2979. get fingerprint() {
  2980. let hash;
  2981. const idArray = this.xref.trailer.get("ID");
  2982. if (Array.isArray(idArray) && idArray[0] && (0, _util.isString)(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  2983. hash = (0, _util.stringToBytes)(idArray[0]);
  2984. } else {
  2985. hash = (0, _crypto.calculateMD5)(this.stream.getByteRange(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  2986. }
  2987. const fingerprintBuf = [];
  2988. for (let i = 0, ii = hash.length; i < ii; i++) {
  2989. const hex = hash[i].toString(16);
  2990. fingerprintBuf.push(hex.padStart(2, "0"));
  2991. }
  2992. return (0, _util.shadow)(this, "fingerprint", fingerprintBuf.join(""));
  2993. }
  2994. _getLinearizationPage(pageIndex) {
  2995. const {
  2996. catalog,
  2997. linearization
  2998. } = this;
  2999. const ref = _primitives.Ref.get(linearization.objectNumberFirst, 0);
  3000. return this.xref.fetchAsync(ref).then(obj => {
  3001. if ((0, _primitives.isDict)(obj, "Page") || (0, _primitives.isDict)(obj) && !obj.has("Type") && obj.has("Contents")) {
  3002. if (ref && !catalog.pageKidsCountCache.has(ref)) {
  3003. catalog.pageKidsCountCache.put(ref, 1);
  3004. }
  3005. return [obj, ref];
  3006. }
  3007. throw new _util.FormatError("The Linearization dictionary doesn't point " + "to a valid Page dictionary.");
  3008. }).catch(reason => {
  3009. (0, _util.info)(reason);
  3010. return catalog.getPageDict(pageIndex);
  3011. });
  3012. }
  3013. getPage(pageIndex) {
  3014. if (this._pagePromises[pageIndex] !== undefined) {
  3015. return this._pagePromises[pageIndex];
  3016. }
  3017. const {
  3018. catalog,
  3019. linearization
  3020. } = this;
  3021. const promise = linearization && linearization.pageFirst === pageIndex ? this._getLinearizationPage(pageIndex) : catalog.getPageDict(pageIndex);
  3022. return this._pagePromises[pageIndex] = promise.then(([pageDict, ref]) => {
  3023. return new Page({
  3024. pdfManager: this.pdfManager,
  3025. xref: this.xref,
  3026. pageIndex,
  3027. pageDict,
  3028. ref,
  3029. globalIdFactory: this._globalIdFactory,
  3030. fontCache: catalog.fontCache,
  3031. builtInCMapCache: catalog.builtInCMapCache,
  3032. globalImageCache: catalog.globalImageCache
  3033. });
  3034. });
  3035. }
  3036. checkFirstPage() {
  3037. return this.getPage(0).catch(async reason => {
  3038. if (reason instanceof _core_utils.XRefEntryException) {
  3039. this._pagePromises.length = 0;
  3040. await this.cleanup();
  3041. throw new _core_utils.XRefParseException();
  3042. }
  3043. });
  3044. }
  3045. fontFallback(id, handler) {
  3046. return this.catalog.fontFallback(id, handler);
  3047. }
  3048. async cleanup(manuallyTriggered = false) {
  3049. return this.catalog ? this.catalog.cleanup(manuallyTriggered) : (0, _primitives.clearPrimitiveCaches)();
  3050. }
  3051. }
  3052. exports.PDFDocument = PDFDocument;
  3053. /***/ }),
  3054. /* 10 */
  3055. /***/ (function(module, exports, __w_pdfjs_require__) {
  3056. "use strict";
  3057. Object.defineProperty(exports, "__esModule", {
  3058. value: true
  3059. });
  3060. exports.FileSpec = exports.XRef = exports.ObjectLoader = exports.Catalog = void 0;
  3061. var _util = __w_pdfjs_require__(2);
  3062. var _primitives = __w_pdfjs_require__(5);
  3063. var _parser = __w_pdfjs_require__(11);
  3064. var _core_utils = __w_pdfjs_require__(8);
  3065. var _crypto = __w_pdfjs_require__(22);
  3066. var _colorspace = __w_pdfjs_require__(23);
  3067. var _image_utils = __w_pdfjs_require__(24);
  3068. function fetchDestination(dest) {
  3069. return (0, _primitives.isDict)(dest) ? dest.get("D") : dest;
  3070. }
  3071. class Catalog {
  3072. constructor(pdfManager, xref) {
  3073. this.pdfManager = pdfManager;
  3074. this.xref = xref;
  3075. this._catDict = xref.getCatalogObj();
  3076. if (!(0, _primitives.isDict)(this._catDict)) {
  3077. throw new _util.FormatError("Catalog object is not a dictionary.");
  3078. }
  3079. this.fontCache = new _primitives.RefSetCache();
  3080. this.builtInCMapCache = new Map();
  3081. this.globalImageCache = new _image_utils.GlobalImageCache();
  3082. this.pageKidsCountCache = new _primitives.RefSetCache();
  3083. }
  3084. get version() {
  3085. const version = this._catDict.get("Version");
  3086. if (!(0, _primitives.isName)(version)) {
  3087. return (0, _util.shadow)(this, "version", null);
  3088. }
  3089. return (0, _util.shadow)(this, "version", version.name);
  3090. }
  3091. get collection() {
  3092. let collection = null;
  3093. try {
  3094. const obj = this._catDict.get("Collection");
  3095. if ((0, _primitives.isDict)(obj) && obj.size > 0) {
  3096. collection = obj;
  3097. }
  3098. } catch (ex) {
  3099. if (ex instanceof _core_utils.MissingDataException) {
  3100. throw ex;
  3101. }
  3102. (0, _util.info)("Cannot fetch Collection entry; assuming no collection is present.");
  3103. }
  3104. return (0, _util.shadow)(this, "collection", collection);
  3105. }
  3106. get acroForm() {
  3107. let acroForm = null;
  3108. try {
  3109. const obj = this._catDict.get("AcroForm");
  3110. if ((0, _primitives.isDict)(obj) && obj.size > 0) {
  3111. acroForm = obj;
  3112. }
  3113. } catch (ex) {
  3114. if (ex instanceof _core_utils.MissingDataException) {
  3115. throw ex;
  3116. }
  3117. (0, _util.info)("Cannot fetch AcroForm entry; assuming no forms are present.");
  3118. }
  3119. return (0, _util.shadow)(this, "acroForm", acroForm);
  3120. }
  3121. get metadata() {
  3122. const streamRef = this._catDict.getRaw("Metadata");
  3123. if (!(0, _primitives.isRef)(streamRef)) {
  3124. return (0, _util.shadow)(this, "metadata", null);
  3125. }
  3126. const suppressEncryption = !(this.xref.encrypt && this.xref.encrypt.encryptMetadata);
  3127. const stream = this.xref.fetch(streamRef, suppressEncryption);
  3128. let metadata;
  3129. if (stream && (0, _primitives.isDict)(stream.dict)) {
  3130. const type = stream.dict.get("Type");
  3131. const subtype = stream.dict.get("Subtype");
  3132. if ((0, _primitives.isName)(type, "Metadata") && (0, _primitives.isName)(subtype, "XML")) {
  3133. try {
  3134. metadata = (0, _util.stringToUTF8String)((0, _util.bytesToString)(stream.getBytes()));
  3135. } catch (e) {
  3136. if (e instanceof _core_utils.MissingDataException) {
  3137. throw e;
  3138. }
  3139. (0, _util.info)("Skipping invalid metadata.");
  3140. }
  3141. }
  3142. }
  3143. return (0, _util.shadow)(this, "metadata", metadata);
  3144. }
  3145. get toplevelPagesDict() {
  3146. const pagesObj = this._catDict.get("Pages");
  3147. if (!(0, _primitives.isDict)(pagesObj)) {
  3148. throw new _util.FormatError("Invalid top-level pages dictionary.");
  3149. }
  3150. return (0, _util.shadow)(this, "toplevelPagesDict", pagesObj);
  3151. }
  3152. get documentOutline() {
  3153. let obj = null;
  3154. try {
  3155. obj = this._readDocumentOutline();
  3156. } catch (ex) {
  3157. if (ex instanceof _core_utils.MissingDataException) {
  3158. throw ex;
  3159. }
  3160. (0, _util.warn)("Unable to read document outline.");
  3161. }
  3162. return (0, _util.shadow)(this, "documentOutline", obj);
  3163. }
  3164. _readDocumentOutline() {
  3165. let obj = this._catDict.get("Outlines");
  3166. if (!(0, _primitives.isDict)(obj)) {
  3167. return null;
  3168. }
  3169. obj = obj.getRaw("First");
  3170. if (!(0, _primitives.isRef)(obj)) {
  3171. return null;
  3172. }
  3173. const root = {
  3174. items: []
  3175. };
  3176. const queue = [{
  3177. obj,
  3178. parent: root
  3179. }];
  3180. const processed = new _primitives.RefSet();
  3181. processed.put(obj);
  3182. const xref = this.xref,
  3183. blackColor = new Uint8ClampedArray(3);
  3184. while (queue.length > 0) {
  3185. const i = queue.shift();
  3186. const outlineDict = xref.fetchIfRef(i.obj);
  3187. if (outlineDict === null) {
  3188. continue;
  3189. }
  3190. if (!outlineDict.has("Title")) {
  3191. throw new _util.FormatError("Invalid outline item encountered.");
  3192. }
  3193. const data = {
  3194. url: null,
  3195. dest: null
  3196. };
  3197. Catalog.parseDestDictionary({
  3198. destDict: outlineDict,
  3199. resultObj: data,
  3200. docBaseUrl: this.pdfManager.docBaseUrl
  3201. });
  3202. const title = outlineDict.get("Title");
  3203. const flags = outlineDict.get("F") || 0;
  3204. const color = outlineDict.getArray("C");
  3205. const count = outlineDict.get("Count");
  3206. let rgbColor = blackColor;
  3207. if (Array.isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  3208. rgbColor = _colorspace.ColorSpace.singletons.rgb.getRgb(color, 0);
  3209. }
  3210. const outlineItem = {
  3211. dest: data.dest,
  3212. url: data.url,
  3213. unsafeUrl: data.unsafeUrl,
  3214. newWindow: data.newWindow,
  3215. title: (0, _util.stringToPDFString)(title),
  3216. color: rgbColor,
  3217. count: Number.isInteger(count) ? count : undefined,
  3218. bold: !!(flags & 2),
  3219. italic: !!(flags & 1),
  3220. items: []
  3221. };
  3222. i.parent.items.push(outlineItem);
  3223. obj = outlineDict.getRaw("First");
  3224. if ((0, _primitives.isRef)(obj) && !processed.has(obj)) {
  3225. queue.push({
  3226. obj,
  3227. parent: outlineItem
  3228. });
  3229. processed.put(obj);
  3230. }
  3231. obj = outlineDict.getRaw("Next");
  3232. if ((0, _primitives.isRef)(obj) && !processed.has(obj)) {
  3233. queue.push({
  3234. obj,
  3235. parent: i.parent
  3236. });
  3237. processed.put(obj);
  3238. }
  3239. }
  3240. return root.items.length > 0 ? root.items : null;
  3241. }
  3242. get permissions() {
  3243. let permissions = null;
  3244. try {
  3245. permissions = this._readPermissions();
  3246. } catch (ex) {
  3247. if (ex instanceof _core_utils.MissingDataException) {
  3248. throw ex;
  3249. }
  3250. (0, _util.warn)("Unable to read permissions.");
  3251. }
  3252. return (0, _util.shadow)(this, "permissions", permissions);
  3253. }
  3254. _readPermissions() {
  3255. const encrypt = this.xref.trailer.get("Encrypt");
  3256. if (!(0, _primitives.isDict)(encrypt)) {
  3257. return null;
  3258. }
  3259. let flags = encrypt.get("P");
  3260. if (!(0, _util.isNum)(flags)) {
  3261. return null;
  3262. }
  3263. flags += 2 ** 32;
  3264. const permissions = [];
  3265. for (const key in _util.PermissionFlag) {
  3266. const value = _util.PermissionFlag[key];
  3267. if (flags & value) {
  3268. permissions.push(value);
  3269. }
  3270. }
  3271. return permissions;
  3272. }
  3273. get optionalContentConfig() {
  3274. let config = null;
  3275. try {
  3276. const properties = this._catDict.get("OCProperties");
  3277. if (!properties) {
  3278. return (0, _util.shadow)(this, "optionalContentConfig", null);
  3279. }
  3280. const defaultConfig = properties.get("D");
  3281. if (!defaultConfig) {
  3282. return (0, _util.shadow)(this, "optionalContentConfig", null);
  3283. }
  3284. const groupsData = properties.get("OCGs");
  3285. if (!Array.isArray(groupsData)) {
  3286. return (0, _util.shadow)(this, "optionalContentConfig", null);
  3287. }
  3288. const groups = [];
  3289. const groupRefs = [];
  3290. for (const groupRef of groupsData) {
  3291. if (!(0, _primitives.isRef)(groupRef)) {
  3292. continue;
  3293. }
  3294. groupRefs.push(groupRef);
  3295. const group = this.xref.fetchIfRef(groupRef);
  3296. groups.push({
  3297. id: groupRef.toString(),
  3298. name: (0, _util.isString)(group.get("Name")) ? (0, _util.stringToPDFString)(group.get("Name")) : null,
  3299. intent: (0, _util.isString)(group.get("Intent")) ? (0, _util.stringToPDFString)(group.get("Intent")) : null
  3300. });
  3301. }
  3302. config = this._readOptionalContentConfig(defaultConfig, groupRefs);
  3303. config.groups = groups;
  3304. } catch (ex) {
  3305. if (ex instanceof _core_utils.MissingDataException) {
  3306. throw ex;
  3307. }
  3308. (0, _util.warn)(`Unable to read optional content config: ${ex}`);
  3309. }
  3310. return (0, _util.shadow)(this, "optionalContentConfig", config);
  3311. }
  3312. _readOptionalContentConfig(config, contentGroupRefs) {
  3313. function parseOnOff(refs) {
  3314. const onParsed = [];
  3315. if (Array.isArray(refs)) {
  3316. for (const value of refs) {
  3317. if (!(0, _primitives.isRef)(value)) {
  3318. continue;
  3319. }
  3320. if (contentGroupRefs.includes(value)) {
  3321. onParsed.push(value.toString());
  3322. }
  3323. }
  3324. }
  3325. return onParsed;
  3326. }
  3327. function parseOrder(refs, nestedLevels = 0) {
  3328. if (!Array.isArray(refs)) {
  3329. return null;
  3330. }
  3331. const order = [];
  3332. for (const value of refs) {
  3333. if ((0, _primitives.isRef)(value) && contentGroupRefs.includes(value)) {
  3334. parsedOrderRefs.put(value);
  3335. order.push(value.toString());
  3336. continue;
  3337. }
  3338. const nestedOrder = parseNestedOrder(value, nestedLevels);
  3339. if (nestedOrder) {
  3340. order.push(nestedOrder);
  3341. }
  3342. }
  3343. if (nestedLevels > 0) {
  3344. return order;
  3345. }
  3346. const hiddenGroups = [];
  3347. for (const groupRef of contentGroupRefs) {
  3348. if (parsedOrderRefs.has(groupRef)) {
  3349. continue;
  3350. }
  3351. hiddenGroups.push(groupRef.toString());
  3352. }
  3353. if (hiddenGroups.length) {
  3354. order.push({
  3355. name: null,
  3356. order: hiddenGroups
  3357. });
  3358. }
  3359. return order;
  3360. }
  3361. function parseNestedOrder(ref, nestedLevels) {
  3362. if (++nestedLevels > MAX_NESTED_LEVELS) {
  3363. (0, _util.warn)("parseNestedOrder - reached MAX_NESTED_LEVELS.");
  3364. return null;
  3365. }
  3366. const value = xref.fetchIfRef(ref);
  3367. if (!Array.isArray(value)) {
  3368. return null;
  3369. }
  3370. const nestedName = xref.fetchIfRef(value[0]);
  3371. if (typeof nestedName !== "string") {
  3372. return null;
  3373. }
  3374. const nestedOrder = parseOrder(value.slice(1), nestedLevels);
  3375. if (!nestedOrder || !nestedOrder.length) {
  3376. return null;
  3377. }
  3378. return {
  3379. name: (0, _util.stringToPDFString)(nestedName),
  3380. order: nestedOrder
  3381. };
  3382. }
  3383. const xref = this.xref,
  3384. parsedOrderRefs = new _primitives.RefSet(),
  3385. MAX_NESTED_LEVELS = 10;
  3386. return {
  3387. name: (0, _util.isString)(config.get("Name")) ? (0, _util.stringToPDFString)(config.get("Name")) : null,
  3388. creator: (0, _util.isString)(config.get("Creator")) ? (0, _util.stringToPDFString)(config.get("Creator")) : null,
  3389. baseState: (0, _primitives.isName)(config.get("BaseState")) ? config.get("BaseState").name : null,
  3390. on: parseOnOff(config.get("ON")),
  3391. off: parseOnOff(config.get("OFF")),
  3392. order: parseOrder(config.get("Order")),
  3393. groups: null
  3394. };
  3395. }
  3396. get numPages() {
  3397. const obj = this.toplevelPagesDict.get("Count");
  3398. if (!Number.isInteger(obj)) {
  3399. throw new _util.FormatError("Page count in top-level pages dictionary is not an integer.");
  3400. }
  3401. return (0, _util.shadow)(this, "numPages", obj);
  3402. }
  3403. get destinations() {
  3404. const obj = this._readDests(),
  3405. dests = Object.create(null);
  3406. if (obj instanceof NameTree) {
  3407. const names = obj.getAll();
  3408. for (const name in names) {
  3409. dests[name] = fetchDestination(names[name]);
  3410. }
  3411. } else if (obj instanceof _primitives.Dict) {
  3412. obj.forEach(function (key, value) {
  3413. if (value) {
  3414. dests[key] = fetchDestination(value);
  3415. }
  3416. });
  3417. }
  3418. return (0, _util.shadow)(this, "destinations", dests);
  3419. }
  3420. getDestination(destinationId) {
  3421. const obj = this._readDests();
  3422. if (obj instanceof NameTree || obj instanceof _primitives.Dict) {
  3423. return fetchDestination(obj.get(destinationId) || null);
  3424. }
  3425. return null;
  3426. }
  3427. _readDests() {
  3428. const obj = this._catDict.get("Names");
  3429. if (obj && obj.has("Dests")) {
  3430. return new NameTree(obj.getRaw("Dests"), this.xref);
  3431. } else if (this._catDict.has("Dests")) {
  3432. return this._catDict.get("Dests");
  3433. }
  3434. return undefined;
  3435. }
  3436. get pageLabels() {
  3437. let obj = null;
  3438. try {
  3439. obj = this._readPageLabels();
  3440. } catch (ex) {
  3441. if (ex instanceof _core_utils.MissingDataException) {
  3442. throw ex;
  3443. }
  3444. (0, _util.warn)("Unable to read page labels.");
  3445. }
  3446. return (0, _util.shadow)(this, "pageLabels", obj);
  3447. }
  3448. _readPageLabels() {
  3449. const obj = this._catDict.getRaw("PageLabels");
  3450. if (!obj) {
  3451. return null;
  3452. }
  3453. const pageLabels = new Array(this.numPages);
  3454. let style = null,
  3455. prefix = "";
  3456. const numberTree = new NumberTree(obj, this.xref);
  3457. const nums = numberTree.getAll();
  3458. let currentLabel = "",
  3459. currentIndex = 1;
  3460. for (let i = 0, ii = this.numPages; i < ii; i++) {
  3461. if (i in nums) {
  3462. const labelDict = nums[i];
  3463. if (!(0, _primitives.isDict)(labelDict)) {
  3464. throw new _util.FormatError("PageLabel is not a dictionary.");
  3465. }
  3466. if (labelDict.has("Type") && !(0, _primitives.isName)(labelDict.get("Type"), "PageLabel")) {
  3467. throw new _util.FormatError("Invalid type in PageLabel dictionary.");
  3468. }
  3469. if (labelDict.has("S")) {
  3470. const s = labelDict.get("S");
  3471. if (!(0, _primitives.isName)(s)) {
  3472. throw new _util.FormatError("Invalid style in PageLabel dictionary.");
  3473. }
  3474. style = s.name;
  3475. } else {
  3476. style = null;
  3477. }
  3478. if (labelDict.has("P")) {
  3479. const p = labelDict.get("P");
  3480. if (!(0, _util.isString)(p)) {
  3481. throw new _util.FormatError("Invalid prefix in PageLabel dictionary.");
  3482. }
  3483. prefix = (0, _util.stringToPDFString)(p);
  3484. } else {
  3485. prefix = "";
  3486. }
  3487. if (labelDict.has("St")) {
  3488. const st = labelDict.get("St");
  3489. if (!(Number.isInteger(st) && st >= 1)) {
  3490. throw new _util.FormatError("Invalid start in PageLabel dictionary.");
  3491. }
  3492. currentIndex = st;
  3493. } else {
  3494. currentIndex = 1;
  3495. }
  3496. }
  3497. switch (style) {
  3498. case "D":
  3499. currentLabel = currentIndex;
  3500. break;
  3501. case "R":
  3502. case "r":
  3503. currentLabel = (0, _core_utils.toRomanNumerals)(currentIndex, style === "r");
  3504. break;
  3505. case "A":
  3506. case "a":
  3507. const LIMIT = 26;
  3508. const A_UPPER_CASE = 0x41,
  3509. A_LOWER_CASE = 0x61;
  3510. const baseCharCode = style === "a" ? A_LOWER_CASE : A_UPPER_CASE;
  3511. const letterIndex = currentIndex - 1;
  3512. const character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  3513. const charBuf = [];
  3514. for (let j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  3515. charBuf.push(character);
  3516. }
  3517. currentLabel = charBuf.join("");
  3518. break;
  3519. default:
  3520. if (style) {
  3521. throw new _util.FormatError(`Invalid style "${style}" in PageLabel dictionary.`);
  3522. }
  3523. currentLabel = "";
  3524. }
  3525. pageLabels[i] = prefix + currentLabel;
  3526. currentIndex++;
  3527. }
  3528. return pageLabels;
  3529. }
  3530. get pageLayout() {
  3531. const obj = this._catDict.get("PageLayout");
  3532. let pageLayout = "";
  3533. if ((0, _primitives.isName)(obj)) {
  3534. switch (obj.name) {
  3535. case "SinglePage":
  3536. case "OneColumn":
  3537. case "TwoColumnLeft":
  3538. case "TwoColumnRight":
  3539. case "TwoPageLeft":
  3540. case "TwoPageRight":
  3541. pageLayout = obj.name;
  3542. }
  3543. }
  3544. return (0, _util.shadow)(this, "pageLayout", pageLayout);
  3545. }
  3546. get pageMode() {
  3547. const obj = this._catDict.get("PageMode");
  3548. let pageMode = "UseNone";
  3549. if ((0, _primitives.isName)(obj)) {
  3550. switch (obj.name) {
  3551. case "UseNone":
  3552. case "UseOutlines":
  3553. case "UseThumbs":
  3554. case "FullScreen":
  3555. case "UseOC":
  3556. case "UseAttachments":
  3557. pageMode = obj.name;
  3558. }
  3559. }
  3560. return (0, _util.shadow)(this, "pageMode", pageMode);
  3561. }
  3562. get viewerPreferences() {
  3563. const ViewerPreferencesValidators = {
  3564. HideToolbar: _util.isBool,
  3565. HideMenubar: _util.isBool,
  3566. HideWindowUI: _util.isBool,
  3567. FitWindow: _util.isBool,
  3568. CenterWindow: _util.isBool,
  3569. DisplayDocTitle: _util.isBool,
  3570. NonFullScreenPageMode: _primitives.isName,
  3571. Direction: _primitives.isName,
  3572. ViewArea: _primitives.isName,
  3573. ViewClip: _primitives.isName,
  3574. PrintArea: _primitives.isName,
  3575. PrintClip: _primitives.isName,
  3576. PrintScaling: _primitives.isName,
  3577. Duplex: _primitives.isName,
  3578. PickTrayByPDFSize: _util.isBool,
  3579. PrintPageRange: Array.isArray,
  3580. NumCopies: Number.isInteger
  3581. };
  3582. const obj = this._catDict.get("ViewerPreferences");
  3583. let prefs = null;
  3584. if ((0, _primitives.isDict)(obj)) {
  3585. for (const key in ViewerPreferencesValidators) {
  3586. if (!obj.has(key)) {
  3587. continue;
  3588. }
  3589. const value = obj.get(key);
  3590. if (!ViewerPreferencesValidators[key](value)) {
  3591. (0, _util.info)(`Bad value in ViewerPreferences for "${key}".`);
  3592. continue;
  3593. }
  3594. let prefValue;
  3595. switch (key) {
  3596. case "NonFullScreenPageMode":
  3597. switch (value.name) {
  3598. case "UseNone":
  3599. case "UseOutlines":
  3600. case "UseThumbs":
  3601. case "UseOC":
  3602. prefValue = value.name;
  3603. break;
  3604. default:
  3605. prefValue = "UseNone";
  3606. }
  3607. break;
  3608. case "Direction":
  3609. switch (value.name) {
  3610. case "L2R":
  3611. case "R2L":
  3612. prefValue = value.name;
  3613. break;
  3614. default:
  3615. prefValue = "L2R";
  3616. }
  3617. break;
  3618. case "ViewArea":
  3619. case "ViewClip":
  3620. case "PrintArea":
  3621. case "PrintClip":
  3622. switch (value.name) {
  3623. case "MediaBox":
  3624. case "CropBox":
  3625. case "BleedBox":
  3626. case "TrimBox":
  3627. case "ArtBox":
  3628. prefValue = value.name;
  3629. break;
  3630. default:
  3631. prefValue = "CropBox";
  3632. }
  3633. break;
  3634. case "PrintScaling":
  3635. switch (value.name) {
  3636. case "None":
  3637. case "AppDefault":
  3638. prefValue = value.name;
  3639. break;
  3640. default:
  3641. prefValue = "AppDefault";
  3642. }
  3643. break;
  3644. case "Duplex":
  3645. switch (value.name) {
  3646. case "Simplex":
  3647. case "DuplexFlipShortEdge":
  3648. case "DuplexFlipLongEdge":
  3649. prefValue = value.name;
  3650. break;
  3651. default:
  3652. prefValue = "None";
  3653. }
  3654. break;
  3655. case "PrintPageRange":
  3656. const length = value.length;
  3657. if (length % 2 !== 0) {
  3658. break;
  3659. }
  3660. const isValid = value.every((page, i, arr) => {
  3661. return Number.isInteger(page) && page > 0 && (i === 0 || page >= arr[i - 1]) && page <= this.numPages;
  3662. });
  3663. if (isValid) {
  3664. prefValue = value;
  3665. }
  3666. break;
  3667. case "NumCopies":
  3668. if (value > 0) {
  3669. prefValue = value;
  3670. }
  3671. break;
  3672. default:
  3673. if (typeof value !== "boolean") {
  3674. throw new _util.FormatError(`viewerPreferences - expected a boolean value for: ${key}`);
  3675. }
  3676. prefValue = value;
  3677. }
  3678. if (prefValue !== undefined) {
  3679. if (!prefs) {
  3680. prefs = Object.create(null);
  3681. }
  3682. prefs[key] = prefValue;
  3683. } else {
  3684. (0, _util.info)(`Bad value in ViewerPreferences for "${key}".`);
  3685. }
  3686. }
  3687. }
  3688. return (0, _util.shadow)(this, "viewerPreferences", prefs);
  3689. }
  3690. get openAction() {
  3691. const obj = this._catDict.get("OpenAction");
  3692. let openAction = null;
  3693. if ((0, _primitives.isDict)(obj)) {
  3694. const destDict = new _primitives.Dict(this.xref);
  3695. destDict.set("A", obj);
  3696. const resultObj = {
  3697. url: null,
  3698. dest: null,
  3699. action: null
  3700. };
  3701. Catalog.parseDestDictionary({
  3702. destDict,
  3703. resultObj
  3704. });
  3705. if (Array.isArray(resultObj.dest)) {
  3706. if (!openAction) {
  3707. openAction = Object.create(null);
  3708. }
  3709. openAction.dest = resultObj.dest;
  3710. } else if (resultObj.action) {
  3711. if (!openAction) {
  3712. openAction = Object.create(null);
  3713. }
  3714. openAction.action = resultObj.action;
  3715. }
  3716. } else if (Array.isArray(obj)) {
  3717. if (!openAction) {
  3718. openAction = Object.create(null);
  3719. }
  3720. openAction.dest = obj;
  3721. }
  3722. return (0, _util.shadow)(this, "openAction", openAction);
  3723. }
  3724. get attachments() {
  3725. const obj = this._catDict.get("Names");
  3726. let attachments = null;
  3727. if (obj && obj.has("EmbeddedFiles")) {
  3728. const nameTree = new NameTree(obj.getRaw("EmbeddedFiles"), this.xref);
  3729. const names = nameTree.getAll();
  3730. for (const name in names) {
  3731. const fs = new FileSpec(names[name], this.xref);
  3732. if (!attachments) {
  3733. attachments = Object.create(null);
  3734. }
  3735. attachments[(0, _util.stringToPDFString)(name)] = fs.serializable;
  3736. }
  3737. }
  3738. return (0, _util.shadow)(this, "attachments", attachments);
  3739. }
  3740. get javaScript() {
  3741. const obj = this._catDict.get("Names");
  3742. let javaScript = null;
  3743. function appendIfJavaScriptDict(jsDict) {
  3744. const type = jsDict.get("S");
  3745. if (!(0, _primitives.isName)(type, "JavaScript")) {
  3746. return;
  3747. }
  3748. let js = jsDict.get("JS");
  3749. if ((0, _primitives.isStream)(js)) {
  3750. js = (0, _util.bytesToString)(js.getBytes());
  3751. } else if (!(0, _util.isString)(js)) {
  3752. return;
  3753. }
  3754. if (!javaScript) {
  3755. javaScript = [];
  3756. }
  3757. javaScript.push((0, _util.stringToPDFString)(js));
  3758. }
  3759. if (obj && obj.has("JavaScript")) {
  3760. const nameTree = new NameTree(obj.getRaw("JavaScript"), this.xref);
  3761. const names = nameTree.getAll();
  3762. for (const name in names) {
  3763. const jsDict = names[name];
  3764. if ((0, _primitives.isDict)(jsDict)) {
  3765. appendIfJavaScriptDict(jsDict);
  3766. }
  3767. }
  3768. }
  3769. const openAction = this._catDict.get("OpenAction");
  3770. if ((0, _primitives.isDict)(openAction) && (0, _primitives.isName)(openAction.get("S"), "JavaScript")) {
  3771. appendIfJavaScriptDict(openAction);
  3772. }
  3773. return (0, _util.shadow)(this, "javaScript", javaScript);
  3774. }
  3775. fontFallback(id, handler) {
  3776. const promises = [];
  3777. this.fontCache.forEach(function (promise) {
  3778. promises.push(promise);
  3779. });
  3780. return Promise.all(promises).then(translatedFonts => {
  3781. for (const translatedFont of translatedFonts) {
  3782. if (translatedFont.loadedName === id) {
  3783. translatedFont.fallback(handler);
  3784. return;
  3785. }
  3786. }
  3787. });
  3788. }
  3789. cleanup(manuallyTriggered = false) {
  3790. (0, _primitives.clearPrimitiveCaches)();
  3791. this.globalImageCache.clear(manuallyTriggered);
  3792. this.pageKidsCountCache.clear();
  3793. const promises = [];
  3794. this.fontCache.forEach(function (promise) {
  3795. promises.push(promise);
  3796. });
  3797. return Promise.all(promises).then(translatedFonts => {
  3798. for (const {
  3799. dict
  3800. } of translatedFonts) {
  3801. delete dict.translated;
  3802. }
  3803. this.fontCache.clear();
  3804. this.builtInCMapCache.clear();
  3805. });
  3806. }
  3807. getPageDict(pageIndex) {
  3808. const capability = (0, _util.createPromiseCapability)();
  3809. const nodesToVisit = [this._catDict.getRaw("Pages")];
  3810. const visitedNodes = new _primitives.RefSet();
  3811. const xref = this.xref,
  3812. pageKidsCountCache = this.pageKidsCountCache;
  3813. let count,
  3814. currentPageIndex = 0;
  3815. function next() {
  3816. while (nodesToVisit.length) {
  3817. const currentNode = nodesToVisit.pop();
  3818. if ((0, _primitives.isRef)(currentNode)) {
  3819. count = pageKidsCountCache.get(currentNode);
  3820. if (count > 0 && currentPageIndex + count < pageIndex) {
  3821. currentPageIndex += count;
  3822. continue;
  3823. }
  3824. if (visitedNodes.has(currentNode)) {
  3825. capability.reject(new _util.FormatError("Pages tree contains circular reference."));
  3826. return;
  3827. }
  3828. visitedNodes.put(currentNode);
  3829. xref.fetchAsync(currentNode).then(function (obj) {
  3830. if ((0, _primitives.isDict)(obj, "Page") || (0, _primitives.isDict)(obj) && !obj.has("Kids")) {
  3831. if (pageIndex === currentPageIndex) {
  3832. if (currentNode && !pageKidsCountCache.has(currentNode)) {
  3833. pageKidsCountCache.put(currentNode, 1);
  3834. }
  3835. capability.resolve([obj, currentNode]);
  3836. } else {
  3837. currentPageIndex++;
  3838. next();
  3839. }
  3840. return;
  3841. }
  3842. nodesToVisit.push(obj);
  3843. next();
  3844. }, capability.reject);
  3845. return;
  3846. }
  3847. if (!(0, _primitives.isDict)(currentNode)) {
  3848. capability.reject(new _util.FormatError("Page dictionary kid reference points to wrong type of object."));
  3849. return;
  3850. }
  3851. count = currentNode.get("Count");
  3852. if (Number.isInteger(count) && count >= 0) {
  3853. const objId = currentNode.objId;
  3854. if (objId && !pageKidsCountCache.has(objId)) {
  3855. pageKidsCountCache.put(objId, count);
  3856. }
  3857. if (currentPageIndex + count <= pageIndex) {
  3858. currentPageIndex += count;
  3859. continue;
  3860. }
  3861. }
  3862. const kids = currentNode.get("Kids");
  3863. if (!Array.isArray(kids)) {
  3864. if ((0, _primitives.isName)(currentNode.get("Type"), "Page") || !currentNode.has("Type") && currentNode.has("Contents")) {
  3865. if (currentPageIndex === pageIndex) {
  3866. capability.resolve([currentNode, null]);
  3867. return;
  3868. }
  3869. currentPageIndex++;
  3870. continue;
  3871. }
  3872. capability.reject(new _util.FormatError("Page dictionary kids object is not an array."));
  3873. return;
  3874. }
  3875. for (let last = kids.length - 1; last >= 0; last--) {
  3876. nodesToVisit.push(kids[last]);
  3877. }
  3878. }
  3879. capability.reject(new Error(`Page index ${pageIndex} not found.`));
  3880. }
  3881. next();
  3882. return capability.promise;
  3883. }
  3884. getPageIndex(pageRef) {
  3885. const xref = this.xref;
  3886. function pagesBeforeRef(kidRef) {
  3887. let total = 0,
  3888. parentRef;
  3889. return xref.fetchAsync(kidRef).then(function (node) {
  3890. if ((0, _primitives.isRefsEqual)(kidRef, pageRef) && !(0, _primitives.isDict)(node, "Page") && !((0, _primitives.isDict)(node) && !node.has("Type") && node.has("Contents"))) {
  3891. throw new _util.FormatError("The reference does not point to a /Page dictionary.");
  3892. }
  3893. if (!node) {
  3894. return null;
  3895. }
  3896. if (!(0, _primitives.isDict)(node)) {
  3897. throw new _util.FormatError("Node must be a dictionary.");
  3898. }
  3899. parentRef = node.getRaw("Parent");
  3900. return node.getAsync("Parent");
  3901. }).then(function (parent) {
  3902. if (!parent) {
  3903. return null;
  3904. }
  3905. if (!(0, _primitives.isDict)(parent)) {
  3906. throw new _util.FormatError("Parent must be a dictionary.");
  3907. }
  3908. return parent.getAsync("Kids");
  3909. }).then(function (kids) {
  3910. if (!kids) {
  3911. return null;
  3912. }
  3913. const kidPromises = [];
  3914. let found = false;
  3915. for (let i = 0, ii = kids.length; i < ii; i++) {
  3916. const kid = kids[i];
  3917. if (!(0, _primitives.isRef)(kid)) {
  3918. throw new _util.FormatError("Kid must be a reference.");
  3919. }
  3920. if ((0, _primitives.isRefsEqual)(kid, kidRef)) {
  3921. found = true;
  3922. break;
  3923. }
  3924. kidPromises.push(xref.fetchAsync(kid).then(function (obj) {
  3925. if (!(0, _primitives.isDict)(obj)) {
  3926. throw new _util.FormatError("Kid node must be a dictionary.");
  3927. }
  3928. if (obj.has("Count")) {
  3929. total += obj.get("Count");
  3930. } else {
  3931. total++;
  3932. }
  3933. }));
  3934. }
  3935. if (!found) {
  3936. throw new _util.FormatError("Kid reference not found in parent's kids.");
  3937. }
  3938. return Promise.all(kidPromises).then(function () {
  3939. return [total, parentRef];
  3940. });
  3941. });
  3942. }
  3943. let total = 0;
  3944. function next(ref) {
  3945. return pagesBeforeRef(ref).then(function (args) {
  3946. if (!args) {
  3947. return total;
  3948. }
  3949. const [count, parentRef] = args;
  3950. total += count;
  3951. return next(parentRef);
  3952. });
  3953. }
  3954. return next(pageRef);
  3955. }
  3956. static parseDestDictionary(params) {
  3957. function addDefaultProtocolToUrl(url) {
  3958. return url.startsWith("www.") ? `http://${url}` : url;
  3959. }
  3960. function tryConvertUrlEncoding(url) {
  3961. try {
  3962. return (0, _util.stringToUTF8String)(url);
  3963. } catch (e) {
  3964. return url;
  3965. }
  3966. }
  3967. const destDict = params.destDict;
  3968. if (!(0, _primitives.isDict)(destDict)) {
  3969. (0, _util.warn)("parseDestDictionary: `destDict` must be a dictionary.");
  3970. return;
  3971. }
  3972. const resultObj = params.resultObj;
  3973. if (typeof resultObj !== "object") {
  3974. (0, _util.warn)("parseDestDictionary: `resultObj` must be an object.");
  3975. return;
  3976. }
  3977. const docBaseUrl = params.docBaseUrl || null;
  3978. let action = destDict.get("A"),
  3979. url,
  3980. dest;
  3981. if (!(0, _primitives.isDict)(action) && destDict.has("Dest")) {
  3982. action = destDict.get("Dest");
  3983. }
  3984. if ((0, _primitives.isDict)(action)) {
  3985. const actionType = action.get("S");
  3986. if (!(0, _primitives.isName)(actionType)) {
  3987. (0, _util.warn)("parseDestDictionary: Invalid type in Action dictionary.");
  3988. return;
  3989. }
  3990. const actionName = actionType.name;
  3991. switch (actionName) {
  3992. case "URI":
  3993. url = action.get("URI");
  3994. if ((0, _primitives.isName)(url)) {
  3995. url = "/" + url.name;
  3996. } else if ((0, _util.isString)(url)) {
  3997. url = addDefaultProtocolToUrl(url);
  3998. }
  3999. break;
  4000. case "GoTo":
  4001. dest = action.get("D");
  4002. break;
  4003. case "Launch":
  4004. case "GoToR":
  4005. const urlDict = action.get("F");
  4006. if ((0, _primitives.isDict)(urlDict)) {
  4007. url = urlDict.get("F") || null;
  4008. } else if ((0, _util.isString)(urlDict)) {
  4009. url = urlDict;
  4010. }
  4011. let remoteDest = action.get("D");
  4012. if (remoteDest) {
  4013. if ((0, _primitives.isName)(remoteDest)) {
  4014. remoteDest = remoteDest.name;
  4015. }
  4016. if ((0, _util.isString)(url)) {
  4017. const baseUrl = url.split("#")[0];
  4018. if ((0, _util.isString)(remoteDest)) {
  4019. url = baseUrl + "#" + remoteDest;
  4020. } else if (Array.isArray(remoteDest)) {
  4021. url = baseUrl + "#" + JSON.stringify(remoteDest);
  4022. }
  4023. }
  4024. }
  4025. const newWindow = action.get("NewWindow");
  4026. if ((0, _util.isBool)(newWindow)) {
  4027. resultObj.newWindow = newWindow;
  4028. }
  4029. break;
  4030. case "Named":
  4031. const namedAction = action.get("N");
  4032. if ((0, _primitives.isName)(namedAction)) {
  4033. resultObj.action = namedAction.name;
  4034. }
  4035. break;
  4036. case "JavaScript":
  4037. const jsAction = action.get("JS");
  4038. let js;
  4039. if ((0, _primitives.isStream)(jsAction)) {
  4040. js = (0, _util.bytesToString)(jsAction.getBytes());
  4041. } else if ((0, _util.isString)(jsAction)) {
  4042. js = jsAction;
  4043. }
  4044. if (js) {
  4045. const URL_OPEN_METHODS = ["app.launchURL", "window.open"];
  4046. const regex = new RegExp("^\\s*(" + URL_OPEN_METHODS.join("|").split(".").join("\\.") + ")\\((?:'|\")([^'\"]*)(?:'|\")(?:,\\s*(\\w+)\\)|\\))", "i");
  4047. const jsUrl = regex.exec((0, _util.stringToPDFString)(js));
  4048. if (jsUrl && jsUrl[2]) {
  4049. url = jsUrl[2];
  4050. if (jsUrl[3] === "true" && jsUrl[1] === "app.launchURL") {
  4051. resultObj.newWindow = true;
  4052. }
  4053. break;
  4054. }
  4055. }
  4056. default:
  4057. (0, _util.warn)(`parseDestDictionary: unsupported action type "${actionName}".`);
  4058. break;
  4059. }
  4060. } else if (destDict.has("Dest")) {
  4061. dest = destDict.get("Dest");
  4062. }
  4063. if ((0, _util.isString)(url)) {
  4064. url = tryConvertUrlEncoding(url);
  4065. const absoluteUrl = (0, _util.createValidAbsoluteUrl)(url, docBaseUrl);
  4066. if (absoluteUrl) {
  4067. resultObj.url = absoluteUrl.href;
  4068. }
  4069. resultObj.unsafeUrl = url;
  4070. }
  4071. if (dest) {
  4072. if ((0, _primitives.isName)(dest)) {
  4073. dest = dest.name;
  4074. }
  4075. if ((0, _util.isString)(dest) || Array.isArray(dest)) {
  4076. resultObj.dest = dest;
  4077. }
  4078. }
  4079. }
  4080. }
  4081. exports.Catalog = Catalog;
  4082. var XRef = function XRefClosure() {
  4083. function XRef(stream, pdfManager) {
  4084. this.stream = stream;
  4085. this.pdfManager = pdfManager;
  4086. this.entries = [];
  4087. this.xrefstms = Object.create(null);
  4088. this._cacheMap = new Map();
  4089. this.stats = {
  4090. streamTypes: Object.create(null),
  4091. fontTypes: Object.create(null)
  4092. };
  4093. this._newRefNum = null;
  4094. }
  4095. XRef.prototype = {
  4096. getNewRef: function XRef_getNewRef() {
  4097. if (this._newRefNum === null) {
  4098. this._newRefNum = this.entries.length;
  4099. }
  4100. return _primitives.Ref.get(this._newRefNum++, 0);
  4101. },
  4102. resetNewRef: function XRef_resetNewRef() {
  4103. this._newRefNum = null;
  4104. },
  4105. setStartXRef: function XRef_setStartXRef(startXRef) {
  4106. this.startXRefQueue = [startXRef];
  4107. },
  4108. parse: function XRef_parse(recoveryMode) {
  4109. var trailerDict;
  4110. if (!recoveryMode) {
  4111. trailerDict = this.readXRef();
  4112. } else {
  4113. (0, _util.warn)("Indexing all PDF objects");
  4114. trailerDict = this.indexObjects();
  4115. }
  4116. trailerDict.assignXref(this);
  4117. this.trailer = trailerDict;
  4118. let encrypt;
  4119. try {
  4120. encrypt = trailerDict.get("Encrypt");
  4121. } catch (ex) {
  4122. if (ex instanceof _core_utils.MissingDataException) {
  4123. throw ex;
  4124. }
  4125. (0, _util.warn)(`XRef.parse - Invalid "Encrypt" reference: "${ex}".`);
  4126. }
  4127. if ((0, _primitives.isDict)(encrypt)) {
  4128. var ids = trailerDict.get("ID");
  4129. var fileId = ids && ids.length ? ids[0] : "";
  4130. encrypt.suppressEncryption = true;
  4131. this.encrypt = new _crypto.CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
  4132. }
  4133. let root;
  4134. try {
  4135. root = trailerDict.get("Root");
  4136. } catch (ex) {
  4137. if (ex instanceof _core_utils.MissingDataException) {
  4138. throw ex;
  4139. }
  4140. (0, _util.warn)(`XRef.parse - Invalid "Root" reference: "${ex}".`);
  4141. }
  4142. if ((0, _primitives.isDict)(root) && root.has("Pages")) {
  4143. this.root = root;
  4144. } else {
  4145. if (!recoveryMode) {
  4146. throw new _core_utils.XRefParseException();
  4147. }
  4148. throw new _util.FormatError("Invalid root reference");
  4149. }
  4150. },
  4151. processXRefTable: function XRef_processXRefTable(parser) {
  4152. if (!("tableState" in this)) {
  4153. this.tableState = {
  4154. entryNum: 0,
  4155. streamPos: parser.lexer.stream.pos,
  4156. parserBuf1: parser.buf1,
  4157. parserBuf2: parser.buf2
  4158. };
  4159. }
  4160. var obj = this.readXRefTable(parser);
  4161. if (!(0, _primitives.isCmd)(obj, "trailer")) {
  4162. throw new _util.FormatError("Invalid XRef table: could not find trailer dictionary");
  4163. }
  4164. var dict = parser.getObj();
  4165. if (!(0, _primitives.isDict)(dict) && dict.dict) {
  4166. dict = dict.dict;
  4167. }
  4168. if (!(0, _primitives.isDict)(dict)) {
  4169. throw new _util.FormatError("Invalid XRef table: could not parse trailer dictionary");
  4170. }
  4171. delete this.tableState;
  4172. return dict;
  4173. },
  4174. readXRefTable: function XRef_readXRefTable(parser) {
  4175. var stream = parser.lexer.stream;
  4176. var tableState = this.tableState;
  4177. stream.pos = tableState.streamPos;
  4178. parser.buf1 = tableState.parserBuf1;
  4179. parser.buf2 = tableState.parserBuf2;
  4180. var obj;
  4181. while (true) {
  4182. if (!("firstEntryNum" in tableState) || !("entryCount" in tableState)) {
  4183. if ((0, _primitives.isCmd)(obj = parser.getObj(), "trailer")) {
  4184. break;
  4185. }
  4186. tableState.firstEntryNum = obj;
  4187. tableState.entryCount = parser.getObj();
  4188. }
  4189. var first = tableState.firstEntryNum;
  4190. var count = tableState.entryCount;
  4191. if (!Number.isInteger(first) || !Number.isInteger(count)) {
  4192. throw new _util.FormatError("Invalid XRef table: wrong types in subsection header");
  4193. }
  4194. for (var i = tableState.entryNum; i < count; i++) {
  4195. tableState.streamPos = stream.pos;
  4196. tableState.entryNum = i;
  4197. tableState.parserBuf1 = parser.buf1;
  4198. tableState.parserBuf2 = parser.buf2;
  4199. var entry = {};
  4200. entry.offset = parser.getObj();
  4201. entry.gen = parser.getObj();
  4202. var type = parser.getObj();
  4203. if (type instanceof _primitives.Cmd) {
  4204. switch (type.cmd) {
  4205. case "f":
  4206. entry.free = true;
  4207. break;
  4208. case "n":
  4209. entry.uncompressed = true;
  4210. break;
  4211. }
  4212. }
  4213. if (!Number.isInteger(entry.offset) || !Number.isInteger(entry.gen) || !(entry.free || entry.uncompressed)) {
  4214. throw new _util.FormatError(`Invalid entry in XRef subsection: ${first}, ${count}`);
  4215. }
  4216. if (i === 0 && entry.free && first === 1) {
  4217. first = 0;
  4218. }
  4219. if (!this.entries[i + first]) {
  4220. this.entries[i + first] = entry;
  4221. }
  4222. }
  4223. tableState.entryNum = 0;
  4224. tableState.streamPos = stream.pos;
  4225. tableState.parserBuf1 = parser.buf1;
  4226. tableState.parserBuf2 = parser.buf2;
  4227. delete tableState.firstEntryNum;
  4228. delete tableState.entryCount;
  4229. }
  4230. if (this.entries[0] && !this.entries[0].free) {
  4231. throw new _util.FormatError("Invalid XRef table: unexpected first object");
  4232. }
  4233. return obj;
  4234. },
  4235. processXRefStream: function XRef_processXRefStream(stream) {
  4236. if (!("streamState" in this)) {
  4237. var streamParameters = stream.dict;
  4238. var byteWidths = streamParameters.get("W");
  4239. var range = streamParameters.get("Index");
  4240. if (!range) {
  4241. range = [0, streamParameters.get("Size")];
  4242. }
  4243. this.streamState = {
  4244. entryRanges: range,
  4245. byteWidths,
  4246. entryNum: 0,
  4247. streamPos: stream.pos
  4248. };
  4249. }
  4250. this.readXRefStream(stream);
  4251. delete this.streamState;
  4252. return stream.dict;
  4253. },
  4254. readXRefStream: function XRef_readXRefStream(stream) {
  4255. var i, j;
  4256. var streamState = this.streamState;
  4257. stream.pos = streamState.streamPos;
  4258. var byteWidths = streamState.byteWidths;
  4259. var typeFieldWidth = byteWidths[0];
  4260. var offsetFieldWidth = byteWidths[1];
  4261. var generationFieldWidth = byteWidths[2];
  4262. var entryRanges = streamState.entryRanges;
  4263. while (entryRanges.length > 0) {
  4264. var first = entryRanges[0];
  4265. var n = entryRanges[1];
  4266. if (!Number.isInteger(first) || !Number.isInteger(n)) {
  4267. throw new _util.FormatError(`Invalid XRef range fields: ${first}, ${n}`);
  4268. }
  4269. if (!Number.isInteger(typeFieldWidth) || !Number.isInteger(offsetFieldWidth) || !Number.isInteger(generationFieldWidth)) {
  4270. throw new _util.FormatError(`Invalid XRef entry fields length: ${first}, ${n}`);
  4271. }
  4272. for (i = streamState.entryNum; i < n; ++i) {
  4273. streamState.entryNum = i;
  4274. streamState.streamPos = stream.pos;
  4275. var type = 0,
  4276. offset = 0,
  4277. generation = 0;
  4278. for (j = 0; j < typeFieldWidth; ++j) {
  4279. type = type << 8 | stream.getByte();
  4280. }
  4281. if (typeFieldWidth === 0) {
  4282. type = 1;
  4283. }
  4284. for (j = 0; j < offsetFieldWidth; ++j) {
  4285. offset = offset << 8 | stream.getByte();
  4286. }
  4287. for (j = 0; j < generationFieldWidth; ++j) {
  4288. generation = generation << 8 | stream.getByte();
  4289. }
  4290. var entry = {};
  4291. entry.offset = offset;
  4292. entry.gen = generation;
  4293. switch (type) {
  4294. case 0:
  4295. entry.free = true;
  4296. break;
  4297. case 1:
  4298. entry.uncompressed = true;
  4299. break;
  4300. case 2:
  4301. break;
  4302. default:
  4303. throw new _util.FormatError(`Invalid XRef entry type: ${type}`);
  4304. }
  4305. if (!this.entries[first + i]) {
  4306. this.entries[first + i] = entry;
  4307. }
  4308. }
  4309. streamState.entryNum = 0;
  4310. streamState.streamPos = stream.pos;
  4311. entryRanges.splice(0, 2);
  4312. }
  4313. },
  4314. indexObjects: function XRef_indexObjects() {
  4315. var TAB = 0x9,
  4316. LF = 0xa,
  4317. CR = 0xd,
  4318. SPACE = 0x20;
  4319. var PERCENT = 0x25,
  4320. LT = 0x3c;
  4321. function readToken(data, offset) {
  4322. var token = "",
  4323. ch = data[offset];
  4324. while (ch !== LF && ch !== CR && ch !== LT) {
  4325. if (++offset >= data.length) {
  4326. break;
  4327. }
  4328. token += String.fromCharCode(ch);
  4329. ch = data[offset];
  4330. }
  4331. return token;
  4332. }
  4333. function skipUntil(data, offset, what) {
  4334. var length = what.length,
  4335. dataLength = data.length;
  4336. var skipped = 0;
  4337. while (offset < dataLength) {
  4338. var i = 0;
  4339. while (i < length && data[offset + i] === what[i]) {
  4340. ++i;
  4341. }
  4342. if (i >= length) {
  4343. break;
  4344. }
  4345. offset++;
  4346. skipped++;
  4347. }
  4348. return skipped;
  4349. }
  4350. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  4351. const endobjRegExp = /\bendobj[\b\s]$/;
  4352. const nestedObjRegExp = /\s+(\d+\s+\d+\s+obj[\b\s<])$/;
  4353. const CHECK_CONTENT_LENGTH = 25;
  4354. var trailerBytes = new Uint8Array([116, 114, 97, 105, 108, 101, 114]);
  4355. var startxrefBytes = new Uint8Array([115, 116, 97, 114, 116, 120, 114, 101, 102]);
  4356. const objBytes = new Uint8Array([111, 98, 106]);
  4357. var xrefBytes = new Uint8Array([47, 88, 82, 101, 102]);
  4358. this.entries.length = 0;
  4359. var stream = this.stream;
  4360. stream.pos = 0;
  4361. var buffer = stream.getBytes();
  4362. var position = stream.start,
  4363. length = buffer.length;
  4364. var trailers = [],
  4365. xrefStms = [];
  4366. while (position < length) {
  4367. var ch = buffer[position];
  4368. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  4369. ++position;
  4370. continue;
  4371. }
  4372. if (ch === PERCENT) {
  4373. do {
  4374. ++position;
  4375. if (position >= length) {
  4376. break;
  4377. }
  4378. ch = buffer[position];
  4379. } while (ch !== LF && ch !== CR);
  4380. continue;
  4381. }
  4382. var token = readToken(buffer, position);
  4383. var m;
  4384. if (token.startsWith("xref") && (token.length === 4 || /\s/.test(token[4]))) {
  4385. position += skipUntil(buffer, position, trailerBytes);
  4386. trailers.push(position);
  4387. position += skipUntil(buffer, position, startxrefBytes);
  4388. } else if (m = objRegExp.exec(token)) {
  4389. const num = m[1] | 0,
  4390. gen = m[2] | 0;
  4391. if (!this.entries[num] || this.entries[num].gen === gen) {
  4392. this.entries[num] = {
  4393. offset: position - stream.start,
  4394. gen,
  4395. uncompressed: true
  4396. };
  4397. }
  4398. let contentLength,
  4399. startPos = position + token.length;
  4400. while (startPos < buffer.length) {
  4401. const endPos = startPos + skipUntil(buffer, startPos, objBytes) + 4;
  4402. contentLength = endPos - position;
  4403. const checkPos = Math.max(endPos - CHECK_CONTENT_LENGTH, startPos);
  4404. const tokenStr = (0, _util.bytesToString)(buffer.subarray(checkPos, endPos));
  4405. if (endobjRegExp.test(tokenStr)) {
  4406. break;
  4407. } else {
  4408. const objToken = nestedObjRegExp.exec(tokenStr);
  4409. if (objToken && objToken[1]) {
  4410. (0, _util.warn)('indexObjects: Found new "obj" inside of another "obj", ' + 'caused by missing "endobj" -- trying to recover.');
  4411. contentLength -= objToken[1].length;
  4412. break;
  4413. }
  4414. }
  4415. startPos = endPos;
  4416. }
  4417. const content = buffer.subarray(position, position + contentLength);
  4418. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  4419. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  4420. xrefStms.push(position - stream.start);
  4421. this.xrefstms[position - stream.start] = 1;
  4422. }
  4423. position += contentLength;
  4424. } else if (token.startsWith("trailer") && (token.length === 7 || /\s/.test(token[7]))) {
  4425. trailers.push(position);
  4426. position += skipUntil(buffer, position, startxrefBytes);
  4427. } else {
  4428. position += token.length + 1;
  4429. }
  4430. }
  4431. var i, ii;
  4432. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  4433. this.startXRefQueue.push(xrefStms[i]);
  4434. this.readXRef(true);
  4435. }
  4436. let trailerDict;
  4437. for (i = 0, ii = trailers.length; i < ii; ++i) {
  4438. stream.pos = trailers[i];
  4439. const parser = new _parser.Parser({
  4440. lexer: new _parser.Lexer(stream),
  4441. xref: this,
  4442. allowStreams: true,
  4443. recoveryMode: true
  4444. });
  4445. var obj = parser.getObj();
  4446. if (!(0, _primitives.isCmd)(obj, "trailer")) {
  4447. continue;
  4448. }
  4449. const dict = parser.getObj();
  4450. if (!(0, _primitives.isDict)(dict)) {
  4451. continue;
  4452. }
  4453. let rootDict;
  4454. try {
  4455. rootDict = dict.get("Root");
  4456. } catch (ex) {
  4457. if (ex instanceof _core_utils.MissingDataException) {
  4458. throw ex;
  4459. }
  4460. continue;
  4461. }
  4462. if (!(0, _primitives.isDict)(rootDict) || !rootDict.has("Pages")) {
  4463. continue;
  4464. }
  4465. if (dict.has("ID")) {
  4466. return dict;
  4467. }
  4468. trailerDict = dict;
  4469. }
  4470. if (trailerDict) {
  4471. return trailerDict;
  4472. }
  4473. throw new _util.InvalidPDFException("Invalid PDF structure.");
  4474. },
  4475. readXRef: function XRef_readXRef(recoveryMode) {
  4476. var stream = this.stream;
  4477. const startXRefParsedCache = Object.create(null);
  4478. try {
  4479. while (this.startXRefQueue.length) {
  4480. var startXRef = this.startXRefQueue[0];
  4481. if (startXRefParsedCache[startXRef]) {
  4482. (0, _util.warn)("readXRef - skipping XRef table since it was already parsed.");
  4483. this.startXRefQueue.shift();
  4484. continue;
  4485. }
  4486. startXRefParsedCache[startXRef] = true;
  4487. stream.pos = startXRef + stream.start;
  4488. const parser = new _parser.Parser({
  4489. lexer: new _parser.Lexer(stream),
  4490. xref: this,
  4491. allowStreams: true
  4492. });
  4493. var obj = parser.getObj();
  4494. var dict;
  4495. if ((0, _primitives.isCmd)(obj, "xref")) {
  4496. dict = this.processXRefTable(parser);
  4497. if (!this.topDict) {
  4498. this.topDict = dict;
  4499. }
  4500. obj = dict.get("XRefStm");
  4501. if (Number.isInteger(obj)) {
  4502. var pos = obj;
  4503. if (!(pos in this.xrefstms)) {
  4504. this.xrefstms[pos] = 1;
  4505. this.startXRefQueue.push(pos);
  4506. }
  4507. }
  4508. } else if (Number.isInteger(obj)) {
  4509. if (!Number.isInteger(parser.getObj()) || !(0, _primitives.isCmd)(parser.getObj(), "obj") || !(0, _primitives.isStream)(obj = parser.getObj())) {
  4510. throw new _util.FormatError("Invalid XRef stream");
  4511. }
  4512. dict = this.processXRefStream(obj);
  4513. if (!this.topDict) {
  4514. this.topDict = dict;
  4515. }
  4516. if (!dict) {
  4517. throw new _util.FormatError("Failed to read XRef stream");
  4518. }
  4519. } else {
  4520. throw new _util.FormatError("Invalid XRef stream header");
  4521. }
  4522. obj = dict.get("Prev");
  4523. if (Number.isInteger(obj)) {
  4524. this.startXRefQueue.push(obj);
  4525. } else if ((0, _primitives.isRef)(obj)) {
  4526. this.startXRefQueue.push(obj.num);
  4527. }
  4528. this.startXRefQueue.shift();
  4529. }
  4530. return this.topDict;
  4531. } catch (e) {
  4532. if (e instanceof _core_utils.MissingDataException) {
  4533. throw e;
  4534. }
  4535. (0, _util.info)("(while reading XRef): " + e);
  4536. }
  4537. if (recoveryMode) {
  4538. return undefined;
  4539. }
  4540. throw new _core_utils.XRefParseException();
  4541. },
  4542. getEntry: function XRef_getEntry(i) {
  4543. var xrefEntry = this.entries[i];
  4544. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  4545. return xrefEntry;
  4546. }
  4547. return null;
  4548. },
  4549. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  4550. if (obj instanceof _primitives.Ref) {
  4551. return this.fetch(obj, suppressEncryption);
  4552. }
  4553. return obj;
  4554. },
  4555. fetch: function XRef_fetch(ref, suppressEncryption) {
  4556. if (!(ref instanceof _primitives.Ref)) {
  4557. throw new Error("ref object is not a reference");
  4558. }
  4559. const num = ref.num;
  4560. const cacheEntry = this._cacheMap.get(num);
  4561. if (cacheEntry !== undefined) {
  4562. if (cacheEntry instanceof _primitives.Dict && !cacheEntry.objId) {
  4563. cacheEntry.objId = ref.toString();
  4564. }
  4565. return cacheEntry;
  4566. }
  4567. let xrefEntry = this.getEntry(num);
  4568. if (xrefEntry === null) {
  4569. this._cacheMap.set(num, xrefEntry);
  4570. return xrefEntry;
  4571. }
  4572. if (xrefEntry.uncompressed) {
  4573. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  4574. } else {
  4575. xrefEntry = this.fetchCompressed(ref, xrefEntry, suppressEncryption);
  4576. }
  4577. if ((0, _primitives.isDict)(xrefEntry)) {
  4578. xrefEntry.objId = ref.toString();
  4579. } else if ((0, _primitives.isStream)(xrefEntry)) {
  4580. xrefEntry.dict.objId = ref.toString();
  4581. }
  4582. return xrefEntry;
  4583. },
  4584. fetchUncompressed(ref, xrefEntry, suppressEncryption = false) {
  4585. var gen = ref.gen;
  4586. var num = ref.num;
  4587. if (xrefEntry.gen !== gen) {
  4588. throw new _core_utils.XRefEntryException(`Inconsistent generation in XRef: ${ref}`);
  4589. }
  4590. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  4591. const parser = new _parser.Parser({
  4592. lexer: new _parser.Lexer(stream),
  4593. xref: this,
  4594. allowStreams: true
  4595. });
  4596. var obj1 = parser.getObj();
  4597. var obj2 = parser.getObj();
  4598. var obj3 = parser.getObj();
  4599. if (obj1 !== num || obj2 !== gen || !(obj3 instanceof _primitives.Cmd)) {
  4600. throw new _core_utils.XRefEntryException(`Bad (uncompressed) XRef entry: ${ref}`);
  4601. }
  4602. if (obj3.cmd !== "obj") {
  4603. if (obj3.cmd.startsWith("obj")) {
  4604. num = parseInt(obj3.cmd.substring(3), 10);
  4605. if (!Number.isNaN(num)) {
  4606. return num;
  4607. }
  4608. }
  4609. throw new _core_utils.XRefEntryException(`Bad (uncompressed) XRef entry: ${ref}`);
  4610. }
  4611. if (this.encrypt && !suppressEncryption) {
  4612. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  4613. } else {
  4614. xrefEntry = parser.getObj();
  4615. }
  4616. if (!(0, _primitives.isStream)(xrefEntry)) {
  4617. this._cacheMap.set(num, xrefEntry);
  4618. }
  4619. return xrefEntry;
  4620. },
  4621. fetchCompressed(ref, xrefEntry, suppressEncryption = false) {
  4622. const tableOffset = xrefEntry.offset;
  4623. const stream = this.fetch(_primitives.Ref.get(tableOffset, 0));
  4624. if (!(0, _primitives.isStream)(stream)) {
  4625. throw new _util.FormatError("bad ObjStm stream");
  4626. }
  4627. const first = stream.dict.get("First");
  4628. const n = stream.dict.get("N");
  4629. if (!Number.isInteger(first) || !Number.isInteger(n)) {
  4630. throw new _util.FormatError("invalid first and n parameters for ObjStm stream");
  4631. }
  4632. const parser = new _parser.Parser({
  4633. lexer: new _parser.Lexer(stream),
  4634. xref: this,
  4635. allowStreams: true
  4636. });
  4637. const nums = new Array(n);
  4638. for (let i = 0; i < n; ++i) {
  4639. const num = parser.getObj();
  4640. if (!Number.isInteger(num)) {
  4641. throw new _util.FormatError(`invalid object number in the ObjStm stream: ${num}`);
  4642. }
  4643. const offset = parser.getObj();
  4644. if (!Number.isInteger(offset)) {
  4645. throw new _util.FormatError(`invalid object offset in the ObjStm stream: ${offset}`);
  4646. }
  4647. nums[i] = num;
  4648. }
  4649. const entries = new Array(n);
  4650. for (let i = 0; i < n; ++i) {
  4651. const obj = parser.getObj();
  4652. entries[i] = obj;
  4653. if (parser.buf1 instanceof _primitives.Cmd && parser.buf1.cmd === "endobj") {
  4654. parser.shift();
  4655. }
  4656. if ((0, _primitives.isStream)(obj)) {
  4657. continue;
  4658. }
  4659. const num = nums[i],
  4660. entry = this.entries[num];
  4661. if (entry && entry.offset === tableOffset && entry.gen === i) {
  4662. this._cacheMap.set(num, obj);
  4663. }
  4664. }
  4665. xrefEntry = entries[xrefEntry.gen];
  4666. if (xrefEntry === undefined) {
  4667. throw new _core_utils.XRefEntryException(`Bad (compressed) XRef entry: ${ref}`);
  4668. }
  4669. return xrefEntry;
  4670. },
  4671. async fetchIfRefAsync(obj, suppressEncryption) {
  4672. if (obj instanceof _primitives.Ref) {
  4673. return this.fetchAsync(obj, suppressEncryption);
  4674. }
  4675. return obj;
  4676. },
  4677. async fetchAsync(ref, suppressEncryption) {
  4678. try {
  4679. return this.fetch(ref, suppressEncryption);
  4680. } catch (ex) {
  4681. if (!(ex instanceof _core_utils.MissingDataException)) {
  4682. throw ex;
  4683. }
  4684. await this.pdfManager.requestRange(ex.begin, ex.end);
  4685. return this.fetchAsync(ref, suppressEncryption);
  4686. }
  4687. },
  4688. getCatalogObj: function XRef_getCatalogObj() {
  4689. return this.root;
  4690. }
  4691. };
  4692. return XRef;
  4693. }();
  4694. exports.XRef = XRef;
  4695. class NameOrNumberTree {
  4696. constructor(root, xref, type) {
  4697. if (this.constructor === NameOrNumberTree) {
  4698. (0, _util.unreachable)("Cannot initialize NameOrNumberTree.");
  4699. }
  4700. this.root = root;
  4701. this.xref = xref;
  4702. this._type = type;
  4703. }
  4704. getAll() {
  4705. const dict = Object.create(null);
  4706. if (!this.root) {
  4707. return dict;
  4708. }
  4709. const xref = this.xref;
  4710. const processed = new _primitives.RefSet();
  4711. processed.put(this.root);
  4712. const queue = [this.root];
  4713. while (queue.length > 0) {
  4714. const obj = xref.fetchIfRef(queue.shift());
  4715. if (!(0, _primitives.isDict)(obj)) {
  4716. continue;
  4717. }
  4718. if (obj.has("Kids")) {
  4719. const kids = obj.get("Kids");
  4720. for (let i = 0, ii = kids.length; i < ii; i++) {
  4721. const kid = kids[i];
  4722. if (processed.has(kid)) {
  4723. throw new _util.FormatError(`Duplicate entry in "${this._type}" tree.`);
  4724. }
  4725. queue.push(kid);
  4726. processed.put(kid);
  4727. }
  4728. continue;
  4729. }
  4730. const entries = obj.get(this._type);
  4731. if (Array.isArray(entries)) {
  4732. for (let i = 0, ii = entries.length; i < ii; i += 2) {
  4733. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  4734. }
  4735. }
  4736. }
  4737. return dict;
  4738. }
  4739. get(key) {
  4740. if (!this.root) {
  4741. return null;
  4742. }
  4743. const xref = this.xref;
  4744. let kidsOrEntries = xref.fetchIfRef(this.root);
  4745. let loopCount = 0;
  4746. const MAX_LEVELS = 10;
  4747. while (kidsOrEntries.has("Kids")) {
  4748. if (++loopCount > MAX_LEVELS) {
  4749. (0, _util.warn)(`Search depth limit reached for "${this._type}" tree.`);
  4750. return null;
  4751. }
  4752. const kids = kidsOrEntries.get("Kids");
  4753. if (!Array.isArray(kids)) {
  4754. return null;
  4755. }
  4756. let l = 0,
  4757. r = kids.length - 1;
  4758. while (l <= r) {
  4759. const m = l + r >> 1;
  4760. const kid = xref.fetchIfRef(kids[m]);
  4761. const limits = kid.get("Limits");
  4762. if (key < xref.fetchIfRef(limits[0])) {
  4763. r = m - 1;
  4764. } else if (key > xref.fetchIfRef(limits[1])) {
  4765. l = m + 1;
  4766. } else {
  4767. kidsOrEntries = xref.fetchIfRef(kids[m]);
  4768. break;
  4769. }
  4770. }
  4771. if (l > r) {
  4772. return null;
  4773. }
  4774. }
  4775. const entries = kidsOrEntries.get(this._type);
  4776. if (Array.isArray(entries)) {
  4777. let l = 0,
  4778. r = entries.length - 2;
  4779. while (l <= r) {
  4780. const tmp = l + r >> 1,
  4781. m = tmp + (tmp & 1);
  4782. const currentKey = xref.fetchIfRef(entries[m]);
  4783. if (key < currentKey) {
  4784. r = m - 2;
  4785. } else if (key > currentKey) {
  4786. l = m + 2;
  4787. } else {
  4788. return xref.fetchIfRef(entries[m + 1]);
  4789. }
  4790. }
  4791. (0, _util.info)(`Falling back to an exhaustive search, for key "${key}", ` + `in "${this._type}" tree.`);
  4792. for (let m = 0, mm = entries.length; m < mm; m += 2) {
  4793. const currentKey = xref.fetchIfRef(entries[m]);
  4794. if (currentKey === key) {
  4795. (0, _util.warn)(`The "${key}" key was found at an incorrect, ` + `i.e. out-of-order, position in "${this._type}" tree.`);
  4796. return xref.fetchIfRef(entries[m + 1]);
  4797. }
  4798. }
  4799. }
  4800. return null;
  4801. }
  4802. }
  4803. class NameTree extends NameOrNumberTree {
  4804. constructor(root, xref) {
  4805. super(root, xref, "Names");
  4806. }
  4807. }
  4808. class NumberTree extends NameOrNumberTree {
  4809. constructor(root, xref) {
  4810. super(root, xref, "Nums");
  4811. }
  4812. }
  4813. var FileSpec = function FileSpecClosure() {
  4814. function FileSpec(root, xref) {
  4815. if (!root || !(0, _primitives.isDict)(root)) {
  4816. return;
  4817. }
  4818. this.xref = xref;
  4819. this.root = root;
  4820. if (root.has("FS")) {
  4821. this.fs = root.get("FS");
  4822. }
  4823. this.description = root.has("Desc") ? (0, _util.stringToPDFString)(root.get("Desc")) : "";
  4824. if (root.has("RF")) {
  4825. (0, _util.warn)("Related file specifications are not supported");
  4826. }
  4827. this.contentAvailable = true;
  4828. if (!root.has("EF")) {
  4829. this.contentAvailable = false;
  4830. (0, _util.warn)("Non-embedded file specifications are not supported");
  4831. }
  4832. }
  4833. function pickPlatformItem(dict) {
  4834. if (dict.has("UF")) {
  4835. return dict.get("UF");
  4836. } else if (dict.has("F")) {
  4837. return dict.get("F");
  4838. } else if (dict.has("Unix")) {
  4839. return dict.get("Unix");
  4840. } else if (dict.has("Mac")) {
  4841. return dict.get("Mac");
  4842. } else if (dict.has("DOS")) {
  4843. return dict.get("DOS");
  4844. }
  4845. return null;
  4846. }
  4847. FileSpec.prototype = {
  4848. get filename() {
  4849. if (!this._filename && this.root) {
  4850. var filename = pickPlatformItem(this.root) || "unnamed";
  4851. this._filename = (0, _util.stringToPDFString)(filename).replace(/\\\\/g, "\\").replace(/\\\//g, "/").replace(/\\/g, "/");
  4852. }
  4853. return this._filename;
  4854. },
  4855. get content() {
  4856. if (!this.contentAvailable) {
  4857. return null;
  4858. }
  4859. if (!this.contentRef && this.root) {
  4860. this.contentRef = pickPlatformItem(this.root.get("EF"));
  4861. }
  4862. var content = null;
  4863. if (this.contentRef) {
  4864. var xref = this.xref;
  4865. var fileObj = xref.fetchIfRef(this.contentRef);
  4866. if (fileObj && (0, _primitives.isStream)(fileObj)) {
  4867. content = fileObj.getBytes();
  4868. } else {
  4869. (0, _util.warn)("Embedded file specification points to non-existing/invalid " + "content");
  4870. }
  4871. } else {
  4872. (0, _util.warn)("Embedded file specification does not have a content");
  4873. }
  4874. return content;
  4875. },
  4876. get serializable() {
  4877. return {
  4878. filename: this.filename,
  4879. content: this.content
  4880. };
  4881. }
  4882. };
  4883. return FileSpec;
  4884. }();
  4885. exports.FileSpec = FileSpec;
  4886. const ObjectLoader = function () {
  4887. function mayHaveChildren(value) {
  4888. return value instanceof _primitives.Ref || value instanceof _primitives.Dict || Array.isArray(value) || (0, _primitives.isStream)(value);
  4889. }
  4890. function addChildren(node, nodesToVisit) {
  4891. if (node instanceof _primitives.Dict) {
  4892. node = node.getRawValues();
  4893. } else if ((0, _primitives.isStream)(node)) {
  4894. node = node.dict.getRawValues();
  4895. } else if (!Array.isArray(node)) {
  4896. return;
  4897. }
  4898. for (const rawValue of node) {
  4899. if (mayHaveChildren(rawValue)) {
  4900. nodesToVisit.push(rawValue);
  4901. }
  4902. }
  4903. }
  4904. function ObjectLoader(dict, keys, xref) {
  4905. this.dict = dict;
  4906. this.keys = keys;
  4907. this.xref = xref;
  4908. this.refSet = null;
  4909. }
  4910. ObjectLoader.prototype = {
  4911. async load() {
  4912. if (!this.xref.stream.allChunksLoaded || this.xref.stream.allChunksLoaded()) {
  4913. return undefined;
  4914. }
  4915. const {
  4916. keys,
  4917. dict
  4918. } = this;
  4919. this.refSet = new _primitives.RefSet();
  4920. const nodesToVisit = [];
  4921. for (let i = 0, ii = keys.length; i < ii; i++) {
  4922. const rawValue = dict.getRaw(keys[i]);
  4923. if (rawValue !== undefined) {
  4924. nodesToVisit.push(rawValue);
  4925. }
  4926. }
  4927. return this._walk(nodesToVisit);
  4928. },
  4929. async _walk(nodesToVisit) {
  4930. const nodesToRevisit = [];
  4931. const pendingRequests = [];
  4932. while (nodesToVisit.length) {
  4933. let currentNode = nodesToVisit.pop();
  4934. if (currentNode instanceof _primitives.Ref) {
  4935. if (this.refSet.has(currentNode)) {
  4936. continue;
  4937. }
  4938. try {
  4939. this.refSet.put(currentNode);
  4940. currentNode = this.xref.fetch(currentNode);
  4941. } catch (ex) {
  4942. if (!(ex instanceof _core_utils.MissingDataException)) {
  4943. throw ex;
  4944. }
  4945. nodesToRevisit.push(currentNode);
  4946. pendingRequests.push({
  4947. begin: ex.begin,
  4948. end: ex.end
  4949. });
  4950. }
  4951. }
  4952. if (currentNode && currentNode.getBaseStreams) {
  4953. const baseStreams = currentNode.getBaseStreams();
  4954. let foundMissingData = false;
  4955. for (let i = 0, ii = baseStreams.length; i < ii; i++) {
  4956. const stream = baseStreams[i];
  4957. if (stream.allChunksLoaded && !stream.allChunksLoaded()) {
  4958. foundMissingData = true;
  4959. pendingRequests.push({
  4960. begin: stream.start,
  4961. end: stream.end
  4962. });
  4963. }
  4964. }
  4965. if (foundMissingData) {
  4966. nodesToRevisit.push(currentNode);
  4967. }
  4968. }
  4969. addChildren(currentNode, nodesToVisit);
  4970. }
  4971. if (pendingRequests.length) {
  4972. await this.xref.stream.manager.requestRanges(pendingRequests);
  4973. for (let i = 0, ii = nodesToRevisit.length; i < ii; i++) {
  4974. const node = nodesToRevisit[i];
  4975. if (node instanceof _primitives.Ref) {
  4976. this.refSet.remove(node);
  4977. }
  4978. }
  4979. return this._walk(nodesToRevisit);
  4980. }
  4981. this.refSet = null;
  4982. return undefined;
  4983. }
  4984. };
  4985. return ObjectLoader;
  4986. }();
  4987. exports.ObjectLoader = ObjectLoader;
  4988. /***/ }),
  4989. /* 11 */
  4990. /***/ (function(module, exports, __w_pdfjs_require__) {
  4991. "use strict";
  4992. Object.defineProperty(exports, "__esModule", {
  4993. value: true
  4994. });
  4995. exports.Parser = exports.Linearization = exports.Lexer = void 0;
  4996. var _stream = __w_pdfjs_require__(12);
  4997. var _util = __w_pdfjs_require__(2);
  4998. var _primitives = __w_pdfjs_require__(5);
  4999. var _core_utils = __w_pdfjs_require__(8);
  5000. var _ccitt_stream = __w_pdfjs_require__(13);
  5001. var _jbig2_stream = __w_pdfjs_require__(15);
  5002. var _jpeg_stream = __w_pdfjs_require__(18);
  5003. var _jpx_stream = __w_pdfjs_require__(20);
  5004. const MAX_LENGTH_TO_CACHE = 1000;
  5005. const MAX_ADLER32_LENGTH = 5552;
  5006. function computeAdler32(bytes) {
  5007. const bytesLength = bytes.length;
  5008. let a = 1,
  5009. b = 0;
  5010. for (let i = 0; i < bytesLength; ++i) {
  5011. a += bytes[i] & 0xff;
  5012. b += a;
  5013. }
  5014. return b % 65521 << 16 | a % 65521;
  5015. }
  5016. class Parser {
  5017. constructor({
  5018. lexer,
  5019. xref,
  5020. allowStreams = false,
  5021. recoveryMode = false
  5022. }) {
  5023. this.lexer = lexer;
  5024. this.xref = xref;
  5025. this.allowStreams = allowStreams;
  5026. this.recoveryMode = recoveryMode;
  5027. this.imageCache = Object.create(null);
  5028. this.refill();
  5029. }
  5030. refill() {
  5031. this.buf1 = this.lexer.getObj();
  5032. this.buf2 = this.lexer.getObj();
  5033. }
  5034. shift() {
  5035. if (this.buf2 instanceof _primitives.Cmd && this.buf2.cmd === "ID") {
  5036. this.buf1 = this.buf2;
  5037. this.buf2 = null;
  5038. } else {
  5039. this.buf1 = this.buf2;
  5040. this.buf2 = this.lexer.getObj();
  5041. }
  5042. }
  5043. tryShift() {
  5044. try {
  5045. this.shift();
  5046. return true;
  5047. } catch (e) {
  5048. if (e instanceof _core_utils.MissingDataException) {
  5049. throw e;
  5050. }
  5051. return false;
  5052. }
  5053. }
  5054. getObj(cipherTransform = null) {
  5055. const buf1 = this.buf1;
  5056. this.shift();
  5057. if (buf1 instanceof _primitives.Cmd) {
  5058. switch (buf1.cmd) {
  5059. case "BI":
  5060. return this.makeInlineImage(cipherTransform);
  5061. case "[":
  5062. const array = [];
  5063. while (!(0, _primitives.isCmd)(this.buf1, "]") && !(0, _primitives.isEOF)(this.buf1)) {
  5064. array.push(this.getObj(cipherTransform));
  5065. }
  5066. if ((0, _primitives.isEOF)(this.buf1)) {
  5067. if (!this.recoveryMode) {
  5068. throw new _util.FormatError("End of file inside array");
  5069. }
  5070. return array;
  5071. }
  5072. this.shift();
  5073. return array;
  5074. case "<<":
  5075. const dict = new _primitives.Dict(this.xref);
  5076. while (!(0, _primitives.isCmd)(this.buf1, ">>") && !(0, _primitives.isEOF)(this.buf1)) {
  5077. if (!(0, _primitives.isName)(this.buf1)) {
  5078. (0, _util.info)("Malformed dictionary: key must be a name object");
  5079. this.shift();
  5080. continue;
  5081. }
  5082. const key = this.buf1.name;
  5083. this.shift();
  5084. if ((0, _primitives.isEOF)(this.buf1)) {
  5085. break;
  5086. }
  5087. dict.set(key, this.getObj(cipherTransform));
  5088. }
  5089. if ((0, _primitives.isEOF)(this.buf1)) {
  5090. if (!this.recoveryMode) {
  5091. throw new _util.FormatError("End of file inside dictionary");
  5092. }
  5093. return dict;
  5094. }
  5095. if ((0, _primitives.isCmd)(this.buf2, "stream")) {
  5096. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  5097. }
  5098. this.shift();
  5099. return dict;
  5100. default:
  5101. return buf1;
  5102. }
  5103. }
  5104. if (Number.isInteger(buf1)) {
  5105. if (Number.isInteger(this.buf1) && (0, _primitives.isCmd)(this.buf2, "R")) {
  5106. const ref = _primitives.Ref.get(buf1, this.buf1);
  5107. this.shift();
  5108. this.shift();
  5109. return ref;
  5110. }
  5111. return buf1;
  5112. }
  5113. if (typeof buf1 === "string") {
  5114. if (cipherTransform) {
  5115. return cipherTransform.decryptString(buf1);
  5116. }
  5117. return buf1;
  5118. }
  5119. return buf1;
  5120. }
  5121. findDefaultInlineStreamEnd(stream) {
  5122. const E = 0x45,
  5123. I = 0x49,
  5124. SPACE = 0x20,
  5125. LF = 0xa,
  5126. CR = 0xd,
  5127. NUL = 0x0;
  5128. const lexer = this.lexer,
  5129. startPos = stream.pos,
  5130. n = 10;
  5131. let state = 0,
  5132. ch,
  5133. maybeEIPos;
  5134. while ((ch = stream.getByte()) !== -1) {
  5135. if (state === 0) {
  5136. state = ch === E ? 1 : 0;
  5137. } else if (state === 1) {
  5138. state = ch === I ? 2 : 0;
  5139. } else {
  5140. (0, _util.assert)(state === 2, "findDefaultInlineStreamEnd - invalid state.");
  5141. if (ch === SPACE || ch === LF || ch === CR) {
  5142. maybeEIPos = stream.pos;
  5143. const followingBytes = stream.peekBytes(n);
  5144. for (let i = 0, ii = followingBytes.length; i < ii; i++) {
  5145. ch = followingBytes[i];
  5146. if (ch === NUL && followingBytes[i + 1] !== NUL) {
  5147. continue;
  5148. }
  5149. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7f)) {
  5150. state = 0;
  5151. break;
  5152. }
  5153. }
  5154. if (state !== 2) {
  5155. continue;
  5156. }
  5157. if (lexer.knownCommands) {
  5158. const nextObj = lexer.peekObj();
  5159. if (nextObj instanceof _primitives.Cmd && !lexer.knownCommands[nextObj.cmd]) {
  5160. state = 0;
  5161. }
  5162. } else {
  5163. (0, _util.warn)("findDefaultInlineStreamEnd - `lexer.knownCommands` is undefined.");
  5164. }
  5165. if (state === 2) {
  5166. break;
  5167. }
  5168. } else {
  5169. state = 0;
  5170. }
  5171. }
  5172. }
  5173. if (ch === -1) {
  5174. (0, _util.warn)("findDefaultInlineStreamEnd: " + "Reached the end of the stream without finding a valid EI marker");
  5175. if (maybeEIPos) {
  5176. (0, _util.warn)('... trying to recover by using the last "EI" occurrence.');
  5177. stream.skip(-(stream.pos - maybeEIPos));
  5178. }
  5179. }
  5180. let endOffset = 4;
  5181. stream.skip(-endOffset);
  5182. ch = stream.peekByte();
  5183. stream.skip(endOffset);
  5184. if (!(0, _core_utils.isWhiteSpace)(ch)) {
  5185. endOffset--;
  5186. }
  5187. return stream.pos - endOffset - startPos;
  5188. }
  5189. findDCTDecodeInlineStreamEnd(stream) {
  5190. const startPos = stream.pos;
  5191. let foundEOI = false,
  5192. b,
  5193. markerLength;
  5194. while ((b = stream.getByte()) !== -1) {
  5195. if (b !== 0xff) {
  5196. continue;
  5197. }
  5198. switch (stream.getByte()) {
  5199. case 0x00:
  5200. break;
  5201. case 0xff:
  5202. stream.skip(-1);
  5203. break;
  5204. case 0xd9:
  5205. foundEOI = true;
  5206. break;
  5207. case 0xc0:
  5208. case 0xc1:
  5209. case 0xc2:
  5210. case 0xc3:
  5211. case 0xc5:
  5212. case 0xc6:
  5213. case 0xc7:
  5214. case 0xc9:
  5215. case 0xca:
  5216. case 0xcb:
  5217. case 0xcd:
  5218. case 0xce:
  5219. case 0xcf:
  5220. case 0xc4:
  5221. case 0xcc:
  5222. case 0xda:
  5223. case 0xdb:
  5224. case 0xdc:
  5225. case 0xdd:
  5226. case 0xde:
  5227. case 0xdf:
  5228. case 0xe0:
  5229. case 0xe1:
  5230. case 0xe2:
  5231. case 0xe3:
  5232. case 0xe4:
  5233. case 0xe5:
  5234. case 0xe6:
  5235. case 0xe7:
  5236. case 0xe8:
  5237. case 0xe9:
  5238. case 0xea:
  5239. case 0xeb:
  5240. case 0xec:
  5241. case 0xed:
  5242. case 0xee:
  5243. case 0xef:
  5244. case 0xfe:
  5245. markerLength = stream.getUint16();
  5246. if (markerLength > 2) {
  5247. stream.skip(markerLength - 2);
  5248. } else {
  5249. stream.skip(-2);
  5250. }
  5251. break;
  5252. }
  5253. if (foundEOI) {
  5254. break;
  5255. }
  5256. }
  5257. const length = stream.pos - startPos;
  5258. if (b === -1) {
  5259. (0, _util.warn)("Inline DCTDecode image stream: " + "EOI marker not found, searching for /EI/ instead.");
  5260. stream.skip(-length);
  5261. return this.findDefaultInlineStreamEnd(stream);
  5262. }
  5263. this.inlineStreamSkipEI(stream);
  5264. return length;
  5265. }
  5266. findASCII85DecodeInlineStreamEnd(stream) {
  5267. const TILDE = 0x7e,
  5268. GT = 0x3e;
  5269. const startPos = stream.pos;
  5270. let ch;
  5271. while ((ch = stream.getByte()) !== -1) {
  5272. if (ch === TILDE) {
  5273. const tildePos = stream.pos;
  5274. ch = stream.peekByte();
  5275. while ((0, _core_utils.isWhiteSpace)(ch)) {
  5276. stream.skip();
  5277. ch = stream.peekByte();
  5278. }
  5279. if (ch === GT) {
  5280. stream.skip();
  5281. break;
  5282. }
  5283. if (stream.pos > tildePos) {
  5284. const maybeEI = stream.peekBytes(2);
  5285. if (maybeEI[0] === 0x45 && maybeEI[1] === 0x49) {
  5286. break;
  5287. }
  5288. }
  5289. }
  5290. }
  5291. const length = stream.pos - startPos;
  5292. if (ch === -1) {
  5293. (0, _util.warn)("Inline ASCII85Decode image stream: " + "EOD marker not found, searching for /EI/ instead.");
  5294. stream.skip(-length);
  5295. return this.findDefaultInlineStreamEnd(stream);
  5296. }
  5297. this.inlineStreamSkipEI(stream);
  5298. return length;
  5299. }
  5300. findASCIIHexDecodeInlineStreamEnd(stream) {
  5301. const GT = 0x3e;
  5302. const startPos = stream.pos;
  5303. let ch;
  5304. while ((ch = stream.getByte()) !== -1) {
  5305. if (ch === GT) {
  5306. break;
  5307. }
  5308. }
  5309. const length = stream.pos - startPos;
  5310. if (ch === -1) {
  5311. (0, _util.warn)("Inline ASCIIHexDecode image stream: " + "EOD marker not found, searching for /EI/ instead.");
  5312. stream.skip(-length);
  5313. return this.findDefaultInlineStreamEnd(stream);
  5314. }
  5315. this.inlineStreamSkipEI(stream);
  5316. return length;
  5317. }
  5318. inlineStreamSkipEI(stream) {
  5319. const E = 0x45,
  5320. I = 0x49;
  5321. let state = 0,
  5322. ch;
  5323. while ((ch = stream.getByte()) !== -1) {
  5324. if (state === 0) {
  5325. state = ch === E ? 1 : 0;
  5326. } else if (state === 1) {
  5327. state = ch === I ? 2 : 0;
  5328. } else if (state === 2) {
  5329. break;
  5330. }
  5331. }
  5332. }
  5333. makeInlineImage(cipherTransform) {
  5334. const lexer = this.lexer;
  5335. const stream = lexer.stream;
  5336. const dict = new _primitives.Dict(this.xref);
  5337. let dictLength;
  5338. while (!(0, _primitives.isCmd)(this.buf1, "ID") && !(0, _primitives.isEOF)(this.buf1)) {
  5339. if (!(0, _primitives.isName)(this.buf1)) {
  5340. throw new _util.FormatError("Dictionary key must be a name object");
  5341. }
  5342. const key = this.buf1.name;
  5343. this.shift();
  5344. if ((0, _primitives.isEOF)(this.buf1)) {
  5345. break;
  5346. }
  5347. dict.set(key, this.getObj(cipherTransform));
  5348. }
  5349. if (lexer.beginInlineImagePos !== -1) {
  5350. dictLength = stream.pos - lexer.beginInlineImagePos;
  5351. }
  5352. const filter = dict.get("Filter", "F");
  5353. let filterName;
  5354. if ((0, _primitives.isName)(filter)) {
  5355. filterName = filter.name;
  5356. } else if (Array.isArray(filter)) {
  5357. const filterZero = this.xref.fetchIfRef(filter[0]);
  5358. if ((0, _primitives.isName)(filterZero)) {
  5359. filterName = filterZero.name;
  5360. }
  5361. }
  5362. const startPos = stream.pos;
  5363. let length;
  5364. if (filterName === "DCTDecode" || filterName === "DCT") {
  5365. length = this.findDCTDecodeInlineStreamEnd(stream);
  5366. } else if (filterName === "ASCII85Decode" || filterName === "A85") {
  5367. length = this.findASCII85DecodeInlineStreamEnd(stream);
  5368. } else if (filterName === "ASCIIHexDecode" || filterName === "AHx") {
  5369. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  5370. } else {
  5371. length = this.findDefaultInlineStreamEnd(stream);
  5372. }
  5373. let imageStream = stream.makeSubStream(startPos, length, dict);
  5374. let cacheKey;
  5375. if (length < MAX_LENGTH_TO_CACHE && dictLength < MAX_ADLER32_LENGTH) {
  5376. const imageBytes = imageStream.getBytes();
  5377. imageStream.reset();
  5378. const initialStreamPos = stream.pos;
  5379. stream.pos = lexer.beginInlineImagePos;
  5380. const dictBytes = stream.getBytes(dictLength);
  5381. stream.pos = initialStreamPos;
  5382. cacheKey = computeAdler32(imageBytes) + "_" + computeAdler32(dictBytes);
  5383. const cacheEntry = this.imageCache[cacheKey];
  5384. if (cacheEntry !== undefined) {
  5385. this.buf2 = _primitives.Cmd.get("EI");
  5386. this.shift();
  5387. cacheEntry.reset();
  5388. return cacheEntry;
  5389. }
  5390. }
  5391. if (cipherTransform) {
  5392. imageStream = cipherTransform.createStream(imageStream, length);
  5393. }
  5394. imageStream = this.filter(imageStream, dict, length);
  5395. imageStream.dict = dict;
  5396. if (cacheKey !== undefined) {
  5397. imageStream.cacheKey = `inline_${length}_${cacheKey}`;
  5398. this.imageCache[cacheKey] = imageStream;
  5399. }
  5400. this.buf2 = _primitives.Cmd.get("EI");
  5401. this.shift();
  5402. return imageStream;
  5403. }
  5404. _findStreamLength(startPos, signature) {
  5405. const {
  5406. stream
  5407. } = this.lexer;
  5408. stream.pos = startPos;
  5409. const SCAN_BLOCK_LENGTH = 2048;
  5410. const signatureLength = signature.length;
  5411. while (stream.pos < stream.end) {
  5412. const scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  5413. const scanLength = scanBytes.length - signatureLength;
  5414. if (scanLength <= 0) {
  5415. break;
  5416. }
  5417. let pos = 0;
  5418. while (pos < scanLength) {
  5419. let j = 0;
  5420. while (j < signatureLength && scanBytes[pos + j] === signature[j]) {
  5421. j++;
  5422. }
  5423. if (j >= signatureLength) {
  5424. stream.pos += pos;
  5425. return stream.pos - startPos;
  5426. }
  5427. pos++;
  5428. }
  5429. stream.pos += scanLength;
  5430. }
  5431. return -1;
  5432. }
  5433. makeStream(dict, cipherTransform) {
  5434. const lexer = this.lexer;
  5435. let stream = lexer.stream;
  5436. lexer.skipToNextLine();
  5437. const startPos = stream.pos - 1;
  5438. let length = dict.get("Length");
  5439. if (!Number.isInteger(length)) {
  5440. (0, _util.info)(`Bad length "${length}" in stream`);
  5441. length = 0;
  5442. }
  5443. stream.pos = startPos + length;
  5444. lexer.nextChar();
  5445. if (this.tryShift() && (0, _primitives.isCmd)(this.buf2, "endstream")) {
  5446. this.shift();
  5447. } else {
  5448. const ENDSTREAM_SIGNATURE = new Uint8Array([0x65, 0x6E, 0x64, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6D]);
  5449. let actualLength = this._findStreamLength(startPos, ENDSTREAM_SIGNATURE);
  5450. if (actualLength < 0) {
  5451. const MAX_TRUNCATION = 1;
  5452. for (let i = 1; i <= MAX_TRUNCATION; i++) {
  5453. const end = ENDSTREAM_SIGNATURE.length - i;
  5454. const TRUNCATED_SIGNATURE = ENDSTREAM_SIGNATURE.slice(0, end);
  5455. const maybeLength = this._findStreamLength(startPos, TRUNCATED_SIGNATURE);
  5456. if (maybeLength >= 0) {
  5457. const lastByte = stream.peekBytes(end + 1)[end];
  5458. if (!(0, _core_utils.isWhiteSpace)(lastByte)) {
  5459. break;
  5460. }
  5461. (0, _util.info)(`Found "${(0, _util.bytesToString)(TRUNCATED_SIGNATURE)}" when ` + "searching for endstream command.");
  5462. actualLength = maybeLength;
  5463. break;
  5464. }
  5465. }
  5466. if (actualLength < 0) {
  5467. throw new _util.FormatError("Missing endstream command.");
  5468. }
  5469. }
  5470. length = actualLength;
  5471. lexer.nextChar();
  5472. this.shift();
  5473. this.shift();
  5474. }
  5475. this.shift();
  5476. stream = stream.makeSubStream(startPos, length, dict);
  5477. if (cipherTransform) {
  5478. stream = cipherTransform.createStream(stream, length);
  5479. }
  5480. stream = this.filter(stream, dict, length);
  5481. stream.dict = dict;
  5482. return stream;
  5483. }
  5484. filter(stream, dict, length) {
  5485. let filter = dict.get("Filter", "F");
  5486. let params = dict.get("DecodeParms", "DP");
  5487. if ((0, _primitives.isName)(filter)) {
  5488. if (Array.isArray(params)) {
  5489. (0, _util.warn)("/DecodeParms should not contain an Array, " + "when /Filter contains a Name.");
  5490. }
  5491. return this.makeFilter(stream, filter.name, length, params);
  5492. }
  5493. let maybeLength = length;
  5494. if (Array.isArray(filter)) {
  5495. const filterArray = filter;
  5496. const paramsArray = params;
  5497. for (let i = 0, ii = filterArray.length; i < ii; ++i) {
  5498. filter = this.xref.fetchIfRef(filterArray[i]);
  5499. if (!(0, _primitives.isName)(filter)) {
  5500. throw new _util.FormatError(`Bad filter name "${filter}"`);
  5501. }
  5502. params = null;
  5503. if (Array.isArray(paramsArray) && i in paramsArray) {
  5504. params = this.xref.fetchIfRef(paramsArray[i]);
  5505. }
  5506. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  5507. maybeLength = null;
  5508. }
  5509. }
  5510. return stream;
  5511. }
  5512. makeFilter(stream, name, maybeLength, params) {
  5513. if (maybeLength === 0) {
  5514. (0, _util.warn)(`Empty "${name}" stream.`);
  5515. return new _stream.NullStream();
  5516. }
  5517. try {
  5518. const xrefStreamStats = this.xref.stats.streamTypes;
  5519. if (name === "FlateDecode" || name === "Fl") {
  5520. xrefStreamStats[_util.StreamType.FLATE] = true;
  5521. if (params) {
  5522. return new _stream.PredictorStream(new _stream.FlateStream(stream, maybeLength), maybeLength, params);
  5523. }
  5524. return new _stream.FlateStream(stream, maybeLength);
  5525. }
  5526. if (name === "LZWDecode" || name === "LZW") {
  5527. xrefStreamStats[_util.StreamType.LZW] = true;
  5528. let earlyChange = 1;
  5529. if (params) {
  5530. if (params.has("EarlyChange")) {
  5531. earlyChange = params.get("EarlyChange");
  5532. }
  5533. return new _stream.PredictorStream(new _stream.LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  5534. }
  5535. return new _stream.LZWStream(stream, maybeLength, earlyChange);
  5536. }
  5537. if (name === "DCTDecode" || name === "DCT") {
  5538. xrefStreamStats[_util.StreamType.DCT] = true;
  5539. return new _jpeg_stream.JpegStream(stream, maybeLength, stream.dict, params);
  5540. }
  5541. if (name === "JPXDecode" || name === "JPX") {
  5542. xrefStreamStats[_util.StreamType.JPX] = true;
  5543. return new _jpx_stream.JpxStream(stream, maybeLength, stream.dict, params);
  5544. }
  5545. if (name === "ASCII85Decode" || name === "A85") {
  5546. xrefStreamStats[_util.StreamType.A85] = true;
  5547. return new _stream.Ascii85Stream(stream, maybeLength);
  5548. }
  5549. if (name === "ASCIIHexDecode" || name === "AHx") {
  5550. xrefStreamStats[_util.StreamType.AHX] = true;
  5551. return new _stream.AsciiHexStream(stream, maybeLength);
  5552. }
  5553. if (name === "CCITTFaxDecode" || name === "CCF") {
  5554. xrefStreamStats[_util.StreamType.CCF] = true;
  5555. return new _ccitt_stream.CCITTFaxStream(stream, maybeLength, params);
  5556. }
  5557. if (name === "RunLengthDecode" || name === "RL") {
  5558. xrefStreamStats[_util.StreamType.RLX] = true;
  5559. return new _stream.RunLengthStream(stream, maybeLength);
  5560. }
  5561. if (name === "JBIG2Decode") {
  5562. xrefStreamStats[_util.StreamType.JBIG] = true;
  5563. return new _jbig2_stream.Jbig2Stream(stream, maybeLength, stream.dict, params);
  5564. }
  5565. (0, _util.warn)(`Filter "${name}" is not supported.`);
  5566. return stream;
  5567. } catch (ex) {
  5568. if (ex instanceof _core_utils.MissingDataException) {
  5569. throw ex;
  5570. }
  5571. (0, _util.warn)(`Invalid stream: "${ex}"`);
  5572. return new _stream.NullStream();
  5573. }
  5574. }
  5575. }
  5576. exports.Parser = Parser;
  5577. const specialChars = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 2, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 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, 2, 0, 2, 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, 2, 0, 2, 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, 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];
  5578. function toHexDigit(ch) {
  5579. if (ch >= 0x30 && ch <= 0x39) {
  5580. return ch & 0x0f;
  5581. }
  5582. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  5583. return (ch & 0x0f) + 9;
  5584. }
  5585. return -1;
  5586. }
  5587. class Lexer {
  5588. constructor(stream, knownCommands = null) {
  5589. this.stream = stream;
  5590. this.nextChar();
  5591. this.strBuf = [];
  5592. this.knownCommands = knownCommands;
  5593. this._hexStringNumWarn = 0;
  5594. this.beginInlineImagePos = -1;
  5595. }
  5596. nextChar() {
  5597. return this.currentChar = this.stream.getByte();
  5598. }
  5599. peekChar() {
  5600. return this.stream.peekByte();
  5601. }
  5602. getNumber() {
  5603. let ch = this.currentChar;
  5604. let eNotation = false;
  5605. let divideBy = 0;
  5606. let sign = 0;
  5607. if (ch === 0x2d) {
  5608. sign = -1;
  5609. ch = this.nextChar();
  5610. if (ch === 0x2d) {
  5611. ch = this.nextChar();
  5612. }
  5613. } else if (ch === 0x2b) {
  5614. sign = 1;
  5615. ch = this.nextChar();
  5616. }
  5617. if (ch === 0x0a || ch === 0x0d) {
  5618. do {
  5619. ch = this.nextChar();
  5620. } while (ch === 0x0a || ch === 0x0d);
  5621. }
  5622. if (ch === 0x2e) {
  5623. divideBy = 10;
  5624. ch = this.nextChar();
  5625. }
  5626. if (ch < 0x30 || ch > 0x39) {
  5627. if (divideBy === 10 && sign === 0 && ((0, _core_utils.isWhiteSpace)(ch) || ch === -1)) {
  5628. (0, _util.warn)("Lexer.getNumber - treating a single decimal point as zero.");
  5629. return 0;
  5630. }
  5631. throw new _util.FormatError(`Invalid number: ${String.fromCharCode(ch)} (charCode ${ch})`);
  5632. }
  5633. sign = sign || 1;
  5634. let baseValue = ch - 0x30;
  5635. let powerValue = 0;
  5636. let powerValueSign = 1;
  5637. while ((ch = this.nextChar()) >= 0) {
  5638. if (ch >= 0x30 && ch <= 0x39) {
  5639. const currentDigit = ch - 0x30;
  5640. if (eNotation) {
  5641. powerValue = powerValue * 10 + currentDigit;
  5642. } else {
  5643. if (divideBy !== 0) {
  5644. divideBy *= 10;
  5645. }
  5646. baseValue = baseValue * 10 + currentDigit;
  5647. }
  5648. } else if (ch === 0x2e) {
  5649. if (divideBy === 0) {
  5650. divideBy = 1;
  5651. } else {
  5652. break;
  5653. }
  5654. } else if (ch === 0x2d) {
  5655. (0, _util.warn)("Badly formatted number: minus sign in the middle");
  5656. } else if (ch === 0x45 || ch === 0x65) {
  5657. ch = this.peekChar();
  5658. if (ch === 0x2b || ch === 0x2d) {
  5659. powerValueSign = ch === 0x2d ? -1 : 1;
  5660. this.nextChar();
  5661. } else if (ch < 0x30 || ch > 0x39) {
  5662. break;
  5663. }
  5664. eNotation = true;
  5665. } else {
  5666. break;
  5667. }
  5668. }
  5669. if (divideBy !== 0) {
  5670. baseValue /= divideBy;
  5671. }
  5672. if (eNotation) {
  5673. baseValue *= 10 ** (powerValueSign * powerValue);
  5674. }
  5675. return sign * baseValue;
  5676. }
  5677. getString() {
  5678. let numParen = 1;
  5679. let done = false;
  5680. const strBuf = this.strBuf;
  5681. strBuf.length = 0;
  5682. let ch = this.nextChar();
  5683. while (true) {
  5684. let charBuffered = false;
  5685. switch (ch | 0) {
  5686. case -1:
  5687. (0, _util.warn)("Unterminated string");
  5688. done = true;
  5689. break;
  5690. case 0x28:
  5691. ++numParen;
  5692. strBuf.push("(");
  5693. break;
  5694. case 0x29:
  5695. if (--numParen === 0) {
  5696. this.nextChar();
  5697. done = true;
  5698. } else {
  5699. strBuf.push(")");
  5700. }
  5701. break;
  5702. case 0x5c:
  5703. ch = this.nextChar();
  5704. switch (ch) {
  5705. case -1:
  5706. (0, _util.warn)("Unterminated string");
  5707. done = true;
  5708. break;
  5709. case 0x6e:
  5710. strBuf.push("\n");
  5711. break;
  5712. case 0x72:
  5713. strBuf.push("\r");
  5714. break;
  5715. case 0x74:
  5716. strBuf.push("\t");
  5717. break;
  5718. case 0x62:
  5719. strBuf.push("\b");
  5720. break;
  5721. case 0x66:
  5722. strBuf.push("\f");
  5723. break;
  5724. case 0x5c:
  5725. case 0x28:
  5726. case 0x29:
  5727. strBuf.push(String.fromCharCode(ch));
  5728. break;
  5729. case 0x30:
  5730. case 0x31:
  5731. case 0x32:
  5732. case 0x33:
  5733. case 0x34:
  5734. case 0x35:
  5735. case 0x36:
  5736. case 0x37:
  5737. let x = ch & 0x0f;
  5738. ch = this.nextChar();
  5739. charBuffered = true;
  5740. if (ch >= 0x30 && ch <= 0x37) {
  5741. x = (x << 3) + (ch & 0x0f);
  5742. ch = this.nextChar();
  5743. if (ch >= 0x30 && ch <= 0x37) {
  5744. charBuffered = false;
  5745. x = (x << 3) + (ch & 0x0f);
  5746. }
  5747. }
  5748. strBuf.push(String.fromCharCode(x));
  5749. break;
  5750. case 0x0d:
  5751. if (this.peekChar() === 0x0a) {
  5752. this.nextChar();
  5753. }
  5754. break;
  5755. case 0x0a:
  5756. break;
  5757. default:
  5758. strBuf.push(String.fromCharCode(ch));
  5759. break;
  5760. }
  5761. break;
  5762. default:
  5763. strBuf.push(String.fromCharCode(ch));
  5764. break;
  5765. }
  5766. if (done) {
  5767. break;
  5768. }
  5769. if (!charBuffered) {
  5770. ch = this.nextChar();
  5771. }
  5772. }
  5773. return strBuf.join("");
  5774. }
  5775. getName() {
  5776. let ch, previousCh;
  5777. const strBuf = this.strBuf;
  5778. strBuf.length = 0;
  5779. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  5780. if (ch === 0x23) {
  5781. ch = this.nextChar();
  5782. if (specialChars[ch]) {
  5783. (0, _util.warn)("Lexer_getName: " + "NUMBER SIGN (#) should be followed by a hexadecimal number.");
  5784. strBuf.push("#");
  5785. break;
  5786. }
  5787. const x = toHexDigit(ch);
  5788. if (x !== -1) {
  5789. previousCh = ch;
  5790. ch = this.nextChar();
  5791. const x2 = toHexDigit(ch);
  5792. if (x2 === -1) {
  5793. (0, _util.warn)(`Lexer_getName: Illegal digit (${String.fromCharCode(ch)}) ` + "in hexadecimal number.");
  5794. strBuf.push("#", String.fromCharCode(previousCh));
  5795. if (specialChars[ch]) {
  5796. break;
  5797. }
  5798. strBuf.push(String.fromCharCode(ch));
  5799. continue;
  5800. }
  5801. strBuf.push(String.fromCharCode(x << 4 | x2));
  5802. } else {
  5803. strBuf.push("#", String.fromCharCode(ch));
  5804. }
  5805. } else {
  5806. strBuf.push(String.fromCharCode(ch));
  5807. }
  5808. }
  5809. if (strBuf.length > 127) {
  5810. (0, _util.warn)(`Name token is longer than allowed by the spec: ${strBuf.length}`);
  5811. }
  5812. return _primitives.Name.get(strBuf.join(""));
  5813. }
  5814. _hexStringWarn(ch) {
  5815. const MAX_HEX_STRING_NUM_WARN = 5;
  5816. if (this._hexStringNumWarn++ === MAX_HEX_STRING_NUM_WARN) {
  5817. (0, _util.warn)("getHexString - ignoring additional invalid characters.");
  5818. return;
  5819. }
  5820. if (this._hexStringNumWarn > MAX_HEX_STRING_NUM_WARN) {
  5821. return;
  5822. }
  5823. (0, _util.warn)(`getHexString - ignoring invalid character: ${ch}`);
  5824. }
  5825. getHexString() {
  5826. const strBuf = this.strBuf;
  5827. strBuf.length = 0;
  5828. let ch = this.currentChar;
  5829. let isFirstHex = true;
  5830. let firstDigit, secondDigit;
  5831. this._hexStringNumWarn = 0;
  5832. while (true) {
  5833. if (ch < 0) {
  5834. (0, _util.warn)("Unterminated hex string");
  5835. break;
  5836. } else if (ch === 0x3e) {
  5837. this.nextChar();
  5838. break;
  5839. } else if (specialChars[ch] === 1) {
  5840. ch = this.nextChar();
  5841. continue;
  5842. } else {
  5843. if (isFirstHex) {
  5844. firstDigit = toHexDigit(ch);
  5845. if (firstDigit === -1) {
  5846. this._hexStringWarn(ch);
  5847. ch = this.nextChar();
  5848. continue;
  5849. }
  5850. } else {
  5851. secondDigit = toHexDigit(ch);
  5852. if (secondDigit === -1) {
  5853. this._hexStringWarn(ch);
  5854. ch = this.nextChar();
  5855. continue;
  5856. }
  5857. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  5858. }
  5859. isFirstHex = !isFirstHex;
  5860. ch = this.nextChar();
  5861. }
  5862. }
  5863. return strBuf.join("");
  5864. }
  5865. getObj() {
  5866. let comment = false;
  5867. let ch = this.currentChar;
  5868. while (true) {
  5869. if (ch < 0) {
  5870. return _primitives.EOF;
  5871. }
  5872. if (comment) {
  5873. if (ch === 0x0a || ch === 0x0d) {
  5874. comment = false;
  5875. }
  5876. } else if (ch === 0x25) {
  5877. comment = true;
  5878. } else if (specialChars[ch] !== 1) {
  5879. break;
  5880. }
  5881. ch = this.nextChar();
  5882. }
  5883. switch (ch | 0) {
  5884. case 0x30:
  5885. case 0x31:
  5886. case 0x32:
  5887. case 0x33:
  5888. case 0x34:
  5889. case 0x35:
  5890. case 0x36:
  5891. case 0x37:
  5892. case 0x38:
  5893. case 0x39:
  5894. case 0x2b:
  5895. case 0x2d:
  5896. case 0x2e:
  5897. return this.getNumber();
  5898. case 0x28:
  5899. return this.getString();
  5900. case 0x2f:
  5901. return this.getName();
  5902. case 0x5b:
  5903. this.nextChar();
  5904. return _primitives.Cmd.get("[");
  5905. case 0x5d:
  5906. this.nextChar();
  5907. return _primitives.Cmd.get("]");
  5908. case 0x3c:
  5909. ch = this.nextChar();
  5910. if (ch === 0x3c) {
  5911. this.nextChar();
  5912. return _primitives.Cmd.get("<<");
  5913. }
  5914. return this.getHexString();
  5915. case 0x3e:
  5916. ch = this.nextChar();
  5917. if (ch === 0x3e) {
  5918. this.nextChar();
  5919. return _primitives.Cmd.get(">>");
  5920. }
  5921. return _primitives.Cmd.get(">");
  5922. case 0x7b:
  5923. this.nextChar();
  5924. return _primitives.Cmd.get("{");
  5925. case 0x7d:
  5926. this.nextChar();
  5927. return _primitives.Cmd.get("}");
  5928. case 0x29:
  5929. this.nextChar();
  5930. throw new _util.FormatError(`Illegal character: ${ch}`);
  5931. }
  5932. let str = String.fromCharCode(ch);
  5933. const knownCommands = this.knownCommands;
  5934. let knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  5935. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  5936. const possibleCommand = str + String.fromCharCode(ch);
  5937. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  5938. break;
  5939. }
  5940. if (str.length === 128) {
  5941. throw new _util.FormatError(`Command token too long: ${str.length}`);
  5942. }
  5943. str = possibleCommand;
  5944. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  5945. }
  5946. if (str === "true") {
  5947. return true;
  5948. }
  5949. if (str === "false") {
  5950. return false;
  5951. }
  5952. if (str === "null") {
  5953. return null;
  5954. }
  5955. if (str === "BI") {
  5956. this.beginInlineImagePos = this.stream.pos;
  5957. }
  5958. return _primitives.Cmd.get(str);
  5959. }
  5960. peekObj() {
  5961. const streamPos = this.stream.pos,
  5962. currentChar = this.currentChar,
  5963. beginInlineImagePos = this.beginInlineImagePos;
  5964. let nextObj;
  5965. try {
  5966. nextObj = this.getObj();
  5967. } catch (ex) {
  5968. if (ex instanceof _core_utils.MissingDataException) {
  5969. throw ex;
  5970. }
  5971. (0, _util.warn)(`peekObj: ${ex}`);
  5972. }
  5973. this.stream.pos = streamPos;
  5974. this.currentChar = currentChar;
  5975. this.beginInlineImagePos = beginInlineImagePos;
  5976. return nextObj;
  5977. }
  5978. skipToNextLine() {
  5979. let ch = this.currentChar;
  5980. while (ch >= 0) {
  5981. if (ch === 0x0d) {
  5982. ch = this.nextChar();
  5983. if (ch === 0x0a) {
  5984. this.nextChar();
  5985. }
  5986. break;
  5987. } else if (ch === 0x0a) {
  5988. this.nextChar();
  5989. break;
  5990. }
  5991. ch = this.nextChar();
  5992. }
  5993. }
  5994. }
  5995. exports.Lexer = Lexer;
  5996. class Linearization {
  5997. static create(stream) {
  5998. function getInt(linDict, name, allowZeroValue = false) {
  5999. const obj = linDict.get(name);
  6000. if (Number.isInteger(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  6001. return obj;
  6002. }
  6003. throw new Error(`The "${name}" parameter in the linearization ` + "dictionary is invalid.");
  6004. }
  6005. function getHints(linDict) {
  6006. const hints = linDict.get("H");
  6007. let hintsLength;
  6008. if (Array.isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  6009. for (let index = 0; index < hintsLength; index++) {
  6010. const hint = hints[index];
  6011. if (!(Number.isInteger(hint) && hint > 0)) {
  6012. throw new Error(`Hint (${index}) in the linearization dictionary is invalid.`);
  6013. }
  6014. }
  6015. return hints;
  6016. }
  6017. throw new Error("Hint array in the linearization dictionary is invalid.");
  6018. }
  6019. const parser = new Parser({
  6020. lexer: new Lexer(stream),
  6021. xref: null
  6022. });
  6023. const obj1 = parser.getObj();
  6024. const obj2 = parser.getObj();
  6025. const obj3 = parser.getObj();
  6026. const linDict = parser.getObj();
  6027. let obj, length;
  6028. if (!(Number.isInteger(obj1) && Number.isInteger(obj2) && (0, _primitives.isCmd)(obj3, "obj") && (0, _primitives.isDict)(linDict) && (0, _util.isNum)(obj = linDict.get("Linearized")) && obj > 0)) {
  6029. return null;
  6030. } else if ((length = getInt(linDict, "L")) !== stream.length) {
  6031. throw new Error('The "L" parameter in the linearization dictionary ' + "does not equal the stream length.");
  6032. }
  6033. return {
  6034. length,
  6035. hints: getHints(linDict),
  6036. objectNumberFirst: getInt(linDict, "O"),
  6037. endFirst: getInt(linDict, "E"),
  6038. numPages: getInt(linDict, "N"),
  6039. mainXRefEntriesOffset: getInt(linDict, "T"),
  6040. pageFirst: linDict.has("P") ? getInt(linDict, "P", true) : 0
  6041. };
  6042. }
  6043. }
  6044. exports.Linearization = Linearization;
  6045. /***/ }),
  6046. /* 12 */
  6047. /***/ (function(module, exports, __w_pdfjs_require__) {
  6048. "use strict";
  6049. Object.defineProperty(exports, "__esModule", {
  6050. value: true
  6051. });
  6052. exports.LZWStream = exports.StringStream = exports.StreamsSequenceStream = exports.Stream = exports.RunLengthStream = exports.PredictorStream = exports.NullStream = exports.FlateStream = exports.DecodeStream = exports.DecryptStream = exports.AsciiHexStream = exports.Ascii85Stream = void 0;
  6053. var _util = __w_pdfjs_require__(2);
  6054. var _primitives = __w_pdfjs_require__(5);
  6055. var _core_utils = __w_pdfjs_require__(8);
  6056. var Stream = function StreamClosure() {
  6057. function Stream(arrayBuffer, start, length, dict) {
  6058. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  6059. this.start = start || 0;
  6060. this.pos = this.start;
  6061. this.end = start + length || this.bytes.length;
  6062. this.dict = dict;
  6063. }
  6064. Stream.prototype = {
  6065. get length() {
  6066. return this.end - this.start;
  6067. },
  6068. get isEmpty() {
  6069. return this.length === 0;
  6070. },
  6071. getByte: function Stream_getByte() {
  6072. if (this.pos >= this.end) {
  6073. return -1;
  6074. }
  6075. return this.bytes[this.pos++];
  6076. },
  6077. getUint16: function Stream_getUint16() {
  6078. var b0 = this.getByte();
  6079. var b1 = this.getByte();
  6080. if (b0 === -1 || b1 === -1) {
  6081. return -1;
  6082. }
  6083. return (b0 << 8) + b1;
  6084. },
  6085. getInt32: function Stream_getInt32() {
  6086. var b0 = this.getByte();
  6087. var b1 = this.getByte();
  6088. var b2 = this.getByte();
  6089. var b3 = this.getByte();
  6090. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  6091. },
  6092. getBytes(length, forceClamped = false) {
  6093. var bytes = this.bytes;
  6094. var pos = this.pos;
  6095. var strEnd = this.end;
  6096. if (!length) {
  6097. const subarray = bytes.subarray(pos, strEnd);
  6098. return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
  6099. }
  6100. var end = pos + length;
  6101. if (end > strEnd) {
  6102. end = strEnd;
  6103. }
  6104. this.pos = end;
  6105. const subarray = bytes.subarray(pos, end);
  6106. return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
  6107. },
  6108. peekByte: function Stream_peekByte() {
  6109. var peekedByte = this.getByte();
  6110. if (peekedByte !== -1) {
  6111. this.pos--;
  6112. }
  6113. return peekedByte;
  6114. },
  6115. peekBytes(length, forceClamped = false) {
  6116. var bytes = this.getBytes(length, forceClamped);
  6117. this.pos -= bytes.length;
  6118. return bytes;
  6119. },
  6120. getByteRange(begin, end) {
  6121. if (begin < 0) {
  6122. begin = 0;
  6123. }
  6124. if (end > this.end) {
  6125. end = this.end;
  6126. }
  6127. return this.bytes.subarray(begin, end);
  6128. },
  6129. skip: function Stream_skip(n) {
  6130. if (!n) {
  6131. n = 1;
  6132. }
  6133. this.pos += n;
  6134. },
  6135. reset: function Stream_reset() {
  6136. this.pos = this.start;
  6137. },
  6138. moveStart: function Stream_moveStart() {
  6139. this.start = this.pos;
  6140. },
  6141. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  6142. return new Stream(this.bytes.buffer, start, length, dict);
  6143. }
  6144. };
  6145. return Stream;
  6146. }();
  6147. exports.Stream = Stream;
  6148. var StringStream = function StringStreamClosure() {
  6149. function StringStream(str) {
  6150. const bytes = (0, _util.stringToBytes)(str);
  6151. Stream.call(this, bytes);
  6152. }
  6153. StringStream.prototype = Stream.prototype;
  6154. return StringStream;
  6155. }();
  6156. exports.StringStream = StringStream;
  6157. var DecodeStream = function DecodeStreamClosure() {
  6158. var emptyBuffer = new Uint8Array(0);
  6159. function DecodeStream(maybeMinBufferLength) {
  6160. this._rawMinBufferLength = maybeMinBufferLength || 0;
  6161. this.pos = 0;
  6162. this.bufferLength = 0;
  6163. this.eof = false;
  6164. this.buffer = emptyBuffer;
  6165. this.minBufferLength = 512;
  6166. if (maybeMinBufferLength) {
  6167. while (this.minBufferLength < maybeMinBufferLength) {
  6168. this.minBufferLength *= 2;
  6169. }
  6170. }
  6171. }
  6172. DecodeStream.prototype = {
  6173. get isEmpty() {
  6174. while (!this.eof && this.bufferLength === 0) {
  6175. this.readBlock();
  6176. }
  6177. return this.bufferLength === 0;
  6178. },
  6179. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  6180. var buffer = this.buffer;
  6181. if (requested <= buffer.byteLength) {
  6182. return buffer;
  6183. }
  6184. var size = this.minBufferLength;
  6185. while (size < requested) {
  6186. size *= 2;
  6187. }
  6188. var buffer2 = new Uint8Array(size);
  6189. buffer2.set(buffer);
  6190. return this.buffer = buffer2;
  6191. },
  6192. getByte: function DecodeStream_getByte() {
  6193. var pos = this.pos;
  6194. while (this.bufferLength <= pos) {
  6195. if (this.eof) {
  6196. return -1;
  6197. }
  6198. this.readBlock();
  6199. }
  6200. return this.buffer[this.pos++];
  6201. },
  6202. getUint16: function DecodeStream_getUint16() {
  6203. var b0 = this.getByte();
  6204. var b1 = this.getByte();
  6205. if (b0 === -1 || b1 === -1) {
  6206. return -1;
  6207. }
  6208. return (b0 << 8) + b1;
  6209. },
  6210. getInt32: function DecodeStream_getInt32() {
  6211. var b0 = this.getByte();
  6212. var b1 = this.getByte();
  6213. var b2 = this.getByte();
  6214. var b3 = this.getByte();
  6215. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  6216. },
  6217. getBytes(length, forceClamped = false) {
  6218. var end,
  6219. pos = this.pos;
  6220. if (length) {
  6221. this.ensureBuffer(pos + length);
  6222. end = pos + length;
  6223. while (!this.eof && this.bufferLength < end) {
  6224. this.readBlock();
  6225. }
  6226. var bufEnd = this.bufferLength;
  6227. if (end > bufEnd) {
  6228. end = bufEnd;
  6229. }
  6230. } else {
  6231. while (!this.eof) {
  6232. this.readBlock();
  6233. }
  6234. end = this.bufferLength;
  6235. }
  6236. this.pos = end;
  6237. const subarray = this.buffer.subarray(pos, end);
  6238. return forceClamped && !(subarray instanceof Uint8ClampedArray) ? new Uint8ClampedArray(subarray) : subarray;
  6239. },
  6240. peekByte: function DecodeStream_peekByte() {
  6241. var peekedByte = this.getByte();
  6242. if (peekedByte !== -1) {
  6243. this.pos--;
  6244. }
  6245. return peekedByte;
  6246. },
  6247. peekBytes(length, forceClamped = false) {
  6248. var bytes = this.getBytes(length, forceClamped);
  6249. this.pos -= bytes.length;
  6250. return bytes;
  6251. },
  6252. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  6253. var end = start + length;
  6254. while (this.bufferLength <= end && !this.eof) {
  6255. this.readBlock();
  6256. }
  6257. return new Stream(this.buffer, start, length, dict);
  6258. },
  6259. getByteRange(begin, end) {
  6260. (0, _util.unreachable)("Should not call DecodeStream.getByteRange");
  6261. },
  6262. skip: function DecodeStream_skip(n) {
  6263. if (!n) {
  6264. n = 1;
  6265. }
  6266. this.pos += n;
  6267. },
  6268. reset: function DecodeStream_reset() {
  6269. this.pos = 0;
  6270. },
  6271. getBaseStreams: function DecodeStream_getBaseStreams() {
  6272. if (this.str && this.str.getBaseStreams) {
  6273. return this.str.getBaseStreams();
  6274. }
  6275. return [];
  6276. }
  6277. };
  6278. return DecodeStream;
  6279. }();
  6280. exports.DecodeStream = DecodeStream;
  6281. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  6282. function StreamsSequenceStream(streams) {
  6283. this.streams = streams;
  6284. let maybeLength = 0;
  6285. for (let i = 0, ii = streams.length; i < ii; i++) {
  6286. const stream = streams[i];
  6287. if (stream instanceof DecodeStream) {
  6288. maybeLength += stream._rawMinBufferLength;
  6289. } else {
  6290. maybeLength += stream.length;
  6291. }
  6292. }
  6293. DecodeStream.call(this, maybeLength);
  6294. }
  6295. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  6296. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  6297. var streams = this.streams;
  6298. if (streams.length === 0) {
  6299. this.eof = true;
  6300. return;
  6301. }
  6302. var stream = streams.shift();
  6303. var chunk = stream.getBytes();
  6304. var bufferLength = this.bufferLength;
  6305. var newLength = bufferLength + chunk.length;
  6306. var buffer = this.ensureBuffer(newLength);
  6307. buffer.set(chunk, bufferLength);
  6308. this.bufferLength = newLength;
  6309. };
  6310. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  6311. var baseStreams = [];
  6312. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  6313. var stream = this.streams[i];
  6314. if (stream.getBaseStreams) {
  6315. baseStreams.push(...stream.getBaseStreams());
  6316. }
  6317. }
  6318. return baseStreams;
  6319. };
  6320. return StreamsSequenceStream;
  6321. }();
  6322. exports.StreamsSequenceStream = StreamsSequenceStream;
  6323. var FlateStream = function FlateStreamClosure() {
  6324. var codeLenCodeMap = new Int32Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
  6325. var lengthDecode = new Int32Array([0x00003, 0x00004, 0x00005, 0x00006, 0x00007, 0x00008, 0x00009, 0x0000a, 0x1000b, 0x1000d, 0x1000f, 0x10011, 0x20013, 0x20017, 0x2001b, 0x2001f, 0x30023, 0x3002b, 0x30033, 0x3003b, 0x40043, 0x40053, 0x40063, 0x40073, 0x50083, 0x500a3, 0x500c3, 0x500e3, 0x00102, 0x00102, 0x00102]);
  6326. var distDecode = new Int32Array([0x00001, 0x00002, 0x00003, 0x00004, 0x10005, 0x10007, 0x20009, 0x2000d, 0x30011, 0x30019, 0x40021, 0x40031, 0x50041, 0x50061, 0x60081, 0x600c1, 0x70101, 0x70181, 0x80201, 0x80301, 0x90401, 0x90601, 0xa0801, 0xa0c01, 0xb1001, 0xb1801, 0xc2001, 0xc3001, 0xd4001, 0xd6001]);
  6327. var fixedLitCodeTab = [new Int32Array([0x70100, 0x80050, 0x80010, 0x80118, 0x70110, 0x80070, 0x80030, 0x900c0, 0x70108, 0x80060, 0x80020, 0x900a0, 0x80000, 0x80080, 0x80040, 0x900e0, 0x70104, 0x80058, 0x80018, 0x90090, 0x70114, 0x80078, 0x80038, 0x900d0, 0x7010c, 0x80068, 0x80028, 0x900b0, 0x80008, 0x80088, 0x80048, 0x900f0, 0x70102, 0x80054, 0x80014, 0x8011c, 0x70112, 0x80074, 0x80034, 0x900c8, 0x7010a, 0x80064, 0x80024, 0x900a8, 0x80004, 0x80084, 0x80044, 0x900e8, 0x70106, 0x8005c, 0x8001c, 0x90098, 0x70116, 0x8007c, 0x8003c, 0x900d8, 0x7010e, 0x8006c, 0x8002c, 0x900b8, 0x8000c, 0x8008c, 0x8004c, 0x900f8, 0x70101, 0x80052, 0x80012, 0x8011a, 0x70111, 0x80072, 0x80032, 0x900c4, 0x70109, 0x80062, 0x80022, 0x900a4, 0x80002, 0x80082, 0x80042, 0x900e4, 0x70105, 0x8005a, 0x8001a, 0x90094, 0x70115, 0x8007a, 0x8003a, 0x900d4, 0x7010d, 0x8006a, 0x8002a, 0x900b4, 0x8000a, 0x8008a, 0x8004a, 0x900f4, 0x70103, 0x80056, 0x80016, 0x8011e, 0x70113, 0x80076, 0x80036, 0x900cc, 0x7010b, 0x80066, 0x80026, 0x900ac, 0x80006, 0x80086, 0x80046, 0x900ec, 0x70107, 0x8005e, 0x8001e, 0x9009c, 0x70117, 0x8007e, 0x8003e, 0x900dc, 0x7010f, 0x8006e, 0x8002e, 0x900bc, 0x8000e, 0x8008e, 0x8004e, 0x900fc, 0x70100, 0x80051, 0x80011, 0x80119, 0x70110, 0x80071, 0x80031, 0x900c2, 0x70108, 0x80061, 0x80021, 0x900a2, 0x80001, 0x80081, 0x80041, 0x900e2, 0x70104, 0x80059, 0x80019, 0x90092, 0x70114, 0x80079, 0x80039, 0x900d2, 0x7010c, 0x80069, 0x80029, 0x900b2, 0x80009, 0x80089, 0x80049, 0x900f2, 0x70102, 0x80055, 0x80015, 0x8011d, 0x70112, 0x80075, 0x80035, 0x900ca, 0x7010a, 0x80065, 0x80025, 0x900aa, 0x80005, 0x80085, 0x80045, 0x900ea, 0x70106, 0x8005d, 0x8001d, 0x9009a, 0x70116, 0x8007d, 0x8003d, 0x900da, 0x7010e, 0x8006d, 0x8002d, 0x900ba, 0x8000d, 0x8008d, 0x8004d, 0x900fa, 0x70101, 0x80053, 0x80013, 0x8011b, 0x70111, 0x80073, 0x80033, 0x900c6, 0x70109, 0x80063, 0x80023, 0x900a6, 0x80003, 0x80083, 0x80043, 0x900e6, 0x70105, 0x8005b, 0x8001b, 0x90096, 0x70115, 0x8007b, 0x8003b, 0x900d6, 0x7010d, 0x8006b, 0x8002b, 0x900b6, 0x8000b, 0x8008b, 0x8004b, 0x900f6, 0x70103, 0x80057, 0x80017, 0x8011f, 0x70113, 0x80077, 0x80037, 0x900ce, 0x7010b, 0x80067, 0x80027, 0x900ae, 0x80007, 0x80087, 0x80047, 0x900ee, 0x70107, 0x8005f, 0x8001f, 0x9009e, 0x70117, 0x8007f, 0x8003f, 0x900de, 0x7010f, 0x8006f, 0x8002f, 0x900be, 0x8000f, 0x8008f, 0x8004f, 0x900fe, 0x70100, 0x80050, 0x80010, 0x80118, 0x70110, 0x80070, 0x80030, 0x900c1, 0x70108, 0x80060, 0x80020, 0x900a1, 0x80000, 0x80080, 0x80040, 0x900e1, 0x70104, 0x80058, 0x80018, 0x90091, 0x70114, 0x80078, 0x80038, 0x900d1, 0x7010c, 0x80068, 0x80028, 0x900b1, 0x80008, 0x80088, 0x80048, 0x900f1, 0x70102, 0x80054, 0x80014, 0x8011c, 0x70112, 0x80074, 0x80034, 0x900c9, 0x7010a, 0x80064, 0x80024, 0x900a9, 0x80004, 0x80084, 0x80044, 0x900e9, 0x70106, 0x8005c, 0x8001c, 0x90099, 0x70116, 0x8007c, 0x8003c, 0x900d9, 0x7010e, 0x8006c, 0x8002c, 0x900b9, 0x8000c, 0x8008c, 0x8004c, 0x900f9, 0x70101, 0x80052, 0x80012, 0x8011a, 0x70111, 0x80072, 0x80032, 0x900c5, 0x70109, 0x80062, 0x80022, 0x900a5, 0x80002, 0x80082, 0x80042, 0x900e5, 0x70105, 0x8005a, 0x8001a, 0x90095, 0x70115, 0x8007a, 0x8003a, 0x900d5, 0x7010d, 0x8006a, 0x8002a, 0x900b5, 0x8000a, 0x8008a, 0x8004a, 0x900f5, 0x70103, 0x80056, 0x80016, 0x8011e, 0x70113, 0x80076, 0x80036, 0x900cd, 0x7010b, 0x80066, 0x80026, 0x900ad, 0x80006, 0x80086, 0x80046, 0x900ed, 0x70107, 0x8005e, 0x8001e, 0x9009d, 0x70117, 0x8007e, 0x8003e, 0x900dd, 0x7010f, 0x8006e, 0x8002e, 0x900bd, 0x8000e, 0x8008e, 0x8004e, 0x900fd, 0x70100, 0x80051, 0x80011, 0x80119, 0x70110, 0x80071, 0x80031, 0x900c3, 0x70108, 0x80061, 0x80021, 0x900a3, 0x80001, 0x80081, 0x80041, 0x900e3, 0x70104, 0x80059, 0x80019, 0x90093, 0x70114, 0x80079, 0x80039, 0x900d3, 0x7010c, 0x80069, 0x80029, 0x900b3, 0x80009, 0x80089, 0x80049, 0x900f3, 0x70102, 0x80055, 0x80015, 0x8011d, 0x70112, 0x80075, 0x80035, 0x900cb, 0x7010a, 0x80065, 0x80025, 0x900ab, 0x80005, 0x80085, 0x80045, 0x900eb, 0x70106, 0x8005d, 0x8001d, 0x9009b, 0x70116, 0x8007d, 0x8003d, 0x900db, 0x7010e, 0x8006d, 0x8002d, 0x900bb, 0x8000d, 0x8008d, 0x8004d, 0x900fb, 0x70101, 0x80053, 0x80013, 0x8011b, 0x70111, 0x80073, 0x80033, 0x900c7, 0x70109, 0x80063, 0x80023, 0x900a7, 0x80003, 0x80083, 0x80043, 0x900e7, 0x70105, 0x8005b, 0x8001b, 0x90097, 0x70115, 0x8007b, 0x8003b, 0x900d7, 0x7010d, 0x8006b, 0x8002b, 0x900b7, 0x8000b, 0x8008b, 0x8004b, 0x900f7, 0x70103, 0x80057, 0x80017, 0x8011f, 0x70113, 0x80077, 0x80037, 0x900cf, 0x7010b, 0x80067, 0x80027, 0x900af, 0x80007, 0x80087, 0x80047, 0x900ef, 0x70107, 0x8005f, 0x8001f, 0x9009f, 0x70117, 0x8007f, 0x8003f, 0x900df, 0x7010f, 0x8006f, 0x8002f, 0x900bf, 0x8000f, 0x8008f, 0x8004f, 0x900ff]), 9];
  6328. var fixedDistCodeTab = [new Int32Array([0x50000, 0x50010, 0x50008, 0x50018, 0x50004, 0x50014, 0x5000c, 0x5001c, 0x50002, 0x50012, 0x5000a, 0x5001a, 0x50006, 0x50016, 0x5000e, 0x00000, 0x50001, 0x50011, 0x50009, 0x50019, 0x50005, 0x50015, 0x5000d, 0x5001d, 0x50003, 0x50013, 0x5000b, 0x5001b, 0x50007, 0x50017, 0x5000f, 0x00000]), 5];
  6329. function FlateStream(str, maybeLength) {
  6330. this.str = str;
  6331. this.dict = str.dict;
  6332. var cmf = str.getByte();
  6333. var flg = str.getByte();
  6334. if (cmf === -1 || flg === -1) {
  6335. throw new _util.FormatError(`Invalid header in flate stream: ${cmf}, ${flg}`);
  6336. }
  6337. if ((cmf & 0x0f) !== 0x08) {
  6338. throw new _util.FormatError(`Unknown compression method in flate stream: ${cmf}, ${flg}`);
  6339. }
  6340. if (((cmf << 8) + flg) % 31 !== 0) {
  6341. throw new _util.FormatError(`Bad FCHECK in flate stream: ${cmf}, ${flg}`);
  6342. }
  6343. if (flg & 0x20) {
  6344. throw new _util.FormatError(`FDICT bit set in flate stream: ${cmf}, ${flg}`);
  6345. }
  6346. this.codeSize = 0;
  6347. this.codeBuf = 0;
  6348. DecodeStream.call(this, maybeLength);
  6349. }
  6350. FlateStream.prototype = Object.create(DecodeStream.prototype);
  6351. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  6352. var str = this.str;
  6353. var codeSize = this.codeSize;
  6354. var codeBuf = this.codeBuf;
  6355. var b;
  6356. while (codeSize < bits) {
  6357. if ((b = str.getByte()) === -1) {
  6358. throw new _util.FormatError("Bad encoding in flate stream");
  6359. }
  6360. codeBuf |= b << codeSize;
  6361. codeSize += 8;
  6362. }
  6363. b = codeBuf & (1 << bits) - 1;
  6364. this.codeBuf = codeBuf >> bits;
  6365. this.codeSize = codeSize -= bits;
  6366. return b;
  6367. };
  6368. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  6369. var str = this.str;
  6370. var codes = table[0];
  6371. var maxLen = table[1];
  6372. var codeSize = this.codeSize;
  6373. var codeBuf = this.codeBuf;
  6374. var b;
  6375. while (codeSize < maxLen) {
  6376. if ((b = str.getByte()) === -1) {
  6377. break;
  6378. }
  6379. codeBuf |= b << codeSize;
  6380. codeSize += 8;
  6381. }
  6382. var code = codes[codeBuf & (1 << maxLen) - 1];
  6383. var codeLen = code >> 16;
  6384. var codeVal = code & 0xffff;
  6385. if (codeLen < 1 || codeSize < codeLen) {
  6386. throw new _util.FormatError("Bad encoding in flate stream");
  6387. }
  6388. this.codeBuf = codeBuf >> codeLen;
  6389. this.codeSize = codeSize - codeLen;
  6390. return codeVal;
  6391. };
  6392. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  6393. var n = lengths.length;
  6394. var maxLen = 0;
  6395. var i;
  6396. for (i = 0; i < n; ++i) {
  6397. if (lengths[i] > maxLen) {
  6398. maxLen = lengths[i];
  6399. }
  6400. }
  6401. var size = 1 << maxLen;
  6402. var codes = new Int32Array(size);
  6403. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  6404. for (var val = 0; val < n; ++val) {
  6405. if (lengths[val] === len) {
  6406. var code2 = 0;
  6407. var t = code;
  6408. for (i = 0; i < len; ++i) {
  6409. code2 = code2 << 1 | t & 1;
  6410. t >>= 1;
  6411. }
  6412. for (i = code2; i < size; i += skip) {
  6413. codes[i] = len << 16 | val;
  6414. }
  6415. ++code;
  6416. }
  6417. }
  6418. }
  6419. return [codes, maxLen];
  6420. };
  6421. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  6422. var buffer, len;
  6423. var str = this.str;
  6424. var hdr = this.getBits(3);
  6425. if (hdr & 1) {
  6426. this.eof = true;
  6427. }
  6428. hdr >>= 1;
  6429. if (hdr === 0) {
  6430. var b;
  6431. if ((b = str.getByte()) === -1) {
  6432. throw new _util.FormatError("Bad block header in flate stream");
  6433. }
  6434. var blockLen = b;
  6435. if ((b = str.getByte()) === -1) {
  6436. throw new _util.FormatError("Bad block header in flate stream");
  6437. }
  6438. blockLen |= b << 8;
  6439. if ((b = str.getByte()) === -1) {
  6440. throw new _util.FormatError("Bad block header in flate stream");
  6441. }
  6442. var check = b;
  6443. if ((b = str.getByte()) === -1) {
  6444. throw new _util.FormatError("Bad block header in flate stream");
  6445. }
  6446. check |= b << 8;
  6447. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  6448. throw new _util.FormatError("Bad uncompressed block length in flate stream");
  6449. }
  6450. this.codeBuf = 0;
  6451. this.codeSize = 0;
  6452. const bufferLength = this.bufferLength,
  6453. end = bufferLength + blockLen;
  6454. buffer = this.ensureBuffer(end);
  6455. this.bufferLength = end;
  6456. if (blockLen === 0) {
  6457. if (str.peekByte() === -1) {
  6458. this.eof = true;
  6459. }
  6460. } else {
  6461. const block = str.getBytes(blockLen);
  6462. buffer.set(block, bufferLength);
  6463. if (block.length < blockLen) {
  6464. this.eof = true;
  6465. }
  6466. }
  6467. return;
  6468. }
  6469. var litCodeTable;
  6470. var distCodeTable;
  6471. if (hdr === 1) {
  6472. litCodeTable = fixedLitCodeTab;
  6473. distCodeTable = fixedDistCodeTab;
  6474. } else if (hdr === 2) {
  6475. var numLitCodes = this.getBits(5) + 257;
  6476. var numDistCodes = this.getBits(5) + 1;
  6477. var numCodeLenCodes = this.getBits(4) + 4;
  6478. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  6479. var i;
  6480. for (i = 0; i < numCodeLenCodes; ++i) {
  6481. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  6482. }
  6483. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  6484. len = 0;
  6485. i = 0;
  6486. var codes = numLitCodes + numDistCodes;
  6487. var codeLengths = new Uint8Array(codes);
  6488. var bitsLength, bitsOffset, what;
  6489. while (i < codes) {
  6490. var code = this.getCode(codeLenCodeTab);
  6491. if (code === 16) {
  6492. bitsLength = 2;
  6493. bitsOffset = 3;
  6494. what = len;
  6495. } else if (code === 17) {
  6496. bitsLength = 3;
  6497. bitsOffset = 3;
  6498. what = len = 0;
  6499. } else if (code === 18) {
  6500. bitsLength = 7;
  6501. bitsOffset = 11;
  6502. what = len = 0;
  6503. } else {
  6504. codeLengths[i++] = len = code;
  6505. continue;
  6506. }
  6507. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  6508. while (repeatLength-- > 0) {
  6509. codeLengths[i++] = what;
  6510. }
  6511. }
  6512. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  6513. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  6514. } else {
  6515. throw new _util.FormatError("Unknown block type in flate stream");
  6516. }
  6517. buffer = this.buffer;
  6518. var limit = buffer ? buffer.length : 0;
  6519. var pos = this.bufferLength;
  6520. while (true) {
  6521. var code1 = this.getCode(litCodeTable);
  6522. if (code1 < 256) {
  6523. if (pos + 1 >= limit) {
  6524. buffer = this.ensureBuffer(pos + 1);
  6525. limit = buffer.length;
  6526. }
  6527. buffer[pos++] = code1;
  6528. continue;
  6529. }
  6530. if (code1 === 256) {
  6531. this.bufferLength = pos;
  6532. return;
  6533. }
  6534. code1 -= 257;
  6535. code1 = lengthDecode[code1];
  6536. var code2 = code1 >> 16;
  6537. if (code2 > 0) {
  6538. code2 = this.getBits(code2);
  6539. }
  6540. len = (code1 & 0xffff) + code2;
  6541. code1 = this.getCode(distCodeTable);
  6542. code1 = distDecode[code1];
  6543. code2 = code1 >> 16;
  6544. if (code2 > 0) {
  6545. code2 = this.getBits(code2);
  6546. }
  6547. var dist = (code1 & 0xffff) + code2;
  6548. if (pos + len >= limit) {
  6549. buffer = this.ensureBuffer(pos + len);
  6550. limit = buffer.length;
  6551. }
  6552. for (var k = 0; k < len; ++k, ++pos) {
  6553. buffer[pos] = buffer[pos - dist];
  6554. }
  6555. }
  6556. };
  6557. return FlateStream;
  6558. }();
  6559. exports.FlateStream = FlateStream;
  6560. var PredictorStream = function PredictorStreamClosure() {
  6561. function PredictorStream(str, maybeLength, params) {
  6562. if (!(0, _primitives.isDict)(params)) {
  6563. return str;
  6564. }
  6565. var predictor = this.predictor = params.get("Predictor") || 1;
  6566. if (predictor <= 1) {
  6567. return str;
  6568. }
  6569. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  6570. throw new _util.FormatError(`Unsupported predictor: ${predictor}`);
  6571. }
  6572. if (predictor === 2) {
  6573. this.readBlock = this.readBlockTiff;
  6574. } else {
  6575. this.readBlock = this.readBlockPng;
  6576. }
  6577. this.str = str;
  6578. this.dict = str.dict;
  6579. var colors = this.colors = params.get("Colors") || 1;
  6580. var bits = this.bits = params.get("BitsPerComponent") || 8;
  6581. var columns = this.columns = params.get("Columns") || 1;
  6582. this.pixBytes = colors * bits + 7 >> 3;
  6583. this.rowBytes = columns * colors * bits + 7 >> 3;
  6584. DecodeStream.call(this, maybeLength);
  6585. return this;
  6586. }
  6587. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  6588. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  6589. var rowBytes = this.rowBytes;
  6590. var bufferLength = this.bufferLength;
  6591. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  6592. var bits = this.bits;
  6593. var colors = this.colors;
  6594. var rawBytes = this.str.getBytes(rowBytes);
  6595. this.eof = !rawBytes.length;
  6596. if (this.eof) {
  6597. return;
  6598. }
  6599. var inbuf = 0,
  6600. outbuf = 0;
  6601. var inbits = 0,
  6602. outbits = 0;
  6603. var pos = bufferLength;
  6604. var i;
  6605. if (bits === 1 && colors === 1) {
  6606. for (i = 0; i < rowBytes; ++i) {
  6607. var c = rawBytes[i] ^ inbuf;
  6608. c ^= c >> 1;
  6609. c ^= c >> 2;
  6610. c ^= c >> 4;
  6611. inbuf = (c & 1) << 7;
  6612. buffer[pos++] = c;
  6613. }
  6614. } else if (bits === 8) {
  6615. for (i = 0; i < colors; ++i) {
  6616. buffer[pos++] = rawBytes[i];
  6617. }
  6618. for (; i < rowBytes; ++i) {
  6619. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  6620. pos++;
  6621. }
  6622. } else if (bits === 16) {
  6623. var bytesPerPixel = colors * 2;
  6624. for (i = 0; i < bytesPerPixel; ++i) {
  6625. buffer[pos++] = rawBytes[i];
  6626. }
  6627. for (; i < rowBytes; i += 2) {
  6628. var sum = ((rawBytes[i] & 0xff) << 8) + (rawBytes[i + 1] & 0xff) + ((buffer[pos - bytesPerPixel] & 0xff) << 8) + (buffer[pos - bytesPerPixel + 1] & 0xff);
  6629. buffer[pos++] = sum >> 8 & 0xff;
  6630. buffer[pos++] = sum & 0xff;
  6631. }
  6632. } else {
  6633. var compArray = new Uint8Array(colors + 1);
  6634. var bitMask = (1 << bits) - 1;
  6635. var j = 0,
  6636. k = bufferLength;
  6637. var columns = this.columns;
  6638. for (i = 0; i < columns; ++i) {
  6639. for (var kk = 0; kk < colors; ++kk) {
  6640. if (inbits < bits) {
  6641. inbuf = inbuf << 8 | rawBytes[j++] & 0xff;
  6642. inbits += 8;
  6643. }
  6644. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  6645. inbits -= bits;
  6646. outbuf = outbuf << bits | compArray[kk];
  6647. outbits += bits;
  6648. if (outbits >= 8) {
  6649. buffer[k++] = outbuf >> outbits - 8 & 0xff;
  6650. outbits -= 8;
  6651. }
  6652. }
  6653. }
  6654. if (outbits > 0) {
  6655. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  6656. }
  6657. }
  6658. this.bufferLength += rowBytes;
  6659. };
  6660. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  6661. var rowBytes = this.rowBytes;
  6662. var pixBytes = this.pixBytes;
  6663. var predictor = this.str.getByte();
  6664. var rawBytes = this.str.getBytes(rowBytes);
  6665. this.eof = !rawBytes.length;
  6666. if (this.eof) {
  6667. return;
  6668. }
  6669. var bufferLength = this.bufferLength;
  6670. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  6671. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  6672. if (prevRow.length === 0) {
  6673. prevRow = new Uint8Array(rowBytes);
  6674. }
  6675. var i,
  6676. j = bufferLength,
  6677. up,
  6678. c;
  6679. switch (predictor) {
  6680. case 0:
  6681. for (i = 0; i < rowBytes; ++i) {
  6682. buffer[j++] = rawBytes[i];
  6683. }
  6684. break;
  6685. case 1:
  6686. for (i = 0; i < pixBytes; ++i) {
  6687. buffer[j++] = rawBytes[i];
  6688. }
  6689. for (; i < rowBytes; ++i) {
  6690. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xff;
  6691. j++;
  6692. }
  6693. break;
  6694. case 2:
  6695. for (i = 0; i < rowBytes; ++i) {
  6696. buffer[j++] = prevRow[i] + rawBytes[i] & 0xff;
  6697. }
  6698. break;
  6699. case 3:
  6700. for (i = 0; i < pixBytes; ++i) {
  6701. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  6702. }
  6703. for (; i < rowBytes; ++i) {
  6704. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xff;
  6705. j++;
  6706. }
  6707. break;
  6708. case 4:
  6709. for (i = 0; i < pixBytes; ++i) {
  6710. up = prevRow[i];
  6711. c = rawBytes[i];
  6712. buffer[j++] = up + c;
  6713. }
  6714. for (; i < rowBytes; ++i) {
  6715. up = prevRow[i];
  6716. var upLeft = prevRow[i - pixBytes];
  6717. var left = buffer[j - pixBytes];
  6718. var p = left + up - upLeft;
  6719. var pa = p - left;
  6720. if (pa < 0) {
  6721. pa = -pa;
  6722. }
  6723. var pb = p - up;
  6724. if (pb < 0) {
  6725. pb = -pb;
  6726. }
  6727. var pc = p - upLeft;
  6728. if (pc < 0) {
  6729. pc = -pc;
  6730. }
  6731. c = rawBytes[i];
  6732. if (pa <= pb && pa <= pc) {
  6733. buffer[j++] = left + c;
  6734. } else if (pb <= pc) {
  6735. buffer[j++] = up + c;
  6736. } else {
  6737. buffer[j++] = upLeft + c;
  6738. }
  6739. }
  6740. break;
  6741. default:
  6742. throw new _util.FormatError(`Unsupported predictor: ${predictor}`);
  6743. }
  6744. this.bufferLength += rowBytes;
  6745. };
  6746. return PredictorStream;
  6747. }();
  6748. exports.PredictorStream = PredictorStream;
  6749. var DecryptStream = function DecryptStreamClosure() {
  6750. function DecryptStream(str, maybeLength, decrypt) {
  6751. this.str = str;
  6752. this.dict = str.dict;
  6753. this.decrypt = decrypt;
  6754. this.nextChunk = null;
  6755. this.initialized = false;
  6756. DecodeStream.call(this, maybeLength);
  6757. }
  6758. var chunkSize = 512;
  6759. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  6760. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  6761. var chunk;
  6762. if (this.initialized) {
  6763. chunk = this.nextChunk;
  6764. } else {
  6765. chunk = this.str.getBytes(chunkSize);
  6766. this.initialized = true;
  6767. }
  6768. if (!chunk || chunk.length === 0) {
  6769. this.eof = true;
  6770. return;
  6771. }
  6772. this.nextChunk = this.str.getBytes(chunkSize);
  6773. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  6774. var decrypt = this.decrypt;
  6775. chunk = decrypt(chunk, !hasMoreData);
  6776. var bufferLength = this.bufferLength;
  6777. var i,
  6778. n = chunk.length;
  6779. var buffer = this.ensureBuffer(bufferLength + n);
  6780. for (i = 0; i < n; i++) {
  6781. buffer[bufferLength++] = chunk[i];
  6782. }
  6783. this.bufferLength = bufferLength;
  6784. };
  6785. return DecryptStream;
  6786. }();
  6787. exports.DecryptStream = DecryptStream;
  6788. var Ascii85Stream = function Ascii85StreamClosure() {
  6789. function Ascii85Stream(str, maybeLength) {
  6790. this.str = str;
  6791. this.dict = str.dict;
  6792. this.input = new Uint8Array(5);
  6793. if (maybeLength) {
  6794. maybeLength = 0.8 * maybeLength;
  6795. }
  6796. DecodeStream.call(this, maybeLength);
  6797. }
  6798. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  6799. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  6800. var TILDA_CHAR = 0x7e;
  6801. var Z_LOWER_CHAR = 0x7a;
  6802. var EOF = -1;
  6803. var str = this.str;
  6804. var c = str.getByte();
  6805. while ((0, _core_utils.isWhiteSpace)(c)) {
  6806. c = str.getByte();
  6807. }
  6808. if (c === EOF || c === TILDA_CHAR) {
  6809. this.eof = true;
  6810. return;
  6811. }
  6812. var bufferLength = this.bufferLength,
  6813. buffer;
  6814. var i;
  6815. if (c === Z_LOWER_CHAR) {
  6816. buffer = this.ensureBuffer(bufferLength + 4);
  6817. for (i = 0; i < 4; ++i) {
  6818. buffer[bufferLength + i] = 0;
  6819. }
  6820. this.bufferLength += 4;
  6821. } else {
  6822. var input = this.input;
  6823. input[0] = c;
  6824. for (i = 1; i < 5; ++i) {
  6825. c = str.getByte();
  6826. while ((0, _core_utils.isWhiteSpace)(c)) {
  6827. c = str.getByte();
  6828. }
  6829. input[i] = c;
  6830. if (c === EOF || c === TILDA_CHAR) {
  6831. break;
  6832. }
  6833. }
  6834. buffer = this.ensureBuffer(bufferLength + i - 1);
  6835. this.bufferLength += i - 1;
  6836. if (i < 5) {
  6837. for (; i < 5; ++i) {
  6838. input[i] = 0x21 + 84;
  6839. }
  6840. this.eof = true;
  6841. }
  6842. var t = 0;
  6843. for (i = 0; i < 5; ++i) {
  6844. t = t * 85 + (input[i] - 0x21);
  6845. }
  6846. for (i = 3; i >= 0; --i) {
  6847. buffer[bufferLength + i] = t & 0xff;
  6848. t >>= 8;
  6849. }
  6850. }
  6851. };
  6852. return Ascii85Stream;
  6853. }();
  6854. exports.Ascii85Stream = Ascii85Stream;
  6855. var AsciiHexStream = function AsciiHexStreamClosure() {
  6856. function AsciiHexStream(str, maybeLength) {
  6857. this.str = str;
  6858. this.dict = str.dict;
  6859. this.firstDigit = -1;
  6860. if (maybeLength) {
  6861. maybeLength = 0.5 * maybeLength;
  6862. }
  6863. DecodeStream.call(this, maybeLength);
  6864. }
  6865. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  6866. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  6867. var UPSTREAM_BLOCK_SIZE = 8000;
  6868. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  6869. if (!bytes.length) {
  6870. this.eof = true;
  6871. return;
  6872. }
  6873. var maxDecodeLength = bytes.length + 1 >> 1;
  6874. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  6875. var bufferLength = this.bufferLength;
  6876. var firstDigit = this.firstDigit;
  6877. for (var i = 0, ii = bytes.length; i < ii; i++) {
  6878. var ch = bytes[i],
  6879. digit;
  6880. if (ch >= 0x30 && ch <= 0x39) {
  6881. digit = ch & 0x0f;
  6882. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  6883. digit = (ch & 0x0f) + 9;
  6884. } else if (ch === 0x3e) {
  6885. this.eof = true;
  6886. break;
  6887. } else {
  6888. continue;
  6889. }
  6890. if (firstDigit < 0) {
  6891. firstDigit = digit;
  6892. } else {
  6893. buffer[bufferLength++] = firstDigit << 4 | digit;
  6894. firstDigit = -1;
  6895. }
  6896. }
  6897. if (firstDigit >= 0 && this.eof) {
  6898. buffer[bufferLength++] = firstDigit << 4;
  6899. firstDigit = -1;
  6900. }
  6901. this.firstDigit = firstDigit;
  6902. this.bufferLength = bufferLength;
  6903. };
  6904. return AsciiHexStream;
  6905. }();
  6906. exports.AsciiHexStream = AsciiHexStream;
  6907. var RunLengthStream = function RunLengthStreamClosure() {
  6908. function RunLengthStream(str, maybeLength) {
  6909. this.str = str;
  6910. this.dict = str.dict;
  6911. DecodeStream.call(this, maybeLength);
  6912. }
  6913. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  6914. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  6915. var repeatHeader = this.str.getBytes(2);
  6916. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  6917. this.eof = true;
  6918. return;
  6919. }
  6920. var buffer;
  6921. var bufferLength = this.bufferLength;
  6922. var n = repeatHeader[0];
  6923. if (n < 128) {
  6924. buffer = this.ensureBuffer(bufferLength + n + 1);
  6925. buffer[bufferLength++] = repeatHeader[1];
  6926. if (n > 0) {
  6927. var source = this.str.getBytes(n);
  6928. buffer.set(source, bufferLength);
  6929. bufferLength += n;
  6930. }
  6931. } else {
  6932. n = 257 - n;
  6933. var b = repeatHeader[1];
  6934. buffer = this.ensureBuffer(bufferLength + n + 1);
  6935. for (var i = 0; i < n; i++) {
  6936. buffer[bufferLength++] = b;
  6937. }
  6938. }
  6939. this.bufferLength = bufferLength;
  6940. };
  6941. return RunLengthStream;
  6942. }();
  6943. exports.RunLengthStream = RunLengthStream;
  6944. var LZWStream = function LZWStreamClosure() {
  6945. function LZWStream(str, maybeLength, earlyChange) {
  6946. this.str = str;
  6947. this.dict = str.dict;
  6948. this.cachedData = 0;
  6949. this.bitsCached = 0;
  6950. var maxLzwDictionarySize = 4096;
  6951. var lzwState = {
  6952. earlyChange,
  6953. codeLength: 9,
  6954. nextCode: 258,
  6955. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  6956. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  6957. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  6958. currentSequence: new Uint8Array(maxLzwDictionarySize),
  6959. currentSequenceLength: 0
  6960. };
  6961. for (var i = 0; i < 256; ++i) {
  6962. lzwState.dictionaryValues[i] = i;
  6963. lzwState.dictionaryLengths[i] = 1;
  6964. }
  6965. this.lzwState = lzwState;
  6966. DecodeStream.call(this, maybeLength);
  6967. }
  6968. LZWStream.prototype = Object.create(DecodeStream.prototype);
  6969. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  6970. var bitsCached = this.bitsCached;
  6971. var cachedData = this.cachedData;
  6972. while (bitsCached < n) {
  6973. var c = this.str.getByte();
  6974. if (c === -1) {
  6975. this.eof = true;
  6976. return null;
  6977. }
  6978. cachedData = cachedData << 8 | c;
  6979. bitsCached += 8;
  6980. }
  6981. this.bitsCached = bitsCached -= n;
  6982. this.cachedData = cachedData;
  6983. this.lastCode = null;
  6984. return cachedData >>> bitsCached & (1 << n) - 1;
  6985. };
  6986. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  6987. var blockSize = 512;
  6988. var estimatedDecodedSize = blockSize * 2,
  6989. decodedSizeDelta = blockSize;
  6990. var i, j, q;
  6991. var lzwState = this.lzwState;
  6992. if (!lzwState) {
  6993. return;
  6994. }
  6995. var earlyChange = lzwState.earlyChange;
  6996. var nextCode = lzwState.nextCode;
  6997. var dictionaryValues = lzwState.dictionaryValues;
  6998. var dictionaryLengths = lzwState.dictionaryLengths;
  6999. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  7000. var codeLength = lzwState.codeLength;
  7001. var prevCode = lzwState.prevCode;
  7002. var currentSequence = lzwState.currentSequence;
  7003. var currentSequenceLength = lzwState.currentSequenceLength;
  7004. var decodedLength = 0;
  7005. var currentBufferLength = this.bufferLength;
  7006. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  7007. for (i = 0; i < blockSize; i++) {
  7008. var code = this.readBits(codeLength);
  7009. var hasPrev = currentSequenceLength > 0;
  7010. if (code < 256) {
  7011. currentSequence[0] = code;
  7012. currentSequenceLength = 1;
  7013. } else if (code >= 258) {
  7014. if (code < nextCode) {
  7015. currentSequenceLength = dictionaryLengths[code];
  7016. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  7017. currentSequence[j] = dictionaryValues[q];
  7018. q = dictionaryPrevCodes[q];
  7019. }
  7020. } else {
  7021. currentSequence[currentSequenceLength++] = currentSequence[0];
  7022. }
  7023. } else if (code === 256) {
  7024. codeLength = 9;
  7025. nextCode = 258;
  7026. currentSequenceLength = 0;
  7027. continue;
  7028. } else {
  7029. this.eof = true;
  7030. delete this.lzwState;
  7031. break;
  7032. }
  7033. if (hasPrev) {
  7034. dictionaryPrevCodes[nextCode] = prevCode;
  7035. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  7036. dictionaryValues[nextCode] = currentSequence[0];
  7037. nextCode++;
  7038. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  7039. }
  7040. prevCode = code;
  7041. decodedLength += currentSequenceLength;
  7042. if (estimatedDecodedSize < decodedLength) {
  7043. do {
  7044. estimatedDecodedSize += decodedSizeDelta;
  7045. } while (estimatedDecodedSize < decodedLength);
  7046. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  7047. }
  7048. for (j = 0; j < currentSequenceLength; j++) {
  7049. buffer[currentBufferLength++] = currentSequence[j];
  7050. }
  7051. }
  7052. lzwState.nextCode = nextCode;
  7053. lzwState.codeLength = codeLength;
  7054. lzwState.prevCode = prevCode;
  7055. lzwState.currentSequenceLength = currentSequenceLength;
  7056. this.bufferLength = currentBufferLength;
  7057. };
  7058. return LZWStream;
  7059. }();
  7060. exports.LZWStream = LZWStream;
  7061. var NullStream = function NullStreamClosure() {
  7062. function NullStream() {
  7063. Stream.call(this, new Uint8Array(0));
  7064. }
  7065. NullStream.prototype = Stream.prototype;
  7066. return NullStream;
  7067. }();
  7068. exports.NullStream = NullStream;
  7069. /***/ }),
  7070. /* 13 */
  7071. /***/ (function(module, exports, __w_pdfjs_require__) {
  7072. "use strict";
  7073. Object.defineProperty(exports, "__esModule", {
  7074. value: true
  7075. });
  7076. exports.CCITTFaxStream = void 0;
  7077. var _primitives = __w_pdfjs_require__(5);
  7078. var _ccitt = __w_pdfjs_require__(14);
  7079. var _stream = __w_pdfjs_require__(12);
  7080. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  7081. function CCITTFaxStream(str, maybeLength, params) {
  7082. this.str = str;
  7083. this.dict = str.dict;
  7084. if (!(0, _primitives.isDict)(params)) {
  7085. params = _primitives.Dict.empty;
  7086. }
  7087. const source = {
  7088. next() {
  7089. return str.getByte();
  7090. }
  7091. };
  7092. this.ccittFaxDecoder = new _ccitt.CCITTFaxDecoder(source, {
  7093. K: params.get("K"),
  7094. EndOfLine: params.get("EndOfLine"),
  7095. EncodedByteAlign: params.get("EncodedByteAlign"),
  7096. Columns: params.get("Columns"),
  7097. Rows: params.get("Rows"),
  7098. EndOfBlock: params.get("EndOfBlock"),
  7099. BlackIs1: params.get("BlackIs1")
  7100. });
  7101. _stream.DecodeStream.call(this, maybeLength);
  7102. }
  7103. CCITTFaxStream.prototype = Object.create(_stream.DecodeStream.prototype);
  7104. CCITTFaxStream.prototype.readBlock = function () {
  7105. while (!this.eof) {
  7106. const c = this.ccittFaxDecoder.readNextChar();
  7107. if (c === -1) {
  7108. this.eof = true;
  7109. return;
  7110. }
  7111. this.ensureBuffer(this.bufferLength + 1);
  7112. this.buffer[this.bufferLength++] = c;
  7113. }
  7114. };
  7115. return CCITTFaxStream;
  7116. }();
  7117. exports.CCITTFaxStream = CCITTFaxStream;
  7118. /***/ }),
  7119. /* 14 */
  7120. /***/ (function(module, exports, __w_pdfjs_require__) {
  7121. "use strict";
  7122. Object.defineProperty(exports, "__esModule", {
  7123. value: true
  7124. });
  7125. exports.CCITTFaxDecoder = void 0;
  7126. var _util = __w_pdfjs_require__(2);
  7127. const CCITTFaxDecoder = function CCITTFaxDecoder() {
  7128. const ccittEOL = -2;
  7129. const ccittEOF = -1;
  7130. const twoDimPass = 0;
  7131. const twoDimHoriz = 1;
  7132. const twoDimVert0 = 2;
  7133. const twoDimVertR1 = 3;
  7134. const twoDimVertL1 = 4;
  7135. const twoDimVertR2 = 5;
  7136. const twoDimVertL2 = 6;
  7137. const twoDimVertR3 = 7;
  7138. const twoDimVertL3 = 8;
  7139. const 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]];
  7140. const 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]];
  7141. const 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]];
  7142. const 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]];
  7143. const 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]];
  7144. const 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]];
  7145. function CCITTFaxDecoder(source, options = {}) {
  7146. if (!source || typeof source.next !== "function") {
  7147. throw new Error('CCITTFaxDecoder - invalid "source" parameter.');
  7148. }
  7149. this.source = source;
  7150. this.eof = false;
  7151. this.encoding = options.K || 0;
  7152. this.eoline = options.EndOfLine || false;
  7153. this.byteAlign = options.EncodedByteAlign || false;
  7154. this.columns = options.Columns || 1728;
  7155. this.rows = options.Rows || 0;
  7156. let eoblock = options.EndOfBlock;
  7157. if (eoblock === null || eoblock === undefined) {
  7158. eoblock = true;
  7159. }
  7160. this.eoblock = eoblock;
  7161. this.black = options.BlackIs1 || false;
  7162. this.codingLine = new Uint32Array(this.columns + 1);
  7163. this.refLine = new Uint32Array(this.columns + 2);
  7164. this.codingLine[0] = this.columns;
  7165. this.codingPos = 0;
  7166. this.row = 0;
  7167. this.nextLine2D = this.encoding < 0;
  7168. this.inputBits = 0;
  7169. this.inputBuf = 0;
  7170. this.outputBits = 0;
  7171. this.rowsDone = false;
  7172. let code1;
  7173. while ((code1 = this._lookBits(12)) === 0) {
  7174. this._eatBits(1);
  7175. }
  7176. if (code1 === 1) {
  7177. this._eatBits(12);
  7178. }
  7179. if (this.encoding > 0) {
  7180. this.nextLine2D = !this._lookBits(1);
  7181. this._eatBits(1);
  7182. }
  7183. }
  7184. CCITTFaxDecoder.prototype = {
  7185. readNextChar() {
  7186. if (this.eof) {
  7187. return -1;
  7188. }
  7189. const refLine = this.refLine;
  7190. const codingLine = this.codingLine;
  7191. const columns = this.columns;
  7192. let refPos, blackPixels, bits, i;
  7193. if (this.outputBits === 0) {
  7194. if (this.rowsDone) {
  7195. this.eof = true;
  7196. }
  7197. if (this.eof) {
  7198. return -1;
  7199. }
  7200. this.err = false;
  7201. let code1, code2, code3;
  7202. if (this.nextLine2D) {
  7203. for (i = 0; codingLine[i] < columns; ++i) {
  7204. refLine[i] = codingLine[i];
  7205. }
  7206. refLine[i++] = columns;
  7207. refLine[i] = columns;
  7208. codingLine[0] = 0;
  7209. this.codingPos = 0;
  7210. refPos = 0;
  7211. blackPixels = 0;
  7212. while (codingLine[this.codingPos] < columns) {
  7213. code1 = this._getTwoDimCode();
  7214. switch (code1) {
  7215. case twoDimPass:
  7216. this._addPixels(refLine[refPos + 1], blackPixels);
  7217. if (refLine[refPos + 1] < columns) {
  7218. refPos += 2;
  7219. }
  7220. break;
  7221. case twoDimHoriz:
  7222. code1 = code2 = 0;
  7223. if (blackPixels) {
  7224. do {
  7225. code1 += code3 = this._getBlackCode();
  7226. } while (code3 >= 64);
  7227. do {
  7228. code2 += code3 = this._getWhiteCode();
  7229. } while (code3 >= 64);
  7230. } else {
  7231. do {
  7232. code1 += code3 = this._getWhiteCode();
  7233. } while (code3 >= 64);
  7234. do {
  7235. code2 += code3 = this._getBlackCode();
  7236. } while (code3 >= 64);
  7237. }
  7238. this._addPixels(codingLine[this.codingPos] + code1, blackPixels);
  7239. if (codingLine[this.codingPos] < columns) {
  7240. this._addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  7241. }
  7242. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7243. refPos += 2;
  7244. }
  7245. break;
  7246. case twoDimVertR3:
  7247. this._addPixels(refLine[refPos] + 3, blackPixels);
  7248. blackPixels ^= 1;
  7249. if (codingLine[this.codingPos] < columns) {
  7250. ++refPos;
  7251. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7252. refPos += 2;
  7253. }
  7254. }
  7255. break;
  7256. case twoDimVertR2:
  7257. this._addPixels(refLine[refPos] + 2, blackPixels);
  7258. blackPixels ^= 1;
  7259. if (codingLine[this.codingPos] < columns) {
  7260. ++refPos;
  7261. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7262. refPos += 2;
  7263. }
  7264. }
  7265. break;
  7266. case twoDimVertR1:
  7267. this._addPixels(refLine[refPos] + 1, blackPixels);
  7268. blackPixels ^= 1;
  7269. if (codingLine[this.codingPos] < columns) {
  7270. ++refPos;
  7271. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7272. refPos += 2;
  7273. }
  7274. }
  7275. break;
  7276. case twoDimVert0:
  7277. this._addPixels(refLine[refPos], blackPixels);
  7278. blackPixels ^= 1;
  7279. if (codingLine[this.codingPos] < columns) {
  7280. ++refPos;
  7281. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7282. refPos += 2;
  7283. }
  7284. }
  7285. break;
  7286. case twoDimVertL3:
  7287. this._addPixelsNeg(refLine[refPos] - 3, blackPixels);
  7288. blackPixels ^= 1;
  7289. if (codingLine[this.codingPos] < columns) {
  7290. if (refPos > 0) {
  7291. --refPos;
  7292. } else {
  7293. ++refPos;
  7294. }
  7295. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7296. refPos += 2;
  7297. }
  7298. }
  7299. break;
  7300. case twoDimVertL2:
  7301. this._addPixelsNeg(refLine[refPos] - 2, blackPixels);
  7302. blackPixels ^= 1;
  7303. if (codingLine[this.codingPos] < columns) {
  7304. if (refPos > 0) {
  7305. --refPos;
  7306. } else {
  7307. ++refPos;
  7308. }
  7309. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7310. refPos += 2;
  7311. }
  7312. }
  7313. break;
  7314. case twoDimVertL1:
  7315. this._addPixelsNeg(refLine[refPos] - 1, blackPixels);
  7316. blackPixels ^= 1;
  7317. if (codingLine[this.codingPos] < columns) {
  7318. if (refPos > 0) {
  7319. --refPos;
  7320. } else {
  7321. ++refPos;
  7322. }
  7323. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  7324. refPos += 2;
  7325. }
  7326. }
  7327. break;
  7328. case ccittEOF:
  7329. this._addPixels(columns, 0);
  7330. this.eof = true;
  7331. break;
  7332. default:
  7333. (0, _util.info)("bad 2d code");
  7334. this._addPixels(columns, 0);
  7335. this.err = true;
  7336. }
  7337. }
  7338. } else {
  7339. codingLine[0] = 0;
  7340. this.codingPos = 0;
  7341. blackPixels = 0;
  7342. while (codingLine[this.codingPos] < columns) {
  7343. code1 = 0;
  7344. if (blackPixels) {
  7345. do {
  7346. code1 += code3 = this._getBlackCode();
  7347. } while (code3 >= 64);
  7348. } else {
  7349. do {
  7350. code1 += code3 = this._getWhiteCode();
  7351. } while (code3 >= 64);
  7352. }
  7353. this._addPixels(codingLine[this.codingPos] + code1, blackPixels);
  7354. blackPixels ^= 1;
  7355. }
  7356. }
  7357. let gotEOL = false;
  7358. if (this.byteAlign) {
  7359. this.inputBits &= ~7;
  7360. }
  7361. if (!this.eoblock && this.row === this.rows - 1) {
  7362. this.rowsDone = true;
  7363. } else {
  7364. code1 = this._lookBits(12);
  7365. if (this.eoline) {
  7366. while (code1 !== ccittEOF && code1 !== 1) {
  7367. this._eatBits(1);
  7368. code1 = this._lookBits(12);
  7369. }
  7370. } else {
  7371. while (code1 === 0) {
  7372. this._eatBits(1);
  7373. code1 = this._lookBits(12);
  7374. }
  7375. }
  7376. if (code1 === 1) {
  7377. this._eatBits(12);
  7378. gotEOL = true;
  7379. } else if (code1 === ccittEOF) {
  7380. this.eof = true;
  7381. }
  7382. }
  7383. if (!this.eof && this.encoding > 0 && !this.rowsDone) {
  7384. this.nextLine2D = !this._lookBits(1);
  7385. this._eatBits(1);
  7386. }
  7387. if (this.eoblock && gotEOL && this.byteAlign) {
  7388. code1 = this._lookBits(12);
  7389. if (code1 === 1) {
  7390. this._eatBits(12);
  7391. if (this.encoding > 0) {
  7392. this._lookBits(1);
  7393. this._eatBits(1);
  7394. }
  7395. if (this.encoding >= 0) {
  7396. for (i = 0; i < 4; ++i) {
  7397. code1 = this._lookBits(12);
  7398. if (code1 !== 1) {
  7399. (0, _util.info)("bad rtc code: " + code1);
  7400. }
  7401. this._eatBits(12);
  7402. if (this.encoding > 0) {
  7403. this._lookBits(1);
  7404. this._eatBits(1);
  7405. }
  7406. }
  7407. }
  7408. this.eof = true;
  7409. }
  7410. } else if (this.err && this.eoline) {
  7411. while (true) {
  7412. code1 = this._lookBits(13);
  7413. if (code1 === ccittEOF) {
  7414. this.eof = true;
  7415. return -1;
  7416. }
  7417. if (code1 >> 1 === 1) {
  7418. break;
  7419. }
  7420. this._eatBits(1);
  7421. }
  7422. this._eatBits(12);
  7423. if (this.encoding > 0) {
  7424. this._eatBits(1);
  7425. this.nextLine2D = !(code1 & 1);
  7426. }
  7427. }
  7428. if (codingLine[0] > 0) {
  7429. this.outputBits = codingLine[this.codingPos = 0];
  7430. } else {
  7431. this.outputBits = codingLine[this.codingPos = 1];
  7432. }
  7433. this.row++;
  7434. }
  7435. let c;
  7436. if (this.outputBits >= 8) {
  7437. c = this.codingPos & 1 ? 0 : 0xff;
  7438. this.outputBits -= 8;
  7439. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  7440. this.codingPos++;
  7441. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  7442. }
  7443. } else {
  7444. bits = 8;
  7445. c = 0;
  7446. do {
  7447. if (this.outputBits > bits) {
  7448. c <<= bits;
  7449. if (!(this.codingPos & 1)) {
  7450. c |= 0xff >> 8 - bits;
  7451. }
  7452. this.outputBits -= bits;
  7453. bits = 0;
  7454. } else {
  7455. c <<= this.outputBits;
  7456. if (!(this.codingPos & 1)) {
  7457. c |= 0xff >> 8 - this.outputBits;
  7458. }
  7459. bits -= this.outputBits;
  7460. this.outputBits = 0;
  7461. if (codingLine[this.codingPos] < columns) {
  7462. this.codingPos++;
  7463. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  7464. } else if (bits > 0) {
  7465. c <<= bits;
  7466. bits = 0;
  7467. }
  7468. }
  7469. } while (bits);
  7470. }
  7471. if (this.black) {
  7472. c ^= 0xff;
  7473. }
  7474. return c;
  7475. },
  7476. _addPixels(a1, blackPixels) {
  7477. const codingLine = this.codingLine;
  7478. let codingPos = this.codingPos;
  7479. if (a1 > codingLine[codingPos]) {
  7480. if (a1 > this.columns) {
  7481. (0, _util.info)("row is wrong length");
  7482. this.err = true;
  7483. a1 = this.columns;
  7484. }
  7485. if (codingPos & 1 ^ blackPixels) {
  7486. ++codingPos;
  7487. }
  7488. codingLine[codingPos] = a1;
  7489. }
  7490. this.codingPos = codingPos;
  7491. },
  7492. _addPixelsNeg(a1, blackPixels) {
  7493. const codingLine = this.codingLine;
  7494. let codingPos = this.codingPos;
  7495. if (a1 > codingLine[codingPos]) {
  7496. if (a1 > this.columns) {
  7497. (0, _util.info)("row is wrong length");
  7498. this.err = true;
  7499. a1 = this.columns;
  7500. }
  7501. if (codingPos & 1 ^ blackPixels) {
  7502. ++codingPos;
  7503. }
  7504. codingLine[codingPos] = a1;
  7505. } else if (a1 < codingLine[codingPos]) {
  7506. if (a1 < 0) {
  7507. (0, _util.info)("invalid code");
  7508. this.err = true;
  7509. a1 = 0;
  7510. }
  7511. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  7512. --codingPos;
  7513. }
  7514. codingLine[codingPos] = a1;
  7515. }
  7516. this.codingPos = codingPos;
  7517. },
  7518. _findTableCode(start, end, table, limit) {
  7519. const limitValue = limit || 0;
  7520. for (let i = start; i <= end; ++i) {
  7521. let code = this._lookBits(i);
  7522. if (code === ccittEOF) {
  7523. return [true, 1, false];
  7524. }
  7525. if (i < end) {
  7526. code <<= end - i;
  7527. }
  7528. if (!limitValue || code >= limitValue) {
  7529. const p = table[code - limitValue];
  7530. if (p[0] === i) {
  7531. this._eatBits(i);
  7532. return [true, p[1], true];
  7533. }
  7534. }
  7535. }
  7536. return [false, 0, false];
  7537. },
  7538. _getTwoDimCode() {
  7539. let code = 0;
  7540. let p;
  7541. if (this.eoblock) {
  7542. code = this._lookBits(7);
  7543. p = twoDimTable[code];
  7544. if (p && p[0] > 0) {
  7545. this._eatBits(p[0]);
  7546. return p[1];
  7547. }
  7548. } else {
  7549. const result = this._findTableCode(1, 7, twoDimTable);
  7550. if (result[0] && result[2]) {
  7551. return result[1];
  7552. }
  7553. }
  7554. (0, _util.info)("Bad two dim code");
  7555. return ccittEOF;
  7556. },
  7557. _getWhiteCode() {
  7558. let code = 0;
  7559. let p;
  7560. if (this.eoblock) {
  7561. code = this._lookBits(12);
  7562. if (code === ccittEOF) {
  7563. return 1;
  7564. }
  7565. if (code >> 5 === 0) {
  7566. p = whiteTable1[code];
  7567. } else {
  7568. p = whiteTable2[code >> 3];
  7569. }
  7570. if (p[0] > 0) {
  7571. this._eatBits(p[0]);
  7572. return p[1];
  7573. }
  7574. } else {
  7575. let result = this._findTableCode(1, 9, whiteTable2);
  7576. if (result[0]) {
  7577. return result[1];
  7578. }
  7579. result = this._findTableCode(11, 12, whiteTable1);
  7580. if (result[0]) {
  7581. return result[1];
  7582. }
  7583. }
  7584. (0, _util.info)("bad white code");
  7585. this._eatBits(1);
  7586. return 1;
  7587. },
  7588. _getBlackCode() {
  7589. let code, p;
  7590. if (this.eoblock) {
  7591. code = this._lookBits(13);
  7592. if (code === ccittEOF) {
  7593. return 1;
  7594. }
  7595. if (code >> 7 === 0) {
  7596. p = blackTable1[code];
  7597. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  7598. p = blackTable2[(code >> 1) - 64];
  7599. } else {
  7600. p = blackTable3[code >> 7];
  7601. }
  7602. if (p[0] > 0) {
  7603. this._eatBits(p[0]);
  7604. return p[1];
  7605. }
  7606. } else {
  7607. let result = this._findTableCode(2, 6, blackTable3);
  7608. if (result[0]) {
  7609. return result[1];
  7610. }
  7611. result = this._findTableCode(7, 12, blackTable2, 64);
  7612. if (result[0]) {
  7613. return result[1];
  7614. }
  7615. result = this._findTableCode(10, 13, blackTable1);
  7616. if (result[0]) {
  7617. return result[1];
  7618. }
  7619. }
  7620. (0, _util.info)("bad black code");
  7621. this._eatBits(1);
  7622. return 1;
  7623. },
  7624. _lookBits(n) {
  7625. let c;
  7626. while (this.inputBits < n) {
  7627. if ((c = this.source.next()) === -1) {
  7628. if (this.inputBits === 0) {
  7629. return ccittEOF;
  7630. }
  7631. return this.inputBuf << n - this.inputBits & 0xffff >> 16 - n;
  7632. }
  7633. this.inputBuf = this.inputBuf << 8 | c;
  7634. this.inputBits += 8;
  7635. }
  7636. return this.inputBuf >> this.inputBits - n & 0xffff >> 16 - n;
  7637. },
  7638. _eatBits(n) {
  7639. if ((this.inputBits -= n) < 0) {
  7640. this.inputBits = 0;
  7641. }
  7642. }
  7643. };
  7644. return CCITTFaxDecoder;
  7645. }();
  7646. exports.CCITTFaxDecoder = CCITTFaxDecoder;
  7647. /***/ }),
  7648. /* 15 */
  7649. /***/ (function(module, exports, __w_pdfjs_require__) {
  7650. "use strict";
  7651. Object.defineProperty(exports, "__esModule", {
  7652. value: true
  7653. });
  7654. exports.Jbig2Stream = void 0;
  7655. var _primitives = __w_pdfjs_require__(5);
  7656. var _stream = __w_pdfjs_require__(12);
  7657. var _jbig = __w_pdfjs_require__(16);
  7658. var _util = __w_pdfjs_require__(2);
  7659. const Jbig2Stream = function Jbig2StreamClosure() {
  7660. function Jbig2Stream(stream, maybeLength, dict, params) {
  7661. this.stream = stream;
  7662. this.maybeLength = maybeLength;
  7663. this.dict = dict;
  7664. this.params = params;
  7665. _stream.DecodeStream.call(this, maybeLength);
  7666. }
  7667. Jbig2Stream.prototype = Object.create(_stream.DecodeStream.prototype);
  7668. Object.defineProperty(Jbig2Stream.prototype, "bytes", {
  7669. get() {
  7670. return (0, _util.shadow)(this, "bytes", this.stream.getBytes(this.maybeLength));
  7671. },
  7672. configurable: true
  7673. });
  7674. Jbig2Stream.prototype.ensureBuffer = function (requested) {};
  7675. Jbig2Stream.prototype.readBlock = function () {
  7676. if (this.eof) {
  7677. return;
  7678. }
  7679. const jbig2Image = new _jbig.Jbig2Image();
  7680. const chunks = [];
  7681. if ((0, _primitives.isDict)(this.params)) {
  7682. const globalsStream = this.params.get("JBIG2Globals");
  7683. if ((0, _primitives.isStream)(globalsStream)) {
  7684. const globals = globalsStream.getBytes();
  7685. chunks.push({
  7686. data: globals,
  7687. start: 0,
  7688. end: globals.length
  7689. });
  7690. }
  7691. }
  7692. chunks.push({
  7693. data: this.bytes,
  7694. start: 0,
  7695. end: this.bytes.length
  7696. });
  7697. const data = jbig2Image.parseChunks(chunks);
  7698. const dataLength = data.length;
  7699. for (let i = 0; i < dataLength; i++) {
  7700. data[i] ^= 0xff;
  7701. }
  7702. this.buffer = data;
  7703. this.bufferLength = dataLength;
  7704. this.eof = true;
  7705. };
  7706. return Jbig2Stream;
  7707. }();
  7708. exports.Jbig2Stream = Jbig2Stream;
  7709. /***/ }),
  7710. /* 16 */
  7711. /***/ (function(module, exports, __w_pdfjs_require__) {
  7712. "use strict";
  7713. Object.defineProperty(exports, "__esModule", {
  7714. value: true
  7715. });
  7716. exports.Jbig2Image = void 0;
  7717. var _util = __w_pdfjs_require__(2);
  7718. var _core_utils = __w_pdfjs_require__(8);
  7719. var _arithmetic_decoder = __w_pdfjs_require__(17);
  7720. var _ccitt = __w_pdfjs_require__(14);
  7721. class Jbig2Error extends _util.BaseException {
  7722. constructor(msg) {
  7723. super(`JBIG2 error: ${msg}`);
  7724. }
  7725. }
  7726. var Jbig2Image = function Jbig2ImageClosure() {
  7727. function ContextCache() {}
  7728. ContextCache.prototype = {
  7729. getContexts(id) {
  7730. if (id in this) {
  7731. return this[id];
  7732. }
  7733. return this[id] = new Int8Array(1 << 16);
  7734. }
  7735. };
  7736. function DecodingContext(data, start, end) {
  7737. this.data = data;
  7738. this.start = start;
  7739. this.end = end;
  7740. }
  7741. DecodingContext.prototype = {
  7742. get decoder() {
  7743. var decoder = new _arithmetic_decoder.ArithmeticDecoder(this.data, this.start, this.end);
  7744. return (0, _util.shadow)(this, "decoder", decoder);
  7745. },
  7746. get contextCache() {
  7747. var cache = new ContextCache();
  7748. return (0, _util.shadow)(this, "contextCache", cache);
  7749. }
  7750. };
  7751. function decodeInteger(contextCache, procedure, decoder) {
  7752. var contexts = contextCache.getContexts(procedure);
  7753. var prev = 1;
  7754. function readBits(length) {
  7755. var v = 0;
  7756. for (var i = 0; i < length; i++) {
  7757. var bit = decoder.readBit(contexts, prev);
  7758. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  7759. v = v << 1 | bit;
  7760. }
  7761. return v >>> 0;
  7762. }
  7763. var sign = readBits(1);
  7764. 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);
  7765. if (sign === 0) {
  7766. return value;
  7767. } else if (value > 0) {
  7768. return -value;
  7769. }
  7770. return null;
  7771. }
  7772. function decodeIAID(contextCache, decoder, codeLength) {
  7773. var contexts = contextCache.getContexts("IAID");
  7774. var prev = 1;
  7775. for (var i = 0; i < codeLength; i++) {
  7776. var bit = decoder.readBit(contexts, prev);
  7777. prev = prev << 1 | bit;
  7778. }
  7779. if (codeLength < 31) {
  7780. return prev & (1 << codeLength) - 1;
  7781. }
  7782. return prev & 0x7fffffff;
  7783. }
  7784. 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"];
  7785. var CodingTemplates = [[{
  7786. x: -1,
  7787. y: -2
  7788. }, {
  7789. x: 0,
  7790. y: -2
  7791. }, {
  7792. x: 1,
  7793. y: -2
  7794. }, {
  7795. x: -2,
  7796. y: -1
  7797. }, {
  7798. x: -1,
  7799. y: -1
  7800. }, {
  7801. x: 0,
  7802. y: -1
  7803. }, {
  7804. x: 1,
  7805. y: -1
  7806. }, {
  7807. x: 2,
  7808. y: -1
  7809. }, {
  7810. x: -4,
  7811. y: 0
  7812. }, {
  7813. x: -3,
  7814. y: 0
  7815. }, {
  7816. x: -2,
  7817. y: 0
  7818. }, {
  7819. x: -1,
  7820. y: 0
  7821. }], [{
  7822. x: -1,
  7823. y: -2
  7824. }, {
  7825. x: 0,
  7826. y: -2
  7827. }, {
  7828. x: 1,
  7829. y: -2
  7830. }, {
  7831. x: 2,
  7832. y: -2
  7833. }, {
  7834. x: -2,
  7835. y: -1
  7836. }, {
  7837. x: -1,
  7838. y: -1
  7839. }, {
  7840. x: 0,
  7841. y: -1
  7842. }, {
  7843. x: 1,
  7844. y: -1
  7845. }, {
  7846. x: 2,
  7847. y: -1
  7848. }, {
  7849. x: -3,
  7850. y: 0
  7851. }, {
  7852. x: -2,
  7853. y: 0
  7854. }, {
  7855. x: -1,
  7856. y: 0
  7857. }], [{
  7858. x: -1,
  7859. y: -2
  7860. }, {
  7861. x: 0,
  7862. y: -2
  7863. }, {
  7864. x: 1,
  7865. y: -2
  7866. }, {
  7867. x: -2,
  7868. y: -1
  7869. }, {
  7870. x: -1,
  7871. y: -1
  7872. }, {
  7873. x: 0,
  7874. y: -1
  7875. }, {
  7876. x: 1,
  7877. y: -1
  7878. }, {
  7879. x: -2,
  7880. y: 0
  7881. }, {
  7882. x: -1,
  7883. y: 0
  7884. }], [{
  7885. x: -3,
  7886. y: -1
  7887. }, {
  7888. x: -2,
  7889. y: -1
  7890. }, {
  7891. x: -1,
  7892. y: -1
  7893. }, {
  7894. x: 0,
  7895. y: -1
  7896. }, {
  7897. x: 1,
  7898. y: -1
  7899. }, {
  7900. x: -4,
  7901. y: 0
  7902. }, {
  7903. x: -3,
  7904. y: 0
  7905. }, {
  7906. x: -2,
  7907. y: 0
  7908. }, {
  7909. x: -1,
  7910. y: 0
  7911. }]];
  7912. var RefinementTemplates = [{
  7913. coding: [{
  7914. x: 0,
  7915. y: -1
  7916. }, {
  7917. x: 1,
  7918. y: -1
  7919. }, {
  7920. x: -1,
  7921. y: 0
  7922. }],
  7923. reference: [{
  7924. x: 0,
  7925. y: -1
  7926. }, {
  7927. x: 1,
  7928. y: -1
  7929. }, {
  7930. x: -1,
  7931. y: 0
  7932. }, {
  7933. x: 0,
  7934. y: 0
  7935. }, {
  7936. x: 1,
  7937. y: 0
  7938. }, {
  7939. x: -1,
  7940. y: 1
  7941. }, {
  7942. x: 0,
  7943. y: 1
  7944. }, {
  7945. x: 1,
  7946. y: 1
  7947. }]
  7948. }, {
  7949. coding: [{
  7950. x: -1,
  7951. y: -1
  7952. }, {
  7953. x: 0,
  7954. y: -1
  7955. }, {
  7956. x: 1,
  7957. y: -1
  7958. }, {
  7959. x: -1,
  7960. y: 0
  7961. }],
  7962. reference: [{
  7963. x: 0,
  7964. y: -1
  7965. }, {
  7966. x: -1,
  7967. y: 0
  7968. }, {
  7969. x: 0,
  7970. y: 0
  7971. }, {
  7972. x: 1,
  7973. y: 0
  7974. }, {
  7975. x: 0,
  7976. y: 1
  7977. }, {
  7978. x: 1,
  7979. y: 1
  7980. }]
  7981. }];
  7982. var ReusedContexts = [0x9b25, 0x0795, 0x00e5, 0x0195];
  7983. var RefinementReusedContexts = [0x0020, 0x0008];
  7984. function decodeBitmapTemplate0(width, height, decodingContext) {
  7985. var decoder = decodingContext.decoder;
  7986. var contexts = decodingContext.contextCache.getContexts("GB");
  7987. var contextLabel,
  7988. i,
  7989. j,
  7990. pixel,
  7991. row,
  7992. row1,
  7993. row2,
  7994. bitmap = [];
  7995. var OLD_PIXEL_MASK = 0x7bf7;
  7996. for (i = 0; i < height; i++) {
  7997. row = bitmap[i] = new Uint8Array(width);
  7998. row1 = i < 1 ? row : bitmap[i - 1];
  7999. row2 = i < 2 ? row : bitmap[i - 2];
  8000. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  8001. for (j = 0; j < width; j++) {
  8002. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  8003. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  8004. }
  8005. }
  8006. return bitmap;
  8007. }
  8008. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  8009. if (mmr) {
  8010. const input = new Reader(decodingContext.data, decodingContext.start, decodingContext.end);
  8011. return decodeMMRBitmap(input, width, height, false);
  8012. }
  8013. 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) {
  8014. return decodeBitmapTemplate0(width, height, decodingContext);
  8015. }
  8016. var useskip = !!skip;
  8017. var template = CodingTemplates[templateIndex].concat(at);
  8018. template.sort(function (a, b) {
  8019. return a.y - b.y || a.x - b.x;
  8020. });
  8021. var templateLength = template.length;
  8022. var templateX = new Int8Array(templateLength);
  8023. var templateY = new Int8Array(templateLength);
  8024. var changingTemplateEntries = [];
  8025. var reuseMask = 0,
  8026. minX = 0,
  8027. maxX = 0,
  8028. minY = 0;
  8029. var c, k;
  8030. for (k = 0; k < templateLength; k++) {
  8031. templateX[k] = template[k].x;
  8032. templateY[k] = template[k].y;
  8033. minX = Math.min(minX, template[k].x);
  8034. maxX = Math.max(maxX, template[k].x);
  8035. minY = Math.min(minY, template[k].y);
  8036. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  8037. reuseMask |= 1 << templateLength - 1 - k;
  8038. } else {
  8039. changingTemplateEntries.push(k);
  8040. }
  8041. }
  8042. var changingEntriesLength = changingTemplateEntries.length;
  8043. var changingTemplateX = new Int8Array(changingEntriesLength);
  8044. var changingTemplateY = new Int8Array(changingEntriesLength);
  8045. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  8046. for (c = 0; c < changingEntriesLength; c++) {
  8047. k = changingTemplateEntries[c];
  8048. changingTemplateX[c] = template[k].x;
  8049. changingTemplateY[c] = template[k].y;
  8050. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  8051. }
  8052. var sbb_left = -minX;
  8053. var sbb_top = -minY;
  8054. var sbb_right = width - maxX;
  8055. var pseudoPixelContext = ReusedContexts[templateIndex];
  8056. var row = new Uint8Array(width);
  8057. var bitmap = [];
  8058. var decoder = decodingContext.decoder;
  8059. var contexts = decodingContext.contextCache.getContexts("GB");
  8060. var ltp = 0,
  8061. j,
  8062. i0,
  8063. j0,
  8064. contextLabel = 0,
  8065. bit,
  8066. shift;
  8067. for (var i = 0; i < height; i++) {
  8068. if (prediction) {
  8069. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  8070. ltp ^= sltp;
  8071. if (ltp) {
  8072. bitmap.push(row);
  8073. continue;
  8074. }
  8075. }
  8076. row = new Uint8Array(row);
  8077. bitmap.push(row);
  8078. for (j = 0; j < width; j++) {
  8079. if (useskip && skip[i][j]) {
  8080. row[j] = 0;
  8081. continue;
  8082. }
  8083. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  8084. contextLabel = contextLabel << 1 & reuseMask;
  8085. for (k = 0; k < changingEntriesLength; k++) {
  8086. i0 = i + changingTemplateY[k];
  8087. j0 = j + changingTemplateX[k];
  8088. bit = bitmap[i0][j0];
  8089. if (bit) {
  8090. bit = changingTemplateBit[k];
  8091. contextLabel |= bit;
  8092. }
  8093. }
  8094. } else {
  8095. contextLabel = 0;
  8096. shift = templateLength - 1;
  8097. for (k = 0; k < templateLength; k++, shift--) {
  8098. j0 = j + templateX[k];
  8099. if (j0 >= 0 && j0 < width) {
  8100. i0 = i + templateY[k];
  8101. if (i0 >= 0) {
  8102. bit = bitmap[i0][j0];
  8103. if (bit) {
  8104. contextLabel |= bit << shift;
  8105. }
  8106. }
  8107. }
  8108. }
  8109. }
  8110. var pixel = decoder.readBit(contexts, contextLabel);
  8111. row[j] = pixel;
  8112. }
  8113. }
  8114. return bitmap;
  8115. }
  8116. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  8117. var codingTemplate = RefinementTemplates[templateIndex].coding;
  8118. if (templateIndex === 0) {
  8119. codingTemplate = codingTemplate.concat([at[0]]);
  8120. }
  8121. var codingTemplateLength = codingTemplate.length;
  8122. var codingTemplateX = new Int32Array(codingTemplateLength);
  8123. var codingTemplateY = new Int32Array(codingTemplateLength);
  8124. var k;
  8125. for (k = 0; k < codingTemplateLength; k++) {
  8126. codingTemplateX[k] = codingTemplate[k].x;
  8127. codingTemplateY[k] = codingTemplate[k].y;
  8128. }
  8129. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  8130. if (templateIndex === 0) {
  8131. referenceTemplate = referenceTemplate.concat([at[1]]);
  8132. }
  8133. var referenceTemplateLength = referenceTemplate.length;
  8134. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  8135. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  8136. for (k = 0; k < referenceTemplateLength; k++) {
  8137. referenceTemplateX[k] = referenceTemplate[k].x;
  8138. referenceTemplateY[k] = referenceTemplate[k].y;
  8139. }
  8140. var referenceWidth = referenceBitmap[0].length;
  8141. var referenceHeight = referenceBitmap.length;
  8142. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  8143. var bitmap = [];
  8144. var decoder = decodingContext.decoder;
  8145. var contexts = decodingContext.contextCache.getContexts("GR");
  8146. var ltp = 0;
  8147. for (var i = 0; i < height; i++) {
  8148. if (prediction) {
  8149. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  8150. ltp ^= sltp;
  8151. if (ltp) {
  8152. throw new Jbig2Error("prediction is not supported");
  8153. }
  8154. }
  8155. var row = new Uint8Array(width);
  8156. bitmap.push(row);
  8157. for (var j = 0; j < width; j++) {
  8158. var i0, j0;
  8159. var contextLabel = 0;
  8160. for (k = 0; k < codingTemplateLength; k++) {
  8161. i0 = i + codingTemplateY[k];
  8162. j0 = j + codingTemplateX[k];
  8163. if (i0 < 0 || j0 < 0 || j0 >= width) {
  8164. contextLabel <<= 1;
  8165. } else {
  8166. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  8167. }
  8168. }
  8169. for (k = 0; k < referenceTemplateLength; k++) {
  8170. i0 = i + referenceTemplateY[k] - offsetY;
  8171. j0 = j + referenceTemplateX[k] - offsetX;
  8172. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  8173. contextLabel <<= 1;
  8174. } else {
  8175. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  8176. }
  8177. }
  8178. var pixel = decoder.readBit(contexts, contextLabel);
  8179. row[j] = pixel;
  8180. }
  8181. }
  8182. return bitmap;
  8183. }
  8184. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext, huffmanInput) {
  8185. if (huffman && refinement) {
  8186. throw new Jbig2Error("symbol refinement with Huffman is not supported");
  8187. }
  8188. var newSymbols = [];
  8189. var currentHeight = 0;
  8190. var symbolCodeLength = (0, _core_utils.log2)(symbols.length + numberOfNewSymbols);
  8191. var decoder = decodingContext.decoder;
  8192. var contextCache = decodingContext.contextCache;
  8193. let tableB1, symbolWidths;
  8194. if (huffman) {
  8195. tableB1 = getStandardTable(1);
  8196. symbolWidths = [];
  8197. symbolCodeLength = Math.max(symbolCodeLength, 1);
  8198. }
  8199. while (newSymbols.length < numberOfNewSymbols) {
  8200. var deltaHeight = huffman ? huffmanTables.tableDeltaHeight.decode(huffmanInput) : decodeInteger(contextCache, "IADH", decoder);
  8201. currentHeight += deltaHeight;
  8202. let currentWidth = 0,
  8203. totalWidth = 0;
  8204. const firstSymbol = huffman ? symbolWidths.length : 0;
  8205. while (true) {
  8206. var deltaWidth = huffman ? huffmanTables.tableDeltaWidth.decode(huffmanInput) : decodeInteger(contextCache, "IADW", decoder);
  8207. if (deltaWidth === null) {
  8208. break;
  8209. }
  8210. currentWidth += deltaWidth;
  8211. totalWidth += currentWidth;
  8212. var bitmap;
  8213. if (refinement) {
  8214. var numberOfInstances = decodeInteger(contextCache, "IAAI", decoder);
  8215. if (numberOfInstances > 1) {
  8216. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext, 0, huffmanInput);
  8217. } else {
  8218. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  8219. var rdx = decodeInteger(contextCache, "IARDX", decoder);
  8220. var rdy = decodeInteger(contextCache, "IARDY", decoder);
  8221. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  8222. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  8223. }
  8224. newSymbols.push(bitmap);
  8225. } else if (huffman) {
  8226. symbolWidths.push(currentWidth);
  8227. } else {
  8228. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  8229. newSymbols.push(bitmap);
  8230. }
  8231. }
  8232. if (huffman && !refinement) {
  8233. const bitmapSize = huffmanTables.tableBitmapSize.decode(huffmanInput);
  8234. huffmanInput.byteAlign();
  8235. let collectiveBitmap;
  8236. if (bitmapSize === 0) {
  8237. collectiveBitmap = readUncompressedBitmap(huffmanInput, totalWidth, currentHeight);
  8238. } else {
  8239. const originalEnd = huffmanInput.end;
  8240. const bitmapEnd = huffmanInput.position + bitmapSize;
  8241. huffmanInput.end = bitmapEnd;
  8242. collectiveBitmap = decodeMMRBitmap(huffmanInput, totalWidth, currentHeight, false);
  8243. huffmanInput.end = originalEnd;
  8244. huffmanInput.position = bitmapEnd;
  8245. }
  8246. const numberOfSymbolsDecoded = symbolWidths.length;
  8247. if (firstSymbol === numberOfSymbolsDecoded - 1) {
  8248. newSymbols.push(collectiveBitmap);
  8249. } else {
  8250. let i,
  8251. y,
  8252. xMin = 0,
  8253. xMax,
  8254. bitmapWidth,
  8255. symbolBitmap;
  8256. for (i = firstSymbol; i < numberOfSymbolsDecoded; i++) {
  8257. bitmapWidth = symbolWidths[i];
  8258. xMax = xMin + bitmapWidth;
  8259. symbolBitmap = [];
  8260. for (y = 0; y < currentHeight; y++) {
  8261. symbolBitmap.push(collectiveBitmap[y].subarray(xMin, xMax));
  8262. }
  8263. newSymbols.push(symbolBitmap);
  8264. xMin = xMax;
  8265. }
  8266. }
  8267. }
  8268. }
  8269. var exportedSymbols = [];
  8270. var flags = [],
  8271. currentFlag = false;
  8272. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  8273. while (flags.length < totalSymbolsLength) {
  8274. var runLength = huffman ? tableB1.decode(huffmanInput) : decodeInteger(contextCache, "IAEX", decoder);
  8275. while (runLength--) {
  8276. flags.push(currentFlag);
  8277. }
  8278. currentFlag = !currentFlag;
  8279. }
  8280. for (var i = 0, ii = symbols.length; i < ii; i++) {
  8281. if (flags[i]) {
  8282. exportedSymbols.push(symbols[i]);
  8283. }
  8284. }
  8285. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  8286. if (flags[i]) {
  8287. exportedSymbols.push(newSymbols[j]);
  8288. }
  8289. }
  8290. return exportedSymbols;
  8291. }
  8292. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext, logStripSize, huffmanInput) {
  8293. if (huffman && refinement) {
  8294. throw new Jbig2Error("refinement with Huffman is not supported");
  8295. }
  8296. var bitmap = [];
  8297. var i, row;
  8298. for (i = 0; i < height; i++) {
  8299. row = new Uint8Array(width);
  8300. if (defaultPixelValue) {
  8301. for (var j = 0; j < width; j++) {
  8302. row[j] = defaultPixelValue;
  8303. }
  8304. }
  8305. bitmap.push(row);
  8306. }
  8307. var decoder = decodingContext.decoder;
  8308. var contextCache = decodingContext.contextCache;
  8309. var stripT = huffman ? -huffmanTables.tableDeltaT.decode(huffmanInput) : -decodeInteger(contextCache, "IADT", decoder);
  8310. var firstS = 0;
  8311. i = 0;
  8312. while (i < numberOfSymbolInstances) {
  8313. var deltaT = huffman ? huffmanTables.tableDeltaT.decode(huffmanInput) : decodeInteger(contextCache, "IADT", decoder);
  8314. stripT += deltaT;
  8315. var deltaFirstS = huffman ? huffmanTables.tableFirstS.decode(huffmanInput) : decodeInteger(contextCache, "IAFS", decoder);
  8316. firstS += deltaFirstS;
  8317. var currentS = firstS;
  8318. do {
  8319. let currentT = 0;
  8320. if (stripSize > 1) {
  8321. currentT = huffman ? huffmanInput.readBits(logStripSize) : decodeInteger(contextCache, "IAIT", decoder);
  8322. }
  8323. var t = stripSize * stripT + currentT;
  8324. var symbolId = huffman ? huffmanTables.symbolIDTable.decode(huffmanInput) : decodeIAID(contextCache, decoder, symbolCodeLength);
  8325. var applyRefinement = refinement && (huffman ? huffmanInput.readBit() : decodeInteger(contextCache, "IARI", decoder));
  8326. var symbolBitmap = inputSymbols[symbolId];
  8327. var symbolWidth = symbolBitmap[0].length;
  8328. var symbolHeight = symbolBitmap.length;
  8329. if (applyRefinement) {
  8330. var rdw = decodeInteger(contextCache, "IARDW", decoder);
  8331. var rdh = decodeInteger(contextCache, "IARDH", decoder);
  8332. var rdx = decodeInteger(contextCache, "IARDX", decoder);
  8333. var rdy = decodeInteger(contextCache, "IARDY", decoder);
  8334. symbolWidth += rdw;
  8335. symbolHeight += rdh;
  8336. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  8337. }
  8338. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight - 1);
  8339. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth - 1 : 0);
  8340. var s2, t2, symbolRow;
  8341. if (transposed) {
  8342. for (s2 = 0; s2 < symbolHeight; s2++) {
  8343. row = bitmap[offsetS + s2];
  8344. if (!row) {
  8345. continue;
  8346. }
  8347. symbolRow = symbolBitmap[s2];
  8348. var maxWidth = Math.min(width - offsetT, symbolWidth);
  8349. switch (combinationOperator) {
  8350. case 0:
  8351. for (t2 = 0; t2 < maxWidth; t2++) {
  8352. row[offsetT + t2] |= symbolRow[t2];
  8353. }
  8354. break;
  8355. case 2:
  8356. for (t2 = 0; t2 < maxWidth; t2++) {
  8357. row[offsetT + t2] ^= symbolRow[t2];
  8358. }
  8359. break;
  8360. default:
  8361. throw new Jbig2Error(`operator ${combinationOperator} is not supported`);
  8362. }
  8363. }
  8364. currentS += symbolHeight - 1;
  8365. } else {
  8366. for (t2 = 0; t2 < symbolHeight; t2++) {
  8367. row = bitmap[offsetT + t2];
  8368. if (!row) {
  8369. continue;
  8370. }
  8371. symbolRow = symbolBitmap[t2];
  8372. switch (combinationOperator) {
  8373. case 0:
  8374. for (s2 = 0; s2 < symbolWidth; s2++) {
  8375. row[offsetS + s2] |= symbolRow[s2];
  8376. }
  8377. break;
  8378. case 2:
  8379. for (s2 = 0; s2 < symbolWidth; s2++) {
  8380. row[offsetS + s2] ^= symbolRow[s2];
  8381. }
  8382. break;
  8383. default:
  8384. throw new Jbig2Error(`operator ${combinationOperator} is not supported`);
  8385. }
  8386. }
  8387. currentS += symbolWidth - 1;
  8388. }
  8389. i++;
  8390. var deltaS = huffman ? huffmanTables.tableDeltaS.decode(huffmanInput) : decodeInteger(contextCache, "IADS", decoder);
  8391. if (deltaS === null) {
  8392. break;
  8393. }
  8394. currentS += deltaS + dsOffset;
  8395. } while (true);
  8396. }
  8397. return bitmap;
  8398. }
  8399. function decodePatternDictionary(mmr, patternWidth, patternHeight, maxPatternIndex, template, decodingContext) {
  8400. const at = [];
  8401. if (!mmr) {
  8402. at.push({
  8403. x: -patternWidth,
  8404. y: 0
  8405. });
  8406. if (template === 0) {
  8407. at.push({
  8408. x: -3,
  8409. y: -1
  8410. });
  8411. at.push({
  8412. x: 2,
  8413. y: -2
  8414. });
  8415. at.push({
  8416. x: -2,
  8417. y: -2
  8418. });
  8419. }
  8420. }
  8421. const collectiveWidth = (maxPatternIndex + 1) * patternWidth;
  8422. const collectiveBitmap = decodeBitmap(mmr, collectiveWidth, patternHeight, template, false, null, at, decodingContext);
  8423. const patterns = [];
  8424. for (let i = 0; i <= maxPatternIndex; i++) {
  8425. const patternBitmap = [];
  8426. const xMin = patternWidth * i;
  8427. const xMax = xMin + patternWidth;
  8428. for (let y = 0; y < patternHeight; y++) {
  8429. patternBitmap.push(collectiveBitmap[y].subarray(xMin, xMax));
  8430. }
  8431. patterns.push(patternBitmap);
  8432. }
  8433. return patterns;
  8434. }
  8435. function decodeHalftoneRegion(mmr, patterns, template, regionWidth, regionHeight, defaultPixelValue, enableSkip, combinationOperator, gridWidth, gridHeight, gridOffsetX, gridOffsetY, gridVectorX, gridVectorY, decodingContext) {
  8436. const skip = null;
  8437. if (enableSkip) {
  8438. throw new Jbig2Error("skip is not supported");
  8439. }
  8440. if (combinationOperator !== 0) {
  8441. throw new Jbig2Error("operator " + combinationOperator + " is not supported in halftone region");
  8442. }
  8443. const regionBitmap = [];
  8444. let i, j, row;
  8445. for (i = 0; i < regionHeight; i++) {
  8446. row = new Uint8Array(regionWidth);
  8447. if (defaultPixelValue) {
  8448. for (j = 0; j < regionWidth; j++) {
  8449. row[j] = defaultPixelValue;
  8450. }
  8451. }
  8452. regionBitmap.push(row);
  8453. }
  8454. const numberOfPatterns = patterns.length;
  8455. const pattern0 = patterns[0];
  8456. const patternWidth = pattern0[0].length,
  8457. patternHeight = pattern0.length;
  8458. const bitsPerValue = (0, _core_utils.log2)(numberOfPatterns);
  8459. const at = [];
  8460. if (!mmr) {
  8461. at.push({
  8462. x: template <= 1 ? 3 : 2,
  8463. y: -1
  8464. });
  8465. if (template === 0) {
  8466. at.push({
  8467. x: -3,
  8468. y: -1
  8469. });
  8470. at.push({
  8471. x: 2,
  8472. y: -2
  8473. });
  8474. at.push({
  8475. x: -2,
  8476. y: -2
  8477. });
  8478. }
  8479. }
  8480. const grayScaleBitPlanes = [];
  8481. let mmrInput, bitmap;
  8482. if (mmr) {
  8483. mmrInput = new Reader(decodingContext.data, decodingContext.start, decodingContext.end);
  8484. }
  8485. for (i = bitsPerValue - 1; i >= 0; i--) {
  8486. if (mmr) {
  8487. bitmap = decodeMMRBitmap(mmrInput, gridWidth, gridHeight, true);
  8488. } else {
  8489. bitmap = decodeBitmap(false, gridWidth, gridHeight, template, false, skip, at, decodingContext);
  8490. }
  8491. grayScaleBitPlanes[i] = bitmap;
  8492. }
  8493. let mg, ng, bit, patternIndex, patternBitmap, x, y, patternRow, regionRow;
  8494. for (mg = 0; mg < gridHeight; mg++) {
  8495. for (ng = 0; ng < gridWidth; ng++) {
  8496. bit = 0;
  8497. patternIndex = 0;
  8498. for (j = bitsPerValue - 1; j >= 0; j--) {
  8499. bit = grayScaleBitPlanes[j][mg][ng] ^ bit;
  8500. patternIndex |= bit << j;
  8501. }
  8502. patternBitmap = patterns[patternIndex];
  8503. x = gridOffsetX + mg * gridVectorY + ng * gridVectorX >> 8;
  8504. y = gridOffsetY + mg * gridVectorX - ng * gridVectorY >> 8;
  8505. if (x >= 0 && x + patternWidth <= regionWidth && y >= 0 && y + patternHeight <= regionHeight) {
  8506. for (i = 0; i < patternHeight; i++) {
  8507. regionRow = regionBitmap[y + i];
  8508. patternRow = patternBitmap[i];
  8509. for (j = 0; j < patternWidth; j++) {
  8510. regionRow[x + j] |= patternRow[j];
  8511. }
  8512. }
  8513. } else {
  8514. let regionX, regionY;
  8515. for (i = 0; i < patternHeight; i++) {
  8516. regionY = y + i;
  8517. if (regionY < 0 || regionY >= regionHeight) {
  8518. continue;
  8519. }
  8520. regionRow = regionBitmap[regionY];
  8521. patternRow = patternBitmap[i];
  8522. for (j = 0; j < patternWidth; j++) {
  8523. regionX = x + j;
  8524. if (regionX >= 0 && regionX < regionWidth) {
  8525. regionRow[regionX] |= patternRow[j];
  8526. }
  8527. }
  8528. }
  8529. }
  8530. }
  8531. }
  8532. return regionBitmap;
  8533. }
  8534. function readSegmentHeader(data, start) {
  8535. var segmentHeader = {};
  8536. segmentHeader.number = (0, _core_utils.readUint32)(data, start);
  8537. var flags = data[start + 4];
  8538. var segmentType = flags & 0x3f;
  8539. if (!SegmentTypes[segmentType]) {
  8540. throw new Jbig2Error("invalid segment type: " + segmentType);
  8541. }
  8542. segmentHeader.type = segmentType;
  8543. segmentHeader.typeName = SegmentTypes[segmentType];
  8544. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  8545. var pageAssociationFieldSize = !!(flags & 0x40);
  8546. var referredFlags = data[start + 5];
  8547. var referredToCount = referredFlags >> 5 & 7;
  8548. var retainBits = [referredFlags & 31];
  8549. var position = start + 6;
  8550. if (referredFlags === 7) {
  8551. referredToCount = (0, _core_utils.readUint32)(data, position - 1) & 0x1fffffff;
  8552. position += 3;
  8553. var bytes = referredToCount + 7 >> 3;
  8554. retainBits[0] = data[position++];
  8555. while (--bytes > 0) {
  8556. retainBits.push(data[position++]);
  8557. }
  8558. } else if (referredFlags === 5 || referredFlags === 6) {
  8559. throw new Jbig2Error("invalid referred-to flags");
  8560. }
  8561. segmentHeader.retainBits = retainBits;
  8562. let referredToSegmentNumberSize = 4;
  8563. if (segmentHeader.number <= 256) {
  8564. referredToSegmentNumberSize = 1;
  8565. } else if (segmentHeader.number <= 65536) {
  8566. referredToSegmentNumberSize = 2;
  8567. }
  8568. var referredTo = [];
  8569. var i, ii;
  8570. for (i = 0; i < referredToCount; i++) {
  8571. let number;
  8572. if (referredToSegmentNumberSize === 1) {
  8573. number = data[position];
  8574. } else if (referredToSegmentNumberSize === 2) {
  8575. number = (0, _core_utils.readUint16)(data, position);
  8576. } else {
  8577. number = (0, _core_utils.readUint32)(data, position);
  8578. }
  8579. referredTo.push(number);
  8580. position += referredToSegmentNumberSize;
  8581. }
  8582. segmentHeader.referredTo = referredTo;
  8583. if (!pageAssociationFieldSize) {
  8584. segmentHeader.pageAssociation = data[position++];
  8585. } else {
  8586. segmentHeader.pageAssociation = (0, _core_utils.readUint32)(data, position);
  8587. position += 4;
  8588. }
  8589. segmentHeader.length = (0, _core_utils.readUint32)(data, position);
  8590. position += 4;
  8591. if (segmentHeader.length === 0xffffffff) {
  8592. if (segmentType === 38) {
  8593. var genericRegionInfo = readRegionSegmentInformation(data, position);
  8594. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  8595. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  8596. var searchPatternLength = 6;
  8597. var searchPattern = new Uint8Array(searchPatternLength);
  8598. if (!genericRegionMmr) {
  8599. searchPattern[0] = 0xff;
  8600. searchPattern[1] = 0xac;
  8601. }
  8602. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xff;
  8603. searchPattern[3] = genericRegionInfo.height >> 16 & 0xff;
  8604. searchPattern[4] = genericRegionInfo.height >> 8 & 0xff;
  8605. searchPattern[5] = genericRegionInfo.height & 0xff;
  8606. for (i = position, ii = data.length; i < ii; i++) {
  8607. var j = 0;
  8608. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  8609. j++;
  8610. }
  8611. if (j === searchPatternLength) {
  8612. segmentHeader.length = i + searchPatternLength;
  8613. break;
  8614. }
  8615. }
  8616. if (segmentHeader.length === 0xffffffff) {
  8617. throw new Jbig2Error("segment end was not found");
  8618. }
  8619. } else {
  8620. throw new Jbig2Error("invalid unknown segment length");
  8621. }
  8622. }
  8623. segmentHeader.headerEnd = position;
  8624. return segmentHeader;
  8625. }
  8626. function readSegments(header, data, start, end) {
  8627. var segments = [];
  8628. var position = start;
  8629. while (position < end) {
  8630. var segmentHeader = readSegmentHeader(data, position);
  8631. position = segmentHeader.headerEnd;
  8632. var segment = {
  8633. header: segmentHeader,
  8634. data
  8635. };
  8636. if (!header.randomAccess) {
  8637. segment.start = position;
  8638. position += segmentHeader.length;
  8639. segment.end = position;
  8640. }
  8641. segments.push(segment);
  8642. if (segmentHeader.type === 51) {
  8643. break;
  8644. }
  8645. }
  8646. if (header.randomAccess) {
  8647. for (var i = 0, ii = segments.length; i < ii; i++) {
  8648. segments[i].start = position;
  8649. position += segments[i].header.length;
  8650. segments[i].end = position;
  8651. }
  8652. }
  8653. return segments;
  8654. }
  8655. function readRegionSegmentInformation(data, start) {
  8656. return {
  8657. width: (0, _core_utils.readUint32)(data, start),
  8658. height: (0, _core_utils.readUint32)(data, start + 4),
  8659. x: (0, _core_utils.readUint32)(data, start + 8),
  8660. y: (0, _core_utils.readUint32)(data, start + 12),
  8661. combinationOperator: data[start + 16] & 7
  8662. };
  8663. }
  8664. var RegionSegmentInformationFieldLength = 17;
  8665. function processSegment(segment, visitor) {
  8666. var header = segment.header;
  8667. var data = segment.data,
  8668. position = segment.start,
  8669. end = segment.end;
  8670. var args, at, i, atLength;
  8671. switch (header.type) {
  8672. case 0:
  8673. var dictionary = {};
  8674. var dictionaryFlags = (0, _core_utils.readUint16)(data, position);
  8675. dictionary.huffman = !!(dictionaryFlags & 1);
  8676. dictionary.refinement = !!(dictionaryFlags & 2);
  8677. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  8678. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  8679. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  8680. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  8681. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  8682. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  8683. dictionary.template = dictionaryFlags >> 10 & 3;
  8684. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  8685. position += 2;
  8686. if (!dictionary.huffman) {
  8687. atLength = dictionary.template === 0 ? 4 : 1;
  8688. at = [];
  8689. for (i = 0; i < atLength; i++) {
  8690. at.push({
  8691. x: (0, _core_utils.readInt8)(data, position),
  8692. y: (0, _core_utils.readInt8)(data, position + 1)
  8693. });
  8694. position += 2;
  8695. }
  8696. dictionary.at = at;
  8697. }
  8698. if (dictionary.refinement && !dictionary.refinementTemplate) {
  8699. at = [];
  8700. for (i = 0; i < 2; i++) {
  8701. at.push({
  8702. x: (0, _core_utils.readInt8)(data, position),
  8703. y: (0, _core_utils.readInt8)(data, position + 1)
  8704. });
  8705. position += 2;
  8706. }
  8707. dictionary.refinementAt = at;
  8708. }
  8709. dictionary.numberOfExportedSymbols = (0, _core_utils.readUint32)(data, position);
  8710. position += 4;
  8711. dictionary.numberOfNewSymbols = (0, _core_utils.readUint32)(data, position);
  8712. position += 4;
  8713. args = [dictionary, header.number, header.referredTo, data, position, end];
  8714. break;
  8715. case 6:
  8716. case 7:
  8717. var textRegion = {};
  8718. textRegion.info = readRegionSegmentInformation(data, position);
  8719. position += RegionSegmentInformationFieldLength;
  8720. var textRegionSegmentFlags = (0, _core_utils.readUint16)(data, position);
  8721. position += 2;
  8722. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  8723. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  8724. textRegion.logStripSize = textRegionSegmentFlags >> 2 & 3;
  8725. textRegion.stripSize = 1 << textRegion.logStripSize;
  8726. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  8727. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  8728. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  8729. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  8730. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  8731. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  8732. if (textRegion.huffman) {
  8733. var textRegionHuffmanFlags = (0, _core_utils.readUint16)(data, position);
  8734. position += 2;
  8735. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  8736. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  8737. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  8738. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  8739. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  8740. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  8741. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  8742. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 0x4000);
  8743. }
  8744. if (textRegion.refinement && !textRegion.refinementTemplate) {
  8745. at = [];
  8746. for (i = 0; i < 2; i++) {
  8747. at.push({
  8748. x: (0, _core_utils.readInt8)(data, position),
  8749. y: (0, _core_utils.readInt8)(data, position + 1)
  8750. });
  8751. position += 2;
  8752. }
  8753. textRegion.refinementAt = at;
  8754. }
  8755. textRegion.numberOfSymbolInstances = (0, _core_utils.readUint32)(data, position);
  8756. position += 4;
  8757. args = [textRegion, header.referredTo, data, position, end];
  8758. break;
  8759. case 16:
  8760. const patternDictionary = {};
  8761. const patternDictionaryFlags = data[position++];
  8762. patternDictionary.mmr = !!(patternDictionaryFlags & 1);
  8763. patternDictionary.template = patternDictionaryFlags >> 1 & 3;
  8764. patternDictionary.patternWidth = data[position++];
  8765. patternDictionary.patternHeight = data[position++];
  8766. patternDictionary.maxPatternIndex = (0, _core_utils.readUint32)(data, position);
  8767. position += 4;
  8768. args = [patternDictionary, header.number, data, position, end];
  8769. break;
  8770. case 22:
  8771. case 23:
  8772. const halftoneRegion = {};
  8773. halftoneRegion.info = readRegionSegmentInformation(data, position);
  8774. position += RegionSegmentInformationFieldLength;
  8775. const halftoneRegionFlags = data[position++];
  8776. halftoneRegion.mmr = !!(halftoneRegionFlags & 1);
  8777. halftoneRegion.template = halftoneRegionFlags >> 1 & 3;
  8778. halftoneRegion.enableSkip = !!(halftoneRegionFlags & 8);
  8779. halftoneRegion.combinationOperator = halftoneRegionFlags >> 4 & 7;
  8780. halftoneRegion.defaultPixelValue = halftoneRegionFlags >> 7 & 1;
  8781. halftoneRegion.gridWidth = (0, _core_utils.readUint32)(data, position);
  8782. position += 4;
  8783. halftoneRegion.gridHeight = (0, _core_utils.readUint32)(data, position);
  8784. position += 4;
  8785. halftoneRegion.gridOffsetX = (0, _core_utils.readUint32)(data, position) & 0xffffffff;
  8786. position += 4;
  8787. halftoneRegion.gridOffsetY = (0, _core_utils.readUint32)(data, position) & 0xffffffff;
  8788. position += 4;
  8789. halftoneRegion.gridVectorX = (0, _core_utils.readUint16)(data, position);
  8790. position += 2;
  8791. halftoneRegion.gridVectorY = (0, _core_utils.readUint16)(data, position);
  8792. position += 2;
  8793. args = [halftoneRegion, header.referredTo, data, position, end];
  8794. break;
  8795. case 38:
  8796. case 39:
  8797. var genericRegion = {};
  8798. genericRegion.info = readRegionSegmentInformation(data, position);
  8799. position += RegionSegmentInformationFieldLength;
  8800. var genericRegionSegmentFlags = data[position++];
  8801. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  8802. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  8803. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  8804. if (!genericRegion.mmr) {
  8805. atLength = genericRegion.template === 0 ? 4 : 1;
  8806. at = [];
  8807. for (i = 0; i < atLength; i++) {
  8808. at.push({
  8809. x: (0, _core_utils.readInt8)(data, position),
  8810. y: (0, _core_utils.readInt8)(data, position + 1)
  8811. });
  8812. position += 2;
  8813. }
  8814. genericRegion.at = at;
  8815. }
  8816. args = [genericRegion, data, position, end];
  8817. break;
  8818. case 48:
  8819. var pageInfo = {
  8820. width: (0, _core_utils.readUint32)(data, position),
  8821. height: (0, _core_utils.readUint32)(data, position + 4),
  8822. resolutionX: (0, _core_utils.readUint32)(data, position + 8),
  8823. resolutionY: (0, _core_utils.readUint32)(data, position + 12)
  8824. };
  8825. if (pageInfo.height === 0xffffffff) {
  8826. delete pageInfo.height;
  8827. }
  8828. var pageSegmentFlags = data[position + 16];
  8829. (0, _core_utils.readUint16)(data, position + 17);
  8830. pageInfo.lossless = !!(pageSegmentFlags & 1);
  8831. pageInfo.refinement = !!(pageSegmentFlags & 2);
  8832. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  8833. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  8834. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  8835. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  8836. args = [pageInfo];
  8837. break;
  8838. case 49:
  8839. break;
  8840. case 50:
  8841. break;
  8842. case 51:
  8843. break;
  8844. case 53:
  8845. args = [header.number, data, position, end];
  8846. break;
  8847. case 62:
  8848. break;
  8849. default:
  8850. throw new Jbig2Error(`segment type ${header.typeName}(${header.type})` + " is not implemented");
  8851. }
  8852. var callbackName = "on" + header.typeName;
  8853. if (callbackName in visitor) {
  8854. visitor[callbackName].apply(visitor, args);
  8855. }
  8856. }
  8857. function processSegments(segments, visitor) {
  8858. for (var i = 0, ii = segments.length; i < ii; i++) {
  8859. processSegment(segments[i], visitor);
  8860. }
  8861. }
  8862. function parseJbig2Chunks(chunks) {
  8863. var visitor = new SimpleSegmentVisitor();
  8864. for (var i = 0, ii = chunks.length; i < ii; i++) {
  8865. var chunk = chunks[i];
  8866. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  8867. processSegments(segments, visitor);
  8868. }
  8869. return visitor.buffer;
  8870. }
  8871. function parseJbig2(data) {
  8872. const end = data.length;
  8873. let position = 0;
  8874. 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) {
  8875. throw new Jbig2Error("parseJbig2 - invalid header.");
  8876. }
  8877. const header = Object.create(null);
  8878. position += 8;
  8879. const flags = data[position++];
  8880. header.randomAccess = !(flags & 1);
  8881. if (!(flags & 2)) {
  8882. header.numberOfPages = (0, _core_utils.readUint32)(data, position);
  8883. position += 4;
  8884. }
  8885. const segments = readSegments(header, data, position, end);
  8886. const visitor = new SimpleSegmentVisitor();
  8887. processSegments(segments, visitor);
  8888. const {
  8889. width,
  8890. height
  8891. } = visitor.currentPageInfo;
  8892. const bitPacked = visitor.buffer;
  8893. const imgData = new Uint8ClampedArray(width * height);
  8894. let q = 0,
  8895. k = 0;
  8896. for (let i = 0; i < height; i++) {
  8897. let mask = 0,
  8898. buffer;
  8899. for (let j = 0; j < width; j++) {
  8900. if (!mask) {
  8901. mask = 128;
  8902. buffer = bitPacked[k++];
  8903. }
  8904. imgData[q++] = buffer & mask ? 0 : 255;
  8905. mask >>= 1;
  8906. }
  8907. }
  8908. return {
  8909. imgData,
  8910. width,
  8911. height
  8912. };
  8913. }
  8914. function SimpleSegmentVisitor() {}
  8915. SimpleSegmentVisitor.prototype = {
  8916. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  8917. this.currentPageInfo = info;
  8918. var rowSize = info.width + 7 >> 3;
  8919. var buffer = new Uint8ClampedArray(rowSize * info.height);
  8920. if (info.defaultPixelValue) {
  8921. for (var i = 0, ii = buffer.length; i < ii; i++) {
  8922. buffer[i] = 0xff;
  8923. }
  8924. }
  8925. this.buffer = buffer;
  8926. },
  8927. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  8928. var pageInfo = this.currentPageInfo;
  8929. var width = regionInfo.width,
  8930. height = regionInfo.height;
  8931. var rowSize = pageInfo.width + 7 >> 3;
  8932. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  8933. var buffer = this.buffer;
  8934. var mask0 = 128 >> (regionInfo.x & 7);
  8935. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  8936. var i, j, mask, offset;
  8937. switch (combinationOperator) {
  8938. case 0:
  8939. for (i = 0; i < height; i++) {
  8940. mask = mask0;
  8941. offset = offset0;
  8942. for (j = 0; j < width; j++) {
  8943. if (bitmap[i][j]) {
  8944. buffer[offset] |= mask;
  8945. }
  8946. mask >>= 1;
  8947. if (!mask) {
  8948. mask = 128;
  8949. offset++;
  8950. }
  8951. }
  8952. offset0 += rowSize;
  8953. }
  8954. break;
  8955. case 2:
  8956. for (i = 0; i < height; i++) {
  8957. mask = mask0;
  8958. offset = offset0;
  8959. for (j = 0; j < width; j++) {
  8960. if (bitmap[i][j]) {
  8961. buffer[offset] ^= mask;
  8962. }
  8963. mask >>= 1;
  8964. if (!mask) {
  8965. mask = 128;
  8966. offset++;
  8967. }
  8968. }
  8969. offset0 += rowSize;
  8970. }
  8971. break;
  8972. default:
  8973. throw new Jbig2Error(`operator ${combinationOperator} is not supported`);
  8974. }
  8975. },
  8976. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  8977. var regionInfo = region.info;
  8978. var decodingContext = new DecodingContext(data, start, end);
  8979. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  8980. this.drawBitmap(regionInfo, bitmap);
  8981. },
  8982. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  8983. this.onImmediateGenericRegion.apply(this, arguments);
  8984. },
  8985. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  8986. let huffmanTables, huffmanInput;
  8987. if (dictionary.huffman) {
  8988. huffmanTables = getSymbolDictionaryHuffmanTables(dictionary, referredSegments, this.customTables);
  8989. huffmanInput = new Reader(data, start, end);
  8990. }
  8991. var symbols = this.symbols;
  8992. if (!symbols) {
  8993. this.symbols = symbols = {};
  8994. }
  8995. var inputSymbols = [];
  8996. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  8997. const referredSymbols = symbols[referredSegments[i]];
  8998. if (referredSymbols) {
  8999. inputSymbols = inputSymbols.concat(referredSymbols);
  9000. }
  9001. }
  9002. var decodingContext = new DecodingContext(data, start, end);
  9003. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext, huffmanInput);
  9004. },
  9005. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  9006. var regionInfo = region.info;
  9007. let huffmanTables, huffmanInput;
  9008. var symbols = this.symbols;
  9009. var inputSymbols = [];
  9010. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  9011. const referredSymbols = symbols[referredSegments[i]];
  9012. if (referredSymbols) {
  9013. inputSymbols = inputSymbols.concat(referredSymbols);
  9014. }
  9015. }
  9016. var symbolCodeLength = (0, _core_utils.log2)(inputSymbols.length);
  9017. if (region.huffman) {
  9018. huffmanInput = new Reader(data, start, end);
  9019. huffmanTables = getTextRegionHuffmanTables(region, referredSegments, this.customTables, inputSymbols.length, huffmanInput);
  9020. }
  9021. var decodingContext = new DecodingContext(data, start, end);
  9022. 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);
  9023. this.drawBitmap(regionInfo, bitmap);
  9024. },
  9025. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  9026. this.onImmediateTextRegion.apply(this, arguments);
  9027. },
  9028. onPatternDictionary(dictionary, currentSegment, data, start, end) {
  9029. let patterns = this.patterns;
  9030. if (!patterns) {
  9031. this.patterns = patterns = {};
  9032. }
  9033. const decodingContext = new DecodingContext(data, start, end);
  9034. patterns[currentSegment] = decodePatternDictionary(dictionary.mmr, dictionary.patternWidth, dictionary.patternHeight, dictionary.maxPatternIndex, dictionary.template, decodingContext);
  9035. },
  9036. onImmediateHalftoneRegion(region, referredSegments, data, start, end) {
  9037. const patterns = this.patterns[referredSegments[0]];
  9038. const regionInfo = region.info;
  9039. const decodingContext = new DecodingContext(data, start, end);
  9040. const 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);
  9041. this.drawBitmap(regionInfo, bitmap);
  9042. },
  9043. onImmediateLosslessHalftoneRegion() {
  9044. this.onImmediateHalftoneRegion.apply(this, arguments);
  9045. },
  9046. onTables(currentSegment, data, start, end) {
  9047. let customTables = this.customTables;
  9048. if (!customTables) {
  9049. this.customTables = customTables = {};
  9050. }
  9051. customTables[currentSegment] = decodeTablesSegment(data, start, end);
  9052. }
  9053. };
  9054. function HuffmanLine(lineData) {
  9055. if (lineData.length === 2) {
  9056. this.isOOB = true;
  9057. this.rangeLow = 0;
  9058. this.prefixLength = lineData[0];
  9059. this.rangeLength = 0;
  9060. this.prefixCode = lineData[1];
  9061. this.isLowerRange = false;
  9062. } else {
  9063. this.isOOB = false;
  9064. this.rangeLow = lineData[0];
  9065. this.prefixLength = lineData[1];
  9066. this.rangeLength = lineData[2];
  9067. this.prefixCode = lineData[3];
  9068. this.isLowerRange = lineData[4] === "lower";
  9069. }
  9070. }
  9071. function HuffmanTreeNode(line) {
  9072. this.children = [];
  9073. if (line) {
  9074. this.isLeaf = true;
  9075. this.rangeLength = line.rangeLength;
  9076. this.rangeLow = line.rangeLow;
  9077. this.isLowerRange = line.isLowerRange;
  9078. this.isOOB = line.isOOB;
  9079. } else {
  9080. this.isLeaf = false;
  9081. }
  9082. }
  9083. HuffmanTreeNode.prototype = {
  9084. buildTree(line, shift) {
  9085. const bit = line.prefixCode >> shift & 1;
  9086. if (shift <= 0) {
  9087. this.children[bit] = new HuffmanTreeNode(line);
  9088. } else {
  9089. let node = this.children[bit];
  9090. if (!node) {
  9091. this.children[bit] = node = new HuffmanTreeNode(null);
  9092. }
  9093. node.buildTree(line, shift - 1);
  9094. }
  9095. },
  9096. decodeNode(reader) {
  9097. if (this.isLeaf) {
  9098. if (this.isOOB) {
  9099. return null;
  9100. }
  9101. const htOffset = reader.readBits(this.rangeLength);
  9102. return this.rangeLow + (this.isLowerRange ? -htOffset : htOffset);
  9103. }
  9104. const node = this.children[reader.readBit()];
  9105. if (!node) {
  9106. throw new Jbig2Error("invalid Huffman data");
  9107. }
  9108. return node.decodeNode(reader);
  9109. }
  9110. };
  9111. function HuffmanTable(lines, prefixCodesDone) {
  9112. if (!prefixCodesDone) {
  9113. this.assignPrefixCodes(lines);
  9114. }
  9115. this.rootNode = new HuffmanTreeNode(null);
  9116. for (let i = 0, ii = lines.length; i < ii; i++) {
  9117. const line = lines[i];
  9118. if (line.prefixLength > 0) {
  9119. this.rootNode.buildTree(line, line.prefixLength - 1);
  9120. }
  9121. }
  9122. }
  9123. HuffmanTable.prototype = {
  9124. decode(reader) {
  9125. return this.rootNode.decodeNode(reader);
  9126. },
  9127. assignPrefixCodes(lines) {
  9128. const linesLength = lines.length;
  9129. let prefixLengthMax = 0;
  9130. for (let i = 0; i < linesLength; i++) {
  9131. prefixLengthMax = Math.max(prefixLengthMax, lines[i].prefixLength);
  9132. }
  9133. const histogram = new Uint32Array(prefixLengthMax + 1);
  9134. for (let i = 0; i < linesLength; i++) {
  9135. histogram[lines[i].prefixLength]++;
  9136. }
  9137. let currentLength = 1,
  9138. firstCode = 0,
  9139. currentCode,
  9140. currentTemp,
  9141. line;
  9142. histogram[0] = 0;
  9143. while (currentLength <= prefixLengthMax) {
  9144. firstCode = firstCode + histogram[currentLength - 1] << 1;
  9145. currentCode = firstCode;
  9146. currentTemp = 0;
  9147. while (currentTemp < linesLength) {
  9148. line = lines[currentTemp];
  9149. if (line.prefixLength === currentLength) {
  9150. line.prefixCode = currentCode;
  9151. currentCode++;
  9152. }
  9153. currentTemp++;
  9154. }
  9155. currentLength++;
  9156. }
  9157. }
  9158. };
  9159. function decodeTablesSegment(data, start, end) {
  9160. const flags = data[start];
  9161. const lowestValue = (0, _core_utils.readUint32)(data, start + 1) & 0xffffffff;
  9162. const highestValue = (0, _core_utils.readUint32)(data, start + 5) & 0xffffffff;
  9163. const reader = new Reader(data, start + 9, end);
  9164. const prefixSizeBits = (flags >> 1 & 7) + 1;
  9165. const rangeSizeBits = (flags >> 4 & 7) + 1;
  9166. const lines = [];
  9167. let prefixLength,
  9168. rangeLength,
  9169. currentRangeLow = lowestValue;
  9170. do {
  9171. prefixLength = reader.readBits(prefixSizeBits);
  9172. rangeLength = reader.readBits(rangeSizeBits);
  9173. lines.push(new HuffmanLine([currentRangeLow, prefixLength, rangeLength, 0]));
  9174. currentRangeLow += 1 << rangeLength;
  9175. } while (currentRangeLow < highestValue);
  9176. prefixLength = reader.readBits(prefixSizeBits);
  9177. lines.push(new HuffmanLine([lowestValue - 1, prefixLength, 32, 0, "lower"]));
  9178. prefixLength = reader.readBits(prefixSizeBits);
  9179. lines.push(new HuffmanLine([highestValue, prefixLength, 32, 0]));
  9180. if (flags & 1) {
  9181. prefixLength = reader.readBits(prefixSizeBits);
  9182. lines.push(new HuffmanLine([prefixLength, 0]));
  9183. }
  9184. return new HuffmanTable(lines, false);
  9185. }
  9186. const standardTablesCache = {};
  9187. function getStandardTable(number) {
  9188. let table = standardTablesCache[number];
  9189. if (table) {
  9190. return table;
  9191. }
  9192. let lines;
  9193. switch (number) {
  9194. case 1:
  9195. lines = [[0, 1, 4, 0x0], [16, 2, 8, 0x2], [272, 3, 16, 0x6], [65808, 3, 32, 0x7]];
  9196. break;
  9197. case 2:
  9198. 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]];
  9199. break;
  9200. case 3:
  9201. 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]];
  9202. break;
  9203. case 4:
  9204. 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]];
  9205. break;
  9206. case 5:
  9207. 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]];
  9208. break;
  9209. case 6:
  9210. 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]];
  9211. break;
  9212. case 7:
  9213. 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]];
  9214. break;
  9215. case 8:
  9216. 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]];
  9217. break;
  9218. case 9:
  9219. 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]];
  9220. break;
  9221. case 10:
  9222. 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]];
  9223. break;
  9224. case 11:
  9225. 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]];
  9226. break;
  9227. case 12:
  9228. 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]];
  9229. break;
  9230. case 13:
  9231. 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]];
  9232. break;
  9233. case 14:
  9234. lines = [[-2, 3, 0, 0x4], [-1, 3, 0, 0x5], [0, 1, 0, 0x0], [1, 3, 0, 0x6], [2, 3, 0, 0x7]];
  9235. break;
  9236. case 15:
  9237. 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]];
  9238. break;
  9239. default:
  9240. throw new Jbig2Error(`standard table B.${number} does not exist`);
  9241. }
  9242. for (let i = 0, ii = lines.length; i < ii; i++) {
  9243. lines[i] = new HuffmanLine(lines[i]);
  9244. }
  9245. table = new HuffmanTable(lines, true);
  9246. standardTablesCache[number] = table;
  9247. return table;
  9248. }
  9249. function Reader(data, start, end) {
  9250. this.data = data;
  9251. this.start = start;
  9252. this.end = end;
  9253. this.position = start;
  9254. this.shift = -1;
  9255. this.currentByte = 0;
  9256. }
  9257. Reader.prototype = {
  9258. readBit() {
  9259. if (this.shift < 0) {
  9260. if (this.position >= this.end) {
  9261. throw new Jbig2Error("end of data while reading bit");
  9262. }
  9263. this.currentByte = this.data[this.position++];
  9264. this.shift = 7;
  9265. }
  9266. const bit = this.currentByte >> this.shift & 1;
  9267. this.shift--;
  9268. return bit;
  9269. },
  9270. readBits(numBits) {
  9271. let result = 0,
  9272. i;
  9273. for (i = numBits - 1; i >= 0; i--) {
  9274. result |= this.readBit() << i;
  9275. }
  9276. return result;
  9277. },
  9278. byteAlign() {
  9279. this.shift = -1;
  9280. },
  9281. next() {
  9282. if (this.position >= this.end) {
  9283. return -1;
  9284. }
  9285. return this.data[this.position++];
  9286. }
  9287. };
  9288. function getCustomHuffmanTable(index, referredTo, customTables) {
  9289. let currentIndex = 0;
  9290. for (let i = 0, ii = referredTo.length; i < ii; i++) {
  9291. const table = customTables[referredTo[i]];
  9292. if (table) {
  9293. if (index === currentIndex) {
  9294. return table;
  9295. }
  9296. currentIndex++;
  9297. }
  9298. }
  9299. throw new Jbig2Error("can't find custom Huffman table");
  9300. }
  9301. function getTextRegionHuffmanTables(textRegion, referredTo, customTables, numberOfSymbols, reader) {
  9302. const codes = [];
  9303. for (let i = 0; i <= 34; i++) {
  9304. const codeLength = reader.readBits(4);
  9305. codes.push(new HuffmanLine([i, codeLength, 0, 0]));
  9306. }
  9307. const runCodesTable = new HuffmanTable(codes, false);
  9308. codes.length = 0;
  9309. for (let i = 0; i < numberOfSymbols;) {
  9310. const codeLength = runCodesTable.decode(reader);
  9311. if (codeLength >= 32) {
  9312. let repeatedLength, numberOfRepeats, j;
  9313. switch (codeLength) {
  9314. case 32:
  9315. if (i === 0) {
  9316. throw new Jbig2Error("no previous value in symbol ID table");
  9317. }
  9318. numberOfRepeats = reader.readBits(2) + 3;
  9319. repeatedLength = codes[i - 1].prefixLength;
  9320. break;
  9321. case 33:
  9322. numberOfRepeats = reader.readBits(3) + 3;
  9323. repeatedLength = 0;
  9324. break;
  9325. case 34:
  9326. numberOfRepeats = reader.readBits(7) + 11;
  9327. repeatedLength = 0;
  9328. break;
  9329. default:
  9330. throw new Jbig2Error("invalid code length in symbol ID table");
  9331. }
  9332. for (j = 0; j < numberOfRepeats; j++) {
  9333. codes.push(new HuffmanLine([i, repeatedLength, 0, 0]));
  9334. i++;
  9335. }
  9336. } else {
  9337. codes.push(new HuffmanLine([i, codeLength, 0, 0]));
  9338. i++;
  9339. }
  9340. }
  9341. reader.byteAlign();
  9342. const symbolIDTable = new HuffmanTable(codes, false);
  9343. let customIndex = 0,
  9344. tableFirstS,
  9345. tableDeltaS,
  9346. tableDeltaT;
  9347. switch (textRegion.huffmanFS) {
  9348. case 0:
  9349. case 1:
  9350. tableFirstS = getStandardTable(textRegion.huffmanFS + 6);
  9351. break;
  9352. case 3:
  9353. tableFirstS = getCustomHuffmanTable(customIndex, referredTo, customTables);
  9354. customIndex++;
  9355. break;
  9356. default:
  9357. throw new Jbig2Error("invalid Huffman FS selector");
  9358. }
  9359. switch (textRegion.huffmanDS) {
  9360. case 0:
  9361. case 1:
  9362. case 2:
  9363. tableDeltaS = getStandardTable(textRegion.huffmanDS + 8);
  9364. break;
  9365. case 3:
  9366. tableDeltaS = getCustomHuffmanTable(customIndex, referredTo, customTables);
  9367. customIndex++;
  9368. break;
  9369. default:
  9370. throw new Jbig2Error("invalid Huffman DS selector");
  9371. }
  9372. switch (textRegion.huffmanDT) {
  9373. case 0:
  9374. case 1:
  9375. case 2:
  9376. tableDeltaT = getStandardTable(textRegion.huffmanDT + 11);
  9377. break;
  9378. case 3:
  9379. tableDeltaT = getCustomHuffmanTable(customIndex, referredTo, customTables);
  9380. customIndex++;
  9381. break;
  9382. default:
  9383. throw new Jbig2Error("invalid Huffman DT selector");
  9384. }
  9385. if (textRegion.refinement) {
  9386. throw new Jbig2Error("refinement with Huffman is not supported");
  9387. }
  9388. return {
  9389. symbolIDTable,
  9390. tableFirstS,
  9391. tableDeltaS,
  9392. tableDeltaT
  9393. };
  9394. }
  9395. function getSymbolDictionaryHuffmanTables(dictionary, referredTo, customTables) {
  9396. let customIndex = 0,
  9397. tableDeltaHeight,
  9398. tableDeltaWidth;
  9399. switch (dictionary.huffmanDHSelector) {
  9400. case 0:
  9401. case 1:
  9402. tableDeltaHeight = getStandardTable(dictionary.huffmanDHSelector + 4);
  9403. break;
  9404. case 3:
  9405. tableDeltaHeight = getCustomHuffmanTable(customIndex, referredTo, customTables);
  9406. customIndex++;
  9407. break;
  9408. default:
  9409. throw new Jbig2Error("invalid Huffman DH selector");
  9410. }
  9411. switch (dictionary.huffmanDWSelector) {
  9412. case 0:
  9413. case 1:
  9414. tableDeltaWidth = getStandardTable(dictionary.huffmanDWSelector + 2);
  9415. break;
  9416. case 3:
  9417. tableDeltaWidth = getCustomHuffmanTable(customIndex, referredTo, customTables);
  9418. customIndex++;
  9419. break;
  9420. default:
  9421. throw new Jbig2Error("invalid Huffman DW selector");
  9422. }
  9423. let tableBitmapSize, tableAggregateInstances;
  9424. if (dictionary.bitmapSizeSelector) {
  9425. tableBitmapSize = getCustomHuffmanTable(customIndex, referredTo, customTables);
  9426. customIndex++;
  9427. } else {
  9428. tableBitmapSize = getStandardTable(1);
  9429. }
  9430. if (dictionary.aggregationInstancesSelector) {
  9431. tableAggregateInstances = getCustomHuffmanTable(customIndex, referredTo, customTables);
  9432. } else {
  9433. tableAggregateInstances = getStandardTable(1);
  9434. }
  9435. return {
  9436. tableDeltaHeight,
  9437. tableDeltaWidth,
  9438. tableBitmapSize,
  9439. tableAggregateInstances
  9440. };
  9441. }
  9442. function readUncompressedBitmap(reader, width, height) {
  9443. const bitmap = [];
  9444. for (let y = 0; y < height; y++) {
  9445. const row = new Uint8Array(width);
  9446. bitmap.push(row);
  9447. for (let x = 0; x < width; x++) {
  9448. row[x] = reader.readBit();
  9449. }
  9450. reader.byteAlign();
  9451. }
  9452. return bitmap;
  9453. }
  9454. function decodeMMRBitmap(input, width, height, endOfBlock) {
  9455. const params = {
  9456. K: -1,
  9457. Columns: width,
  9458. Rows: height,
  9459. BlackIs1: true,
  9460. EndOfBlock: endOfBlock
  9461. };
  9462. const decoder = new _ccitt.CCITTFaxDecoder(input, params);
  9463. const bitmap = [];
  9464. let currentByte,
  9465. eof = false;
  9466. for (let y = 0; y < height; y++) {
  9467. const row = new Uint8Array(width);
  9468. bitmap.push(row);
  9469. let shift = -1;
  9470. for (let x = 0; x < width; x++) {
  9471. if (shift < 0) {
  9472. currentByte = decoder.readNextChar();
  9473. if (currentByte === -1) {
  9474. currentByte = 0;
  9475. eof = true;
  9476. }
  9477. shift = 7;
  9478. }
  9479. row[x] = currentByte >> shift & 1;
  9480. shift--;
  9481. }
  9482. }
  9483. if (endOfBlock && !eof) {
  9484. const lookForEOFLimit = 5;
  9485. for (let i = 0; i < lookForEOFLimit; i++) {
  9486. if (decoder.readNextChar() === -1) {
  9487. break;
  9488. }
  9489. }
  9490. }
  9491. return bitmap;
  9492. }
  9493. function Jbig2Image() {}
  9494. Jbig2Image.prototype = {
  9495. parseChunks(chunks) {
  9496. return parseJbig2Chunks(chunks);
  9497. },
  9498. parse(data) {
  9499. const {
  9500. imgData,
  9501. width,
  9502. height
  9503. } = parseJbig2(data);
  9504. this.width = width;
  9505. this.height = height;
  9506. return imgData;
  9507. }
  9508. };
  9509. return Jbig2Image;
  9510. }();
  9511. exports.Jbig2Image = Jbig2Image;
  9512. /***/ }),
  9513. /* 17 */
  9514. /***/ (function(module, exports, __w_pdfjs_require__) {
  9515. "use strict";
  9516. Object.defineProperty(exports, "__esModule", {
  9517. value: true
  9518. });
  9519. exports.ArithmeticDecoder = void 0;
  9520. const QeTable = [{
  9521. qe: 0x5601,
  9522. nmps: 1,
  9523. nlps: 1,
  9524. switchFlag: 1
  9525. }, {
  9526. qe: 0x3401,
  9527. nmps: 2,
  9528. nlps: 6,
  9529. switchFlag: 0
  9530. }, {
  9531. qe: 0x1801,
  9532. nmps: 3,
  9533. nlps: 9,
  9534. switchFlag: 0
  9535. }, {
  9536. qe: 0x0ac1,
  9537. nmps: 4,
  9538. nlps: 12,
  9539. switchFlag: 0
  9540. }, {
  9541. qe: 0x0521,
  9542. nmps: 5,
  9543. nlps: 29,
  9544. switchFlag: 0
  9545. }, {
  9546. qe: 0x0221,
  9547. nmps: 38,
  9548. nlps: 33,
  9549. switchFlag: 0
  9550. }, {
  9551. qe: 0x5601,
  9552. nmps: 7,
  9553. nlps: 6,
  9554. switchFlag: 1
  9555. }, {
  9556. qe: 0x5401,
  9557. nmps: 8,
  9558. nlps: 14,
  9559. switchFlag: 0
  9560. }, {
  9561. qe: 0x4801,
  9562. nmps: 9,
  9563. nlps: 14,
  9564. switchFlag: 0
  9565. }, {
  9566. qe: 0x3801,
  9567. nmps: 10,
  9568. nlps: 14,
  9569. switchFlag: 0
  9570. }, {
  9571. qe: 0x3001,
  9572. nmps: 11,
  9573. nlps: 17,
  9574. switchFlag: 0
  9575. }, {
  9576. qe: 0x2401,
  9577. nmps: 12,
  9578. nlps: 18,
  9579. switchFlag: 0
  9580. }, {
  9581. qe: 0x1c01,
  9582. nmps: 13,
  9583. nlps: 20,
  9584. switchFlag: 0
  9585. }, {
  9586. qe: 0x1601,
  9587. nmps: 29,
  9588. nlps: 21,
  9589. switchFlag: 0
  9590. }, {
  9591. qe: 0x5601,
  9592. nmps: 15,
  9593. nlps: 14,
  9594. switchFlag: 1
  9595. }, {
  9596. qe: 0x5401,
  9597. nmps: 16,
  9598. nlps: 14,
  9599. switchFlag: 0
  9600. }, {
  9601. qe: 0x5101,
  9602. nmps: 17,
  9603. nlps: 15,
  9604. switchFlag: 0
  9605. }, {
  9606. qe: 0x4801,
  9607. nmps: 18,
  9608. nlps: 16,
  9609. switchFlag: 0
  9610. }, {
  9611. qe: 0x3801,
  9612. nmps: 19,
  9613. nlps: 17,
  9614. switchFlag: 0
  9615. }, {
  9616. qe: 0x3401,
  9617. nmps: 20,
  9618. nlps: 18,
  9619. switchFlag: 0
  9620. }, {
  9621. qe: 0x3001,
  9622. nmps: 21,
  9623. nlps: 19,
  9624. switchFlag: 0
  9625. }, {
  9626. qe: 0x2801,
  9627. nmps: 22,
  9628. nlps: 19,
  9629. switchFlag: 0
  9630. }, {
  9631. qe: 0x2401,
  9632. nmps: 23,
  9633. nlps: 20,
  9634. switchFlag: 0
  9635. }, {
  9636. qe: 0x2201,
  9637. nmps: 24,
  9638. nlps: 21,
  9639. switchFlag: 0
  9640. }, {
  9641. qe: 0x1c01,
  9642. nmps: 25,
  9643. nlps: 22,
  9644. switchFlag: 0
  9645. }, {
  9646. qe: 0x1801,
  9647. nmps: 26,
  9648. nlps: 23,
  9649. switchFlag: 0
  9650. }, {
  9651. qe: 0x1601,
  9652. nmps: 27,
  9653. nlps: 24,
  9654. switchFlag: 0
  9655. }, {
  9656. qe: 0x1401,
  9657. nmps: 28,
  9658. nlps: 25,
  9659. switchFlag: 0
  9660. }, {
  9661. qe: 0x1201,
  9662. nmps: 29,
  9663. nlps: 26,
  9664. switchFlag: 0
  9665. }, {
  9666. qe: 0x1101,
  9667. nmps: 30,
  9668. nlps: 27,
  9669. switchFlag: 0
  9670. }, {
  9671. qe: 0x0ac1,
  9672. nmps: 31,
  9673. nlps: 28,
  9674. switchFlag: 0
  9675. }, {
  9676. qe: 0x09c1,
  9677. nmps: 32,
  9678. nlps: 29,
  9679. switchFlag: 0
  9680. }, {
  9681. qe: 0x08a1,
  9682. nmps: 33,
  9683. nlps: 30,
  9684. switchFlag: 0
  9685. }, {
  9686. qe: 0x0521,
  9687. nmps: 34,
  9688. nlps: 31,
  9689. switchFlag: 0
  9690. }, {
  9691. qe: 0x0441,
  9692. nmps: 35,
  9693. nlps: 32,
  9694. switchFlag: 0
  9695. }, {
  9696. qe: 0x02a1,
  9697. nmps: 36,
  9698. nlps: 33,
  9699. switchFlag: 0
  9700. }, {
  9701. qe: 0x0221,
  9702. nmps: 37,
  9703. nlps: 34,
  9704. switchFlag: 0
  9705. }, {
  9706. qe: 0x0141,
  9707. nmps: 38,
  9708. nlps: 35,
  9709. switchFlag: 0
  9710. }, {
  9711. qe: 0x0111,
  9712. nmps: 39,
  9713. nlps: 36,
  9714. switchFlag: 0
  9715. }, {
  9716. qe: 0x0085,
  9717. nmps: 40,
  9718. nlps: 37,
  9719. switchFlag: 0
  9720. }, {
  9721. qe: 0x0049,
  9722. nmps: 41,
  9723. nlps: 38,
  9724. switchFlag: 0
  9725. }, {
  9726. qe: 0x0025,
  9727. nmps: 42,
  9728. nlps: 39,
  9729. switchFlag: 0
  9730. }, {
  9731. qe: 0x0015,
  9732. nmps: 43,
  9733. nlps: 40,
  9734. switchFlag: 0
  9735. }, {
  9736. qe: 0x0009,
  9737. nmps: 44,
  9738. nlps: 41,
  9739. switchFlag: 0
  9740. }, {
  9741. qe: 0x0005,
  9742. nmps: 45,
  9743. nlps: 42,
  9744. switchFlag: 0
  9745. }, {
  9746. qe: 0x0001,
  9747. nmps: 45,
  9748. nlps: 43,
  9749. switchFlag: 0
  9750. }, {
  9751. qe: 0x5601,
  9752. nmps: 46,
  9753. nlps: 46,
  9754. switchFlag: 0
  9755. }];
  9756. class ArithmeticDecoder {
  9757. constructor(data, start, end) {
  9758. this.data = data;
  9759. this.bp = start;
  9760. this.dataEnd = end;
  9761. this.chigh = data[start];
  9762. this.clow = 0;
  9763. this.byteIn();
  9764. this.chigh = this.chigh << 7 & 0xffff | this.clow >> 9 & 0x7f;
  9765. this.clow = this.clow << 7 & 0xffff;
  9766. this.ct -= 7;
  9767. this.a = 0x8000;
  9768. }
  9769. byteIn() {
  9770. const data = this.data;
  9771. let bp = this.bp;
  9772. if (data[bp] === 0xff) {
  9773. if (data[bp + 1] > 0x8f) {
  9774. this.clow += 0xff00;
  9775. this.ct = 8;
  9776. } else {
  9777. bp++;
  9778. this.clow += data[bp] << 9;
  9779. this.ct = 7;
  9780. this.bp = bp;
  9781. }
  9782. } else {
  9783. bp++;
  9784. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xff00;
  9785. this.ct = 8;
  9786. this.bp = bp;
  9787. }
  9788. if (this.clow > 0xffff) {
  9789. this.chigh += this.clow >> 16;
  9790. this.clow &= 0xffff;
  9791. }
  9792. }
  9793. readBit(contexts, pos) {
  9794. let cx_index = contexts[pos] >> 1,
  9795. cx_mps = contexts[pos] & 1;
  9796. const qeTableIcx = QeTable[cx_index];
  9797. const qeIcx = qeTableIcx.qe;
  9798. let d;
  9799. let a = this.a - qeIcx;
  9800. if (this.chigh < qeIcx) {
  9801. if (a < qeIcx) {
  9802. a = qeIcx;
  9803. d = cx_mps;
  9804. cx_index = qeTableIcx.nmps;
  9805. } else {
  9806. a = qeIcx;
  9807. d = 1 ^ cx_mps;
  9808. if (qeTableIcx.switchFlag === 1) {
  9809. cx_mps = d;
  9810. }
  9811. cx_index = qeTableIcx.nlps;
  9812. }
  9813. } else {
  9814. this.chigh -= qeIcx;
  9815. if ((a & 0x8000) !== 0) {
  9816. this.a = a;
  9817. return cx_mps;
  9818. }
  9819. if (a < qeIcx) {
  9820. d = 1 ^ cx_mps;
  9821. if (qeTableIcx.switchFlag === 1) {
  9822. cx_mps = d;
  9823. }
  9824. cx_index = qeTableIcx.nlps;
  9825. } else {
  9826. d = cx_mps;
  9827. cx_index = qeTableIcx.nmps;
  9828. }
  9829. }
  9830. do {
  9831. if (this.ct === 0) {
  9832. this.byteIn();
  9833. }
  9834. a <<= 1;
  9835. this.chigh = this.chigh << 1 & 0xffff | this.clow >> 15 & 1;
  9836. this.clow = this.clow << 1 & 0xffff;
  9837. this.ct--;
  9838. } while ((a & 0x8000) === 0);
  9839. this.a = a;
  9840. contexts[pos] = cx_index << 1 | cx_mps;
  9841. return d;
  9842. }
  9843. }
  9844. exports.ArithmeticDecoder = ArithmeticDecoder;
  9845. /***/ }),
  9846. /* 18 */
  9847. /***/ (function(module, exports, __w_pdfjs_require__) {
  9848. "use strict";
  9849. Object.defineProperty(exports, "__esModule", {
  9850. value: true
  9851. });
  9852. exports.JpegStream = void 0;
  9853. var _stream = __w_pdfjs_require__(12);
  9854. var _primitives = __w_pdfjs_require__(5);
  9855. var _jpg = __w_pdfjs_require__(19);
  9856. var _util = __w_pdfjs_require__(2);
  9857. const JpegStream = function JpegStreamClosure() {
  9858. function JpegStream(stream, maybeLength, dict, params) {
  9859. let ch;
  9860. while ((ch = stream.getByte()) !== -1) {
  9861. if (ch === 0xff) {
  9862. stream.skip(-1);
  9863. break;
  9864. }
  9865. }
  9866. this.stream = stream;
  9867. this.maybeLength = maybeLength;
  9868. this.dict = dict;
  9869. this.params = params;
  9870. _stream.DecodeStream.call(this, maybeLength);
  9871. }
  9872. JpegStream.prototype = Object.create(_stream.DecodeStream.prototype);
  9873. Object.defineProperty(JpegStream.prototype, "bytes", {
  9874. get: function JpegStream_bytes() {
  9875. return (0, _util.shadow)(this, "bytes", this.stream.getBytes(this.maybeLength));
  9876. },
  9877. configurable: true
  9878. });
  9879. JpegStream.prototype.ensureBuffer = function (requested) {};
  9880. JpegStream.prototype.readBlock = function () {
  9881. if (this.eof) {
  9882. return;
  9883. }
  9884. const jpegOptions = {
  9885. decodeTransform: undefined,
  9886. colorTransform: undefined
  9887. };
  9888. const decodeArr = this.dict.getArray("Decode", "D");
  9889. if (this.forceRGB && Array.isArray(decodeArr)) {
  9890. const bitsPerComponent = this.dict.get("BitsPerComponent") || 8;
  9891. const decodeArrLength = decodeArr.length;
  9892. const transform = new Int32Array(decodeArrLength);
  9893. let transformNeeded = false;
  9894. const maxValue = (1 << bitsPerComponent) - 1;
  9895. for (let i = 0; i < decodeArrLength; i += 2) {
  9896. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  9897. transform[i + 1] = decodeArr[i] * maxValue | 0;
  9898. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  9899. transformNeeded = true;
  9900. }
  9901. }
  9902. if (transformNeeded) {
  9903. jpegOptions.decodeTransform = transform;
  9904. }
  9905. }
  9906. if ((0, _primitives.isDict)(this.params)) {
  9907. const colorTransform = this.params.get("ColorTransform");
  9908. if (Number.isInteger(colorTransform)) {
  9909. jpegOptions.colorTransform = colorTransform;
  9910. }
  9911. }
  9912. const jpegImage = new _jpg.JpegImage(jpegOptions);
  9913. jpegImage.parse(this.bytes);
  9914. const data = jpegImage.getData({
  9915. width: this.drawWidth,
  9916. height: this.drawHeight,
  9917. forceRGB: this.forceRGB,
  9918. isSourcePDF: true
  9919. });
  9920. this.buffer = data;
  9921. this.bufferLength = data.length;
  9922. this.eof = true;
  9923. };
  9924. return JpegStream;
  9925. }();
  9926. exports.JpegStream = JpegStream;
  9927. /***/ }),
  9928. /* 19 */
  9929. /***/ (function(module, exports, __w_pdfjs_require__) {
  9930. "use strict";
  9931. Object.defineProperty(exports, "__esModule", {
  9932. value: true
  9933. });
  9934. exports.JpegImage = void 0;
  9935. var _util = __w_pdfjs_require__(2);
  9936. var _core_utils = __w_pdfjs_require__(8);
  9937. class JpegError extends _util.BaseException {
  9938. constructor(msg) {
  9939. super(`JPEG error: ${msg}`);
  9940. }
  9941. }
  9942. class DNLMarkerError extends _util.BaseException {
  9943. constructor(message, scanLines) {
  9944. super(message);
  9945. this.scanLines = scanLines;
  9946. }
  9947. }
  9948. class EOIMarkerError extends _util.BaseException {}
  9949. var JpegImage = function JpegImageClosure() {
  9950. 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]);
  9951. var dctCos1 = 4017;
  9952. var dctSin1 = 799;
  9953. var dctCos3 = 3406;
  9954. var dctSin3 = 2276;
  9955. var dctCos6 = 1567;
  9956. var dctSin6 = 3784;
  9957. var dctSqrt2 = 5793;
  9958. var dctSqrt1d2 = 2896;
  9959. function JpegImage({
  9960. decodeTransform = null,
  9961. colorTransform = -1
  9962. } = {}) {
  9963. this._decodeTransform = decodeTransform;
  9964. this._colorTransform = colorTransform;
  9965. }
  9966. function buildHuffmanTable(codeLengths, values) {
  9967. var k = 0,
  9968. code = [],
  9969. i,
  9970. j,
  9971. length = 16;
  9972. while (length > 0 && !codeLengths[length - 1]) {
  9973. length--;
  9974. }
  9975. code.push({
  9976. children: [],
  9977. index: 0
  9978. });
  9979. var p = code[0],
  9980. q;
  9981. for (i = 0; i < length; i++) {
  9982. for (j = 0; j < codeLengths[i]; j++) {
  9983. p = code.pop();
  9984. p.children[p.index] = values[k];
  9985. while (p.index > 0) {
  9986. p = code.pop();
  9987. }
  9988. p.index++;
  9989. code.push(p);
  9990. while (code.length <= i) {
  9991. code.push(q = {
  9992. children: [],
  9993. index: 0
  9994. });
  9995. p.children[p.index] = q.children;
  9996. p = q;
  9997. }
  9998. k++;
  9999. }
  10000. if (i + 1 < length) {
  10001. code.push(q = {
  10002. children: [],
  10003. index: 0
  10004. });
  10005. p.children[p.index] = q.children;
  10006. p = q;
  10007. }
  10008. }
  10009. return code[0].children;
  10010. }
  10011. function getBlockBufferOffset(component, row, col) {
  10012. return 64 * ((component.blocksPerLine + 1) * row + col);
  10013. }
  10014. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive, parseDNLMarker = false) {
  10015. var mcusPerLine = frame.mcusPerLine;
  10016. var progressive = frame.progressive;
  10017. const startOffset = offset;
  10018. let bitsData = 0,
  10019. bitsCount = 0;
  10020. function readBit() {
  10021. if (bitsCount > 0) {
  10022. bitsCount--;
  10023. return bitsData >> bitsCount & 1;
  10024. }
  10025. bitsData = data[offset++];
  10026. if (bitsData === 0xff) {
  10027. var nextByte = data[offset++];
  10028. if (nextByte) {
  10029. if (nextByte === 0xdc && parseDNLMarker) {
  10030. offset += 2;
  10031. const scanLines = (0, _core_utils.readUint16)(data, offset);
  10032. offset += 2;
  10033. if (scanLines > 0 && scanLines !== frame.scanLines) {
  10034. throw new DNLMarkerError("Found DNL marker (0xFFDC) while parsing scan data", scanLines);
  10035. }
  10036. } else if (nextByte === 0xd9) {
  10037. if (parseDNLMarker) {
  10038. const maybeScanLines = blockRow * (frame.precision === 8 ? 8 : 0);
  10039. if (maybeScanLines > 0 && Math.round(frame.scanLines / maybeScanLines) >= 10) {
  10040. throw new DNLMarkerError("Found EOI marker (0xFFD9) while parsing scan data, " + "possibly caused by incorrect `scanLines` parameter", maybeScanLines);
  10041. }
  10042. }
  10043. throw new EOIMarkerError("Found EOI marker (0xFFD9) while parsing scan data");
  10044. }
  10045. throw new JpegError(`unexpected marker ${(bitsData << 8 | nextByte).toString(16)}`);
  10046. }
  10047. }
  10048. bitsCount = 7;
  10049. return bitsData >>> 7;
  10050. }
  10051. function decodeHuffman(tree) {
  10052. var node = tree;
  10053. while (true) {
  10054. node = node[readBit()];
  10055. switch (typeof node) {
  10056. case "number":
  10057. return node;
  10058. case "object":
  10059. continue;
  10060. }
  10061. throw new JpegError("invalid huffman sequence");
  10062. }
  10063. }
  10064. function receive(length) {
  10065. var n = 0;
  10066. while (length > 0) {
  10067. n = n << 1 | readBit();
  10068. length--;
  10069. }
  10070. return n;
  10071. }
  10072. function receiveAndExtend(length) {
  10073. if (length === 1) {
  10074. return readBit() === 1 ? 1 : -1;
  10075. }
  10076. var n = receive(length);
  10077. if (n >= 1 << length - 1) {
  10078. return n;
  10079. }
  10080. return n + (-1 << length) + 1;
  10081. }
  10082. function decodeBaseline(component, blockOffset) {
  10083. var t = decodeHuffman(component.huffmanTableDC);
  10084. var diff = t === 0 ? 0 : receiveAndExtend(t);
  10085. component.blockData[blockOffset] = component.pred += diff;
  10086. var k = 1;
  10087. while (k < 64) {
  10088. var rs = decodeHuffman(component.huffmanTableAC);
  10089. var s = rs & 15,
  10090. r = rs >> 4;
  10091. if (s === 0) {
  10092. if (r < 15) {
  10093. break;
  10094. }
  10095. k += 16;
  10096. continue;
  10097. }
  10098. k += r;
  10099. var z = dctZigZag[k];
  10100. component.blockData[blockOffset + z] = receiveAndExtend(s);
  10101. k++;
  10102. }
  10103. }
  10104. function decodeDCFirst(component, blockOffset) {
  10105. var t = decodeHuffman(component.huffmanTableDC);
  10106. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  10107. component.blockData[blockOffset] = component.pred += diff;
  10108. }
  10109. function decodeDCSuccessive(component, blockOffset) {
  10110. component.blockData[blockOffset] |= readBit() << successive;
  10111. }
  10112. var eobrun = 0;
  10113. function decodeACFirst(component, blockOffset) {
  10114. if (eobrun > 0) {
  10115. eobrun--;
  10116. return;
  10117. }
  10118. var k = spectralStart,
  10119. e = spectralEnd;
  10120. while (k <= e) {
  10121. var rs = decodeHuffman(component.huffmanTableAC);
  10122. var s = rs & 15,
  10123. r = rs >> 4;
  10124. if (s === 0) {
  10125. if (r < 15) {
  10126. eobrun = receive(r) + (1 << r) - 1;
  10127. break;
  10128. }
  10129. k += 16;
  10130. continue;
  10131. }
  10132. k += r;
  10133. var z = dctZigZag[k];
  10134. component.blockData[blockOffset + z] = receiveAndExtend(s) * (1 << successive);
  10135. k++;
  10136. }
  10137. }
  10138. var successiveACState = 0,
  10139. successiveACNextValue;
  10140. function decodeACSuccessive(component, blockOffset) {
  10141. var k = spectralStart;
  10142. var e = spectralEnd;
  10143. var r = 0;
  10144. var s;
  10145. var rs;
  10146. while (k <= e) {
  10147. const offsetZ = blockOffset + dctZigZag[k];
  10148. const sign = component.blockData[offsetZ] < 0 ? -1 : 1;
  10149. switch (successiveACState) {
  10150. case 0:
  10151. rs = decodeHuffman(component.huffmanTableAC);
  10152. s = rs & 15;
  10153. r = rs >> 4;
  10154. if (s === 0) {
  10155. if (r < 15) {
  10156. eobrun = receive(r) + (1 << r);
  10157. successiveACState = 4;
  10158. } else {
  10159. r = 16;
  10160. successiveACState = 1;
  10161. }
  10162. } else {
  10163. if (s !== 1) {
  10164. throw new JpegError("invalid ACn encoding");
  10165. }
  10166. successiveACNextValue = receiveAndExtend(s);
  10167. successiveACState = r ? 2 : 3;
  10168. }
  10169. continue;
  10170. case 1:
  10171. case 2:
  10172. if (component.blockData[offsetZ]) {
  10173. component.blockData[offsetZ] += sign * (readBit() << successive);
  10174. } else {
  10175. r--;
  10176. if (r === 0) {
  10177. successiveACState = successiveACState === 2 ? 3 : 0;
  10178. }
  10179. }
  10180. break;
  10181. case 3:
  10182. if (component.blockData[offsetZ]) {
  10183. component.blockData[offsetZ] += sign * (readBit() << successive);
  10184. } else {
  10185. component.blockData[offsetZ] = successiveACNextValue << successive;
  10186. successiveACState = 0;
  10187. }
  10188. break;
  10189. case 4:
  10190. if (component.blockData[offsetZ]) {
  10191. component.blockData[offsetZ] += sign * (readBit() << successive);
  10192. }
  10193. break;
  10194. }
  10195. k++;
  10196. }
  10197. if (successiveACState === 4) {
  10198. eobrun--;
  10199. if (eobrun === 0) {
  10200. successiveACState = 0;
  10201. }
  10202. }
  10203. }
  10204. let blockRow = 0;
  10205. function decodeMcu(component, decode, mcu, row, col) {
  10206. var mcuRow = mcu / mcusPerLine | 0;
  10207. var mcuCol = mcu % mcusPerLine;
  10208. blockRow = mcuRow * component.v + row;
  10209. var blockCol = mcuCol * component.h + col;
  10210. const blockOffset = getBlockBufferOffset(component, blockRow, blockCol);
  10211. decode(component, blockOffset);
  10212. }
  10213. function decodeBlock(component, decode, mcu) {
  10214. blockRow = mcu / component.blocksPerLine | 0;
  10215. var blockCol = mcu % component.blocksPerLine;
  10216. const blockOffset = getBlockBufferOffset(component, blockRow, blockCol);
  10217. decode(component, blockOffset);
  10218. }
  10219. var componentsLength = components.length;
  10220. var component, i, j, k, n;
  10221. var decodeFn;
  10222. if (progressive) {
  10223. if (spectralStart === 0) {
  10224. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  10225. } else {
  10226. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  10227. }
  10228. } else {
  10229. decodeFn = decodeBaseline;
  10230. }
  10231. var mcu = 0,
  10232. fileMarker;
  10233. var mcuExpected;
  10234. if (componentsLength === 1) {
  10235. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  10236. } else {
  10237. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  10238. }
  10239. var h, v;
  10240. while (mcu <= mcuExpected) {
  10241. var mcuToRead = resetInterval ? Math.min(mcuExpected - mcu, resetInterval) : mcuExpected;
  10242. if (mcuToRead > 0) {
  10243. for (i = 0; i < componentsLength; i++) {
  10244. components[i].pred = 0;
  10245. }
  10246. eobrun = 0;
  10247. if (componentsLength === 1) {
  10248. component = components[0];
  10249. for (n = 0; n < mcuToRead; n++) {
  10250. decodeBlock(component, decodeFn, mcu);
  10251. mcu++;
  10252. }
  10253. } else {
  10254. for (n = 0; n < mcuToRead; n++) {
  10255. for (i = 0; i < componentsLength; i++) {
  10256. component = components[i];
  10257. h = component.h;
  10258. v = component.v;
  10259. for (j = 0; j < v; j++) {
  10260. for (k = 0; k < h; k++) {
  10261. decodeMcu(component, decodeFn, mcu, j, k);
  10262. }
  10263. }
  10264. }
  10265. mcu++;
  10266. }
  10267. }
  10268. }
  10269. bitsCount = 0;
  10270. fileMarker = findNextFileMarker(data, offset);
  10271. if (!fileMarker) {
  10272. break;
  10273. }
  10274. if (fileMarker.invalid) {
  10275. const partialMsg = mcuToRead > 0 ? "unexpected" : "excessive";
  10276. (0, _util.warn)(`decodeScan - ${partialMsg} MCU data, current marker is: ${fileMarker.invalid}`);
  10277. offset = fileMarker.offset;
  10278. }
  10279. if (fileMarker.marker >= 0xffd0 && fileMarker.marker <= 0xffd7) {
  10280. offset += 2;
  10281. } else {
  10282. break;
  10283. }
  10284. }
  10285. return offset - startOffset;
  10286. }
  10287. function quantizeAndInverse(component, blockBufferOffset, p) {
  10288. var qt = component.quantizationTable,
  10289. blockData = component.blockData;
  10290. var v0, v1, v2, v3, v4, v5, v6, v7;
  10291. var p0, p1, p2, p3, p4, p5, p6, p7;
  10292. var t;
  10293. if (!qt) {
  10294. throw new JpegError("missing required Quantization Table.");
  10295. }
  10296. for (var row = 0; row < 64; row += 8) {
  10297. p0 = blockData[blockBufferOffset + row];
  10298. p1 = blockData[blockBufferOffset + row + 1];
  10299. p2 = blockData[blockBufferOffset + row + 2];
  10300. p3 = blockData[blockBufferOffset + row + 3];
  10301. p4 = blockData[blockBufferOffset + row + 4];
  10302. p5 = blockData[blockBufferOffset + row + 5];
  10303. p6 = blockData[blockBufferOffset + row + 6];
  10304. p7 = blockData[blockBufferOffset + row + 7];
  10305. p0 *= qt[row];
  10306. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  10307. t = dctSqrt2 * p0 + 512 >> 10;
  10308. p[row] = t;
  10309. p[row + 1] = t;
  10310. p[row + 2] = t;
  10311. p[row + 3] = t;
  10312. p[row + 4] = t;
  10313. p[row + 5] = t;
  10314. p[row + 6] = t;
  10315. p[row + 7] = t;
  10316. continue;
  10317. }
  10318. p1 *= qt[row + 1];
  10319. p2 *= qt[row + 2];
  10320. p3 *= qt[row + 3];
  10321. p4 *= qt[row + 4];
  10322. p5 *= qt[row + 5];
  10323. p6 *= qt[row + 6];
  10324. p7 *= qt[row + 7];
  10325. v0 = dctSqrt2 * p0 + 128 >> 8;
  10326. v1 = dctSqrt2 * p4 + 128 >> 8;
  10327. v2 = p2;
  10328. v3 = p6;
  10329. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  10330. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  10331. v5 = p3 << 4;
  10332. v6 = p5 << 4;
  10333. v0 = v0 + v1 + 1 >> 1;
  10334. v1 = v0 - v1;
  10335. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  10336. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  10337. v3 = t;
  10338. v4 = v4 + v6 + 1 >> 1;
  10339. v6 = v4 - v6;
  10340. v7 = v7 + v5 + 1 >> 1;
  10341. v5 = v7 - v5;
  10342. v0 = v0 + v3 + 1 >> 1;
  10343. v3 = v0 - v3;
  10344. v1 = v1 + v2 + 1 >> 1;
  10345. v2 = v1 - v2;
  10346. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  10347. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  10348. v7 = t;
  10349. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  10350. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  10351. v6 = t;
  10352. p[row] = v0 + v7;
  10353. p[row + 7] = v0 - v7;
  10354. p[row + 1] = v1 + v6;
  10355. p[row + 6] = v1 - v6;
  10356. p[row + 2] = v2 + v5;
  10357. p[row + 5] = v2 - v5;
  10358. p[row + 3] = v3 + v4;
  10359. p[row + 4] = v3 - v4;
  10360. }
  10361. for (var col = 0; col < 8; ++col) {
  10362. p0 = p[col];
  10363. p1 = p[col + 8];
  10364. p2 = p[col + 16];
  10365. p3 = p[col + 24];
  10366. p4 = p[col + 32];
  10367. p5 = p[col + 40];
  10368. p6 = p[col + 48];
  10369. p7 = p[col + 56];
  10370. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  10371. t = dctSqrt2 * p0 + 8192 >> 14;
  10372. if (t < -2040) {
  10373. t = 0;
  10374. } else if (t >= 2024) {
  10375. t = 255;
  10376. } else {
  10377. t = t + 2056 >> 4;
  10378. }
  10379. blockData[blockBufferOffset + col] = t;
  10380. blockData[blockBufferOffset + col + 8] = t;
  10381. blockData[blockBufferOffset + col + 16] = t;
  10382. blockData[blockBufferOffset + col + 24] = t;
  10383. blockData[blockBufferOffset + col + 32] = t;
  10384. blockData[blockBufferOffset + col + 40] = t;
  10385. blockData[blockBufferOffset + col + 48] = t;
  10386. blockData[blockBufferOffset + col + 56] = t;
  10387. continue;
  10388. }
  10389. v0 = dctSqrt2 * p0 + 2048 >> 12;
  10390. v1 = dctSqrt2 * p4 + 2048 >> 12;
  10391. v2 = p2;
  10392. v3 = p6;
  10393. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  10394. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  10395. v5 = p3;
  10396. v6 = p5;
  10397. v0 = (v0 + v1 + 1 >> 1) + 4112;
  10398. v1 = v0 - v1;
  10399. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  10400. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  10401. v3 = t;
  10402. v4 = v4 + v6 + 1 >> 1;
  10403. v6 = v4 - v6;
  10404. v7 = v7 + v5 + 1 >> 1;
  10405. v5 = v7 - v5;
  10406. v0 = v0 + v3 + 1 >> 1;
  10407. v3 = v0 - v3;
  10408. v1 = v1 + v2 + 1 >> 1;
  10409. v2 = v1 - v2;
  10410. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  10411. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  10412. v7 = t;
  10413. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  10414. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  10415. v6 = t;
  10416. p0 = v0 + v7;
  10417. p7 = v0 - v7;
  10418. p1 = v1 + v6;
  10419. p6 = v1 - v6;
  10420. p2 = v2 + v5;
  10421. p5 = v2 - v5;
  10422. p3 = v3 + v4;
  10423. p4 = v3 - v4;
  10424. if (p0 < 16) {
  10425. p0 = 0;
  10426. } else if (p0 >= 4080) {
  10427. p0 = 255;
  10428. } else {
  10429. p0 >>= 4;
  10430. }
  10431. if (p1 < 16) {
  10432. p1 = 0;
  10433. } else if (p1 >= 4080) {
  10434. p1 = 255;
  10435. } else {
  10436. p1 >>= 4;
  10437. }
  10438. if (p2 < 16) {
  10439. p2 = 0;
  10440. } else if (p2 >= 4080) {
  10441. p2 = 255;
  10442. } else {
  10443. p2 >>= 4;
  10444. }
  10445. if (p3 < 16) {
  10446. p3 = 0;
  10447. } else if (p3 >= 4080) {
  10448. p3 = 255;
  10449. } else {
  10450. p3 >>= 4;
  10451. }
  10452. if (p4 < 16) {
  10453. p4 = 0;
  10454. } else if (p4 >= 4080) {
  10455. p4 = 255;
  10456. } else {
  10457. p4 >>= 4;
  10458. }
  10459. if (p5 < 16) {
  10460. p5 = 0;
  10461. } else if (p5 >= 4080) {
  10462. p5 = 255;
  10463. } else {
  10464. p5 >>= 4;
  10465. }
  10466. if (p6 < 16) {
  10467. p6 = 0;
  10468. } else if (p6 >= 4080) {
  10469. p6 = 255;
  10470. } else {
  10471. p6 >>= 4;
  10472. }
  10473. if (p7 < 16) {
  10474. p7 = 0;
  10475. } else if (p7 >= 4080) {
  10476. p7 = 255;
  10477. } else {
  10478. p7 >>= 4;
  10479. }
  10480. blockData[blockBufferOffset + col] = p0;
  10481. blockData[blockBufferOffset + col + 8] = p1;
  10482. blockData[blockBufferOffset + col + 16] = p2;
  10483. blockData[blockBufferOffset + col + 24] = p3;
  10484. blockData[blockBufferOffset + col + 32] = p4;
  10485. blockData[blockBufferOffset + col + 40] = p5;
  10486. blockData[blockBufferOffset + col + 48] = p6;
  10487. blockData[blockBufferOffset + col + 56] = p7;
  10488. }
  10489. }
  10490. function buildComponentData(frame, component) {
  10491. var blocksPerLine = component.blocksPerLine;
  10492. var blocksPerColumn = component.blocksPerColumn;
  10493. var computationBuffer = new Int16Array(64);
  10494. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  10495. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  10496. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  10497. quantizeAndInverse(component, offset, computationBuffer);
  10498. }
  10499. }
  10500. return component.blockData;
  10501. }
  10502. function findNextFileMarker(data, currentPos, startPos = currentPos) {
  10503. const maxPos = data.length - 1;
  10504. var newPos = startPos < currentPos ? startPos : currentPos;
  10505. if (currentPos >= maxPos) {
  10506. return null;
  10507. }
  10508. var currentMarker = (0, _core_utils.readUint16)(data, currentPos);
  10509. if (currentMarker >= 0xffc0 && currentMarker <= 0xfffe) {
  10510. return {
  10511. invalid: null,
  10512. marker: currentMarker,
  10513. offset: currentPos
  10514. };
  10515. }
  10516. var newMarker = (0, _core_utils.readUint16)(data, newPos);
  10517. while (!(newMarker >= 0xffc0 && newMarker <= 0xfffe)) {
  10518. if (++newPos >= maxPos) {
  10519. return null;
  10520. }
  10521. newMarker = (0, _core_utils.readUint16)(data, newPos);
  10522. }
  10523. return {
  10524. invalid: currentMarker.toString(16),
  10525. marker: newMarker,
  10526. offset: newPos
  10527. };
  10528. }
  10529. JpegImage.prototype = {
  10530. parse(data, {
  10531. dnlScanLines = null
  10532. } = {}) {
  10533. function readDataBlock() {
  10534. const length = (0, _core_utils.readUint16)(data, offset);
  10535. offset += 2;
  10536. let endOffset = offset + length - 2;
  10537. var fileMarker = findNextFileMarker(data, endOffset, offset);
  10538. if (fileMarker && fileMarker.invalid) {
  10539. (0, _util.warn)("readDataBlock - incorrect length, current marker is: " + fileMarker.invalid);
  10540. endOffset = fileMarker.offset;
  10541. }
  10542. var array = data.subarray(offset, endOffset);
  10543. offset += array.length;
  10544. return array;
  10545. }
  10546. function prepareComponents(frame) {
  10547. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  10548. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  10549. for (var i = 0; i < frame.components.length; i++) {
  10550. component = frame.components[i];
  10551. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  10552. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  10553. var blocksPerLineForMcu = mcusPerLine * component.h;
  10554. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  10555. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  10556. component.blockData = new Int16Array(blocksBufferSize);
  10557. component.blocksPerLine = blocksPerLine;
  10558. component.blocksPerColumn = blocksPerColumn;
  10559. }
  10560. frame.mcusPerLine = mcusPerLine;
  10561. frame.mcusPerColumn = mcusPerColumn;
  10562. }
  10563. var offset = 0;
  10564. var jfif = null;
  10565. var adobe = null;
  10566. var frame, resetInterval;
  10567. let numSOSMarkers = 0;
  10568. var quantizationTables = [];
  10569. var huffmanTablesAC = [],
  10570. huffmanTablesDC = [];
  10571. let fileMarker = (0, _core_utils.readUint16)(data, offset);
  10572. offset += 2;
  10573. if (fileMarker !== 0xffd8) {
  10574. throw new JpegError("SOI not found");
  10575. }
  10576. fileMarker = (0, _core_utils.readUint16)(data, offset);
  10577. offset += 2;
  10578. markerLoop: while (fileMarker !== 0xffd9) {
  10579. var i, j, l;
  10580. switch (fileMarker) {
  10581. case 0xffe0:
  10582. case 0xffe1:
  10583. case 0xffe2:
  10584. case 0xffe3:
  10585. case 0xffe4:
  10586. case 0xffe5:
  10587. case 0xffe6:
  10588. case 0xffe7:
  10589. case 0xffe8:
  10590. case 0xffe9:
  10591. case 0xffea:
  10592. case 0xffeb:
  10593. case 0xffec:
  10594. case 0xffed:
  10595. case 0xffee:
  10596. case 0xffef:
  10597. case 0xfffe:
  10598. var appData = readDataBlock();
  10599. if (fileMarker === 0xffe0) {
  10600. if (appData[0] === 0x4a && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  10601. jfif = {
  10602. version: {
  10603. major: appData[5],
  10604. minor: appData[6]
  10605. },
  10606. densityUnits: appData[7],
  10607. xDensity: appData[8] << 8 | appData[9],
  10608. yDensity: appData[10] << 8 | appData[11],
  10609. thumbWidth: appData[12],
  10610. thumbHeight: appData[13],
  10611. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  10612. };
  10613. }
  10614. }
  10615. if (fileMarker === 0xffee) {
  10616. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6f && appData[3] === 0x62 && appData[4] === 0x65) {
  10617. adobe = {
  10618. version: appData[5] << 8 | appData[6],
  10619. flags0: appData[7] << 8 | appData[8],
  10620. flags1: appData[9] << 8 | appData[10],
  10621. transformCode: appData[11]
  10622. };
  10623. }
  10624. }
  10625. break;
  10626. case 0xffdb:
  10627. const quantizationTablesLength = (0, _core_utils.readUint16)(data, offset);
  10628. offset += 2;
  10629. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  10630. var z;
  10631. while (offset < quantizationTablesEnd) {
  10632. var quantizationTableSpec = data[offset++];
  10633. var tableData = new Uint16Array(64);
  10634. if (quantizationTableSpec >> 4 === 0) {
  10635. for (j = 0; j < 64; j++) {
  10636. z = dctZigZag[j];
  10637. tableData[z] = data[offset++];
  10638. }
  10639. } else if (quantizationTableSpec >> 4 === 1) {
  10640. for (j = 0; j < 64; j++) {
  10641. z = dctZigZag[j];
  10642. tableData[z] = (0, _core_utils.readUint16)(data, offset);
  10643. offset += 2;
  10644. }
  10645. } else {
  10646. throw new JpegError("DQT - invalid table spec");
  10647. }
  10648. quantizationTables[quantizationTableSpec & 15] = tableData;
  10649. }
  10650. break;
  10651. case 0xffc0:
  10652. case 0xffc1:
  10653. case 0xffc2:
  10654. if (frame) {
  10655. throw new JpegError("Only single frame JPEGs supported");
  10656. }
  10657. offset += 2;
  10658. frame = {};
  10659. frame.extended = fileMarker === 0xffc1;
  10660. frame.progressive = fileMarker === 0xffc2;
  10661. frame.precision = data[offset++];
  10662. const sofScanLines = (0, _core_utils.readUint16)(data, offset);
  10663. offset += 2;
  10664. frame.scanLines = dnlScanLines || sofScanLines;
  10665. frame.samplesPerLine = (0, _core_utils.readUint16)(data, offset);
  10666. offset += 2;
  10667. frame.components = [];
  10668. frame.componentIds = {};
  10669. var componentsCount = data[offset++],
  10670. componentId;
  10671. var maxH = 0,
  10672. maxV = 0;
  10673. for (i = 0; i < componentsCount; i++) {
  10674. componentId = data[offset];
  10675. var h = data[offset + 1] >> 4;
  10676. var v = data[offset + 1] & 15;
  10677. if (maxH < h) {
  10678. maxH = h;
  10679. }
  10680. if (maxV < v) {
  10681. maxV = v;
  10682. }
  10683. var qId = data[offset + 2];
  10684. l = frame.components.push({
  10685. h,
  10686. v,
  10687. quantizationId: qId,
  10688. quantizationTable: null
  10689. });
  10690. frame.componentIds[componentId] = l - 1;
  10691. offset += 3;
  10692. }
  10693. frame.maxH = maxH;
  10694. frame.maxV = maxV;
  10695. prepareComponents(frame);
  10696. break;
  10697. case 0xffc4:
  10698. const huffmanLength = (0, _core_utils.readUint16)(data, offset);
  10699. offset += 2;
  10700. for (i = 2; i < huffmanLength;) {
  10701. var huffmanTableSpec = data[offset++];
  10702. var codeLengths = new Uint8Array(16);
  10703. var codeLengthSum = 0;
  10704. for (j = 0; j < 16; j++, offset++) {
  10705. codeLengthSum += codeLengths[j] = data[offset];
  10706. }
  10707. var huffmanValues = new Uint8Array(codeLengthSum);
  10708. for (j = 0; j < codeLengthSum; j++, offset++) {
  10709. huffmanValues[j] = data[offset];
  10710. }
  10711. i += 17 + codeLengthSum;
  10712. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  10713. }
  10714. break;
  10715. case 0xffdd:
  10716. offset += 2;
  10717. resetInterval = (0, _core_utils.readUint16)(data, offset);
  10718. offset += 2;
  10719. break;
  10720. case 0xffda:
  10721. const parseDNLMarker = ++numSOSMarkers === 1 && !dnlScanLines;
  10722. offset += 2;
  10723. var selectorsCount = data[offset++];
  10724. var components = [],
  10725. component;
  10726. for (i = 0; i < selectorsCount; i++) {
  10727. const index = data[offset++];
  10728. var componentIndex = frame.componentIds[index];
  10729. component = frame.components[componentIndex];
  10730. component.index = index;
  10731. var tableSpec = data[offset++];
  10732. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  10733. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  10734. components.push(component);
  10735. }
  10736. var spectralStart = data[offset++];
  10737. var spectralEnd = data[offset++];
  10738. var successiveApproximation = data[offset++];
  10739. try {
  10740. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15, parseDNLMarker);
  10741. offset += processed;
  10742. } catch (ex) {
  10743. if (ex instanceof DNLMarkerError) {
  10744. (0, _util.warn)(`${ex.message} -- attempting to re-parse the JPEG image.`);
  10745. return this.parse(data, {
  10746. dnlScanLines: ex.scanLines
  10747. });
  10748. } else if (ex instanceof EOIMarkerError) {
  10749. (0, _util.warn)(`${ex.message} -- ignoring the rest of the image data.`);
  10750. break markerLoop;
  10751. }
  10752. throw ex;
  10753. }
  10754. break;
  10755. case 0xffdc:
  10756. offset += 4;
  10757. break;
  10758. case 0xffff:
  10759. if (data[offset] !== 0xff) {
  10760. offset--;
  10761. }
  10762. break;
  10763. default:
  10764. const nextFileMarker = findNextFileMarker(data, offset - 2, offset - 3);
  10765. if (nextFileMarker && nextFileMarker.invalid) {
  10766. (0, _util.warn)("JpegImage.parse - unexpected data, current marker is: " + nextFileMarker.invalid);
  10767. offset = nextFileMarker.offset;
  10768. break;
  10769. }
  10770. if (offset >= data.length - 1) {
  10771. (0, _util.warn)("JpegImage.parse - reached the end of the image data " + "without finding an EOI marker (0xFFD9).");
  10772. break markerLoop;
  10773. }
  10774. throw new JpegError("JpegImage.parse - unknown marker: " + fileMarker.toString(16));
  10775. }
  10776. fileMarker = (0, _core_utils.readUint16)(data, offset);
  10777. offset += 2;
  10778. }
  10779. this.width = frame.samplesPerLine;
  10780. this.height = frame.scanLines;
  10781. this.jfif = jfif;
  10782. this.adobe = adobe;
  10783. this.components = [];
  10784. for (i = 0; i < frame.components.length; i++) {
  10785. component = frame.components[i];
  10786. var quantizationTable = quantizationTables[component.quantizationId];
  10787. if (quantizationTable) {
  10788. component.quantizationTable = quantizationTable;
  10789. }
  10790. this.components.push({
  10791. index: component.index,
  10792. output: buildComponentData(frame, component),
  10793. scaleX: component.h / frame.maxH,
  10794. scaleY: component.v / frame.maxV,
  10795. blocksPerLine: component.blocksPerLine,
  10796. blocksPerColumn: component.blocksPerColumn
  10797. });
  10798. }
  10799. this.numComponents = this.components.length;
  10800. return undefined;
  10801. },
  10802. _getLinearizedBlockData(width, height, isSourcePDF = false) {
  10803. var scaleX = this.width / width,
  10804. scaleY = this.height / height;
  10805. var component, componentScaleX, componentScaleY, blocksPerScanline;
  10806. var x, y, i, j, k;
  10807. var index;
  10808. var offset = 0;
  10809. var output;
  10810. var numComponents = this.components.length;
  10811. var dataLength = width * height * numComponents;
  10812. var data = new Uint8ClampedArray(dataLength);
  10813. var xScaleBlockOffset = new Uint32Array(width);
  10814. var mask3LSB = 0xfffffff8;
  10815. let lastComponentScaleX;
  10816. for (i = 0; i < numComponents; i++) {
  10817. component = this.components[i];
  10818. componentScaleX = component.scaleX * scaleX;
  10819. componentScaleY = component.scaleY * scaleY;
  10820. offset = i;
  10821. output = component.output;
  10822. blocksPerScanline = component.blocksPerLine + 1 << 3;
  10823. if (componentScaleX !== lastComponentScaleX) {
  10824. for (x = 0; x < width; x++) {
  10825. j = 0 | x * componentScaleX;
  10826. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  10827. }
  10828. lastComponentScaleX = componentScaleX;
  10829. }
  10830. for (y = 0; y < height; y++) {
  10831. j = 0 | y * componentScaleY;
  10832. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  10833. for (x = 0; x < width; x++) {
  10834. data[offset] = output[index + xScaleBlockOffset[x]];
  10835. offset += numComponents;
  10836. }
  10837. }
  10838. }
  10839. let transform = this._decodeTransform;
  10840. if (!isSourcePDF && numComponents === 4 && !transform) {
  10841. transform = new Int32Array([-256, 255, -256, 255, -256, 255, -256, 255]);
  10842. }
  10843. if (transform) {
  10844. for (i = 0; i < dataLength;) {
  10845. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  10846. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  10847. }
  10848. }
  10849. }
  10850. return data;
  10851. },
  10852. get _isColorConversionNeeded() {
  10853. if (this.adobe) {
  10854. return !!this.adobe.transformCode;
  10855. }
  10856. if (this.numComponents === 3) {
  10857. if (this._colorTransform === 0) {
  10858. return false;
  10859. } else if (this.components[0].index === 0x52 && this.components[1].index === 0x47 && this.components[2].index === 0x42) {
  10860. return false;
  10861. }
  10862. return true;
  10863. }
  10864. if (this._colorTransform === 1) {
  10865. return true;
  10866. }
  10867. return false;
  10868. },
  10869. _convertYccToRgb: function convertYccToRgb(data) {
  10870. var Y, Cb, Cr;
  10871. for (var i = 0, length = data.length; i < length; i += 3) {
  10872. Y = data[i];
  10873. Cb = data[i + 1];
  10874. Cr = data[i + 2];
  10875. data[i] = Y - 179.456 + 1.402 * Cr;
  10876. data[i + 1] = Y + 135.459 - 0.344 * Cb - 0.714 * Cr;
  10877. data[i + 2] = Y - 226.816 + 1.772 * Cb;
  10878. }
  10879. return data;
  10880. },
  10881. _convertYcckToRgb: function convertYcckToRgb(data) {
  10882. var Y, Cb, Cr, k;
  10883. var offset = 0;
  10884. for (var i = 0, length = data.length; i < length; i += 4) {
  10885. Y = data[i];
  10886. Cb = data[i + 1];
  10887. Cr = data[i + 2];
  10888. k = data[i + 3];
  10889. 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);
  10890. 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);
  10891. 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);
  10892. }
  10893. return data.subarray(0, offset);
  10894. },
  10895. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  10896. var Y, Cb, Cr;
  10897. for (var i = 0, length = data.length; i < length; i += 4) {
  10898. Y = data[i];
  10899. Cb = data[i + 1];
  10900. Cr = data[i + 2];
  10901. data[i] = 434.456 - Y - 1.402 * Cr;
  10902. data[i + 1] = 119.541 - Y + 0.344 * Cb + 0.714 * Cr;
  10903. data[i + 2] = 481.816 - Y - 1.772 * Cb;
  10904. }
  10905. return data;
  10906. },
  10907. _convertCmykToRgb: function convertCmykToRgb(data) {
  10908. var c, m, y, k;
  10909. var offset = 0;
  10910. for (var i = 0, length = data.length; i < length; i += 4) {
  10911. c = data[i];
  10912. m = data[i + 1];
  10913. y = data[i + 2];
  10914. k = data[i + 3];
  10915. 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);
  10916. 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.00031891311758832814 * k + 0.7364883807733168);
  10917. 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);
  10918. }
  10919. return data.subarray(0, offset);
  10920. },
  10921. getData({
  10922. width,
  10923. height,
  10924. forceRGB = false,
  10925. isSourcePDF = false
  10926. }) {
  10927. if (this.numComponents > 4) {
  10928. throw new JpegError("Unsupported color mode");
  10929. }
  10930. var data = this._getLinearizedBlockData(width, height, isSourcePDF);
  10931. if (this.numComponents === 1 && forceRGB) {
  10932. var dataLength = data.length;
  10933. var rgbData = new Uint8ClampedArray(dataLength * 3);
  10934. var offset = 0;
  10935. for (var i = 0; i < dataLength; i++) {
  10936. var grayColor = data[i];
  10937. rgbData[offset++] = grayColor;
  10938. rgbData[offset++] = grayColor;
  10939. rgbData[offset++] = grayColor;
  10940. }
  10941. return rgbData;
  10942. } else if (this.numComponents === 3 && this._isColorConversionNeeded) {
  10943. return this._convertYccToRgb(data);
  10944. } else if (this.numComponents === 4) {
  10945. if (this._isColorConversionNeeded) {
  10946. if (forceRGB) {
  10947. return this._convertYcckToRgb(data);
  10948. }
  10949. return this._convertYcckToCmyk(data);
  10950. } else if (forceRGB) {
  10951. return this._convertCmykToRgb(data);
  10952. }
  10953. }
  10954. return data;
  10955. }
  10956. };
  10957. return JpegImage;
  10958. }();
  10959. exports.JpegImage = JpegImage;
  10960. /***/ }),
  10961. /* 20 */
  10962. /***/ (function(module, exports, __w_pdfjs_require__) {
  10963. "use strict";
  10964. Object.defineProperty(exports, "__esModule", {
  10965. value: true
  10966. });
  10967. exports.JpxStream = void 0;
  10968. var _stream = __w_pdfjs_require__(12);
  10969. var _jpx = __w_pdfjs_require__(21);
  10970. var _util = __w_pdfjs_require__(2);
  10971. const JpxStream = function JpxStreamClosure() {
  10972. function JpxStream(stream, maybeLength, dict, params) {
  10973. this.stream = stream;
  10974. this.maybeLength = maybeLength;
  10975. this.dict = dict;
  10976. this.params = params;
  10977. _stream.DecodeStream.call(this, maybeLength);
  10978. }
  10979. JpxStream.prototype = Object.create(_stream.DecodeStream.prototype);
  10980. Object.defineProperty(JpxStream.prototype, "bytes", {
  10981. get: function JpxStream_bytes() {
  10982. return (0, _util.shadow)(this, "bytes", this.stream.getBytes(this.maybeLength));
  10983. },
  10984. configurable: true
  10985. });
  10986. JpxStream.prototype.ensureBuffer = function (requested) {};
  10987. JpxStream.prototype.readBlock = function () {
  10988. if (this.eof) {
  10989. return;
  10990. }
  10991. const jpxImage = new _jpx.JpxImage();
  10992. jpxImage.parse(this.bytes);
  10993. const width = jpxImage.width;
  10994. const height = jpxImage.height;
  10995. const componentsCount = jpxImage.componentsCount;
  10996. const tileCount = jpxImage.tiles.length;
  10997. if (tileCount === 1) {
  10998. this.buffer = jpxImage.tiles[0].items;
  10999. } else {
  11000. const data = new Uint8ClampedArray(width * height * componentsCount);
  11001. for (let k = 0; k < tileCount; k++) {
  11002. const tileComponents = jpxImage.tiles[k];
  11003. const tileWidth = tileComponents.width;
  11004. const tileHeight = tileComponents.height;
  11005. const tileLeft = tileComponents.left;
  11006. const tileTop = tileComponents.top;
  11007. const src = tileComponents.items;
  11008. let srcPosition = 0;
  11009. let dataPosition = (width * tileTop + tileLeft) * componentsCount;
  11010. const imgRowSize = width * componentsCount;
  11011. const tileRowSize = tileWidth * componentsCount;
  11012. for (let j = 0; j < tileHeight; j++) {
  11013. const rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  11014. data.set(rowBytes, dataPosition);
  11015. srcPosition += tileRowSize;
  11016. dataPosition += imgRowSize;
  11017. }
  11018. }
  11019. this.buffer = data;
  11020. }
  11021. this.bufferLength = this.buffer.length;
  11022. this.eof = true;
  11023. };
  11024. return JpxStream;
  11025. }();
  11026. exports.JpxStream = JpxStream;
  11027. /***/ }),
  11028. /* 21 */
  11029. /***/ (function(module, exports, __w_pdfjs_require__) {
  11030. "use strict";
  11031. Object.defineProperty(exports, "__esModule", {
  11032. value: true
  11033. });
  11034. exports.JpxImage = void 0;
  11035. var _util = __w_pdfjs_require__(2);
  11036. var _core_utils = __w_pdfjs_require__(8);
  11037. var _arithmetic_decoder = __w_pdfjs_require__(17);
  11038. class JpxError extends _util.BaseException {
  11039. constructor(msg) {
  11040. super(`JPX error: ${msg}`);
  11041. }
  11042. }
  11043. var JpxImage = function JpxImageClosure() {
  11044. var SubbandsGainLog2 = {
  11045. LL: 0,
  11046. LH: 1,
  11047. HL: 1,
  11048. HH: 2
  11049. };
  11050. function JpxImage() {
  11051. this.failOnCorruptedImage = false;
  11052. }
  11053. JpxImage.prototype = {
  11054. parse: function JpxImage_parse(data) {
  11055. var head = (0, _core_utils.readUint16)(data, 0);
  11056. if (head === 0xff4f) {
  11057. this.parseCodestream(data, 0, data.length);
  11058. return;
  11059. }
  11060. var position = 0,
  11061. length = data.length;
  11062. while (position < length) {
  11063. var headerSize = 8;
  11064. var lbox = (0, _core_utils.readUint32)(data, position);
  11065. var tbox = (0, _core_utils.readUint32)(data, position + 4);
  11066. position += headerSize;
  11067. if (lbox === 1) {
  11068. lbox = (0, _core_utils.readUint32)(data, position) * 4294967296 + (0, _core_utils.readUint32)(data, position + 4);
  11069. position += 8;
  11070. headerSize += 8;
  11071. }
  11072. if (lbox === 0) {
  11073. lbox = length - position + headerSize;
  11074. }
  11075. if (lbox < headerSize) {
  11076. throw new JpxError("Invalid box field size");
  11077. }
  11078. var dataLength = lbox - headerSize;
  11079. var jumpDataLength = true;
  11080. switch (tbox) {
  11081. case 0x6a703268:
  11082. jumpDataLength = false;
  11083. break;
  11084. case 0x636f6c72:
  11085. var method = data[position];
  11086. if (method === 1) {
  11087. var colorspace = (0, _core_utils.readUint32)(data, position + 3);
  11088. switch (colorspace) {
  11089. case 16:
  11090. case 17:
  11091. case 18:
  11092. break;
  11093. default:
  11094. (0, _util.warn)("Unknown colorspace " + colorspace);
  11095. break;
  11096. }
  11097. } else if (method === 2) {
  11098. (0, _util.info)("ICC profile not supported");
  11099. }
  11100. break;
  11101. case 0x6a703263:
  11102. this.parseCodestream(data, position, position + dataLength);
  11103. break;
  11104. case 0x6a502020:
  11105. if ((0, _core_utils.readUint32)(data, position) !== 0x0d0a870a) {
  11106. (0, _util.warn)("Invalid JP2 signature");
  11107. }
  11108. break;
  11109. case 0x6a501a1a:
  11110. case 0x66747970:
  11111. case 0x72726571:
  11112. case 0x72657320:
  11113. case 0x69686472:
  11114. break;
  11115. default:
  11116. var headerType = String.fromCharCode(tbox >> 24 & 0xff, tbox >> 16 & 0xff, tbox >> 8 & 0xff, tbox & 0xff);
  11117. (0, _util.warn)("Unsupported header type " + tbox + " (" + headerType + ")");
  11118. break;
  11119. }
  11120. if (jumpDataLength) {
  11121. position += dataLength;
  11122. }
  11123. }
  11124. },
  11125. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  11126. var newByte = stream.getByte();
  11127. while (newByte >= 0) {
  11128. var oldByte = newByte;
  11129. newByte = stream.getByte();
  11130. var code = oldByte << 8 | newByte;
  11131. if (code === 0xff51) {
  11132. stream.skip(4);
  11133. var Xsiz = stream.getInt32() >>> 0;
  11134. var Ysiz = stream.getInt32() >>> 0;
  11135. var XOsiz = stream.getInt32() >>> 0;
  11136. var YOsiz = stream.getInt32() >>> 0;
  11137. stream.skip(16);
  11138. var Csiz = stream.getUint16();
  11139. this.width = Xsiz - XOsiz;
  11140. this.height = Ysiz - YOsiz;
  11141. this.componentsCount = Csiz;
  11142. this.bitsPerComponent = 8;
  11143. return;
  11144. }
  11145. }
  11146. throw new JpxError("No size marker found in JPX stream");
  11147. },
  11148. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  11149. var context = {};
  11150. var doNotRecover = false;
  11151. try {
  11152. var position = start;
  11153. while (position + 1 < end) {
  11154. var code = (0, _core_utils.readUint16)(data, position);
  11155. position += 2;
  11156. var length = 0,
  11157. j,
  11158. sqcd,
  11159. spqcds,
  11160. spqcdSize,
  11161. scalarExpounded,
  11162. tile;
  11163. switch (code) {
  11164. case 0xff4f:
  11165. context.mainHeader = true;
  11166. break;
  11167. case 0xffd9:
  11168. break;
  11169. case 0xff51:
  11170. length = (0, _core_utils.readUint16)(data, position);
  11171. var siz = {};
  11172. siz.Xsiz = (0, _core_utils.readUint32)(data, position + 4);
  11173. siz.Ysiz = (0, _core_utils.readUint32)(data, position + 8);
  11174. siz.XOsiz = (0, _core_utils.readUint32)(data, position + 12);
  11175. siz.YOsiz = (0, _core_utils.readUint32)(data, position + 16);
  11176. siz.XTsiz = (0, _core_utils.readUint32)(data, position + 20);
  11177. siz.YTsiz = (0, _core_utils.readUint32)(data, position + 24);
  11178. siz.XTOsiz = (0, _core_utils.readUint32)(data, position + 28);
  11179. siz.YTOsiz = (0, _core_utils.readUint32)(data, position + 32);
  11180. var componentsCount = (0, _core_utils.readUint16)(data, position + 36);
  11181. siz.Csiz = componentsCount;
  11182. var components = [];
  11183. j = position + 38;
  11184. for (var i = 0; i < componentsCount; i++) {
  11185. var component = {
  11186. precision: (data[j] & 0x7f) + 1,
  11187. isSigned: !!(data[j] & 0x80),
  11188. XRsiz: data[j + 1],
  11189. YRsiz: data[j + 2]
  11190. };
  11191. j += 3;
  11192. calculateComponentDimensions(component, siz);
  11193. components.push(component);
  11194. }
  11195. context.SIZ = siz;
  11196. context.components = components;
  11197. calculateTileGrids(context, components);
  11198. context.QCC = [];
  11199. context.COC = [];
  11200. break;
  11201. case 0xff5c:
  11202. length = (0, _core_utils.readUint16)(data, position);
  11203. var qcd = {};
  11204. j = position + 2;
  11205. sqcd = data[j++];
  11206. switch (sqcd & 0x1f) {
  11207. case 0:
  11208. spqcdSize = 8;
  11209. scalarExpounded = true;
  11210. break;
  11211. case 1:
  11212. spqcdSize = 16;
  11213. scalarExpounded = false;
  11214. break;
  11215. case 2:
  11216. spqcdSize = 16;
  11217. scalarExpounded = true;
  11218. break;
  11219. default:
  11220. throw new Error("Invalid SQcd value " + sqcd);
  11221. }
  11222. qcd.noQuantization = spqcdSize === 8;
  11223. qcd.scalarExpounded = scalarExpounded;
  11224. qcd.guardBits = sqcd >> 5;
  11225. spqcds = [];
  11226. while (j < length + position) {
  11227. var spqcd = {};
  11228. if (spqcdSize === 8) {
  11229. spqcd.epsilon = data[j++] >> 3;
  11230. spqcd.mu = 0;
  11231. } else {
  11232. spqcd.epsilon = data[j] >> 3;
  11233. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  11234. j += 2;
  11235. }
  11236. spqcds.push(spqcd);
  11237. }
  11238. qcd.SPqcds = spqcds;
  11239. if (context.mainHeader) {
  11240. context.QCD = qcd;
  11241. } else {
  11242. context.currentTile.QCD = qcd;
  11243. context.currentTile.QCC = [];
  11244. }
  11245. break;
  11246. case 0xff5d:
  11247. length = (0, _core_utils.readUint16)(data, position);
  11248. var qcc = {};
  11249. j = position + 2;
  11250. var cqcc;
  11251. if (context.SIZ.Csiz < 257) {
  11252. cqcc = data[j++];
  11253. } else {
  11254. cqcc = (0, _core_utils.readUint16)(data, j);
  11255. j += 2;
  11256. }
  11257. sqcd = data[j++];
  11258. switch (sqcd & 0x1f) {
  11259. case 0:
  11260. spqcdSize = 8;
  11261. scalarExpounded = true;
  11262. break;
  11263. case 1:
  11264. spqcdSize = 16;
  11265. scalarExpounded = false;
  11266. break;
  11267. case 2:
  11268. spqcdSize = 16;
  11269. scalarExpounded = true;
  11270. break;
  11271. default:
  11272. throw new Error("Invalid SQcd value " + sqcd);
  11273. }
  11274. qcc.noQuantization = spqcdSize === 8;
  11275. qcc.scalarExpounded = scalarExpounded;
  11276. qcc.guardBits = sqcd >> 5;
  11277. spqcds = [];
  11278. while (j < length + position) {
  11279. spqcd = {};
  11280. if (spqcdSize === 8) {
  11281. spqcd.epsilon = data[j++] >> 3;
  11282. spqcd.mu = 0;
  11283. } else {
  11284. spqcd.epsilon = data[j] >> 3;
  11285. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  11286. j += 2;
  11287. }
  11288. spqcds.push(spqcd);
  11289. }
  11290. qcc.SPqcds = spqcds;
  11291. if (context.mainHeader) {
  11292. context.QCC[cqcc] = qcc;
  11293. } else {
  11294. context.currentTile.QCC[cqcc] = qcc;
  11295. }
  11296. break;
  11297. case 0xff52:
  11298. length = (0, _core_utils.readUint16)(data, position);
  11299. var cod = {};
  11300. j = position + 2;
  11301. var scod = data[j++];
  11302. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  11303. cod.sopMarkerUsed = !!(scod & 2);
  11304. cod.ephMarkerUsed = !!(scod & 4);
  11305. cod.progressionOrder = data[j++];
  11306. cod.layersCount = (0, _core_utils.readUint16)(data, j);
  11307. j += 2;
  11308. cod.multipleComponentTransform = data[j++];
  11309. cod.decompositionLevelsCount = data[j++];
  11310. cod.xcb = (data[j++] & 0xf) + 2;
  11311. cod.ycb = (data[j++] & 0xf) + 2;
  11312. var blockStyle = data[j++];
  11313. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  11314. cod.resetContextProbabilities = !!(blockStyle & 2);
  11315. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  11316. cod.verticallyStripe = !!(blockStyle & 8);
  11317. cod.predictableTermination = !!(blockStyle & 16);
  11318. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  11319. cod.reversibleTransformation = data[j++];
  11320. if (cod.entropyCoderWithCustomPrecincts) {
  11321. var precinctsSizes = [];
  11322. while (j < length + position) {
  11323. var precinctsSize = data[j++];
  11324. precinctsSizes.push({
  11325. PPx: precinctsSize & 0xf,
  11326. PPy: precinctsSize >> 4
  11327. });
  11328. }
  11329. cod.precinctsSizes = precinctsSizes;
  11330. }
  11331. var unsupported = [];
  11332. if (cod.selectiveArithmeticCodingBypass) {
  11333. unsupported.push("selectiveArithmeticCodingBypass");
  11334. }
  11335. if (cod.resetContextProbabilities) {
  11336. unsupported.push("resetContextProbabilities");
  11337. }
  11338. if (cod.terminationOnEachCodingPass) {
  11339. unsupported.push("terminationOnEachCodingPass");
  11340. }
  11341. if (cod.verticallyStripe) {
  11342. unsupported.push("verticallyStripe");
  11343. }
  11344. if (cod.predictableTermination) {
  11345. unsupported.push("predictableTermination");
  11346. }
  11347. if (unsupported.length > 0) {
  11348. doNotRecover = true;
  11349. throw new Error("Unsupported COD options (" + unsupported.join(", ") + ")");
  11350. }
  11351. if (context.mainHeader) {
  11352. context.COD = cod;
  11353. } else {
  11354. context.currentTile.COD = cod;
  11355. context.currentTile.COC = [];
  11356. }
  11357. break;
  11358. case 0xff90:
  11359. length = (0, _core_utils.readUint16)(data, position);
  11360. tile = {};
  11361. tile.index = (0, _core_utils.readUint16)(data, position + 2);
  11362. tile.length = (0, _core_utils.readUint32)(data, position + 4);
  11363. tile.dataEnd = tile.length + position - 2;
  11364. tile.partIndex = data[position + 8];
  11365. tile.partsCount = data[position + 9];
  11366. context.mainHeader = false;
  11367. if (tile.partIndex === 0) {
  11368. tile.COD = context.COD;
  11369. tile.COC = context.COC.slice(0);
  11370. tile.QCD = context.QCD;
  11371. tile.QCC = context.QCC.slice(0);
  11372. }
  11373. context.currentTile = tile;
  11374. break;
  11375. case 0xff93:
  11376. tile = context.currentTile;
  11377. if (tile.partIndex === 0) {
  11378. initializeTile(context, tile.index);
  11379. buildPackets(context);
  11380. }
  11381. length = tile.dataEnd - position;
  11382. parseTilePackets(context, data, position, length);
  11383. break;
  11384. case 0xff55:
  11385. case 0xff57:
  11386. case 0xff58:
  11387. case 0xff64:
  11388. length = (0, _core_utils.readUint16)(data, position);
  11389. break;
  11390. case 0xff53:
  11391. throw new Error("Codestream code 0xFF53 (COC) is not implemented");
  11392. default:
  11393. throw new Error("Unknown codestream code: " + code.toString(16));
  11394. }
  11395. position += length;
  11396. }
  11397. } catch (e) {
  11398. if (doNotRecover || this.failOnCorruptedImage) {
  11399. throw new JpxError(e.message);
  11400. } else {
  11401. (0, _util.warn)("JPX: Trying to recover from: " + e.message);
  11402. }
  11403. }
  11404. this.tiles = transformComponents(context);
  11405. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  11406. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  11407. this.componentsCount = context.SIZ.Csiz;
  11408. }
  11409. };
  11410. function calculateComponentDimensions(component, siz) {
  11411. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  11412. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  11413. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  11414. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  11415. component.width = component.x1 - component.x0;
  11416. component.height = component.y1 - component.y0;
  11417. }
  11418. function calculateTileGrids(context, components) {
  11419. var siz = context.SIZ;
  11420. var tile,
  11421. tiles = [];
  11422. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  11423. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  11424. for (var q = 0; q < numYtiles; q++) {
  11425. for (var p = 0; p < numXtiles; p++) {
  11426. tile = {};
  11427. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  11428. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  11429. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  11430. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  11431. tile.width = tile.tx1 - tile.tx0;
  11432. tile.height = tile.ty1 - tile.ty0;
  11433. tile.components = [];
  11434. tiles.push(tile);
  11435. }
  11436. }
  11437. context.tiles = tiles;
  11438. var componentsCount = siz.Csiz;
  11439. for (var i = 0, ii = componentsCount; i < ii; i++) {
  11440. var component = components[i];
  11441. for (var j = 0, jj = tiles.length; j < jj; j++) {
  11442. var tileComponent = {};
  11443. tile = tiles[j];
  11444. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  11445. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  11446. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  11447. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  11448. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  11449. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  11450. tile.components[i] = tileComponent;
  11451. }
  11452. }
  11453. }
  11454. function getBlocksDimensions(context, component, r) {
  11455. var codOrCoc = component.codingStyleParameters;
  11456. var result = {};
  11457. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  11458. result.PPx = 15;
  11459. result.PPy = 15;
  11460. } else {
  11461. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  11462. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  11463. }
  11464. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  11465. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  11466. return result;
  11467. }
  11468. function buildPrecincts(context, resolution, dimensions) {
  11469. var precinctWidth = 1 << dimensions.PPx;
  11470. var precinctHeight = 1 << dimensions.PPy;
  11471. var isZeroRes = resolution.resLevel === 0;
  11472. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  11473. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  11474. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  11475. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  11476. var numprecincts = numprecinctswide * numprecinctshigh;
  11477. resolution.precinctParameters = {
  11478. precinctWidth,
  11479. precinctHeight,
  11480. numprecinctswide,
  11481. numprecinctshigh,
  11482. numprecincts,
  11483. precinctWidthInSubband,
  11484. precinctHeightInSubband
  11485. };
  11486. }
  11487. function buildCodeblocks(context, subband, dimensions) {
  11488. var xcb_ = dimensions.xcb_;
  11489. var ycb_ = dimensions.ycb_;
  11490. var codeblockWidth = 1 << xcb_;
  11491. var codeblockHeight = 1 << ycb_;
  11492. var cbx0 = subband.tbx0 >> xcb_;
  11493. var cby0 = subband.tby0 >> ycb_;
  11494. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  11495. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  11496. var precinctParameters = subband.resolution.precinctParameters;
  11497. var codeblocks = [];
  11498. var precincts = [];
  11499. var i, j, codeblock, precinctNumber;
  11500. for (j = cby0; j < cby1; j++) {
  11501. for (i = cbx0; i < cbx1; i++) {
  11502. codeblock = {
  11503. cbx: i,
  11504. cby: j,
  11505. tbx0: codeblockWidth * i,
  11506. tby0: codeblockHeight * j,
  11507. tbx1: codeblockWidth * (i + 1),
  11508. tby1: codeblockHeight * (j + 1)
  11509. };
  11510. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  11511. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  11512. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  11513. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  11514. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  11515. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  11516. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  11517. codeblock.precinctNumber = precinctNumber;
  11518. codeblock.subbandType = subband.type;
  11519. codeblock.Lblock = 3;
  11520. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  11521. continue;
  11522. }
  11523. codeblocks.push(codeblock);
  11524. var precinct = precincts[precinctNumber];
  11525. if (precinct !== undefined) {
  11526. if (i < precinct.cbxMin) {
  11527. precinct.cbxMin = i;
  11528. } else if (i > precinct.cbxMax) {
  11529. precinct.cbxMax = i;
  11530. }
  11531. if (j < precinct.cbyMin) {
  11532. precinct.cbxMin = j;
  11533. } else if (j > precinct.cbyMax) {
  11534. precinct.cbyMax = j;
  11535. }
  11536. } else {
  11537. precincts[precinctNumber] = precinct = {
  11538. cbxMin: i,
  11539. cbyMin: j,
  11540. cbxMax: i,
  11541. cbyMax: j
  11542. };
  11543. }
  11544. codeblock.precinct = precinct;
  11545. }
  11546. }
  11547. subband.codeblockParameters = {
  11548. codeblockWidth: xcb_,
  11549. codeblockHeight: ycb_,
  11550. numcodeblockwide: cbx1 - cbx0 + 1,
  11551. numcodeblockhigh: cby1 - cby0 + 1
  11552. };
  11553. subband.codeblocks = codeblocks;
  11554. subband.precincts = precincts;
  11555. }
  11556. function createPacket(resolution, precinctNumber, layerNumber) {
  11557. var precinctCodeblocks = [];
  11558. var subbands = resolution.subbands;
  11559. for (var i = 0, ii = subbands.length; i < ii; i++) {
  11560. var subband = subbands[i];
  11561. var codeblocks = subband.codeblocks;
  11562. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  11563. var codeblock = codeblocks[j];
  11564. if (codeblock.precinctNumber !== precinctNumber) {
  11565. continue;
  11566. }
  11567. precinctCodeblocks.push(codeblock);
  11568. }
  11569. }
  11570. return {
  11571. layerNumber,
  11572. codeblocks: precinctCodeblocks
  11573. };
  11574. }
  11575. function LayerResolutionComponentPositionIterator(context) {
  11576. var siz = context.SIZ;
  11577. var tileIndex = context.currentTile.index;
  11578. var tile = context.tiles[tileIndex];
  11579. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  11580. var componentsCount = siz.Csiz;
  11581. var maxDecompositionLevelsCount = 0;
  11582. for (var q = 0; q < componentsCount; q++) {
  11583. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  11584. }
  11585. var l = 0,
  11586. r = 0,
  11587. i = 0,
  11588. k = 0;
  11589. this.nextPacket = function JpxImage_nextPacket() {
  11590. for (; l < layersCount; l++) {
  11591. for (; r <= maxDecompositionLevelsCount; r++) {
  11592. for (; i < componentsCount; i++) {
  11593. var component = tile.components[i];
  11594. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  11595. continue;
  11596. }
  11597. var resolution = component.resolutions[r];
  11598. var numprecincts = resolution.precinctParameters.numprecincts;
  11599. for (; k < numprecincts;) {
  11600. var packet = createPacket(resolution, k, l);
  11601. k++;
  11602. return packet;
  11603. }
  11604. k = 0;
  11605. }
  11606. i = 0;
  11607. }
  11608. r = 0;
  11609. }
  11610. throw new JpxError("Out of packets");
  11611. };
  11612. }
  11613. function ResolutionLayerComponentPositionIterator(context) {
  11614. var siz = context.SIZ;
  11615. var tileIndex = context.currentTile.index;
  11616. var tile = context.tiles[tileIndex];
  11617. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  11618. var componentsCount = siz.Csiz;
  11619. var maxDecompositionLevelsCount = 0;
  11620. for (var q = 0; q < componentsCount; q++) {
  11621. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  11622. }
  11623. var r = 0,
  11624. l = 0,
  11625. i = 0,
  11626. k = 0;
  11627. this.nextPacket = function JpxImage_nextPacket() {
  11628. for (; r <= maxDecompositionLevelsCount; r++) {
  11629. for (; l < layersCount; l++) {
  11630. for (; i < componentsCount; i++) {
  11631. var component = tile.components[i];
  11632. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  11633. continue;
  11634. }
  11635. var resolution = component.resolutions[r];
  11636. var numprecincts = resolution.precinctParameters.numprecincts;
  11637. for (; k < numprecincts;) {
  11638. var packet = createPacket(resolution, k, l);
  11639. k++;
  11640. return packet;
  11641. }
  11642. k = 0;
  11643. }
  11644. i = 0;
  11645. }
  11646. l = 0;
  11647. }
  11648. throw new JpxError("Out of packets");
  11649. };
  11650. }
  11651. function ResolutionPositionComponentLayerIterator(context) {
  11652. var siz = context.SIZ;
  11653. var tileIndex = context.currentTile.index;
  11654. var tile = context.tiles[tileIndex];
  11655. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  11656. var componentsCount = siz.Csiz;
  11657. var l, r, c, p;
  11658. var maxDecompositionLevelsCount = 0;
  11659. for (c = 0; c < componentsCount; c++) {
  11660. const component = tile.components[c];
  11661. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  11662. }
  11663. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  11664. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  11665. var maxNumPrecincts = 0;
  11666. for (c = 0; c < componentsCount; ++c) {
  11667. var resolutions = tile.components[c].resolutions;
  11668. if (r < resolutions.length) {
  11669. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  11670. }
  11671. }
  11672. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  11673. }
  11674. l = 0;
  11675. r = 0;
  11676. c = 0;
  11677. p = 0;
  11678. this.nextPacket = function JpxImage_nextPacket() {
  11679. for (; r <= maxDecompositionLevelsCount; r++) {
  11680. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  11681. for (; c < componentsCount; c++) {
  11682. const component = tile.components[c];
  11683. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  11684. continue;
  11685. }
  11686. var resolution = component.resolutions[r];
  11687. var numprecincts = resolution.precinctParameters.numprecincts;
  11688. if (p >= numprecincts) {
  11689. continue;
  11690. }
  11691. for (; l < layersCount;) {
  11692. var packet = createPacket(resolution, p, l);
  11693. l++;
  11694. return packet;
  11695. }
  11696. l = 0;
  11697. }
  11698. c = 0;
  11699. }
  11700. p = 0;
  11701. }
  11702. throw new JpxError("Out of packets");
  11703. };
  11704. }
  11705. function PositionComponentResolutionLayerIterator(context) {
  11706. var siz = context.SIZ;
  11707. var tileIndex = context.currentTile.index;
  11708. var tile = context.tiles[tileIndex];
  11709. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  11710. var componentsCount = siz.Csiz;
  11711. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  11712. var precinctsIterationSizes = precinctsSizes;
  11713. var l = 0,
  11714. r = 0,
  11715. c = 0,
  11716. px = 0,
  11717. py = 0;
  11718. this.nextPacket = function JpxImage_nextPacket() {
  11719. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  11720. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  11721. for (; c < componentsCount; c++) {
  11722. var component = tile.components[c];
  11723. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  11724. for (; r <= decompositionLevelsCount; r++) {
  11725. var resolution = component.resolutions[r];
  11726. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  11727. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  11728. if (k === null) {
  11729. continue;
  11730. }
  11731. for (; l < layersCount;) {
  11732. var packet = createPacket(resolution, k, l);
  11733. l++;
  11734. return packet;
  11735. }
  11736. l = 0;
  11737. }
  11738. r = 0;
  11739. }
  11740. c = 0;
  11741. }
  11742. px = 0;
  11743. }
  11744. throw new JpxError("Out of packets");
  11745. };
  11746. }
  11747. function ComponentPositionResolutionLayerIterator(context) {
  11748. var siz = context.SIZ;
  11749. var tileIndex = context.currentTile.index;
  11750. var tile = context.tiles[tileIndex];
  11751. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  11752. var componentsCount = siz.Csiz;
  11753. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  11754. var l = 0,
  11755. r = 0,
  11756. c = 0,
  11757. px = 0,
  11758. py = 0;
  11759. this.nextPacket = function JpxImage_nextPacket() {
  11760. for (; c < componentsCount; ++c) {
  11761. var component = tile.components[c];
  11762. var precinctsIterationSizes = precinctsSizes.components[c];
  11763. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  11764. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  11765. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  11766. for (; r <= decompositionLevelsCount; r++) {
  11767. var resolution = component.resolutions[r];
  11768. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  11769. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  11770. if (k === null) {
  11771. continue;
  11772. }
  11773. for (; l < layersCount;) {
  11774. var packet = createPacket(resolution, k, l);
  11775. l++;
  11776. return packet;
  11777. }
  11778. l = 0;
  11779. }
  11780. r = 0;
  11781. }
  11782. px = 0;
  11783. }
  11784. py = 0;
  11785. }
  11786. throw new JpxError("Out of packets");
  11787. };
  11788. }
  11789. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  11790. var posX = pxIndex * precinctIterationSizes.minWidth;
  11791. var posY = pyIndex * precinctIterationSizes.minHeight;
  11792. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  11793. return null;
  11794. }
  11795. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  11796. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  11797. }
  11798. function getPrecinctSizesInImageScale(tile) {
  11799. var componentsCount = tile.components.length;
  11800. var minWidth = Number.MAX_VALUE;
  11801. var minHeight = Number.MAX_VALUE;
  11802. var maxNumWide = 0;
  11803. var maxNumHigh = 0;
  11804. var sizePerComponent = new Array(componentsCount);
  11805. for (var c = 0; c < componentsCount; c++) {
  11806. var component = tile.components[c];
  11807. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  11808. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  11809. var minWidthCurrentComponent = Number.MAX_VALUE;
  11810. var minHeightCurrentComponent = Number.MAX_VALUE;
  11811. var maxNumWideCurrentComponent = 0;
  11812. var maxNumHighCurrentComponent = 0;
  11813. var scale = 1;
  11814. for (var r = decompositionLevelsCount; r >= 0; --r) {
  11815. var resolution = component.resolutions[r];
  11816. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  11817. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  11818. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  11819. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  11820. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  11821. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  11822. sizePerResolution[r] = {
  11823. width: widthCurrentResolution,
  11824. height: heightCurrentResolution
  11825. };
  11826. scale <<= 1;
  11827. }
  11828. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  11829. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  11830. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  11831. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  11832. sizePerComponent[c] = {
  11833. resolutions: sizePerResolution,
  11834. minWidth: minWidthCurrentComponent,
  11835. minHeight: minHeightCurrentComponent,
  11836. maxNumWide: maxNumWideCurrentComponent,
  11837. maxNumHigh: maxNumHighCurrentComponent
  11838. };
  11839. }
  11840. return {
  11841. components: sizePerComponent,
  11842. minWidth,
  11843. minHeight,
  11844. maxNumWide,
  11845. maxNumHigh
  11846. };
  11847. }
  11848. function buildPackets(context) {
  11849. var siz = context.SIZ;
  11850. var tileIndex = context.currentTile.index;
  11851. var tile = context.tiles[tileIndex];
  11852. var componentsCount = siz.Csiz;
  11853. for (var c = 0; c < componentsCount; c++) {
  11854. var component = tile.components[c];
  11855. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  11856. var resolutions = [];
  11857. var subbands = [];
  11858. for (var r = 0; r <= decompositionLevelsCount; r++) {
  11859. var blocksDimensions = getBlocksDimensions(context, component, r);
  11860. var resolution = {};
  11861. var scale = 1 << decompositionLevelsCount - r;
  11862. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  11863. resolution.try0 = Math.ceil(component.tcy0 / scale);
  11864. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  11865. resolution.try1 = Math.ceil(component.tcy1 / scale);
  11866. resolution.resLevel = r;
  11867. buildPrecincts(context, resolution, blocksDimensions);
  11868. resolutions.push(resolution);
  11869. var subband;
  11870. if (r === 0) {
  11871. subband = {};
  11872. subband.type = "LL";
  11873. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  11874. subband.tby0 = Math.ceil(component.tcy0 / scale);
  11875. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  11876. subband.tby1 = Math.ceil(component.tcy1 / scale);
  11877. subband.resolution = resolution;
  11878. buildCodeblocks(context, subband, blocksDimensions);
  11879. subbands.push(subband);
  11880. resolution.subbands = [subband];
  11881. } else {
  11882. var bscale = 1 << decompositionLevelsCount - r + 1;
  11883. var resolutionSubbands = [];
  11884. subband = {};
  11885. subband.type = "HL";
  11886. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  11887. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  11888. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  11889. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  11890. subband.resolution = resolution;
  11891. buildCodeblocks(context, subband, blocksDimensions);
  11892. subbands.push(subband);
  11893. resolutionSubbands.push(subband);
  11894. subband = {};
  11895. subband.type = "LH";
  11896. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  11897. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  11898. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  11899. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  11900. subband.resolution = resolution;
  11901. buildCodeblocks(context, subband, blocksDimensions);
  11902. subbands.push(subband);
  11903. resolutionSubbands.push(subband);
  11904. subband = {};
  11905. subband.type = "HH";
  11906. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  11907. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  11908. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  11909. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  11910. subband.resolution = resolution;
  11911. buildCodeblocks(context, subband, blocksDimensions);
  11912. subbands.push(subband);
  11913. resolutionSubbands.push(subband);
  11914. resolution.subbands = resolutionSubbands;
  11915. }
  11916. }
  11917. component.resolutions = resolutions;
  11918. component.subbands = subbands;
  11919. }
  11920. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  11921. switch (progressionOrder) {
  11922. case 0:
  11923. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  11924. break;
  11925. case 1:
  11926. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  11927. break;
  11928. case 2:
  11929. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  11930. break;
  11931. case 3:
  11932. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  11933. break;
  11934. case 4:
  11935. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  11936. break;
  11937. default:
  11938. throw new JpxError(`Unsupported progression order ${progressionOrder}`);
  11939. }
  11940. }
  11941. function parseTilePackets(context, data, offset, dataLength) {
  11942. var position = 0;
  11943. var buffer,
  11944. bufferSize = 0,
  11945. skipNextBit = false;
  11946. function readBits(count) {
  11947. while (bufferSize < count) {
  11948. var b = data[offset + position];
  11949. position++;
  11950. if (skipNextBit) {
  11951. buffer = buffer << 7 | b;
  11952. bufferSize += 7;
  11953. skipNextBit = false;
  11954. } else {
  11955. buffer = buffer << 8 | b;
  11956. bufferSize += 8;
  11957. }
  11958. if (b === 0xff) {
  11959. skipNextBit = true;
  11960. }
  11961. }
  11962. bufferSize -= count;
  11963. return buffer >>> bufferSize & (1 << count) - 1;
  11964. }
  11965. function skipMarkerIfEqual(value) {
  11966. if (data[offset + position - 1] === 0xff && data[offset + position] === value) {
  11967. skipBytes(1);
  11968. return true;
  11969. } else if (data[offset + position] === 0xff && data[offset + position + 1] === value) {
  11970. skipBytes(2);
  11971. return true;
  11972. }
  11973. return false;
  11974. }
  11975. function skipBytes(count) {
  11976. position += count;
  11977. }
  11978. function alignToByte() {
  11979. bufferSize = 0;
  11980. if (skipNextBit) {
  11981. position++;
  11982. skipNextBit = false;
  11983. }
  11984. }
  11985. function readCodingpasses() {
  11986. if (readBits(1) === 0) {
  11987. return 1;
  11988. }
  11989. if (readBits(1) === 0) {
  11990. return 2;
  11991. }
  11992. var value = readBits(2);
  11993. if (value < 3) {
  11994. return value + 3;
  11995. }
  11996. value = readBits(5);
  11997. if (value < 31) {
  11998. return value + 6;
  11999. }
  12000. value = readBits(7);
  12001. return value + 37;
  12002. }
  12003. var tileIndex = context.currentTile.index;
  12004. var tile = context.tiles[tileIndex];
  12005. var sopMarkerUsed = context.COD.sopMarkerUsed;
  12006. var ephMarkerUsed = context.COD.ephMarkerUsed;
  12007. var packetsIterator = tile.packetsIterator;
  12008. while (position < dataLength) {
  12009. alignToByte();
  12010. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  12011. skipBytes(4);
  12012. }
  12013. var packet = packetsIterator.nextPacket();
  12014. if (!readBits(1)) {
  12015. continue;
  12016. }
  12017. var layerNumber = packet.layerNumber;
  12018. var queue = [],
  12019. codeblock;
  12020. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  12021. codeblock = packet.codeblocks[i];
  12022. var precinct = codeblock.precinct;
  12023. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  12024. var codeblockRow = codeblock.cby - precinct.cbyMin;
  12025. var codeblockIncluded = false;
  12026. var firstTimeInclusion = false;
  12027. var valueReady;
  12028. if (codeblock.included !== undefined) {
  12029. codeblockIncluded = !!readBits(1);
  12030. } else {
  12031. precinct = codeblock.precinct;
  12032. var inclusionTree, zeroBitPlanesTree;
  12033. if (precinct.inclusionTree !== undefined) {
  12034. inclusionTree = precinct.inclusionTree;
  12035. } else {
  12036. var width = precinct.cbxMax - precinct.cbxMin + 1;
  12037. var height = precinct.cbyMax - precinct.cbyMin + 1;
  12038. inclusionTree = new InclusionTree(width, height, layerNumber);
  12039. zeroBitPlanesTree = new TagTree(width, height);
  12040. precinct.inclusionTree = inclusionTree;
  12041. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  12042. }
  12043. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  12044. while (true) {
  12045. if (readBits(1)) {
  12046. valueReady = !inclusionTree.nextLevel();
  12047. if (valueReady) {
  12048. codeblock.included = true;
  12049. codeblockIncluded = firstTimeInclusion = true;
  12050. break;
  12051. }
  12052. } else {
  12053. inclusionTree.incrementValue(layerNumber);
  12054. break;
  12055. }
  12056. }
  12057. }
  12058. }
  12059. if (!codeblockIncluded) {
  12060. continue;
  12061. }
  12062. if (firstTimeInclusion) {
  12063. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  12064. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  12065. while (true) {
  12066. if (readBits(1)) {
  12067. valueReady = !zeroBitPlanesTree.nextLevel();
  12068. if (valueReady) {
  12069. break;
  12070. }
  12071. } else {
  12072. zeroBitPlanesTree.incrementValue();
  12073. }
  12074. }
  12075. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  12076. }
  12077. var codingpasses = readCodingpasses();
  12078. while (readBits(1)) {
  12079. codeblock.Lblock++;
  12080. }
  12081. var codingpassesLog2 = (0, _core_utils.log2)(codingpasses);
  12082. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  12083. var codedDataLength = readBits(bits);
  12084. queue.push({
  12085. codeblock,
  12086. codingpasses,
  12087. dataLength: codedDataLength
  12088. });
  12089. }
  12090. alignToByte();
  12091. if (ephMarkerUsed) {
  12092. skipMarkerIfEqual(0x92);
  12093. }
  12094. while (queue.length > 0) {
  12095. var packetItem = queue.shift();
  12096. codeblock = packetItem.codeblock;
  12097. if (codeblock.data === undefined) {
  12098. codeblock.data = [];
  12099. }
  12100. codeblock.data.push({
  12101. data,
  12102. start: offset + position,
  12103. end: offset + position + packetItem.dataLength,
  12104. codingpasses: packetItem.codingpasses
  12105. });
  12106. position += packetItem.dataLength;
  12107. }
  12108. }
  12109. return position;
  12110. }
  12111. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  12112. var x0 = subband.tbx0;
  12113. var y0 = subband.tby0;
  12114. var width = subband.tbx1 - subband.tbx0;
  12115. var codeblocks = subband.codeblocks;
  12116. var right = subband.type.charAt(0) === "H" ? 1 : 0;
  12117. var bottom = subband.type.charAt(1) === "H" ? levelWidth : 0;
  12118. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  12119. var codeblock = codeblocks[i];
  12120. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  12121. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  12122. if (blockWidth === 0 || blockHeight === 0) {
  12123. continue;
  12124. }
  12125. if (codeblock.data === undefined) {
  12126. continue;
  12127. }
  12128. var bitModel, currentCodingpassType;
  12129. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  12130. currentCodingpassType = 2;
  12131. var data = codeblock.data,
  12132. totalLength = 0,
  12133. codingpasses = 0;
  12134. var j, jj, dataItem;
  12135. for (j = 0, jj = data.length; j < jj; j++) {
  12136. dataItem = data[j];
  12137. totalLength += dataItem.end - dataItem.start;
  12138. codingpasses += dataItem.codingpasses;
  12139. }
  12140. var encodedData = new Uint8Array(totalLength);
  12141. var position = 0;
  12142. for (j = 0, jj = data.length; j < jj; j++) {
  12143. dataItem = data[j];
  12144. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  12145. encodedData.set(chunk, position);
  12146. position += chunk.length;
  12147. }
  12148. var decoder = new _arithmetic_decoder.ArithmeticDecoder(encodedData, 0, totalLength);
  12149. bitModel.setDecoder(decoder);
  12150. for (j = 0; j < codingpasses; j++) {
  12151. switch (currentCodingpassType) {
  12152. case 0:
  12153. bitModel.runSignificancePropagationPass();
  12154. break;
  12155. case 1:
  12156. bitModel.runMagnitudeRefinementPass();
  12157. break;
  12158. case 2:
  12159. bitModel.runCleanupPass();
  12160. if (segmentationSymbolUsed) {
  12161. bitModel.checkSegmentationSymbol();
  12162. }
  12163. break;
  12164. }
  12165. currentCodingpassType = (currentCodingpassType + 1) % 3;
  12166. }
  12167. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  12168. var sign = bitModel.coefficentsSign;
  12169. var magnitude = bitModel.coefficentsMagnitude;
  12170. var bitsDecoded = bitModel.bitsDecoded;
  12171. var magnitudeCorrection = reversible ? 0 : 0.5;
  12172. var k, n, nb;
  12173. position = 0;
  12174. var interleave = subband.type !== "LL";
  12175. for (j = 0; j < blockHeight; j++) {
  12176. var row = offset / width | 0;
  12177. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  12178. for (k = 0; k < blockWidth; k++) {
  12179. n = magnitude[position];
  12180. if (n !== 0) {
  12181. n = (n + magnitudeCorrection) * delta;
  12182. if (sign[position] !== 0) {
  12183. n = -n;
  12184. }
  12185. nb = bitsDecoded[position];
  12186. var pos = interleave ? levelOffset + (offset << 1) : offset;
  12187. if (reversible && nb >= mb) {
  12188. coefficients[pos] = n;
  12189. } else {
  12190. coefficients[pos] = n * (1 << mb - nb);
  12191. }
  12192. }
  12193. offset++;
  12194. position++;
  12195. }
  12196. offset += width - blockWidth;
  12197. }
  12198. }
  12199. }
  12200. function transformTile(context, tile, c) {
  12201. var component = tile.components[c];
  12202. var codingStyleParameters = component.codingStyleParameters;
  12203. var quantizationParameters = component.quantizationParameters;
  12204. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  12205. var spqcds = quantizationParameters.SPqcds;
  12206. var scalarExpounded = quantizationParameters.scalarExpounded;
  12207. var guardBits = quantizationParameters.guardBits;
  12208. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  12209. var precision = context.components[c].precision;
  12210. var reversible = codingStyleParameters.reversibleTransformation;
  12211. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  12212. var subbandCoefficients = [];
  12213. var b = 0;
  12214. for (var i = 0; i <= decompositionLevelsCount; i++) {
  12215. var resolution = component.resolutions[i];
  12216. var width = resolution.trx1 - resolution.trx0;
  12217. var height = resolution.try1 - resolution.try0;
  12218. var coefficients = new Float32Array(width * height);
  12219. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  12220. var mu, epsilon;
  12221. if (!scalarExpounded) {
  12222. mu = spqcds[0].mu;
  12223. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  12224. } else {
  12225. mu = spqcds[b].mu;
  12226. epsilon = spqcds[b].epsilon;
  12227. b++;
  12228. }
  12229. var subband = resolution.subbands[j];
  12230. var gainLog2 = SubbandsGainLog2[subband.type];
  12231. var delta = reversible ? 1 : 2 ** (precision + gainLog2 - epsilon) * (1 + mu / 2048);
  12232. var mb = guardBits + epsilon - 1;
  12233. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  12234. }
  12235. subbandCoefficients.push({
  12236. width,
  12237. height,
  12238. items: coefficients
  12239. });
  12240. }
  12241. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  12242. return {
  12243. left: component.tcx0,
  12244. top: component.tcy0,
  12245. width: result.width,
  12246. height: result.height,
  12247. items: result.items
  12248. };
  12249. }
  12250. function transformComponents(context) {
  12251. var siz = context.SIZ;
  12252. var components = context.components;
  12253. var componentsCount = siz.Csiz;
  12254. var resultImages = [];
  12255. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  12256. var tile = context.tiles[i];
  12257. var transformedTiles = [];
  12258. var c;
  12259. for (c = 0; c < componentsCount; c++) {
  12260. transformedTiles[c] = transformTile(context, tile, c);
  12261. }
  12262. var tile0 = transformedTiles[0];
  12263. var out = new Uint8ClampedArray(tile0.items.length * componentsCount);
  12264. var result = {
  12265. left: tile0.left,
  12266. top: tile0.top,
  12267. width: tile0.width,
  12268. height: tile0.height,
  12269. items: out
  12270. };
  12271. var shift, offset;
  12272. var pos = 0,
  12273. j,
  12274. jj,
  12275. y0,
  12276. y1,
  12277. y2;
  12278. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  12279. var fourComponents = componentsCount === 4;
  12280. var y0items = transformedTiles[0].items;
  12281. var y1items = transformedTiles[1].items;
  12282. var y2items = transformedTiles[2].items;
  12283. var y3items = fourComponents ? transformedTiles[3].items : null;
  12284. shift = components[0].precision - 8;
  12285. offset = (128 << shift) + 0.5;
  12286. var component0 = tile.components[0];
  12287. var alpha01 = componentsCount - 3;
  12288. jj = y0items.length;
  12289. if (!component0.codingStyleParameters.reversibleTransformation) {
  12290. for (j = 0; j < jj; j++, pos += alpha01) {
  12291. y0 = y0items[j] + offset;
  12292. y1 = y1items[j];
  12293. y2 = y2items[j];
  12294. out[pos++] = y0 + 1.402 * y2 >> shift;
  12295. out[pos++] = y0 - 0.34413 * y1 - 0.71414 * y2 >> shift;
  12296. out[pos++] = y0 + 1.772 * y1 >> shift;
  12297. }
  12298. } else {
  12299. for (j = 0; j < jj; j++, pos += alpha01) {
  12300. y0 = y0items[j] + offset;
  12301. y1 = y1items[j];
  12302. y2 = y2items[j];
  12303. const g = y0 - (y2 + y1 >> 2);
  12304. out[pos++] = g + y2 >> shift;
  12305. out[pos++] = g >> shift;
  12306. out[pos++] = g + y1 >> shift;
  12307. }
  12308. }
  12309. if (fourComponents) {
  12310. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  12311. out[pos] = y3items[j] + offset >> shift;
  12312. }
  12313. }
  12314. } else {
  12315. for (c = 0; c < componentsCount; c++) {
  12316. var items = transformedTiles[c].items;
  12317. shift = components[c].precision - 8;
  12318. offset = (128 << shift) + 0.5;
  12319. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  12320. out[pos] = items[j] + offset >> shift;
  12321. pos += componentsCount;
  12322. }
  12323. }
  12324. }
  12325. resultImages.push(result);
  12326. }
  12327. return resultImages;
  12328. }
  12329. function initializeTile(context, tileIndex) {
  12330. var siz = context.SIZ;
  12331. var componentsCount = siz.Csiz;
  12332. var tile = context.tiles[tileIndex];
  12333. for (var c = 0; c < componentsCount; c++) {
  12334. var component = tile.components[c];
  12335. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  12336. component.quantizationParameters = qcdOrQcc;
  12337. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  12338. component.codingStyleParameters = codOrCoc;
  12339. }
  12340. tile.codingStyleDefaultParameters = context.currentTile.COD;
  12341. }
  12342. var TagTree = function TagTreeClosure() {
  12343. function TagTree(width, height) {
  12344. var levelsLength = (0, _core_utils.log2)(Math.max(width, height)) + 1;
  12345. this.levels = [];
  12346. for (var i = 0; i < levelsLength; i++) {
  12347. var level = {
  12348. width,
  12349. height,
  12350. items: []
  12351. };
  12352. this.levels.push(level);
  12353. width = Math.ceil(width / 2);
  12354. height = Math.ceil(height / 2);
  12355. }
  12356. }
  12357. TagTree.prototype = {
  12358. reset: function TagTree_reset(i, j) {
  12359. var currentLevel = 0,
  12360. value = 0,
  12361. level;
  12362. while (currentLevel < this.levels.length) {
  12363. level = this.levels[currentLevel];
  12364. var index = i + j * level.width;
  12365. if (level.items[index] !== undefined) {
  12366. value = level.items[index];
  12367. break;
  12368. }
  12369. level.index = index;
  12370. i >>= 1;
  12371. j >>= 1;
  12372. currentLevel++;
  12373. }
  12374. currentLevel--;
  12375. level = this.levels[currentLevel];
  12376. level.items[level.index] = value;
  12377. this.currentLevel = currentLevel;
  12378. delete this.value;
  12379. },
  12380. incrementValue: function TagTree_incrementValue() {
  12381. var level = this.levels[this.currentLevel];
  12382. level.items[level.index]++;
  12383. },
  12384. nextLevel: function TagTree_nextLevel() {
  12385. var currentLevel = this.currentLevel;
  12386. var level = this.levels[currentLevel];
  12387. var value = level.items[level.index];
  12388. currentLevel--;
  12389. if (currentLevel < 0) {
  12390. this.value = value;
  12391. return false;
  12392. }
  12393. this.currentLevel = currentLevel;
  12394. level = this.levels[currentLevel];
  12395. level.items[level.index] = value;
  12396. return true;
  12397. }
  12398. };
  12399. return TagTree;
  12400. }();
  12401. var InclusionTree = function InclusionTreeClosure() {
  12402. function InclusionTree(width, height, defaultValue) {
  12403. var levelsLength = (0, _core_utils.log2)(Math.max(width, height)) + 1;
  12404. this.levels = [];
  12405. for (var i = 0; i < levelsLength; i++) {
  12406. var items = new Uint8Array(width * height);
  12407. for (var j = 0, jj = items.length; j < jj; j++) {
  12408. items[j] = defaultValue;
  12409. }
  12410. var level = {
  12411. width,
  12412. height,
  12413. items
  12414. };
  12415. this.levels.push(level);
  12416. width = Math.ceil(width / 2);
  12417. height = Math.ceil(height / 2);
  12418. }
  12419. }
  12420. InclusionTree.prototype = {
  12421. reset: function InclusionTree_reset(i, j, stopValue) {
  12422. var currentLevel = 0;
  12423. while (currentLevel < this.levels.length) {
  12424. var level = this.levels[currentLevel];
  12425. var index = i + j * level.width;
  12426. level.index = index;
  12427. var value = level.items[index];
  12428. if (value === 0xff) {
  12429. break;
  12430. }
  12431. if (value > stopValue) {
  12432. this.currentLevel = currentLevel;
  12433. this.propagateValues();
  12434. return false;
  12435. }
  12436. i >>= 1;
  12437. j >>= 1;
  12438. currentLevel++;
  12439. }
  12440. this.currentLevel = currentLevel - 1;
  12441. return true;
  12442. },
  12443. incrementValue: function InclusionTree_incrementValue(stopValue) {
  12444. var level = this.levels[this.currentLevel];
  12445. level.items[level.index] = stopValue + 1;
  12446. this.propagateValues();
  12447. },
  12448. propagateValues: function InclusionTree_propagateValues() {
  12449. var levelIndex = this.currentLevel;
  12450. var level = this.levels[levelIndex];
  12451. var currentValue = level.items[level.index];
  12452. while (--levelIndex >= 0) {
  12453. level = this.levels[levelIndex];
  12454. level.items[level.index] = currentValue;
  12455. }
  12456. },
  12457. nextLevel: function InclusionTree_nextLevel() {
  12458. var currentLevel = this.currentLevel;
  12459. var level = this.levels[currentLevel];
  12460. var value = level.items[level.index];
  12461. level.items[level.index] = 0xff;
  12462. currentLevel--;
  12463. if (currentLevel < 0) {
  12464. return false;
  12465. }
  12466. this.currentLevel = currentLevel;
  12467. level = this.levels[currentLevel];
  12468. level.items[level.index] = value;
  12469. return true;
  12470. }
  12471. };
  12472. return InclusionTree;
  12473. }();
  12474. var BitModel = function BitModelClosure() {
  12475. var UNIFORM_CONTEXT = 17;
  12476. var RUNLENGTH_CONTEXT = 18;
  12477. 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]);
  12478. 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]);
  12479. 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]);
  12480. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  12481. this.width = width;
  12482. this.height = height;
  12483. let contextLabelTable;
  12484. if (subband === "HH") {
  12485. contextLabelTable = HHContextLabel;
  12486. } else if (subband === "HL") {
  12487. contextLabelTable = HLContextLabel;
  12488. } else {
  12489. contextLabelTable = LLAndLHContextsLabel;
  12490. }
  12491. this.contextLabelTable = contextLabelTable;
  12492. var coefficientCount = width * height;
  12493. this.neighborsSignificance = new Uint8Array(coefficientCount);
  12494. this.coefficentsSign = new Uint8Array(coefficientCount);
  12495. let coefficentsMagnitude;
  12496. if (mb > 14) {
  12497. coefficentsMagnitude = new Uint32Array(coefficientCount);
  12498. } else if (mb > 6) {
  12499. coefficentsMagnitude = new Uint16Array(coefficientCount);
  12500. } else {
  12501. coefficentsMagnitude = new Uint8Array(coefficientCount);
  12502. }
  12503. this.coefficentsMagnitude = coefficentsMagnitude;
  12504. this.processingFlags = new Uint8Array(coefficientCount);
  12505. var bitsDecoded = new Uint8Array(coefficientCount);
  12506. if (zeroBitPlanes !== 0) {
  12507. for (var i = 0; i < coefficientCount; i++) {
  12508. bitsDecoded[i] = zeroBitPlanes;
  12509. }
  12510. }
  12511. this.bitsDecoded = bitsDecoded;
  12512. this.reset();
  12513. }
  12514. BitModel.prototype = {
  12515. setDecoder: function BitModel_setDecoder(decoder) {
  12516. this.decoder = decoder;
  12517. },
  12518. reset: function BitModel_reset() {
  12519. this.contexts = new Int8Array(19);
  12520. this.contexts[0] = 4 << 1 | 0;
  12521. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  12522. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  12523. },
  12524. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  12525. var neighborsSignificance = this.neighborsSignificance;
  12526. var width = this.width,
  12527. height = this.height;
  12528. var left = column > 0;
  12529. var right = column + 1 < width;
  12530. var i;
  12531. if (row > 0) {
  12532. i = index - width;
  12533. if (left) {
  12534. neighborsSignificance[i - 1] += 0x10;
  12535. }
  12536. if (right) {
  12537. neighborsSignificance[i + 1] += 0x10;
  12538. }
  12539. neighborsSignificance[i] += 0x04;
  12540. }
  12541. if (row + 1 < height) {
  12542. i = index + width;
  12543. if (left) {
  12544. neighborsSignificance[i - 1] += 0x10;
  12545. }
  12546. if (right) {
  12547. neighborsSignificance[i + 1] += 0x10;
  12548. }
  12549. neighborsSignificance[i] += 0x04;
  12550. }
  12551. if (left) {
  12552. neighborsSignificance[index - 1] += 0x01;
  12553. }
  12554. if (right) {
  12555. neighborsSignificance[index + 1] += 0x01;
  12556. }
  12557. neighborsSignificance[index] |= 0x80;
  12558. },
  12559. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  12560. var decoder = this.decoder;
  12561. var width = this.width,
  12562. height = this.height;
  12563. var coefficentsMagnitude = this.coefficentsMagnitude;
  12564. var coefficentsSign = this.coefficentsSign;
  12565. var neighborsSignificance = this.neighborsSignificance;
  12566. var processingFlags = this.processingFlags;
  12567. var contexts = this.contexts;
  12568. var labels = this.contextLabelTable;
  12569. var bitsDecoded = this.bitsDecoded;
  12570. var processedInverseMask = ~1;
  12571. var processedMask = 1;
  12572. var firstMagnitudeBitMask = 2;
  12573. for (var i0 = 0; i0 < height; i0 += 4) {
  12574. for (var j = 0; j < width; j++) {
  12575. var index = i0 * width + j;
  12576. for (var i1 = 0; i1 < 4; i1++, index += width) {
  12577. var i = i0 + i1;
  12578. if (i >= height) {
  12579. break;
  12580. }
  12581. processingFlags[index] &= processedInverseMask;
  12582. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  12583. continue;
  12584. }
  12585. var contextLabel = labels[neighborsSignificance[index]];
  12586. var decision = decoder.readBit(contexts, contextLabel);
  12587. if (decision) {
  12588. var sign = this.decodeSignBit(i, j, index);
  12589. coefficentsSign[index] = sign;
  12590. coefficentsMagnitude[index] = 1;
  12591. this.setNeighborsSignificance(i, j, index);
  12592. processingFlags[index] |= firstMagnitudeBitMask;
  12593. }
  12594. bitsDecoded[index]++;
  12595. processingFlags[index] |= processedMask;
  12596. }
  12597. }
  12598. }
  12599. },
  12600. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  12601. var width = this.width,
  12602. height = this.height;
  12603. var coefficentsMagnitude = this.coefficentsMagnitude;
  12604. var coefficentsSign = this.coefficentsSign;
  12605. var contribution, sign0, sign1, significance1;
  12606. var contextLabel, decoded;
  12607. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  12608. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  12609. sign1 = coefficentsSign[index + 1];
  12610. if (significance1) {
  12611. sign0 = coefficentsSign[index - 1];
  12612. contribution = 1 - sign1 - sign0;
  12613. } else {
  12614. contribution = 1 - sign1 - sign1;
  12615. }
  12616. } else if (significance1) {
  12617. sign0 = coefficentsSign[index - 1];
  12618. contribution = 1 - sign0 - sign0;
  12619. } else {
  12620. contribution = 0;
  12621. }
  12622. var horizontalContribution = 3 * contribution;
  12623. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  12624. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  12625. sign1 = coefficentsSign[index + width];
  12626. if (significance1) {
  12627. sign0 = coefficentsSign[index - width];
  12628. contribution = 1 - sign1 - sign0 + horizontalContribution;
  12629. } else {
  12630. contribution = 1 - sign1 - sign1 + horizontalContribution;
  12631. }
  12632. } else if (significance1) {
  12633. sign0 = coefficentsSign[index - width];
  12634. contribution = 1 - sign0 - sign0 + horizontalContribution;
  12635. } else {
  12636. contribution = horizontalContribution;
  12637. }
  12638. if (contribution >= 0) {
  12639. contextLabel = 9 + contribution;
  12640. decoded = this.decoder.readBit(this.contexts, contextLabel);
  12641. } else {
  12642. contextLabel = 9 - contribution;
  12643. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  12644. }
  12645. return decoded;
  12646. },
  12647. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  12648. var decoder = this.decoder;
  12649. var width = this.width,
  12650. height = this.height;
  12651. var coefficentsMagnitude = this.coefficentsMagnitude;
  12652. var neighborsSignificance = this.neighborsSignificance;
  12653. var contexts = this.contexts;
  12654. var bitsDecoded = this.bitsDecoded;
  12655. var processingFlags = this.processingFlags;
  12656. var processedMask = 1;
  12657. var firstMagnitudeBitMask = 2;
  12658. var length = width * height;
  12659. var width4 = width * 4;
  12660. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  12661. indexNext = Math.min(length, index0 + width4);
  12662. for (var j = 0; j < width; j++) {
  12663. for (var index = index0 + j; index < indexNext; index += width) {
  12664. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  12665. continue;
  12666. }
  12667. var contextLabel = 16;
  12668. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  12669. processingFlags[index] ^= firstMagnitudeBitMask;
  12670. var significance = neighborsSignificance[index] & 127;
  12671. contextLabel = significance === 0 ? 15 : 14;
  12672. }
  12673. var bit = decoder.readBit(contexts, contextLabel);
  12674. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  12675. bitsDecoded[index]++;
  12676. processingFlags[index] |= processedMask;
  12677. }
  12678. }
  12679. }
  12680. },
  12681. runCleanupPass: function BitModel_runCleanupPass() {
  12682. var decoder = this.decoder;
  12683. var width = this.width,
  12684. height = this.height;
  12685. var neighborsSignificance = this.neighborsSignificance;
  12686. var coefficentsMagnitude = this.coefficentsMagnitude;
  12687. var coefficentsSign = this.coefficentsSign;
  12688. var contexts = this.contexts;
  12689. var labels = this.contextLabelTable;
  12690. var bitsDecoded = this.bitsDecoded;
  12691. var processingFlags = this.processingFlags;
  12692. var processedMask = 1;
  12693. var firstMagnitudeBitMask = 2;
  12694. var oneRowDown = width;
  12695. var twoRowsDown = width * 2;
  12696. var threeRowsDown = width * 3;
  12697. var iNext;
  12698. for (var i0 = 0; i0 < height; i0 = iNext) {
  12699. iNext = Math.min(i0 + 4, height);
  12700. var indexBase = i0 * width;
  12701. var checkAllEmpty = i0 + 3 < height;
  12702. for (var j = 0; j < width; j++) {
  12703. var index0 = indexBase + j;
  12704. 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;
  12705. var i1 = 0,
  12706. index = index0;
  12707. var i = i0,
  12708. sign;
  12709. if (allEmpty) {
  12710. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  12711. if (!hasSignificantCoefficent) {
  12712. bitsDecoded[index0]++;
  12713. bitsDecoded[index0 + oneRowDown]++;
  12714. bitsDecoded[index0 + twoRowsDown]++;
  12715. bitsDecoded[index0 + threeRowsDown]++;
  12716. continue;
  12717. }
  12718. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  12719. if (i1 !== 0) {
  12720. i = i0 + i1;
  12721. index += i1 * width;
  12722. }
  12723. sign = this.decodeSignBit(i, j, index);
  12724. coefficentsSign[index] = sign;
  12725. coefficentsMagnitude[index] = 1;
  12726. this.setNeighborsSignificance(i, j, index);
  12727. processingFlags[index] |= firstMagnitudeBitMask;
  12728. index = index0;
  12729. for (var i2 = i0; i2 <= i; i2++, index += width) {
  12730. bitsDecoded[index]++;
  12731. }
  12732. i1++;
  12733. }
  12734. for (i = i0 + i1; i < iNext; i++, index += width) {
  12735. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  12736. continue;
  12737. }
  12738. var contextLabel = labels[neighborsSignificance[index]];
  12739. var decision = decoder.readBit(contexts, contextLabel);
  12740. if (decision === 1) {
  12741. sign = this.decodeSignBit(i, j, index);
  12742. coefficentsSign[index] = sign;
  12743. coefficentsMagnitude[index] = 1;
  12744. this.setNeighborsSignificance(i, j, index);
  12745. processingFlags[index] |= firstMagnitudeBitMask;
  12746. }
  12747. bitsDecoded[index]++;
  12748. }
  12749. }
  12750. }
  12751. },
  12752. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  12753. var decoder = this.decoder;
  12754. var contexts = this.contexts;
  12755. 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);
  12756. if (symbol !== 0xa) {
  12757. throw new JpxError("Invalid segmentation symbol");
  12758. }
  12759. }
  12760. };
  12761. return BitModel;
  12762. }();
  12763. var Transform = function TransformClosure() {
  12764. function Transform() {}
  12765. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  12766. var ll = subbands[0];
  12767. for (var i = 1, ii = subbands.length; i < ii; i++) {
  12768. ll = this.iterate(ll, subbands[i], u0, v0);
  12769. }
  12770. return ll;
  12771. };
  12772. Transform.prototype.extend = function extend(buffer, offset, size) {
  12773. var i1 = offset - 1,
  12774. j1 = offset + 1;
  12775. var i2 = offset + size - 2,
  12776. j2 = offset + size;
  12777. buffer[i1--] = buffer[j1++];
  12778. buffer[j2++] = buffer[i2--];
  12779. buffer[i1--] = buffer[j1++];
  12780. buffer[j2++] = buffer[i2--];
  12781. buffer[i1--] = buffer[j1++];
  12782. buffer[j2++] = buffer[i2--];
  12783. buffer[i1] = buffer[j1];
  12784. buffer[j2] = buffer[i2];
  12785. };
  12786. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  12787. var llWidth = ll.width,
  12788. llHeight = ll.height,
  12789. llItems = ll.items;
  12790. var width = hl_lh_hh.width;
  12791. var height = hl_lh_hh.height;
  12792. var items = hl_lh_hh.items;
  12793. var i, j, k, l, u, v;
  12794. for (k = 0, i = 0; i < llHeight; i++) {
  12795. l = i * 2 * width;
  12796. for (j = 0; j < llWidth; j++, k++, l += 2) {
  12797. items[l] = llItems[k];
  12798. }
  12799. }
  12800. llItems = ll.items = null;
  12801. var bufferPadding = 4;
  12802. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  12803. if (width === 1) {
  12804. if ((u0 & 1) !== 0) {
  12805. for (v = 0, k = 0; v < height; v++, k += width) {
  12806. items[k] *= 0.5;
  12807. }
  12808. }
  12809. } else {
  12810. for (v = 0, k = 0; v < height; v++, k += width) {
  12811. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  12812. this.extend(rowBuffer, bufferPadding, width);
  12813. this.filter(rowBuffer, bufferPadding, width);
  12814. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  12815. }
  12816. }
  12817. var numBuffers = 16;
  12818. var colBuffers = [];
  12819. for (i = 0; i < numBuffers; i++) {
  12820. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  12821. }
  12822. var b,
  12823. currentBuffer = 0;
  12824. ll = bufferPadding + height;
  12825. if (height === 1) {
  12826. if ((v0 & 1) !== 0) {
  12827. for (u = 0; u < width; u++) {
  12828. items[u] *= 0.5;
  12829. }
  12830. }
  12831. } else {
  12832. for (u = 0; u < width; u++) {
  12833. if (currentBuffer === 0) {
  12834. numBuffers = Math.min(width - u, numBuffers);
  12835. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  12836. for (b = 0; b < numBuffers; b++) {
  12837. colBuffers[b][l] = items[k + b];
  12838. }
  12839. }
  12840. currentBuffer = numBuffers;
  12841. }
  12842. currentBuffer--;
  12843. var buffer = colBuffers[currentBuffer];
  12844. this.extend(buffer, bufferPadding, height);
  12845. this.filter(buffer, bufferPadding, height);
  12846. if (currentBuffer === 0) {
  12847. k = u - numBuffers + 1;
  12848. for (l = bufferPadding; l < ll; k += width, l++) {
  12849. for (b = 0; b < numBuffers; b++) {
  12850. items[k + b] = colBuffers[b][l];
  12851. }
  12852. }
  12853. }
  12854. }
  12855. }
  12856. return {
  12857. width,
  12858. height,
  12859. items
  12860. };
  12861. };
  12862. return Transform;
  12863. }();
  12864. var IrreversibleTransform = function IrreversibleTransformClosure() {
  12865. function IrreversibleTransform() {
  12866. Transform.call(this);
  12867. }
  12868. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  12869. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  12870. var len = length >> 1;
  12871. offset = offset | 0;
  12872. var j, n, current, next;
  12873. var alpha = -1.586134342059924;
  12874. var beta = -0.052980118572961;
  12875. var gamma = 0.882911075530934;
  12876. var delta = 0.443506852043971;
  12877. var K = 1.230174104914001;
  12878. var K_ = 1 / K;
  12879. j = offset - 3;
  12880. for (n = len + 4; n--; j += 2) {
  12881. x[j] *= K_;
  12882. }
  12883. j = offset - 2;
  12884. current = delta * x[j - 1];
  12885. for (n = len + 3; n--; j += 2) {
  12886. next = delta * x[j + 1];
  12887. x[j] = K * x[j] - current - next;
  12888. if (n--) {
  12889. j += 2;
  12890. current = delta * x[j + 1];
  12891. x[j] = K * x[j] - current - next;
  12892. } else {
  12893. break;
  12894. }
  12895. }
  12896. j = offset - 1;
  12897. current = gamma * x[j - 1];
  12898. for (n = len + 2; n--; j += 2) {
  12899. next = gamma * x[j + 1];
  12900. x[j] -= current + next;
  12901. if (n--) {
  12902. j += 2;
  12903. current = gamma * x[j + 1];
  12904. x[j] -= current + next;
  12905. } else {
  12906. break;
  12907. }
  12908. }
  12909. j = offset;
  12910. current = beta * x[j - 1];
  12911. for (n = len + 1; n--; j += 2) {
  12912. next = beta * x[j + 1];
  12913. x[j] -= current + next;
  12914. if (n--) {
  12915. j += 2;
  12916. current = beta * x[j + 1];
  12917. x[j] -= current + next;
  12918. } else {
  12919. break;
  12920. }
  12921. }
  12922. if (len !== 0) {
  12923. j = offset + 1;
  12924. current = alpha * x[j - 1];
  12925. for (n = len; n--; j += 2) {
  12926. next = alpha * x[j + 1];
  12927. x[j] -= current + next;
  12928. if (n--) {
  12929. j += 2;
  12930. current = alpha * x[j + 1];
  12931. x[j] -= current + next;
  12932. } else {
  12933. break;
  12934. }
  12935. }
  12936. }
  12937. };
  12938. return IrreversibleTransform;
  12939. }();
  12940. var ReversibleTransform = function ReversibleTransformClosure() {
  12941. function ReversibleTransform() {
  12942. Transform.call(this);
  12943. }
  12944. ReversibleTransform.prototype = Object.create(Transform.prototype);
  12945. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  12946. var len = length >> 1;
  12947. offset = offset | 0;
  12948. var j, n;
  12949. for (j = offset, n = len + 1; n--; j += 2) {
  12950. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  12951. }
  12952. for (j = offset + 1, n = len; n--; j += 2) {
  12953. x[j] += x[j - 1] + x[j + 1] >> 1;
  12954. }
  12955. };
  12956. return ReversibleTransform;
  12957. }();
  12958. return JpxImage;
  12959. }();
  12960. exports.JpxImage = JpxImage;
  12961. /***/ }),
  12962. /* 22 */
  12963. /***/ (function(module, exports, __w_pdfjs_require__) {
  12964. "use strict";
  12965. Object.defineProperty(exports, "__esModule", {
  12966. value: true
  12967. });
  12968. exports.calculateSHA512 = exports.calculateSHA384 = exports.calculateSHA256 = exports.calculateMD5 = exports.PDF20 = exports.PDF17 = exports.CipherTransformFactory = exports.ARCFourCipher = exports.AES256Cipher = exports.AES128Cipher = void 0;
  12969. var _util = __w_pdfjs_require__(2);
  12970. var _primitives = __w_pdfjs_require__(5);
  12971. var _stream = __w_pdfjs_require__(12);
  12972. var ARCFourCipher = function ARCFourCipherClosure() {
  12973. function ARCFourCipher(key) {
  12974. this.a = 0;
  12975. this.b = 0;
  12976. var s = new Uint8Array(256);
  12977. var i,
  12978. j = 0,
  12979. tmp,
  12980. keyLength = key.length;
  12981. for (i = 0; i < 256; ++i) {
  12982. s[i] = i;
  12983. }
  12984. for (i = 0; i < 256; ++i) {
  12985. tmp = s[i];
  12986. j = j + tmp + key[i % keyLength] & 0xff;
  12987. s[i] = s[j];
  12988. s[j] = tmp;
  12989. }
  12990. this.s = s;
  12991. }
  12992. ARCFourCipher.prototype = {
  12993. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  12994. var i,
  12995. n = data.length,
  12996. tmp,
  12997. tmp2;
  12998. var a = this.a,
  12999. b = this.b,
  13000. s = this.s;
  13001. var output = new Uint8Array(n);
  13002. for (i = 0; i < n; ++i) {
  13003. a = a + 1 & 0xff;
  13004. tmp = s[a];
  13005. b = b + tmp & 0xff;
  13006. tmp2 = s[b];
  13007. s[a] = tmp2;
  13008. s[b] = tmp;
  13009. output[i] = data[i] ^ s[tmp + tmp2 & 0xff];
  13010. }
  13011. this.a = a;
  13012. this.b = b;
  13013. return output;
  13014. }
  13015. };
  13016. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  13017. ARCFourCipher.prototype.encrypt = ARCFourCipher.prototype.encryptBlock;
  13018. return ARCFourCipher;
  13019. }();
  13020. exports.ARCFourCipher = ARCFourCipher;
  13021. var calculateMD5 = function calculateMD5Closure() {
  13022. var r = new Uint8Array([7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21]);
  13023. var k = new Int32Array([-680876936, -389564586, 606105819, -1044525330, -176418897, 1200080426, -1473231341, -45705983, 1770035416, -1958414417, -42063, -1990404162, 1804603682, -40341101, -1502002290, 1236535329, -165796510, -1069501632, 643717713, -373897302, -701558691, 38016083, -660478335, -405537848, 568446438, -1019803690, -187363961, 1163531501, -1444681467, -51403784, 1735328473, -1926607734, -378558, -2022574463, 1839030562, -35309556, -1530992060, 1272893353, -155497632, -1094730640, 681279174, -358537222, -722521979, 76029189, -640364487, -421815835, 530742520, -995338651, -198630844, 1126891415, -1416354905, -57434055, 1700485571, -1894986606, -1051523, -2054922799, 1873313359, -30611744, -1560198380, 1309151649, -145523070, -1120210379, 718787259, -343485551]);
  13024. function hash(data, offset, length) {
  13025. var h0 = 1732584193,
  13026. h1 = -271733879,
  13027. h2 = -1732584194,
  13028. h3 = 271733878;
  13029. var paddedLength = length + 72 & ~63;
  13030. var padded = new Uint8Array(paddedLength);
  13031. var i, j, n;
  13032. for (i = 0; i < length; ++i) {
  13033. padded[i] = data[offset++];
  13034. }
  13035. padded[i++] = 0x80;
  13036. n = paddedLength - 8;
  13037. while (i < n) {
  13038. padded[i++] = 0;
  13039. }
  13040. padded[i++] = length << 3 & 0xff;
  13041. padded[i++] = length >> 5 & 0xff;
  13042. padded[i++] = length >> 13 & 0xff;
  13043. padded[i++] = length >> 21 & 0xff;
  13044. padded[i++] = length >>> 29 & 0xff;
  13045. padded[i++] = 0;
  13046. padded[i++] = 0;
  13047. padded[i++] = 0;
  13048. var w = new Int32Array(16);
  13049. for (i = 0; i < paddedLength;) {
  13050. for (j = 0; j < 16; ++j, i += 4) {
  13051. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  13052. }
  13053. var a = h0,
  13054. b = h1,
  13055. c = h2,
  13056. d = h3,
  13057. f,
  13058. g;
  13059. for (j = 0; j < 64; ++j) {
  13060. if (j < 16) {
  13061. f = b & c | ~b & d;
  13062. g = j;
  13063. } else if (j < 32) {
  13064. f = d & b | ~d & c;
  13065. g = 5 * j + 1 & 15;
  13066. } else if (j < 48) {
  13067. f = b ^ c ^ d;
  13068. g = 3 * j + 5 & 15;
  13069. } else {
  13070. f = c ^ (b | ~d);
  13071. g = 7 * j & 15;
  13072. }
  13073. var tmp = d,
  13074. rotateArg = a + f + k[j] + w[g] | 0,
  13075. rotate = r[j];
  13076. d = c;
  13077. c = b;
  13078. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  13079. a = tmp;
  13080. }
  13081. h0 = h0 + a | 0;
  13082. h1 = h1 + b | 0;
  13083. h2 = h2 + c | 0;
  13084. h3 = h3 + d | 0;
  13085. }
  13086. return new Uint8Array([h0 & 0xFF, h0 >> 8 & 0xFF, h0 >> 16 & 0xFF, h0 >>> 24 & 0xFF, h1 & 0xFF, h1 >> 8 & 0xFF, h1 >> 16 & 0xFF, h1 >>> 24 & 0xFF, h2 & 0xFF, h2 >> 8 & 0xFF, h2 >> 16 & 0xFF, h2 >>> 24 & 0xFF, h3 & 0xFF, h3 >> 8 & 0xFF, h3 >> 16 & 0xFF, h3 >>> 24 & 0xFF]);
  13087. }
  13088. return hash;
  13089. }();
  13090. exports.calculateMD5 = calculateMD5;
  13091. var Word64 = function Word64Closure() {
  13092. function Word64(highInteger, lowInteger) {
  13093. this.high = highInteger | 0;
  13094. this.low = lowInteger | 0;
  13095. }
  13096. Word64.prototype = {
  13097. and: function Word64_and(word) {
  13098. this.high &= word.high;
  13099. this.low &= word.low;
  13100. },
  13101. xor: function Word64_xor(word) {
  13102. this.high ^= word.high;
  13103. this.low ^= word.low;
  13104. },
  13105. or: function Word64_or(word) {
  13106. this.high |= word.high;
  13107. this.low |= word.low;
  13108. },
  13109. shiftRight: function Word64_shiftRight(places) {
  13110. if (places >= 32) {
  13111. this.low = this.high >>> places - 32 | 0;
  13112. this.high = 0;
  13113. } else {
  13114. this.low = this.low >>> places | this.high << 32 - places;
  13115. this.high = this.high >>> places | 0;
  13116. }
  13117. },
  13118. shiftLeft: function Word64_shiftLeft(places) {
  13119. if (places >= 32) {
  13120. this.high = this.low << places - 32;
  13121. this.low = 0;
  13122. } else {
  13123. this.high = this.high << places | this.low >>> 32 - places;
  13124. this.low = this.low << places;
  13125. }
  13126. },
  13127. rotateRight: function Word64_rotateRight(places) {
  13128. var low, high;
  13129. if (places & 32) {
  13130. high = this.low;
  13131. low = this.high;
  13132. } else {
  13133. low = this.low;
  13134. high = this.high;
  13135. }
  13136. places &= 31;
  13137. this.low = low >>> places | high << 32 - places;
  13138. this.high = high >>> places | low << 32 - places;
  13139. },
  13140. not: function Word64_not() {
  13141. this.high = ~this.high;
  13142. this.low = ~this.low;
  13143. },
  13144. add: function Word64_add(word) {
  13145. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  13146. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  13147. if (lowAdd > 0xffffffff) {
  13148. highAdd += 1;
  13149. }
  13150. this.low = lowAdd | 0;
  13151. this.high = highAdd | 0;
  13152. },
  13153. copyTo: function Word64_copyTo(bytes, offset) {
  13154. bytes[offset] = this.high >>> 24 & 0xff;
  13155. bytes[offset + 1] = this.high >> 16 & 0xff;
  13156. bytes[offset + 2] = this.high >> 8 & 0xff;
  13157. bytes[offset + 3] = this.high & 0xff;
  13158. bytes[offset + 4] = this.low >>> 24 & 0xff;
  13159. bytes[offset + 5] = this.low >> 16 & 0xff;
  13160. bytes[offset + 6] = this.low >> 8 & 0xff;
  13161. bytes[offset + 7] = this.low & 0xff;
  13162. },
  13163. assign: function Word64_assign(word) {
  13164. this.high = word.high;
  13165. this.low = word.low;
  13166. }
  13167. };
  13168. return Word64;
  13169. }();
  13170. var calculateSHA256 = function calculateSHA256Closure() {
  13171. function rotr(x, n) {
  13172. return x >>> n | x << 32 - n;
  13173. }
  13174. function ch(x, y, z) {
  13175. return x & y ^ ~x & z;
  13176. }
  13177. function maj(x, y, z) {
  13178. return x & y ^ x & z ^ y & z;
  13179. }
  13180. function sigma(x) {
  13181. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  13182. }
  13183. function sigmaPrime(x) {
  13184. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  13185. }
  13186. function littleSigma(x) {
  13187. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  13188. }
  13189. function littleSigmaPrime(x) {
  13190. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  13191. }
  13192. var k = [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2];
  13193. function hash(data, offset, length) {
  13194. var h0 = 0x6a09e667,
  13195. h1 = 0xbb67ae85,
  13196. h2 = 0x3c6ef372,
  13197. h3 = 0xa54ff53a,
  13198. h4 = 0x510e527f,
  13199. h5 = 0x9b05688c,
  13200. h6 = 0x1f83d9ab,
  13201. h7 = 0x5be0cd19;
  13202. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  13203. var padded = new Uint8Array(paddedLength);
  13204. var i, j, n;
  13205. for (i = 0; i < length; ++i) {
  13206. padded[i] = data[offset++];
  13207. }
  13208. padded[i++] = 0x80;
  13209. n = paddedLength - 8;
  13210. while (i < n) {
  13211. padded[i++] = 0;
  13212. }
  13213. padded[i++] = 0;
  13214. padded[i++] = 0;
  13215. padded[i++] = 0;
  13216. padded[i++] = length >>> 29 & 0xff;
  13217. padded[i++] = length >> 21 & 0xff;
  13218. padded[i++] = length >> 13 & 0xff;
  13219. padded[i++] = length >> 5 & 0xff;
  13220. padded[i++] = length << 3 & 0xff;
  13221. var w = new Uint32Array(64);
  13222. for (i = 0; i < paddedLength;) {
  13223. for (j = 0; j < 16; ++j) {
  13224. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  13225. i += 4;
  13226. }
  13227. for (j = 16; j < 64; ++j) {
  13228. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  13229. }
  13230. var a = h0,
  13231. b = h1,
  13232. c = h2,
  13233. d = h3,
  13234. e = h4,
  13235. f = h5,
  13236. g = h6,
  13237. h = h7,
  13238. t1,
  13239. t2;
  13240. for (j = 0; j < 64; ++j) {
  13241. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  13242. t2 = sigma(a) + maj(a, b, c);
  13243. h = g;
  13244. g = f;
  13245. f = e;
  13246. e = d + t1 | 0;
  13247. d = c;
  13248. c = b;
  13249. b = a;
  13250. a = t1 + t2 | 0;
  13251. }
  13252. h0 = h0 + a | 0;
  13253. h1 = h1 + b | 0;
  13254. h2 = h2 + c | 0;
  13255. h3 = h3 + d | 0;
  13256. h4 = h4 + e | 0;
  13257. h5 = h5 + f | 0;
  13258. h6 = h6 + g | 0;
  13259. h7 = h7 + h | 0;
  13260. }
  13261. return new Uint8Array([h0 >> 24 & 0xFF, h0 >> 16 & 0xFF, h0 >> 8 & 0xFF, h0 & 0xFF, h1 >> 24 & 0xFF, h1 >> 16 & 0xFF, h1 >> 8 & 0xFF, h1 & 0xFF, h2 >> 24 & 0xFF, h2 >> 16 & 0xFF, h2 >> 8 & 0xFF, h2 & 0xFF, h3 >> 24 & 0xFF, h3 >> 16 & 0xFF, h3 >> 8 & 0xFF, h3 & 0xFF, h4 >> 24 & 0xFF, h4 >> 16 & 0xFF, h4 >> 8 & 0xFF, h4 & 0xFF, h5 >> 24 & 0xFF, h5 >> 16 & 0xFF, h5 >> 8 & 0xFF, h5 & 0xFF, h6 >> 24 & 0xFF, h6 >> 16 & 0xFF, h6 >> 8 & 0xFF, h6 & 0xFF, h7 >> 24 & 0xFF, h7 >> 16 & 0xFF, h7 >> 8 & 0xFF, h7 & 0xFF]);
  13262. }
  13263. return hash;
  13264. }();
  13265. exports.calculateSHA256 = calculateSHA256;
  13266. var calculateSHA512 = function calculateSHA512Closure() {
  13267. function ch(result, x, y, z, tmp) {
  13268. result.assign(x);
  13269. result.and(y);
  13270. tmp.assign(x);
  13271. tmp.not();
  13272. tmp.and(z);
  13273. result.xor(tmp);
  13274. }
  13275. function maj(result, x, y, z, tmp) {
  13276. result.assign(x);
  13277. result.and(y);
  13278. tmp.assign(x);
  13279. tmp.and(z);
  13280. result.xor(tmp);
  13281. tmp.assign(y);
  13282. tmp.and(z);
  13283. result.xor(tmp);
  13284. }
  13285. function sigma(result, x, tmp) {
  13286. result.assign(x);
  13287. result.rotateRight(28);
  13288. tmp.assign(x);
  13289. tmp.rotateRight(34);
  13290. result.xor(tmp);
  13291. tmp.assign(x);
  13292. tmp.rotateRight(39);
  13293. result.xor(tmp);
  13294. }
  13295. function sigmaPrime(result, x, tmp) {
  13296. result.assign(x);
  13297. result.rotateRight(14);
  13298. tmp.assign(x);
  13299. tmp.rotateRight(18);
  13300. result.xor(tmp);
  13301. tmp.assign(x);
  13302. tmp.rotateRight(41);
  13303. result.xor(tmp);
  13304. }
  13305. function littleSigma(result, x, tmp) {
  13306. result.assign(x);
  13307. result.rotateRight(1);
  13308. tmp.assign(x);
  13309. tmp.rotateRight(8);
  13310. result.xor(tmp);
  13311. tmp.assign(x);
  13312. tmp.shiftRight(7);
  13313. result.xor(tmp);
  13314. }
  13315. function littleSigmaPrime(result, x, tmp) {
  13316. result.assign(x);
  13317. result.rotateRight(19);
  13318. tmp.assign(x);
  13319. tmp.rotateRight(61);
  13320. result.xor(tmp);
  13321. tmp.assign(x);
  13322. tmp.shiftRight(6);
  13323. result.xor(tmp);
  13324. }
  13325. var k = [new Word64(0x428a2f98, 0xd728ae22), new Word64(0x71374491, 0x23ef65cd), new Word64(0xb5c0fbcf, 0xec4d3b2f), new Word64(0xe9b5dba5, 0x8189dbbc), new Word64(0x3956c25b, 0xf348b538), new Word64(0x59f111f1, 0xb605d019), new Word64(0x923f82a4, 0xaf194f9b), new Word64(0xab1c5ed5, 0xda6d8118), new Word64(0xd807aa98, 0xa3030242), new Word64(0x12835b01, 0x45706fbe), new Word64(0x243185be, 0x4ee4b28c), new Word64(0x550c7dc3, 0xd5ffb4e2), new Word64(0x72be5d74, 0xf27b896f), new Word64(0x80deb1fe, 0x3b1696b1), new Word64(0x9bdc06a7, 0x25c71235), new Word64(0xc19bf174, 0xcf692694), new Word64(0xe49b69c1, 0x9ef14ad2), new Word64(0xefbe4786, 0x384f25e3), new Word64(0x0fc19dc6, 0x8b8cd5b5), new Word64(0x240ca1cc, 0x77ac9c65), new Word64(0x2de92c6f, 0x592b0275), new Word64(0x4a7484aa, 0x6ea6e483), new Word64(0x5cb0a9dc, 0xbd41fbd4), new Word64(0x76f988da, 0x831153b5), new Word64(0x983e5152, 0xee66dfab), new Word64(0xa831c66d, 0x2db43210), new Word64(0xb00327c8, 0x98fb213f), new Word64(0xbf597fc7, 0xbeef0ee4), new Word64(0xc6e00bf3, 0x3da88fc2), new Word64(0xd5a79147, 0x930aa725), new Word64(0x06ca6351, 0xe003826f), new Word64(0x14292967, 0x0a0e6e70), new Word64(0x27b70a85, 0x46d22ffc), new Word64(0x2e1b2138, 0x5c26c926), new Word64(0x4d2c6dfc, 0x5ac42aed), new Word64(0x53380d13, 0x9d95b3df), new Word64(0x650a7354, 0x8baf63de), new Word64(0x766a0abb, 0x3c77b2a8), new Word64(0x81c2c92e, 0x47edaee6), new Word64(0x92722c85, 0x1482353b), new Word64(0xa2bfe8a1, 0x4cf10364), new Word64(0xa81a664b, 0xbc423001), new Word64(0xc24b8b70, 0xd0f89791), new Word64(0xc76c51a3, 0x0654be30), new Word64(0xd192e819, 0xd6ef5218), new Word64(0xd6990624, 0x5565a910), new Word64(0xf40e3585, 0x5771202a), new Word64(0x106aa070, 0x32bbd1b8), new Word64(0x19a4c116, 0xb8d2d0c8), new Word64(0x1e376c08, 0x5141ab53), new Word64(0x2748774c, 0xdf8eeb99), new Word64(0x34b0bcb5, 0xe19b48a8), new Word64(0x391c0cb3, 0xc5c95a63), new Word64(0x4ed8aa4a, 0xe3418acb), new Word64(0x5b9cca4f, 0x7763e373), new Word64(0x682e6ff3, 0xd6b2b8a3), new Word64(0x748f82ee, 0x5defb2fc), new Word64(0x78a5636f, 0x43172f60), new Word64(0x84c87814, 0xa1f0ab72), new Word64(0x8cc70208, 0x1a6439ec), new Word64(0x90befffa, 0x23631e28), new Word64(0xa4506ceb, 0xde82bde9), new Word64(0xbef9a3f7, 0xb2c67915), new Word64(0xc67178f2, 0xe372532b), new Word64(0xca273ece, 0xea26619c), new Word64(0xd186b8c7, 0x21c0c207), new Word64(0xeada7dd6, 0xcde0eb1e), new Word64(0xf57d4f7f, 0xee6ed178), new Word64(0x06f067aa, 0x72176fba), new Word64(0x0a637dc5, 0xa2c898a6), new Word64(0x113f9804, 0xbef90dae), new Word64(0x1b710b35, 0x131c471b), new Word64(0x28db77f5, 0x23047d84), new Word64(0x32caab7b, 0x40c72493), new Word64(0x3c9ebe0a, 0x15c9bebc), new Word64(0x431d67c4, 0x9c100d4c), new Word64(0x4cc5d4be, 0xcb3e42b6), new Word64(0x597f299c, 0xfc657e2a), new Word64(0x5fcb6fab, 0x3ad6faec), new Word64(0x6c44198c, 0x4a475817)];
  13326. function hash(data, offset, length, mode384) {
  13327. mode384 = !!mode384;
  13328. var h0, h1, h2, h3, h4, h5, h6, h7;
  13329. if (!mode384) {
  13330. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  13331. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  13332. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  13333. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  13334. h4 = new Word64(0x510e527f, 0xade682d1);
  13335. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  13336. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  13337. h7 = new Word64(0x5be0cd19, 0x137e2179);
  13338. } else {
  13339. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  13340. h1 = new Word64(0x629a292a, 0x367cd507);
  13341. h2 = new Word64(0x9159015a, 0x3070dd17);
  13342. h3 = new Word64(0x152fecd8, 0xf70e5939);
  13343. h4 = new Word64(0x67332667, 0xffc00b31);
  13344. h5 = new Word64(0x8eb44a87, 0x68581511);
  13345. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  13346. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  13347. }
  13348. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  13349. var padded = new Uint8Array(paddedLength);
  13350. var i, j, n;
  13351. for (i = 0; i < length; ++i) {
  13352. padded[i] = data[offset++];
  13353. }
  13354. padded[i++] = 0x80;
  13355. n = paddedLength - 16;
  13356. while (i < n) {
  13357. padded[i++] = 0;
  13358. }
  13359. padded[i++] = 0;
  13360. padded[i++] = 0;
  13361. padded[i++] = 0;
  13362. padded[i++] = 0;
  13363. padded[i++] = 0;
  13364. padded[i++] = 0;
  13365. padded[i++] = 0;
  13366. padded[i++] = 0;
  13367. padded[i++] = 0;
  13368. padded[i++] = 0;
  13369. padded[i++] = 0;
  13370. padded[i++] = length >>> 29 & 0xff;
  13371. padded[i++] = length >> 21 & 0xff;
  13372. padded[i++] = length >> 13 & 0xff;
  13373. padded[i++] = length >> 5 & 0xff;
  13374. padded[i++] = length << 3 & 0xff;
  13375. var w = new Array(80);
  13376. for (i = 0; i < 80; i++) {
  13377. w[i] = new Word64(0, 0);
  13378. }
  13379. var a = new Word64(0, 0),
  13380. b = new Word64(0, 0),
  13381. c = new Word64(0, 0);
  13382. var d = new Word64(0, 0),
  13383. e = new Word64(0, 0),
  13384. f = new Word64(0, 0);
  13385. var g = new Word64(0, 0),
  13386. h = new Word64(0, 0);
  13387. var t1 = new Word64(0, 0),
  13388. t2 = new Word64(0, 0);
  13389. var tmp1 = new Word64(0, 0),
  13390. tmp2 = new Word64(0, 0),
  13391. tmp3;
  13392. for (i = 0; i < paddedLength;) {
  13393. for (j = 0; j < 16; ++j) {
  13394. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  13395. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  13396. i += 8;
  13397. }
  13398. for (j = 16; j < 80; ++j) {
  13399. tmp3 = w[j];
  13400. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  13401. tmp3.add(w[j - 7]);
  13402. littleSigma(tmp1, w[j - 15], tmp2);
  13403. tmp3.add(tmp1);
  13404. tmp3.add(w[j - 16]);
  13405. }
  13406. a.assign(h0);
  13407. b.assign(h1);
  13408. c.assign(h2);
  13409. d.assign(h3);
  13410. e.assign(h4);
  13411. f.assign(h5);
  13412. g.assign(h6);
  13413. h.assign(h7);
  13414. for (j = 0; j < 80; ++j) {
  13415. t1.assign(h);
  13416. sigmaPrime(tmp1, e, tmp2);
  13417. t1.add(tmp1);
  13418. ch(tmp1, e, f, g, tmp2);
  13419. t1.add(tmp1);
  13420. t1.add(k[j]);
  13421. t1.add(w[j]);
  13422. sigma(t2, a, tmp2);
  13423. maj(tmp1, a, b, c, tmp2);
  13424. t2.add(tmp1);
  13425. tmp3 = h;
  13426. h = g;
  13427. g = f;
  13428. f = e;
  13429. d.add(t1);
  13430. e = d;
  13431. d = c;
  13432. c = b;
  13433. b = a;
  13434. tmp3.assign(t1);
  13435. tmp3.add(t2);
  13436. a = tmp3;
  13437. }
  13438. h0.add(a);
  13439. h1.add(b);
  13440. h2.add(c);
  13441. h3.add(d);
  13442. h4.add(e);
  13443. h5.add(f);
  13444. h6.add(g);
  13445. h7.add(h);
  13446. }
  13447. var result;
  13448. if (!mode384) {
  13449. result = new Uint8Array(64);
  13450. h0.copyTo(result, 0);
  13451. h1.copyTo(result, 8);
  13452. h2.copyTo(result, 16);
  13453. h3.copyTo(result, 24);
  13454. h4.copyTo(result, 32);
  13455. h5.copyTo(result, 40);
  13456. h6.copyTo(result, 48);
  13457. h7.copyTo(result, 56);
  13458. } else {
  13459. result = new Uint8Array(48);
  13460. h0.copyTo(result, 0);
  13461. h1.copyTo(result, 8);
  13462. h2.copyTo(result, 16);
  13463. h3.copyTo(result, 24);
  13464. h4.copyTo(result, 32);
  13465. h5.copyTo(result, 40);
  13466. }
  13467. return result;
  13468. }
  13469. return hash;
  13470. }();
  13471. exports.calculateSHA512 = calculateSHA512;
  13472. var calculateSHA384 = function calculateSHA384Closure() {
  13473. function hash(data, offset, length) {
  13474. return calculateSHA512(data, offset, length, true);
  13475. }
  13476. return hash;
  13477. }();
  13478. exports.calculateSHA384 = calculateSHA384;
  13479. var NullCipher = function NullCipherClosure() {
  13480. function NullCipher() {}
  13481. NullCipher.prototype = {
  13482. decryptBlock: function NullCipher_decryptBlock(data) {
  13483. return data;
  13484. },
  13485. encrypt: function NullCipher_encrypt(data) {
  13486. return data;
  13487. }
  13488. };
  13489. return NullCipher;
  13490. }();
  13491. class AESBaseCipher {
  13492. constructor() {
  13493. if (this.constructor === AESBaseCipher) {
  13494. (0, _util.unreachable)("Cannot initialize AESBaseCipher.");
  13495. }
  13496. this._s = new Uint8Array([0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16]);
  13497. this._inv_s = new Uint8Array([0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d]);
  13498. this._mix = new Uint32Array([0x00000000, 0x0e090d0b, 0x1c121a16, 0x121b171d, 0x3824342c, 0x362d3927, 0x24362e3a, 0x2a3f2331, 0x70486858, 0x7e416553, 0x6c5a724e, 0x62537f45, 0x486c5c74, 0x4665517f, 0x547e4662, 0x5a774b69, 0xe090d0b0, 0xee99ddbb, 0xfc82caa6, 0xf28bc7ad, 0xd8b4e49c, 0xd6bde997, 0xc4a6fe8a, 0xcaaff381, 0x90d8b8e8, 0x9ed1b5e3, 0x8ccaa2fe, 0x82c3aff5, 0xa8fc8cc4, 0xa6f581cf, 0xb4ee96d2, 0xbae79bd9, 0xdb3bbb7b, 0xd532b670, 0xc729a16d, 0xc920ac66, 0xe31f8f57, 0xed16825c, 0xff0d9541, 0xf104984a, 0xab73d323, 0xa57ade28, 0xb761c935, 0xb968c43e, 0x9357e70f, 0x9d5eea04, 0x8f45fd19, 0x814cf012, 0x3bab6bcb, 0x35a266c0, 0x27b971dd, 0x29b07cd6, 0x038f5fe7, 0x0d8652ec, 0x1f9d45f1, 0x119448fa, 0x4be30393, 0x45ea0e98, 0x57f11985, 0x59f8148e, 0x73c737bf, 0x7dce3ab4, 0x6fd52da9, 0x61dc20a2, 0xad766df6, 0xa37f60fd, 0xb16477e0, 0xbf6d7aeb, 0x955259da, 0x9b5b54d1, 0x894043cc, 0x87494ec7, 0xdd3e05ae, 0xd33708a5, 0xc12c1fb8, 0xcf2512b3, 0xe51a3182, 0xeb133c89, 0xf9082b94, 0xf701269f, 0x4de6bd46, 0x43efb04d, 0x51f4a750, 0x5ffdaa5b, 0x75c2896a, 0x7bcb8461, 0x69d0937c, 0x67d99e77, 0x3daed51e, 0x33a7d815, 0x21bccf08, 0x2fb5c203, 0x058ae132, 0x0b83ec39, 0x1998fb24, 0x1791f62f, 0x764dd68d, 0x7844db86, 0x6a5fcc9b, 0x6456c190, 0x4e69e2a1, 0x4060efaa, 0x527bf8b7, 0x5c72f5bc, 0x0605bed5, 0x080cb3de, 0x1a17a4c3, 0x141ea9c8, 0x3e218af9, 0x302887f2, 0x223390ef, 0x2c3a9de4, 0x96dd063d, 0x98d40b36, 0x8acf1c2b, 0x84c61120, 0xaef93211, 0xa0f03f1a, 0xb2eb2807, 0xbce2250c, 0xe6956e65, 0xe89c636e, 0xfa877473, 0xf48e7978, 0xdeb15a49, 0xd0b85742, 0xc2a3405f, 0xccaa4d54, 0x41ecdaf7, 0x4fe5d7fc, 0x5dfec0e1, 0x53f7cdea, 0x79c8eedb, 0x77c1e3d0, 0x65daf4cd, 0x6bd3f9c6, 0x31a4b2af, 0x3fadbfa4, 0x2db6a8b9, 0x23bfa5b2, 0x09808683, 0x07898b88, 0x15929c95, 0x1b9b919e, 0xa17c0a47, 0xaf75074c, 0xbd6e1051, 0xb3671d5a, 0x99583e6b, 0x97513360, 0x854a247d, 0x8b432976, 0xd134621f, 0xdf3d6f14, 0xcd267809, 0xc32f7502, 0xe9105633, 0xe7195b38, 0xf5024c25, 0xfb0b412e, 0x9ad7618c, 0x94de6c87, 0x86c57b9a, 0x88cc7691, 0xa2f355a0, 0xacfa58ab, 0xbee14fb6, 0xb0e842bd, 0xea9f09d4, 0xe49604df, 0xf68d13c2, 0xf8841ec9, 0xd2bb3df8, 0xdcb230f3, 0xcea927ee, 0xc0a02ae5, 0x7a47b13c, 0x744ebc37, 0x6655ab2a, 0x685ca621, 0x42638510, 0x4c6a881b, 0x5e719f06, 0x5078920d, 0x0a0fd964, 0x0406d46f, 0x161dc372, 0x1814ce79, 0x322bed48, 0x3c22e043, 0x2e39f75e, 0x2030fa55, 0xec9ab701, 0xe293ba0a, 0xf088ad17, 0xfe81a01c, 0xd4be832d, 0xdab78e26, 0xc8ac993b, 0xc6a59430, 0x9cd2df59, 0x92dbd252, 0x80c0c54f, 0x8ec9c844, 0xa4f6eb75, 0xaaffe67e, 0xb8e4f163, 0xb6edfc68, 0x0c0a67b1, 0x02036aba, 0x10187da7, 0x1e1170ac, 0x342e539d, 0x3a275e96, 0x283c498b, 0x26354480, 0x7c420fe9, 0x724b02e2, 0x605015ff, 0x6e5918f4, 0x44663bc5, 0x4a6f36ce, 0x587421d3, 0x567d2cd8, 0x37a10c7a, 0x39a80171, 0x2bb3166c, 0x25ba1b67, 0x0f853856, 0x018c355d, 0x13972240, 0x1d9e2f4b, 0x47e96422, 0x49e06929, 0x5bfb7e34, 0x55f2733f, 0x7fcd500e, 0x71c45d05, 0x63df4a18, 0x6dd64713, 0xd731dcca, 0xd938d1c1, 0xcb23c6dc, 0xc52acbd7, 0xef15e8e6, 0xe11ce5ed, 0xf307f2f0, 0xfd0efffb, 0xa779b492, 0xa970b999, 0xbb6bae84, 0xb562a38f, 0x9f5d80be, 0x91548db5, 0x834f9aa8, 0x8d4697a3]);
  13499. this._mixCol = new Uint8Array(256);
  13500. for (let i = 0; i < 256; i++) {
  13501. if (i < 128) {
  13502. this._mixCol[i] = i << 1;
  13503. } else {
  13504. this._mixCol[i] = i << 1 ^ 0x1b;
  13505. }
  13506. }
  13507. this.buffer = new Uint8Array(16);
  13508. this.bufferPosition = 0;
  13509. }
  13510. _expandKey(cipherKey) {
  13511. (0, _util.unreachable)("Cannot call `_expandKey` on the base class");
  13512. }
  13513. _decrypt(input, key) {
  13514. let t, u, v;
  13515. const state = new Uint8Array(16);
  13516. state.set(input);
  13517. for (let j = 0, k = this._keySize; j < 16; ++j, ++k) {
  13518. state[j] ^= key[k];
  13519. }
  13520. for (let i = this._cyclesOfRepetition - 1; i >= 1; --i) {
  13521. t = state[13];
  13522. state[13] = state[9];
  13523. state[9] = state[5];
  13524. state[5] = state[1];
  13525. state[1] = t;
  13526. t = state[14];
  13527. u = state[10];
  13528. state[14] = state[6];
  13529. state[10] = state[2];
  13530. state[6] = t;
  13531. state[2] = u;
  13532. t = state[15];
  13533. u = state[11];
  13534. v = state[7];
  13535. state[15] = state[3];
  13536. state[11] = t;
  13537. state[7] = u;
  13538. state[3] = v;
  13539. for (let j = 0; j < 16; ++j) {
  13540. state[j] = this._inv_s[state[j]];
  13541. }
  13542. for (let j = 0, k = i * 16; j < 16; ++j, ++k) {
  13543. state[j] ^= key[k];
  13544. }
  13545. for (let j = 0; j < 16; j += 4) {
  13546. const s0 = this._mix[state[j]];
  13547. const s1 = this._mix[state[j + 1]];
  13548. const s2 = this._mix[state[j + 2]];
  13549. const s3 = this._mix[state[j + 3]];
  13550. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  13551. state[j] = t >>> 24 & 0xff;
  13552. state[j + 1] = t >> 16 & 0xff;
  13553. state[j + 2] = t >> 8 & 0xff;
  13554. state[j + 3] = t & 0xff;
  13555. }
  13556. }
  13557. t = state[13];
  13558. state[13] = state[9];
  13559. state[9] = state[5];
  13560. state[5] = state[1];
  13561. state[1] = t;
  13562. t = state[14];
  13563. u = state[10];
  13564. state[14] = state[6];
  13565. state[10] = state[2];
  13566. state[6] = t;
  13567. state[2] = u;
  13568. t = state[15];
  13569. u = state[11];
  13570. v = state[7];
  13571. state[15] = state[3];
  13572. state[11] = t;
  13573. state[7] = u;
  13574. state[3] = v;
  13575. for (let j = 0; j < 16; ++j) {
  13576. state[j] = this._inv_s[state[j]];
  13577. state[j] ^= key[j];
  13578. }
  13579. return state;
  13580. }
  13581. _encrypt(input, key) {
  13582. const s = this._s;
  13583. let t, u, v;
  13584. const state = new Uint8Array(16);
  13585. state.set(input);
  13586. for (let j = 0; j < 16; ++j) {
  13587. state[j] ^= key[j];
  13588. }
  13589. for (let i = 1; i < this._cyclesOfRepetition; i++) {
  13590. for (let j = 0; j < 16; ++j) {
  13591. state[j] = s[state[j]];
  13592. }
  13593. v = state[1];
  13594. state[1] = state[5];
  13595. state[5] = state[9];
  13596. state[9] = state[13];
  13597. state[13] = v;
  13598. v = state[2];
  13599. u = state[6];
  13600. state[2] = state[10];
  13601. state[6] = state[14];
  13602. state[10] = v;
  13603. state[14] = u;
  13604. v = state[3];
  13605. u = state[7];
  13606. t = state[11];
  13607. state[3] = state[15];
  13608. state[7] = v;
  13609. state[11] = u;
  13610. state[15] = t;
  13611. for (let j = 0; j < 16; j += 4) {
  13612. const s0 = state[j + 0];
  13613. const s1 = state[j + 1];
  13614. const s2 = state[j + 2];
  13615. const s3 = state[j + 3];
  13616. t = s0 ^ s1 ^ s2 ^ s3;
  13617. state[j + 0] ^= t ^ this._mixCol[s0 ^ s1];
  13618. state[j + 1] ^= t ^ this._mixCol[s1 ^ s2];
  13619. state[j + 2] ^= t ^ this._mixCol[s2 ^ s3];
  13620. state[j + 3] ^= t ^ this._mixCol[s3 ^ s0];
  13621. }
  13622. for (let j = 0, k = i * 16; j < 16; ++j, ++k) {
  13623. state[j] ^= key[k];
  13624. }
  13625. }
  13626. for (let j = 0; j < 16; ++j) {
  13627. state[j] = s[state[j]];
  13628. }
  13629. v = state[1];
  13630. state[1] = state[5];
  13631. state[5] = state[9];
  13632. state[9] = state[13];
  13633. state[13] = v;
  13634. v = state[2];
  13635. u = state[6];
  13636. state[2] = state[10];
  13637. state[6] = state[14];
  13638. state[10] = v;
  13639. state[14] = u;
  13640. v = state[3];
  13641. u = state[7];
  13642. t = state[11];
  13643. state[3] = state[15];
  13644. state[7] = v;
  13645. state[11] = u;
  13646. state[15] = t;
  13647. for (let j = 0, k = this._keySize; j < 16; ++j, ++k) {
  13648. state[j] ^= key[k];
  13649. }
  13650. return state;
  13651. }
  13652. _decryptBlock2(data, finalize) {
  13653. const sourceLength = data.length;
  13654. let buffer = this.buffer,
  13655. bufferLength = this.bufferPosition;
  13656. const result = [];
  13657. let iv = this.iv;
  13658. for (let i = 0; i < sourceLength; ++i) {
  13659. buffer[bufferLength] = data[i];
  13660. ++bufferLength;
  13661. if (bufferLength < 16) {
  13662. continue;
  13663. }
  13664. const plain = this._decrypt(buffer, this._key);
  13665. for (let j = 0; j < 16; ++j) {
  13666. plain[j] ^= iv[j];
  13667. }
  13668. iv = buffer;
  13669. result.push(plain);
  13670. buffer = new Uint8Array(16);
  13671. bufferLength = 0;
  13672. }
  13673. this.buffer = buffer;
  13674. this.bufferLength = bufferLength;
  13675. this.iv = iv;
  13676. if (result.length === 0) {
  13677. return new Uint8Array(0);
  13678. }
  13679. let outputLength = 16 * result.length;
  13680. if (finalize) {
  13681. const lastBlock = result[result.length - 1];
  13682. let psLen = lastBlock[15];
  13683. if (psLen <= 16) {
  13684. for (let i = 15, ii = 16 - psLen; i >= ii; --i) {
  13685. if (lastBlock[i] !== psLen) {
  13686. psLen = 0;
  13687. break;
  13688. }
  13689. }
  13690. outputLength -= psLen;
  13691. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  13692. }
  13693. }
  13694. const output = new Uint8Array(outputLength);
  13695. for (let i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  13696. output.set(result[i], j);
  13697. }
  13698. return output;
  13699. }
  13700. decryptBlock(data, finalize, iv = null) {
  13701. const sourceLength = data.length;
  13702. const buffer = this.buffer;
  13703. let bufferLength = this.bufferPosition;
  13704. if (iv) {
  13705. this.iv = iv;
  13706. } else {
  13707. for (let i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  13708. buffer[bufferLength] = data[i];
  13709. }
  13710. if (bufferLength < 16) {
  13711. this.bufferLength = bufferLength;
  13712. return new Uint8Array(0);
  13713. }
  13714. this.iv = buffer;
  13715. data = data.subarray(16);
  13716. }
  13717. this.buffer = new Uint8Array(16);
  13718. this.bufferLength = 0;
  13719. this.decryptBlock = this._decryptBlock2;
  13720. return this.decryptBlock(data, finalize);
  13721. }
  13722. encrypt(data, iv) {
  13723. const sourceLength = data.length;
  13724. let buffer = this.buffer,
  13725. bufferLength = this.bufferPosition;
  13726. const result = [];
  13727. if (!iv) {
  13728. iv = new Uint8Array(16);
  13729. }
  13730. for (let i = 0; i < sourceLength; ++i) {
  13731. buffer[bufferLength] = data[i];
  13732. ++bufferLength;
  13733. if (bufferLength < 16) {
  13734. continue;
  13735. }
  13736. for (let j = 0; j < 16; ++j) {
  13737. buffer[j] ^= iv[j];
  13738. }
  13739. const cipher = this._encrypt(buffer, this._key);
  13740. iv = cipher;
  13741. result.push(cipher);
  13742. buffer = new Uint8Array(16);
  13743. bufferLength = 0;
  13744. }
  13745. this.buffer = buffer;
  13746. this.bufferLength = bufferLength;
  13747. this.iv = iv;
  13748. if (result.length === 0) {
  13749. return new Uint8Array(0);
  13750. }
  13751. const outputLength = 16 * result.length;
  13752. const output = new Uint8Array(outputLength);
  13753. for (let i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  13754. output.set(result[i], j);
  13755. }
  13756. return output;
  13757. }
  13758. }
  13759. class AES128Cipher extends AESBaseCipher {
  13760. constructor(key) {
  13761. super();
  13762. this._cyclesOfRepetition = 10;
  13763. this._keySize = 160;
  13764. this._rcon = new Uint8Array([0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d]);
  13765. this._key = this._expandKey(key);
  13766. }
  13767. _expandKey(cipherKey) {
  13768. const b = 176;
  13769. const s = this._s;
  13770. const rcon = this._rcon;
  13771. const result = new Uint8Array(b);
  13772. result.set(cipherKey);
  13773. for (let j = 16, i = 1; j < b; ++i) {
  13774. let t1 = result[j - 3];
  13775. let t2 = result[j - 2];
  13776. let t3 = result[j - 1];
  13777. let t4 = result[j - 4];
  13778. t1 = s[t1];
  13779. t2 = s[t2];
  13780. t3 = s[t3];
  13781. t4 = s[t4];
  13782. t1 = t1 ^ rcon[i];
  13783. for (let n = 0; n < 4; ++n) {
  13784. result[j] = t1 ^= result[j - 16];
  13785. j++;
  13786. result[j] = t2 ^= result[j - 16];
  13787. j++;
  13788. result[j] = t3 ^= result[j - 16];
  13789. j++;
  13790. result[j] = t4 ^= result[j - 16];
  13791. j++;
  13792. }
  13793. }
  13794. return result;
  13795. }
  13796. }
  13797. exports.AES128Cipher = AES128Cipher;
  13798. class AES256Cipher extends AESBaseCipher {
  13799. constructor(key) {
  13800. super();
  13801. this._cyclesOfRepetition = 14;
  13802. this._keySize = 224;
  13803. this._key = this._expandKey(key);
  13804. }
  13805. _expandKey(cipherKey) {
  13806. const b = 240;
  13807. const s = this._s;
  13808. const result = new Uint8Array(b);
  13809. result.set(cipherKey);
  13810. let r = 1;
  13811. let t1, t2, t3, t4;
  13812. for (let j = 32, i = 1; j < b; ++i) {
  13813. if (j % 32 === 16) {
  13814. t1 = s[t1];
  13815. t2 = s[t2];
  13816. t3 = s[t3];
  13817. t4 = s[t4];
  13818. } else if (j % 32 === 0) {
  13819. t1 = result[j - 3];
  13820. t2 = result[j - 2];
  13821. t3 = result[j - 1];
  13822. t4 = result[j - 4];
  13823. t1 = s[t1];
  13824. t2 = s[t2];
  13825. t3 = s[t3];
  13826. t4 = s[t4];
  13827. t1 = t1 ^ r;
  13828. if ((r <<= 1) >= 256) {
  13829. r = (r ^ 0x1b) & 0xff;
  13830. }
  13831. }
  13832. for (let n = 0; n < 4; ++n) {
  13833. result[j] = t1 ^= result[j - 32];
  13834. j++;
  13835. result[j] = t2 ^= result[j - 32];
  13836. j++;
  13837. result[j] = t3 ^= result[j - 32];
  13838. j++;
  13839. result[j] = t4 ^= result[j - 32];
  13840. j++;
  13841. }
  13842. }
  13843. return result;
  13844. }
  13845. }
  13846. exports.AES256Cipher = AES256Cipher;
  13847. var PDF17 = function PDF17Closure() {
  13848. function compareByteArrays(array1, array2) {
  13849. if (array1.length !== array2.length) {
  13850. return false;
  13851. }
  13852. for (var i = 0; i < array1.length; i++) {
  13853. if (array1[i] !== array2[i]) {
  13854. return false;
  13855. }
  13856. }
  13857. return true;
  13858. }
  13859. function PDF17() {}
  13860. PDF17.prototype = {
  13861. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  13862. var hashData = new Uint8Array(password.length + 56);
  13863. hashData.set(password, 0);
  13864. hashData.set(ownerValidationSalt, password.length);
  13865. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  13866. var result = calculateSHA256(hashData, 0, hashData.length);
  13867. return compareByteArrays(result, ownerPassword);
  13868. },
  13869. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  13870. var hashData = new Uint8Array(password.length + 8);
  13871. hashData.set(password, 0);
  13872. hashData.set(userValidationSalt, password.length);
  13873. var result = calculateSHA256(hashData, 0, hashData.length);
  13874. return compareByteArrays(result, userPassword);
  13875. },
  13876. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  13877. var hashData = new Uint8Array(password.length + 56);
  13878. hashData.set(password, 0);
  13879. hashData.set(ownerKeySalt, password.length);
  13880. hashData.set(userBytes, password.length + ownerKeySalt.length);
  13881. var key = calculateSHA256(hashData, 0, hashData.length);
  13882. var cipher = new AES256Cipher(key);
  13883. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  13884. },
  13885. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  13886. var hashData = new Uint8Array(password.length + 8);
  13887. hashData.set(password, 0);
  13888. hashData.set(userKeySalt, password.length);
  13889. var key = calculateSHA256(hashData, 0, hashData.length);
  13890. var cipher = new AES256Cipher(key);
  13891. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  13892. }
  13893. };
  13894. return PDF17;
  13895. }();
  13896. exports.PDF17 = PDF17;
  13897. var PDF20 = function PDF20Closure() {
  13898. function concatArrays(array1, array2) {
  13899. var t = new Uint8Array(array1.length + array2.length);
  13900. t.set(array1, 0);
  13901. t.set(array2, array1.length);
  13902. return t;
  13903. }
  13904. function calculatePDF20Hash(password, input, userBytes) {
  13905. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  13906. var e = [0];
  13907. var i = 0;
  13908. while (i < 64 || e[e.length - 1] > i - 32) {
  13909. var arrayLength = password.length + k.length + userBytes.length;
  13910. var k1 = new Uint8Array(arrayLength * 64);
  13911. var array = concatArrays(password, k);
  13912. array = concatArrays(array, userBytes);
  13913. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  13914. k1.set(array, pos);
  13915. }
  13916. var cipher = new AES128Cipher(k.subarray(0, 16));
  13917. e = cipher.encrypt(k1, k.subarray(16, 32));
  13918. var remainder = 0;
  13919. for (var z = 0; z < 16; z++) {
  13920. remainder *= 256 % 3;
  13921. remainder %= 3;
  13922. remainder += (e[z] >>> 0) % 3;
  13923. remainder %= 3;
  13924. }
  13925. if (remainder === 0) {
  13926. k = calculateSHA256(e, 0, e.length);
  13927. } else if (remainder === 1) {
  13928. k = calculateSHA384(e, 0, e.length);
  13929. } else if (remainder === 2) {
  13930. k = calculateSHA512(e, 0, e.length);
  13931. }
  13932. i++;
  13933. }
  13934. return k.subarray(0, 32);
  13935. }
  13936. function PDF20() {}
  13937. function compareByteArrays(array1, array2) {
  13938. if (array1.length !== array2.length) {
  13939. return false;
  13940. }
  13941. for (var i = 0; i < array1.length; i++) {
  13942. if (array1[i] !== array2[i]) {
  13943. return false;
  13944. }
  13945. }
  13946. return true;
  13947. }
  13948. PDF20.prototype = {
  13949. hash: function PDF20_hash(password, concatBytes, userBytes) {
  13950. return calculatePDF20Hash(password, concatBytes, userBytes);
  13951. },
  13952. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  13953. var hashData = new Uint8Array(password.length + 56);
  13954. hashData.set(password, 0);
  13955. hashData.set(ownerValidationSalt, password.length);
  13956. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  13957. var result = calculatePDF20Hash(password, hashData, userBytes);
  13958. return compareByteArrays(result, ownerPassword);
  13959. },
  13960. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  13961. var hashData = new Uint8Array(password.length + 8);
  13962. hashData.set(password, 0);
  13963. hashData.set(userValidationSalt, password.length);
  13964. var result = calculatePDF20Hash(password, hashData, []);
  13965. return compareByteArrays(result, userPassword);
  13966. },
  13967. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  13968. var hashData = new Uint8Array(password.length + 56);
  13969. hashData.set(password, 0);
  13970. hashData.set(ownerKeySalt, password.length);
  13971. hashData.set(userBytes, password.length + ownerKeySalt.length);
  13972. var key = calculatePDF20Hash(password, hashData, userBytes);
  13973. var cipher = new AES256Cipher(key);
  13974. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  13975. },
  13976. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  13977. var hashData = new Uint8Array(password.length + 8);
  13978. hashData.set(password, 0);
  13979. hashData.set(userKeySalt, password.length);
  13980. var key = calculatePDF20Hash(password, hashData, []);
  13981. var cipher = new AES256Cipher(key);
  13982. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  13983. }
  13984. };
  13985. return PDF20;
  13986. }();
  13987. exports.PDF20 = PDF20;
  13988. var CipherTransform = function CipherTransformClosure() {
  13989. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  13990. this.StringCipherConstructor = stringCipherConstructor;
  13991. this.StreamCipherConstructor = streamCipherConstructor;
  13992. }
  13993. CipherTransform.prototype = {
  13994. createStream: function CipherTransform_createStream(stream, length) {
  13995. var cipher = new this.StreamCipherConstructor();
  13996. return new _stream.DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  13997. return cipher.decryptBlock(data, finalize);
  13998. });
  13999. },
  14000. decryptString: function CipherTransform_decryptString(s) {
  14001. var cipher = new this.StringCipherConstructor();
  14002. var data = (0, _util.stringToBytes)(s);
  14003. data = cipher.decryptBlock(data, true);
  14004. return (0, _util.bytesToString)(data);
  14005. },
  14006. encryptString: function CipherTransform_encryptString(s) {
  14007. const cipher = new this.StringCipherConstructor();
  14008. if (cipher instanceof AESBaseCipher) {
  14009. const strLen = s.length;
  14010. const pad = 16 - strLen % 16;
  14011. if (pad !== 16) {
  14012. s = s.padEnd(16 * Math.ceil(strLen / 16), String.fromCharCode(pad));
  14013. }
  14014. const iv = new Uint8Array(16);
  14015. if (typeof crypto !== "undefined") {
  14016. crypto.getRandomValues(iv);
  14017. } else {
  14018. for (let i = 0; i < 16; i++) {
  14019. iv[i] = Math.floor(256 * Math.random());
  14020. }
  14021. }
  14022. let data = (0, _util.stringToBytes)(s);
  14023. data = cipher.encrypt(data, iv);
  14024. const buf = new Uint8Array(16 + data.length);
  14025. buf.set(iv);
  14026. buf.set(data, 16);
  14027. return (0, _util.bytesToString)(buf);
  14028. }
  14029. let data = (0, _util.stringToBytes)(s);
  14030. data = cipher.encrypt(data);
  14031. return (0, _util.bytesToString)(data);
  14032. }
  14033. };
  14034. return CipherTransform;
  14035. }();
  14036. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  14037. var defaultPasswordBytes = new Uint8Array([0x28, 0xBF, 0x4E, 0x5E, 0x4E, 0x75, 0x8A, 0x41, 0x64, 0x00, 0x4E, 0x56, 0xFF, 0xFA, 0x01, 0x08, 0x2E, 0x2E, 0x00, 0xB6, 0xD0, 0x68, 0x3E, 0x80, 0x2F, 0x0C, 0xA9, 0xFE, 0x64, 0x53, 0x69, 0x7A]);
  14038. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  14039. if (password) {
  14040. var passwordLength = Math.min(127, password.length);
  14041. password = password.subarray(0, passwordLength);
  14042. } else {
  14043. password = [];
  14044. }
  14045. var pdfAlgorithm;
  14046. if (revision === 6) {
  14047. pdfAlgorithm = new PDF20();
  14048. } else {
  14049. pdfAlgorithm = new PDF17();
  14050. }
  14051. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  14052. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  14053. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  14054. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  14055. }
  14056. return null;
  14057. }
  14058. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  14059. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  14060. var hashData = new Uint8Array(hashDataSize),
  14061. i = 0,
  14062. j,
  14063. n;
  14064. if (password) {
  14065. n = Math.min(32, password.length);
  14066. for (; i < n; ++i) {
  14067. hashData[i] = password[i];
  14068. }
  14069. }
  14070. j = 0;
  14071. while (i < 32) {
  14072. hashData[i++] = defaultPasswordBytes[j++];
  14073. }
  14074. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  14075. hashData[i++] = ownerPassword[j];
  14076. }
  14077. hashData[i++] = flags & 0xff;
  14078. hashData[i++] = flags >> 8 & 0xff;
  14079. hashData[i++] = flags >> 16 & 0xff;
  14080. hashData[i++] = flags >>> 24 & 0xff;
  14081. for (j = 0, n = fileId.length; j < n; ++j) {
  14082. hashData[i++] = fileId[j];
  14083. }
  14084. if (revision >= 4 && !encryptMetadata) {
  14085. hashData[i++] = 0xff;
  14086. hashData[i++] = 0xff;
  14087. hashData[i++] = 0xff;
  14088. hashData[i++] = 0xff;
  14089. }
  14090. var hash = calculateMD5(hashData, 0, i);
  14091. var keyLengthInBytes = keyLength >> 3;
  14092. if (revision >= 3) {
  14093. for (j = 0; j < 50; ++j) {
  14094. hash = calculateMD5(hash, 0, keyLengthInBytes);
  14095. }
  14096. }
  14097. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  14098. var cipher, checkData;
  14099. if (revision >= 3) {
  14100. for (i = 0; i < 32; ++i) {
  14101. hashData[i] = defaultPasswordBytes[i];
  14102. }
  14103. for (j = 0, n = fileId.length; j < n; ++j) {
  14104. hashData[i++] = fileId[j];
  14105. }
  14106. cipher = new ARCFourCipher(encryptionKey);
  14107. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  14108. n = encryptionKey.length;
  14109. var derivedKey = new Uint8Array(n),
  14110. k;
  14111. for (j = 1; j <= 19; ++j) {
  14112. for (k = 0; k < n; ++k) {
  14113. derivedKey[k] = encryptionKey[k] ^ j;
  14114. }
  14115. cipher = new ARCFourCipher(derivedKey);
  14116. checkData = cipher.encryptBlock(checkData);
  14117. }
  14118. for (j = 0, n = checkData.length; j < n; ++j) {
  14119. if (userPassword[j] !== checkData[j]) {
  14120. return null;
  14121. }
  14122. }
  14123. } else {
  14124. cipher = new ARCFourCipher(encryptionKey);
  14125. checkData = cipher.encryptBlock(defaultPasswordBytes);
  14126. for (j = 0, n = checkData.length; j < n; ++j) {
  14127. if (userPassword[j] !== checkData[j]) {
  14128. return null;
  14129. }
  14130. }
  14131. }
  14132. return encryptionKey;
  14133. }
  14134. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  14135. var hashData = new Uint8Array(32),
  14136. i = 0,
  14137. j,
  14138. n;
  14139. n = Math.min(32, password.length);
  14140. for (; i < n; ++i) {
  14141. hashData[i] = password[i];
  14142. }
  14143. j = 0;
  14144. while (i < 32) {
  14145. hashData[i++] = defaultPasswordBytes[j++];
  14146. }
  14147. var hash = calculateMD5(hashData, 0, i);
  14148. var keyLengthInBytes = keyLength >> 3;
  14149. if (revision >= 3) {
  14150. for (j = 0; j < 50; ++j) {
  14151. hash = calculateMD5(hash, 0, hash.length);
  14152. }
  14153. }
  14154. var cipher, userPassword;
  14155. if (revision >= 3) {
  14156. userPassword = ownerPassword;
  14157. var derivedKey = new Uint8Array(keyLengthInBytes),
  14158. k;
  14159. for (j = 19; j >= 0; j--) {
  14160. for (k = 0; k < keyLengthInBytes; ++k) {
  14161. derivedKey[k] = hash[k] ^ j;
  14162. }
  14163. cipher = new ARCFourCipher(derivedKey);
  14164. userPassword = cipher.encryptBlock(userPassword);
  14165. }
  14166. } else {
  14167. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  14168. userPassword = cipher.encryptBlock(ownerPassword);
  14169. }
  14170. return userPassword;
  14171. }
  14172. var identityName = _primitives.Name.get("Identity");
  14173. function CipherTransformFactory(dict, fileId, password) {
  14174. var filter = dict.get("Filter");
  14175. if (!(0, _primitives.isName)(filter, "Standard")) {
  14176. throw new _util.FormatError("unknown encryption method");
  14177. }
  14178. this.dict = dict;
  14179. var algorithm = dict.get("V");
  14180. if (!Number.isInteger(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  14181. throw new _util.FormatError("unsupported encryption algorithm");
  14182. }
  14183. this.algorithm = algorithm;
  14184. var keyLength = dict.get("Length");
  14185. if (!keyLength) {
  14186. if (algorithm <= 3) {
  14187. keyLength = 40;
  14188. } else {
  14189. var cfDict = dict.get("CF");
  14190. var streamCryptoName = dict.get("StmF");
  14191. if ((0, _primitives.isDict)(cfDict) && (0, _primitives.isName)(streamCryptoName)) {
  14192. cfDict.suppressEncryption = true;
  14193. var handlerDict = cfDict.get(streamCryptoName.name);
  14194. keyLength = handlerDict && handlerDict.get("Length") || 128;
  14195. if (keyLength < 40) {
  14196. keyLength <<= 3;
  14197. }
  14198. }
  14199. }
  14200. }
  14201. if (!Number.isInteger(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  14202. throw new _util.FormatError("invalid key length");
  14203. }
  14204. var ownerPassword = (0, _util.stringToBytes)(dict.get("O")).subarray(0, 32);
  14205. var userPassword = (0, _util.stringToBytes)(dict.get("U")).subarray(0, 32);
  14206. var flags = dict.get("P");
  14207. var revision = dict.get("R");
  14208. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get("EncryptMetadata") !== false;
  14209. this.encryptMetadata = encryptMetadata;
  14210. var fileIdBytes = (0, _util.stringToBytes)(fileId);
  14211. var passwordBytes;
  14212. if (password) {
  14213. if (revision === 6) {
  14214. try {
  14215. password = (0, _util.utf8StringToString)(password);
  14216. } catch (ex) {
  14217. (0, _util.warn)("CipherTransformFactory: " + "Unable to convert UTF8 encoded password.");
  14218. }
  14219. }
  14220. passwordBytes = (0, _util.stringToBytes)(password);
  14221. }
  14222. var encryptionKey;
  14223. if (algorithm !== 5) {
  14224. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  14225. } else {
  14226. var ownerValidationSalt = (0, _util.stringToBytes)(dict.get("O")).subarray(32, 40);
  14227. var ownerKeySalt = (0, _util.stringToBytes)(dict.get("O")).subarray(40, 48);
  14228. var uBytes = (0, _util.stringToBytes)(dict.get("U")).subarray(0, 48);
  14229. var userValidationSalt = (0, _util.stringToBytes)(dict.get("U")).subarray(32, 40);
  14230. var userKeySalt = (0, _util.stringToBytes)(dict.get("U")).subarray(40, 48);
  14231. var ownerEncryption = (0, _util.stringToBytes)(dict.get("OE"));
  14232. var userEncryption = (0, _util.stringToBytes)(dict.get("UE"));
  14233. var perms = (0, _util.stringToBytes)(dict.get("Perms"));
  14234. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  14235. }
  14236. if (!encryptionKey && !password) {
  14237. throw new _util.PasswordException("No password given", _util.PasswordResponses.NEED_PASSWORD);
  14238. } else if (!encryptionKey && password) {
  14239. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  14240. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  14241. }
  14242. if (!encryptionKey) {
  14243. throw new _util.PasswordException("Incorrect Password", _util.PasswordResponses.INCORRECT_PASSWORD);
  14244. }
  14245. this.encryptionKey = encryptionKey;
  14246. if (algorithm >= 4) {
  14247. var cf = dict.get("CF");
  14248. if ((0, _primitives.isDict)(cf)) {
  14249. cf.suppressEncryption = true;
  14250. }
  14251. this.cf = cf;
  14252. this.stmf = dict.get("StmF") || identityName;
  14253. this.strf = dict.get("StrF") || identityName;
  14254. this.eff = dict.get("EFF") || this.stmf;
  14255. }
  14256. }
  14257. function buildObjectKey(num, gen, encryptionKey, isAes) {
  14258. var key = new Uint8Array(encryptionKey.length + 9),
  14259. i,
  14260. n;
  14261. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  14262. key[i] = encryptionKey[i];
  14263. }
  14264. key[i++] = num & 0xff;
  14265. key[i++] = num >> 8 & 0xff;
  14266. key[i++] = num >> 16 & 0xff;
  14267. key[i++] = gen & 0xff;
  14268. key[i++] = gen >> 8 & 0xff;
  14269. if (isAes) {
  14270. key[i++] = 0x73;
  14271. key[i++] = 0x41;
  14272. key[i++] = 0x6c;
  14273. key[i++] = 0x54;
  14274. }
  14275. var hash = calculateMD5(key, 0, i);
  14276. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  14277. }
  14278. function buildCipherConstructor(cf, name, num, gen, key) {
  14279. if (!(0, _primitives.isName)(name)) {
  14280. throw new _util.FormatError("Invalid crypt filter name.");
  14281. }
  14282. var cryptFilter = cf.get(name.name);
  14283. var cfm;
  14284. if (cryptFilter !== null && cryptFilter !== undefined) {
  14285. cfm = cryptFilter.get("CFM");
  14286. }
  14287. if (!cfm || cfm.name === "None") {
  14288. return function cipherTransformFactoryBuildCipherConstructorNone() {
  14289. return new NullCipher();
  14290. };
  14291. }
  14292. if (cfm.name === "V2") {
  14293. return function cipherTransformFactoryBuildCipherConstructorV2() {
  14294. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  14295. };
  14296. }
  14297. if (cfm.name === "AESV2") {
  14298. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  14299. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  14300. };
  14301. }
  14302. if (cfm.name === "AESV3") {
  14303. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  14304. return new AES256Cipher(key);
  14305. };
  14306. }
  14307. throw new _util.FormatError("Unknown crypto method");
  14308. }
  14309. CipherTransformFactory.prototype = {
  14310. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  14311. if (this.algorithm === 4 || this.algorithm === 5) {
  14312. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  14313. }
  14314. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  14315. var cipherConstructor = function buildCipherCipherConstructor() {
  14316. return new ARCFourCipher(key);
  14317. };
  14318. return new CipherTransform(cipherConstructor, cipherConstructor);
  14319. }
  14320. };
  14321. return CipherTransformFactory;
  14322. }();
  14323. exports.CipherTransformFactory = CipherTransformFactory;
  14324. /***/ }),
  14325. /* 23 */
  14326. /***/ (function(module, exports, __w_pdfjs_require__) {
  14327. "use strict";
  14328. Object.defineProperty(exports, "__esModule", {
  14329. value: true
  14330. });
  14331. exports.ColorSpace = void 0;
  14332. var _util = __w_pdfjs_require__(2);
  14333. var _primitives = __w_pdfjs_require__(5);
  14334. var _core_utils = __w_pdfjs_require__(8);
  14335. function resizeRgbImage(src, dest, w1, h1, w2, h2, alpha01) {
  14336. const COMPONENTS = 3;
  14337. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  14338. const xRatio = w1 / w2;
  14339. const yRatio = h1 / h2;
  14340. let newIndex = 0,
  14341. oldIndex;
  14342. const xScaled = new Uint16Array(w2);
  14343. const w1Scanline = w1 * COMPONENTS;
  14344. for (let i = 0; i < w2; i++) {
  14345. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  14346. }
  14347. for (let i = 0; i < h2; i++) {
  14348. const py = Math.floor(i * yRatio) * w1Scanline;
  14349. for (let j = 0; j < w2; j++) {
  14350. oldIndex = py + xScaled[j];
  14351. dest[newIndex++] = src[oldIndex++];
  14352. dest[newIndex++] = src[oldIndex++];
  14353. dest[newIndex++] = src[oldIndex++];
  14354. newIndex += alpha01;
  14355. }
  14356. }
  14357. }
  14358. class ColorSpace {
  14359. constructor(name, numComps) {
  14360. if (this.constructor === ColorSpace) {
  14361. (0, _util.unreachable)("Cannot initialize ColorSpace.");
  14362. }
  14363. this.name = name;
  14364. this.numComps = numComps;
  14365. }
  14366. getRgb(src, srcOffset) {
  14367. const rgb = new Uint8ClampedArray(3);
  14368. this.getRgbItem(src, srcOffset, rgb, 0);
  14369. return rgb;
  14370. }
  14371. getRgbItem(src, srcOffset, dest, destOffset) {
  14372. (0, _util.unreachable)("Should not call ColorSpace.getRgbItem");
  14373. }
  14374. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  14375. (0, _util.unreachable)("Should not call ColorSpace.getRgbBuffer");
  14376. }
  14377. getOutputLength(inputLength, alpha01) {
  14378. (0, _util.unreachable)("Should not call ColorSpace.getOutputLength");
  14379. }
  14380. isPassthrough(bits) {
  14381. return false;
  14382. }
  14383. isDefaultDecode(decodeMap, bpc) {
  14384. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  14385. }
  14386. fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  14387. const count = originalWidth * originalHeight;
  14388. let rgbBuf = null;
  14389. const numComponentColors = 1 << bpc;
  14390. const needsResizing = originalHeight !== height || originalWidth !== width;
  14391. if (this.isPassthrough(bpc)) {
  14392. rgbBuf = comps;
  14393. } else if (this.numComps === 1 && count > numComponentColors && this.name !== "DeviceGray" && this.name !== "DeviceRGB") {
  14394. const allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  14395. for (let i = 0; i < numComponentColors; i++) {
  14396. allColors[i] = i;
  14397. }
  14398. const colorMap = new Uint8ClampedArray(numComponentColors * 3);
  14399. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  14400. if (!needsResizing) {
  14401. let destPos = 0;
  14402. for (let i = 0; i < count; ++i) {
  14403. const key = comps[i] * 3;
  14404. dest[destPos++] = colorMap[key];
  14405. dest[destPos++] = colorMap[key + 1];
  14406. dest[destPos++] = colorMap[key + 2];
  14407. destPos += alpha01;
  14408. }
  14409. } else {
  14410. rgbBuf = new Uint8Array(count * 3);
  14411. let rgbPos = 0;
  14412. for (let i = 0; i < count; ++i) {
  14413. const key = comps[i] * 3;
  14414. rgbBuf[rgbPos++] = colorMap[key];
  14415. rgbBuf[rgbPos++] = colorMap[key + 1];
  14416. rgbBuf[rgbPos++] = colorMap[key + 2];
  14417. }
  14418. }
  14419. } else {
  14420. if (!needsResizing) {
  14421. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  14422. } else {
  14423. rgbBuf = new Uint8ClampedArray(count * 3);
  14424. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  14425. }
  14426. }
  14427. if (rgbBuf) {
  14428. if (needsResizing) {
  14429. resizeRgbImage(rgbBuf, dest, originalWidth, originalHeight, width, height, alpha01);
  14430. } else {
  14431. let destPos = 0,
  14432. rgbPos = 0;
  14433. for (let i = 0, ii = width * actualHeight; i < ii; i++) {
  14434. dest[destPos++] = rgbBuf[rgbPos++];
  14435. dest[destPos++] = rgbBuf[rgbPos++];
  14436. dest[destPos++] = rgbBuf[rgbPos++];
  14437. destPos += alpha01;
  14438. }
  14439. }
  14440. }
  14441. }
  14442. get usesZeroToOneRange() {
  14443. return (0, _util.shadow)(this, "usesZeroToOneRange", true);
  14444. }
  14445. static _cache(cacheKey, xref, localColorSpaceCache, parsedColorSpace) {
  14446. if (!localColorSpaceCache) {
  14447. throw new Error('ColorSpace._cache - expected "localColorSpaceCache" argument.');
  14448. }
  14449. if (!parsedColorSpace) {
  14450. throw new Error('ColorSpace._cache - expected "parsedColorSpace" argument.');
  14451. }
  14452. let csName, csRef;
  14453. if (cacheKey instanceof _primitives.Ref) {
  14454. csRef = cacheKey;
  14455. cacheKey = xref.fetch(cacheKey);
  14456. }
  14457. if (cacheKey instanceof _primitives.Name) {
  14458. csName = cacheKey.name;
  14459. }
  14460. if (csName || csRef) {
  14461. localColorSpaceCache.set(csName, csRef, parsedColorSpace);
  14462. }
  14463. }
  14464. static getCached(cacheKey, xref, localColorSpaceCache) {
  14465. if (!localColorSpaceCache) {
  14466. throw new Error('ColorSpace.getCached - expected "localColorSpaceCache" argument.');
  14467. }
  14468. if (cacheKey instanceof _primitives.Ref) {
  14469. const localColorSpace = localColorSpaceCache.getByRef(cacheKey);
  14470. if (localColorSpace) {
  14471. return localColorSpace;
  14472. }
  14473. try {
  14474. cacheKey = xref.fetch(cacheKey);
  14475. } catch (ex) {
  14476. if (ex instanceof _core_utils.MissingDataException) {
  14477. throw ex;
  14478. }
  14479. }
  14480. }
  14481. if (cacheKey instanceof _primitives.Name) {
  14482. const localColorSpace = localColorSpaceCache.getByName(cacheKey.name);
  14483. if (localColorSpace) {
  14484. return localColorSpace;
  14485. }
  14486. }
  14487. return null;
  14488. }
  14489. static async parseAsync({
  14490. cs,
  14491. xref,
  14492. resources = null,
  14493. pdfFunctionFactory,
  14494. localColorSpaceCache
  14495. }) {
  14496. const parsedColorSpace = this._parse(cs, xref, resources, pdfFunctionFactory);
  14497. this._cache(cs, xref, localColorSpaceCache, parsedColorSpace);
  14498. return parsedColorSpace;
  14499. }
  14500. static parse({
  14501. cs,
  14502. xref,
  14503. resources = null,
  14504. pdfFunctionFactory,
  14505. localColorSpaceCache
  14506. }) {
  14507. const cachedColorSpace = this.getCached(cs, xref, localColorSpaceCache);
  14508. if (cachedColorSpace) {
  14509. return cachedColorSpace;
  14510. }
  14511. const parsedColorSpace = this._parse(cs, xref, resources, pdfFunctionFactory);
  14512. this._cache(cs, xref, localColorSpaceCache, parsedColorSpace);
  14513. return parsedColorSpace;
  14514. }
  14515. static _parse(cs, xref, resources = null, pdfFunctionFactory) {
  14516. cs = xref.fetchIfRef(cs);
  14517. if ((0, _primitives.isName)(cs)) {
  14518. switch (cs.name) {
  14519. case "DeviceGray":
  14520. case "G":
  14521. return this.singletons.gray;
  14522. case "DeviceRGB":
  14523. case "RGB":
  14524. return this.singletons.rgb;
  14525. case "DeviceCMYK":
  14526. case "CMYK":
  14527. return this.singletons.cmyk;
  14528. case "Pattern":
  14529. return new PatternCS(null);
  14530. default:
  14531. if ((0, _primitives.isDict)(resources)) {
  14532. const colorSpaces = resources.get("ColorSpace");
  14533. if ((0, _primitives.isDict)(colorSpaces)) {
  14534. const resourcesCS = colorSpaces.get(cs.name);
  14535. if (resourcesCS) {
  14536. if ((0, _primitives.isName)(resourcesCS)) {
  14537. return this._parse(resourcesCS, xref, resources, pdfFunctionFactory);
  14538. }
  14539. cs = resourcesCS;
  14540. break;
  14541. }
  14542. }
  14543. }
  14544. throw new _util.FormatError(`Unrecognized ColorSpace: ${cs.name}`);
  14545. }
  14546. }
  14547. if (Array.isArray(cs)) {
  14548. const mode = xref.fetchIfRef(cs[0]).name;
  14549. let params, numComps, baseCS, whitePoint, blackPoint, gamma;
  14550. switch (mode) {
  14551. case "DeviceGray":
  14552. case "G":
  14553. return this.singletons.gray;
  14554. case "DeviceRGB":
  14555. case "RGB":
  14556. return this.singletons.rgb;
  14557. case "DeviceCMYK":
  14558. case "CMYK":
  14559. return this.singletons.cmyk;
  14560. case "CalGray":
  14561. params = xref.fetchIfRef(cs[1]);
  14562. whitePoint = params.getArray("WhitePoint");
  14563. blackPoint = params.getArray("BlackPoint");
  14564. gamma = params.get("Gamma");
  14565. return new CalGrayCS(whitePoint, blackPoint, gamma);
  14566. case "CalRGB":
  14567. params = xref.fetchIfRef(cs[1]);
  14568. whitePoint = params.getArray("WhitePoint");
  14569. blackPoint = params.getArray("BlackPoint");
  14570. gamma = params.getArray("Gamma");
  14571. const matrix = params.getArray("Matrix");
  14572. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  14573. case "ICCBased":
  14574. const stream = xref.fetchIfRef(cs[1]);
  14575. const dict = stream.dict;
  14576. numComps = dict.get("N");
  14577. const alt = dict.get("Alternate");
  14578. if (alt) {
  14579. const altCS = this._parse(alt, xref, resources, pdfFunctionFactory);
  14580. if (altCS.numComps === numComps) {
  14581. return altCS;
  14582. }
  14583. (0, _util.warn)("ICCBased color space: Ignoring incorrect /Alternate entry.");
  14584. }
  14585. if (numComps === 1) {
  14586. return this.singletons.gray;
  14587. } else if (numComps === 3) {
  14588. return this.singletons.rgb;
  14589. } else if (numComps === 4) {
  14590. return this.singletons.cmyk;
  14591. }
  14592. break;
  14593. case "Pattern":
  14594. baseCS = cs[1] || null;
  14595. if (baseCS) {
  14596. baseCS = this._parse(baseCS, xref, resources, pdfFunctionFactory);
  14597. }
  14598. return new PatternCS(baseCS);
  14599. case "Indexed":
  14600. case "I":
  14601. baseCS = this._parse(cs[1], xref, resources, pdfFunctionFactory);
  14602. const hiVal = xref.fetchIfRef(cs[2]) + 1;
  14603. const lookup = xref.fetchIfRef(cs[3]);
  14604. return new IndexedCS(baseCS, hiVal, lookup);
  14605. case "Separation":
  14606. case "DeviceN":
  14607. const name = xref.fetchIfRef(cs[1]);
  14608. numComps = Array.isArray(name) ? name.length : 1;
  14609. baseCS = this._parse(cs[2], xref, resources, pdfFunctionFactory);
  14610. const tintFn = pdfFunctionFactory.create(cs[3]);
  14611. return new AlternateCS(numComps, baseCS, tintFn);
  14612. case "Lab":
  14613. params = xref.fetchIfRef(cs[1]);
  14614. whitePoint = params.getArray("WhitePoint");
  14615. blackPoint = params.getArray("BlackPoint");
  14616. const range = params.getArray("Range");
  14617. return new LabCS(whitePoint, blackPoint, range);
  14618. default:
  14619. throw new _util.FormatError(`Unimplemented ColorSpace object: ${mode}`);
  14620. }
  14621. }
  14622. throw new _util.FormatError(`Unrecognized ColorSpace object: ${cs}`);
  14623. }
  14624. static isDefaultDecode(decode, numComps) {
  14625. if (!Array.isArray(decode)) {
  14626. return true;
  14627. }
  14628. if (numComps * 2 !== decode.length) {
  14629. (0, _util.warn)("The decode map is not the correct length");
  14630. return true;
  14631. }
  14632. for (let i = 0, ii = decode.length; i < ii; i += 2) {
  14633. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  14634. return false;
  14635. }
  14636. }
  14637. return true;
  14638. }
  14639. static get singletons() {
  14640. return (0, _util.shadow)(this, "singletons", {
  14641. get gray() {
  14642. return (0, _util.shadow)(this, "gray", new DeviceGrayCS());
  14643. },
  14644. get rgb() {
  14645. return (0, _util.shadow)(this, "rgb", new DeviceRgbCS());
  14646. },
  14647. get cmyk() {
  14648. return (0, _util.shadow)(this, "cmyk", new DeviceCmykCS());
  14649. }
  14650. });
  14651. }
  14652. }
  14653. exports.ColorSpace = ColorSpace;
  14654. class AlternateCS extends ColorSpace {
  14655. constructor(numComps, base, tintFn) {
  14656. super("Alternate", numComps);
  14657. this.base = base;
  14658. this.tintFn = tintFn;
  14659. this.tmpBuf = new Float32Array(base.numComps);
  14660. }
  14661. getRgbItem(src, srcOffset, dest, destOffset) {
  14662. const tmpBuf = this.tmpBuf;
  14663. this.tintFn(src, srcOffset, tmpBuf, 0);
  14664. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  14665. }
  14666. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  14667. const tintFn = this.tintFn;
  14668. const base = this.base;
  14669. const scale = 1 / ((1 << bits) - 1);
  14670. const baseNumComps = base.numComps;
  14671. const usesZeroToOneRange = base.usesZeroToOneRange;
  14672. const isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  14673. let pos = isPassthrough ? destOffset : 0;
  14674. const baseBuf = isPassthrough ? dest : new Uint8ClampedArray(baseNumComps * count);
  14675. const numComps = this.numComps;
  14676. const scaled = new Float32Array(numComps);
  14677. const tinted = new Float32Array(baseNumComps);
  14678. let i, j;
  14679. for (i = 0; i < count; i++) {
  14680. for (j = 0; j < numComps; j++) {
  14681. scaled[j] = src[srcOffset++] * scale;
  14682. }
  14683. tintFn(scaled, 0, tinted, 0);
  14684. if (usesZeroToOneRange) {
  14685. for (j = 0; j < baseNumComps; j++) {
  14686. baseBuf[pos++] = tinted[j] * 255;
  14687. }
  14688. } else {
  14689. base.getRgbItem(tinted, 0, baseBuf, pos);
  14690. pos += baseNumComps;
  14691. }
  14692. }
  14693. if (!isPassthrough) {
  14694. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  14695. }
  14696. }
  14697. getOutputLength(inputLength, alpha01) {
  14698. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  14699. }
  14700. }
  14701. class PatternCS extends ColorSpace {
  14702. constructor(baseCS) {
  14703. super("Pattern", null);
  14704. this.base = baseCS;
  14705. }
  14706. isDefaultDecode(decodeMap, bpc) {
  14707. (0, _util.unreachable)("Should not call PatternCS.isDefaultDecode");
  14708. }
  14709. }
  14710. class IndexedCS extends ColorSpace {
  14711. constructor(base, highVal, lookup) {
  14712. super("Indexed", 1);
  14713. this.base = base;
  14714. this.highVal = highVal;
  14715. const length = base.numComps * highVal;
  14716. this.lookup = new Uint8Array(length);
  14717. if ((0, _primitives.isStream)(lookup)) {
  14718. const bytes = lookup.getBytes(length);
  14719. this.lookup.set(bytes);
  14720. } else if (typeof lookup === "string") {
  14721. for (let i = 0; i < length; ++i) {
  14722. this.lookup[i] = lookup.charCodeAt(i) & 0xff;
  14723. }
  14724. } else {
  14725. throw new _util.FormatError(`IndexedCS - unrecognized lookup table: ${lookup}`);
  14726. }
  14727. }
  14728. getRgbItem(src, srcOffset, dest, destOffset) {
  14729. const numComps = this.base.numComps;
  14730. const start = src[srcOffset] * numComps;
  14731. this.base.getRgbBuffer(this.lookup, start, 1, dest, destOffset, 8, 0);
  14732. }
  14733. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  14734. const base = this.base;
  14735. const numComps = base.numComps;
  14736. const outputDelta = base.getOutputLength(numComps, alpha01);
  14737. const lookup = this.lookup;
  14738. for (let i = 0; i < count; ++i) {
  14739. const lookupPos = src[srcOffset++] * numComps;
  14740. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  14741. destOffset += outputDelta;
  14742. }
  14743. }
  14744. getOutputLength(inputLength, alpha01) {
  14745. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  14746. }
  14747. isDefaultDecode(decodeMap, bpc) {
  14748. if (!Array.isArray(decodeMap)) {
  14749. return true;
  14750. }
  14751. if (decodeMap.length !== 2) {
  14752. (0, _util.warn)("Decode map length is not correct");
  14753. return true;
  14754. }
  14755. if (!Number.isInteger(bpc) || bpc < 1) {
  14756. (0, _util.warn)("Bits per component is not correct");
  14757. return true;
  14758. }
  14759. return decodeMap[0] === 0 && decodeMap[1] === (1 << bpc) - 1;
  14760. }
  14761. }
  14762. class DeviceGrayCS extends ColorSpace {
  14763. constructor() {
  14764. super("DeviceGray", 1);
  14765. }
  14766. getRgbItem(src, srcOffset, dest, destOffset) {
  14767. const c = src[srcOffset] * 255;
  14768. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  14769. }
  14770. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  14771. const scale = 255 / ((1 << bits) - 1);
  14772. let j = srcOffset,
  14773. q = destOffset;
  14774. for (let i = 0; i < count; ++i) {
  14775. const c = scale * src[j++];
  14776. dest[q++] = c;
  14777. dest[q++] = c;
  14778. dest[q++] = c;
  14779. q += alpha01;
  14780. }
  14781. }
  14782. getOutputLength(inputLength, alpha01) {
  14783. return inputLength * (3 + alpha01);
  14784. }
  14785. }
  14786. class DeviceRgbCS extends ColorSpace {
  14787. constructor() {
  14788. super("DeviceRGB", 3);
  14789. }
  14790. getRgbItem(src, srcOffset, dest, destOffset) {
  14791. dest[destOffset] = src[srcOffset] * 255;
  14792. dest[destOffset + 1] = src[srcOffset + 1] * 255;
  14793. dest[destOffset + 2] = src[srcOffset + 2] * 255;
  14794. }
  14795. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  14796. if (bits === 8 && alpha01 === 0) {
  14797. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  14798. return;
  14799. }
  14800. const scale = 255 / ((1 << bits) - 1);
  14801. let j = srcOffset,
  14802. q = destOffset;
  14803. for (let i = 0; i < count; ++i) {
  14804. dest[q++] = scale * src[j++];
  14805. dest[q++] = scale * src[j++];
  14806. dest[q++] = scale * src[j++];
  14807. q += alpha01;
  14808. }
  14809. }
  14810. getOutputLength(inputLength, alpha01) {
  14811. return inputLength * (3 + alpha01) / 3 | 0;
  14812. }
  14813. isPassthrough(bits) {
  14814. return bits === 8;
  14815. }
  14816. }
  14817. const DeviceCmykCS = function DeviceCmykCSClosure() {
  14818. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  14819. const c = src[srcOffset] * srcScale;
  14820. const m = src[srcOffset + 1] * srcScale;
  14821. const y = src[srcOffset + 2] * srcScale;
  14822. const k = src[srcOffset + 3] * srcScale;
  14823. dest[destOffset] = 255 + c * (-4.387332384609988 * c + 54.48615194189176 * m + 18.82290502165302 * y + 212.25662451639585 * k + -285.2331026137004) + m * (1.7149763477362134 * m - 5.6096736904047315 * y + -17.873870861415444 * k - 5.497006427196366) + y * (-2.5217340131683033 * y - 21.248923337353073 * k + 17.5119270841813) + k * (-21.86122147463605 * k - 189.48180835922747);
  14824. dest[destOffset + 1] = 255 + c * (8.841041422036149 * c + 60.118027045597366 * m + 6.871425592049007 * y + 31.159100130055922 * k + -79.2970844816548) + m * (-15.310361306967817 * m + 17.575251261109482 * y + 131.35250912493976 * k - 190.9453302588951) + y * (4.444339102852739 * y + 9.8632861493405 * k - 24.86741582555878) + k * (-20.737325471181034 * k - 187.80453709719578);
  14825. dest[destOffset + 2] = 255 + c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k + -14.183576799673286) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 112.23884253719248) + y * (0.03296041114873217 * y + 115.60384449646641 * k + -193.58209356861505) + k * (-22.33816807309886 * k - 180.12613974708367);
  14826. }
  14827. class DeviceCmykCS extends ColorSpace {
  14828. constructor() {
  14829. super("DeviceCMYK", 4);
  14830. }
  14831. getRgbItem(src, srcOffset, dest, destOffset) {
  14832. convertToRgb(src, srcOffset, 1, dest, destOffset);
  14833. }
  14834. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  14835. const scale = 1 / ((1 << bits) - 1);
  14836. for (let i = 0; i < count; i++) {
  14837. convertToRgb(src, srcOffset, scale, dest, destOffset);
  14838. srcOffset += 4;
  14839. destOffset += 3 + alpha01;
  14840. }
  14841. }
  14842. getOutputLength(inputLength, alpha01) {
  14843. return inputLength / 4 * (3 + alpha01) | 0;
  14844. }
  14845. }
  14846. return DeviceCmykCS;
  14847. }();
  14848. const CalGrayCS = function CalGrayCSClosure() {
  14849. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  14850. const A = src[srcOffset] * scale;
  14851. const AG = A ** cs.G;
  14852. const L = cs.YW * AG;
  14853. const val = Math.max(295.8 * L ** 0.333333333333333333 - 40.8, 0);
  14854. dest[destOffset] = val;
  14855. dest[destOffset + 1] = val;
  14856. dest[destOffset + 2] = val;
  14857. }
  14858. class CalGrayCS extends ColorSpace {
  14859. constructor(whitePoint, blackPoint, gamma) {
  14860. super("CalGray", 1);
  14861. if (!whitePoint) {
  14862. throw new _util.FormatError("WhitePoint missing - required for color space CalGray");
  14863. }
  14864. blackPoint = blackPoint || [0, 0, 0];
  14865. gamma = gamma || 1;
  14866. this.XW = whitePoint[0];
  14867. this.YW = whitePoint[1];
  14868. this.ZW = whitePoint[2];
  14869. this.XB = blackPoint[0];
  14870. this.YB = blackPoint[1];
  14871. this.ZB = blackPoint[2];
  14872. this.G = gamma;
  14873. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  14874. throw new _util.FormatError(`Invalid WhitePoint components for ${this.name}` + ", no fallback available");
  14875. }
  14876. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  14877. (0, _util.info)(`Invalid BlackPoint for ${this.name}, falling back to default.`);
  14878. this.XB = this.YB = this.ZB = 0;
  14879. }
  14880. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  14881. (0, _util.warn)(`${this.name}, BlackPoint: XB: ${this.XB}, YB: ${this.YB}, ` + `ZB: ${this.ZB}, only default values are supported.`);
  14882. }
  14883. if (this.G < 1) {
  14884. (0, _util.info)(`Invalid Gamma: ${this.G} for ${this.name}, ` + "falling back to default.");
  14885. this.G = 1;
  14886. }
  14887. }
  14888. getRgbItem(src, srcOffset, dest, destOffset) {
  14889. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  14890. }
  14891. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  14892. const scale = 1 / ((1 << bits) - 1);
  14893. for (let i = 0; i < count; ++i) {
  14894. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  14895. srcOffset += 1;
  14896. destOffset += 3 + alpha01;
  14897. }
  14898. }
  14899. getOutputLength(inputLength, alpha01) {
  14900. return inputLength * (3 + alpha01);
  14901. }
  14902. }
  14903. return CalGrayCS;
  14904. }();
  14905. const CalRGBCS = function CalRGBCSClosure() {
  14906. const BRADFORD_SCALE_MATRIX = new Float32Array([0.8951, 0.2664, -0.1614, -0.7502, 1.7135, 0.0367, 0.0389, -0.0685, 1.0296]);
  14907. const BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([0.9869929, -0.1470543, 0.1599627, 0.4323053, 0.5183603, 0.0492912, -0.0085287, 0.0400428, 0.9684867]);
  14908. const SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([3.2404542, -1.5371385, -0.4985314, -0.9692660, 1.8760108, 0.0415560, 0.0556434, -0.2040259, 1.0572252]);
  14909. const FLAT_WHITEPOINT_MATRIX = new Float32Array([1, 1, 1]);
  14910. const tempNormalizeMatrix = new Float32Array(3);
  14911. const tempConvertMatrix1 = new Float32Array(3);
  14912. const tempConvertMatrix2 = new Float32Array(3);
  14913. const DECODE_L_CONSTANT = ((8 + 16) / 116) ** 3 / 8.0;
  14914. function matrixProduct(a, b, result) {
  14915. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  14916. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  14917. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  14918. }
  14919. function convertToFlat(sourceWhitePoint, LMS, result) {
  14920. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  14921. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  14922. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  14923. }
  14924. function convertToD65(sourceWhitePoint, LMS, result) {
  14925. const D65X = 0.95047;
  14926. const D65Y = 1;
  14927. const D65Z = 1.08883;
  14928. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  14929. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  14930. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  14931. }
  14932. function sRGBTransferFunction(color) {
  14933. if (color <= 0.0031308) {
  14934. return adjustToRange(0, 1, 12.92 * color);
  14935. }
  14936. if (color >= 0.99554525) {
  14937. return 1;
  14938. }
  14939. return adjustToRange(0, 1, (1 + 0.055) * color ** (1 / 2.4) - 0.055);
  14940. }
  14941. function adjustToRange(min, max, value) {
  14942. return Math.max(min, Math.min(max, value));
  14943. }
  14944. function decodeL(L) {
  14945. if (L < 0) {
  14946. return -decodeL(-L);
  14947. }
  14948. if (L > 8.0) {
  14949. return ((L + 16) / 116) ** 3;
  14950. }
  14951. return L * DECODE_L_CONSTANT;
  14952. }
  14953. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  14954. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  14955. result[0] = XYZ_Flat[0];
  14956. result[1] = XYZ_Flat[1];
  14957. result[2] = XYZ_Flat[2];
  14958. return;
  14959. }
  14960. const zeroDecodeL = decodeL(0);
  14961. const X_DST = zeroDecodeL;
  14962. const X_SRC = decodeL(sourceBlackPoint[0]);
  14963. const Y_DST = zeroDecodeL;
  14964. const Y_SRC = decodeL(sourceBlackPoint[1]);
  14965. const Z_DST = zeroDecodeL;
  14966. const Z_SRC = decodeL(sourceBlackPoint[2]);
  14967. const X_Scale = (1 - X_DST) / (1 - X_SRC);
  14968. const X_Offset = 1 - X_Scale;
  14969. const Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  14970. const Y_Offset = 1 - Y_Scale;
  14971. const Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  14972. const Z_Offset = 1 - Z_Scale;
  14973. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  14974. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  14975. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  14976. }
  14977. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  14978. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  14979. result[0] = XYZ_In[0];
  14980. result[1] = XYZ_In[1];
  14981. result[2] = XYZ_In[2];
  14982. return;
  14983. }
  14984. const LMS = result;
  14985. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  14986. const LMS_Flat = tempNormalizeMatrix;
  14987. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  14988. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  14989. }
  14990. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  14991. const LMS = result;
  14992. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  14993. const LMS_D65 = tempNormalizeMatrix;
  14994. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  14995. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  14996. }
  14997. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  14998. const A = adjustToRange(0, 1, src[srcOffset] * scale);
  14999. const B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  15000. const C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  15001. const AGR = A === 1 ? 1 : A ** cs.GR;
  15002. const BGG = B === 1 ? 1 : B ** cs.GG;
  15003. const CGB = C === 1 ? 1 : C ** cs.GB;
  15004. const X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  15005. const Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  15006. const Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  15007. const XYZ = tempConvertMatrix1;
  15008. XYZ[0] = X;
  15009. XYZ[1] = Y;
  15010. XYZ[2] = Z;
  15011. const XYZ_Flat = tempConvertMatrix2;
  15012. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  15013. const XYZ_Black = tempConvertMatrix1;
  15014. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  15015. const XYZ_D65 = tempConvertMatrix2;
  15016. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  15017. const SRGB = tempConvertMatrix1;
  15018. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  15019. dest[destOffset] = sRGBTransferFunction(SRGB[0]) * 255;
  15020. dest[destOffset + 1] = sRGBTransferFunction(SRGB[1]) * 255;
  15021. dest[destOffset + 2] = sRGBTransferFunction(SRGB[2]) * 255;
  15022. }
  15023. class CalRGBCS extends ColorSpace {
  15024. constructor(whitePoint, blackPoint, gamma, matrix) {
  15025. super("CalRGB", 3);
  15026. if (!whitePoint) {
  15027. throw new _util.FormatError("WhitePoint missing - required for color space CalRGB");
  15028. }
  15029. blackPoint = blackPoint || new Float32Array(3);
  15030. gamma = gamma || new Float32Array([1, 1, 1]);
  15031. matrix = matrix || new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);
  15032. const XW = whitePoint[0];
  15033. const YW = whitePoint[1];
  15034. const ZW = whitePoint[2];
  15035. this.whitePoint = whitePoint;
  15036. const XB = blackPoint[0];
  15037. const YB = blackPoint[1];
  15038. const ZB = blackPoint[2];
  15039. this.blackPoint = blackPoint;
  15040. this.GR = gamma[0];
  15041. this.GG = gamma[1];
  15042. this.GB = gamma[2];
  15043. this.MXA = matrix[0];
  15044. this.MYA = matrix[1];
  15045. this.MZA = matrix[2];
  15046. this.MXB = matrix[3];
  15047. this.MYB = matrix[4];
  15048. this.MZB = matrix[5];
  15049. this.MXC = matrix[6];
  15050. this.MYC = matrix[7];
  15051. this.MZC = matrix[8];
  15052. if (XW < 0 || ZW < 0 || YW !== 1) {
  15053. throw new _util.FormatError(`Invalid WhitePoint components for ${this.name}` + ", no fallback available");
  15054. }
  15055. if (XB < 0 || YB < 0 || ZB < 0) {
  15056. (0, _util.info)(`Invalid BlackPoint for ${this.name} [${XB}, ${YB}, ${ZB}], ` + "falling back to default.");
  15057. this.blackPoint = new Float32Array(3);
  15058. }
  15059. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  15060. (0, _util.info)(`Invalid Gamma [${this.GR}, ${this.GG}, ${this.GB}] for ` + `${this.name}, falling back to default.`);
  15061. this.GR = this.GG = this.GB = 1;
  15062. }
  15063. }
  15064. getRgbItem(src, srcOffset, dest, destOffset) {
  15065. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  15066. }
  15067. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  15068. const scale = 1 / ((1 << bits) - 1);
  15069. for (let i = 0; i < count; ++i) {
  15070. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  15071. srcOffset += 3;
  15072. destOffset += 3 + alpha01;
  15073. }
  15074. }
  15075. getOutputLength(inputLength, alpha01) {
  15076. return inputLength * (3 + alpha01) / 3 | 0;
  15077. }
  15078. }
  15079. return CalRGBCS;
  15080. }();
  15081. const LabCS = function LabCSClosure() {
  15082. function fn_g(x) {
  15083. let result;
  15084. if (x >= 6 / 29) {
  15085. result = x * x * x;
  15086. } else {
  15087. result = 108 / 841 * (x - 4 / 29);
  15088. }
  15089. return result;
  15090. }
  15091. function decode(value, high1, low2, high2) {
  15092. return low2 + value * (high2 - low2) / high1;
  15093. }
  15094. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  15095. let Ls = src[srcOffset];
  15096. let as = src[srcOffset + 1];
  15097. let bs = src[srcOffset + 2];
  15098. if (maxVal !== false) {
  15099. Ls = decode(Ls, maxVal, 0, 100);
  15100. as = decode(as, maxVal, cs.amin, cs.amax);
  15101. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  15102. }
  15103. if (as > cs.amax) {
  15104. as = cs.amax;
  15105. } else if (as < cs.amin) {
  15106. as = cs.amin;
  15107. }
  15108. if (bs > cs.bmax) {
  15109. bs = cs.bmax;
  15110. } else if (bs < cs.bmin) {
  15111. bs = cs.bmin;
  15112. }
  15113. const M = (Ls + 16) / 116;
  15114. const L = M + as / 500;
  15115. const N = M - bs / 200;
  15116. const X = cs.XW * fn_g(L);
  15117. const Y = cs.YW * fn_g(M);
  15118. const Z = cs.ZW * fn_g(N);
  15119. let r, g, b;
  15120. if (cs.ZW < 1) {
  15121. r = X * 3.1339 + Y * -1.617 + Z * -0.4906;
  15122. g = X * -0.9785 + Y * 1.916 + Z * 0.0333;
  15123. b = X * 0.072 + Y * -0.229 + Z * 1.4057;
  15124. } else {
  15125. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  15126. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  15127. b = X * 0.0557 + Y * -0.204 + Z * 1.057;
  15128. }
  15129. dest[destOffset] = Math.sqrt(r) * 255;
  15130. dest[destOffset + 1] = Math.sqrt(g) * 255;
  15131. dest[destOffset + 2] = Math.sqrt(b) * 255;
  15132. }
  15133. class LabCS extends ColorSpace {
  15134. constructor(whitePoint, blackPoint, range) {
  15135. super("Lab", 3);
  15136. if (!whitePoint) {
  15137. throw new _util.FormatError("WhitePoint missing - required for color space Lab");
  15138. }
  15139. blackPoint = blackPoint || [0, 0, 0];
  15140. range = range || [-100, 100, -100, 100];
  15141. this.XW = whitePoint[0];
  15142. this.YW = whitePoint[1];
  15143. this.ZW = whitePoint[2];
  15144. this.amin = range[0];
  15145. this.amax = range[1];
  15146. this.bmin = range[2];
  15147. this.bmax = range[3];
  15148. this.XB = blackPoint[0];
  15149. this.YB = blackPoint[1];
  15150. this.ZB = blackPoint[2];
  15151. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  15152. throw new _util.FormatError("Invalid WhitePoint components, no fallback available");
  15153. }
  15154. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  15155. (0, _util.info)("Invalid BlackPoint, falling back to default");
  15156. this.XB = this.YB = this.ZB = 0;
  15157. }
  15158. if (this.amin > this.amax || this.bmin > this.bmax) {
  15159. (0, _util.info)("Invalid Range, falling back to defaults");
  15160. this.amin = -100;
  15161. this.amax = 100;
  15162. this.bmin = -100;
  15163. this.bmax = 100;
  15164. }
  15165. }
  15166. getRgbItem(src, srcOffset, dest, destOffset) {
  15167. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  15168. }
  15169. getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  15170. const maxVal = (1 << bits) - 1;
  15171. for (let i = 0; i < count; i++) {
  15172. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  15173. srcOffset += 3;
  15174. destOffset += 3 + alpha01;
  15175. }
  15176. }
  15177. getOutputLength(inputLength, alpha01) {
  15178. return inputLength * (3 + alpha01) / 3 | 0;
  15179. }
  15180. isDefaultDecode(decodeMap, bpc) {
  15181. return true;
  15182. }
  15183. get usesZeroToOneRange() {
  15184. return (0, _util.shadow)(this, "usesZeroToOneRange", false);
  15185. }
  15186. }
  15187. return LabCS;
  15188. }();
  15189. /***/ }),
  15190. /* 24 */
  15191. /***/ (function(module, exports, __w_pdfjs_require__) {
  15192. "use strict";
  15193. Object.defineProperty(exports, "__esModule", {
  15194. value: true
  15195. });
  15196. exports.GlobalImageCache = exports.LocalGStateCache = exports.LocalFunctionCache = exports.LocalColorSpaceCache = exports.LocalImageCache = void 0;
  15197. var _util = __w_pdfjs_require__(2);
  15198. var _primitives = __w_pdfjs_require__(5);
  15199. class BaseLocalCache {
  15200. constructor(options) {
  15201. if (this.constructor === BaseLocalCache) {
  15202. (0, _util.unreachable)("Cannot initialize BaseLocalCache.");
  15203. }
  15204. if (!options || !options.onlyRefs) {
  15205. this._nameRefMap = new Map();
  15206. this._imageMap = new Map();
  15207. }
  15208. this._imageCache = new _primitives.RefSetCache();
  15209. }
  15210. getByName(name) {
  15211. const ref = this._nameRefMap.get(name);
  15212. if (ref) {
  15213. return this.getByRef(ref);
  15214. }
  15215. return this._imageMap.get(name) || null;
  15216. }
  15217. getByRef(ref) {
  15218. return this._imageCache.get(ref) || null;
  15219. }
  15220. set(name, ref, data) {
  15221. (0, _util.unreachable)("Abstract method `set` called.");
  15222. }
  15223. }
  15224. class LocalImageCache extends BaseLocalCache {
  15225. set(name, ref = null, data) {
  15226. if (!name) {
  15227. throw new Error('LocalImageCache.set - expected "name" argument.');
  15228. }
  15229. if (ref) {
  15230. if (this._imageCache.has(ref)) {
  15231. return;
  15232. }
  15233. this._nameRefMap.set(name, ref);
  15234. this._imageCache.put(ref, data);
  15235. return;
  15236. }
  15237. if (this._imageMap.has(name)) {
  15238. return;
  15239. }
  15240. this._imageMap.set(name, data);
  15241. }
  15242. }
  15243. exports.LocalImageCache = LocalImageCache;
  15244. class LocalColorSpaceCache extends BaseLocalCache {
  15245. set(name = null, ref = null, data) {
  15246. if (!name && !ref) {
  15247. throw new Error('LocalColorSpaceCache.set - expected "name" and/or "ref" argument.');
  15248. }
  15249. if (ref) {
  15250. if (this._imageCache.has(ref)) {
  15251. return;
  15252. }
  15253. if (name) {
  15254. this._nameRefMap.set(name, ref);
  15255. }
  15256. this._imageCache.put(ref, data);
  15257. return;
  15258. }
  15259. if (this._imageMap.has(name)) {
  15260. return;
  15261. }
  15262. this._imageMap.set(name, data);
  15263. }
  15264. }
  15265. exports.LocalColorSpaceCache = LocalColorSpaceCache;
  15266. class LocalFunctionCache extends BaseLocalCache {
  15267. constructor(options) {
  15268. super({
  15269. onlyRefs: true
  15270. });
  15271. }
  15272. getByName(name) {
  15273. (0, _util.unreachable)("Should not call `getByName` method.");
  15274. }
  15275. set(name = null, ref, data) {
  15276. if (!ref) {
  15277. throw new Error('LocalFunctionCache.set - expected "ref" argument.');
  15278. }
  15279. if (this._imageCache.has(ref)) {
  15280. return;
  15281. }
  15282. this._imageCache.put(ref, data);
  15283. }
  15284. }
  15285. exports.LocalFunctionCache = LocalFunctionCache;
  15286. class LocalGStateCache extends BaseLocalCache {
  15287. set(name, ref = null, data) {
  15288. if (!name) {
  15289. throw new Error('LocalGStateCache.set - expected "name" argument.');
  15290. }
  15291. if (ref) {
  15292. if (this._imageCache.has(ref)) {
  15293. return;
  15294. }
  15295. this._nameRefMap.set(name, ref);
  15296. this._imageCache.put(ref, data);
  15297. return;
  15298. }
  15299. if (this._imageMap.has(name)) {
  15300. return;
  15301. }
  15302. this._imageMap.set(name, data);
  15303. }
  15304. }
  15305. exports.LocalGStateCache = LocalGStateCache;
  15306. class GlobalImageCache {
  15307. static get NUM_PAGES_THRESHOLD() {
  15308. return (0, _util.shadow)(this, "NUM_PAGES_THRESHOLD", 2);
  15309. }
  15310. static get MAX_IMAGES_TO_CACHE() {
  15311. return (0, _util.shadow)(this, "MAX_IMAGES_TO_CACHE", 10);
  15312. }
  15313. constructor() {
  15314. this._refCache = new _primitives.RefSetCache();
  15315. this._imageCache = new _primitives.RefSetCache();
  15316. }
  15317. shouldCache(ref, pageIndex) {
  15318. const pageIndexSet = this._refCache.get(ref);
  15319. const numPages = pageIndexSet ? pageIndexSet.size + (pageIndexSet.has(pageIndex) ? 0 : 1) : 1;
  15320. if (numPages < GlobalImageCache.NUM_PAGES_THRESHOLD) {
  15321. return false;
  15322. }
  15323. if (!this._imageCache.has(ref) && this._imageCache.size >= GlobalImageCache.MAX_IMAGES_TO_CACHE) {
  15324. return false;
  15325. }
  15326. return true;
  15327. }
  15328. addPageIndex(ref, pageIndex) {
  15329. let pageIndexSet = this._refCache.get(ref);
  15330. if (!pageIndexSet) {
  15331. pageIndexSet = new Set();
  15332. this._refCache.put(ref, pageIndexSet);
  15333. }
  15334. pageIndexSet.add(pageIndex);
  15335. }
  15336. getData(ref, pageIndex) {
  15337. const pageIndexSet = this._refCache.get(ref);
  15338. if (!pageIndexSet) {
  15339. return null;
  15340. }
  15341. if (pageIndexSet.size < GlobalImageCache.NUM_PAGES_THRESHOLD) {
  15342. return null;
  15343. }
  15344. if (!this._imageCache.has(ref)) {
  15345. return null;
  15346. }
  15347. pageIndexSet.add(pageIndex);
  15348. return this._imageCache.get(ref);
  15349. }
  15350. setData(ref, data) {
  15351. if (!this._refCache.has(ref)) {
  15352. throw new Error('GlobalImageCache.setData - expected "addPageIndex" to have been called.');
  15353. }
  15354. if (this._imageCache.has(ref)) {
  15355. return;
  15356. }
  15357. if (this._imageCache.size >= GlobalImageCache.MAX_IMAGES_TO_CACHE) {
  15358. (0, _util.info)("GlobalImageCache.setData - ignoring image above MAX_IMAGES_TO_CACHE.");
  15359. return;
  15360. }
  15361. this._imageCache.put(ref, data);
  15362. }
  15363. clear(onlyData = false) {
  15364. if (!onlyData) {
  15365. this._refCache.clear();
  15366. }
  15367. this._imageCache.clear();
  15368. }
  15369. }
  15370. exports.GlobalImageCache = GlobalImageCache;
  15371. /***/ }),
  15372. /* 25 */
  15373. /***/ (function(module, exports, __w_pdfjs_require__) {
  15374. "use strict";
  15375. Object.defineProperty(exports, "__esModule", {
  15376. value: true
  15377. });
  15378. exports.getQuadPoints = getQuadPoints;
  15379. exports.MarkupAnnotation = exports.AnnotationFactory = exports.AnnotationBorderStyle = exports.Annotation = void 0;
  15380. var _util = __w_pdfjs_require__(2);
  15381. var _obj = __w_pdfjs_require__(10);
  15382. var _primitives = __w_pdfjs_require__(5);
  15383. var _colorspace = __w_pdfjs_require__(23);
  15384. var _core_utils = __w_pdfjs_require__(8);
  15385. var _operator_list = __w_pdfjs_require__(26);
  15386. var _stream = __w_pdfjs_require__(12);
  15387. var _writer = __w_pdfjs_require__(27);
  15388. class AnnotationFactory {
  15389. static create(xref, ref, pdfManager, idFactory) {
  15390. return pdfManager.ensureCatalog("acroForm").then(acroForm => {
  15391. return pdfManager.ensure(this, "_create", [xref, ref, pdfManager, idFactory, acroForm]);
  15392. });
  15393. }
  15394. static _create(xref, ref, pdfManager, idFactory, acroForm) {
  15395. const dict = xref.fetchIfRef(ref);
  15396. if (!(0, _primitives.isDict)(dict)) {
  15397. return undefined;
  15398. }
  15399. const id = (0, _primitives.isRef)(ref) ? ref.toString() : `annot_${idFactory.createObjId()}`;
  15400. let subtype = dict.get("Subtype");
  15401. subtype = (0, _primitives.isName)(subtype) ? subtype.name : null;
  15402. const parameters = {
  15403. xref,
  15404. ref,
  15405. dict,
  15406. subtype,
  15407. id,
  15408. pdfManager,
  15409. acroForm: acroForm instanceof _primitives.Dict ? acroForm : _primitives.Dict.empty
  15410. };
  15411. switch (subtype) {
  15412. case "Link":
  15413. return new LinkAnnotation(parameters);
  15414. case "Text":
  15415. return new TextAnnotation(parameters);
  15416. case "Widget":
  15417. let fieldType = (0, _core_utils.getInheritableProperty)({
  15418. dict,
  15419. key: "FT"
  15420. });
  15421. fieldType = (0, _primitives.isName)(fieldType) ? fieldType.name : null;
  15422. switch (fieldType) {
  15423. case "Tx":
  15424. return new TextWidgetAnnotation(parameters);
  15425. case "Btn":
  15426. return new ButtonWidgetAnnotation(parameters);
  15427. case "Ch":
  15428. return new ChoiceWidgetAnnotation(parameters);
  15429. }
  15430. (0, _util.warn)('Unimplemented widget field type "' + fieldType + '", ' + "falling back to base field type.");
  15431. return new WidgetAnnotation(parameters);
  15432. case "Popup":
  15433. return new PopupAnnotation(parameters);
  15434. case "FreeText":
  15435. return new FreeTextAnnotation(parameters);
  15436. case "Line":
  15437. return new LineAnnotation(parameters);
  15438. case "Square":
  15439. return new SquareAnnotation(parameters);
  15440. case "Circle":
  15441. return new CircleAnnotation(parameters);
  15442. case "PolyLine":
  15443. return new PolylineAnnotation(parameters);
  15444. case "Polygon":
  15445. return new PolygonAnnotation(parameters);
  15446. case "Caret":
  15447. return new CaretAnnotation(parameters);
  15448. case "Ink":
  15449. return new InkAnnotation(parameters);
  15450. case "Highlight":
  15451. return new HighlightAnnotation(parameters);
  15452. case "Underline":
  15453. return new UnderlineAnnotation(parameters);
  15454. case "Squiggly":
  15455. return new SquigglyAnnotation(parameters);
  15456. case "StrikeOut":
  15457. return new StrikeOutAnnotation(parameters);
  15458. case "Stamp":
  15459. return new StampAnnotation(parameters);
  15460. case "FileAttachment":
  15461. return new FileAttachmentAnnotation(parameters);
  15462. default:
  15463. if (!subtype) {
  15464. (0, _util.warn)("Annotation is missing the required /Subtype.");
  15465. } else {
  15466. (0, _util.warn)('Unimplemented annotation type "' + subtype + '", ' + "falling back to base annotation.");
  15467. }
  15468. return new Annotation(parameters);
  15469. }
  15470. }
  15471. }
  15472. exports.AnnotationFactory = AnnotationFactory;
  15473. function getQuadPoints(dict, rect) {
  15474. if (!dict.has("QuadPoints")) {
  15475. return null;
  15476. }
  15477. const quadPoints = dict.getArray("QuadPoints");
  15478. if (!Array.isArray(quadPoints) || quadPoints.length % 8 > 0) {
  15479. return null;
  15480. }
  15481. const quadPointsLists = [];
  15482. for (let i = 0, ii = quadPoints.length / 8; i < ii; i++) {
  15483. quadPointsLists.push([]);
  15484. for (let j = i * 8, jj = i * 8 + 8; j < jj; j += 2) {
  15485. const x = quadPoints[j];
  15486. const y = quadPoints[j + 1];
  15487. if (x < rect[0] || x > rect[2] || y < rect[1] || y > rect[3]) {
  15488. return null;
  15489. }
  15490. quadPointsLists[i].push({
  15491. x,
  15492. y
  15493. });
  15494. }
  15495. }
  15496. return quadPointsLists;
  15497. }
  15498. function getTransformMatrix(rect, bbox, matrix) {
  15499. const [minX, minY, maxX, maxY] = _util.Util.getAxialAlignedBoundingBox(bbox, matrix);
  15500. if (minX === maxX || minY === maxY) {
  15501. return [1, 0, 0, 1, rect[0], rect[1]];
  15502. }
  15503. const xRatio = (rect[2] - rect[0]) / (maxX - minX);
  15504. const yRatio = (rect[3] - rect[1]) / (maxY - minY);
  15505. return [xRatio, 0, 0, yRatio, rect[0] - minX * xRatio, rect[1] - minY * yRatio];
  15506. }
  15507. class Annotation {
  15508. constructor(params) {
  15509. const dict = params.dict;
  15510. this.setContents(dict.get("Contents"));
  15511. this.setModificationDate(dict.get("M"));
  15512. this.setFlags(dict.get("F"));
  15513. this.setRectangle(dict.getArray("Rect"));
  15514. this.setColor(dict.getArray("C"));
  15515. this.setBorderStyle(dict);
  15516. this.setAppearance(dict);
  15517. this.data = {
  15518. annotationFlags: this.flags,
  15519. borderStyle: this.borderStyle,
  15520. color: this.color,
  15521. contents: this.contents,
  15522. hasAppearance: !!this.appearance,
  15523. id: params.id,
  15524. modificationDate: this.modificationDate,
  15525. rect: this.rectangle,
  15526. subtype: params.subtype
  15527. };
  15528. }
  15529. _hasFlag(flags, flag) {
  15530. return !!(flags & flag);
  15531. }
  15532. _isViewable(flags) {
  15533. return !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, _util.AnnotationFlag.HIDDEN) && !this._hasFlag(flags, _util.AnnotationFlag.NOVIEW);
  15534. }
  15535. _isPrintable(flags) {
  15536. return this._hasFlag(flags, _util.AnnotationFlag.PRINT) && !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, _util.AnnotationFlag.HIDDEN);
  15537. }
  15538. get viewable() {
  15539. if (this.flags === 0) {
  15540. return true;
  15541. }
  15542. return this._isViewable(this.flags);
  15543. }
  15544. get printable() {
  15545. if (this.flags === 0) {
  15546. return false;
  15547. }
  15548. return this._isPrintable(this.flags);
  15549. }
  15550. setContents(contents) {
  15551. this.contents = (0, _util.stringToPDFString)(contents || "");
  15552. }
  15553. setModificationDate(modificationDate) {
  15554. this.modificationDate = (0, _util.isString)(modificationDate) ? modificationDate : null;
  15555. }
  15556. setFlags(flags) {
  15557. this.flags = Number.isInteger(flags) && flags > 0 ? flags : 0;
  15558. }
  15559. hasFlag(flag) {
  15560. return this._hasFlag(this.flags, flag);
  15561. }
  15562. setRectangle(rectangle) {
  15563. if (Array.isArray(rectangle) && rectangle.length === 4) {
  15564. this.rectangle = _util.Util.normalizeRect(rectangle);
  15565. } else {
  15566. this.rectangle = [0, 0, 0, 0];
  15567. }
  15568. }
  15569. setColor(color) {
  15570. const rgbColor = new Uint8ClampedArray(3);
  15571. if (!Array.isArray(color)) {
  15572. this.color = rgbColor;
  15573. return;
  15574. }
  15575. switch (color.length) {
  15576. case 0:
  15577. this.color = null;
  15578. break;
  15579. case 1:
  15580. _colorspace.ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  15581. this.color = rgbColor;
  15582. break;
  15583. case 3:
  15584. _colorspace.ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  15585. this.color = rgbColor;
  15586. break;
  15587. case 4:
  15588. _colorspace.ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  15589. this.color = rgbColor;
  15590. break;
  15591. default:
  15592. this.color = rgbColor;
  15593. break;
  15594. }
  15595. }
  15596. setBorderStyle(borderStyle) {
  15597. this.borderStyle = new AnnotationBorderStyle();
  15598. if (!(0, _primitives.isDict)(borderStyle)) {
  15599. return;
  15600. }
  15601. if (borderStyle.has("BS")) {
  15602. const dict = borderStyle.get("BS");
  15603. const dictType = dict.get("Type");
  15604. if (!dictType || (0, _primitives.isName)(dictType, "Border")) {
  15605. this.borderStyle.setWidth(dict.get("W"), this.rectangle);
  15606. this.borderStyle.setStyle(dict.get("S"));
  15607. this.borderStyle.setDashArray(dict.getArray("D"));
  15608. }
  15609. } else if (borderStyle.has("Border")) {
  15610. const array = borderStyle.getArray("Border");
  15611. if (Array.isArray(array) && array.length >= 3) {
  15612. this.borderStyle.setHorizontalCornerRadius(array[0]);
  15613. this.borderStyle.setVerticalCornerRadius(array[1]);
  15614. this.borderStyle.setWidth(array[2], this.rectangle);
  15615. if (array.length === 4) {
  15616. this.borderStyle.setDashArray(array[3]);
  15617. }
  15618. }
  15619. } else {
  15620. this.borderStyle.setWidth(0);
  15621. }
  15622. }
  15623. setAppearance(dict) {
  15624. this.appearance = null;
  15625. const appearanceStates = dict.get("AP");
  15626. if (!(0, _primitives.isDict)(appearanceStates)) {
  15627. return;
  15628. }
  15629. const normalAppearanceState = appearanceStates.get("N");
  15630. if ((0, _primitives.isStream)(normalAppearanceState)) {
  15631. this.appearance = normalAppearanceState;
  15632. return;
  15633. }
  15634. if (!(0, _primitives.isDict)(normalAppearanceState)) {
  15635. return;
  15636. }
  15637. const as = dict.get("AS");
  15638. if (!(0, _primitives.isName)(as) || !normalAppearanceState.has(as.name)) {
  15639. return;
  15640. }
  15641. this.appearance = normalAppearanceState.get(as.name);
  15642. }
  15643. loadResources(keys) {
  15644. return this.appearance.dict.getAsync("Resources").then(resources => {
  15645. if (!resources) {
  15646. return undefined;
  15647. }
  15648. const objectLoader = new _obj.ObjectLoader(resources, keys, resources.xref);
  15649. return objectLoader.load().then(function () {
  15650. return resources;
  15651. });
  15652. });
  15653. }
  15654. getOperatorList(evaluator, task, renderForms, annotationStorage) {
  15655. if (!this.appearance) {
  15656. return Promise.resolve(new _operator_list.OperatorList());
  15657. }
  15658. const appearance = this.appearance;
  15659. const data = this.data;
  15660. const appearanceDict = appearance.dict;
  15661. const resourcesPromise = this.loadResources(["ExtGState", "ColorSpace", "Pattern", "Shading", "XObject", "Font"]);
  15662. const bbox = appearanceDict.getArray("BBox") || [0, 0, 1, 1];
  15663. const matrix = appearanceDict.getArray("Matrix") || [1, 0, 0, 1, 0, 0];
  15664. const transform = getTransformMatrix(data.rect, bbox, matrix);
  15665. return resourcesPromise.then(resources => {
  15666. const opList = new _operator_list.OperatorList();
  15667. opList.addOp(_util.OPS.beginAnnotation, [data.rect, transform, matrix]);
  15668. return evaluator.getOperatorList({
  15669. stream: appearance,
  15670. task,
  15671. resources,
  15672. operatorList: opList
  15673. }).then(() => {
  15674. opList.addOp(_util.OPS.endAnnotation, []);
  15675. appearance.reset();
  15676. return opList;
  15677. });
  15678. });
  15679. }
  15680. async save(evaluator, task, annotationStorage) {
  15681. return null;
  15682. }
  15683. }
  15684. exports.Annotation = Annotation;
  15685. class AnnotationBorderStyle {
  15686. constructor() {
  15687. this.width = 1;
  15688. this.style = _util.AnnotationBorderStyleType.SOLID;
  15689. this.dashArray = [3];
  15690. this.horizontalCornerRadius = 0;
  15691. this.verticalCornerRadius = 0;
  15692. }
  15693. setWidth(width, rect = [0, 0, 0, 0]) {
  15694. if ((0, _primitives.isName)(width)) {
  15695. this.width = 0;
  15696. return;
  15697. }
  15698. if (Number.isInteger(width)) {
  15699. if (width > 0) {
  15700. const maxWidth = (rect[2] - rect[0]) / 2;
  15701. const maxHeight = (rect[3] - rect[1]) / 2;
  15702. if (maxWidth > 0 && maxHeight > 0 && (width > maxWidth || width > maxHeight)) {
  15703. (0, _util.warn)(`AnnotationBorderStyle.setWidth - ignoring width: ${width}`);
  15704. width = 1;
  15705. }
  15706. }
  15707. this.width = width;
  15708. }
  15709. }
  15710. setStyle(style) {
  15711. if (!(0, _primitives.isName)(style)) {
  15712. return;
  15713. }
  15714. switch (style.name) {
  15715. case "S":
  15716. this.style = _util.AnnotationBorderStyleType.SOLID;
  15717. break;
  15718. case "D":
  15719. this.style = _util.AnnotationBorderStyleType.DASHED;
  15720. break;
  15721. case "B":
  15722. this.style = _util.AnnotationBorderStyleType.BEVELED;
  15723. break;
  15724. case "I":
  15725. this.style = _util.AnnotationBorderStyleType.INSET;
  15726. break;
  15727. case "U":
  15728. this.style = _util.AnnotationBorderStyleType.UNDERLINE;
  15729. break;
  15730. default:
  15731. break;
  15732. }
  15733. }
  15734. setDashArray(dashArray) {
  15735. if (Array.isArray(dashArray) && dashArray.length > 0) {
  15736. let isValid = true;
  15737. let allZeros = true;
  15738. for (const element of dashArray) {
  15739. const validNumber = +element >= 0;
  15740. if (!validNumber) {
  15741. isValid = false;
  15742. break;
  15743. } else if (element > 0) {
  15744. allZeros = false;
  15745. }
  15746. }
  15747. if (isValid && !allZeros) {
  15748. this.dashArray = dashArray;
  15749. } else {
  15750. this.width = 0;
  15751. }
  15752. } else if (dashArray) {
  15753. this.width = 0;
  15754. }
  15755. }
  15756. setHorizontalCornerRadius(radius) {
  15757. if (Number.isInteger(radius)) {
  15758. this.horizontalCornerRadius = radius;
  15759. }
  15760. }
  15761. setVerticalCornerRadius(radius) {
  15762. if (Number.isInteger(radius)) {
  15763. this.verticalCornerRadius = radius;
  15764. }
  15765. }
  15766. }
  15767. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  15768. class MarkupAnnotation extends Annotation {
  15769. constructor(parameters) {
  15770. super(parameters);
  15771. const dict = parameters.dict;
  15772. if (dict.has("IRT")) {
  15773. const rawIRT = dict.getRaw("IRT");
  15774. this.data.inReplyTo = (0, _primitives.isRef)(rawIRT) ? rawIRT.toString() : null;
  15775. const rt = dict.get("RT");
  15776. this.data.replyType = (0, _primitives.isName)(rt) ? rt.name : _util.AnnotationReplyType.REPLY;
  15777. }
  15778. if (this.data.replyType === _util.AnnotationReplyType.GROUP) {
  15779. const parent = dict.get("IRT");
  15780. this.data.title = (0, _util.stringToPDFString)(parent.get("T") || "");
  15781. this.setContents(parent.get("Contents"));
  15782. this.data.contents = this.contents;
  15783. if (!parent.has("CreationDate")) {
  15784. this.data.creationDate = null;
  15785. } else {
  15786. this.setCreationDate(parent.get("CreationDate"));
  15787. this.data.creationDate = this.creationDate;
  15788. }
  15789. if (!parent.has("M")) {
  15790. this.data.modificationDate = null;
  15791. } else {
  15792. this.setModificationDate(parent.get("M"));
  15793. this.data.modificationDate = this.modificationDate;
  15794. }
  15795. this.data.hasPopup = parent.has("Popup");
  15796. if (!parent.has("C")) {
  15797. this.data.color = null;
  15798. } else {
  15799. this.setColor(parent.getArray("C"));
  15800. this.data.color = this.color;
  15801. }
  15802. } else {
  15803. this.data.title = (0, _util.stringToPDFString)(dict.get("T") || "");
  15804. this.setCreationDate(dict.get("CreationDate"));
  15805. this.data.creationDate = this.creationDate;
  15806. this.data.hasPopup = dict.has("Popup");
  15807. if (!dict.has("C")) {
  15808. this.data.color = null;
  15809. }
  15810. }
  15811. }
  15812. setCreationDate(creationDate) {
  15813. this.creationDate = (0, _util.isString)(creationDate) ? creationDate : null;
  15814. }
  15815. }
  15816. exports.MarkupAnnotation = MarkupAnnotation;
  15817. class WidgetAnnotation extends Annotation {
  15818. constructor(params) {
  15819. super(params);
  15820. const dict = params.dict;
  15821. const data = this.data;
  15822. this.ref = params.ref;
  15823. data.annotationType = _util.AnnotationType.WIDGET;
  15824. data.fieldName = this._constructFieldName(dict);
  15825. const fieldValue = (0, _core_utils.getInheritableProperty)({
  15826. dict,
  15827. key: "V",
  15828. getArray: true
  15829. });
  15830. data.fieldValue = this._decodeFormValue(fieldValue);
  15831. data.alternativeText = (0, _util.stringToPDFString)(dict.get("TU") || "");
  15832. data.defaultAppearance = (0, _core_utils.getInheritableProperty)({
  15833. dict,
  15834. key: "DA"
  15835. }) || params.acroForm.get("DA") || "";
  15836. const fieldType = (0, _core_utils.getInheritableProperty)({
  15837. dict,
  15838. key: "FT"
  15839. });
  15840. data.fieldType = (0, _primitives.isName)(fieldType) ? fieldType.name : null;
  15841. this.fieldResources = (0, _core_utils.getInheritableProperty)({
  15842. dict,
  15843. key: "DR"
  15844. }) || params.acroForm.get("DR") || _primitives.Dict.empty;
  15845. data.fieldFlags = (0, _core_utils.getInheritableProperty)({
  15846. dict,
  15847. key: "Ff"
  15848. });
  15849. if (!Number.isInteger(data.fieldFlags) || data.fieldFlags < 0) {
  15850. data.fieldFlags = 0;
  15851. }
  15852. data.readOnly = this.hasFieldFlag(_util.AnnotationFieldFlag.READONLY);
  15853. if (data.fieldType === "Sig") {
  15854. data.fieldValue = null;
  15855. this.setFlags(_util.AnnotationFlag.HIDDEN);
  15856. }
  15857. }
  15858. _constructFieldName(dict) {
  15859. if (!dict.has("T") && !dict.has("Parent")) {
  15860. (0, _util.warn)("Unknown field name, falling back to empty field name.");
  15861. return "";
  15862. }
  15863. if (!dict.has("Parent")) {
  15864. return (0, _util.stringToPDFString)(dict.get("T"));
  15865. }
  15866. const fieldName = [];
  15867. if (dict.has("T")) {
  15868. fieldName.unshift((0, _util.stringToPDFString)(dict.get("T")));
  15869. }
  15870. let loopDict = dict;
  15871. while (loopDict.has("Parent")) {
  15872. loopDict = loopDict.get("Parent");
  15873. if (!(0, _primitives.isDict)(loopDict)) {
  15874. break;
  15875. }
  15876. if (loopDict.has("T")) {
  15877. fieldName.unshift((0, _util.stringToPDFString)(loopDict.get("T")));
  15878. }
  15879. }
  15880. return fieldName.join(".");
  15881. }
  15882. _decodeFormValue(formValue) {
  15883. if (Array.isArray(formValue)) {
  15884. return formValue.filter(item => (0, _util.isString)(item)).map(item => (0, _util.stringToPDFString)(item));
  15885. } else if ((0, _primitives.isName)(formValue)) {
  15886. return (0, _util.stringToPDFString)(formValue.name);
  15887. } else if ((0, _util.isString)(formValue)) {
  15888. return (0, _util.stringToPDFString)(formValue);
  15889. }
  15890. return null;
  15891. }
  15892. hasFieldFlag(flag) {
  15893. return !!(this.data.fieldFlags & flag);
  15894. }
  15895. getOperatorList(evaluator, task, renderForms, annotationStorage) {
  15896. if (renderForms) {
  15897. return Promise.resolve(new _operator_list.OperatorList());
  15898. }
  15899. if (!this._hasText) {
  15900. return super.getOperatorList(evaluator, task, renderForms, annotationStorage);
  15901. }
  15902. return this._getAppearance(evaluator, task, annotationStorage).then(content => {
  15903. if (this.appearance && content === null) {
  15904. return super.getOperatorList(evaluator, task, renderForms, annotationStorage);
  15905. }
  15906. const operatorList = new _operator_list.OperatorList();
  15907. if (!this.data.defaultAppearance || content === null) {
  15908. return operatorList;
  15909. }
  15910. const matrix = [1, 0, 0, 1, 0, 0];
  15911. const bbox = [0, 0, this.data.rect[2] - this.data.rect[0], this.data.rect[3] - this.data.rect[1]];
  15912. const transform = getTransformMatrix(this.data.rect, bbox, matrix);
  15913. operatorList.addOp(_util.OPS.beginAnnotation, [this.data.rect, transform, matrix]);
  15914. const stream = new _stream.StringStream(content);
  15915. return evaluator.getOperatorList({
  15916. stream,
  15917. task,
  15918. resources: this.fieldResources,
  15919. operatorList
  15920. }).then(function () {
  15921. operatorList.addOp(_util.OPS.endAnnotation, []);
  15922. return operatorList;
  15923. });
  15924. });
  15925. }
  15926. async save(evaluator, task, annotationStorage) {
  15927. if (this.data.fieldValue === annotationStorage[this.data.id]) {
  15928. return null;
  15929. }
  15930. let appearance = await this._getAppearance(evaluator, task, annotationStorage);
  15931. if (appearance === null) {
  15932. return null;
  15933. }
  15934. const dict = evaluator.xref.fetchIfRef(this.ref);
  15935. if (!(0, _primitives.isDict)(dict)) {
  15936. return null;
  15937. }
  15938. const bbox = [0, 0, this.data.rect[2] - this.data.rect[0], this.data.rect[3] - this.data.rect[1]];
  15939. const newRef = evaluator.xref.getNewRef();
  15940. const AP = new _primitives.Dict(evaluator.xref);
  15941. AP.set("N", newRef);
  15942. const value = annotationStorage[this.data.id];
  15943. const encrypt = evaluator.xref.encrypt;
  15944. let originalTransform = null;
  15945. let newTransform = null;
  15946. if (encrypt) {
  15947. originalTransform = encrypt.createCipherTransform(this.ref.num, this.ref.gen);
  15948. newTransform = encrypt.createCipherTransform(newRef.num, newRef.gen);
  15949. appearance = newTransform.encryptString(appearance);
  15950. }
  15951. dict.set("V", value);
  15952. dict.set("AP", AP);
  15953. dict.set("M", `D:${(0, _util.getModificationDate)()}`);
  15954. const appearanceDict = new _primitives.Dict(evaluator.xref);
  15955. appearanceDict.set("Length", appearance.length);
  15956. appearanceDict.set("Subtype", _primitives.Name.get("Form"));
  15957. appearanceDict.set("Resources", this.fieldResources);
  15958. appearanceDict.set("BBox", bbox);
  15959. const bufferOriginal = [`${this.ref.num} ${this.ref.gen} obj\n`];
  15960. (0, _writer.writeDict)(dict, bufferOriginal, originalTransform);
  15961. bufferOriginal.push("\nendobj\n");
  15962. const bufferNew = [`${newRef.num} ${newRef.gen} obj\n`];
  15963. (0, _writer.writeDict)(appearanceDict, bufferNew, newTransform);
  15964. bufferNew.push(" stream\n");
  15965. bufferNew.push(appearance);
  15966. bufferNew.push("\nendstream\nendobj\n");
  15967. return [{
  15968. ref: this.ref,
  15969. data: bufferOriginal.join("")
  15970. }, {
  15971. ref: newRef,
  15972. data: bufferNew.join("")
  15973. }];
  15974. }
  15975. async _getAppearance(evaluator, task, annotationStorage) {
  15976. const isPassword = this.hasFieldFlag(_util.AnnotationFieldFlag.PASSWORD);
  15977. if (!annotationStorage || isPassword) {
  15978. return null;
  15979. }
  15980. const value = annotationStorage[this.data.id];
  15981. if (value === "") {
  15982. return "";
  15983. }
  15984. const defaultPadding = 2;
  15985. const hPadding = defaultPadding;
  15986. const totalHeight = this.data.rect[3] - this.data.rect[1];
  15987. const totalWidth = this.data.rect[2] - this.data.rect[0];
  15988. const fontInfo = await this._getFontData(evaluator, task);
  15989. const [font, fontName] = fontInfo;
  15990. let fontSize = fontInfo[2];
  15991. fontSize = this._computeFontSize(font, fontName, fontSize, totalHeight);
  15992. let descent = font.descent;
  15993. if (isNaN(descent)) {
  15994. descent = 0;
  15995. }
  15996. const vPadding = defaultPadding + Math.abs(descent) * fontSize;
  15997. const defaultAppearance = this.data.defaultAppearance;
  15998. const alignment = this.data.textAlignment;
  15999. if (this.data.comb) {
  16000. return this._getCombAppearance(defaultAppearance, value, totalWidth, hPadding, vPadding);
  16001. }
  16002. if (this.data.multiLine) {
  16003. return this._getMultilineAppearance(defaultAppearance, value, font, fontSize, totalWidth, totalHeight, alignment, hPadding, vPadding);
  16004. }
  16005. if (alignment === 0 || alignment > 2) {
  16006. return "/Tx BMC q BT " + defaultAppearance + ` 1 0 0 1 ${hPadding} ${vPadding} Tm (${(0, _util.escapeString)(value)}) Tj` + " ET Q EMC";
  16007. }
  16008. const renderedText = this._renderText(value, font, fontSize, totalWidth, alignment, hPadding, vPadding);
  16009. return "/Tx BMC q BT " + defaultAppearance + ` 1 0 0 1 0 0 Tm ${renderedText}` + " ET Q EMC";
  16010. }
  16011. async _getFontData(evaluator, task) {
  16012. const operatorList = new _operator_list.OperatorList();
  16013. const initialState = {
  16014. fontSize: 0,
  16015. font: null,
  16016. fontName: null,
  16017. clone() {
  16018. return this;
  16019. }
  16020. };
  16021. await evaluator.getOperatorList({
  16022. stream: new _stream.StringStream(this.data.defaultAppearance),
  16023. task,
  16024. resources: this.fieldResources,
  16025. operatorList,
  16026. initialState
  16027. });
  16028. return [initialState.font, initialState.fontName, initialState.fontSize];
  16029. }
  16030. _computeFontSize(font, fontName, fontSize, height) {
  16031. if (fontSize === null || fontSize === 0) {
  16032. const em = font.charsToGlyphs("M", true)[0].width / 1000;
  16033. const capHeight = 0.7 * em;
  16034. fontSize = Math.max(1, Math.floor(height / (1.5 * capHeight)));
  16035. let fontRegex = new RegExp(`/${fontName}\\s+[0-9\.]+\\s+Tf`);
  16036. if (this.data.defaultAppearance.search(fontRegex) === -1) {
  16037. fontRegex = new RegExp(`/${fontName}\\s+Tf`);
  16038. }
  16039. this.data.defaultAppearance = this.data.defaultAppearance.replace(fontRegex, `/${fontName} ${fontSize} Tf`);
  16040. }
  16041. return fontSize;
  16042. }
  16043. _renderText(text, font, fontSize, totalWidth, alignment, hPadding, vPadding) {
  16044. const glyphs = font.charsToGlyphs(text);
  16045. const scale = fontSize / 1000;
  16046. let width = 0;
  16047. for (const glyph of glyphs) {
  16048. width += glyph.width * scale;
  16049. }
  16050. let shift;
  16051. if (alignment === 1) {
  16052. shift = (totalWidth - width) / 2;
  16053. } else if (alignment === 2) {
  16054. shift = totalWidth - width - hPadding;
  16055. } else {
  16056. shift = hPadding;
  16057. }
  16058. shift = shift.toFixed(2);
  16059. vPadding = vPadding.toFixed(2);
  16060. return `${shift} ${vPadding} Td (${(0, _util.escapeString)(text)}) Tj`;
  16061. }
  16062. }
  16063. class TextWidgetAnnotation extends WidgetAnnotation {
  16064. constructor(params) {
  16065. super(params);
  16066. this._hasText = true;
  16067. const dict = params.dict;
  16068. if (!(0, _util.isString)(this.data.fieldValue)) {
  16069. this.data.fieldValue = "";
  16070. }
  16071. let alignment = (0, _core_utils.getInheritableProperty)({
  16072. dict,
  16073. key: "Q"
  16074. });
  16075. if (!Number.isInteger(alignment) || alignment < 0 || alignment > 2) {
  16076. alignment = null;
  16077. }
  16078. this.data.textAlignment = alignment;
  16079. let maximumLength = (0, _core_utils.getInheritableProperty)({
  16080. dict,
  16081. key: "MaxLen"
  16082. });
  16083. if (!Number.isInteger(maximumLength) || maximumLength < 0) {
  16084. maximumLength = null;
  16085. }
  16086. this.data.maxLen = maximumLength;
  16087. this.data.multiLine = this.hasFieldFlag(_util.AnnotationFieldFlag.MULTILINE);
  16088. this.data.comb = this.hasFieldFlag(_util.AnnotationFieldFlag.COMB) && !this.hasFieldFlag(_util.AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(_util.AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(_util.AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  16089. }
  16090. _getCombAppearance(defaultAppearance, text, width, hPadding, vPadding) {
  16091. const combWidth = (width / this.data.maxLen).toFixed(2);
  16092. const buf = [];
  16093. for (const character of text) {
  16094. buf.push(`(${(0, _util.escapeString)(character)}) Tj`);
  16095. }
  16096. const renderedComb = buf.join(` ${combWidth} 0 Td `);
  16097. return "/Tx BMC q BT " + defaultAppearance + ` 1 0 0 1 ${hPadding} ${vPadding} Tm ${renderedComb}` + " ET Q EMC";
  16098. }
  16099. _getMultilineAppearance(defaultAppearance, text, font, fontSize, width, height, alignment, hPadding, vPadding) {
  16100. const lines = text.split(/\r\n|\r|\n/);
  16101. const buf = [];
  16102. const totalWidth = width - 2 * hPadding;
  16103. for (const line of lines) {
  16104. const chunks = this._splitLine(line, font, fontSize, totalWidth);
  16105. for (const chunk of chunks) {
  16106. const padding = buf.length === 0 ? hPadding : 0;
  16107. buf.push(this._renderText(chunk, font, fontSize, width, alignment, padding, -fontSize));
  16108. }
  16109. }
  16110. const renderedText = buf.join("\n");
  16111. return "/Tx BMC q BT " + defaultAppearance + ` 1 0 0 1 0 ${height} Tm ${renderedText}` + " ET Q EMC";
  16112. }
  16113. _splitLine(line, font, fontSize, width) {
  16114. if (line.length <= 1) {
  16115. return [line];
  16116. }
  16117. const scale = fontSize / 1000;
  16118. const whitespace = font.charsToGlyphs(" ", true)[0].width * scale;
  16119. const chunks = [];
  16120. let lastSpacePos = -1,
  16121. startChunk = 0,
  16122. currentWidth = 0;
  16123. for (let i = 0, ii = line.length; i < ii; i++) {
  16124. const character = line.charAt(i);
  16125. if (character === " ") {
  16126. if (currentWidth + whitespace > width) {
  16127. chunks.push(line.substring(startChunk, i));
  16128. startChunk = i;
  16129. currentWidth = whitespace;
  16130. lastSpacePos = -1;
  16131. } else {
  16132. currentWidth += whitespace;
  16133. lastSpacePos = i;
  16134. }
  16135. } else {
  16136. const charWidth = font.charsToGlyphs(character, false)[0].width * scale;
  16137. if (currentWidth + charWidth > width) {
  16138. if (lastSpacePos !== -1) {
  16139. chunks.push(line.substring(startChunk, lastSpacePos + 1));
  16140. startChunk = i = lastSpacePos + 1;
  16141. lastSpacePos = -1;
  16142. currentWidth = 0;
  16143. } else {
  16144. chunks.push(line.substring(startChunk, i));
  16145. startChunk = i;
  16146. currentWidth = charWidth;
  16147. }
  16148. } else {
  16149. currentWidth += charWidth;
  16150. }
  16151. }
  16152. }
  16153. if (startChunk < line.length) {
  16154. chunks.push(line.substring(startChunk, line.length));
  16155. }
  16156. return chunks;
  16157. }
  16158. }
  16159. class ButtonWidgetAnnotation extends WidgetAnnotation {
  16160. constructor(params) {
  16161. super(params);
  16162. this.checkedAppearance = null;
  16163. this.uncheckedAppearance = null;
  16164. this.data.checkBox = !this.hasFieldFlag(_util.AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
  16165. this.data.radioButton = this.hasFieldFlag(_util.AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
  16166. this.data.pushButton = this.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
  16167. if (this.data.checkBox) {
  16168. this._processCheckBox(params);
  16169. } else if (this.data.radioButton) {
  16170. this._processRadioButton(params);
  16171. } else if (this.data.pushButton) {
  16172. this._processPushButton(params);
  16173. } else {
  16174. (0, _util.warn)("Invalid field flags for button widget annotation");
  16175. }
  16176. }
  16177. getOperatorList(evaluator, task, renderForms, annotationStorage) {
  16178. if (this.data.pushButton) {
  16179. return super.getOperatorList(evaluator, task, false, annotationStorage);
  16180. }
  16181. if (annotationStorage) {
  16182. const value = annotationStorage[this.data.id] || false;
  16183. let appearance;
  16184. if (value) {
  16185. appearance = this.checkedAppearance;
  16186. } else {
  16187. appearance = this.uncheckedAppearance;
  16188. }
  16189. if (appearance) {
  16190. const savedAppearance = this.appearance;
  16191. this.appearance = appearance;
  16192. const operatorList = super.getOperatorList(evaluator, task, renderForms, annotationStorage);
  16193. this.appearance = savedAppearance;
  16194. return operatorList;
  16195. }
  16196. return Promise.resolve(new _operator_list.OperatorList());
  16197. }
  16198. return super.getOperatorList(evaluator, task, renderForms, annotationStorage);
  16199. }
  16200. async save(evaluator, task, annotationStorage) {
  16201. if (this.data.checkBox) {
  16202. return this._saveCheckbox(evaluator, task, annotationStorage);
  16203. }
  16204. if (this.data.radioButton) {
  16205. return this._saveRadioButton(evaluator, task, annotationStorage);
  16206. }
  16207. return super.save(evaluator, task, annotationStorage);
  16208. }
  16209. async _saveCheckbox(evaluator, task, annotationStorage) {
  16210. const defaultValue = this.data.fieldValue && this.data.fieldValue !== "Off";
  16211. const value = annotationStorage[this.data.id];
  16212. if (defaultValue === value) {
  16213. return null;
  16214. }
  16215. const dict = evaluator.xref.fetchIfRef(this.ref);
  16216. if (!(0, _primitives.isDict)(dict)) {
  16217. return null;
  16218. }
  16219. const name = _primitives.Name.get(value ? this.data.exportValue : "Off");
  16220. dict.set("V", name);
  16221. dict.set("AS", name);
  16222. dict.set("M", `D:${(0, _util.getModificationDate)()}`);
  16223. const encrypt = evaluator.xref.encrypt;
  16224. let originalTransform = null;
  16225. if (encrypt) {
  16226. originalTransform = encrypt.createCipherTransform(this.ref.num, this.ref.gen);
  16227. }
  16228. const buffer = [`${this.ref.num} ${this.ref.gen} obj\n`];
  16229. (0, _writer.writeDict)(dict, buffer, originalTransform);
  16230. buffer.push("\nendobj\n");
  16231. return [{
  16232. ref: this.ref,
  16233. data: buffer.join("")
  16234. }];
  16235. }
  16236. async _saveRadioButton(evaluator, task, annotationStorage) {
  16237. const defaultValue = this.data.fieldValue === this.data.buttonValue;
  16238. const value = annotationStorage[this.data.id];
  16239. if (defaultValue === value) {
  16240. return null;
  16241. }
  16242. const dict = evaluator.xref.fetchIfRef(this.ref);
  16243. if (!(0, _primitives.isDict)(dict)) {
  16244. return null;
  16245. }
  16246. const name = _primitives.Name.get(value ? this.data.buttonValue : "Off");
  16247. let parentBuffer = null;
  16248. const encrypt = evaluator.xref.encrypt;
  16249. if (value) {
  16250. if ((0, _primitives.isRef)(this.parent)) {
  16251. const parent = evaluator.xref.fetch(this.parent);
  16252. let parentTransform = null;
  16253. if (encrypt) {
  16254. parentTransform = encrypt.createCipherTransform(this.parent.num, this.parent.gen);
  16255. }
  16256. parent.set("V", name);
  16257. parentBuffer = [`${this.parent.num} ${this.parent.gen} obj\n`];
  16258. (0, _writer.writeDict)(parent, parentBuffer, parentTransform);
  16259. parentBuffer.push("\nendobj\n");
  16260. } else if ((0, _primitives.isDict)(this.parent)) {
  16261. this.parent.set("V", name);
  16262. }
  16263. }
  16264. dict.set("AS", name);
  16265. dict.set("M", `D:${(0, _util.getModificationDate)()}`);
  16266. let originalTransform = null;
  16267. if (encrypt) {
  16268. originalTransform = encrypt.createCipherTransform(this.ref.num, this.ref.gen);
  16269. }
  16270. const buffer = [`${this.ref.num} ${this.ref.gen} obj\n`];
  16271. (0, _writer.writeDict)(dict, buffer, originalTransform);
  16272. buffer.push("\nendobj\n");
  16273. const newRefs = [{
  16274. ref: this.ref,
  16275. data: buffer.join("")
  16276. }];
  16277. if (parentBuffer !== null) {
  16278. newRefs.push({
  16279. ref: this.parent,
  16280. data: parentBuffer.join("")
  16281. });
  16282. }
  16283. return newRefs;
  16284. }
  16285. _processCheckBox(params) {
  16286. const customAppearance = params.dict.get("AP");
  16287. if (!(0, _primitives.isDict)(customAppearance)) {
  16288. return;
  16289. }
  16290. const normalAppearance = customAppearance.get("N");
  16291. if (!(0, _primitives.isDict)(normalAppearance)) {
  16292. return;
  16293. }
  16294. const exportValues = normalAppearance.getKeys();
  16295. if (!exportValues.includes("Off")) {
  16296. exportValues.push("Off");
  16297. }
  16298. if (exportValues.length !== 2) {
  16299. return;
  16300. }
  16301. this.data.exportValue = exportValues[0] === "Off" ? exportValues[1] : exportValues[0];
  16302. this.checkedAppearance = normalAppearance.get(this.data.exportValue);
  16303. this.uncheckedAppearance = normalAppearance.get("Off") || null;
  16304. }
  16305. _processRadioButton(params) {
  16306. this.data.fieldValue = this.data.buttonValue = null;
  16307. const fieldParent = params.dict.get("Parent");
  16308. if ((0, _primitives.isDict)(fieldParent) && fieldParent.has("V")) {
  16309. const fieldParentValue = fieldParent.get("V");
  16310. if ((0, _primitives.isName)(fieldParentValue)) {
  16311. this.parent = params.dict.getRaw("Parent");
  16312. this.data.fieldValue = this._decodeFormValue(fieldParentValue);
  16313. }
  16314. }
  16315. const appearanceStates = params.dict.get("AP");
  16316. if (!(0, _primitives.isDict)(appearanceStates)) {
  16317. return;
  16318. }
  16319. const normalAppearance = appearanceStates.get("N");
  16320. if (!(0, _primitives.isDict)(normalAppearance)) {
  16321. return;
  16322. }
  16323. for (const key of normalAppearance.getKeys()) {
  16324. if (key !== "Off") {
  16325. this.data.buttonValue = key;
  16326. break;
  16327. }
  16328. }
  16329. this.checkedAppearance = normalAppearance.get(this.data.buttonValue);
  16330. this.uncheckedAppearance = normalAppearance.get("Off") || null;
  16331. }
  16332. _processPushButton(params) {
  16333. if (!params.dict.has("A")) {
  16334. (0, _util.warn)("Push buttons without action dictionaries are not supported");
  16335. return;
  16336. }
  16337. _obj.Catalog.parseDestDictionary({
  16338. destDict: params.dict,
  16339. resultObj: this.data,
  16340. docBaseUrl: params.pdfManager.docBaseUrl
  16341. });
  16342. }
  16343. }
  16344. class ChoiceWidgetAnnotation extends WidgetAnnotation {
  16345. constructor(params) {
  16346. super(params);
  16347. this.data.options = [];
  16348. const options = (0, _core_utils.getInheritableProperty)({
  16349. dict: params.dict,
  16350. key: "Opt"
  16351. });
  16352. if (Array.isArray(options)) {
  16353. const xref = params.xref;
  16354. for (let i = 0, ii = options.length; i < ii; i++) {
  16355. const option = xref.fetchIfRef(options[i]);
  16356. const isOptionArray = Array.isArray(option);
  16357. this.data.options[i] = {
  16358. exportValue: this._decodeFormValue(isOptionArray ? xref.fetchIfRef(option[0]) : option),
  16359. displayValue: this._decodeFormValue(isOptionArray ? xref.fetchIfRef(option[1]) : option)
  16360. };
  16361. }
  16362. }
  16363. if ((0, _util.isString)(this.data.fieldValue)) {
  16364. this.data.fieldValue = [this.data.fieldValue];
  16365. } else if (!this.data.fieldValue) {
  16366. this.data.fieldValue = [];
  16367. }
  16368. this.data.combo = this.hasFieldFlag(_util.AnnotationFieldFlag.COMBO);
  16369. this.data.multiSelect = this.hasFieldFlag(_util.AnnotationFieldFlag.MULTISELECT);
  16370. this._hasText = true;
  16371. }
  16372. }
  16373. class TextAnnotation extends MarkupAnnotation {
  16374. constructor(parameters) {
  16375. const DEFAULT_ICON_SIZE = 22;
  16376. super(parameters);
  16377. const dict = parameters.dict;
  16378. this.data.annotationType = _util.AnnotationType.TEXT;
  16379. if (this.data.hasAppearance) {
  16380. this.data.name = "NoIcon";
  16381. } else {
  16382. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  16383. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  16384. this.data.name = dict.has("Name") ? dict.get("Name").name : "Note";
  16385. }
  16386. if (dict.has("State")) {
  16387. this.data.state = dict.get("State") || null;
  16388. this.data.stateModel = dict.get("StateModel") || null;
  16389. } else {
  16390. this.data.state = null;
  16391. this.data.stateModel = null;
  16392. }
  16393. }
  16394. }
  16395. class LinkAnnotation extends Annotation {
  16396. constructor(params) {
  16397. super(params);
  16398. this.data.annotationType = _util.AnnotationType.LINK;
  16399. const quadPoints = getQuadPoints(params.dict, this.rectangle);
  16400. if (quadPoints) {
  16401. this.data.quadPoints = quadPoints;
  16402. }
  16403. _obj.Catalog.parseDestDictionary({
  16404. destDict: params.dict,
  16405. resultObj: this.data,
  16406. docBaseUrl: params.pdfManager.docBaseUrl
  16407. });
  16408. }
  16409. }
  16410. class PopupAnnotation extends Annotation {
  16411. constructor(parameters) {
  16412. super(parameters);
  16413. this.data.annotationType = _util.AnnotationType.POPUP;
  16414. let parentItem = parameters.dict.get("Parent");
  16415. if (!parentItem) {
  16416. (0, _util.warn)("Popup annotation has a missing or invalid parent annotation.");
  16417. return;
  16418. }
  16419. const parentSubtype = parentItem.get("Subtype");
  16420. this.data.parentType = (0, _primitives.isName)(parentSubtype) ? parentSubtype.name : null;
  16421. const rawParent = parameters.dict.getRaw("Parent");
  16422. this.data.parentId = (0, _primitives.isRef)(rawParent) ? rawParent.toString() : null;
  16423. const rt = parentItem.get("RT");
  16424. if ((0, _primitives.isName)(rt, _util.AnnotationReplyType.GROUP)) {
  16425. parentItem = parentItem.get("IRT");
  16426. }
  16427. if (!parentItem.has("M")) {
  16428. this.data.modificationDate = null;
  16429. } else {
  16430. this.setModificationDate(parentItem.get("M"));
  16431. this.data.modificationDate = this.modificationDate;
  16432. }
  16433. if (!parentItem.has("C")) {
  16434. this.data.color = null;
  16435. } else {
  16436. this.setColor(parentItem.getArray("C"));
  16437. this.data.color = this.color;
  16438. }
  16439. if (!this.viewable) {
  16440. const parentFlags = parentItem.get("F");
  16441. if (this._isViewable(parentFlags)) {
  16442. this.setFlags(parentFlags);
  16443. }
  16444. }
  16445. this.data.title = (0, _util.stringToPDFString)(parentItem.get("T") || "");
  16446. this.data.contents = (0, _util.stringToPDFString)(parentItem.get("Contents") || "");
  16447. }
  16448. }
  16449. class FreeTextAnnotation extends MarkupAnnotation {
  16450. constructor(parameters) {
  16451. super(parameters);
  16452. this.data.annotationType = _util.AnnotationType.FREETEXT;
  16453. }
  16454. }
  16455. class LineAnnotation extends MarkupAnnotation {
  16456. constructor(parameters) {
  16457. super(parameters);
  16458. this.data.annotationType = _util.AnnotationType.LINE;
  16459. this.data.lineCoordinates = _util.Util.normalizeRect(parameters.dict.getArray("L"));
  16460. }
  16461. }
  16462. class SquareAnnotation extends MarkupAnnotation {
  16463. constructor(parameters) {
  16464. super(parameters);
  16465. this.data.annotationType = _util.AnnotationType.SQUARE;
  16466. }
  16467. }
  16468. class CircleAnnotation extends MarkupAnnotation {
  16469. constructor(parameters) {
  16470. super(parameters);
  16471. this.data.annotationType = _util.AnnotationType.CIRCLE;
  16472. }
  16473. }
  16474. class PolylineAnnotation extends MarkupAnnotation {
  16475. constructor(parameters) {
  16476. super(parameters);
  16477. this.data.annotationType = _util.AnnotationType.POLYLINE;
  16478. const rawVertices = parameters.dict.getArray("Vertices");
  16479. this.data.vertices = [];
  16480. for (let i = 0, ii = rawVertices.length; i < ii; i += 2) {
  16481. this.data.vertices.push({
  16482. x: rawVertices[i],
  16483. y: rawVertices[i + 1]
  16484. });
  16485. }
  16486. }
  16487. }
  16488. class PolygonAnnotation extends PolylineAnnotation {
  16489. constructor(parameters) {
  16490. super(parameters);
  16491. this.data.annotationType = _util.AnnotationType.POLYGON;
  16492. }
  16493. }
  16494. class CaretAnnotation extends MarkupAnnotation {
  16495. constructor(parameters) {
  16496. super(parameters);
  16497. this.data.annotationType = _util.AnnotationType.CARET;
  16498. }
  16499. }
  16500. class InkAnnotation extends MarkupAnnotation {
  16501. constructor(parameters) {
  16502. super(parameters);
  16503. this.data.annotationType = _util.AnnotationType.INK;
  16504. const xref = parameters.xref;
  16505. const originalInkLists = parameters.dict.getArray("InkList");
  16506. this.data.inkLists = [];
  16507. for (let i = 0, ii = originalInkLists.length; i < ii; ++i) {
  16508. this.data.inkLists.push([]);
  16509. for (let j = 0, jj = originalInkLists[i].length; j < jj; j += 2) {
  16510. this.data.inkLists[i].push({
  16511. x: xref.fetchIfRef(originalInkLists[i][j]),
  16512. y: xref.fetchIfRef(originalInkLists[i][j + 1])
  16513. });
  16514. }
  16515. }
  16516. }
  16517. }
  16518. class HighlightAnnotation extends MarkupAnnotation {
  16519. constructor(parameters) {
  16520. super(parameters);
  16521. this.data.annotationType = _util.AnnotationType.HIGHLIGHT;
  16522. const quadPoints = getQuadPoints(parameters.dict, this.rectangle);
  16523. if (quadPoints) {
  16524. this.data.quadPoints = quadPoints;
  16525. }
  16526. }
  16527. }
  16528. class UnderlineAnnotation extends MarkupAnnotation {
  16529. constructor(parameters) {
  16530. super(parameters);
  16531. this.data.annotationType = _util.AnnotationType.UNDERLINE;
  16532. const quadPoints = getQuadPoints(parameters.dict, this.rectangle);
  16533. if (quadPoints) {
  16534. this.data.quadPoints = quadPoints;
  16535. }
  16536. }
  16537. }
  16538. class SquigglyAnnotation extends MarkupAnnotation {
  16539. constructor(parameters) {
  16540. super(parameters);
  16541. this.data.annotationType = _util.AnnotationType.SQUIGGLY;
  16542. const quadPoints = getQuadPoints(parameters.dict, this.rectangle);
  16543. if (quadPoints) {
  16544. this.data.quadPoints = quadPoints;
  16545. }
  16546. }
  16547. }
  16548. class StrikeOutAnnotation extends MarkupAnnotation {
  16549. constructor(parameters) {
  16550. super(parameters);
  16551. this.data.annotationType = _util.AnnotationType.STRIKEOUT;
  16552. const quadPoints = getQuadPoints(parameters.dict, this.rectangle);
  16553. if (quadPoints) {
  16554. this.data.quadPoints = quadPoints;
  16555. }
  16556. }
  16557. }
  16558. class StampAnnotation extends MarkupAnnotation {
  16559. constructor(parameters) {
  16560. super(parameters);
  16561. this.data.annotationType = _util.AnnotationType.STAMP;
  16562. }
  16563. }
  16564. class FileAttachmentAnnotation extends MarkupAnnotation {
  16565. constructor(parameters) {
  16566. super(parameters);
  16567. const file = new _obj.FileSpec(parameters.dict.get("FS"), parameters.xref);
  16568. this.data.annotationType = _util.AnnotationType.FILEATTACHMENT;
  16569. this.data.file = file.serializable;
  16570. }
  16571. }
  16572. /***/ }),
  16573. /* 26 */
  16574. /***/ (function(module, exports, __w_pdfjs_require__) {
  16575. "use strict";
  16576. Object.defineProperty(exports, "__esModule", {
  16577. value: true
  16578. });
  16579. exports.OperatorList = void 0;
  16580. var _util = __w_pdfjs_require__(2);
  16581. var QueueOptimizer = function QueueOptimizerClosure() {
  16582. function addState(parentState, pattern, checkFn, iterateFn, processFn) {
  16583. var state = parentState;
  16584. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  16585. var item = pattern[i];
  16586. state = state[item] || (state[item] = []);
  16587. }
  16588. state[pattern[pattern.length - 1]] = {
  16589. checkFn,
  16590. iterateFn,
  16591. processFn
  16592. };
  16593. }
  16594. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  16595. var iFirstPIMXO = iFirstSave + 2;
  16596. for (var i = 0; i < count; i++) {
  16597. var arg = argsArray[iFirstPIMXO + 4 * i];
  16598. var imageMask = arg.length === 1 && arg[0];
  16599. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  16600. fnArray[iFirstPIMXO + 4 * i] = _util.OPS.paintSolidColorImageMask;
  16601. continue;
  16602. }
  16603. break;
  16604. }
  16605. return count - i;
  16606. }
  16607. var InitialState = [];
  16608. addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintInlineImageXObject, _util.OPS.restore], null, function iterateInlineImageGroup(context, i) {
  16609. var fnArray = context.fnArray;
  16610. var iFirstSave = context.iCurr - 3;
  16611. var pos = (i - iFirstSave) % 4;
  16612. switch (pos) {
  16613. case 0:
  16614. return fnArray[i] === _util.OPS.save;
  16615. case 1:
  16616. return fnArray[i] === _util.OPS.transform;
  16617. case 2:
  16618. return fnArray[i] === _util.OPS.paintInlineImageXObject;
  16619. case 3:
  16620. return fnArray[i] === _util.OPS.restore;
  16621. }
  16622. throw new Error(`iterateInlineImageGroup - invalid pos: ${pos}`);
  16623. }, function foundInlineImageGroup(context, i) {
  16624. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  16625. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  16626. var MAX_WIDTH = 1000;
  16627. var IMAGE_PADDING = 1;
  16628. var fnArray = context.fnArray,
  16629. argsArray = context.argsArray;
  16630. var curr = context.iCurr;
  16631. var iFirstSave = curr - 3;
  16632. var iFirstTransform = curr - 2;
  16633. var iFirstPIIXO = curr - 1;
  16634. var count = Math.min(Math.floor((i - iFirstSave) / 4), MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  16635. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  16636. return i - (i - iFirstSave) % 4;
  16637. }
  16638. var maxX = 0;
  16639. var map = [],
  16640. maxLineHeight = 0;
  16641. var currentX = IMAGE_PADDING,
  16642. currentY = IMAGE_PADDING;
  16643. var q;
  16644. for (q = 0; q < count; q++) {
  16645. var transform = argsArray[iFirstTransform + (q << 2)];
  16646. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  16647. if (currentX + img.width > MAX_WIDTH) {
  16648. maxX = Math.max(maxX, currentX);
  16649. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  16650. currentX = 0;
  16651. maxLineHeight = 0;
  16652. }
  16653. map.push({
  16654. transform,
  16655. x: currentX,
  16656. y: currentY,
  16657. w: img.width,
  16658. h: img.height
  16659. });
  16660. currentX += img.width + 2 * IMAGE_PADDING;
  16661. maxLineHeight = Math.max(maxLineHeight, img.height);
  16662. }
  16663. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  16664. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  16665. var imgData = new Uint8ClampedArray(imgWidth * imgHeight * 4);
  16666. var imgRowSize = imgWidth << 2;
  16667. for (q = 0; q < count; q++) {
  16668. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  16669. var rowSize = map[q].w << 2;
  16670. var dataOffset = 0;
  16671. var offset = map[q].x + map[q].y * imgWidth << 2;
  16672. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  16673. for (var k = 0, kk = map[q].h; k < kk; k++) {
  16674. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  16675. dataOffset += rowSize;
  16676. offset += imgRowSize;
  16677. }
  16678. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  16679. while (offset >= 0) {
  16680. data[offset - 4] = data[offset];
  16681. data[offset - 3] = data[offset + 1];
  16682. data[offset - 2] = data[offset + 2];
  16683. data[offset - 1] = data[offset + 3];
  16684. data[offset + rowSize] = data[offset + rowSize - 4];
  16685. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  16686. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  16687. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  16688. offset -= imgRowSize;
  16689. }
  16690. }
  16691. fnArray.splice(iFirstSave, count * 4, _util.OPS.paintInlineImageXObjectGroup);
  16692. argsArray.splice(iFirstSave, count * 4, [{
  16693. width: imgWidth,
  16694. height: imgHeight,
  16695. kind: _util.ImageKind.RGBA_32BPP,
  16696. data: imgData
  16697. }, map]);
  16698. return iFirstSave + 1;
  16699. });
  16700. addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintImageMaskXObject, _util.OPS.restore], null, function iterateImageMaskGroup(context, i) {
  16701. var fnArray = context.fnArray;
  16702. var iFirstSave = context.iCurr - 3;
  16703. var pos = (i - iFirstSave) % 4;
  16704. switch (pos) {
  16705. case 0:
  16706. return fnArray[i] === _util.OPS.save;
  16707. case 1:
  16708. return fnArray[i] === _util.OPS.transform;
  16709. case 2:
  16710. return fnArray[i] === _util.OPS.paintImageMaskXObject;
  16711. case 3:
  16712. return fnArray[i] === _util.OPS.restore;
  16713. }
  16714. throw new Error(`iterateImageMaskGroup - invalid pos: ${pos}`);
  16715. }, function foundImageMaskGroup(context, i) {
  16716. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  16717. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  16718. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  16719. var fnArray = context.fnArray,
  16720. argsArray = context.argsArray;
  16721. var curr = context.iCurr;
  16722. var iFirstSave = curr - 3;
  16723. var iFirstTransform = curr - 2;
  16724. var iFirstPIMXO = curr - 1;
  16725. var count = Math.floor((i - iFirstSave) / 4);
  16726. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  16727. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  16728. return i - (i - iFirstSave) % 4;
  16729. }
  16730. var q;
  16731. var isSameImage = false;
  16732. var iTransform, transformArgs;
  16733. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  16734. const firstTransformArg0 = argsArray[iFirstTransform][0],
  16735. firstTransformArg1 = argsArray[iFirstTransform][1],
  16736. firstTransformArg2 = argsArray[iFirstTransform][2],
  16737. firstTransformArg3 = argsArray[iFirstTransform][3];
  16738. if (firstTransformArg1 === firstTransformArg2) {
  16739. isSameImage = true;
  16740. iTransform = iFirstTransform + 4;
  16741. var iPIMXO = iFirstPIMXO + 4;
  16742. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  16743. transformArgs = argsArray[iTransform];
  16744. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== firstTransformArg1 || transformArgs[2] !== firstTransformArg2 || transformArgs[3] !== firstTransformArg3) {
  16745. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  16746. isSameImage = false;
  16747. } else {
  16748. count = q;
  16749. }
  16750. break;
  16751. }
  16752. }
  16753. }
  16754. if (isSameImage) {
  16755. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  16756. var positions = new Float32Array(count * 2);
  16757. iTransform = iFirstTransform;
  16758. for (q = 0; q < count; q++, iTransform += 4) {
  16759. transformArgs = argsArray[iTransform];
  16760. positions[q << 1] = transformArgs[4];
  16761. positions[(q << 1) + 1] = transformArgs[5];
  16762. }
  16763. fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageMaskXObjectRepeat);
  16764. argsArray.splice(iFirstSave, count * 4, [firstPIMXOArg0, firstTransformArg0, firstTransformArg1, firstTransformArg2, firstTransformArg3, positions]);
  16765. } else {
  16766. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  16767. var images = [];
  16768. for (q = 0; q < count; q++) {
  16769. transformArgs = argsArray[iFirstTransform + (q << 2)];
  16770. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  16771. images.push({
  16772. data: maskParams.data,
  16773. width: maskParams.width,
  16774. height: maskParams.height,
  16775. transform: transformArgs
  16776. });
  16777. }
  16778. fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageMaskXObjectGroup);
  16779. argsArray.splice(iFirstSave, count * 4, [images]);
  16780. }
  16781. return iFirstSave + 1;
  16782. });
  16783. addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintImageXObject, _util.OPS.restore], function (context) {
  16784. var argsArray = context.argsArray;
  16785. var iFirstTransform = context.iCurr - 2;
  16786. return argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0;
  16787. }, function iterateImageGroup(context, i) {
  16788. var fnArray = context.fnArray,
  16789. argsArray = context.argsArray;
  16790. var iFirstSave = context.iCurr - 3;
  16791. var pos = (i - iFirstSave) % 4;
  16792. switch (pos) {
  16793. case 0:
  16794. return fnArray[i] === _util.OPS.save;
  16795. case 1:
  16796. if (fnArray[i] !== _util.OPS.transform) {
  16797. return false;
  16798. }
  16799. var iFirstTransform = context.iCurr - 2;
  16800. var firstTransformArg0 = argsArray[iFirstTransform][0];
  16801. var firstTransformArg3 = argsArray[iFirstTransform][3];
  16802. if (argsArray[i][0] !== firstTransformArg0 || argsArray[i][1] !== 0 || argsArray[i][2] !== 0 || argsArray[i][3] !== firstTransformArg3) {
  16803. return false;
  16804. }
  16805. return true;
  16806. case 2:
  16807. if (fnArray[i] !== _util.OPS.paintImageXObject) {
  16808. return false;
  16809. }
  16810. var iFirstPIXO = context.iCurr - 1;
  16811. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  16812. if (argsArray[i][0] !== firstPIXOArg0) {
  16813. return false;
  16814. }
  16815. return true;
  16816. case 3:
  16817. return fnArray[i] === _util.OPS.restore;
  16818. }
  16819. throw new Error(`iterateImageGroup - invalid pos: ${pos}`);
  16820. }, function (context, i) {
  16821. var MIN_IMAGES_IN_BLOCK = 3;
  16822. var MAX_IMAGES_IN_BLOCK = 1000;
  16823. var fnArray = context.fnArray,
  16824. argsArray = context.argsArray;
  16825. var curr = context.iCurr;
  16826. var iFirstSave = curr - 3;
  16827. var iFirstTransform = curr - 2;
  16828. var iFirstPIXO = curr - 1;
  16829. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  16830. var firstTransformArg0 = argsArray[iFirstTransform][0];
  16831. var firstTransformArg3 = argsArray[iFirstTransform][3];
  16832. var count = Math.min(Math.floor((i - iFirstSave) / 4), MAX_IMAGES_IN_BLOCK);
  16833. if (count < MIN_IMAGES_IN_BLOCK) {
  16834. return i - (i - iFirstSave) % 4;
  16835. }
  16836. var positions = new Float32Array(count * 2);
  16837. var iTransform = iFirstTransform;
  16838. for (var q = 0; q < count; q++, iTransform += 4) {
  16839. var transformArgs = argsArray[iTransform];
  16840. positions[q << 1] = transformArgs[4];
  16841. positions[(q << 1) + 1] = transformArgs[5];
  16842. }
  16843. var args = [firstPIXOArg0, firstTransformArg0, firstTransformArg3, positions];
  16844. fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageXObjectRepeat);
  16845. argsArray.splice(iFirstSave, count * 4, args);
  16846. return iFirstSave + 1;
  16847. });
  16848. addState(InitialState, [_util.OPS.beginText, _util.OPS.setFont, _util.OPS.setTextMatrix, _util.OPS.showText, _util.OPS.endText], null, function iterateShowTextGroup(context, i) {
  16849. var fnArray = context.fnArray,
  16850. argsArray = context.argsArray;
  16851. var iFirstSave = context.iCurr - 4;
  16852. var pos = (i - iFirstSave) % 5;
  16853. switch (pos) {
  16854. case 0:
  16855. return fnArray[i] === _util.OPS.beginText;
  16856. case 1:
  16857. return fnArray[i] === _util.OPS.setFont;
  16858. case 2:
  16859. return fnArray[i] === _util.OPS.setTextMatrix;
  16860. case 3:
  16861. if (fnArray[i] !== _util.OPS.showText) {
  16862. return false;
  16863. }
  16864. var iFirstSetFont = context.iCurr - 3;
  16865. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  16866. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  16867. if (argsArray[i][0] !== firstSetFontArg0 || argsArray[i][1] !== firstSetFontArg1) {
  16868. return false;
  16869. }
  16870. return true;
  16871. case 4:
  16872. return fnArray[i] === _util.OPS.endText;
  16873. }
  16874. throw new Error(`iterateShowTextGroup - invalid pos: ${pos}`);
  16875. }, function (context, i) {
  16876. var MIN_CHARS_IN_BLOCK = 3;
  16877. var MAX_CHARS_IN_BLOCK = 1000;
  16878. var fnArray = context.fnArray,
  16879. argsArray = context.argsArray;
  16880. var curr = context.iCurr;
  16881. var iFirstBeginText = curr - 4;
  16882. var iFirstSetFont = curr - 3;
  16883. var iFirstSetTextMatrix = curr - 2;
  16884. var iFirstShowText = curr - 1;
  16885. var iFirstEndText = curr;
  16886. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  16887. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  16888. var count = Math.min(Math.floor((i - iFirstBeginText) / 5), MAX_CHARS_IN_BLOCK);
  16889. if (count < MIN_CHARS_IN_BLOCK) {
  16890. return i - (i - iFirstBeginText) % 5;
  16891. }
  16892. var iFirst = iFirstBeginText;
  16893. if (iFirstBeginText >= 4 && fnArray[iFirstBeginText - 4] === fnArray[iFirstSetFont] && fnArray[iFirstBeginText - 3] === fnArray[iFirstSetTextMatrix] && fnArray[iFirstBeginText - 2] === fnArray[iFirstShowText] && fnArray[iFirstBeginText - 1] === fnArray[iFirstEndText] && argsArray[iFirstBeginText - 4][0] === firstSetFontArg0 && argsArray[iFirstBeginText - 4][1] === firstSetFontArg1) {
  16894. count++;
  16895. iFirst -= 5;
  16896. }
  16897. var iEndText = iFirst + 4;
  16898. for (var q = 1; q < count; q++) {
  16899. fnArray.splice(iEndText, 3);
  16900. argsArray.splice(iEndText, 3);
  16901. iEndText += 2;
  16902. }
  16903. return iEndText + 1;
  16904. });
  16905. function QueueOptimizer(queue) {
  16906. this.queue = queue;
  16907. this.state = null;
  16908. this.context = {
  16909. iCurr: 0,
  16910. fnArray: queue.fnArray,
  16911. argsArray: queue.argsArray
  16912. };
  16913. this.match = null;
  16914. this.lastProcessed = 0;
  16915. }
  16916. QueueOptimizer.prototype = {
  16917. _optimize() {
  16918. const fnArray = this.queue.fnArray;
  16919. let i = this.lastProcessed,
  16920. ii = fnArray.length;
  16921. let state = this.state;
  16922. let match = this.match;
  16923. if (!state && !match && i + 1 === ii && !InitialState[fnArray[i]]) {
  16924. this.lastProcessed = ii;
  16925. return;
  16926. }
  16927. const context = this.context;
  16928. while (i < ii) {
  16929. if (match) {
  16930. const iterate = (0, match.iterateFn)(context, i);
  16931. if (iterate) {
  16932. i++;
  16933. continue;
  16934. }
  16935. i = (0, match.processFn)(context, i + 1);
  16936. ii = fnArray.length;
  16937. match = null;
  16938. state = null;
  16939. if (i >= ii) {
  16940. break;
  16941. }
  16942. }
  16943. state = (state || InitialState)[fnArray[i]];
  16944. if (!state || Array.isArray(state)) {
  16945. i++;
  16946. continue;
  16947. }
  16948. context.iCurr = i;
  16949. i++;
  16950. if (state.checkFn && !(0, state.checkFn)(context)) {
  16951. state = null;
  16952. continue;
  16953. }
  16954. match = state;
  16955. state = null;
  16956. }
  16957. this.state = state;
  16958. this.match = match;
  16959. this.lastProcessed = i;
  16960. },
  16961. push(fn, args) {
  16962. this.queue.fnArray.push(fn);
  16963. this.queue.argsArray.push(args);
  16964. this._optimize();
  16965. },
  16966. flush() {
  16967. while (this.match) {
  16968. const length = this.queue.fnArray.length;
  16969. this.lastProcessed = (0, this.match.processFn)(this.context, length);
  16970. this.match = null;
  16971. this.state = null;
  16972. this._optimize();
  16973. }
  16974. },
  16975. reset() {
  16976. this.state = null;
  16977. this.match = null;
  16978. this.lastProcessed = 0;
  16979. }
  16980. };
  16981. return QueueOptimizer;
  16982. }();
  16983. var NullOptimizer = function NullOptimizerClosure() {
  16984. function NullOptimizer(queue) {
  16985. this.queue = queue;
  16986. }
  16987. NullOptimizer.prototype = {
  16988. push(fn, args) {
  16989. this.queue.fnArray.push(fn);
  16990. this.queue.argsArray.push(args);
  16991. },
  16992. flush() {},
  16993. reset() {}
  16994. };
  16995. return NullOptimizer;
  16996. }();
  16997. var OperatorList = function OperatorListClosure() {
  16998. var CHUNK_SIZE = 1000;
  16999. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  17000. function OperatorList(intent, streamSink) {
  17001. this._streamSink = streamSink;
  17002. this.fnArray = [];
  17003. this.argsArray = [];
  17004. if (streamSink && intent !== "oplist") {
  17005. this.optimizer = new QueueOptimizer(this);
  17006. } else {
  17007. this.optimizer = new NullOptimizer(this);
  17008. }
  17009. this.dependencies = new Set();
  17010. this._totalLength = 0;
  17011. this.weight = 0;
  17012. this._resolved = streamSink ? null : Promise.resolve();
  17013. }
  17014. OperatorList.prototype = {
  17015. get length() {
  17016. return this.argsArray.length;
  17017. },
  17018. get ready() {
  17019. return this._resolved || this._streamSink.ready;
  17020. },
  17021. get totalLength() {
  17022. return this._totalLength + this.length;
  17023. },
  17024. addOp(fn, args) {
  17025. this.optimizer.push(fn, args);
  17026. this.weight++;
  17027. if (this._streamSink) {
  17028. if (this.weight >= CHUNK_SIZE) {
  17029. this.flush();
  17030. } else if (this.weight >= CHUNK_SIZE_ABOUT && (fn === _util.OPS.restore || fn === _util.OPS.endText)) {
  17031. this.flush();
  17032. }
  17033. }
  17034. },
  17035. addDependency(dependency) {
  17036. if (this.dependencies.has(dependency)) {
  17037. return;
  17038. }
  17039. this.dependencies.add(dependency);
  17040. this.addOp(_util.OPS.dependency, [dependency]);
  17041. },
  17042. addDependencies(dependencies) {
  17043. for (const dependency of dependencies) {
  17044. this.addDependency(dependency);
  17045. }
  17046. },
  17047. addOpList(opList) {
  17048. if (!(opList instanceof OperatorList)) {
  17049. (0, _util.warn)('addOpList - ignoring invalid "opList" parameter.');
  17050. return;
  17051. }
  17052. for (const dependency of opList.dependencies) {
  17053. this.dependencies.add(dependency);
  17054. }
  17055. for (var i = 0, ii = opList.length; i < ii; i++) {
  17056. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  17057. }
  17058. },
  17059. getIR() {
  17060. return {
  17061. fnArray: this.fnArray,
  17062. argsArray: this.argsArray,
  17063. length: this.length
  17064. };
  17065. },
  17066. get _transfers() {
  17067. const transfers = [];
  17068. const {
  17069. fnArray,
  17070. argsArray,
  17071. length
  17072. } = this;
  17073. for (let i = 0; i < length; i++) {
  17074. switch (fnArray[i]) {
  17075. case _util.OPS.paintInlineImageXObject:
  17076. case _util.OPS.paintInlineImageXObjectGroup:
  17077. case _util.OPS.paintImageMaskXObject:
  17078. const arg = argsArray[i][0];
  17079. ;
  17080. if (!arg.cached) {
  17081. transfers.push(arg.data.buffer);
  17082. }
  17083. break;
  17084. }
  17085. }
  17086. return transfers;
  17087. },
  17088. flush(lastChunk = false) {
  17089. this.optimizer.flush();
  17090. const length = this.length;
  17091. this._totalLength += length;
  17092. this._streamSink.enqueue({
  17093. fnArray: this.fnArray,
  17094. argsArray: this.argsArray,
  17095. lastChunk,
  17096. length
  17097. }, 1, this._transfers);
  17098. this.dependencies.clear();
  17099. this.fnArray.length = 0;
  17100. this.argsArray.length = 0;
  17101. this.weight = 0;
  17102. this.optimizer.reset();
  17103. }
  17104. };
  17105. return OperatorList;
  17106. }();
  17107. exports.OperatorList = OperatorList;
  17108. /***/ }),
  17109. /* 27 */
  17110. /***/ (function(module, exports, __w_pdfjs_require__) {
  17111. "use strict";
  17112. Object.defineProperty(exports, "__esModule", {
  17113. value: true
  17114. });
  17115. exports.writeDict = writeDict;
  17116. exports.incrementalUpdate = incrementalUpdate;
  17117. var _util = __w_pdfjs_require__(2);
  17118. var _primitives = __w_pdfjs_require__(5);
  17119. var _crypto = __w_pdfjs_require__(22);
  17120. function writeDict(dict, buffer, transform) {
  17121. buffer.push("<<");
  17122. for (const key of dict.getKeys()) {
  17123. buffer.push(` /${key} `);
  17124. writeValue(dict.getRaw(key), buffer, transform);
  17125. }
  17126. buffer.push(">>");
  17127. }
  17128. function writeStream(stream, buffer, transform) {
  17129. writeDict(stream.dict, buffer, transform);
  17130. buffer.push(" stream\n");
  17131. let string = (0, _util.bytesToString)(stream.getBytes());
  17132. if (transform !== null) {
  17133. string = transform.encryptString(string);
  17134. }
  17135. buffer.push(string);
  17136. buffer.push("\nendstream\n");
  17137. }
  17138. function writeArray(array, buffer, transform) {
  17139. buffer.push("[");
  17140. let first = true;
  17141. for (const val of array) {
  17142. if (!first) {
  17143. buffer.push(" ");
  17144. } else {
  17145. first = false;
  17146. }
  17147. writeValue(val, buffer, transform);
  17148. }
  17149. buffer.push("]");
  17150. }
  17151. function numberToString(value) {
  17152. if (Number.isInteger(value)) {
  17153. return value.toString();
  17154. }
  17155. const roundedValue = Math.round(value * 100);
  17156. if (roundedValue % 100 === 0) {
  17157. return (roundedValue / 100).toString();
  17158. }
  17159. if (roundedValue % 10 === 0) {
  17160. return value.toFixed(1);
  17161. }
  17162. return value.toFixed(2);
  17163. }
  17164. function writeValue(value, buffer, transform) {
  17165. if ((0, _primitives.isName)(value)) {
  17166. buffer.push(`/${value.name}`);
  17167. } else if ((0, _primitives.isRef)(value)) {
  17168. buffer.push(`${value.num} ${value.gen} R`);
  17169. } else if (Array.isArray(value)) {
  17170. writeArray(value, buffer, transform);
  17171. } else if (typeof value === "string") {
  17172. if (transform !== null) {
  17173. value = transform.encryptString(value);
  17174. }
  17175. buffer.push(`(${(0, _util.escapeString)(value)})`);
  17176. } else if (typeof value === "number") {
  17177. buffer.push(numberToString(value));
  17178. } else if ((0, _primitives.isDict)(value)) {
  17179. writeDict(value, buffer, transform);
  17180. } else if ((0, _primitives.isStream)(value)) {
  17181. writeStream(value, buffer, transform);
  17182. }
  17183. }
  17184. function writeInt(number, size, offset, buffer) {
  17185. for (let i = size + offset - 1; i > offset - 1; i--) {
  17186. buffer[i] = number & 0xff;
  17187. number >>= 8;
  17188. }
  17189. return offset + size;
  17190. }
  17191. function writeString(string, offset, buffer) {
  17192. for (let i = 0, len = string.length; i < len; i++) {
  17193. buffer[offset + i] = string.charCodeAt(i) & 0xff;
  17194. }
  17195. }
  17196. function computeMD5(filesize, xrefInfo) {
  17197. const time = Math.floor(Date.now() / 1000);
  17198. const filename = xrefInfo.filename || "";
  17199. const md5Buffer = [time.toString(), filename, filesize.toString()];
  17200. let md5BufferLen = md5Buffer.reduce((a, str) => a + str.length, 0);
  17201. for (const value of Object.values(xrefInfo.info)) {
  17202. md5Buffer.push(value);
  17203. md5BufferLen += value.length;
  17204. }
  17205. const array = new Uint8Array(md5BufferLen);
  17206. let offset = 0;
  17207. for (const str of md5Buffer) {
  17208. writeString(str, offset, array);
  17209. offset += str.length;
  17210. }
  17211. return (0, _util.bytesToString)((0, _crypto.calculateMD5)(array));
  17212. }
  17213. function incrementalUpdate(originalData, xrefInfo, newRefs) {
  17214. const newXref = new _primitives.Dict(null);
  17215. const refForXrefTable = xrefInfo.newRef;
  17216. let buffer, baseOffset;
  17217. const lastByte = originalData[originalData.length - 1];
  17218. if (lastByte === 0x0a || lastByte === 0x0d) {
  17219. buffer = [];
  17220. baseOffset = originalData.length;
  17221. } else {
  17222. buffer = ["\n"];
  17223. baseOffset = originalData.length + 1;
  17224. }
  17225. newXref.set("Size", refForXrefTable.num + 1);
  17226. newXref.set("Prev", xrefInfo.startXRef);
  17227. newXref.set("Type", _primitives.Name.get("XRef"));
  17228. if (xrefInfo.rootRef !== null) {
  17229. newXref.set("Root", xrefInfo.rootRef);
  17230. }
  17231. if (xrefInfo.infoRef !== null) {
  17232. newXref.set("Info", xrefInfo.infoRef);
  17233. }
  17234. if (xrefInfo.encrypt !== null) {
  17235. newXref.set("Encrypt", xrefInfo.encrypt);
  17236. }
  17237. newRefs.push({
  17238. ref: refForXrefTable,
  17239. data: ""
  17240. });
  17241. newRefs = newRefs.sort((a, b) => {
  17242. return a.ref.num - b.ref.num;
  17243. });
  17244. const xrefTableData = [[0, 1, 0xffff]];
  17245. const indexes = [0, 1];
  17246. let maxOffset = 0;
  17247. for (const {
  17248. ref,
  17249. data
  17250. } of newRefs) {
  17251. maxOffset = Math.max(maxOffset, baseOffset);
  17252. xrefTableData.push([1, baseOffset, Math.min(ref.gen, 0xffff)]);
  17253. baseOffset += data.length;
  17254. indexes.push(ref.num);
  17255. indexes.push(1);
  17256. buffer.push(data);
  17257. }
  17258. newXref.set("Index", indexes);
  17259. if (xrefInfo.fileIds.length !== 0) {
  17260. const md5 = computeMD5(baseOffset, xrefInfo);
  17261. newXref.set("ID", [xrefInfo.fileIds[0], md5]);
  17262. }
  17263. const offsetSize = Math.ceil(Math.log2(maxOffset) / 8);
  17264. const sizes = [1, offsetSize, 2];
  17265. const structSize = sizes[0] + sizes[1] + sizes[2];
  17266. const tableLength = structSize * xrefTableData.length;
  17267. newXref.set("W", sizes);
  17268. newXref.set("Length", tableLength);
  17269. buffer.push(`${refForXrefTable.num} ${refForXrefTable.gen} obj\n`);
  17270. writeDict(newXref, buffer, null);
  17271. buffer.push(" stream\n");
  17272. const bufferLen = buffer.reduce((a, str) => a + str.length, 0);
  17273. const footer = `\nendstream\nendobj\nstartxref\n${baseOffset}\n%%EOF\n`;
  17274. const array = new Uint8Array(originalData.length + bufferLen + tableLength + footer.length);
  17275. array.set(originalData);
  17276. let offset = originalData.length;
  17277. for (const str of buffer) {
  17278. writeString(str, offset, array);
  17279. offset += str.length;
  17280. }
  17281. for (const [type, objOffset, gen] of xrefTableData) {
  17282. offset = writeInt(type, sizes[0], offset, array);
  17283. offset = writeInt(objOffset, sizes[1], offset, array);
  17284. offset = writeInt(gen, sizes[2], offset, array);
  17285. }
  17286. writeString(footer, offset, array);
  17287. return array;
  17288. }
  17289. /***/ }),
  17290. /* 28 */
  17291. /***/ (function(module, exports, __w_pdfjs_require__) {
  17292. "use strict";
  17293. Object.defineProperty(exports, "__esModule", {
  17294. value: true
  17295. });
  17296. exports.PartialEvaluator = void 0;
  17297. var _util = __w_pdfjs_require__(2);
  17298. var _cmap = __w_pdfjs_require__(29);
  17299. var _primitives = __w_pdfjs_require__(5);
  17300. var _fonts = __w_pdfjs_require__(30);
  17301. var _encodings = __w_pdfjs_require__(33);
  17302. var _core_utils = __w_pdfjs_require__(8);
  17303. var _unicode = __w_pdfjs_require__(36);
  17304. var _standard_fonts = __w_pdfjs_require__(35);
  17305. var _pattern = __w_pdfjs_require__(39);
  17306. var _function = __w_pdfjs_require__(40);
  17307. var _parser = __w_pdfjs_require__(11);
  17308. var _image_utils = __w_pdfjs_require__(24);
  17309. var _bidi = __w_pdfjs_require__(42);
  17310. var _colorspace = __w_pdfjs_require__(23);
  17311. var _stream = __w_pdfjs_require__(12);
  17312. var _glyphlist = __w_pdfjs_require__(34);
  17313. var _metrics = __w_pdfjs_require__(43);
  17314. var _murmurhash = __w_pdfjs_require__(44);
  17315. var _operator_list = __w_pdfjs_require__(26);
  17316. var _image = __w_pdfjs_require__(45);
  17317. const DefaultPartialEvaluatorOptions = Object.freeze({
  17318. maxImageSize: -1,
  17319. disableFontFace: false,
  17320. ignoreErrors: false,
  17321. isEvalSupported: true,
  17322. fontExtraProperties: false
  17323. });
  17324. const PatternType = {
  17325. TILING: 1,
  17326. SHADING: 2
  17327. };
  17328. const deferred = Promise.resolve();
  17329. function normalizeBlendMode(value, parsingArray = false) {
  17330. if (Array.isArray(value)) {
  17331. for (let i = 0, ii = value.length; i < ii; i++) {
  17332. const maybeBM = normalizeBlendMode(value[i], true);
  17333. if (maybeBM) {
  17334. return maybeBM;
  17335. }
  17336. }
  17337. (0, _util.warn)(`Unsupported blend mode Array: ${value}`);
  17338. return "source-over";
  17339. }
  17340. if (!(0, _primitives.isName)(value)) {
  17341. if (parsingArray) {
  17342. return null;
  17343. }
  17344. return "source-over";
  17345. }
  17346. switch (value.name) {
  17347. case "Normal":
  17348. case "Compatible":
  17349. return "source-over";
  17350. case "Multiply":
  17351. return "multiply";
  17352. case "Screen":
  17353. return "screen";
  17354. case "Overlay":
  17355. return "overlay";
  17356. case "Darken":
  17357. return "darken";
  17358. case "Lighten":
  17359. return "lighten";
  17360. case "ColorDodge":
  17361. return "color-dodge";
  17362. case "ColorBurn":
  17363. return "color-burn";
  17364. case "HardLight":
  17365. return "hard-light";
  17366. case "SoftLight":
  17367. return "soft-light";
  17368. case "Difference":
  17369. return "difference";
  17370. case "Exclusion":
  17371. return "exclusion";
  17372. case "Hue":
  17373. return "hue";
  17374. case "Saturation":
  17375. return "saturation";
  17376. case "Color":
  17377. return "color";
  17378. case "Luminosity":
  17379. return "luminosity";
  17380. }
  17381. if (parsingArray) {
  17382. return null;
  17383. }
  17384. (0, _util.warn)(`Unsupported blend mode: ${value.name}`);
  17385. return "source-over";
  17386. }
  17387. class TimeSlotManager {
  17388. static get TIME_SLOT_DURATION_MS() {
  17389. return (0, _util.shadow)(this, "TIME_SLOT_DURATION_MS", 20);
  17390. }
  17391. static get CHECK_TIME_EVERY() {
  17392. return (0, _util.shadow)(this, "CHECK_TIME_EVERY", 100);
  17393. }
  17394. constructor() {
  17395. this.reset();
  17396. }
  17397. check() {
  17398. if (++this.checked < TimeSlotManager.CHECK_TIME_EVERY) {
  17399. return false;
  17400. }
  17401. this.checked = 0;
  17402. return this.endTime <= Date.now();
  17403. }
  17404. reset() {
  17405. this.endTime = Date.now() + TimeSlotManager.TIME_SLOT_DURATION_MS;
  17406. this.checked = 0;
  17407. }
  17408. }
  17409. class PartialEvaluator {
  17410. constructor({
  17411. xref,
  17412. handler,
  17413. pageIndex,
  17414. idFactory,
  17415. fontCache,
  17416. builtInCMapCache,
  17417. globalImageCache,
  17418. options = null
  17419. }) {
  17420. this.xref = xref;
  17421. this.handler = handler;
  17422. this.pageIndex = pageIndex;
  17423. this.idFactory = idFactory;
  17424. this.fontCache = fontCache;
  17425. this.builtInCMapCache = builtInCMapCache;
  17426. this.globalImageCache = globalImageCache;
  17427. this.options = options || DefaultPartialEvaluatorOptions;
  17428. this.parsingType3Font = false;
  17429. this._fetchBuiltInCMapBound = this.fetchBuiltInCMap.bind(this);
  17430. }
  17431. get _pdfFunctionFactory() {
  17432. const pdfFunctionFactory = new _function.PDFFunctionFactory({
  17433. xref: this.xref,
  17434. isEvalSupported: this.options.isEvalSupported
  17435. });
  17436. return (0, _util.shadow)(this, "_pdfFunctionFactory", pdfFunctionFactory);
  17437. }
  17438. clone(newOptions = DefaultPartialEvaluatorOptions) {
  17439. var newEvaluator = Object.create(this);
  17440. newEvaluator.options = newOptions;
  17441. return newEvaluator;
  17442. }
  17443. hasBlendModes(resources) {
  17444. if (!(resources instanceof _primitives.Dict)) {
  17445. return false;
  17446. }
  17447. const processed = new _primitives.RefSet();
  17448. if (resources.objId) {
  17449. processed.put(resources.objId);
  17450. }
  17451. var nodes = [resources],
  17452. xref = this.xref;
  17453. while (nodes.length) {
  17454. var node = nodes.shift();
  17455. var graphicStates = node.get("ExtGState");
  17456. if (graphicStates instanceof _primitives.Dict) {
  17457. for (let graphicState of graphicStates.getRawValues()) {
  17458. if (graphicState instanceof _primitives.Ref) {
  17459. if (processed.has(graphicState)) {
  17460. continue;
  17461. }
  17462. try {
  17463. graphicState = xref.fetch(graphicState);
  17464. } catch (ex) {
  17465. if (ex instanceof _core_utils.MissingDataException) {
  17466. throw ex;
  17467. }
  17468. processed.put(graphicState);
  17469. (0, _util.info)(`hasBlendModes - ignoring ExtGState: "${ex}".`);
  17470. continue;
  17471. }
  17472. }
  17473. if (!(graphicState instanceof _primitives.Dict)) {
  17474. continue;
  17475. }
  17476. if (graphicState.objId) {
  17477. processed.put(graphicState.objId);
  17478. }
  17479. const bm = graphicState.get("BM");
  17480. if (bm instanceof _primitives.Name) {
  17481. if (bm.name !== "Normal") {
  17482. return true;
  17483. }
  17484. continue;
  17485. }
  17486. if (bm !== undefined && Array.isArray(bm)) {
  17487. for (const element of bm) {
  17488. if (element instanceof _primitives.Name && element.name !== "Normal") {
  17489. return true;
  17490. }
  17491. }
  17492. }
  17493. }
  17494. }
  17495. var xObjects = node.get("XObject");
  17496. if (!(xObjects instanceof _primitives.Dict)) {
  17497. continue;
  17498. }
  17499. for (let xObject of xObjects.getRawValues()) {
  17500. if (xObject instanceof _primitives.Ref) {
  17501. if (processed.has(xObject)) {
  17502. continue;
  17503. }
  17504. try {
  17505. xObject = xref.fetch(xObject);
  17506. } catch (ex) {
  17507. if (ex instanceof _core_utils.MissingDataException) {
  17508. throw ex;
  17509. }
  17510. processed.put(xObject);
  17511. (0, _util.info)(`hasBlendModes - ignoring XObject: "${ex}".`);
  17512. continue;
  17513. }
  17514. }
  17515. if (!(0, _primitives.isStream)(xObject)) {
  17516. continue;
  17517. }
  17518. if (xObject.dict.objId) {
  17519. processed.put(xObject.dict.objId);
  17520. }
  17521. var xResources = xObject.dict.get("Resources");
  17522. if (!(xResources instanceof _primitives.Dict)) {
  17523. continue;
  17524. }
  17525. if (xResources.objId && processed.has(xResources.objId)) {
  17526. continue;
  17527. }
  17528. nodes.push(xResources);
  17529. if (xResources.objId) {
  17530. processed.put(xResources.objId);
  17531. }
  17532. }
  17533. }
  17534. return false;
  17535. }
  17536. async fetchBuiltInCMap(name) {
  17537. const cachedData = this.builtInCMapCache.get(name);
  17538. if (cachedData) {
  17539. return cachedData;
  17540. }
  17541. const readableStream = this.handler.sendWithStream("FetchBuiltInCMap", {
  17542. name
  17543. });
  17544. const reader = readableStream.getReader();
  17545. const data = await new Promise(function (resolve, reject) {
  17546. function pump() {
  17547. reader.read().then(function ({
  17548. value,
  17549. done
  17550. }) {
  17551. if (done) {
  17552. return;
  17553. }
  17554. resolve(value);
  17555. pump();
  17556. }, reject);
  17557. }
  17558. pump();
  17559. });
  17560. if (data.compressionType !== _util.CMapCompressionType.NONE) {
  17561. this.builtInCMapCache.set(name, data);
  17562. }
  17563. return data;
  17564. }
  17565. async buildFormXObject(resources, xobj, smask, operatorList, task, initialState, localColorSpaceCache) {
  17566. var dict = xobj.dict;
  17567. var matrix = dict.getArray("Matrix");
  17568. var bbox = dict.getArray("BBox");
  17569. if (Array.isArray(bbox) && bbox.length === 4) {
  17570. bbox = _util.Util.normalizeRect(bbox);
  17571. } else {
  17572. bbox = null;
  17573. }
  17574. let optionalContent = null;
  17575. if (dict.has("OC")) {
  17576. optionalContent = await this.parseMarkedContentProps(dict.get("OC"), resources);
  17577. operatorList.addOp(_util.OPS.beginMarkedContentProps, ["OC", optionalContent]);
  17578. }
  17579. var group = dict.get("Group");
  17580. if (group) {
  17581. var groupOptions = {
  17582. matrix,
  17583. bbox,
  17584. smask,
  17585. isolated: false,
  17586. knockout: false
  17587. };
  17588. var groupSubtype = group.get("S");
  17589. var colorSpace = null;
  17590. if ((0, _primitives.isName)(groupSubtype, "Transparency")) {
  17591. groupOptions.isolated = group.get("I") || false;
  17592. groupOptions.knockout = group.get("K") || false;
  17593. if (group.has("CS")) {
  17594. const cs = group.getRaw("CS");
  17595. const cachedColorSpace = _colorspace.ColorSpace.getCached(cs, this.xref, localColorSpaceCache);
  17596. if (cachedColorSpace) {
  17597. colorSpace = cachedColorSpace;
  17598. } else {
  17599. colorSpace = await this.parseColorSpace({
  17600. cs,
  17601. resources,
  17602. localColorSpaceCache
  17603. });
  17604. }
  17605. }
  17606. }
  17607. if (smask && smask.backdrop) {
  17608. colorSpace = colorSpace || _colorspace.ColorSpace.singletons.rgb;
  17609. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  17610. }
  17611. operatorList.addOp(_util.OPS.beginGroup, [groupOptions]);
  17612. }
  17613. operatorList.addOp(_util.OPS.paintFormXObjectBegin, [matrix, bbox]);
  17614. return this.getOperatorList({
  17615. stream: xobj,
  17616. task,
  17617. resources: dict.get("Resources") || resources,
  17618. operatorList,
  17619. initialState
  17620. }).then(function () {
  17621. operatorList.addOp(_util.OPS.paintFormXObjectEnd, []);
  17622. if (group) {
  17623. operatorList.addOp(_util.OPS.endGroup, [groupOptions]);
  17624. }
  17625. if (optionalContent) {
  17626. operatorList.addOp(_util.OPS.endMarkedContent, []);
  17627. }
  17628. });
  17629. }
  17630. _sendImgData(objId, imgData, cacheGlobally = false) {
  17631. const transfers = imgData ? [imgData.data.buffer] : null;
  17632. if (this.parsingType3Font || cacheGlobally) {
  17633. return this.handler.send("commonobj", [objId, "Image", imgData], transfers);
  17634. }
  17635. return this.handler.send("obj", [objId, this.pageIndex, "Image", imgData], transfers);
  17636. }
  17637. async buildPaintImageXObject({
  17638. resources,
  17639. image,
  17640. isInline = false,
  17641. operatorList,
  17642. cacheKey,
  17643. localImageCache,
  17644. localColorSpaceCache
  17645. }) {
  17646. var dict = image.dict;
  17647. const imageRef = dict.objId;
  17648. var w = dict.get("Width", "W");
  17649. var h = dict.get("Height", "H");
  17650. if (!(w && (0, _util.isNum)(w)) || !(h && (0, _util.isNum)(h))) {
  17651. (0, _util.warn)("Image dimensions are missing, or not numbers.");
  17652. return undefined;
  17653. }
  17654. var maxImageSize = this.options.maxImageSize;
  17655. if (maxImageSize !== -1 && w * h > maxImageSize) {
  17656. (0, _util.warn)("Image exceeded maximum allowed size and was removed.");
  17657. return undefined;
  17658. }
  17659. var imageMask = dict.get("ImageMask", "IM") || false;
  17660. var imgData, args;
  17661. if (imageMask) {
  17662. var width = dict.get("Width", "W");
  17663. var height = dict.get("Height", "H");
  17664. var bitStrideLength = width + 7 >> 3;
  17665. var imgArray = image.getBytes(bitStrideLength * height, true);
  17666. var decode = dict.getArray("Decode", "D");
  17667. imgData = _image.PDFImage.createMask({
  17668. imgArray,
  17669. width,
  17670. height,
  17671. imageIsFromDecodeStream: image instanceof _stream.DecodeStream,
  17672. inverseDecode: !!decode && decode[0] > 0
  17673. });
  17674. imgData.cached = !!cacheKey;
  17675. args = [imgData];
  17676. operatorList.addOp(_util.OPS.paintImageMaskXObject, args);
  17677. if (cacheKey) {
  17678. localImageCache.set(cacheKey, imageRef, {
  17679. fn: _util.OPS.paintImageMaskXObject,
  17680. args
  17681. });
  17682. }
  17683. return undefined;
  17684. }
  17685. var softMask = dict.get("SMask", "SM") || false;
  17686. var mask = dict.get("Mask") || false;
  17687. var SMALL_IMAGE_DIMENSIONS = 200;
  17688. if (isInline && !softMask && !mask && w + h < SMALL_IMAGE_DIMENSIONS) {
  17689. const imageObj = new _image.PDFImage({
  17690. xref: this.xref,
  17691. res: resources,
  17692. image,
  17693. isInline,
  17694. pdfFunctionFactory: this._pdfFunctionFactory,
  17695. localColorSpaceCache
  17696. });
  17697. imgData = imageObj.createImageData(true);
  17698. operatorList.addOp(_util.OPS.paintInlineImageXObject, [imgData]);
  17699. return undefined;
  17700. }
  17701. let objId = `img_${this.idFactory.createObjId()}`,
  17702. cacheGlobally = false;
  17703. if (this.parsingType3Font) {
  17704. objId = `${this.idFactory.getDocId()}_type3_${objId}`;
  17705. } else if (imageRef) {
  17706. cacheGlobally = this.globalImageCache.shouldCache(imageRef, this.pageIndex);
  17707. if (cacheGlobally) {
  17708. objId = `${this.idFactory.getDocId()}_${objId}`;
  17709. }
  17710. }
  17711. operatorList.addDependency(objId);
  17712. args = [objId, w, h];
  17713. _image.PDFImage.buildImage({
  17714. xref: this.xref,
  17715. res: resources,
  17716. image,
  17717. isInline,
  17718. pdfFunctionFactory: this._pdfFunctionFactory,
  17719. localColorSpaceCache
  17720. }).then(imageObj => {
  17721. imgData = imageObj.createImageData(false);
  17722. return this._sendImgData(objId, imgData, cacheGlobally);
  17723. }).catch(reason => {
  17724. (0, _util.warn)(`Unable to decode image "${objId}": "${reason}".`);
  17725. return this._sendImgData(objId, null, cacheGlobally);
  17726. });
  17727. operatorList.addOp(_util.OPS.paintImageXObject, args);
  17728. if (cacheKey) {
  17729. localImageCache.set(cacheKey, imageRef, {
  17730. fn: _util.OPS.paintImageXObject,
  17731. args
  17732. });
  17733. if (imageRef) {
  17734. (0, _util.assert)(!isInline, "Cannot cache an inline image globally.");
  17735. this.globalImageCache.addPageIndex(imageRef, this.pageIndex);
  17736. if (cacheGlobally) {
  17737. this.globalImageCache.setData(imageRef, {
  17738. objId,
  17739. fn: _util.OPS.paintImageXObject,
  17740. args
  17741. });
  17742. }
  17743. }
  17744. }
  17745. return undefined;
  17746. }
  17747. handleSMask(smask, resources, operatorList, task, stateManager, localColorSpaceCache) {
  17748. var smaskContent = smask.get("G");
  17749. var smaskOptions = {
  17750. subtype: smask.get("S").name,
  17751. backdrop: smask.get("BC")
  17752. };
  17753. var transferObj = smask.get("TR");
  17754. if ((0, _function.isPDFFunction)(transferObj)) {
  17755. const transferFn = this._pdfFunctionFactory.create(transferObj);
  17756. var transferMap = new Uint8Array(256);
  17757. var tmp = new Float32Array(1);
  17758. for (var i = 0; i < 256; i++) {
  17759. tmp[0] = i / 255;
  17760. transferFn(tmp, 0, tmp, 0);
  17761. transferMap[i] = tmp[0] * 255 | 0;
  17762. }
  17763. smaskOptions.transferMap = transferMap;
  17764. }
  17765. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone(), localColorSpaceCache);
  17766. }
  17767. handleTransferFunction(tr) {
  17768. let transferArray;
  17769. if (Array.isArray(tr)) {
  17770. transferArray = tr;
  17771. } else if ((0, _function.isPDFFunction)(tr)) {
  17772. transferArray = [tr];
  17773. } else {
  17774. return null;
  17775. }
  17776. const transferMaps = [];
  17777. let numFns = 0,
  17778. numEffectfulFns = 0;
  17779. for (const entry of transferArray) {
  17780. const transferObj = this.xref.fetchIfRef(entry);
  17781. numFns++;
  17782. if ((0, _primitives.isName)(transferObj, "Identity")) {
  17783. transferMaps.push(null);
  17784. continue;
  17785. } else if (!(0, _function.isPDFFunction)(transferObj)) {
  17786. return null;
  17787. }
  17788. const transferFn = this._pdfFunctionFactory.create(transferObj);
  17789. const transferMap = new Uint8Array(256),
  17790. tmp = new Float32Array(1);
  17791. for (let j = 0; j < 256; j++) {
  17792. tmp[0] = j / 255;
  17793. transferFn(tmp, 0, tmp, 0);
  17794. transferMap[j] = tmp[0] * 255 | 0;
  17795. }
  17796. transferMaps.push(transferMap);
  17797. numEffectfulFns++;
  17798. }
  17799. if (!(numFns === 1 || numFns === 4)) {
  17800. return null;
  17801. }
  17802. if (numEffectfulFns === 0) {
  17803. return null;
  17804. }
  17805. return transferMaps;
  17806. }
  17807. handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  17808. const tilingOpList = new _operator_list.OperatorList();
  17809. const patternResources = _primitives.Dict.merge({
  17810. xref: this.xref,
  17811. dictArray: [patternDict.get("Resources"), resources]
  17812. });
  17813. return this.getOperatorList({
  17814. stream: pattern,
  17815. task,
  17816. resources: patternResources,
  17817. operatorList: tilingOpList
  17818. }).then(function () {
  17819. return (0, _pattern.getTilingPatternIR)({
  17820. fnArray: tilingOpList.fnArray,
  17821. argsArray: tilingOpList.argsArray
  17822. }, patternDict, args);
  17823. }).then(function (tilingPatternIR) {
  17824. operatorList.addDependencies(tilingOpList.dependencies);
  17825. operatorList.addOp(fn, tilingPatternIR);
  17826. }, reason => {
  17827. if (reason instanceof _util.AbortException) {
  17828. return;
  17829. }
  17830. if (this.options.ignoreErrors) {
  17831. this.handler.send("UnsupportedFeature", {
  17832. featureId: _util.UNSUPPORTED_FEATURES.errorTilingPattern
  17833. });
  17834. (0, _util.warn)(`handleTilingType - ignoring pattern: "${reason}".`);
  17835. return;
  17836. }
  17837. throw reason;
  17838. });
  17839. }
  17840. handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  17841. var fontName,
  17842. fontSize = 0;
  17843. if (fontArgs) {
  17844. fontArgs = fontArgs.slice();
  17845. fontName = fontArgs[0].name;
  17846. fontSize = fontArgs[1];
  17847. }
  17848. return this.loadFont(fontName, fontRef, resources).then(translated => {
  17849. if (!translated.font.isType3Font) {
  17850. return translated;
  17851. }
  17852. return translated.loadType3Data(this, resources, task).then(function () {
  17853. operatorList.addDependencies(translated.type3Dependencies);
  17854. return translated;
  17855. }).catch(reason => {
  17856. this.handler.send("UnsupportedFeature", {
  17857. featureId: _util.UNSUPPORTED_FEATURES.errorFontLoadType3
  17858. });
  17859. return new TranslatedFont({
  17860. loadedName: "g_font_error",
  17861. font: new _fonts.ErrorFont(`Type3 font load error: ${reason}`),
  17862. dict: translated.font,
  17863. extraProperties: this.options.fontExtraProperties
  17864. });
  17865. });
  17866. }).then(translated => {
  17867. state.font = translated.font;
  17868. state.fontSize = fontSize;
  17869. state.fontName = fontName;
  17870. translated.send(this.handler);
  17871. return translated.loadedName;
  17872. });
  17873. }
  17874. handleText(chars, state) {
  17875. const font = state.font;
  17876. const glyphs = font.charsToGlyphs(chars);
  17877. if (font.data) {
  17878. const isAddToPathSet = !!(state.textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
  17879. if (isAddToPathSet || state.fillColorSpace.name === "Pattern" || font.disableFontFace || this.options.disableFontFace) {
  17880. PartialEvaluator.buildFontPaths(font, glyphs, this.handler);
  17881. }
  17882. }
  17883. return glyphs;
  17884. }
  17885. ensureStateFont(state) {
  17886. if (state.font) {
  17887. return;
  17888. }
  17889. const reason = new _util.FormatError("Missing setFont (Tf) operator before text rendering operator.");
  17890. if (this.options.ignoreErrors) {
  17891. this.handler.send("UnsupportedFeature", {
  17892. featureId: _util.UNSUPPORTED_FEATURES.errorFontState
  17893. });
  17894. (0, _util.warn)(`ensureStateFont: "${reason}".`);
  17895. return;
  17896. }
  17897. throw reason;
  17898. }
  17899. async setGState({
  17900. resources,
  17901. gState,
  17902. operatorList,
  17903. cacheKey,
  17904. task,
  17905. stateManager,
  17906. localGStateCache,
  17907. localColorSpaceCache
  17908. }) {
  17909. const gStateRef = gState.objId;
  17910. let isSimpleGState = true;
  17911. var gStateObj = [];
  17912. var gStateKeys = gState.getKeys();
  17913. var promise = Promise.resolve();
  17914. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  17915. const key = gStateKeys[i];
  17916. const value = gState.get(key);
  17917. switch (key) {
  17918. case "Type":
  17919. break;
  17920. case "LW":
  17921. case "LC":
  17922. case "LJ":
  17923. case "ML":
  17924. case "D":
  17925. case "RI":
  17926. case "FL":
  17927. case "CA":
  17928. case "ca":
  17929. gStateObj.push([key, value]);
  17930. break;
  17931. case "Font":
  17932. isSimpleGState = false;
  17933. promise = promise.then(() => {
  17934. return this.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  17935. operatorList.addDependency(loadedName);
  17936. gStateObj.push([key, [loadedName, value[1]]]);
  17937. });
  17938. });
  17939. break;
  17940. case "BM":
  17941. gStateObj.push([key, normalizeBlendMode(value)]);
  17942. break;
  17943. case "SMask":
  17944. if ((0, _primitives.isName)(value, "None")) {
  17945. gStateObj.push([key, false]);
  17946. break;
  17947. }
  17948. if ((0, _primitives.isDict)(value)) {
  17949. isSimpleGState = false;
  17950. promise = promise.then(() => {
  17951. return this.handleSMask(value, resources, operatorList, task, stateManager, localColorSpaceCache);
  17952. });
  17953. gStateObj.push([key, true]);
  17954. } else {
  17955. (0, _util.warn)("Unsupported SMask type");
  17956. }
  17957. break;
  17958. case "TR":
  17959. const transferMaps = this.handleTransferFunction(value);
  17960. gStateObj.push([key, transferMaps]);
  17961. break;
  17962. case "OP":
  17963. case "op":
  17964. case "OPM":
  17965. case "BG":
  17966. case "BG2":
  17967. case "UCR":
  17968. case "UCR2":
  17969. case "TR2":
  17970. case "HT":
  17971. case "SM":
  17972. case "SA":
  17973. case "AIS":
  17974. case "TK":
  17975. (0, _util.info)("graphic state operator " + key);
  17976. break;
  17977. default:
  17978. (0, _util.info)("Unknown graphic state operator " + key);
  17979. break;
  17980. }
  17981. }
  17982. return promise.then(function () {
  17983. if (gStateObj.length > 0) {
  17984. operatorList.addOp(_util.OPS.setGState, [gStateObj]);
  17985. }
  17986. if (isSimpleGState) {
  17987. localGStateCache.set(cacheKey, gStateRef, gStateObj);
  17988. }
  17989. });
  17990. }
  17991. loadFont(fontName, font, resources) {
  17992. const errorFont = () => {
  17993. return Promise.resolve(new TranslatedFont({
  17994. loadedName: "g_font_error",
  17995. font: new _fonts.ErrorFont(`Font "${fontName}" is not available.`),
  17996. dict: font,
  17997. extraProperties: this.options.fontExtraProperties
  17998. }));
  17999. };
  18000. var fontRef,
  18001. xref = this.xref;
  18002. if (font) {
  18003. if (!(0, _primitives.isRef)(font)) {
  18004. throw new _util.FormatError('The "font" object should be a reference.');
  18005. }
  18006. fontRef = font;
  18007. } else {
  18008. var fontRes = resources.get("Font");
  18009. if (fontRes) {
  18010. fontRef = fontRes.getRaw(fontName);
  18011. }
  18012. }
  18013. if (!fontRef) {
  18014. const partialMsg = `Font "${fontName || font && font.toString()}" is not available`;
  18015. if (!this.options.ignoreErrors && !this.parsingType3Font) {
  18016. (0, _util.warn)(`${partialMsg}.`);
  18017. return errorFont();
  18018. }
  18019. this.handler.send("UnsupportedFeature", {
  18020. featureId: _util.UNSUPPORTED_FEATURES.errorFontMissing
  18021. });
  18022. (0, _util.warn)(`${partialMsg} -- attempting to fallback to a default font.`);
  18023. fontRef = PartialEvaluator.fallbackFontDict;
  18024. }
  18025. if (this.fontCache.has(fontRef)) {
  18026. return this.fontCache.get(fontRef);
  18027. }
  18028. font = xref.fetchIfRef(fontRef);
  18029. if (!(0, _primitives.isDict)(font)) {
  18030. return errorFont();
  18031. }
  18032. if (font.translated) {
  18033. return font.translated;
  18034. }
  18035. var fontCapability = (0, _util.createPromiseCapability)();
  18036. var preEvaluatedFont = this.preEvaluateFont(font);
  18037. const {
  18038. descriptor,
  18039. hash
  18040. } = preEvaluatedFont;
  18041. var fontRefIsRef = (0, _primitives.isRef)(fontRef),
  18042. fontID;
  18043. if (fontRefIsRef) {
  18044. fontID = `f${fontRef.toString()}`;
  18045. }
  18046. if (hash && (0, _primitives.isDict)(descriptor)) {
  18047. if (!descriptor.fontAliases) {
  18048. descriptor.fontAliases = Object.create(null);
  18049. }
  18050. var fontAliases = descriptor.fontAliases;
  18051. if (fontAliases[hash]) {
  18052. var aliasFontRef = fontAliases[hash].aliasRef;
  18053. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  18054. this.fontCache.putAlias(fontRef, aliasFontRef);
  18055. return this.fontCache.get(fontRef);
  18056. }
  18057. } else {
  18058. fontAliases[hash] = {
  18059. fontID: this.idFactory.createFontId()
  18060. };
  18061. }
  18062. if (fontRefIsRef) {
  18063. fontAliases[hash].aliasRef = fontRef;
  18064. }
  18065. fontID = fontAliases[hash].fontID;
  18066. }
  18067. if (fontRefIsRef) {
  18068. this.fontCache.put(fontRef, fontCapability.promise);
  18069. } else {
  18070. if (!fontID) {
  18071. fontID = this.idFactory.createFontId();
  18072. }
  18073. this.fontCache.put(`id_${fontID}`, fontCapability.promise);
  18074. }
  18075. (0, _util.assert)(fontID && fontID.startsWith("f"), 'The "fontID" must be (correctly) defined.');
  18076. font.loadedName = `${this.idFactory.getDocId()}_${fontID}`;
  18077. font.translated = fontCapability.promise;
  18078. var translatedPromise;
  18079. try {
  18080. translatedPromise = this.translateFont(preEvaluatedFont);
  18081. } catch (e) {
  18082. translatedPromise = Promise.reject(e);
  18083. }
  18084. translatedPromise.then(translatedFont => {
  18085. if (translatedFont.fontType !== undefined) {
  18086. var xrefFontStats = xref.stats.fontTypes;
  18087. xrefFontStats[translatedFont.fontType] = true;
  18088. }
  18089. fontCapability.resolve(new TranslatedFont({
  18090. loadedName: font.loadedName,
  18091. font: translatedFont,
  18092. dict: font,
  18093. extraProperties: this.options.fontExtraProperties
  18094. }));
  18095. }).catch(reason => {
  18096. this.handler.send("UnsupportedFeature", {
  18097. featureId: _util.UNSUPPORTED_FEATURES.errorFontTranslate
  18098. });
  18099. try {
  18100. var fontFile3 = descriptor && descriptor.get("FontFile3");
  18101. var subtype = fontFile3 && fontFile3.get("Subtype");
  18102. var fontType = (0, _fonts.getFontType)(preEvaluatedFont.type, subtype && subtype.name);
  18103. var xrefFontStats = xref.stats.fontTypes;
  18104. xrefFontStats[fontType] = true;
  18105. } catch (ex) {}
  18106. fontCapability.resolve(new TranslatedFont({
  18107. loadedName: font.loadedName,
  18108. font: new _fonts.ErrorFont(reason instanceof Error ? reason.message : reason),
  18109. dict: font,
  18110. extraProperties: this.options.fontExtraProperties
  18111. }));
  18112. });
  18113. return fontCapability.promise;
  18114. }
  18115. buildPath(operatorList, fn, args, parsingText = false) {
  18116. var lastIndex = operatorList.length - 1;
  18117. if (!args) {
  18118. args = [];
  18119. }
  18120. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== _util.OPS.constructPath) {
  18121. if (parsingText) {
  18122. (0, _util.warn)(`Encountered path operator "${fn}" inside of a text object.`);
  18123. operatorList.addOp(_util.OPS.save, null);
  18124. }
  18125. operatorList.addOp(_util.OPS.constructPath, [[fn], args]);
  18126. if (parsingText) {
  18127. operatorList.addOp(_util.OPS.restore, null);
  18128. }
  18129. } else {
  18130. var opArgs = operatorList.argsArray[lastIndex];
  18131. opArgs[0].push(fn);
  18132. Array.prototype.push.apply(opArgs[1], args);
  18133. }
  18134. }
  18135. parseColorSpace({
  18136. cs,
  18137. resources,
  18138. localColorSpaceCache
  18139. }) {
  18140. return _colorspace.ColorSpace.parseAsync({
  18141. cs,
  18142. xref: this.xref,
  18143. resources,
  18144. pdfFunctionFactory: this._pdfFunctionFactory,
  18145. localColorSpaceCache
  18146. }).catch(reason => {
  18147. if (reason instanceof _util.AbortException) {
  18148. return null;
  18149. }
  18150. if (this.options.ignoreErrors) {
  18151. this.handler.send("UnsupportedFeature", {
  18152. featureId: _util.UNSUPPORTED_FEATURES.errorColorSpace
  18153. });
  18154. (0, _util.warn)(`parseColorSpace - ignoring ColorSpace: "${reason}".`);
  18155. return null;
  18156. }
  18157. throw reason;
  18158. });
  18159. }
  18160. async handleColorN(operatorList, fn, args, cs, patterns, resources, task, localColorSpaceCache) {
  18161. var patternName = args[args.length - 1];
  18162. var pattern;
  18163. if ((0, _primitives.isName)(patternName) && (pattern = patterns.get(patternName.name))) {
  18164. var dict = (0, _primitives.isStream)(pattern) ? pattern.dict : pattern;
  18165. var typeNum = dict.get("PatternType");
  18166. if (typeNum === PatternType.TILING) {
  18167. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  18168. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  18169. } else if (typeNum === PatternType.SHADING) {
  18170. var shading = dict.get("Shading");
  18171. var matrix = dict.getArray("Matrix");
  18172. pattern = _pattern.Pattern.parseShading(shading, matrix, this.xref, resources, this.handler, this._pdfFunctionFactory, localColorSpaceCache);
  18173. operatorList.addOp(fn, pattern.getIR());
  18174. return undefined;
  18175. }
  18176. throw new _util.FormatError(`Unknown PatternType: ${typeNum}`);
  18177. }
  18178. throw new _util.FormatError(`Unknown PatternName: ${patternName}`);
  18179. }
  18180. async parseMarkedContentProps(contentProperties, resources) {
  18181. let optionalContent;
  18182. if ((0, _primitives.isName)(contentProperties)) {
  18183. const properties = resources.get("Properties");
  18184. optionalContent = properties.get(contentProperties.name);
  18185. } else if ((0, _primitives.isDict)(contentProperties)) {
  18186. optionalContent = contentProperties;
  18187. } else {
  18188. throw new _util.FormatError("Optional content properties malformed.");
  18189. }
  18190. const optionalContentType = optionalContent.get("Type").name;
  18191. if (optionalContentType === "OCG") {
  18192. return {
  18193. type: optionalContentType,
  18194. id: optionalContent.objId
  18195. };
  18196. } else if (optionalContentType === "OCMD") {
  18197. const optionalContentGroups = optionalContent.get("OCGs");
  18198. if (Array.isArray(optionalContentGroups) || (0, _primitives.isDict)(optionalContentGroups)) {
  18199. const groupIds = [];
  18200. if (Array.isArray(optionalContentGroups)) {
  18201. optionalContent.get("OCGs").forEach(ocg => {
  18202. groupIds.push(ocg.toString());
  18203. });
  18204. } else {
  18205. groupIds.push(optionalContentGroups.objId);
  18206. }
  18207. let expression = null;
  18208. if (optionalContent.get("VE")) {
  18209. expression = true;
  18210. }
  18211. return {
  18212. type: optionalContentType,
  18213. ids: groupIds,
  18214. policy: (0, _primitives.isName)(optionalContent.get("P")) ? optionalContent.get("P").name : null,
  18215. expression
  18216. };
  18217. } else if ((0, _primitives.isRef)(optionalContentGroups)) {
  18218. return {
  18219. type: optionalContentType,
  18220. id: optionalContentGroups.toString()
  18221. };
  18222. }
  18223. }
  18224. return null;
  18225. }
  18226. getOperatorList({
  18227. stream,
  18228. task,
  18229. resources,
  18230. operatorList,
  18231. initialState = null
  18232. }) {
  18233. resources = resources || _primitives.Dict.empty;
  18234. initialState = initialState || new EvalState();
  18235. if (!operatorList) {
  18236. throw new Error('getOperatorList: missing "operatorList" parameter');
  18237. }
  18238. var self = this;
  18239. var xref = this.xref;
  18240. let parsingText = false;
  18241. const localImageCache = new _image_utils.LocalImageCache();
  18242. const localColorSpaceCache = new _image_utils.LocalColorSpaceCache();
  18243. const localGStateCache = new _image_utils.LocalGStateCache();
  18244. var xobjs = resources.get("XObject") || _primitives.Dict.empty;
  18245. var patterns = resources.get("Pattern") || _primitives.Dict.empty;
  18246. var stateManager = new StateManager(initialState);
  18247. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  18248. var timeSlotManager = new TimeSlotManager();
  18249. function closePendingRestoreOPS(argument) {
  18250. for (var i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  18251. operatorList.addOp(_util.OPS.restore, []);
  18252. }
  18253. }
  18254. return new Promise(function promiseBody(resolve, reject) {
  18255. const next = function (promise) {
  18256. Promise.all([promise, operatorList.ready]).then(function () {
  18257. try {
  18258. promiseBody(resolve, reject);
  18259. } catch (ex) {
  18260. reject(ex);
  18261. }
  18262. }, reject);
  18263. };
  18264. task.ensureNotTerminated();
  18265. timeSlotManager.reset();
  18266. var stop,
  18267. operation = {},
  18268. i,
  18269. ii,
  18270. cs,
  18271. name;
  18272. while (!(stop = timeSlotManager.check())) {
  18273. operation.args = null;
  18274. if (!preprocessor.read(operation)) {
  18275. break;
  18276. }
  18277. var args = operation.args;
  18278. var fn = operation.fn;
  18279. switch (fn | 0) {
  18280. case _util.OPS.paintXObject:
  18281. name = args[0].name;
  18282. if (name) {
  18283. const localImage = localImageCache.getByName(name);
  18284. if (localImage) {
  18285. operatorList.addOp(localImage.fn, localImage.args);
  18286. args = null;
  18287. continue;
  18288. }
  18289. }
  18290. next(new Promise(function (resolveXObject, rejectXObject) {
  18291. if (!name) {
  18292. throw new _util.FormatError("XObject must be referred to by name.");
  18293. }
  18294. let xobj = xobjs.getRaw(name);
  18295. if (xobj instanceof _primitives.Ref) {
  18296. const localImage = localImageCache.getByRef(xobj);
  18297. if (localImage) {
  18298. operatorList.addOp(localImage.fn, localImage.args);
  18299. resolveXObject();
  18300. return;
  18301. }
  18302. const globalImage = self.globalImageCache.getData(xobj, self.pageIndex);
  18303. if (globalImage) {
  18304. operatorList.addDependency(globalImage.objId);
  18305. operatorList.addOp(globalImage.fn, globalImage.args);
  18306. resolveXObject();
  18307. return;
  18308. }
  18309. xobj = xref.fetch(xobj);
  18310. }
  18311. if (!(0, _primitives.isStream)(xobj)) {
  18312. throw new _util.FormatError("XObject should be a stream");
  18313. }
  18314. const type = xobj.dict.get("Subtype");
  18315. if (!(0, _primitives.isName)(type)) {
  18316. throw new _util.FormatError("XObject should have a Name subtype");
  18317. }
  18318. if (type.name === "Form") {
  18319. stateManager.save();
  18320. self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone(), localColorSpaceCache).then(function () {
  18321. stateManager.restore();
  18322. resolveXObject();
  18323. }, rejectXObject);
  18324. return;
  18325. } else if (type.name === "Image") {
  18326. self.buildPaintImageXObject({
  18327. resources,
  18328. image: xobj,
  18329. operatorList,
  18330. cacheKey: name,
  18331. localImageCache,
  18332. localColorSpaceCache
  18333. }).then(resolveXObject, rejectXObject);
  18334. return;
  18335. } else if (type.name === "PS") {
  18336. (0, _util.info)("Ignored XObject subtype PS");
  18337. } else {
  18338. throw new _util.FormatError(`Unhandled XObject subtype ${type.name}`);
  18339. }
  18340. resolveXObject();
  18341. }).catch(function (reason) {
  18342. if (reason instanceof _util.AbortException) {
  18343. return;
  18344. }
  18345. if (self.options.ignoreErrors) {
  18346. self.handler.send("UnsupportedFeature", {
  18347. featureId: _util.UNSUPPORTED_FEATURES.errorXObject
  18348. });
  18349. (0, _util.warn)(`getOperatorList - ignoring XObject: "${reason}".`);
  18350. return;
  18351. }
  18352. throw reason;
  18353. }));
  18354. return;
  18355. case _util.OPS.setFont:
  18356. var fontSize = args[1];
  18357. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  18358. operatorList.addDependency(loadedName);
  18359. operatorList.addOp(_util.OPS.setFont, [loadedName, fontSize]);
  18360. }));
  18361. return;
  18362. case _util.OPS.beginText:
  18363. parsingText = true;
  18364. break;
  18365. case _util.OPS.endText:
  18366. parsingText = false;
  18367. break;
  18368. case _util.OPS.endInlineImage:
  18369. var cacheKey = args[0].cacheKey;
  18370. if (cacheKey) {
  18371. const localImage = localImageCache.getByName(cacheKey);
  18372. if (localImage) {
  18373. operatorList.addOp(localImage.fn, localImage.args);
  18374. args = null;
  18375. continue;
  18376. }
  18377. }
  18378. next(self.buildPaintImageXObject({
  18379. resources,
  18380. image: args[0],
  18381. isInline: true,
  18382. operatorList,
  18383. cacheKey,
  18384. localImageCache,
  18385. localColorSpaceCache
  18386. }));
  18387. return;
  18388. case _util.OPS.showText:
  18389. if (!stateManager.state.font) {
  18390. self.ensureStateFont(stateManager.state);
  18391. continue;
  18392. }
  18393. args[0] = self.handleText(args[0], stateManager.state);
  18394. break;
  18395. case _util.OPS.showSpacedText:
  18396. if (!stateManager.state.font) {
  18397. self.ensureStateFont(stateManager.state);
  18398. continue;
  18399. }
  18400. var arr = args[0];
  18401. var combinedGlyphs = [];
  18402. var arrLength = arr.length;
  18403. var state = stateManager.state;
  18404. for (i = 0; i < arrLength; ++i) {
  18405. var arrItem = arr[i];
  18406. if ((0, _util.isString)(arrItem)) {
  18407. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  18408. } else if ((0, _util.isNum)(arrItem)) {
  18409. combinedGlyphs.push(arrItem);
  18410. }
  18411. }
  18412. args[0] = combinedGlyphs;
  18413. fn = _util.OPS.showText;
  18414. break;
  18415. case _util.OPS.nextLineShowText:
  18416. if (!stateManager.state.font) {
  18417. self.ensureStateFont(stateManager.state);
  18418. continue;
  18419. }
  18420. operatorList.addOp(_util.OPS.nextLine);
  18421. args[0] = self.handleText(args[0], stateManager.state);
  18422. fn = _util.OPS.showText;
  18423. break;
  18424. case _util.OPS.nextLineSetSpacingShowText:
  18425. if (!stateManager.state.font) {
  18426. self.ensureStateFont(stateManager.state);
  18427. continue;
  18428. }
  18429. operatorList.addOp(_util.OPS.nextLine);
  18430. operatorList.addOp(_util.OPS.setWordSpacing, [args.shift()]);
  18431. operatorList.addOp(_util.OPS.setCharSpacing, [args.shift()]);
  18432. args[0] = self.handleText(args[0], stateManager.state);
  18433. fn = _util.OPS.showText;
  18434. break;
  18435. case _util.OPS.setTextRenderingMode:
  18436. stateManager.state.textRenderingMode = args[0];
  18437. break;
  18438. case _util.OPS.setFillColorSpace:
  18439. {
  18440. const cachedColorSpace = _colorspace.ColorSpace.getCached(args[0], xref, localColorSpaceCache);
  18441. if (cachedColorSpace) {
  18442. stateManager.state.fillColorSpace = cachedColorSpace;
  18443. continue;
  18444. }
  18445. next(self.parseColorSpace({
  18446. cs: args[0],
  18447. resources,
  18448. localColorSpaceCache
  18449. }).then(function (colorSpace) {
  18450. if (colorSpace) {
  18451. stateManager.state.fillColorSpace = colorSpace;
  18452. }
  18453. }));
  18454. return;
  18455. }
  18456. case _util.OPS.setStrokeColorSpace:
  18457. {
  18458. const cachedColorSpace = _colorspace.ColorSpace.getCached(args[0], xref, localColorSpaceCache);
  18459. if (cachedColorSpace) {
  18460. stateManager.state.strokeColorSpace = cachedColorSpace;
  18461. continue;
  18462. }
  18463. next(self.parseColorSpace({
  18464. cs: args[0],
  18465. resources,
  18466. localColorSpaceCache
  18467. }).then(function (colorSpace) {
  18468. if (colorSpace) {
  18469. stateManager.state.strokeColorSpace = colorSpace;
  18470. }
  18471. }));
  18472. return;
  18473. }
  18474. case _util.OPS.setFillColor:
  18475. cs = stateManager.state.fillColorSpace;
  18476. args = cs.getRgb(args, 0);
  18477. fn = _util.OPS.setFillRGBColor;
  18478. break;
  18479. case _util.OPS.setStrokeColor:
  18480. cs = stateManager.state.strokeColorSpace;
  18481. args = cs.getRgb(args, 0);
  18482. fn = _util.OPS.setStrokeRGBColor;
  18483. break;
  18484. case _util.OPS.setFillGray:
  18485. stateManager.state.fillColorSpace = _colorspace.ColorSpace.singletons.gray;
  18486. args = _colorspace.ColorSpace.singletons.gray.getRgb(args, 0);
  18487. fn = _util.OPS.setFillRGBColor;
  18488. break;
  18489. case _util.OPS.setStrokeGray:
  18490. stateManager.state.strokeColorSpace = _colorspace.ColorSpace.singletons.gray;
  18491. args = _colorspace.ColorSpace.singletons.gray.getRgb(args, 0);
  18492. fn = _util.OPS.setStrokeRGBColor;
  18493. break;
  18494. case _util.OPS.setFillCMYKColor:
  18495. stateManager.state.fillColorSpace = _colorspace.ColorSpace.singletons.cmyk;
  18496. args = _colorspace.ColorSpace.singletons.cmyk.getRgb(args, 0);
  18497. fn = _util.OPS.setFillRGBColor;
  18498. break;
  18499. case _util.OPS.setStrokeCMYKColor:
  18500. stateManager.state.strokeColorSpace = _colorspace.ColorSpace.singletons.cmyk;
  18501. args = _colorspace.ColorSpace.singletons.cmyk.getRgb(args, 0);
  18502. fn = _util.OPS.setStrokeRGBColor;
  18503. break;
  18504. case _util.OPS.setFillRGBColor:
  18505. stateManager.state.fillColorSpace = _colorspace.ColorSpace.singletons.rgb;
  18506. args = _colorspace.ColorSpace.singletons.rgb.getRgb(args, 0);
  18507. break;
  18508. case _util.OPS.setStrokeRGBColor:
  18509. stateManager.state.strokeColorSpace = _colorspace.ColorSpace.singletons.rgb;
  18510. args = _colorspace.ColorSpace.singletons.rgb.getRgb(args, 0);
  18511. break;
  18512. case _util.OPS.setFillColorN:
  18513. cs = stateManager.state.fillColorSpace;
  18514. if (cs.name === "Pattern") {
  18515. next(self.handleColorN(operatorList, _util.OPS.setFillColorN, args, cs, patterns, resources, task, localColorSpaceCache));
  18516. return;
  18517. }
  18518. args = cs.getRgb(args, 0);
  18519. fn = _util.OPS.setFillRGBColor;
  18520. break;
  18521. case _util.OPS.setStrokeColorN:
  18522. cs = stateManager.state.strokeColorSpace;
  18523. if (cs.name === "Pattern") {
  18524. next(self.handleColorN(operatorList, _util.OPS.setStrokeColorN, args, cs, patterns, resources, task, localColorSpaceCache));
  18525. return;
  18526. }
  18527. args = cs.getRgb(args, 0);
  18528. fn = _util.OPS.setStrokeRGBColor;
  18529. break;
  18530. case _util.OPS.shadingFill:
  18531. var shadingRes = resources.get("Shading");
  18532. if (!shadingRes) {
  18533. throw new _util.FormatError("No shading resource found");
  18534. }
  18535. var shading = shadingRes.get(args[0].name);
  18536. if (!shading) {
  18537. throw new _util.FormatError("No shading object found");
  18538. }
  18539. var shadingFill = _pattern.Pattern.parseShading(shading, null, xref, resources, self.handler, self._pdfFunctionFactory, localColorSpaceCache);
  18540. var patternIR = shadingFill.getIR();
  18541. args = [patternIR];
  18542. fn = _util.OPS.shadingFill;
  18543. break;
  18544. case _util.OPS.setGState:
  18545. name = args[0].name;
  18546. if (name) {
  18547. const localGStateObj = localGStateCache.getByName(name);
  18548. if (localGStateObj) {
  18549. if (localGStateObj.length > 0) {
  18550. operatorList.addOp(_util.OPS.setGState, [localGStateObj]);
  18551. }
  18552. args = null;
  18553. continue;
  18554. }
  18555. }
  18556. next(new Promise(function (resolveGState, rejectGState) {
  18557. if (!name) {
  18558. throw new _util.FormatError("GState must be referred to by name.");
  18559. }
  18560. const extGState = resources.get("ExtGState");
  18561. if (!(extGState instanceof _primitives.Dict)) {
  18562. throw new _util.FormatError("ExtGState should be a dictionary.");
  18563. }
  18564. const gState = extGState.get(name);
  18565. if (!(gState instanceof _primitives.Dict)) {
  18566. throw new _util.FormatError("GState should be a dictionary.");
  18567. }
  18568. self.setGState({
  18569. resources,
  18570. gState,
  18571. operatorList,
  18572. cacheKey: name,
  18573. task,
  18574. stateManager,
  18575. localGStateCache,
  18576. localColorSpaceCache
  18577. }).then(resolveGState, rejectGState);
  18578. }).catch(function (reason) {
  18579. if (reason instanceof _util.AbortException) {
  18580. return;
  18581. }
  18582. if (self.options.ignoreErrors) {
  18583. self.handler.send("UnsupportedFeature", {
  18584. featureId: _util.UNSUPPORTED_FEATURES.errorExtGState
  18585. });
  18586. (0, _util.warn)(`getOperatorList - ignoring ExtGState: "${reason}".`);
  18587. return;
  18588. }
  18589. throw reason;
  18590. }));
  18591. return;
  18592. case _util.OPS.moveTo:
  18593. case _util.OPS.lineTo:
  18594. case _util.OPS.curveTo:
  18595. case _util.OPS.curveTo2:
  18596. case _util.OPS.curveTo3:
  18597. case _util.OPS.closePath:
  18598. case _util.OPS.rectangle:
  18599. self.buildPath(operatorList, fn, args, parsingText);
  18600. continue;
  18601. case _util.OPS.markPoint:
  18602. case _util.OPS.markPointProps:
  18603. case _util.OPS.beginCompat:
  18604. case _util.OPS.endCompat:
  18605. continue;
  18606. case _util.OPS.beginMarkedContentProps:
  18607. if (!(0, _primitives.isName)(args[0])) {
  18608. (0, _util.warn)(`Expected name for beginMarkedContentProps arg0=${args[0]}`);
  18609. continue;
  18610. }
  18611. if (args[0].name === "OC") {
  18612. next(self.parseMarkedContentProps(args[1], resources).then(data => {
  18613. operatorList.addOp(_util.OPS.beginMarkedContentProps, ["OC", data]);
  18614. }).catch(reason => {
  18615. if (reason instanceof _util.AbortException) {
  18616. return;
  18617. }
  18618. if (self.options.ignoreErrors) {
  18619. self.handler.send("UnsupportedFeature", {
  18620. featureId: _util.UNSUPPORTED_FEATURES.errorMarkedContent
  18621. });
  18622. (0, _util.warn)(`getOperatorList - ignoring beginMarkedContentProps: "${reason}".`);
  18623. return;
  18624. }
  18625. throw reason;
  18626. }));
  18627. return;
  18628. }
  18629. args = [args[0].name];
  18630. break;
  18631. case _util.OPS.beginMarkedContent:
  18632. case _util.OPS.endMarkedContent:
  18633. default:
  18634. if (args !== null) {
  18635. for (i = 0, ii = args.length; i < ii; i++) {
  18636. if (args[i] instanceof _primitives.Dict) {
  18637. break;
  18638. }
  18639. }
  18640. if (i < ii) {
  18641. (0, _util.warn)("getOperatorList - ignoring operator: " + fn);
  18642. continue;
  18643. }
  18644. }
  18645. }
  18646. operatorList.addOp(fn, args);
  18647. }
  18648. if (stop) {
  18649. next(deferred);
  18650. return;
  18651. }
  18652. closePendingRestoreOPS();
  18653. resolve();
  18654. }).catch(reason => {
  18655. if (reason instanceof _util.AbortException) {
  18656. return;
  18657. }
  18658. if (this.options.ignoreErrors) {
  18659. this.handler.send("UnsupportedFeature", {
  18660. featureId: _util.UNSUPPORTED_FEATURES.errorOperatorList
  18661. });
  18662. (0, _util.warn)(`getOperatorList - ignoring errors during "${task.name}" ` + `task: "${reason}".`);
  18663. closePendingRestoreOPS();
  18664. return;
  18665. }
  18666. throw reason;
  18667. });
  18668. }
  18669. getTextContent({
  18670. stream,
  18671. task,
  18672. resources,
  18673. stateManager = null,
  18674. normalizeWhitespace = false,
  18675. combineTextItems = false,
  18676. sink,
  18677. seenStyles = Object.create(null)
  18678. }) {
  18679. resources = resources || _primitives.Dict.empty;
  18680. stateManager = stateManager || new StateManager(new TextState());
  18681. var WhitespaceRegexp = /\s/g;
  18682. var textContent = {
  18683. items: [],
  18684. styles: Object.create(null)
  18685. };
  18686. var textContentItem = {
  18687. initialized: false,
  18688. str: [],
  18689. width: 0,
  18690. height: 0,
  18691. vertical: false,
  18692. lastAdvanceWidth: 0,
  18693. lastAdvanceHeight: 0,
  18694. textAdvanceScale: 0,
  18695. spaceWidth: 0,
  18696. fakeSpaceMin: Infinity,
  18697. fakeMultiSpaceMin: Infinity,
  18698. fakeMultiSpaceMax: -0,
  18699. textRunBreakAllowed: false,
  18700. transform: null,
  18701. fontName: null
  18702. };
  18703. var SPACE_FACTOR = 0.3;
  18704. var MULTI_SPACE_FACTOR = 1.5;
  18705. var MULTI_SPACE_FACTOR_MAX = 4;
  18706. var self = this;
  18707. var xref = this.xref;
  18708. var xobjs = null;
  18709. const emptyXObjectCache = new _image_utils.LocalImageCache();
  18710. const emptyGStateCache = new _image_utils.LocalGStateCache();
  18711. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  18712. var textState;
  18713. function ensureTextContentItem() {
  18714. if (textContentItem.initialized) {
  18715. return textContentItem;
  18716. }
  18717. var font = textState.font;
  18718. if (!(font.loadedName in seenStyles)) {
  18719. seenStyles[font.loadedName] = true;
  18720. textContent.styles[font.loadedName] = {
  18721. fontFamily: font.fallbackName,
  18722. ascent: font.ascent,
  18723. descent: font.descent,
  18724. vertical: font.vertical
  18725. };
  18726. }
  18727. textContentItem.fontName = font.loadedName;
  18728. var tsm = [textState.fontSize * textState.textHScale, 0, 0, textState.fontSize, 0, textState.textRise];
  18729. if (font.isType3Font && textState.fontSize <= 1 && !(0, _util.isArrayEqual)(textState.fontMatrix, _util.FONT_IDENTITY_MATRIX)) {
  18730. const glyphHeight = font.bbox[3] - font.bbox[1];
  18731. if (glyphHeight > 0) {
  18732. tsm[3] *= glyphHeight * textState.fontMatrix[3];
  18733. }
  18734. }
  18735. var trm = _util.Util.transform(textState.ctm, _util.Util.transform(textState.textMatrix, tsm));
  18736. textContentItem.transform = trm;
  18737. if (!font.vertical) {
  18738. textContentItem.width = 0;
  18739. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  18740. textContentItem.vertical = false;
  18741. } else {
  18742. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  18743. textContentItem.height = 0;
  18744. textContentItem.vertical = true;
  18745. }
  18746. var a = textState.textLineMatrix[0];
  18747. var b = textState.textLineMatrix[1];
  18748. var scaleLineX = Math.sqrt(a * a + b * b);
  18749. a = textState.ctm[0];
  18750. b = textState.ctm[1];
  18751. var scaleCtmX = Math.sqrt(a * a + b * b);
  18752. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  18753. textContentItem.lastAdvanceWidth = 0;
  18754. textContentItem.lastAdvanceHeight = 0;
  18755. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  18756. if (spaceWidth) {
  18757. textContentItem.spaceWidth = spaceWidth;
  18758. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  18759. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  18760. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  18761. textContentItem.textRunBreakAllowed = !font.isMonospace;
  18762. } else {
  18763. textContentItem.spaceWidth = 0;
  18764. textContentItem.fakeSpaceMin = Infinity;
  18765. textContentItem.fakeMultiSpaceMin = Infinity;
  18766. textContentItem.fakeMultiSpaceMax = 0;
  18767. textContentItem.textRunBreakAllowed = false;
  18768. }
  18769. textContentItem.initialized = true;
  18770. return textContentItem;
  18771. }
  18772. function replaceWhitespace(str) {
  18773. var i = 0,
  18774. ii = str.length,
  18775. code;
  18776. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7f) {
  18777. i++;
  18778. }
  18779. return i < ii ? str.replace(WhitespaceRegexp, " ") : str;
  18780. }
  18781. function runBidiTransform(textChunk) {
  18782. var str = textChunk.str.join("");
  18783. var bidiResult = (0, _bidi.bidi)(str, -1, textChunk.vertical);
  18784. return {
  18785. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  18786. dir: bidiResult.dir,
  18787. width: textChunk.width,
  18788. height: textChunk.height,
  18789. transform: textChunk.transform,
  18790. fontName: textChunk.fontName
  18791. };
  18792. }
  18793. function handleSetFont(fontName, fontRef) {
  18794. return self.loadFont(fontName, fontRef, resources).then(function (translated) {
  18795. textState.font = translated.font;
  18796. textState.fontMatrix = translated.font.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  18797. });
  18798. }
  18799. function buildTextContentItem(chars) {
  18800. var font = textState.font;
  18801. var textChunk = ensureTextContentItem();
  18802. var width = 0;
  18803. var height = 0;
  18804. var glyphs = font.charsToGlyphs(chars);
  18805. for (var i = 0; i < glyphs.length; i++) {
  18806. var glyph = glyphs[i];
  18807. var glyphWidth = null;
  18808. if (font.vertical && glyph.vmetric) {
  18809. glyphWidth = glyph.vmetric[0];
  18810. } else {
  18811. glyphWidth = glyph.width;
  18812. }
  18813. var glyphUnicode = glyph.unicode;
  18814. var NormalizedUnicodes = (0, _unicode.getNormalizedUnicodes)();
  18815. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  18816. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  18817. }
  18818. glyphUnicode = (0, _unicode.reverseIfRtl)(glyphUnicode);
  18819. var charSpacing = textState.charSpacing;
  18820. if (glyph.isSpace) {
  18821. var wordSpacing = textState.wordSpacing;
  18822. charSpacing += wordSpacing;
  18823. if (wordSpacing > 0) {
  18824. addFakeSpaces(wordSpacing, textChunk.str);
  18825. }
  18826. }
  18827. var tx = 0;
  18828. var ty = 0;
  18829. if (!font.vertical) {
  18830. var w0 = glyphWidth * textState.fontMatrix[0];
  18831. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  18832. width += tx;
  18833. } else {
  18834. var w1 = glyphWidth * textState.fontMatrix[0];
  18835. ty = w1 * textState.fontSize + charSpacing;
  18836. height += ty;
  18837. }
  18838. textState.translateTextMatrix(tx, ty);
  18839. textChunk.str.push(glyphUnicode);
  18840. }
  18841. if (!font.vertical) {
  18842. textChunk.lastAdvanceWidth = width;
  18843. textChunk.width += width;
  18844. } else {
  18845. textChunk.lastAdvanceHeight = height;
  18846. textChunk.height += Math.abs(height);
  18847. }
  18848. return textChunk;
  18849. }
  18850. function addFakeSpaces(width, strBuf) {
  18851. if (width < textContentItem.fakeSpaceMin) {
  18852. return;
  18853. }
  18854. if (width < textContentItem.fakeMultiSpaceMin) {
  18855. strBuf.push(" ");
  18856. return;
  18857. }
  18858. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  18859. while (fakeSpaces-- > 0) {
  18860. strBuf.push(" ");
  18861. }
  18862. }
  18863. function flushTextContentItem() {
  18864. if (!textContentItem.initialized) {
  18865. return;
  18866. }
  18867. if (!textContentItem.vertical) {
  18868. textContentItem.width *= textContentItem.textAdvanceScale;
  18869. } else {
  18870. textContentItem.height *= textContentItem.textAdvanceScale;
  18871. }
  18872. textContent.items.push(runBidiTransform(textContentItem));
  18873. textContentItem.initialized = false;
  18874. textContentItem.str.length = 0;
  18875. }
  18876. function enqueueChunk() {
  18877. const length = textContent.items.length;
  18878. if (length > 0) {
  18879. sink.enqueue(textContent, length);
  18880. textContent.items = [];
  18881. textContent.styles = Object.create(null);
  18882. }
  18883. }
  18884. var timeSlotManager = new TimeSlotManager();
  18885. return new Promise(function promiseBody(resolve, reject) {
  18886. const next = function (promise) {
  18887. enqueueChunk();
  18888. Promise.all([promise, sink.ready]).then(function () {
  18889. try {
  18890. promiseBody(resolve, reject);
  18891. } catch (ex) {
  18892. reject(ex);
  18893. }
  18894. }, reject);
  18895. };
  18896. task.ensureNotTerminated();
  18897. timeSlotManager.reset();
  18898. var stop,
  18899. operation = {},
  18900. args = [];
  18901. while (!(stop = timeSlotManager.check())) {
  18902. args.length = 0;
  18903. operation.args = args;
  18904. if (!preprocessor.read(operation)) {
  18905. break;
  18906. }
  18907. textState = stateManager.state;
  18908. var fn = operation.fn;
  18909. args = operation.args;
  18910. var advance, diff;
  18911. switch (fn | 0) {
  18912. case _util.OPS.setFont:
  18913. var fontNameArg = args[0].name,
  18914. fontSizeArg = args[1];
  18915. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  18916. break;
  18917. }
  18918. flushTextContentItem();
  18919. textState.fontName = fontNameArg;
  18920. textState.fontSize = fontSizeArg;
  18921. next(handleSetFont(fontNameArg, null));
  18922. return;
  18923. case _util.OPS.setTextRise:
  18924. flushTextContentItem();
  18925. textState.textRise = args[0];
  18926. break;
  18927. case _util.OPS.setHScale:
  18928. flushTextContentItem();
  18929. textState.textHScale = args[0] / 100;
  18930. break;
  18931. case _util.OPS.setLeading:
  18932. flushTextContentItem();
  18933. textState.leading = args[0];
  18934. break;
  18935. case _util.OPS.moveText:
  18936. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  18937. advance = args[0] - args[1];
  18938. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  18939. textState.translateTextLineMatrix(args[0], args[1]);
  18940. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  18941. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  18942. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  18943. addFakeSpaces(diff, textContentItem.str);
  18944. break;
  18945. }
  18946. flushTextContentItem();
  18947. textState.translateTextLineMatrix(args[0], args[1]);
  18948. textState.textMatrix = textState.textLineMatrix.slice();
  18949. break;
  18950. case _util.OPS.setLeadingMoveText:
  18951. flushTextContentItem();
  18952. textState.leading = -args[1];
  18953. textState.translateTextLineMatrix(args[0], args[1]);
  18954. textState.textMatrix = textState.textLineMatrix.slice();
  18955. break;
  18956. case _util.OPS.nextLine:
  18957. flushTextContentItem();
  18958. textState.carriageReturn();
  18959. break;
  18960. case _util.OPS.setTextMatrix:
  18961. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  18962. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  18963. textState.translateTextLineMatrix(advance.width, advance.height);
  18964. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  18965. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  18966. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  18967. addFakeSpaces(diff, textContentItem.str);
  18968. break;
  18969. }
  18970. flushTextContentItem();
  18971. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  18972. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  18973. break;
  18974. case _util.OPS.setCharSpacing:
  18975. textState.charSpacing = args[0];
  18976. break;
  18977. case _util.OPS.setWordSpacing:
  18978. textState.wordSpacing = args[0];
  18979. break;
  18980. case _util.OPS.beginText:
  18981. flushTextContentItem();
  18982. textState.textMatrix = _util.IDENTITY_MATRIX.slice();
  18983. textState.textLineMatrix = _util.IDENTITY_MATRIX.slice();
  18984. break;
  18985. case _util.OPS.showSpacedText:
  18986. if (!stateManager.state.font) {
  18987. self.ensureStateFont(stateManager.state);
  18988. continue;
  18989. }
  18990. var items = args[0];
  18991. var offset;
  18992. for (var j = 0, jj = items.length; j < jj; j++) {
  18993. if (typeof items[j] === "string") {
  18994. buildTextContentItem(items[j]);
  18995. } else if ((0, _util.isNum)(items[j])) {
  18996. ensureTextContentItem();
  18997. advance = items[j] * textState.fontSize / 1000;
  18998. var breakTextRun = false;
  18999. if (textState.font.vertical) {
  19000. offset = advance;
  19001. textState.translateTextMatrix(0, offset);
  19002. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  19003. if (!breakTextRun) {
  19004. textContentItem.height += offset;
  19005. }
  19006. } else {
  19007. advance = -advance;
  19008. offset = advance * textState.textHScale;
  19009. textState.translateTextMatrix(offset, 0);
  19010. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  19011. if (!breakTextRun) {
  19012. textContentItem.width += offset;
  19013. }
  19014. }
  19015. if (breakTextRun) {
  19016. flushTextContentItem();
  19017. } else if (advance > 0) {
  19018. addFakeSpaces(advance, textContentItem.str);
  19019. }
  19020. }
  19021. }
  19022. break;
  19023. case _util.OPS.showText:
  19024. if (!stateManager.state.font) {
  19025. self.ensureStateFont(stateManager.state);
  19026. continue;
  19027. }
  19028. buildTextContentItem(args[0]);
  19029. break;
  19030. case _util.OPS.nextLineShowText:
  19031. if (!stateManager.state.font) {
  19032. self.ensureStateFont(stateManager.state);
  19033. continue;
  19034. }
  19035. flushTextContentItem();
  19036. textState.carriageReturn();
  19037. buildTextContentItem(args[0]);
  19038. break;
  19039. case _util.OPS.nextLineSetSpacingShowText:
  19040. if (!stateManager.state.font) {
  19041. self.ensureStateFont(stateManager.state);
  19042. continue;
  19043. }
  19044. flushTextContentItem();
  19045. textState.wordSpacing = args[0];
  19046. textState.charSpacing = args[1];
  19047. textState.carriageReturn();
  19048. buildTextContentItem(args[2]);
  19049. break;
  19050. case _util.OPS.paintXObject:
  19051. flushTextContentItem();
  19052. if (!xobjs) {
  19053. xobjs = resources.get("XObject") || _primitives.Dict.empty;
  19054. }
  19055. var name = args[0].name;
  19056. if (name && emptyXObjectCache.getByName(name)) {
  19057. break;
  19058. }
  19059. next(new Promise(function (resolveXObject, rejectXObject) {
  19060. if (!name) {
  19061. throw new _util.FormatError("XObject must be referred to by name.");
  19062. }
  19063. let xobj = xobjs.getRaw(name);
  19064. if (xobj instanceof _primitives.Ref) {
  19065. if (emptyXObjectCache.getByRef(xobj)) {
  19066. resolveXObject();
  19067. return;
  19068. }
  19069. xobj = xref.fetch(xobj);
  19070. }
  19071. if (!(0, _primitives.isStream)(xobj)) {
  19072. throw new _util.FormatError("XObject should be a stream");
  19073. }
  19074. const type = xobj.dict.get("Subtype");
  19075. if (!(0, _primitives.isName)(type)) {
  19076. throw new _util.FormatError("XObject should have a Name subtype");
  19077. }
  19078. if (type.name !== "Form") {
  19079. emptyXObjectCache.set(name, xobj.dict.objId, true);
  19080. resolveXObject();
  19081. return;
  19082. }
  19083. const currentState = stateManager.state.clone();
  19084. const xObjStateManager = new StateManager(currentState);
  19085. const matrix = xobj.dict.getArray("Matrix");
  19086. if (Array.isArray(matrix) && matrix.length === 6) {
  19087. xObjStateManager.transform(matrix);
  19088. }
  19089. enqueueChunk();
  19090. const sinkWrapper = {
  19091. enqueueInvoked: false,
  19092. enqueue(chunk, size) {
  19093. this.enqueueInvoked = true;
  19094. sink.enqueue(chunk, size);
  19095. },
  19096. get desiredSize() {
  19097. return sink.desiredSize;
  19098. },
  19099. get ready() {
  19100. return sink.ready;
  19101. }
  19102. };
  19103. self.getTextContent({
  19104. stream: xobj,
  19105. task,
  19106. resources: xobj.dict.get("Resources") || resources,
  19107. stateManager: xObjStateManager,
  19108. normalizeWhitespace,
  19109. combineTextItems,
  19110. sink: sinkWrapper,
  19111. seenStyles
  19112. }).then(function () {
  19113. if (!sinkWrapper.enqueueInvoked) {
  19114. emptyXObjectCache.set(name, xobj.dict.objId, true);
  19115. }
  19116. resolveXObject();
  19117. }, rejectXObject);
  19118. }).catch(function (reason) {
  19119. if (reason instanceof _util.AbortException) {
  19120. return;
  19121. }
  19122. if (self.options.ignoreErrors) {
  19123. (0, _util.warn)(`getTextContent - ignoring XObject: "${reason}".`);
  19124. return;
  19125. }
  19126. throw reason;
  19127. }));
  19128. return;
  19129. case _util.OPS.setGState:
  19130. name = args[0].name;
  19131. if (name && emptyGStateCache.getByName(name)) {
  19132. break;
  19133. }
  19134. next(new Promise(function (resolveGState, rejectGState) {
  19135. if (!name) {
  19136. throw new _util.FormatError("GState must be referred to by name.");
  19137. }
  19138. const extGState = resources.get("ExtGState");
  19139. if (!(extGState instanceof _primitives.Dict)) {
  19140. throw new _util.FormatError("ExtGState should be a dictionary.");
  19141. }
  19142. const gState = extGState.get(name);
  19143. if (!(gState instanceof _primitives.Dict)) {
  19144. throw new _util.FormatError("GState should be a dictionary.");
  19145. }
  19146. const gStateFont = gState.get("Font");
  19147. if (!gStateFont) {
  19148. emptyGStateCache.set(name, gState.objId, true);
  19149. resolveGState();
  19150. return;
  19151. }
  19152. flushTextContentItem();
  19153. textState.fontName = null;
  19154. textState.fontSize = gStateFont[1];
  19155. handleSetFont(null, gStateFont[0]).then(resolveGState, rejectGState);
  19156. }).catch(function (reason) {
  19157. if (reason instanceof _util.AbortException) {
  19158. return;
  19159. }
  19160. if (self.options.ignoreErrors) {
  19161. (0, _util.warn)(`getTextContent - ignoring ExtGState: "${reason}".`);
  19162. return;
  19163. }
  19164. throw reason;
  19165. }));
  19166. return;
  19167. }
  19168. if (textContent.items.length >= sink.desiredSize) {
  19169. stop = true;
  19170. break;
  19171. }
  19172. }
  19173. if (stop) {
  19174. next(deferred);
  19175. return;
  19176. }
  19177. flushTextContentItem();
  19178. enqueueChunk();
  19179. resolve();
  19180. }).catch(reason => {
  19181. if (reason instanceof _util.AbortException) {
  19182. return;
  19183. }
  19184. if (this.options.ignoreErrors) {
  19185. (0, _util.warn)(`getTextContent - ignoring errors during "${task.name}" ` + `task: "${reason}".`);
  19186. flushTextContentItem();
  19187. enqueueChunk();
  19188. return;
  19189. }
  19190. throw reason;
  19191. });
  19192. }
  19193. extractDataStructures(dict, baseDict, properties) {
  19194. const xref = this.xref;
  19195. let cidToGidBytes;
  19196. var toUnicode = dict.get("ToUnicode") || baseDict.get("ToUnicode");
  19197. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  19198. if (properties.composite) {
  19199. var cidSystemInfo = dict.get("CIDSystemInfo");
  19200. if ((0, _primitives.isDict)(cidSystemInfo)) {
  19201. properties.cidSystemInfo = {
  19202. registry: (0, _util.stringToPDFString)(cidSystemInfo.get("Registry")),
  19203. ordering: (0, _util.stringToPDFString)(cidSystemInfo.get("Ordering")),
  19204. supplement: cidSystemInfo.get("Supplement")
  19205. };
  19206. }
  19207. var cidToGidMap = dict.get("CIDToGIDMap");
  19208. if ((0, _primitives.isStream)(cidToGidMap)) {
  19209. cidToGidBytes = cidToGidMap.getBytes();
  19210. }
  19211. }
  19212. var differences = [];
  19213. var baseEncodingName = null;
  19214. var encoding;
  19215. if (dict.has("Encoding")) {
  19216. encoding = dict.get("Encoding");
  19217. if ((0, _primitives.isDict)(encoding)) {
  19218. baseEncodingName = encoding.get("BaseEncoding");
  19219. baseEncodingName = (0, _primitives.isName)(baseEncodingName) ? baseEncodingName.name : null;
  19220. if (encoding.has("Differences")) {
  19221. var diffEncoding = encoding.get("Differences");
  19222. var index = 0;
  19223. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  19224. var data = xref.fetchIfRef(diffEncoding[j]);
  19225. if ((0, _util.isNum)(data)) {
  19226. index = data;
  19227. } else if ((0, _primitives.isName)(data)) {
  19228. differences[index++] = data.name;
  19229. } else {
  19230. throw new _util.FormatError(`Invalid entry in 'Differences' array: ${data}`);
  19231. }
  19232. }
  19233. }
  19234. } else if ((0, _primitives.isName)(encoding)) {
  19235. baseEncodingName = encoding.name;
  19236. } else {
  19237. throw new _util.FormatError("Encoding is not a Name nor a Dict");
  19238. }
  19239. if (baseEncodingName !== "MacRomanEncoding" && baseEncodingName !== "MacExpertEncoding" && baseEncodingName !== "WinAnsiEncoding") {
  19240. baseEncodingName = null;
  19241. }
  19242. }
  19243. if (baseEncodingName) {
  19244. properties.defaultEncoding = (0, _encodings.getEncoding)(baseEncodingName).slice();
  19245. } else {
  19246. var isSymbolicFont = !!(properties.flags & _fonts.FontFlags.Symbolic);
  19247. var isNonsymbolicFont = !!(properties.flags & _fonts.FontFlags.Nonsymbolic);
  19248. encoding = _encodings.StandardEncoding;
  19249. if (properties.type === "TrueType" && !isNonsymbolicFont) {
  19250. encoding = _encodings.WinAnsiEncoding;
  19251. }
  19252. if (isSymbolicFont) {
  19253. encoding = _encodings.MacRomanEncoding;
  19254. if (!properties.file) {
  19255. if (/Symbol/i.test(properties.name)) {
  19256. encoding = _encodings.SymbolSetEncoding;
  19257. } else if (/Dingbats|Wingdings/i.test(properties.name)) {
  19258. encoding = _encodings.ZapfDingbatsEncoding;
  19259. }
  19260. }
  19261. }
  19262. properties.defaultEncoding = encoding;
  19263. }
  19264. properties.differences = differences;
  19265. properties.baseEncodingName = baseEncodingName;
  19266. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  19267. properties.dict = dict;
  19268. return toUnicodePromise.then(readToUnicode => {
  19269. properties.toUnicode = readToUnicode;
  19270. return this.buildToUnicode(properties);
  19271. }).then(builtToUnicode => {
  19272. properties.toUnicode = builtToUnicode;
  19273. if (cidToGidBytes) {
  19274. properties.cidToGidMap = this.readCidToGidMap(cidToGidBytes, builtToUnicode);
  19275. }
  19276. return properties;
  19277. });
  19278. }
  19279. _buildSimpleFontToUnicode(properties, forceGlyphs = false) {
  19280. (0, _util.assert)(!properties.composite, "Must be a simple font.");
  19281. const toUnicode = [];
  19282. const encoding = properties.defaultEncoding.slice();
  19283. const baseEncodingName = properties.baseEncodingName;
  19284. const differences = properties.differences;
  19285. for (const charcode in differences) {
  19286. const glyphName = differences[charcode];
  19287. if (glyphName === ".notdef") {
  19288. continue;
  19289. }
  19290. encoding[charcode] = glyphName;
  19291. }
  19292. const glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  19293. for (const charcode in encoding) {
  19294. let glyphName = encoding[charcode];
  19295. if (glyphName === "") {
  19296. continue;
  19297. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  19298. let code = 0;
  19299. switch (glyphName[0]) {
  19300. case "G":
  19301. if (glyphName.length === 3) {
  19302. code = parseInt(glyphName.substring(1), 16);
  19303. }
  19304. break;
  19305. case "g":
  19306. if (glyphName.length === 5) {
  19307. code = parseInt(glyphName.substring(1), 16);
  19308. }
  19309. break;
  19310. case "C":
  19311. case "c":
  19312. if (glyphName.length >= 3 && glyphName.length <= 4) {
  19313. const codeStr = glyphName.substring(1);
  19314. if (forceGlyphs) {
  19315. code = parseInt(codeStr, 16);
  19316. break;
  19317. }
  19318. code = +codeStr;
  19319. if (Number.isNaN(code) && Number.isInteger(parseInt(codeStr, 16))) {
  19320. return this._buildSimpleFontToUnicode(properties, true);
  19321. }
  19322. }
  19323. break;
  19324. default:
  19325. const unicode = (0, _unicode.getUnicodeForGlyph)(glyphName, glyphsUnicodeMap);
  19326. if (unicode !== -1) {
  19327. code = unicode;
  19328. }
  19329. }
  19330. if (code > 0 && code <= 0x10ffff && Number.isInteger(code)) {
  19331. if (baseEncodingName && code === +charcode) {
  19332. const baseEncoding = (0, _encodings.getEncoding)(baseEncodingName);
  19333. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  19334. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  19335. continue;
  19336. }
  19337. }
  19338. toUnicode[charcode] = String.fromCodePoint(code);
  19339. }
  19340. continue;
  19341. }
  19342. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  19343. }
  19344. return new _fonts.ToUnicodeMap(toUnicode);
  19345. }
  19346. buildToUnicode(properties) {
  19347. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  19348. if (properties.hasIncludedToUnicodeMap) {
  19349. if (!properties.composite && properties.hasEncoding) {
  19350. properties.fallbackToUnicode = this._buildSimpleFontToUnicode(properties);
  19351. }
  19352. return Promise.resolve(properties.toUnicode);
  19353. }
  19354. if (!properties.composite) {
  19355. return Promise.resolve(this._buildSimpleFontToUnicode(properties));
  19356. }
  19357. if (properties.composite && (properties.cMap.builtInCMap && !(properties.cMap instanceof _cmap.IdentityCMap) || properties.cidSystemInfo.registry === "Adobe" && (properties.cidSystemInfo.ordering === "GB1" || properties.cidSystemInfo.ordering === "CNS1" || properties.cidSystemInfo.ordering === "Japan1" || properties.cidSystemInfo.ordering === "Korea1"))) {
  19358. const registry = properties.cidSystemInfo.registry;
  19359. const ordering = properties.cidSystemInfo.ordering;
  19360. const ucs2CMapName = _primitives.Name.get(registry + "-" + ordering + "-UCS2");
  19361. return _cmap.CMapFactory.create({
  19362. encoding: ucs2CMapName,
  19363. fetchBuiltInCMap: this._fetchBuiltInCMapBound,
  19364. useCMap: null
  19365. }).then(function (ucs2CMap) {
  19366. const cMap = properties.cMap;
  19367. const toUnicode = [];
  19368. cMap.forEach(function (charcode, cid) {
  19369. if (cid > 0xffff) {
  19370. throw new _util.FormatError("Max size of CID is 65,535");
  19371. }
  19372. const ucs2 = ucs2CMap.lookup(cid);
  19373. if (ucs2) {
  19374. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  19375. }
  19376. });
  19377. return new _fonts.ToUnicodeMap(toUnicode);
  19378. });
  19379. }
  19380. return Promise.resolve(new _fonts.IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  19381. }
  19382. readToUnicode(toUnicode) {
  19383. var cmapObj = toUnicode;
  19384. if ((0, _primitives.isName)(cmapObj)) {
  19385. return _cmap.CMapFactory.create({
  19386. encoding: cmapObj,
  19387. fetchBuiltInCMap: this._fetchBuiltInCMapBound,
  19388. useCMap: null
  19389. }).then(function (cmap) {
  19390. if (cmap instanceof _cmap.IdentityCMap) {
  19391. return new _fonts.IdentityToUnicodeMap(0, 0xffff);
  19392. }
  19393. return new _fonts.ToUnicodeMap(cmap.getMap());
  19394. });
  19395. } else if ((0, _primitives.isStream)(cmapObj)) {
  19396. return _cmap.CMapFactory.create({
  19397. encoding: cmapObj,
  19398. fetchBuiltInCMap: this._fetchBuiltInCMapBound,
  19399. useCMap: null
  19400. }).then(function (cmap) {
  19401. if (cmap instanceof _cmap.IdentityCMap) {
  19402. return new _fonts.IdentityToUnicodeMap(0, 0xffff);
  19403. }
  19404. var map = new Array(cmap.length);
  19405. cmap.forEach(function (charCode, token) {
  19406. var str = [];
  19407. for (var k = 0; k < token.length; k += 2) {
  19408. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  19409. if ((w1 & 0xf800) !== 0xd800) {
  19410. str.push(w1);
  19411. continue;
  19412. }
  19413. k += 2;
  19414. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  19415. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  19416. }
  19417. map[charCode] = String.fromCodePoint.apply(String, str);
  19418. });
  19419. return new _fonts.ToUnicodeMap(map);
  19420. }, reason => {
  19421. if (reason instanceof _util.AbortException) {
  19422. return null;
  19423. }
  19424. if (this.options.ignoreErrors) {
  19425. this.handler.send("UnsupportedFeature", {
  19426. featureId: _util.UNSUPPORTED_FEATURES.errorFontToUnicode
  19427. });
  19428. (0, _util.warn)(`readToUnicode - ignoring ToUnicode data: "${reason}".`);
  19429. return null;
  19430. }
  19431. throw reason;
  19432. });
  19433. }
  19434. return Promise.resolve(null);
  19435. }
  19436. readCidToGidMap(glyphsData, toUnicode) {
  19437. var result = [];
  19438. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  19439. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  19440. const code = j >> 1;
  19441. if (glyphID === 0 && !toUnicode.has(code)) {
  19442. continue;
  19443. }
  19444. result[code] = glyphID;
  19445. }
  19446. return result;
  19447. }
  19448. extractWidths(dict, descriptor, properties) {
  19449. var xref = this.xref;
  19450. var glyphsWidths = [];
  19451. var defaultWidth = 0;
  19452. var glyphsVMetrics = [];
  19453. var defaultVMetrics;
  19454. var i, ii, j, jj, start, code, widths;
  19455. if (properties.composite) {
  19456. defaultWidth = dict.has("DW") ? dict.get("DW") : 1000;
  19457. widths = dict.get("W");
  19458. if (widths) {
  19459. for (i = 0, ii = widths.length; i < ii; i++) {
  19460. start = xref.fetchIfRef(widths[i++]);
  19461. code = xref.fetchIfRef(widths[i]);
  19462. if (Array.isArray(code)) {
  19463. for (j = 0, jj = code.length; j < jj; j++) {
  19464. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  19465. }
  19466. } else {
  19467. var width = xref.fetchIfRef(widths[++i]);
  19468. for (j = start; j <= code; j++) {
  19469. glyphsWidths[j] = width;
  19470. }
  19471. }
  19472. }
  19473. }
  19474. if (properties.vertical) {
  19475. var vmetrics = dict.getArray("DW2") || [880, -1000];
  19476. defaultVMetrics = [vmetrics[1], defaultWidth * 0.5, vmetrics[0]];
  19477. vmetrics = dict.get("W2");
  19478. if (vmetrics) {
  19479. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  19480. start = xref.fetchIfRef(vmetrics[i++]);
  19481. code = xref.fetchIfRef(vmetrics[i]);
  19482. if (Array.isArray(code)) {
  19483. for (j = 0, jj = code.length; j < jj; j++) {
  19484. glyphsVMetrics[start++] = [xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j])];
  19485. }
  19486. } else {
  19487. var vmetric = [xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i])];
  19488. for (j = start; j <= code; j++) {
  19489. glyphsVMetrics[j] = vmetric;
  19490. }
  19491. }
  19492. }
  19493. }
  19494. }
  19495. } else {
  19496. var firstChar = properties.firstChar;
  19497. widths = dict.get("Widths");
  19498. if (widths) {
  19499. j = firstChar;
  19500. for (i = 0, ii = widths.length; i < ii; i++) {
  19501. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  19502. }
  19503. defaultWidth = parseFloat(descriptor.get("MissingWidth")) || 0;
  19504. } else {
  19505. var baseFontName = dict.get("BaseFont");
  19506. if ((0, _primitives.isName)(baseFontName)) {
  19507. var metrics = this.getBaseFontMetrics(baseFontName.name);
  19508. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  19509. defaultWidth = metrics.defaultWidth;
  19510. }
  19511. }
  19512. }
  19513. var isMonospace = true;
  19514. var firstWidth = defaultWidth;
  19515. for (var glyph in glyphsWidths) {
  19516. var glyphWidth = glyphsWidths[glyph];
  19517. if (!glyphWidth) {
  19518. continue;
  19519. }
  19520. if (!firstWidth) {
  19521. firstWidth = glyphWidth;
  19522. continue;
  19523. }
  19524. if (firstWidth !== glyphWidth) {
  19525. isMonospace = false;
  19526. break;
  19527. }
  19528. }
  19529. if (isMonospace) {
  19530. properties.flags |= _fonts.FontFlags.FixedPitch;
  19531. }
  19532. properties.defaultWidth = defaultWidth;
  19533. properties.widths = glyphsWidths;
  19534. properties.defaultVMetrics = defaultVMetrics;
  19535. properties.vmetrics = glyphsVMetrics;
  19536. }
  19537. isSerifFont(baseFontName) {
  19538. var fontNameWoStyle = baseFontName.split("-")[0];
  19539. return fontNameWoStyle in (0, _standard_fonts.getSerifFonts)() || fontNameWoStyle.search(/serif/gi) !== -1;
  19540. }
  19541. getBaseFontMetrics(name) {
  19542. var defaultWidth = 0;
  19543. var widths = [];
  19544. var monospace = false;
  19545. var stdFontMap = (0, _standard_fonts.getStdFontMap)();
  19546. var lookupName = stdFontMap[name] || name;
  19547. var Metrics = (0, _metrics.getMetrics)();
  19548. if (!(lookupName in Metrics)) {
  19549. if (this.isSerifFont(name)) {
  19550. lookupName = "Times-Roman";
  19551. } else {
  19552. lookupName = "Helvetica";
  19553. }
  19554. }
  19555. var glyphWidths = Metrics[lookupName];
  19556. if ((0, _util.isNum)(glyphWidths)) {
  19557. defaultWidth = glyphWidths;
  19558. monospace = true;
  19559. } else {
  19560. widths = glyphWidths();
  19561. }
  19562. return {
  19563. defaultWidth,
  19564. monospace,
  19565. widths
  19566. };
  19567. }
  19568. buildCharCodeToWidth(widthsByGlyphName, properties) {
  19569. var widths = Object.create(null);
  19570. var differences = properties.differences;
  19571. var encoding = properties.defaultEncoding;
  19572. for (var charCode = 0; charCode < 256; charCode++) {
  19573. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  19574. widths[charCode] = widthsByGlyphName[differences[charCode]];
  19575. continue;
  19576. }
  19577. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  19578. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  19579. continue;
  19580. }
  19581. }
  19582. return widths;
  19583. }
  19584. preEvaluateFont(dict) {
  19585. var baseDict = dict;
  19586. var type = dict.get("Subtype");
  19587. if (!(0, _primitives.isName)(type)) {
  19588. throw new _util.FormatError("invalid font Subtype");
  19589. }
  19590. var composite = false;
  19591. var uint8array;
  19592. if (type.name === "Type0") {
  19593. var df = dict.get("DescendantFonts");
  19594. if (!df) {
  19595. throw new _util.FormatError("Descendant fonts are not specified");
  19596. }
  19597. dict = Array.isArray(df) ? this.xref.fetchIfRef(df[0]) : df;
  19598. type = dict.get("Subtype");
  19599. if (!(0, _primitives.isName)(type)) {
  19600. throw new _util.FormatError("invalid font Subtype");
  19601. }
  19602. composite = true;
  19603. }
  19604. var descriptor = dict.get("FontDescriptor");
  19605. if (descriptor) {
  19606. var hash = new _murmurhash.MurmurHash3_64();
  19607. var encoding = baseDict.getRaw("Encoding");
  19608. if ((0, _primitives.isName)(encoding)) {
  19609. hash.update(encoding.name);
  19610. } else if ((0, _primitives.isRef)(encoding)) {
  19611. hash.update(encoding.toString());
  19612. } else if ((0, _primitives.isDict)(encoding)) {
  19613. for (const entry of encoding.getRawValues()) {
  19614. if ((0, _primitives.isName)(entry)) {
  19615. hash.update(entry.name);
  19616. } else if ((0, _primitives.isRef)(entry)) {
  19617. hash.update(entry.toString());
  19618. } else if (Array.isArray(entry)) {
  19619. var diffLength = entry.length,
  19620. diffBuf = new Array(diffLength);
  19621. for (var j = 0; j < diffLength; j++) {
  19622. var diffEntry = entry[j];
  19623. if ((0, _primitives.isName)(diffEntry)) {
  19624. diffBuf[j] = diffEntry.name;
  19625. } else if ((0, _util.isNum)(diffEntry) || (0, _primitives.isRef)(diffEntry)) {
  19626. diffBuf[j] = diffEntry.toString();
  19627. }
  19628. }
  19629. hash.update(diffBuf.join());
  19630. }
  19631. }
  19632. }
  19633. const firstChar = dict.get("FirstChar") || 0;
  19634. const lastChar = dict.get("LastChar") || (composite ? 0xffff : 0xff);
  19635. hash.update(`${firstChar}-${lastChar}`);
  19636. var toUnicode = dict.get("ToUnicode") || baseDict.get("ToUnicode");
  19637. if ((0, _primitives.isStream)(toUnicode)) {
  19638. var stream = toUnicode.str || toUnicode;
  19639. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  19640. hash.update(uint8array);
  19641. } else if ((0, _primitives.isName)(toUnicode)) {
  19642. hash.update(toUnicode.name);
  19643. }
  19644. var widths = dict.get("Widths") || baseDict.get("Widths");
  19645. if (widths) {
  19646. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  19647. hash.update(uint8array);
  19648. }
  19649. }
  19650. return {
  19651. descriptor,
  19652. dict,
  19653. baseDict,
  19654. composite,
  19655. type: type.name,
  19656. hash: hash ? hash.hexdigest() : ""
  19657. };
  19658. }
  19659. translateFont(preEvaluatedFont) {
  19660. var baseDict = preEvaluatedFont.baseDict;
  19661. var dict = preEvaluatedFont.dict;
  19662. var composite = preEvaluatedFont.composite;
  19663. var descriptor = preEvaluatedFont.descriptor;
  19664. var type = preEvaluatedFont.type;
  19665. var maxCharIndex = composite ? 0xffff : 0xff;
  19666. var properties;
  19667. const firstChar = dict.get("FirstChar") || 0;
  19668. const lastChar = dict.get("LastChar") || maxCharIndex;
  19669. if (!descriptor) {
  19670. if (type === "Type3") {
  19671. descriptor = new _primitives.Dict(null);
  19672. descriptor.set("FontName", _primitives.Name.get(type));
  19673. descriptor.set("FontBBox", dict.getArray("FontBBox") || [0, 0, 0, 0]);
  19674. } else {
  19675. var baseFontName = dict.get("BaseFont");
  19676. if (!(0, _primitives.isName)(baseFontName)) {
  19677. throw new _util.FormatError("Base font is not specified");
  19678. }
  19679. baseFontName = baseFontName.name.replace(/[,_]/g, "-");
  19680. var metrics = this.getBaseFontMetrics(baseFontName);
  19681. var fontNameWoStyle = baseFontName.split("-")[0];
  19682. var flags = (this.isSerifFont(fontNameWoStyle) ? _fonts.FontFlags.Serif : 0) | (metrics.monospace ? _fonts.FontFlags.FixedPitch : 0) | ((0, _standard_fonts.getSymbolsFonts)()[fontNameWoStyle] ? _fonts.FontFlags.Symbolic : _fonts.FontFlags.Nonsymbolic);
  19683. properties = {
  19684. type,
  19685. name: baseFontName,
  19686. widths: metrics.widths,
  19687. defaultWidth: metrics.defaultWidth,
  19688. flags,
  19689. firstChar,
  19690. lastChar
  19691. };
  19692. const widths = dict.get("Widths");
  19693. return this.extractDataStructures(dict, dict, properties).then(newProperties => {
  19694. if (widths) {
  19695. const glyphWidths = [];
  19696. let j = firstChar;
  19697. for (let i = 0, ii = widths.length; i < ii; i++) {
  19698. glyphWidths[j++] = this.xref.fetchIfRef(widths[i]);
  19699. }
  19700. newProperties.widths = glyphWidths;
  19701. } else {
  19702. newProperties.widths = this.buildCharCodeToWidth(metrics.widths, newProperties);
  19703. }
  19704. return new _fonts.Font(baseFontName, null, newProperties);
  19705. });
  19706. }
  19707. }
  19708. var fontName = descriptor.get("FontName");
  19709. var baseFont = dict.get("BaseFont");
  19710. if ((0, _util.isString)(fontName)) {
  19711. fontName = _primitives.Name.get(fontName);
  19712. }
  19713. if ((0, _util.isString)(baseFont)) {
  19714. baseFont = _primitives.Name.get(baseFont);
  19715. }
  19716. if (type !== "Type3") {
  19717. var fontNameStr = fontName && fontName.name;
  19718. var baseFontStr = baseFont && baseFont.name;
  19719. if (fontNameStr !== baseFontStr) {
  19720. (0, _util.info)(`The FontDescriptor\'s FontName is "${fontNameStr}" but ` + `should be the same as the Font\'s BaseFont "${baseFontStr}".`);
  19721. if (fontNameStr && baseFontStr && baseFontStr.startsWith(fontNameStr)) {
  19722. fontName = baseFont;
  19723. }
  19724. }
  19725. }
  19726. fontName = fontName || baseFont;
  19727. if (!(0, _primitives.isName)(fontName)) {
  19728. throw new _util.FormatError("invalid font name");
  19729. }
  19730. var fontFile = descriptor.get("FontFile", "FontFile2", "FontFile3");
  19731. if (fontFile) {
  19732. if (fontFile.dict) {
  19733. var subtype = fontFile.dict.get("Subtype");
  19734. if (subtype) {
  19735. subtype = subtype.name;
  19736. }
  19737. var length1 = fontFile.dict.get("Length1");
  19738. var length2 = fontFile.dict.get("Length2");
  19739. var length3 = fontFile.dict.get("Length3");
  19740. }
  19741. }
  19742. properties = {
  19743. type,
  19744. name: fontName.name,
  19745. subtype,
  19746. file: fontFile,
  19747. length1,
  19748. length2,
  19749. length3,
  19750. loadedName: baseDict.loadedName,
  19751. composite,
  19752. fixedPitch: false,
  19753. fontMatrix: dict.getArray("FontMatrix") || _util.FONT_IDENTITY_MATRIX,
  19754. firstChar: firstChar || 0,
  19755. lastChar: lastChar || maxCharIndex,
  19756. bbox: descriptor.getArray("FontBBox"),
  19757. ascent: descriptor.get("Ascent"),
  19758. descent: descriptor.get("Descent"),
  19759. xHeight: descriptor.get("XHeight"),
  19760. capHeight: descriptor.get("CapHeight"),
  19761. flags: descriptor.get("Flags"),
  19762. italicAngle: descriptor.get("ItalicAngle"),
  19763. isType3Font: false
  19764. };
  19765. var cMapPromise;
  19766. if (composite) {
  19767. var cidEncoding = baseDict.get("Encoding");
  19768. if ((0, _primitives.isName)(cidEncoding)) {
  19769. properties.cidEncoding = cidEncoding.name;
  19770. }
  19771. cMapPromise = _cmap.CMapFactory.create({
  19772. encoding: cidEncoding,
  19773. fetchBuiltInCMap: this._fetchBuiltInCMapBound,
  19774. useCMap: null
  19775. }).then(function (cMap) {
  19776. properties.cMap = cMap;
  19777. properties.vertical = properties.cMap.vertical;
  19778. });
  19779. } else {
  19780. cMapPromise = Promise.resolve(undefined);
  19781. }
  19782. return cMapPromise.then(() => {
  19783. return this.extractDataStructures(dict, baseDict, properties);
  19784. }).then(newProperties => {
  19785. this.extractWidths(dict, descriptor, newProperties);
  19786. if (type === "Type3") {
  19787. newProperties.isType3Font = true;
  19788. }
  19789. return new _fonts.Font(fontName.name, fontFile, newProperties);
  19790. });
  19791. }
  19792. static buildFontPaths(font, glyphs, handler) {
  19793. function buildPath(fontChar) {
  19794. if (font.renderer.hasBuiltPath(fontChar)) {
  19795. return;
  19796. }
  19797. handler.send("commonobj", [`${font.loadedName}_path_${fontChar}`, "FontPath", font.renderer.getPathJs(fontChar)]);
  19798. }
  19799. for (const glyph of glyphs) {
  19800. buildPath(glyph.fontChar);
  19801. const accent = glyph.accent;
  19802. if (accent && accent.fontChar) {
  19803. buildPath(accent.fontChar);
  19804. }
  19805. }
  19806. }
  19807. static get fallbackFontDict() {
  19808. const dict = new _primitives.Dict();
  19809. dict.set("BaseFont", _primitives.Name.get("PDFJS-FallbackFont"));
  19810. dict.set("Type", _primitives.Name.get("FallbackType"));
  19811. dict.set("Subtype", _primitives.Name.get("FallbackType"));
  19812. dict.set("Encoding", _primitives.Name.get("WinAnsiEncoding"));
  19813. return (0, _util.shadow)(this, "fallbackFontDict", dict);
  19814. }
  19815. }
  19816. exports.PartialEvaluator = PartialEvaluator;
  19817. class TranslatedFont {
  19818. constructor({
  19819. loadedName,
  19820. font,
  19821. dict,
  19822. extraProperties = false
  19823. }) {
  19824. this.loadedName = loadedName;
  19825. this.font = font;
  19826. this.dict = dict;
  19827. this._extraProperties = extraProperties;
  19828. this.type3Loaded = null;
  19829. this.type3Dependencies = font.isType3Font ? new Set() : null;
  19830. this.sent = false;
  19831. }
  19832. send(handler) {
  19833. if (this.sent) {
  19834. return;
  19835. }
  19836. this.sent = true;
  19837. handler.send("commonobj", [this.loadedName, "Font", this.font.exportData(this._extraProperties)]);
  19838. }
  19839. fallback(handler) {
  19840. if (!this.font.data) {
  19841. return;
  19842. }
  19843. this.font.disableFontFace = true;
  19844. const glyphs = this.font.glyphCacheValues;
  19845. PartialEvaluator.buildFontPaths(this.font, glyphs, handler);
  19846. }
  19847. loadType3Data(evaluator, resources, task) {
  19848. if (this.type3Loaded) {
  19849. return this.type3Loaded;
  19850. }
  19851. if (!this.font.isType3Font) {
  19852. throw new Error("Must be a Type3 font.");
  19853. }
  19854. var type3Options = Object.create(evaluator.options);
  19855. type3Options.ignoreErrors = false;
  19856. var type3Evaluator = evaluator.clone(type3Options);
  19857. type3Evaluator.parsingType3Font = true;
  19858. const translatedFont = this.font,
  19859. type3Dependencies = this.type3Dependencies;
  19860. var loadCharProcsPromise = Promise.resolve();
  19861. var charProcs = this.dict.get("CharProcs");
  19862. var fontResources = this.dict.get("Resources") || resources;
  19863. var charProcOperatorList = Object.create(null);
  19864. for (const key of charProcs.getKeys()) {
  19865. loadCharProcsPromise = loadCharProcsPromise.then(function () {
  19866. var glyphStream = charProcs.get(key);
  19867. var operatorList = new _operator_list.OperatorList();
  19868. return type3Evaluator.getOperatorList({
  19869. stream: glyphStream,
  19870. task,
  19871. resources: fontResources,
  19872. operatorList
  19873. }).then(function () {
  19874. charProcOperatorList[key] = operatorList.getIR();
  19875. for (const dependency of operatorList.dependencies) {
  19876. type3Dependencies.add(dependency);
  19877. }
  19878. }).catch(function (reason) {
  19879. (0, _util.warn)(`Type3 font resource "${key}" is not available.`);
  19880. const dummyOperatorList = new _operator_list.OperatorList();
  19881. charProcOperatorList[key] = dummyOperatorList.getIR();
  19882. });
  19883. });
  19884. }
  19885. this.type3Loaded = loadCharProcsPromise.then(function () {
  19886. translatedFont.charProcOperatorList = charProcOperatorList;
  19887. });
  19888. return this.type3Loaded;
  19889. }
  19890. }
  19891. class StateManager {
  19892. constructor(initialState) {
  19893. this.state = initialState;
  19894. this.stateStack = [];
  19895. }
  19896. save() {
  19897. var old = this.state;
  19898. this.stateStack.push(this.state);
  19899. this.state = old.clone();
  19900. }
  19901. restore() {
  19902. var prev = this.stateStack.pop();
  19903. if (prev) {
  19904. this.state = prev;
  19905. }
  19906. }
  19907. transform(args) {
  19908. this.state.ctm = _util.Util.transform(this.state.ctm, args);
  19909. }
  19910. }
  19911. class TextState {
  19912. constructor() {
  19913. this.ctm = new Float32Array(_util.IDENTITY_MATRIX);
  19914. this.fontName = null;
  19915. this.fontSize = 0;
  19916. this.font = null;
  19917. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  19918. this.textMatrix = _util.IDENTITY_MATRIX.slice();
  19919. this.textLineMatrix = _util.IDENTITY_MATRIX.slice();
  19920. this.charSpacing = 0;
  19921. this.wordSpacing = 0;
  19922. this.leading = 0;
  19923. this.textHScale = 1;
  19924. this.textRise = 0;
  19925. }
  19926. setTextMatrix(a, b, c, d, e, f) {
  19927. var m = this.textMatrix;
  19928. m[0] = a;
  19929. m[1] = b;
  19930. m[2] = c;
  19931. m[3] = d;
  19932. m[4] = e;
  19933. m[5] = f;
  19934. }
  19935. setTextLineMatrix(a, b, c, d, e, f) {
  19936. var m = this.textLineMatrix;
  19937. m[0] = a;
  19938. m[1] = b;
  19939. m[2] = c;
  19940. m[3] = d;
  19941. m[4] = e;
  19942. m[5] = f;
  19943. }
  19944. translateTextMatrix(x, y) {
  19945. var m = this.textMatrix;
  19946. m[4] = m[0] * x + m[2] * y + m[4];
  19947. m[5] = m[1] * x + m[3] * y + m[5];
  19948. }
  19949. translateTextLineMatrix(x, y) {
  19950. var m = this.textLineMatrix;
  19951. m[4] = m[0] * x + m[2] * y + m[4];
  19952. m[5] = m[1] * x + m[3] * y + m[5];
  19953. }
  19954. calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  19955. var font = this.font;
  19956. if (!font) {
  19957. return null;
  19958. }
  19959. var m = this.textLineMatrix;
  19960. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  19961. return null;
  19962. }
  19963. var txDiff = e - m[4],
  19964. tyDiff = f - m[5];
  19965. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  19966. return null;
  19967. }
  19968. var tx,
  19969. ty,
  19970. denominator = a * d - b * c;
  19971. if (font.vertical) {
  19972. tx = -tyDiff * c / denominator;
  19973. ty = tyDiff * a / denominator;
  19974. } else {
  19975. tx = txDiff * d / denominator;
  19976. ty = -txDiff * b / denominator;
  19977. }
  19978. return {
  19979. width: tx,
  19980. height: ty,
  19981. value: font.vertical ? ty : tx
  19982. };
  19983. }
  19984. calcRenderMatrix(ctm) {
  19985. var tsm = [this.fontSize * this.textHScale, 0, 0, this.fontSize, 0, this.textRise];
  19986. return _util.Util.transform(ctm, _util.Util.transform(this.textMatrix, tsm));
  19987. }
  19988. carriageReturn() {
  19989. this.translateTextLineMatrix(0, -this.leading);
  19990. this.textMatrix = this.textLineMatrix.slice();
  19991. }
  19992. clone() {
  19993. var clone = Object.create(this);
  19994. clone.textMatrix = this.textMatrix.slice();
  19995. clone.textLineMatrix = this.textLineMatrix.slice();
  19996. clone.fontMatrix = this.fontMatrix.slice();
  19997. return clone;
  19998. }
  19999. }
  20000. class EvalState {
  20001. constructor() {
  20002. this.ctm = new Float32Array(_util.IDENTITY_MATRIX);
  20003. this.font = null;
  20004. this.textRenderingMode = _util.TextRenderingMode.FILL;
  20005. this.fillColorSpace = _colorspace.ColorSpace.singletons.gray;
  20006. this.strokeColorSpace = _colorspace.ColorSpace.singletons.gray;
  20007. }
  20008. clone() {
  20009. return Object.create(this);
  20010. }
  20011. }
  20012. class EvaluatorPreprocessor {
  20013. static get opMap() {
  20014. const getOPMap = (0, _core_utils.getLookupTableFactory)(function (t) {
  20015. t.w = {
  20016. id: _util.OPS.setLineWidth,
  20017. numArgs: 1,
  20018. variableArgs: false
  20019. };
  20020. t.J = {
  20021. id: _util.OPS.setLineCap,
  20022. numArgs: 1,
  20023. variableArgs: false
  20024. };
  20025. t.j = {
  20026. id: _util.OPS.setLineJoin,
  20027. numArgs: 1,
  20028. variableArgs: false
  20029. };
  20030. t.M = {
  20031. id: _util.OPS.setMiterLimit,
  20032. numArgs: 1,
  20033. variableArgs: false
  20034. };
  20035. t.d = {
  20036. id: _util.OPS.setDash,
  20037. numArgs: 2,
  20038. variableArgs: false
  20039. };
  20040. t.ri = {
  20041. id: _util.OPS.setRenderingIntent,
  20042. numArgs: 1,
  20043. variableArgs: false
  20044. };
  20045. t.i = {
  20046. id: _util.OPS.setFlatness,
  20047. numArgs: 1,
  20048. variableArgs: false
  20049. };
  20050. t.gs = {
  20051. id: _util.OPS.setGState,
  20052. numArgs: 1,
  20053. variableArgs: false
  20054. };
  20055. t.q = {
  20056. id: _util.OPS.save,
  20057. numArgs: 0,
  20058. variableArgs: false
  20059. };
  20060. t.Q = {
  20061. id: _util.OPS.restore,
  20062. numArgs: 0,
  20063. variableArgs: false
  20064. };
  20065. t.cm = {
  20066. id: _util.OPS.transform,
  20067. numArgs: 6,
  20068. variableArgs: false
  20069. };
  20070. t.m = {
  20071. id: _util.OPS.moveTo,
  20072. numArgs: 2,
  20073. variableArgs: false
  20074. };
  20075. t.l = {
  20076. id: _util.OPS.lineTo,
  20077. numArgs: 2,
  20078. variableArgs: false
  20079. };
  20080. t.c = {
  20081. id: _util.OPS.curveTo,
  20082. numArgs: 6,
  20083. variableArgs: false
  20084. };
  20085. t.v = {
  20086. id: _util.OPS.curveTo2,
  20087. numArgs: 4,
  20088. variableArgs: false
  20089. };
  20090. t.y = {
  20091. id: _util.OPS.curveTo3,
  20092. numArgs: 4,
  20093. variableArgs: false
  20094. };
  20095. t.h = {
  20096. id: _util.OPS.closePath,
  20097. numArgs: 0,
  20098. variableArgs: false
  20099. };
  20100. t.re = {
  20101. id: _util.OPS.rectangle,
  20102. numArgs: 4,
  20103. variableArgs: false
  20104. };
  20105. t.S = {
  20106. id: _util.OPS.stroke,
  20107. numArgs: 0,
  20108. variableArgs: false
  20109. };
  20110. t.s = {
  20111. id: _util.OPS.closeStroke,
  20112. numArgs: 0,
  20113. variableArgs: false
  20114. };
  20115. t.f = {
  20116. id: _util.OPS.fill,
  20117. numArgs: 0,
  20118. variableArgs: false
  20119. };
  20120. t.F = {
  20121. id: _util.OPS.fill,
  20122. numArgs: 0,
  20123. variableArgs: false
  20124. };
  20125. t["f*"] = {
  20126. id: _util.OPS.eoFill,
  20127. numArgs: 0,
  20128. variableArgs: false
  20129. };
  20130. t.B = {
  20131. id: _util.OPS.fillStroke,
  20132. numArgs: 0,
  20133. variableArgs: false
  20134. };
  20135. t["B*"] = {
  20136. id: _util.OPS.eoFillStroke,
  20137. numArgs: 0,
  20138. variableArgs: false
  20139. };
  20140. t.b = {
  20141. id: _util.OPS.closeFillStroke,
  20142. numArgs: 0,
  20143. variableArgs: false
  20144. };
  20145. t["b*"] = {
  20146. id: _util.OPS.closeEOFillStroke,
  20147. numArgs: 0,
  20148. variableArgs: false
  20149. };
  20150. t.n = {
  20151. id: _util.OPS.endPath,
  20152. numArgs: 0,
  20153. variableArgs: false
  20154. };
  20155. t.W = {
  20156. id: _util.OPS.clip,
  20157. numArgs: 0,
  20158. variableArgs: false
  20159. };
  20160. t["W*"] = {
  20161. id: _util.OPS.eoClip,
  20162. numArgs: 0,
  20163. variableArgs: false
  20164. };
  20165. t.BT = {
  20166. id: _util.OPS.beginText,
  20167. numArgs: 0,
  20168. variableArgs: false
  20169. };
  20170. t.ET = {
  20171. id: _util.OPS.endText,
  20172. numArgs: 0,
  20173. variableArgs: false
  20174. };
  20175. t.Tc = {
  20176. id: _util.OPS.setCharSpacing,
  20177. numArgs: 1,
  20178. variableArgs: false
  20179. };
  20180. t.Tw = {
  20181. id: _util.OPS.setWordSpacing,
  20182. numArgs: 1,
  20183. variableArgs: false
  20184. };
  20185. t.Tz = {
  20186. id: _util.OPS.setHScale,
  20187. numArgs: 1,
  20188. variableArgs: false
  20189. };
  20190. t.TL = {
  20191. id: _util.OPS.setLeading,
  20192. numArgs: 1,
  20193. variableArgs: false
  20194. };
  20195. t.Tf = {
  20196. id: _util.OPS.setFont,
  20197. numArgs: 2,
  20198. variableArgs: false
  20199. };
  20200. t.Tr = {
  20201. id: _util.OPS.setTextRenderingMode,
  20202. numArgs: 1,
  20203. variableArgs: false
  20204. };
  20205. t.Ts = {
  20206. id: _util.OPS.setTextRise,
  20207. numArgs: 1,
  20208. variableArgs: false
  20209. };
  20210. t.Td = {
  20211. id: _util.OPS.moveText,
  20212. numArgs: 2,
  20213. variableArgs: false
  20214. };
  20215. t.TD = {
  20216. id: _util.OPS.setLeadingMoveText,
  20217. numArgs: 2,
  20218. variableArgs: false
  20219. };
  20220. t.Tm = {
  20221. id: _util.OPS.setTextMatrix,
  20222. numArgs: 6,
  20223. variableArgs: false
  20224. };
  20225. t["T*"] = {
  20226. id: _util.OPS.nextLine,
  20227. numArgs: 0,
  20228. variableArgs: false
  20229. };
  20230. t.Tj = {
  20231. id: _util.OPS.showText,
  20232. numArgs: 1,
  20233. variableArgs: false
  20234. };
  20235. t.TJ = {
  20236. id: _util.OPS.showSpacedText,
  20237. numArgs: 1,
  20238. variableArgs: false
  20239. };
  20240. t["'"] = {
  20241. id: _util.OPS.nextLineShowText,
  20242. numArgs: 1,
  20243. variableArgs: false
  20244. };
  20245. t['"'] = {
  20246. id: _util.OPS.nextLineSetSpacingShowText,
  20247. numArgs: 3,
  20248. variableArgs: false
  20249. };
  20250. t.d0 = {
  20251. id: _util.OPS.setCharWidth,
  20252. numArgs: 2,
  20253. variableArgs: false
  20254. };
  20255. t.d1 = {
  20256. id: _util.OPS.setCharWidthAndBounds,
  20257. numArgs: 6,
  20258. variableArgs: false
  20259. };
  20260. t.CS = {
  20261. id: _util.OPS.setStrokeColorSpace,
  20262. numArgs: 1,
  20263. variableArgs: false
  20264. };
  20265. t.cs = {
  20266. id: _util.OPS.setFillColorSpace,
  20267. numArgs: 1,
  20268. variableArgs: false
  20269. };
  20270. t.SC = {
  20271. id: _util.OPS.setStrokeColor,
  20272. numArgs: 4,
  20273. variableArgs: true
  20274. };
  20275. t.SCN = {
  20276. id: _util.OPS.setStrokeColorN,
  20277. numArgs: 33,
  20278. variableArgs: true
  20279. };
  20280. t.sc = {
  20281. id: _util.OPS.setFillColor,
  20282. numArgs: 4,
  20283. variableArgs: true
  20284. };
  20285. t.scn = {
  20286. id: _util.OPS.setFillColorN,
  20287. numArgs: 33,
  20288. variableArgs: true
  20289. };
  20290. t.G = {
  20291. id: _util.OPS.setStrokeGray,
  20292. numArgs: 1,
  20293. variableArgs: false
  20294. };
  20295. t.g = {
  20296. id: _util.OPS.setFillGray,
  20297. numArgs: 1,
  20298. variableArgs: false
  20299. };
  20300. t.RG = {
  20301. id: _util.OPS.setStrokeRGBColor,
  20302. numArgs: 3,
  20303. variableArgs: false
  20304. };
  20305. t.rg = {
  20306. id: _util.OPS.setFillRGBColor,
  20307. numArgs: 3,
  20308. variableArgs: false
  20309. };
  20310. t.K = {
  20311. id: _util.OPS.setStrokeCMYKColor,
  20312. numArgs: 4,
  20313. variableArgs: false
  20314. };
  20315. t.k = {
  20316. id: _util.OPS.setFillCMYKColor,
  20317. numArgs: 4,
  20318. variableArgs: false
  20319. };
  20320. t.sh = {
  20321. id: _util.OPS.shadingFill,
  20322. numArgs: 1,
  20323. variableArgs: false
  20324. };
  20325. t.BI = {
  20326. id: _util.OPS.beginInlineImage,
  20327. numArgs: 0,
  20328. variableArgs: false
  20329. };
  20330. t.ID = {
  20331. id: _util.OPS.beginImageData,
  20332. numArgs: 0,
  20333. variableArgs: false
  20334. };
  20335. t.EI = {
  20336. id: _util.OPS.endInlineImage,
  20337. numArgs: 1,
  20338. variableArgs: false
  20339. };
  20340. t.Do = {
  20341. id: _util.OPS.paintXObject,
  20342. numArgs: 1,
  20343. variableArgs: false
  20344. };
  20345. t.MP = {
  20346. id: _util.OPS.markPoint,
  20347. numArgs: 1,
  20348. variableArgs: false
  20349. };
  20350. t.DP = {
  20351. id: _util.OPS.markPointProps,
  20352. numArgs: 2,
  20353. variableArgs: false
  20354. };
  20355. t.BMC = {
  20356. id: _util.OPS.beginMarkedContent,
  20357. numArgs: 1,
  20358. variableArgs: false
  20359. };
  20360. t.BDC = {
  20361. id: _util.OPS.beginMarkedContentProps,
  20362. numArgs: 2,
  20363. variableArgs: false
  20364. };
  20365. t.EMC = {
  20366. id: _util.OPS.endMarkedContent,
  20367. numArgs: 0,
  20368. variableArgs: false
  20369. };
  20370. t.BX = {
  20371. id: _util.OPS.beginCompat,
  20372. numArgs: 0,
  20373. variableArgs: false
  20374. };
  20375. t.EX = {
  20376. id: _util.OPS.endCompat,
  20377. numArgs: 0,
  20378. variableArgs: false
  20379. };
  20380. t.BM = null;
  20381. t.BD = null;
  20382. t.true = null;
  20383. t.fa = null;
  20384. t.fal = null;
  20385. t.fals = null;
  20386. t.false = null;
  20387. t.nu = null;
  20388. t.nul = null;
  20389. t.null = null;
  20390. });
  20391. return (0, _util.shadow)(this, "opMap", getOPMap());
  20392. }
  20393. static get MAX_INVALID_PATH_OPS() {
  20394. return (0, _util.shadow)(this, "MAX_INVALID_PATH_OPS", 20);
  20395. }
  20396. constructor(stream, xref, stateManager) {
  20397. this.parser = new _parser.Parser({
  20398. lexer: new _parser.Lexer(stream, EvaluatorPreprocessor.opMap),
  20399. xref
  20400. });
  20401. this.stateManager = stateManager;
  20402. this.nonProcessedArgs = [];
  20403. this._numInvalidPathOPS = 0;
  20404. }
  20405. get savedStatesDepth() {
  20406. return this.stateManager.stateStack.length;
  20407. }
  20408. read(operation) {
  20409. var args = operation.args;
  20410. while (true) {
  20411. var obj = this.parser.getObj();
  20412. if (obj instanceof _primitives.Cmd) {
  20413. var cmd = obj.cmd;
  20414. var opSpec = EvaluatorPreprocessor.opMap[cmd];
  20415. if (!opSpec) {
  20416. (0, _util.warn)(`Unknown command "${cmd}".`);
  20417. continue;
  20418. }
  20419. var fn = opSpec.id;
  20420. var numArgs = opSpec.numArgs;
  20421. var argsLength = args !== null ? args.length : 0;
  20422. if (!opSpec.variableArgs) {
  20423. if (argsLength !== numArgs) {
  20424. var nonProcessedArgs = this.nonProcessedArgs;
  20425. while (argsLength > numArgs) {
  20426. nonProcessedArgs.push(args.shift());
  20427. argsLength--;
  20428. }
  20429. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  20430. if (args === null) {
  20431. args = [];
  20432. }
  20433. args.unshift(nonProcessedArgs.pop());
  20434. argsLength++;
  20435. }
  20436. }
  20437. if (argsLength < numArgs) {
  20438. const partialMsg = `command ${cmd}: expected ${numArgs} args, ` + `but received ${argsLength} args.`;
  20439. if (fn >= _util.OPS.moveTo && fn <= _util.OPS.endPath && ++this._numInvalidPathOPS > EvaluatorPreprocessor.MAX_INVALID_PATH_OPS) {
  20440. throw new _util.FormatError(`Invalid ${partialMsg}`);
  20441. }
  20442. (0, _util.warn)(`Skipping ${partialMsg}`);
  20443. if (args !== null) {
  20444. args.length = 0;
  20445. }
  20446. continue;
  20447. }
  20448. } else if (argsLength > numArgs) {
  20449. (0, _util.info)(`Command ${cmd}: expected [0, ${numArgs}] args, ` + `but received ${argsLength} args.`);
  20450. }
  20451. this.preprocessCommand(fn, args);
  20452. operation.fn = fn;
  20453. operation.args = args;
  20454. return true;
  20455. }
  20456. if (obj === _primitives.EOF) {
  20457. return false;
  20458. }
  20459. if (obj !== null) {
  20460. if (args === null) {
  20461. args = [];
  20462. }
  20463. args.push(obj);
  20464. if (args.length > 33) {
  20465. throw new _util.FormatError("Too many arguments");
  20466. }
  20467. }
  20468. }
  20469. }
  20470. preprocessCommand(fn, args) {
  20471. switch (fn | 0) {
  20472. case _util.OPS.save:
  20473. this.stateManager.save();
  20474. break;
  20475. case _util.OPS.restore:
  20476. this.stateManager.restore();
  20477. break;
  20478. case _util.OPS.transform:
  20479. this.stateManager.transform(args);
  20480. break;
  20481. }
  20482. }
  20483. }
  20484. /***/ }),
  20485. /* 29 */
  20486. /***/ (function(module, exports, __w_pdfjs_require__) {
  20487. "use strict";
  20488. Object.defineProperty(exports, "__esModule", {
  20489. value: true
  20490. });
  20491. exports.CMapFactory = exports.IdentityCMap = exports.CMap = void 0;
  20492. var _util = __w_pdfjs_require__(2);
  20493. var _primitives = __w_pdfjs_require__(5);
  20494. var _parser = __w_pdfjs_require__(11);
  20495. var _core_utils = __w_pdfjs_require__(8);
  20496. var _stream = __w_pdfjs_require__(12);
  20497. var BUILT_IN_CMAPS = ["Adobe-GB1-UCS2", "Adobe-CNS1-UCS2", "Adobe-Japan1-UCS2", "Adobe-Korea1-UCS2", "78-EUC-H", "78-EUC-V", "78-H", "78-RKSJ-H", "78-RKSJ-V", "78-V", "78ms-RKSJ-H", "78ms-RKSJ-V", "83pv-RKSJ-H", "90ms-RKSJ-H", "90ms-RKSJ-V", "90msp-RKSJ-H", "90msp-RKSJ-V", "90pv-RKSJ-H", "90pv-RKSJ-V", "Add-H", "Add-RKSJ-H", "Add-RKSJ-V", "Add-V", "Adobe-CNS1-0", "Adobe-CNS1-1", "Adobe-CNS1-2", "Adobe-CNS1-3", "Adobe-CNS1-4", "Adobe-CNS1-5", "Adobe-CNS1-6", "Adobe-GB1-0", "Adobe-GB1-1", "Adobe-GB1-2", "Adobe-GB1-3", "Adobe-GB1-4", "Adobe-GB1-5", "Adobe-Japan1-0", "Adobe-Japan1-1", "Adobe-Japan1-2", "Adobe-Japan1-3", "Adobe-Japan1-4", "Adobe-Japan1-5", "Adobe-Japan1-6", "Adobe-Korea1-0", "Adobe-Korea1-1", "Adobe-Korea1-2", "B5-H", "B5-V", "B5pc-H", "B5pc-V", "CNS-EUC-H", "CNS-EUC-V", "CNS1-H", "CNS1-V", "CNS2-H", "CNS2-V", "ETHK-B5-H", "ETHK-B5-V", "ETen-B5-H", "ETen-B5-V", "ETenms-B5-H", "ETenms-B5-V", "EUC-H", "EUC-V", "Ext-H", "Ext-RKSJ-H", "Ext-RKSJ-V", "Ext-V", "GB-EUC-H", "GB-EUC-V", "GB-H", "GB-V", "GBK-EUC-H", "GBK-EUC-V", "GBK2K-H", "GBK2K-V", "GBKp-EUC-H", "GBKp-EUC-V", "GBT-EUC-H", "GBT-EUC-V", "GBT-H", "GBT-V", "GBTpc-EUC-H", "GBTpc-EUC-V", "GBpc-EUC-H", "GBpc-EUC-V", "H", "HKdla-B5-H", "HKdla-B5-V", "HKdlb-B5-H", "HKdlb-B5-V", "HKgccs-B5-H", "HKgccs-B5-V", "HKm314-B5-H", "HKm314-B5-V", "HKm471-B5-H", "HKm471-B5-V", "HKscs-B5-H", "HKscs-B5-V", "Hankaku", "Hiragana", "KSC-EUC-H", "KSC-EUC-V", "KSC-H", "KSC-Johab-H", "KSC-Johab-V", "KSC-V", "KSCms-UHC-H", "KSCms-UHC-HW-H", "KSCms-UHC-HW-V", "KSCms-UHC-V", "KSCpc-EUC-H", "KSCpc-EUC-V", "Katakana", "NWP-H", "NWP-V", "RKSJ-H", "RKSJ-V", "Roman", "UniCNS-UCS2-H", "UniCNS-UCS2-V", "UniCNS-UTF16-H", "UniCNS-UTF16-V", "UniCNS-UTF32-H", "UniCNS-UTF32-V", "UniCNS-UTF8-H", "UniCNS-UTF8-V", "UniGB-UCS2-H", "UniGB-UCS2-V", "UniGB-UTF16-H", "UniGB-UTF16-V", "UniGB-UTF32-H", "UniGB-UTF32-V", "UniGB-UTF8-H", "UniGB-UTF8-V", "UniJIS-UCS2-H", "UniJIS-UCS2-HW-H", "UniJIS-UCS2-HW-V", "UniJIS-UCS2-V", "UniJIS-UTF16-H", "UniJIS-UTF16-V", "UniJIS-UTF32-H", "UniJIS-UTF32-V", "UniJIS-UTF8-H", "UniJIS-UTF8-V", "UniJIS2004-UTF16-H", "UniJIS2004-UTF16-V", "UniJIS2004-UTF32-H", "UniJIS2004-UTF32-V", "UniJIS2004-UTF8-H", "UniJIS2004-UTF8-V", "UniJISPro-UCS2-HW-V", "UniJISPro-UCS2-V", "UniJISPro-UTF8-V", "UniJISX0213-UTF32-H", "UniJISX0213-UTF32-V", "UniJISX02132004-UTF32-H", "UniJISX02132004-UTF32-V", "UniKS-UCS2-H", "UniKS-UCS2-V", "UniKS-UTF16-H", "UniKS-UTF16-V", "UniKS-UTF32-H", "UniKS-UTF32-V", "UniKS-UTF8-H", "UniKS-UTF8-V", "V", "WP-Symbol"];
  20498. const MAX_MAP_RANGE = 2 ** 24 - 1;
  20499. class CMap {
  20500. constructor(builtInCMap = false) {
  20501. this.codespaceRanges = [[], [], [], []];
  20502. this.numCodespaceRanges = 0;
  20503. this._map = [];
  20504. this.name = "";
  20505. this.vertical = false;
  20506. this.useCMap = null;
  20507. this.builtInCMap = builtInCMap;
  20508. }
  20509. addCodespaceRange(n, low, high) {
  20510. this.codespaceRanges[n - 1].push(low, high);
  20511. this.numCodespaceRanges++;
  20512. }
  20513. mapCidRange(low, high, dstLow) {
  20514. if (high - low > MAX_MAP_RANGE) {
  20515. throw new Error("mapCidRange - ignoring data above MAX_MAP_RANGE.");
  20516. }
  20517. while (low <= high) {
  20518. this._map[low++] = dstLow++;
  20519. }
  20520. }
  20521. mapBfRange(low, high, dstLow) {
  20522. if (high - low > MAX_MAP_RANGE) {
  20523. throw new Error("mapBfRange - ignoring data above MAX_MAP_RANGE.");
  20524. }
  20525. var lastByte = dstLow.length - 1;
  20526. while (low <= high) {
  20527. this._map[low++] = dstLow;
  20528. dstLow = dstLow.substring(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  20529. }
  20530. }
  20531. mapBfRangeToArray(low, high, array) {
  20532. if (high - low > MAX_MAP_RANGE) {
  20533. throw new Error("mapBfRangeToArray - ignoring data above MAX_MAP_RANGE.");
  20534. }
  20535. const ii = array.length;
  20536. let i = 0;
  20537. while (low <= high && i < ii) {
  20538. this._map[low] = array[i++];
  20539. ++low;
  20540. }
  20541. }
  20542. mapOne(src, dst) {
  20543. this._map[src] = dst;
  20544. }
  20545. lookup(code) {
  20546. return this._map[code];
  20547. }
  20548. contains(code) {
  20549. return this._map[code] !== undefined;
  20550. }
  20551. forEach(callback) {
  20552. const map = this._map;
  20553. const length = map.length;
  20554. if (length <= 0x10000) {
  20555. for (let i = 0; i < length; i++) {
  20556. if (map[i] !== undefined) {
  20557. callback(i, map[i]);
  20558. }
  20559. }
  20560. } else {
  20561. for (const i in map) {
  20562. callback(i, map[i]);
  20563. }
  20564. }
  20565. }
  20566. charCodeOf(value) {
  20567. const map = this._map;
  20568. if (map.length <= 0x10000) {
  20569. return map.indexOf(value);
  20570. }
  20571. for (const charCode in map) {
  20572. if (map[charCode] === value) {
  20573. return charCode | 0;
  20574. }
  20575. }
  20576. return -1;
  20577. }
  20578. getMap() {
  20579. return this._map;
  20580. }
  20581. readCharCode(str, offset, out) {
  20582. let c = 0;
  20583. const codespaceRanges = this.codespaceRanges;
  20584. for (let n = 0, nn = codespaceRanges.length; n < nn; n++) {
  20585. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  20586. const codespaceRange = codespaceRanges[n];
  20587. for (let k = 0, kk = codespaceRange.length; k < kk;) {
  20588. const low = codespaceRange[k++];
  20589. const high = codespaceRange[k++];
  20590. if (c >= low && c <= high) {
  20591. out.charcode = c;
  20592. out.length = n + 1;
  20593. return;
  20594. }
  20595. }
  20596. }
  20597. out.charcode = 0;
  20598. out.length = 1;
  20599. }
  20600. get length() {
  20601. return this._map.length;
  20602. }
  20603. get isIdentityCMap() {
  20604. if (!(this.name === "Identity-H" || this.name === "Identity-V")) {
  20605. return false;
  20606. }
  20607. if (this._map.length !== 0x10000) {
  20608. return false;
  20609. }
  20610. for (let i = 0; i < 0x10000; i++) {
  20611. if (this._map[i] !== i) {
  20612. return false;
  20613. }
  20614. }
  20615. return true;
  20616. }
  20617. }
  20618. exports.CMap = CMap;
  20619. class IdentityCMap extends CMap {
  20620. constructor(vertical, n) {
  20621. super();
  20622. this.vertical = vertical;
  20623. this.addCodespaceRange(n, 0, 0xffff);
  20624. }
  20625. mapCidRange(low, high, dstLow) {
  20626. (0, _util.unreachable)("should not call mapCidRange");
  20627. }
  20628. mapBfRange(low, high, dstLow) {
  20629. (0, _util.unreachable)("should not call mapBfRange");
  20630. }
  20631. mapBfRangeToArray(low, high, array) {
  20632. (0, _util.unreachable)("should not call mapBfRangeToArray");
  20633. }
  20634. mapOne(src, dst) {
  20635. (0, _util.unreachable)("should not call mapCidOne");
  20636. }
  20637. lookup(code) {
  20638. return Number.isInteger(code) && code <= 0xffff ? code : undefined;
  20639. }
  20640. contains(code) {
  20641. return Number.isInteger(code) && code <= 0xffff;
  20642. }
  20643. forEach(callback) {
  20644. for (let i = 0; i <= 0xffff; i++) {
  20645. callback(i, i);
  20646. }
  20647. }
  20648. charCodeOf(value) {
  20649. return Number.isInteger(value) && value <= 0xffff ? value : -1;
  20650. }
  20651. getMap() {
  20652. const map = new Array(0x10000);
  20653. for (let i = 0; i <= 0xffff; i++) {
  20654. map[i] = i;
  20655. }
  20656. return map;
  20657. }
  20658. get length() {
  20659. return 0x10000;
  20660. }
  20661. get isIdentityCMap() {
  20662. (0, _util.unreachable)("should not access .isIdentityCMap");
  20663. }
  20664. }
  20665. exports.IdentityCMap = IdentityCMap;
  20666. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  20667. function hexToInt(a, size) {
  20668. var n = 0;
  20669. for (var i = 0; i <= size; i++) {
  20670. n = n << 8 | a[i];
  20671. }
  20672. return n >>> 0;
  20673. }
  20674. function hexToStr(a, size) {
  20675. if (size === 1) {
  20676. return String.fromCharCode(a[0], a[1]);
  20677. }
  20678. if (size === 3) {
  20679. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  20680. }
  20681. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  20682. }
  20683. function addHex(a, b, size) {
  20684. var c = 0;
  20685. for (var i = size; i >= 0; i--) {
  20686. c += a[i] + b[i];
  20687. a[i] = c & 255;
  20688. c >>= 8;
  20689. }
  20690. }
  20691. function incHex(a, size) {
  20692. var c = 1;
  20693. for (var i = size; i >= 0 && c > 0; i--) {
  20694. c += a[i];
  20695. a[i] = c & 255;
  20696. c >>= 8;
  20697. }
  20698. }
  20699. var MAX_NUM_SIZE = 16;
  20700. var MAX_ENCODED_NUM_SIZE = 19;
  20701. function BinaryCMapStream(data) {
  20702. this.buffer = data;
  20703. this.pos = 0;
  20704. this.end = data.length;
  20705. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  20706. }
  20707. BinaryCMapStream.prototype = {
  20708. readByte() {
  20709. if (this.pos >= this.end) {
  20710. return -1;
  20711. }
  20712. return this.buffer[this.pos++];
  20713. },
  20714. readNumber() {
  20715. var n = 0;
  20716. var last;
  20717. do {
  20718. var b = this.readByte();
  20719. if (b < 0) {
  20720. throw new _util.FormatError("unexpected EOF in bcmap");
  20721. }
  20722. last = !(b & 0x80);
  20723. n = n << 7 | b & 0x7f;
  20724. } while (!last);
  20725. return n;
  20726. },
  20727. readSigned() {
  20728. var n = this.readNumber();
  20729. return n & 1 ? ~(n >>> 1) : n >>> 1;
  20730. },
  20731. readHex(num, size) {
  20732. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  20733. this.pos += size + 1;
  20734. },
  20735. readHexNumber(num, size) {
  20736. var last;
  20737. var stack = this.tmpBuf,
  20738. sp = 0;
  20739. do {
  20740. var b = this.readByte();
  20741. if (b < 0) {
  20742. throw new _util.FormatError("unexpected EOF in bcmap");
  20743. }
  20744. last = !(b & 0x80);
  20745. stack[sp++] = b & 0x7f;
  20746. } while (!last);
  20747. var i = size,
  20748. buffer = 0,
  20749. bufferSize = 0;
  20750. while (i >= 0) {
  20751. while (bufferSize < 8 && stack.length > 0) {
  20752. buffer = stack[--sp] << bufferSize | buffer;
  20753. bufferSize += 7;
  20754. }
  20755. num[i] = buffer & 255;
  20756. i--;
  20757. buffer >>= 8;
  20758. bufferSize -= 8;
  20759. }
  20760. },
  20761. readHexSigned(num, size) {
  20762. this.readHexNumber(num, size);
  20763. var sign = num[size] & 1 ? 255 : 0;
  20764. var c = 0;
  20765. for (var i = 0; i <= size; i++) {
  20766. c = (c & 1) << 8 | num[i];
  20767. num[i] = c >> 1 ^ sign;
  20768. }
  20769. },
  20770. readString() {
  20771. var len = this.readNumber();
  20772. var s = "";
  20773. for (var i = 0; i < len; i++) {
  20774. s += String.fromCharCode(this.readNumber());
  20775. }
  20776. return s;
  20777. }
  20778. };
  20779. function processBinaryCMap(data, cMap, extend) {
  20780. return new Promise(function (resolve, reject) {
  20781. var stream = new BinaryCMapStream(data);
  20782. var header = stream.readByte();
  20783. cMap.vertical = !!(header & 1);
  20784. var useCMap = null;
  20785. var start = new Uint8Array(MAX_NUM_SIZE);
  20786. var end = new Uint8Array(MAX_NUM_SIZE);
  20787. var char = new Uint8Array(MAX_NUM_SIZE);
  20788. var charCode = new Uint8Array(MAX_NUM_SIZE);
  20789. var tmp = new Uint8Array(MAX_NUM_SIZE);
  20790. var code;
  20791. var b;
  20792. while ((b = stream.readByte()) >= 0) {
  20793. var type = b >> 5;
  20794. if (type === 7) {
  20795. switch (b & 0x1f) {
  20796. case 0:
  20797. stream.readString();
  20798. break;
  20799. case 1:
  20800. useCMap = stream.readString();
  20801. break;
  20802. }
  20803. continue;
  20804. }
  20805. var sequence = !!(b & 0x10);
  20806. var dataSize = b & 15;
  20807. if (dataSize + 1 > MAX_NUM_SIZE) {
  20808. throw new Error("processBinaryCMap: Invalid dataSize.");
  20809. }
  20810. var ucs2DataSize = 1;
  20811. var subitemsCount = stream.readNumber();
  20812. var i;
  20813. switch (type) {
  20814. case 0:
  20815. stream.readHex(start, dataSize);
  20816. stream.readHexNumber(end, dataSize);
  20817. addHex(end, start, dataSize);
  20818. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  20819. for (i = 1; i < subitemsCount; i++) {
  20820. incHex(end, dataSize);
  20821. stream.readHexNumber(start, dataSize);
  20822. addHex(start, end, dataSize);
  20823. stream.readHexNumber(end, dataSize);
  20824. addHex(end, start, dataSize);
  20825. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  20826. }
  20827. break;
  20828. case 1:
  20829. stream.readHex(start, dataSize);
  20830. stream.readHexNumber(end, dataSize);
  20831. addHex(end, start, dataSize);
  20832. stream.readNumber();
  20833. for (i = 1; i < subitemsCount; i++) {
  20834. incHex(end, dataSize);
  20835. stream.readHexNumber(start, dataSize);
  20836. addHex(start, end, dataSize);
  20837. stream.readHexNumber(end, dataSize);
  20838. addHex(end, start, dataSize);
  20839. stream.readNumber();
  20840. }
  20841. break;
  20842. case 2:
  20843. stream.readHex(char, dataSize);
  20844. code = stream.readNumber();
  20845. cMap.mapOne(hexToInt(char, dataSize), code);
  20846. for (i = 1; i < subitemsCount; i++) {
  20847. incHex(char, dataSize);
  20848. if (!sequence) {
  20849. stream.readHexNumber(tmp, dataSize);
  20850. addHex(char, tmp, dataSize);
  20851. }
  20852. code = stream.readSigned() + (code + 1);
  20853. cMap.mapOne(hexToInt(char, dataSize), code);
  20854. }
  20855. break;
  20856. case 3:
  20857. stream.readHex(start, dataSize);
  20858. stream.readHexNumber(end, dataSize);
  20859. addHex(end, start, dataSize);
  20860. code = stream.readNumber();
  20861. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  20862. for (i = 1; i < subitemsCount; i++) {
  20863. incHex(end, dataSize);
  20864. if (!sequence) {
  20865. stream.readHexNumber(start, dataSize);
  20866. addHex(start, end, dataSize);
  20867. } else {
  20868. start.set(end);
  20869. }
  20870. stream.readHexNumber(end, dataSize);
  20871. addHex(end, start, dataSize);
  20872. code = stream.readNumber();
  20873. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  20874. }
  20875. break;
  20876. case 4:
  20877. stream.readHex(char, ucs2DataSize);
  20878. stream.readHex(charCode, dataSize);
  20879. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  20880. for (i = 1; i < subitemsCount; i++) {
  20881. incHex(char, ucs2DataSize);
  20882. if (!sequence) {
  20883. stream.readHexNumber(tmp, ucs2DataSize);
  20884. addHex(char, tmp, ucs2DataSize);
  20885. }
  20886. incHex(charCode, dataSize);
  20887. stream.readHexSigned(tmp, dataSize);
  20888. addHex(charCode, tmp, dataSize);
  20889. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  20890. }
  20891. break;
  20892. case 5:
  20893. stream.readHex(start, ucs2DataSize);
  20894. stream.readHexNumber(end, ucs2DataSize);
  20895. addHex(end, start, ucs2DataSize);
  20896. stream.readHex(charCode, dataSize);
  20897. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  20898. for (i = 1; i < subitemsCount; i++) {
  20899. incHex(end, ucs2DataSize);
  20900. if (!sequence) {
  20901. stream.readHexNumber(start, ucs2DataSize);
  20902. addHex(start, end, ucs2DataSize);
  20903. } else {
  20904. start.set(end);
  20905. }
  20906. stream.readHexNumber(end, ucs2DataSize);
  20907. addHex(end, start, ucs2DataSize);
  20908. stream.readHex(charCode, dataSize);
  20909. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  20910. }
  20911. break;
  20912. default:
  20913. reject(new Error("processBinaryCMap: Unknown type: " + type));
  20914. return;
  20915. }
  20916. }
  20917. if (useCMap) {
  20918. resolve(extend(useCMap));
  20919. return;
  20920. }
  20921. resolve(cMap);
  20922. });
  20923. }
  20924. function BinaryCMapReader() {}
  20925. BinaryCMapReader.prototype = {
  20926. process: processBinaryCMap
  20927. };
  20928. return BinaryCMapReader;
  20929. }();
  20930. var CMapFactory = function CMapFactoryClosure() {
  20931. function strToInt(str) {
  20932. var a = 0;
  20933. for (var i = 0; i < str.length; i++) {
  20934. a = a << 8 | str.charCodeAt(i);
  20935. }
  20936. return a >>> 0;
  20937. }
  20938. function expectString(obj) {
  20939. if (!(0, _util.isString)(obj)) {
  20940. throw new _util.FormatError("Malformed CMap: expected string.");
  20941. }
  20942. }
  20943. function expectInt(obj) {
  20944. if (!Number.isInteger(obj)) {
  20945. throw new _util.FormatError("Malformed CMap: expected int.");
  20946. }
  20947. }
  20948. function parseBfChar(cMap, lexer) {
  20949. while (true) {
  20950. var obj = lexer.getObj();
  20951. if ((0, _primitives.isEOF)(obj)) {
  20952. break;
  20953. }
  20954. if ((0, _primitives.isCmd)(obj, "endbfchar")) {
  20955. return;
  20956. }
  20957. expectString(obj);
  20958. var src = strToInt(obj);
  20959. obj = lexer.getObj();
  20960. expectString(obj);
  20961. var dst = obj;
  20962. cMap.mapOne(src, dst);
  20963. }
  20964. }
  20965. function parseBfRange(cMap, lexer) {
  20966. while (true) {
  20967. var obj = lexer.getObj();
  20968. if ((0, _primitives.isEOF)(obj)) {
  20969. break;
  20970. }
  20971. if ((0, _primitives.isCmd)(obj, "endbfrange")) {
  20972. return;
  20973. }
  20974. expectString(obj);
  20975. var low = strToInt(obj);
  20976. obj = lexer.getObj();
  20977. expectString(obj);
  20978. var high = strToInt(obj);
  20979. obj = lexer.getObj();
  20980. if (Number.isInteger(obj) || (0, _util.isString)(obj)) {
  20981. var dstLow = Number.isInteger(obj) ? String.fromCharCode(obj) : obj;
  20982. cMap.mapBfRange(low, high, dstLow);
  20983. } else if ((0, _primitives.isCmd)(obj, "[")) {
  20984. obj = lexer.getObj();
  20985. var array = [];
  20986. while (!(0, _primitives.isCmd)(obj, "]") && !(0, _primitives.isEOF)(obj)) {
  20987. array.push(obj);
  20988. obj = lexer.getObj();
  20989. }
  20990. cMap.mapBfRangeToArray(low, high, array);
  20991. } else {
  20992. break;
  20993. }
  20994. }
  20995. throw new _util.FormatError("Invalid bf range.");
  20996. }
  20997. function parseCidChar(cMap, lexer) {
  20998. while (true) {
  20999. var obj = lexer.getObj();
  21000. if ((0, _primitives.isEOF)(obj)) {
  21001. break;
  21002. }
  21003. if ((0, _primitives.isCmd)(obj, "endcidchar")) {
  21004. return;
  21005. }
  21006. expectString(obj);
  21007. var src = strToInt(obj);
  21008. obj = lexer.getObj();
  21009. expectInt(obj);
  21010. var dst = obj;
  21011. cMap.mapOne(src, dst);
  21012. }
  21013. }
  21014. function parseCidRange(cMap, lexer) {
  21015. while (true) {
  21016. var obj = lexer.getObj();
  21017. if ((0, _primitives.isEOF)(obj)) {
  21018. break;
  21019. }
  21020. if ((0, _primitives.isCmd)(obj, "endcidrange")) {
  21021. return;
  21022. }
  21023. expectString(obj);
  21024. var low = strToInt(obj);
  21025. obj = lexer.getObj();
  21026. expectString(obj);
  21027. var high = strToInt(obj);
  21028. obj = lexer.getObj();
  21029. expectInt(obj);
  21030. var dstLow = obj;
  21031. cMap.mapCidRange(low, high, dstLow);
  21032. }
  21033. }
  21034. function parseCodespaceRange(cMap, lexer) {
  21035. while (true) {
  21036. var obj = lexer.getObj();
  21037. if ((0, _primitives.isEOF)(obj)) {
  21038. break;
  21039. }
  21040. if ((0, _primitives.isCmd)(obj, "endcodespacerange")) {
  21041. return;
  21042. }
  21043. if (!(0, _util.isString)(obj)) {
  21044. break;
  21045. }
  21046. var low = strToInt(obj);
  21047. obj = lexer.getObj();
  21048. if (!(0, _util.isString)(obj)) {
  21049. break;
  21050. }
  21051. var high = strToInt(obj);
  21052. cMap.addCodespaceRange(obj.length, low, high);
  21053. }
  21054. throw new _util.FormatError("Invalid codespace range.");
  21055. }
  21056. function parseWMode(cMap, lexer) {
  21057. var obj = lexer.getObj();
  21058. if (Number.isInteger(obj)) {
  21059. cMap.vertical = !!obj;
  21060. }
  21061. }
  21062. function parseCMapName(cMap, lexer) {
  21063. var obj = lexer.getObj();
  21064. if ((0, _primitives.isName)(obj) && (0, _util.isString)(obj.name)) {
  21065. cMap.name = obj.name;
  21066. }
  21067. }
  21068. function parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap) {
  21069. var previous;
  21070. var embeddedUseCMap;
  21071. objLoop: while (true) {
  21072. try {
  21073. var obj = lexer.getObj();
  21074. if ((0, _primitives.isEOF)(obj)) {
  21075. break;
  21076. } else if ((0, _primitives.isName)(obj)) {
  21077. if (obj.name === "WMode") {
  21078. parseWMode(cMap, lexer);
  21079. } else if (obj.name === "CMapName") {
  21080. parseCMapName(cMap, lexer);
  21081. }
  21082. previous = obj;
  21083. } else if ((0, _primitives.isCmd)(obj)) {
  21084. switch (obj.cmd) {
  21085. case "endcmap":
  21086. break objLoop;
  21087. case "usecmap":
  21088. if ((0, _primitives.isName)(previous)) {
  21089. embeddedUseCMap = previous.name;
  21090. }
  21091. break;
  21092. case "begincodespacerange":
  21093. parseCodespaceRange(cMap, lexer);
  21094. break;
  21095. case "beginbfchar":
  21096. parseBfChar(cMap, lexer);
  21097. break;
  21098. case "begincidchar":
  21099. parseCidChar(cMap, lexer);
  21100. break;
  21101. case "beginbfrange":
  21102. parseBfRange(cMap, lexer);
  21103. break;
  21104. case "begincidrange":
  21105. parseCidRange(cMap, lexer);
  21106. break;
  21107. }
  21108. }
  21109. } catch (ex) {
  21110. if (ex instanceof _core_utils.MissingDataException) {
  21111. throw ex;
  21112. }
  21113. (0, _util.warn)("Invalid cMap data: " + ex);
  21114. continue;
  21115. }
  21116. }
  21117. if (!useCMap && embeddedUseCMap) {
  21118. useCMap = embeddedUseCMap;
  21119. }
  21120. if (useCMap) {
  21121. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  21122. }
  21123. return Promise.resolve(cMap);
  21124. }
  21125. function extendCMap(cMap, fetchBuiltInCMap, useCMap) {
  21126. return createBuiltInCMap(useCMap, fetchBuiltInCMap).then(function (newCMap) {
  21127. cMap.useCMap = newCMap;
  21128. if (cMap.numCodespaceRanges === 0) {
  21129. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  21130. for (var i = 0; i < useCodespaceRanges.length; i++) {
  21131. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  21132. }
  21133. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  21134. }
  21135. cMap.useCMap.forEach(function (key, value) {
  21136. if (!cMap.contains(key)) {
  21137. cMap.mapOne(key, cMap.useCMap.lookup(key));
  21138. }
  21139. });
  21140. return cMap;
  21141. });
  21142. }
  21143. function createBuiltInCMap(name, fetchBuiltInCMap) {
  21144. if (name === "Identity-H") {
  21145. return Promise.resolve(new IdentityCMap(false, 2));
  21146. } else if (name === "Identity-V") {
  21147. return Promise.resolve(new IdentityCMap(true, 2));
  21148. }
  21149. if (!BUILT_IN_CMAPS.includes(name)) {
  21150. return Promise.reject(new Error("Unknown CMap name: " + name));
  21151. }
  21152. if (!fetchBuiltInCMap) {
  21153. return Promise.reject(new Error("Built-in CMap parameters are not provided."));
  21154. }
  21155. return fetchBuiltInCMap(name).then(function (data) {
  21156. var cMapData = data.cMapData,
  21157. compressionType = data.compressionType;
  21158. var cMap = new CMap(true);
  21159. if (compressionType === _util.CMapCompressionType.BINARY) {
  21160. return new BinaryCMapReader().process(cMapData, cMap, function (useCMap) {
  21161. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  21162. });
  21163. }
  21164. if (compressionType === _util.CMapCompressionType.NONE) {
  21165. var lexer = new _parser.Lexer(new _stream.Stream(cMapData));
  21166. return parseCMap(cMap, lexer, fetchBuiltInCMap, null);
  21167. }
  21168. return Promise.reject(new Error("TODO: Only BINARY/NONE CMap compression is currently supported."));
  21169. });
  21170. }
  21171. return {
  21172. async create(params) {
  21173. var encoding = params.encoding;
  21174. var fetchBuiltInCMap = params.fetchBuiltInCMap;
  21175. var useCMap = params.useCMap;
  21176. if ((0, _primitives.isName)(encoding)) {
  21177. return createBuiltInCMap(encoding.name, fetchBuiltInCMap);
  21178. } else if ((0, _primitives.isStream)(encoding)) {
  21179. var cMap = new CMap();
  21180. var lexer = new _parser.Lexer(encoding);
  21181. return parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap).then(function (parsedCMap) {
  21182. if (parsedCMap.isIdentityCMap) {
  21183. return createBuiltInCMap(parsedCMap.name, fetchBuiltInCMap);
  21184. }
  21185. return parsedCMap;
  21186. });
  21187. }
  21188. throw new Error("Encoding required.");
  21189. }
  21190. };
  21191. }();
  21192. exports.CMapFactory = CMapFactory;
  21193. /***/ }),
  21194. /* 30 */
  21195. /***/ (function(module, exports, __w_pdfjs_require__) {
  21196. "use strict";
  21197. Object.defineProperty(exports, "__esModule", {
  21198. value: true
  21199. });
  21200. exports.getFontType = getFontType;
  21201. exports.IdentityToUnicodeMap = exports.ToUnicodeMap = exports.FontFlags = exports.Font = exports.ErrorFont = exports.SEAC_ANALYSIS_ENABLED = void 0;
  21202. var _util = __w_pdfjs_require__(2);
  21203. var _cff_parser = __w_pdfjs_require__(31);
  21204. var _glyphlist = __w_pdfjs_require__(34);
  21205. var _encodings = __w_pdfjs_require__(33);
  21206. var _standard_fonts = __w_pdfjs_require__(35);
  21207. var _unicode = __w_pdfjs_require__(36);
  21208. var _core_utils = __w_pdfjs_require__(8);
  21209. var _font_renderer = __w_pdfjs_require__(37);
  21210. var _cmap = __w_pdfjs_require__(29);
  21211. var _stream = __w_pdfjs_require__(12);
  21212. var _type1_parser = __w_pdfjs_require__(38);
  21213. const PRIVATE_USE_AREAS = [[0xe000, 0xf8ff], [0x100000, 0x10fffd]];
  21214. var PDF_GLYPH_SPACE_UNITS = 1000;
  21215. var SEAC_ANALYSIS_ENABLED = true;
  21216. exports.SEAC_ANALYSIS_ENABLED = SEAC_ANALYSIS_ENABLED;
  21217. const EXPORT_DATA_PROPERTIES = ["ascent", "bbox", "black", "bold", "charProcOperatorList", "composite", "data", "defaultVMetrics", "defaultWidth", "descent", "fallbackName", "fontMatrix", "fontType", "isMonospace", "isSerifFont", "isType3Font", "italic", "loadedName", "mimetype", "missingFile", "name", "remeasure", "subtype", "type", "vertical"];
  21218. const EXPORT_DATA_EXTRA_PROPERTIES = ["cMap", "defaultEncoding", "differences", "isSymbolicFont", "seacMap", "toFontChar", "toUnicode", "vmetrics", "widths"];
  21219. var FontFlags = {
  21220. FixedPitch: 1,
  21221. Serif: 2,
  21222. Symbolic: 4,
  21223. Script: 8,
  21224. Nonsymbolic: 32,
  21225. Italic: 64,
  21226. AllCap: 65536,
  21227. SmallCap: 131072,
  21228. ForceBold: 262144
  21229. };
  21230. exports.FontFlags = FontFlags;
  21231. var MacStandardGlyphOrdering = [".notdef", ".null", "nonmarkingreturn", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "Adieresis", "Aring", "Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis", "aacute", "agrave", "acircumflex", "adieresis", "atilde", "aring", "ccedilla", "eacute", "egrave", "ecircumflex", "edieresis", "iacute", "igrave", "icircumflex", "idieresis", "ntilde", "oacute", "ograve", "ocircumflex", "odieresis", "otilde", "uacute", "ugrave", "ucircumflex", "udieresis", "dagger", "degree", "cent", "sterling", "section", "bullet", "paragraph", "germandbls", "registered", "copyright", "trademark", "acute", "dieresis", "notequal", "AE", "Oslash", "infinity", "plusminus", "lessequal", "greaterequal", "yen", "mu", "partialdiff", "summation", "product", "pi", "integral", "ordfeminine", "ordmasculine", "Omega", "ae", "oslash", "questiondown", "exclamdown", "logicalnot", "radical", "florin", "approxequal", "Delta", "guillemotleft", "guillemotright", "ellipsis", "nonbreakingspace", "Agrave", "Atilde", "Otilde", "OE", "oe", "endash", "emdash", "quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide", "lozenge", "ydieresis", "Ydieresis", "fraction", "currency", "guilsinglleft", "guilsinglright", "fi", "fl", "daggerdbl", "periodcentered", "quotesinglbase", "quotedblbase", "perthousand", "Acircumflex", "Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex", "apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave", "dotlessi", "circumflex", "tilde", "macron", "breve", "dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "Lslash", "lslash", "Scaron", "scaron", "Zcaron", "zcaron", "brokenbar", "Eth", "eth", "Yacute", "yacute", "Thorn", "thorn", "minus", "multiply", "onesuperior", "twosuperior", "threesuperior", "onehalf", "onequarter", "threequarters", "franc", "Gbreve", "gbreve", "Idotaccent", "Scedilla", "scedilla", "Cacute", "cacute", "Ccaron", "ccaron", "dcroat"];
  21232. function adjustWidths(properties) {
  21233. if (!properties.fontMatrix) {
  21234. return;
  21235. }
  21236. if (properties.fontMatrix[0] === _util.FONT_IDENTITY_MATRIX[0]) {
  21237. return;
  21238. }
  21239. var scale = 0.001 / properties.fontMatrix[0];
  21240. var glyphsWidths = properties.widths;
  21241. for (var glyph in glyphsWidths) {
  21242. glyphsWidths[glyph] *= scale;
  21243. }
  21244. properties.defaultWidth *= scale;
  21245. }
  21246. function adjustToUnicode(properties, builtInEncoding) {
  21247. if (properties.hasIncludedToUnicodeMap) {
  21248. return;
  21249. }
  21250. if (properties.hasEncoding) {
  21251. return;
  21252. }
  21253. if (builtInEncoding === properties.defaultEncoding) {
  21254. return;
  21255. }
  21256. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  21257. return;
  21258. }
  21259. var toUnicode = [],
  21260. glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  21261. for (var charCode in builtInEncoding) {
  21262. var glyphName = builtInEncoding[charCode];
  21263. var unicode = (0, _unicode.getUnicodeForGlyph)(glyphName, glyphsUnicodeMap);
  21264. if (unicode !== -1) {
  21265. toUnicode[charCode] = String.fromCharCode(unicode);
  21266. }
  21267. }
  21268. properties.toUnicode.amend(toUnicode);
  21269. }
  21270. function getFontType(type, subtype) {
  21271. switch (type) {
  21272. case "Type1":
  21273. return subtype === "Type1C" ? _util.FontType.TYPE1C : _util.FontType.TYPE1;
  21274. case "CIDFontType0":
  21275. return subtype === "CIDFontType0C" ? _util.FontType.CIDFONTTYPE0C : _util.FontType.CIDFONTTYPE0;
  21276. case "OpenType":
  21277. return _util.FontType.OPENTYPE;
  21278. case "TrueType":
  21279. return _util.FontType.TRUETYPE;
  21280. case "CIDFontType2":
  21281. return _util.FontType.CIDFONTTYPE2;
  21282. case "MMType1":
  21283. return _util.FontType.MMTYPE1;
  21284. case "Type0":
  21285. return _util.FontType.TYPE0;
  21286. default:
  21287. return _util.FontType.UNKNOWN;
  21288. }
  21289. }
  21290. function recoverGlyphName(name, glyphsUnicodeMap) {
  21291. if (glyphsUnicodeMap[name] !== undefined) {
  21292. return name;
  21293. }
  21294. var unicode = (0, _unicode.getUnicodeForGlyph)(name, glyphsUnicodeMap);
  21295. if (unicode !== -1) {
  21296. for (var key in glyphsUnicodeMap) {
  21297. if (glyphsUnicodeMap[key] === unicode) {
  21298. return key;
  21299. }
  21300. }
  21301. }
  21302. (0, _util.info)("Unable to recover a standard glyph name for: " + name);
  21303. return name;
  21304. }
  21305. var Glyph = function GlyphClosure() {
  21306. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  21307. this.fontChar = fontChar;
  21308. this.unicode = unicode;
  21309. this.accent = accent;
  21310. this.width = width;
  21311. this.vmetric = vmetric;
  21312. this.operatorListId = operatorListId;
  21313. this.isSpace = isSpace;
  21314. this.isInFont = isInFont;
  21315. }
  21316. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  21317. return this.fontChar === fontChar && this.unicode === unicode && this.accent === accent && this.width === width && this.vmetric === vmetric && this.operatorListId === operatorListId && this.isSpace === isSpace && this.isInFont === isInFont;
  21318. };
  21319. return Glyph;
  21320. }();
  21321. var ToUnicodeMap = function ToUnicodeMapClosure() {
  21322. function ToUnicodeMap(cmap = []) {
  21323. this._map = cmap;
  21324. }
  21325. ToUnicodeMap.prototype = {
  21326. get length() {
  21327. return this._map.length;
  21328. },
  21329. forEach(callback) {
  21330. for (var charCode in this._map) {
  21331. callback(charCode, this._map[charCode].charCodeAt(0));
  21332. }
  21333. },
  21334. has(i) {
  21335. return this._map[i] !== undefined;
  21336. },
  21337. get(i) {
  21338. return this._map[i];
  21339. },
  21340. charCodeOf(value) {
  21341. const map = this._map;
  21342. if (map.length <= 0x10000) {
  21343. return map.indexOf(value);
  21344. }
  21345. for (const charCode in map) {
  21346. if (map[charCode] === value) {
  21347. return charCode | 0;
  21348. }
  21349. }
  21350. return -1;
  21351. },
  21352. amend(map) {
  21353. for (var charCode in map) {
  21354. this._map[charCode] = map[charCode];
  21355. }
  21356. }
  21357. };
  21358. return ToUnicodeMap;
  21359. }();
  21360. exports.ToUnicodeMap = ToUnicodeMap;
  21361. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  21362. function IdentityToUnicodeMap(firstChar, lastChar) {
  21363. this.firstChar = firstChar;
  21364. this.lastChar = lastChar;
  21365. }
  21366. IdentityToUnicodeMap.prototype = {
  21367. get length() {
  21368. return this.lastChar + 1 - this.firstChar;
  21369. },
  21370. forEach(callback) {
  21371. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  21372. callback(i, i);
  21373. }
  21374. },
  21375. has(i) {
  21376. return this.firstChar <= i && i <= this.lastChar;
  21377. },
  21378. get(i) {
  21379. if (this.firstChar <= i && i <= this.lastChar) {
  21380. return String.fromCharCode(i);
  21381. }
  21382. return undefined;
  21383. },
  21384. charCodeOf(v) {
  21385. return Number.isInteger(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  21386. },
  21387. amend(map) {
  21388. (0, _util.unreachable)("Should not call amend()");
  21389. }
  21390. };
  21391. return IdentityToUnicodeMap;
  21392. }();
  21393. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  21394. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  21395. function writeInt16(dest, offset, num) {
  21396. dest[offset] = num >> 8 & 0xff;
  21397. dest[offset + 1] = num & 0xff;
  21398. }
  21399. function writeInt32(dest, offset, num) {
  21400. dest[offset] = num >> 24 & 0xff;
  21401. dest[offset + 1] = num >> 16 & 0xff;
  21402. dest[offset + 2] = num >> 8 & 0xff;
  21403. dest[offset + 3] = num & 0xff;
  21404. }
  21405. function writeData(dest, offset, data) {
  21406. var i, ii;
  21407. if (data instanceof Uint8Array) {
  21408. dest.set(data, offset);
  21409. } else if (typeof data === "string") {
  21410. for (i = 0, ii = data.length; i < ii; i++) {
  21411. dest[offset++] = data.charCodeAt(i) & 0xff;
  21412. }
  21413. } else {
  21414. for (i = 0, ii = data.length; i < ii; i++) {
  21415. dest[offset++] = data[i] & 0xff;
  21416. }
  21417. }
  21418. }
  21419. function OpenTypeFileBuilder(sfnt) {
  21420. this.sfnt = sfnt;
  21421. this.tables = Object.create(null);
  21422. }
  21423. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  21424. var maxPower2 = 1,
  21425. log2 = 0;
  21426. while ((maxPower2 ^ entriesCount) > maxPower2) {
  21427. maxPower2 <<= 1;
  21428. log2++;
  21429. }
  21430. var searchRange = maxPower2 * entrySize;
  21431. return {
  21432. range: searchRange,
  21433. entry: log2,
  21434. rangeShift: entrySize * entriesCount - searchRange
  21435. };
  21436. };
  21437. var OTF_HEADER_SIZE = 12;
  21438. var OTF_TABLE_ENTRY_SIZE = 16;
  21439. OpenTypeFileBuilder.prototype = {
  21440. toArray: function OpenTypeFileBuilder_toArray() {
  21441. var sfnt = this.sfnt;
  21442. var tables = this.tables;
  21443. var tablesNames = Object.keys(tables);
  21444. tablesNames.sort();
  21445. var numTables = tablesNames.length;
  21446. var i, j, jj, table, tableName;
  21447. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  21448. var tableOffsets = [offset];
  21449. for (i = 0; i < numTables; i++) {
  21450. table = tables[tablesNames[i]];
  21451. var paddedLength = (table.length + 3 & ~3) >>> 0;
  21452. offset += paddedLength;
  21453. tableOffsets.push(offset);
  21454. }
  21455. var file = new Uint8Array(offset);
  21456. for (i = 0; i < numTables; i++) {
  21457. table = tables[tablesNames[i]];
  21458. writeData(file, tableOffsets[i], table);
  21459. }
  21460. if (sfnt === "true") {
  21461. sfnt = (0, _util.string32)(0x00010000);
  21462. }
  21463. file[0] = sfnt.charCodeAt(0) & 0xff;
  21464. file[1] = sfnt.charCodeAt(1) & 0xff;
  21465. file[2] = sfnt.charCodeAt(2) & 0xff;
  21466. file[3] = sfnt.charCodeAt(3) & 0xff;
  21467. writeInt16(file, 4, numTables);
  21468. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  21469. writeInt16(file, 6, searchParams.range);
  21470. writeInt16(file, 8, searchParams.entry);
  21471. writeInt16(file, 10, searchParams.rangeShift);
  21472. offset = OTF_HEADER_SIZE;
  21473. for (i = 0; i < numTables; i++) {
  21474. tableName = tablesNames[i];
  21475. file[offset] = tableName.charCodeAt(0) & 0xff;
  21476. file[offset + 1] = tableName.charCodeAt(1) & 0xff;
  21477. file[offset + 2] = tableName.charCodeAt(2) & 0xff;
  21478. file[offset + 3] = tableName.charCodeAt(3) & 0xff;
  21479. var checksum = 0;
  21480. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  21481. var quad = (0, _core_utils.readUint32)(file, j);
  21482. checksum = checksum + quad >>> 0;
  21483. }
  21484. writeInt32(file, offset + 4, checksum);
  21485. writeInt32(file, offset + 8, tableOffsets[i]);
  21486. writeInt32(file, offset + 12, tables[tableName].length);
  21487. offset += OTF_TABLE_ENTRY_SIZE;
  21488. }
  21489. return file;
  21490. },
  21491. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  21492. if (tag in this.tables) {
  21493. throw new Error("Table " + tag + " already exists");
  21494. }
  21495. this.tables[tag] = data;
  21496. }
  21497. };
  21498. return OpenTypeFileBuilder;
  21499. }();
  21500. var Font = function FontClosure() {
  21501. function Font(name, file, properties) {
  21502. var charCode;
  21503. this.name = name;
  21504. this.loadedName = properties.loadedName;
  21505. this.isType3Font = properties.isType3Font;
  21506. this.missingFile = false;
  21507. this.glyphCache = Object.create(null);
  21508. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  21509. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  21510. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  21511. var type = properties.type;
  21512. var subtype = properties.subtype;
  21513. this.type = type;
  21514. this.subtype = subtype;
  21515. let fallbackName = "sans-serif";
  21516. if (this.isMonospace) {
  21517. fallbackName = "monospace";
  21518. } else if (this.isSerifFont) {
  21519. fallbackName = "serif";
  21520. }
  21521. this.fallbackName = fallbackName;
  21522. this.differences = properties.differences;
  21523. this.widths = properties.widths;
  21524. this.defaultWidth = properties.defaultWidth;
  21525. this.composite = properties.composite;
  21526. this.cMap = properties.cMap;
  21527. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  21528. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  21529. this.fontMatrix = properties.fontMatrix;
  21530. this.bbox = properties.bbox;
  21531. this.defaultEncoding = properties.defaultEncoding;
  21532. this.toUnicode = properties.toUnicode;
  21533. this.fallbackToUnicode = properties.fallbackToUnicode || new ToUnicodeMap();
  21534. this.toFontChar = [];
  21535. if (properties.type === "Type3") {
  21536. for (charCode = 0; charCode < 256; charCode++) {
  21537. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  21538. }
  21539. this.fontType = _util.FontType.TYPE3;
  21540. return;
  21541. }
  21542. this.cidEncoding = properties.cidEncoding;
  21543. this.vertical = !!properties.vertical;
  21544. if (this.vertical) {
  21545. this.vmetrics = properties.vmetrics;
  21546. this.defaultVMetrics = properties.defaultVMetrics;
  21547. }
  21548. if (!file || file.isEmpty) {
  21549. if (file) {
  21550. (0, _util.warn)('Font file is empty in "' + name + '" (' + this.loadedName + ")");
  21551. }
  21552. this.fallbackToSystemFont();
  21553. return;
  21554. }
  21555. [type, subtype] = getFontFileType(file, properties);
  21556. if (type !== this.type || subtype !== this.subtype) {
  21557. (0, _util.info)("Inconsistent font file Type/SubType, expected: " + `${this.type}/${this.subtype} but found: ${type}/${subtype}.`);
  21558. }
  21559. try {
  21560. var data;
  21561. switch (type) {
  21562. case "MMType1":
  21563. (0, _util.info)("MMType1 font (" + name + "), falling back to Type1.");
  21564. case "Type1":
  21565. case "CIDFontType0":
  21566. this.mimetype = "font/opentype";
  21567. var cff = subtype === "Type1C" || subtype === "CIDFontType0C" ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  21568. adjustWidths(properties);
  21569. data = this.convert(name, cff, properties);
  21570. break;
  21571. case "OpenType":
  21572. case "TrueType":
  21573. case "CIDFontType2":
  21574. this.mimetype = "font/opentype";
  21575. data = this.checkAndRepair(name, file, properties);
  21576. if (this.isOpenType) {
  21577. adjustWidths(properties);
  21578. type = "OpenType";
  21579. }
  21580. break;
  21581. default:
  21582. throw new _util.FormatError(`Font ${type} is not supported`);
  21583. }
  21584. } catch (e) {
  21585. (0, _util.warn)(e);
  21586. this.fallbackToSystemFont();
  21587. return;
  21588. }
  21589. this.data = data;
  21590. this.fontType = getFontType(type, subtype);
  21591. this.fontMatrix = properties.fontMatrix;
  21592. this.widths = properties.widths;
  21593. this.defaultWidth = properties.defaultWidth;
  21594. this.toUnicode = properties.toUnicode;
  21595. this.seacMap = properties.seacMap;
  21596. }
  21597. function int16(b0, b1) {
  21598. return (b0 << 8) + b1;
  21599. }
  21600. function writeSignedInt16(bytes, index, value) {
  21601. bytes[index + 1] = value;
  21602. bytes[index] = value >>> 8;
  21603. }
  21604. function signedInt16(b0, b1) {
  21605. var value = (b0 << 8) + b1;
  21606. return value & 1 << 15 ? value - 0x10000 : value;
  21607. }
  21608. function int32(b0, b1, b2, b3) {
  21609. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  21610. }
  21611. function string16(value) {
  21612. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  21613. }
  21614. function safeString16(value) {
  21615. if (value > 0x7fff) {
  21616. value = 0x7fff;
  21617. } else if (value < -0x8000) {
  21618. value = -0x8000;
  21619. }
  21620. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  21621. }
  21622. function isTrueTypeFile(file) {
  21623. var header = file.peekBytes(4);
  21624. return (0, _core_utils.readUint32)(header, 0) === 0x00010000 || (0, _util.bytesToString)(header) === "true";
  21625. }
  21626. function isTrueTypeCollectionFile(file) {
  21627. const header = file.peekBytes(4);
  21628. return (0, _util.bytesToString)(header) === "ttcf";
  21629. }
  21630. function isOpenTypeFile(file) {
  21631. var header = file.peekBytes(4);
  21632. return (0, _util.bytesToString)(header) === "OTTO";
  21633. }
  21634. function isType1File(file) {
  21635. var header = file.peekBytes(2);
  21636. if (header[0] === 0x25 && header[1] === 0x21) {
  21637. return true;
  21638. }
  21639. if (header[0] === 0x80 && header[1] === 0x01) {
  21640. return true;
  21641. }
  21642. return false;
  21643. }
  21644. function isCFFFile(file) {
  21645. const header = file.peekBytes(4);
  21646. if (header[0] >= 1 && header[3] >= 1 && header[3] <= 4) {
  21647. return true;
  21648. }
  21649. return false;
  21650. }
  21651. function getFontFileType(file, {
  21652. type,
  21653. subtype,
  21654. composite
  21655. }) {
  21656. let fileType, fileSubtype;
  21657. if (isTrueTypeFile(file) || isTrueTypeCollectionFile(file)) {
  21658. if (composite) {
  21659. fileType = "CIDFontType2";
  21660. } else {
  21661. fileType = "TrueType";
  21662. }
  21663. } else if (isOpenTypeFile(file)) {
  21664. if (composite) {
  21665. fileType = "CIDFontType2";
  21666. } else {
  21667. fileType = "OpenType";
  21668. }
  21669. } else if (isType1File(file)) {
  21670. if (composite) {
  21671. fileType = "CIDFontType0";
  21672. } else {
  21673. fileType = type === "MMType1" ? "MMType1" : "Type1";
  21674. }
  21675. } else if (isCFFFile(file)) {
  21676. if (composite) {
  21677. fileType = "CIDFontType0";
  21678. fileSubtype = "CIDFontType0C";
  21679. } else {
  21680. fileType = type === "MMType1" ? "MMType1" : "Type1";
  21681. fileSubtype = "Type1C";
  21682. }
  21683. } else {
  21684. (0, _util.warn)("getFontFileType: Unable to detect correct font file Type/Subtype.");
  21685. fileType = type;
  21686. fileSubtype = subtype;
  21687. }
  21688. return [fileType, fileSubtype];
  21689. }
  21690. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  21691. var toFontChar = [],
  21692. unicode;
  21693. for (var i = 0, ii = encoding.length; i < ii; i++) {
  21694. unicode = (0, _unicode.getUnicodeForGlyph)(encoding[i], glyphsUnicodeMap);
  21695. if (unicode !== -1) {
  21696. toFontChar[i] = unicode;
  21697. }
  21698. }
  21699. for (var charCode in differences) {
  21700. unicode = (0, _unicode.getUnicodeForGlyph)(differences[charCode], glyphsUnicodeMap);
  21701. if (unicode !== -1) {
  21702. toFontChar[+charCode] = unicode;
  21703. }
  21704. }
  21705. return toFontChar;
  21706. }
  21707. function adjustMapping(charCodeToGlyphId, hasGlyph, newGlyphZeroId) {
  21708. var newMap = Object.create(null);
  21709. var toFontChar = [];
  21710. var privateUseAreaIndex = 0;
  21711. var nextAvailableFontCharCode = PRIVATE_USE_AREAS[privateUseAreaIndex][0];
  21712. var privateUseOffetEnd = PRIVATE_USE_AREAS[privateUseAreaIndex][1];
  21713. for (var originalCharCode in charCodeToGlyphId) {
  21714. originalCharCode |= 0;
  21715. var glyphId = charCodeToGlyphId[originalCharCode];
  21716. if (!hasGlyph(glyphId)) {
  21717. continue;
  21718. }
  21719. if (nextAvailableFontCharCode > privateUseOffetEnd) {
  21720. privateUseAreaIndex++;
  21721. if (privateUseAreaIndex >= PRIVATE_USE_AREAS.length) {
  21722. (0, _util.warn)("Ran out of space in font private use area.");
  21723. break;
  21724. }
  21725. nextAvailableFontCharCode = PRIVATE_USE_AREAS[privateUseAreaIndex][0];
  21726. privateUseOffetEnd = PRIVATE_USE_AREAS[privateUseAreaIndex][1];
  21727. }
  21728. var fontCharCode = nextAvailableFontCharCode++;
  21729. if (glyphId === 0) {
  21730. glyphId = newGlyphZeroId;
  21731. }
  21732. newMap[fontCharCode] = glyphId;
  21733. toFontChar[originalCharCode] = fontCharCode;
  21734. }
  21735. return {
  21736. toFontChar,
  21737. charCodeToGlyphId: newMap,
  21738. nextAvailableFontCharCode
  21739. };
  21740. }
  21741. function getRanges(glyphs, numGlyphs) {
  21742. var codes = [];
  21743. for (var charCode in glyphs) {
  21744. if (glyphs[charCode] >= numGlyphs) {
  21745. continue;
  21746. }
  21747. codes.push({
  21748. fontCharCode: charCode | 0,
  21749. glyphId: glyphs[charCode]
  21750. });
  21751. }
  21752. if (codes.length === 0) {
  21753. codes.push({
  21754. fontCharCode: 0,
  21755. glyphId: 0
  21756. });
  21757. }
  21758. codes.sort(function fontGetRangesSort(a, b) {
  21759. return a.fontCharCode - b.fontCharCode;
  21760. });
  21761. var ranges = [];
  21762. var length = codes.length;
  21763. for (var n = 0; n < length;) {
  21764. var start = codes[n].fontCharCode;
  21765. var codeIndices = [codes[n].glyphId];
  21766. ++n;
  21767. var end = start;
  21768. while (n < length && end + 1 === codes[n].fontCharCode) {
  21769. codeIndices.push(codes[n].glyphId);
  21770. ++end;
  21771. ++n;
  21772. if (end === 0xffff) {
  21773. break;
  21774. }
  21775. }
  21776. ranges.push([start, end, codeIndices]);
  21777. }
  21778. return ranges;
  21779. }
  21780. function createCmapTable(glyphs, numGlyphs) {
  21781. var ranges = getRanges(glyphs, numGlyphs);
  21782. var numTables = ranges[ranges.length - 1][1] > 0xffff ? 2 : 1;
  21783. var cmap = "\x00\x00" + string16(numTables) + "\x00\x03" + "\x00\x01" + (0, _util.string32)(4 + numTables * 8);
  21784. var i, ii, j, jj;
  21785. for (i = ranges.length - 1; i >= 0; --i) {
  21786. if (ranges[i][0] <= 0xffff) {
  21787. break;
  21788. }
  21789. }
  21790. var bmpLength = i + 1;
  21791. if (ranges[i][0] < 0xffff && ranges[i][1] === 0xffff) {
  21792. ranges[i][1] = 0xfffe;
  21793. }
  21794. var trailingRangesCount = ranges[i][1] < 0xffff ? 1 : 0;
  21795. var segCount = bmpLength + trailingRangesCount;
  21796. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  21797. var startCount = "";
  21798. var endCount = "";
  21799. var idDeltas = "";
  21800. var idRangeOffsets = "";
  21801. var glyphsIds = "";
  21802. var bias = 0;
  21803. var range, start, end, codes;
  21804. for (i = 0, ii = bmpLength; i < ii; i++) {
  21805. range = ranges[i];
  21806. start = range[0];
  21807. end = range[1];
  21808. startCount += string16(start);
  21809. endCount += string16(end);
  21810. codes = range[2];
  21811. var contiguous = true;
  21812. for (j = 1, jj = codes.length; j < jj; ++j) {
  21813. if (codes[j] !== codes[j - 1] + 1) {
  21814. contiguous = false;
  21815. break;
  21816. }
  21817. }
  21818. if (!contiguous) {
  21819. var offset = (segCount - i) * 2 + bias * 2;
  21820. bias += end - start + 1;
  21821. idDeltas += string16(0);
  21822. idRangeOffsets += string16(offset);
  21823. for (j = 0, jj = codes.length; j < jj; ++j) {
  21824. glyphsIds += string16(codes[j]);
  21825. }
  21826. } else {
  21827. var startCode = codes[0];
  21828. idDeltas += string16(startCode - start & 0xffff);
  21829. idRangeOffsets += string16(0);
  21830. }
  21831. }
  21832. if (trailingRangesCount > 0) {
  21833. endCount += "\xFF\xFF";
  21834. startCount += "\xFF\xFF";
  21835. idDeltas += "\x00\x01";
  21836. idRangeOffsets += "\x00\x00";
  21837. }
  21838. var format314 = "\x00\x00" + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + "\x00\x00" + startCount + idDeltas + idRangeOffsets + glyphsIds;
  21839. var format31012 = "";
  21840. var header31012 = "";
  21841. if (numTables > 1) {
  21842. cmap += "\x00\x03" + "\x00\x0A" + (0, _util.string32)(4 + numTables * 8 + 4 + format314.length);
  21843. format31012 = "";
  21844. for (i = 0, ii = ranges.length; i < ii; i++) {
  21845. range = ranges[i];
  21846. start = range[0];
  21847. codes = range[2];
  21848. var code = codes[0];
  21849. for (j = 1, jj = codes.length; j < jj; ++j) {
  21850. if (codes[j] !== codes[j - 1] + 1) {
  21851. end = range[0] + j - 1;
  21852. format31012 += (0, _util.string32)(start) + (0, _util.string32)(end) + (0, _util.string32)(code);
  21853. start = end + 1;
  21854. code = codes[j];
  21855. }
  21856. }
  21857. format31012 += (0, _util.string32)(start) + (0, _util.string32)(range[1]) + (0, _util.string32)(code);
  21858. }
  21859. header31012 = "\x00\x0C" + "\x00\x00" + (0, _util.string32)(format31012.length + 16) + "\x00\x00\x00\x00" + (0, _util.string32)(format31012.length / 12);
  21860. }
  21861. return cmap + "\x00\x04" + string16(format314.length + 4) + format314 + header31012 + format31012;
  21862. }
  21863. function validateOS2Table(os2, file) {
  21864. file.pos = (file.start || 0) + os2.offset;
  21865. var version = file.getUint16();
  21866. file.skip(60);
  21867. var selection = file.getUint16();
  21868. if (version < 4 && selection & 0x0300) {
  21869. return false;
  21870. }
  21871. var firstChar = file.getUint16();
  21872. var lastChar = file.getUint16();
  21873. if (firstChar > lastChar) {
  21874. return false;
  21875. }
  21876. file.skip(6);
  21877. var usWinAscent = file.getUint16();
  21878. if (usWinAscent === 0) {
  21879. return false;
  21880. }
  21881. os2.data[8] = os2.data[9] = 0;
  21882. return true;
  21883. }
  21884. function createOS2Table(properties, charstrings, override) {
  21885. override = override || {
  21886. unitsPerEm: 0,
  21887. yMax: 0,
  21888. yMin: 0,
  21889. ascent: 0,
  21890. descent: 0
  21891. };
  21892. var ulUnicodeRange1 = 0;
  21893. var ulUnicodeRange2 = 0;
  21894. var ulUnicodeRange3 = 0;
  21895. var ulUnicodeRange4 = 0;
  21896. var firstCharIndex = null;
  21897. var lastCharIndex = 0;
  21898. if (charstrings) {
  21899. for (var code in charstrings) {
  21900. code |= 0;
  21901. if (firstCharIndex > code || !firstCharIndex) {
  21902. firstCharIndex = code;
  21903. }
  21904. if (lastCharIndex < code) {
  21905. lastCharIndex = code;
  21906. }
  21907. var position = (0, _unicode.getUnicodeRangeFor)(code);
  21908. if (position < 32) {
  21909. ulUnicodeRange1 |= 1 << position;
  21910. } else if (position < 64) {
  21911. ulUnicodeRange2 |= 1 << position - 32;
  21912. } else if (position < 96) {
  21913. ulUnicodeRange3 |= 1 << position - 64;
  21914. } else if (position < 123) {
  21915. ulUnicodeRange4 |= 1 << position - 96;
  21916. } else {
  21917. throw new _util.FormatError("Unicode ranges Bits > 123 are reserved for internal usage");
  21918. }
  21919. }
  21920. if (lastCharIndex > 0xffff) {
  21921. lastCharIndex = 0xffff;
  21922. }
  21923. } else {
  21924. firstCharIndex = 0;
  21925. lastCharIndex = 255;
  21926. }
  21927. var bbox = properties.bbox || [0, 0, 0, 0];
  21928. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || _util.FONT_IDENTITY_MATRIX)[0];
  21929. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  21930. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  21931. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  21932. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  21933. typoDescent = -typoDescent;
  21934. }
  21935. var winAscent = override.yMax || typoAscent;
  21936. var winDescent = -override.yMin || -typoDescent;
  21937. return "\x00\x03" + "\x02\x24" + "\x01\xF4" + "\x00\x05" + "\x00\x00" + "\x02\x8A" + "\x02\xBB" + "\x00\x00" + "\x00\x8C" + "\x02\x8A" + "\x02\xBB" + "\x00\x00" + "\x01\xDF" + "\x00\x31" + "\x01\x02" + "\x00\x00" + "\x00\x00\x06" + String.fromCharCode(properties.fixedPitch ? 0x09 : 0x00) + "\x00\x00\x00\x00\x00\x00" + (0, _util.string32)(ulUnicodeRange1) + (0, _util.string32)(ulUnicodeRange2) + (0, _util.string32)(ulUnicodeRange3) + (0, _util.string32)(ulUnicodeRange4) + "\x2A\x32\x31\x2A" + string16(properties.italicAngle ? 1 : 0) + string16(firstCharIndex || properties.firstChar) + string16(lastCharIndex || properties.lastChar) + string16(typoAscent) + string16(typoDescent) + "\x00\x64" + string16(winAscent) + string16(winDescent) + "\x00\x00\x00\x00" + "\x00\x00\x00\x00" + string16(properties.xHeight) + string16(properties.capHeight) + string16(0) + string16(firstCharIndex || properties.firstChar) + "\x00\x03";
  21938. }
  21939. function createPostTable(properties) {
  21940. var angle = Math.floor(properties.italicAngle * 2 ** 16);
  21941. return "\x00\x03\x00\x00" + (0, _util.string32)(angle) + "\x00\x00" + "\x00\x00" + (0, _util.string32)(properties.fixedPitch) + "\x00\x00\x00\x00" + "\x00\x00\x00\x00" + "\x00\x00\x00\x00" + "\x00\x00\x00\x00";
  21942. }
  21943. function createNameTable(name, proto) {
  21944. if (!proto) {
  21945. proto = [[], []];
  21946. }
  21947. var strings = [proto[0][0] || "Original licence", proto[0][1] || name, proto[0][2] || "Unknown", proto[0][3] || "uniqueID", proto[0][4] || name, proto[0][5] || "Version 0.11", proto[0][6] || "", proto[0][7] || "Unknown", proto[0][8] || "Unknown", proto[0][9] || "Unknown"];
  21948. var stringsUnicode = [];
  21949. var i, ii, j, jj, str;
  21950. for (i = 0, ii = strings.length; i < ii; i++) {
  21951. str = proto[1][i] || strings[i];
  21952. var strBufUnicode = [];
  21953. for (j = 0, jj = str.length; j < jj; j++) {
  21954. strBufUnicode.push(string16(str.charCodeAt(j)));
  21955. }
  21956. stringsUnicode.push(strBufUnicode.join(""));
  21957. }
  21958. var names = [strings, stringsUnicode];
  21959. var platforms = ["\x00\x01", "\x00\x03"];
  21960. var encodings = ["\x00\x00", "\x00\x01"];
  21961. var languages = ["\x00\x00", "\x04\x09"];
  21962. var namesRecordCount = strings.length * platforms.length;
  21963. var nameTable = "\x00\x00" + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  21964. var strOffset = 0;
  21965. for (i = 0, ii = platforms.length; i < ii; i++) {
  21966. var strs = names[i];
  21967. for (j = 0, jj = strs.length; j < jj; j++) {
  21968. str = strs[j];
  21969. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  21970. nameTable += nameRecord;
  21971. strOffset += str.length;
  21972. }
  21973. }
  21974. nameTable += strings.join("") + stringsUnicode.join("");
  21975. return nameTable;
  21976. }
  21977. Font.prototype = {
  21978. name: null,
  21979. font: null,
  21980. mimetype: null,
  21981. disableFontFace: false,
  21982. get renderer() {
  21983. var renderer = _font_renderer.FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  21984. return (0, _util.shadow)(this, "renderer", renderer);
  21985. },
  21986. exportData(extraProperties = false) {
  21987. const exportDataProperties = extraProperties ? [...EXPORT_DATA_PROPERTIES, ...EXPORT_DATA_EXTRA_PROPERTIES] : EXPORT_DATA_PROPERTIES;
  21988. const data = Object.create(null);
  21989. let property, value;
  21990. for (property of exportDataProperties) {
  21991. value = this[property];
  21992. if (value !== undefined) {
  21993. data[property] = value;
  21994. }
  21995. }
  21996. return data;
  21997. },
  21998. fallbackToSystemFont: function Font_fallbackToSystemFont() {
  21999. this.missingFile = true;
  22000. var name = this.name;
  22001. var type = this.type;
  22002. var subtype = this.subtype;
  22003. let fontName = name.replace(/[,_]/g, "-").replace(/\s/g, "");
  22004. var stdFontMap = (0, _standard_fonts.getStdFontMap)(),
  22005. nonStdFontMap = (0, _standard_fonts.getNonStdFontMap)();
  22006. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  22007. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  22008. this.bold = fontName.search(/bold/gi) !== -1;
  22009. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  22010. this.black = name.search(/Black/g) !== -1;
  22011. this.remeasure = Object.keys(this.widths).length > 0;
  22012. if (isStandardFont && type === "CIDFontType2" && this.cidEncoding.startsWith("Identity-")) {
  22013. const GlyphMapForStandardFonts = (0, _standard_fonts.getGlyphMapForStandardFonts)();
  22014. const map = [];
  22015. for (const charCode in GlyphMapForStandardFonts) {
  22016. map[+charCode] = GlyphMapForStandardFonts[charCode];
  22017. }
  22018. if (/Arial-?Black/i.test(name)) {
  22019. var SupplementalGlyphMapForArialBlack = (0, _standard_fonts.getSupplementalGlyphMapForArialBlack)();
  22020. for (const charCode in SupplementalGlyphMapForArialBlack) {
  22021. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  22022. }
  22023. } else if (/Calibri/i.test(name)) {
  22024. const SupplementalGlyphMapForCalibri = (0, _standard_fonts.getSupplementalGlyphMapForCalibri)();
  22025. for (const charCode in SupplementalGlyphMapForCalibri) {
  22026. map[+charCode] = SupplementalGlyphMapForCalibri[charCode];
  22027. }
  22028. }
  22029. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  22030. if (!isIdentityUnicode) {
  22031. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  22032. map[+charCode] = unicodeCharCode;
  22033. });
  22034. }
  22035. this.toFontChar = map;
  22036. this.toUnicode = new ToUnicodeMap(map);
  22037. } else if (/Symbol/i.test(fontName)) {
  22038. this.toFontChar = buildToFontChar(_encodings.SymbolSetEncoding, (0, _glyphlist.getGlyphsUnicode)(), this.differences);
  22039. } else if (/Dingbats/i.test(fontName)) {
  22040. if (/Wingdings/i.test(name)) {
  22041. (0, _util.warn)("Non-embedded Wingdings font, falling back to ZapfDingbats.");
  22042. }
  22043. this.toFontChar = buildToFontChar(_encodings.ZapfDingbatsEncoding, (0, _glyphlist.getDingbatsGlyphsUnicode)(), this.differences);
  22044. } else if (isStandardFont) {
  22045. this.toFontChar = buildToFontChar(this.defaultEncoding, (0, _glyphlist.getGlyphsUnicode)(), this.differences);
  22046. } else {
  22047. const glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  22048. const map = [];
  22049. this.toUnicode.forEach((charCode, unicodeCharCode) => {
  22050. if (!this.composite) {
  22051. var glyphName = this.differences[charCode] || this.defaultEncoding[charCode];
  22052. const unicode = (0, _unicode.getUnicodeForGlyph)(glyphName, glyphsUnicodeMap);
  22053. if (unicode !== -1) {
  22054. unicodeCharCode = unicode;
  22055. }
  22056. }
  22057. map[+charCode] = unicodeCharCode;
  22058. });
  22059. if (this.composite && this.toUnicode instanceof IdentityToUnicodeMap) {
  22060. if (/Verdana/i.test(name)) {
  22061. const GlyphMapForStandardFonts = (0, _standard_fonts.getGlyphMapForStandardFonts)();
  22062. for (const charCode in GlyphMapForStandardFonts) {
  22063. map[+charCode] = GlyphMapForStandardFonts[charCode];
  22064. }
  22065. }
  22066. }
  22067. this.toFontChar = map;
  22068. }
  22069. this.loadedName = fontName.split("-")[0];
  22070. this.fontType = getFontType(type, subtype);
  22071. },
  22072. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  22073. const VALID_TABLES = ["OS/2", "cmap", "head", "hhea", "hmtx", "maxp", "name", "post", "loca", "glyf", "fpgm", "prep", "cvt ", "CFF "];
  22074. function readTables(file, numTables) {
  22075. const tables = Object.create(null);
  22076. tables["OS/2"] = null;
  22077. tables.cmap = null;
  22078. tables.head = null;
  22079. tables.hhea = null;
  22080. tables.hmtx = null;
  22081. tables.maxp = null;
  22082. tables.name = null;
  22083. tables.post = null;
  22084. for (let i = 0; i < numTables; i++) {
  22085. const table = readTableEntry(file);
  22086. if (!VALID_TABLES.includes(table.tag)) {
  22087. continue;
  22088. }
  22089. if (table.length === 0) {
  22090. continue;
  22091. }
  22092. tables[table.tag] = table;
  22093. }
  22094. return tables;
  22095. }
  22096. function readTableEntry(file) {
  22097. var tag = (0, _util.bytesToString)(file.getBytes(4));
  22098. var checksum = file.getInt32() >>> 0;
  22099. var offset = file.getInt32() >>> 0;
  22100. var length = file.getInt32() >>> 0;
  22101. var previousPosition = file.pos;
  22102. file.pos = file.start ? file.start : 0;
  22103. file.skip(offset);
  22104. var data = file.getBytes(length);
  22105. file.pos = previousPosition;
  22106. if (tag === "head") {
  22107. data[8] = data[9] = data[10] = data[11] = 0;
  22108. data[17] |= 0x20;
  22109. }
  22110. return {
  22111. tag,
  22112. checksum,
  22113. length,
  22114. offset,
  22115. data
  22116. };
  22117. }
  22118. function readOpenTypeHeader(ttf) {
  22119. return {
  22120. version: (0, _util.bytesToString)(ttf.getBytes(4)),
  22121. numTables: ttf.getUint16(),
  22122. searchRange: ttf.getUint16(),
  22123. entrySelector: ttf.getUint16(),
  22124. rangeShift: ttf.getUint16()
  22125. };
  22126. }
  22127. function readTrueTypeCollectionHeader(ttc) {
  22128. const ttcTag = (0, _util.bytesToString)(ttc.getBytes(4));
  22129. (0, _util.assert)(ttcTag === "ttcf", "Must be a TrueType Collection font.");
  22130. const majorVersion = ttc.getUint16();
  22131. const minorVersion = ttc.getUint16();
  22132. const numFonts = ttc.getInt32() >>> 0;
  22133. const offsetTable = [];
  22134. for (let i = 0; i < numFonts; i++) {
  22135. offsetTable.push(ttc.getInt32() >>> 0);
  22136. }
  22137. const header = {
  22138. ttcTag,
  22139. majorVersion,
  22140. minorVersion,
  22141. numFonts,
  22142. offsetTable
  22143. };
  22144. switch (majorVersion) {
  22145. case 1:
  22146. return header;
  22147. case 2:
  22148. header.dsigTag = ttc.getInt32() >>> 0;
  22149. header.dsigLength = ttc.getInt32() >>> 0;
  22150. header.dsigOffset = ttc.getInt32() >>> 0;
  22151. return header;
  22152. }
  22153. throw new _util.FormatError(`Invalid TrueType Collection majorVersion: ${majorVersion}.`);
  22154. }
  22155. function readTrueTypeCollectionData(ttc, fontName) {
  22156. const {
  22157. numFonts,
  22158. offsetTable
  22159. } = readTrueTypeCollectionHeader(ttc);
  22160. for (let i = 0; i < numFonts; i++) {
  22161. ttc.pos = (ttc.start || 0) + offsetTable[i];
  22162. const potentialHeader = readOpenTypeHeader(ttc);
  22163. const potentialTables = readTables(ttc, potentialHeader.numTables);
  22164. if (!potentialTables.name) {
  22165. throw new _util.FormatError('TrueType Collection font must contain a "name" table.');
  22166. }
  22167. const nameTable = readNameTable(potentialTables.name);
  22168. for (let j = 0, jj = nameTable.length; j < jj; j++) {
  22169. for (let k = 0, kk = nameTable[j].length; k < kk; k++) {
  22170. const nameEntry = nameTable[j][k];
  22171. if (nameEntry && nameEntry.replace(/\s/g, "") === fontName) {
  22172. return {
  22173. header: potentialHeader,
  22174. tables: potentialTables
  22175. };
  22176. }
  22177. }
  22178. }
  22179. }
  22180. throw new _util.FormatError(`TrueType Collection does not contain "${fontName}" font.`);
  22181. }
  22182. function readCmapTable(cmap, file, isSymbolicFont, hasEncoding) {
  22183. if (!cmap) {
  22184. (0, _util.warn)("No cmap table available.");
  22185. return {
  22186. platformId: -1,
  22187. encodingId: -1,
  22188. mappings: [],
  22189. hasShortCmap: false
  22190. };
  22191. }
  22192. var segment;
  22193. var start = (file.start ? file.start : 0) + cmap.offset;
  22194. file.pos = start;
  22195. file.skip(2);
  22196. var numTables = file.getUint16();
  22197. var potentialTable;
  22198. var canBreak = false;
  22199. for (var i = 0; i < numTables; i++) {
  22200. var platformId = file.getUint16();
  22201. var encodingId = file.getUint16();
  22202. var offset = file.getInt32() >>> 0;
  22203. var useTable = false;
  22204. if (potentialTable && potentialTable.platformId === platformId && potentialTable.encodingId === encodingId) {
  22205. continue;
  22206. }
  22207. if (platformId === 0 && (encodingId === 0 || encodingId === 1 || encodingId === 3)) {
  22208. useTable = true;
  22209. } else if (platformId === 1 && encodingId === 0) {
  22210. useTable = true;
  22211. } else if (platformId === 3 && encodingId === 1 && (hasEncoding || !potentialTable)) {
  22212. useTable = true;
  22213. if (!isSymbolicFont) {
  22214. canBreak = true;
  22215. }
  22216. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  22217. useTable = true;
  22218. canBreak = true;
  22219. }
  22220. if (useTable) {
  22221. potentialTable = {
  22222. platformId,
  22223. encodingId,
  22224. offset
  22225. };
  22226. }
  22227. if (canBreak) {
  22228. break;
  22229. }
  22230. }
  22231. if (potentialTable) {
  22232. file.pos = start + potentialTable.offset;
  22233. }
  22234. if (!potentialTable || file.peekByte() === -1) {
  22235. (0, _util.warn)("Could not find a preferred cmap table.");
  22236. return {
  22237. platformId: -1,
  22238. encodingId: -1,
  22239. mappings: [],
  22240. hasShortCmap: false
  22241. };
  22242. }
  22243. var format = file.getUint16();
  22244. file.skip(2 + 2);
  22245. var hasShortCmap = false;
  22246. var mappings = [];
  22247. var j, glyphId;
  22248. if (format === 0) {
  22249. for (j = 0; j < 256; j++) {
  22250. var index = file.getByte();
  22251. if (!index) {
  22252. continue;
  22253. }
  22254. mappings.push({
  22255. charCode: j,
  22256. glyphId: index
  22257. });
  22258. }
  22259. hasShortCmap = true;
  22260. } else if (format === 4) {
  22261. var segCount = file.getUint16() >> 1;
  22262. file.skip(6);
  22263. var segIndex,
  22264. segments = [];
  22265. for (segIndex = 0; segIndex < segCount; segIndex++) {
  22266. segments.push({
  22267. end: file.getUint16()
  22268. });
  22269. }
  22270. file.skip(2);
  22271. for (segIndex = 0; segIndex < segCount; segIndex++) {
  22272. segments[segIndex].start = file.getUint16();
  22273. }
  22274. for (segIndex = 0; segIndex < segCount; segIndex++) {
  22275. segments[segIndex].delta = file.getUint16();
  22276. }
  22277. var offsetsCount = 0;
  22278. for (segIndex = 0; segIndex < segCount; segIndex++) {
  22279. segment = segments[segIndex];
  22280. var rangeOffset = file.getUint16();
  22281. if (!rangeOffset) {
  22282. segment.offsetIndex = -1;
  22283. continue;
  22284. }
  22285. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  22286. segment.offsetIndex = offsetIndex;
  22287. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  22288. }
  22289. var offsets = [];
  22290. for (j = 0; j < offsetsCount; j++) {
  22291. offsets.push(file.getUint16());
  22292. }
  22293. for (segIndex = 0; segIndex < segCount; segIndex++) {
  22294. segment = segments[segIndex];
  22295. start = segment.start;
  22296. var end = segment.end;
  22297. var delta = segment.delta;
  22298. offsetIndex = segment.offsetIndex;
  22299. for (j = start; j <= end; j++) {
  22300. if (j === 0xffff) {
  22301. continue;
  22302. }
  22303. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  22304. glyphId = glyphId + delta & 0xffff;
  22305. mappings.push({
  22306. charCode: j,
  22307. glyphId
  22308. });
  22309. }
  22310. }
  22311. } else if (format === 6) {
  22312. var firstCode = file.getUint16();
  22313. var entryCount = file.getUint16();
  22314. for (j = 0; j < entryCount; j++) {
  22315. glyphId = file.getUint16();
  22316. var charCode = firstCode + j;
  22317. mappings.push({
  22318. charCode,
  22319. glyphId
  22320. });
  22321. }
  22322. } else {
  22323. (0, _util.warn)("cmap table has unsupported format: " + format);
  22324. return {
  22325. platformId: -1,
  22326. encodingId: -1,
  22327. mappings: [],
  22328. hasShortCmap: false
  22329. };
  22330. }
  22331. mappings.sort(function (a, b) {
  22332. return a.charCode - b.charCode;
  22333. });
  22334. for (i = 1; i < mappings.length; i++) {
  22335. if (mappings[i - 1].charCode === mappings[i].charCode) {
  22336. mappings.splice(i, 1);
  22337. i--;
  22338. }
  22339. }
  22340. return {
  22341. platformId: potentialTable.platformId,
  22342. encodingId: potentialTable.encodingId,
  22343. mappings,
  22344. hasShortCmap
  22345. };
  22346. }
  22347. function sanitizeMetrics(file, header, metrics, numGlyphs, dupFirstEntry) {
  22348. if (!header) {
  22349. if (metrics) {
  22350. metrics.data = null;
  22351. }
  22352. return;
  22353. }
  22354. file.pos = (file.start ? file.start : 0) + header.offset;
  22355. file.pos += 4;
  22356. file.pos += 2;
  22357. file.pos += 2;
  22358. file.pos += 2;
  22359. file.pos += 2;
  22360. file.pos += 2;
  22361. file.pos += 2;
  22362. file.pos += 2;
  22363. file.pos += 2;
  22364. file.pos += 2;
  22365. file.pos += 2;
  22366. file.pos += 8;
  22367. file.pos += 2;
  22368. var numOfMetrics = file.getUint16();
  22369. if (numOfMetrics > numGlyphs) {
  22370. (0, _util.info)("The numOfMetrics (" + numOfMetrics + ") should not be " + "greater than the numGlyphs (" + numGlyphs + ")");
  22371. numOfMetrics = numGlyphs;
  22372. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  22373. header.data[35] = numOfMetrics & 0x00ff;
  22374. }
  22375. var numOfSidebearings = numGlyphs - numOfMetrics;
  22376. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  22377. if (numMissing > 0) {
  22378. var entries = new Uint8Array(metrics.length + numMissing * 2);
  22379. entries.set(metrics.data);
  22380. if (dupFirstEntry) {
  22381. entries[metrics.length] = metrics.data[2];
  22382. entries[metrics.length + 1] = metrics.data[3];
  22383. }
  22384. metrics.data = entries;
  22385. }
  22386. }
  22387. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  22388. var glyphProfile = {
  22389. length: 0,
  22390. sizeOfInstructions: 0
  22391. };
  22392. if (sourceEnd - sourceStart <= 12) {
  22393. return glyphProfile;
  22394. }
  22395. var glyf = source.subarray(sourceStart, sourceEnd);
  22396. var contoursCount = signedInt16(glyf[0], glyf[1]);
  22397. if (contoursCount < 0) {
  22398. contoursCount = -1;
  22399. writeSignedInt16(glyf, 0, contoursCount);
  22400. dest.set(glyf, destStart);
  22401. glyphProfile.length = glyf.length;
  22402. return glyphProfile;
  22403. }
  22404. var i,
  22405. j = 10,
  22406. flagsCount = 0;
  22407. for (i = 0; i < contoursCount; i++) {
  22408. var endPoint = glyf[j] << 8 | glyf[j + 1];
  22409. flagsCount = endPoint + 1;
  22410. j += 2;
  22411. }
  22412. var instructionsStart = j;
  22413. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  22414. glyphProfile.sizeOfInstructions = instructionsLength;
  22415. j += 2 + instructionsLength;
  22416. var instructionsEnd = j;
  22417. var coordinatesLength = 0;
  22418. for (i = 0; i < flagsCount; i++) {
  22419. var flag = glyf[j++];
  22420. if (flag & 0xc0) {
  22421. glyf[j - 1] = flag & 0x3f;
  22422. }
  22423. let xLength = 2;
  22424. if (flag & 2) {
  22425. xLength = 1;
  22426. } else if (flag & 16) {
  22427. xLength = 0;
  22428. }
  22429. let yLength = 2;
  22430. if (flag & 4) {
  22431. yLength = 1;
  22432. } else if (flag & 32) {
  22433. yLength = 0;
  22434. }
  22435. const xyLength = xLength + yLength;
  22436. coordinatesLength += xyLength;
  22437. if (flag & 8) {
  22438. var repeat = glyf[j++];
  22439. i += repeat;
  22440. coordinatesLength += repeat * xyLength;
  22441. }
  22442. }
  22443. if (coordinatesLength === 0) {
  22444. return glyphProfile;
  22445. }
  22446. var glyphDataLength = j + coordinatesLength;
  22447. if (glyphDataLength > glyf.length) {
  22448. return glyphProfile;
  22449. }
  22450. if (!hintsValid && instructionsLength > 0) {
  22451. dest.set(glyf.subarray(0, instructionsStart), destStart);
  22452. dest.set([0, 0], destStart + instructionsStart);
  22453. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  22454. glyphDataLength -= instructionsLength;
  22455. if (glyf.length - glyphDataLength > 3) {
  22456. glyphDataLength = glyphDataLength + 3 & ~3;
  22457. }
  22458. glyphProfile.length = glyphDataLength;
  22459. return glyphProfile;
  22460. }
  22461. if (glyf.length - glyphDataLength > 3) {
  22462. glyphDataLength = glyphDataLength + 3 & ~3;
  22463. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  22464. glyphProfile.length = glyphDataLength;
  22465. return glyphProfile;
  22466. }
  22467. dest.set(glyf, destStart);
  22468. glyphProfile.length = glyf.length;
  22469. return glyphProfile;
  22470. }
  22471. function sanitizeHead(head, numGlyphs, locaLength) {
  22472. var data = head.data;
  22473. var version = int32(data[0], data[1], data[2], data[3]);
  22474. if (version >> 16 !== 1) {
  22475. (0, _util.info)("Attempting to fix invalid version in head table: " + version);
  22476. data[0] = 0;
  22477. data[1] = 1;
  22478. data[2] = 0;
  22479. data[3] = 0;
  22480. }
  22481. var indexToLocFormat = int16(data[50], data[51]);
  22482. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  22483. (0, _util.info)("Attempting to fix invalid indexToLocFormat in head table: " + indexToLocFormat);
  22484. var numGlyphsPlusOne = numGlyphs + 1;
  22485. if (locaLength === numGlyphsPlusOne << 1) {
  22486. data[50] = 0;
  22487. data[51] = 0;
  22488. } else if (locaLength === numGlyphsPlusOne << 2) {
  22489. data[50] = 0;
  22490. data[51] = 1;
  22491. } else {
  22492. throw new _util.FormatError("Could not fix indexToLocFormat: " + indexToLocFormat);
  22493. }
  22494. }
  22495. }
  22496. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry, maxSizeOfInstructions) {
  22497. var itemSize, itemDecode, itemEncode;
  22498. if (isGlyphLocationsLong) {
  22499. itemSize = 4;
  22500. itemDecode = function fontItemDecodeLong(data, offset) {
  22501. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  22502. };
  22503. itemEncode = function fontItemEncodeLong(data, offset, value) {
  22504. data[offset] = value >>> 24 & 0xff;
  22505. data[offset + 1] = value >> 16 & 0xff;
  22506. data[offset + 2] = value >> 8 & 0xff;
  22507. data[offset + 3] = value & 0xff;
  22508. };
  22509. } else {
  22510. itemSize = 2;
  22511. itemDecode = function fontItemDecode(data, offset) {
  22512. return data[offset] << 9 | data[offset + 1] << 1;
  22513. };
  22514. itemEncode = function fontItemEncode(data, offset, value) {
  22515. data[offset] = value >> 9 & 0xff;
  22516. data[offset + 1] = value >> 1 & 0xff;
  22517. };
  22518. }
  22519. var numGlyphsOut = dupFirstEntry ? numGlyphs + 1 : numGlyphs;
  22520. var locaDataSize = itemSize * (1 + numGlyphsOut);
  22521. var locaData = new Uint8Array(locaDataSize);
  22522. locaData.set(loca.data.subarray(0, locaDataSize));
  22523. loca.data = locaData;
  22524. var oldGlyfData = glyf.data;
  22525. var oldGlyfDataLength = oldGlyfData.length;
  22526. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  22527. var i, j;
  22528. const locaEntries = [];
  22529. for (i = 0, j = 0; i < numGlyphs + 1; i++, j += itemSize) {
  22530. let offset = itemDecode(locaData, j);
  22531. if (offset > oldGlyfDataLength) {
  22532. offset = oldGlyfDataLength;
  22533. }
  22534. locaEntries.push({
  22535. index: i,
  22536. offset,
  22537. endOffset: 0
  22538. });
  22539. }
  22540. locaEntries.sort((a, b) => {
  22541. return a.offset - b.offset;
  22542. });
  22543. for (i = 0; i < numGlyphs; i++) {
  22544. locaEntries[i].endOffset = locaEntries[i + 1].offset;
  22545. }
  22546. locaEntries.sort((a, b) => {
  22547. return a.index - b.index;
  22548. });
  22549. var missingGlyphs = Object.create(null);
  22550. var writeOffset = 0;
  22551. itemEncode(locaData, 0, writeOffset);
  22552. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  22553. var glyphProfile = sanitizeGlyph(oldGlyfData, locaEntries[i].offset, locaEntries[i].endOffset, newGlyfData, writeOffset, hintsValid);
  22554. var newLength = glyphProfile.length;
  22555. if (newLength === 0) {
  22556. missingGlyphs[i] = true;
  22557. }
  22558. if (glyphProfile.sizeOfInstructions > maxSizeOfInstructions) {
  22559. maxSizeOfInstructions = glyphProfile.sizeOfInstructions;
  22560. }
  22561. writeOffset += newLength;
  22562. itemEncode(locaData, j, writeOffset);
  22563. }
  22564. if (writeOffset === 0) {
  22565. var simpleGlyph = new Uint8Array([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 0]);
  22566. for (i = 0, j = itemSize; i < numGlyphsOut; i++, j += itemSize) {
  22567. itemEncode(locaData, j, simpleGlyph.length);
  22568. }
  22569. glyf.data = simpleGlyph;
  22570. } else if (dupFirstEntry) {
  22571. var firstEntryLength = itemDecode(locaData, itemSize);
  22572. if (newGlyfData.length > firstEntryLength + writeOffset) {
  22573. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  22574. } else {
  22575. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  22576. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  22577. }
  22578. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  22579. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  22580. } else {
  22581. glyf.data = newGlyfData.subarray(0, writeOffset);
  22582. }
  22583. return {
  22584. missingGlyphs,
  22585. maxSizeOfInstructions
  22586. };
  22587. }
  22588. function readPostScriptTable(post, propertiesObj, maxpNumGlyphs) {
  22589. var start = (font.start ? font.start : 0) + post.offset;
  22590. font.pos = start;
  22591. var length = post.length,
  22592. end = start + length;
  22593. var version = font.getInt32();
  22594. font.skip(28);
  22595. var glyphNames;
  22596. var valid = true;
  22597. var i;
  22598. switch (version) {
  22599. case 0x00010000:
  22600. glyphNames = MacStandardGlyphOrdering;
  22601. break;
  22602. case 0x00020000:
  22603. var numGlyphs = font.getUint16();
  22604. if (numGlyphs !== maxpNumGlyphs) {
  22605. valid = false;
  22606. break;
  22607. }
  22608. var glyphNameIndexes = [];
  22609. for (i = 0; i < numGlyphs; ++i) {
  22610. var index = font.getUint16();
  22611. if (index >= 32768) {
  22612. valid = false;
  22613. break;
  22614. }
  22615. glyphNameIndexes.push(index);
  22616. }
  22617. if (!valid) {
  22618. break;
  22619. }
  22620. var customNames = [];
  22621. var strBuf = [];
  22622. while (font.pos < end) {
  22623. var stringLength = font.getByte();
  22624. strBuf.length = stringLength;
  22625. for (i = 0; i < stringLength; ++i) {
  22626. strBuf[i] = String.fromCharCode(font.getByte());
  22627. }
  22628. customNames.push(strBuf.join(""));
  22629. }
  22630. glyphNames = [];
  22631. for (i = 0; i < numGlyphs; ++i) {
  22632. var j = glyphNameIndexes[i];
  22633. if (j < 258) {
  22634. glyphNames.push(MacStandardGlyphOrdering[j]);
  22635. continue;
  22636. }
  22637. glyphNames.push(customNames[j - 258]);
  22638. }
  22639. break;
  22640. case 0x00030000:
  22641. break;
  22642. default:
  22643. (0, _util.warn)("Unknown/unsupported post table version " + version);
  22644. valid = false;
  22645. if (propertiesObj.defaultEncoding) {
  22646. glyphNames = propertiesObj.defaultEncoding;
  22647. }
  22648. break;
  22649. }
  22650. propertiesObj.glyphNames = glyphNames;
  22651. return valid;
  22652. }
  22653. function readNameTable(nameTable) {
  22654. var start = (font.start ? font.start : 0) + nameTable.offset;
  22655. font.pos = start;
  22656. var names = [[], []];
  22657. var length = nameTable.length,
  22658. end = start + length;
  22659. var format = font.getUint16();
  22660. var FORMAT_0_HEADER_LENGTH = 6;
  22661. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  22662. return names;
  22663. }
  22664. var numRecords = font.getUint16();
  22665. var stringsStart = font.getUint16();
  22666. var records = [];
  22667. var NAME_RECORD_LENGTH = 12;
  22668. var i, ii;
  22669. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  22670. var r = {
  22671. platform: font.getUint16(),
  22672. encoding: font.getUint16(),
  22673. language: font.getUint16(),
  22674. name: font.getUint16(),
  22675. length: font.getUint16(),
  22676. offset: font.getUint16()
  22677. };
  22678. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  22679. records.push(r);
  22680. }
  22681. }
  22682. for (i = 0, ii = records.length; i < ii; i++) {
  22683. var record = records[i];
  22684. if (record.length <= 0) {
  22685. continue;
  22686. }
  22687. var pos = start + stringsStart + record.offset;
  22688. if (pos + record.length > end) {
  22689. continue;
  22690. }
  22691. font.pos = pos;
  22692. var nameIndex = record.name;
  22693. if (record.encoding) {
  22694. var str = "";
  22695. for (var j = 0, jj = record.length; j < jj; j += 2) {
  22696. str += String.fromCharCode(font.getUint16());
  22697. }
  22698. names[1][nameIndex] = str;
  22699. } else {
  22700. names[0][nameIndex] = (0, _util.bytesToString)(font.getBytes(record.length));
  22701. }
  22702. }
  22703. return names;
  22704. }
  22705. var TTOpsStackDeltas = [0, 0, 0, 0, 0, 0, 0, 0, -2, -2, -2, -2, 0, 0, -2, -5, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, 0, -1, -1, -1, -1, 1, -1, -999, 0, 1, 0, -1, -2, 0, -1, -2, -1, -1, 0, -1, -1, 0, 0, -999, -999, -1, -1, -1, -1, -2, -999, -2, -2, -999, 0, -2, -2, 0, 0, -2, 0, -2, 0, 0, 0, -2, -1, -1, 1, 1, 0, 0, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, 0, -1, -1, 0, -999, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, -999, -999, -999, -999, -999, -1, -1, -2, -2, 0, 0, 0, 0, -1, -1, -999, -2, -2, 0, 0, -1, -2, -2, 0, 0, 0, -1, -1, -1, -2];
  22706. function sanitizeTTProgram(table, ttContext) {
  22707. var data = table.data;
  22708. var i = 0,
  22709. j,
  22710. n,
  22711. b,
  22712. funcId,
  22713. pc,
  22714. lastEndf = 0,
  22715. lastDeff = 0;
  22716. var stack = [];
  22717. var callstack = [];
  22718. var functionsCalled = [];
  22719. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  22720. var inFDEF = false,
  22721. ifLevel = 0,
  22722. inELSE = 0;
  22723. for (var ii = data.length; i < ii;) {
  22724. var op = data[i++];
  22725. if (op === 0x40) {
  22726. n = data[i++];
  22727. if (inFDEF || inELSE) {
  22728. i += n;
  22729. } else {
  22730. for (j = 0; j < n; j++) {
  22731. stack.push(data[i++]);
  22732. }
  22733. }
  22734. } else if (op === 0x41) {
  22735. n = data[i++];
  22736. if (inFDEF || inELSE) {
  22737. i += n * 2;
  22738. } else {
  22739. for (j = 0; j < n; j++) {
  22740. b = data[i++];
  22741. stack.push(b << 8 | data[i++]);
  22742. }
  22743. }
  22744. } else if ((op & 0xf8) === 0xb0) {
  22745. n = op - 0xb0 + 1;
  22746. if (inFDEF || inELSE) {
  22747. i += n;
  22748. } else {
  22749. for (j = 0; j < n; j++) {
  22750. stack.push(data[i++]);
  22751. }
  22752. }
  22753. } else if ((op & 0xf8) === 0xb8) {
  22754. n = op - 0xb8 + 1;
  22755. if (inFDEF || inELSE) {
  22756. i += n * 2;
  22757. } else {
  22758. for (j = 0; j < n; j++) {
  22759. b = data[i++];
  22760. stack.push(b << 8 | data[i++]);
  22761. }
  22762. }
  22763. } else if (op === 0x2b && !tooComplexToFollowFunctions) {
  22764. if (!inFDEF && !inELSE) {
  22765. funcId = stack[stack.length - 1];
  22766. if (isNaN(funcId)) {
  22767. (0, _util.info)("TT: CALL empty stack (or invalid entry).");
  22768. } else {
  22769. ttContext.functionsUsed[funcId] = true;
  22770. if (funcId in ttContext.functionsStackDeltas) {
  22771. const newStackLength = stack.length + ttContext.functionsStackDeltas[funcId];
  22772. if (newStackLength < 0) {
  22773. (0, _util.warn)("TT: CALL invalid functions stack delta.");
  22774. ttContext.hintsValid = false;
  22775. return;
  22776. }
  22777. stack.length = newStackLength;
  22778. } else if (funcId in ttContext.functionsDefined && !functionsCalled.includes(funcId)) {
  22779. callstack.push({
  22780. data,
  22781. i,
  22782. stackTop: stack.length - 1
  22783. });
  22784. functionsCalled.push(funcId);
  22785. pc = ttContext.functionsDefined[funcId];
  22786. if (!pc) {
  22787. (0, _util.warn)("TT: CALL non-existent function");
  22788. ttContext.hintsValid = false;
  22789. return;
  22790. }
  22791. data = pc.data;
  22792. i = pc.i;
  22793. }
  22794. }
  22795. }
  22796. } else if (op === 0x2c && !tooComplexToFollowFunctions) {
  22797. if (inFDEF || inELSE) {
  22798. (0, _util.warn)("TT: nested FDEFs not allowed");
  22799. tooComplexToFollowFunctions = true;
  22800. }
  22801. inFDEF = true;
  22802. lastDeff = i;
  22803. funcId = stack.pop();
  22804. ttContext.functionsDefined[funcId] = {
  22805. data,
  22806. i
  22807. };
  22808. } else if (op === 0x2d) {
  22809. if (inFDEF) {
  22810. inFDEF = false;
  22811. lastEndf = i;
  22812. } else {
  22813. pc = callstack.pop();
  22814. if (!pc) {
  22815. (0, _util.warn)("TT: ENDF bad stack");
  22816. ttContext.hintsValid = false;
  22817. return;
  22818. }
  22819. funcId = functionsCalled.pop();
  22820. data = pc.data;
  22821. i = pc.i;
  22822. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  22823. }
  22824. } else if (op === 0x89) {
  22825. if (inFDEF || inELSE) {
  22826. (0, _util.warn)("TT: nested IDEFs not allowed");
  22827. tooComplexToFollowFunctions = true;
  22828. }
  22829. inFDEF = true;
  22830. lastDeff = i;
  22831. } else if (op === 0x58) {
  22832. ++ifLevel;
  22833. } else if (op === 0x1b) {
  22834. inELSE = ifLevel;
  22835. } else if (op === 0x59) {
  22836. if (inELSE === ifLevel) {
  22837. inELSE = 0;
  22838. }
  22839. --ifLevel;
  22840. } else if (op === 0x1c) {
  22841. if (!inFDEF && !inELSE) {
  22842. var offset = stack[stack.length - 1];
  22843. if (offset > 0) {
  22844. i += offset - 1;
  22845. }
  22846. }
  22847. }
  22848. if (!inFDEF && !inELSE) {
  22849. let stackDelta = 0;
  22850. if (op <= 0x8e) {
  22851. stackDelta = TTOpsStackDeltas[op];
  22852. } else if (op >= 0xc0 && op <= 0xdf) {
  22853. stackDelta = -1;
  22854. } else if (op >= 0xe0) {
  22855. stackDelta = -2;
  22856. }
  22857. if (op >= 0x71 && op <= 0x75) {
  22858. n = stack.pop();
  22859. if (!isNaN(n)) {
  22860. stackDelta = -n * 2;
  22861. }
  22862. }
  22863. while (stackDelta < 0 && stack.length > 0) {
  22864. stack.pop();
  22865. stackDelta++;
  22866. }
  22867. while (stackDelta > 0) {
  22868. stack.push(NaN);
  22869. stackDelta--;
  22870. }
  22871. }
  22872. }
  22873. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  22874. var content = [data];
  22875. if (i > data.length) {
  22876. content.push(new Uint8Array(i - data.length));
  22877. }
  22878. if (lastDeff > lastEndf) {
  22879. (0, _util.warn)("TT: complementing a missing function tail");
  22880. content.push(new Uint8Array([0x22, 0x2d]));
  22881. }
  22882. foldTTTable(table, content);
  22883. }
  22884. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  22885. if (ttContext.tooComplexToFollowFunctions) {
  22886. return;
  22887. }
  22888. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  22889. (0, _util.warn)("TT: more functions defined than expected");
  22890. ttContext.hintsValid = false;
  22891. return;
  22892. }
  22893. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  22894. if (j > maxFunctionDefs) {
  22895. (0, _util.warn)("TT: invalid function id: " + j);
  22896. ttContext.hintsValid = false;
  22897. return;
  22898. }
  22899. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  22900. (0, _util.warn)("TT: undefined function: " + j);
  22901. ttContext.hintsValid = false;
  22902. return;
  22903. }
  22904. }
  22905. }
  22906. function foldTTTable(table, content) {
  22907. if (content.length > 1) {
  22908. var newLength = 0;
  22909. var j, jj;
  22910. for (j = 0, jj = content.length; j < jj; j++) {
  22911. newLength += content[j].length;
  22912. }
  22913. newLength = newLength + 3 & ~3;
  22914. var result = new Uint8Array(newLength);
  22915. var pos = 0;
  22916. for (j = 0, jj = content.length; j < jj; j++) {
  22917. result.set(content[j], pos);
  22918. pos += content[j].length;
  22919. }
  22920. table.data = result;
  22921. table.length = newLength;
  22922. }
  22923. }
  22924. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  22925. var ttContext = {
  22926. functionsDefined: [],
  22927. functionsUsed: [],
  22928. functionsStackDeltas: [],
  22929. tooComplexToFollowFunctions: false,
  22930. hintsValid: true
  22931. };
  22932. if (fpgm) {
  22933. sanitizeTTProgram(fpgm, ttContext);
  22934. }
  22935. if (prep) {
  22936. sanitizeTTProgram(prep, ttContext);
  22937. }
  22938. if (fpgm) {
  22939. checkInvalidFunctions(ttContext, maxFunctionDefs);
  22940. }
  22941. if (cvt && cvt.length & 1) {
  22942. var cvtData = new Uint8Array(cvt.length + 1);
  22943. cvtData.set(cvt.data);
  22944. cvt.data = cvtData;
  22945. }
  22946. return ttContext.hintsValid;
  22947. }
  22948. font = new _stream.Stream(new Uint8Array(font.getBytes()));
  22949. let header, tables;
  22950. if (isTrueTypeCollectionFile(font)) {
  22951. const ttcData = readTrueTypeCollectionData(font, this.name);
  22952. header = ttcData.header;
  22953. tables = ttcData.tables;
  22954. } else {
  22955. header = readOpenTypeHeader(font);
  22956. tables = readTables(font, header.numTables);
  22957. }
  22958. let cff, cffFile;
  22959. var isTrueType = !tables["CFF "];
  22960. if (!isTrueType) {
  22961. const isComposite = properties.composite && ((properties.cidToGidMap || []).length > 0 || !(properties.cMap instanceof _cmap.IdentityCMap));
  22962. if (header.version === "OTTO" && !isComposite || !tables.head || !tables.hhea || !tables.maxp || !tables.post) {
  22963. cffFile = new _stream.Stream(tables["CFF "].data);
  22964. cff = new CFFFont(cffFile, properties);
  22965. adjustWidths(properties);
  22966. return this.convert(name, cff, properties);
  22967. }
  22968. delete tables.glyf;
  22969. delete tables.loca;
  22970. delete tables.fpgm;
  22971. delete tables.prep;
  22972. delete tables["cvt "];
  22973. this.isOpenType = true;
  22974. } else {
  22975. if (!tables.loca) {
  22976. throw new _util.FormatError('Required "loca" table is not found');
  22977. }
  22978. if (!tables.glyf) {
  22979. (0, _util.warn)('Required "glyf" table is not found -- trying to recover.');
  22980. tables.glyf = {
  22981. tag: "glyf",
  22982. data: new Uint8Array(0)
  22983. };
  22984. }
  22985. this.isOpenType = false;
  22986. }
  22987. if (!tables.maxp) {
  22988. throw new _util.FormatError('Required "maxp" table is not found');
  22989. }
  22990. font.pos = (font.start || 0) + tables.maxp.offset;
  22991. var version = font.getInt32();
  22992. const numGlyphs = font.getUint16();
  22993. let numGlyphsOut = numGlyphs + 1;
  22994. let dupFirstEntry = true;
  22995. if (numGlyphsOut > 0xffff) {
  22996. dupFirstEntry = false;
  22997. numGlyphsOut = numGlyphs;
  22998. (0, _util.warn)("Not enough space in glyfs to duplicate first glyph.");
  22999. }
  23000. var maxFunctionDefs = 0;
  23001. var maxSizeOfInstructions = 0;
  23002. if (version >= 0x00010000 && tables.maxp.length >= 22) {
  23003. font.pos += 8;
  23004. var maxZones = font.getUint16();
  23005. if (maxZones > 2) {
  23006. tables.maxp.data[14] = 0;
  23007. tables.maxp.data[15] = 2;
  23008. }
  23009. font.pos += 4;
  23010. maxFunctionDefs = font.getUint16();
  23011. font.pos += 4;
  23012. maxSizeOfInstructions = font.getUint16();
  23013. }
  23014. tables.maxp.data[4] = numGlyphsOut >> 8;
  23015. tables.maxp.data[5] = numGlyphsOut & 255;
  23016. var hintsValid = sanitizeTTPrograms(tables.fpgm, tables.prep, tables["cvt "], maxFunctionDefs);
  23017. if (!hintsValid) {
  23018. delete tables.fpgm;
  23019. delete tables.prep;
  23020. delete tables["cvt "];
  23021. }
  23022. sanitizeMetrics(font, tables.hhea, tables.hmtx, numGlyphsOut, dupFirstEntry);
  23023. if (!tables.head) {
  23024. throw new _util.FormatError('Required "head" table is not found');
  23025. }
  23026. sanitizeHead(tables.head, numGlyphs, isTrueType ? tables.loca.length : 0);
  23027. var missingGlyphs = Object.create(null);
  23028. if (isTrueType) {
  23029. var isGlyphLocationsLong = int16(tables.head.data[50], tables.head.data[51]);
  23030. var glyphsInfo = sanitizeGlyphLocations(tables.loca, tables.glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry, maxSizeOfInstructions);
  23031. missingGlyphs = glyphsInfo.missingGlyphs;
  23032. if (version >= 0x00010000 && tables.maxp.length >= 22) {
  23033. tables.maxp.data[26] = glyphsInfo.maxSizeOfInstructions >> 8;
  23034. tables.maxp.data[27] = glyphsInfo.maxSizeOfInstructions & 255;
  23035. }
  23036. }
  23037. if (!tables.hhea) {
  23038. throw new _util.FormatError('Required "hhea" table is not found');
  23039. }
  23040. if (tables.hhea.data[10] === 0 && tables.hhea.data[11] === 0) {
  23041. tables.hhea.data[10] = 0xff;
  23042. tables.hhea.data[11] = 0xff;
  23043. }
  23044. var metricsOverride = {
  23045. unitsPerEm: int16(tables.head.data[18], tables.head.data[19]),
  23046. yMax: int16(tables.head.data[42], tables.head.data[43]),
  23047. yMin: signedInt16(tables.head.data[38], tables.head.data[39]),
  23048. ascent: int16(tables.hhea.data[4], tables.hhea.data[5]),
  23049. descent: signedInt16(tables.hhea.data[6], tables.hhea.data[7])
  23050. };
  23051. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  23052. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  23053. if (tables.post) {
  23054. readPostScriptTable(tables.post, properties, numGlyphs);
  23055. }
  23056. tables.post = {
  23057. tag: "post",
  23058. data: createPostTable(properties)
  23059. };
  23060. const charCodeToGlyphId = [];
  23061. function hasGlyph(glyphId) {
  23062. return !missingGlyphs[glyphId];
  23063. }
  23064. if (properties.composite) {
  23065. var cidToGidMap = properties.cidToGidMap || [];
  23066. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  23067. properties.cMap.forEach(function (charCode, cid) {
  23068. if (cid > 0xffff) {
  23069. throw new _util.FormatError("Max size of CID is 65,535");
  23070. }
  23071. var glyphId = -1;
  23072. if (isCidToGidMapEmpty) {
  23073. glyphId = cid;
  23074. } else if (cidToGidMap[cid] !== undefined) {
  23075. glyphId = cidToGidMap[cid];
  23076. }
  23077. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId)) {
  23078. charCodeToGlyphId[charCode] = glyphId;
  23079. }
  23080. });
  23081. } else {
  23082. var cmapTable = readCmapTable(tables.cmap, font, this.isSymbolicFont, properties.hasEncoding);
  23083. var cmapPlatformId = cmapTable.platformId;
  23084. var cmapEncodingId = cmapTable.encodingId;
  23085. var cmapMappings = cmapTable.mappings;
  23086. var cmapMappingsLength = cmapMappings.length;
  23087. let baseEncoding = [];
  23088. if (properties.hasEncoding && (properties.baseEncodingName === "MacRomanEncoding" || properties.baseEncodingName === "WinAnsiEncoding")) {
  23089. baseEncoding = (0, _encodings.getEncoding)(properties.baseEncodingName);
  23090. }
  23091. if (properties.hasEncoding && !this.isSymbolicFont && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0)) {
  23092. var glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  23093. for (let charCode = 0; charCode < 256; charCode++) {
  23094. var glyphName, standardGlyphName;
  23095. if (this.differences && charCode in this.differences) {
  23096. glyphName = this.differences[charCode];
  23097. } else if (charCode in baseEncoding && baseEncoding[charCode] !== "") {
  23098. glyphName = baseEncoding[charCode];
  23099. } else {
  23100. glyphName = _encodings.StandardEncoding[charCode];
  23101. }
  23102. if (!glyphName) {
  23103. continue;
  23104. }
  23105. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  23106. var unicodeOrCharCode;
  23107. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  23108. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  23109. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  23110. unicodeOrCharCode = _encodings.MacRomanEncoding.indexOf(standardGlyphName);
  23111. }
  23112. for (let i = 0; i < cmapMappingsLength; ++i) {
  23113. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  23114. continue;
  23115. }
  23116. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  23117. break;
  23118. }
  23119. }
  23120. } else if (cmapPlatformId === 0) {
  23121. for (let i = 0; i < cmapMappingsLength; ++i) {
  23122. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  23123. }
  23124. } else {
  23125. for (let i = 0; i < cmapMappingsLength; ++i) {
  23126. let charCode = cmapMappings[i].charCode;
  23127. if (cmapPlatformId === 3 && charCode >= 0xf000 && charCode <= 0xf0ff) {
  23128. charCode &= 0xff;
  23129. }
  23130. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  23131. }
  23132. }
  23133. if (properties.glyphNames && baseEncoding.length) {
  23134. for (let i = 0; i < 256; ++i) {
  23135. if (charCodeToGlyphId[i] === undefined && baseEncoding[i]) {
  23136. glyphName = baseEncoding[i];
  23137. const glyphId = properties.glyphNames.indexOf(glyphName);
  23138. if (glyphId > 0 && hasGlyph(glyphId)) {
  23139. charCodeToGlyphId[i] = glyphId;
  23140. }
  23141. }
  23142. }
  23143. }
  23144. }
  23145. if (charCodeToGlyphId.length === 0) {
  23146. charCodeToGlyphId[0] = 0;
  23147. }
  23148. let glyphZeroId = numGlyphsOut - 1;
  23149. if (!dupFirstEntry) {
  23150. glyphZeroId = 0;
  23151. }
  23152. var newMapping = adjustMapping(charCodeToGlyphId, hasGlyph, glyphZeroId);
  23153. this.toFontChar = newMapping.toFontChar;
  23154. tables.cmap = {
  23155. tag: "cmap",
  23156. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphsOut)
  23157. };
  23158. if (!tables["OS/2"] || !validateOS2Table(tables["OS/2"], font)) {
  23159. tables["OS/2"] = {
  23160. tag: "OS/2",
  23161. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  23162. };
  23163. }
  23164. if (!isTrueType) {
  23165. try {
  23166. cffFile = new _stream.Stream(tables["CFF "].data);
  23167. var parser = new _cff_parser.CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  23168. cff = parser.parse();
  23169. cff.duplicateFirstGlyph();
  23170. var compiler = new _cff_parser.CFFCompiler(cff);
  23171. tables["CFF "].data = compiler.compile();
  23172. } catch (e) {
  23173. (0, _util.warn)("Failed to compile font " + properties.loadedName);
  23174. }
  23175. }
  23176. if (!tables.name) {
  23177. tables.name = {
  23178. tag: "name",
  23179. data: createNameTable(this.name)
  23180. };
  23181. } else {
  23182. var namePrototype = readNameTable(tables.name);
  23183. tables.name.data = createNameTable(name, namePrototype);
  23184. }
  23185. var builder = new OpenTypeFileBuilder(header.version);
  23186. for (var tableTag in tables) {
  23187. builder.addTable(tableTag, tables[tableTag].data);
  23188. }
  23189. return builder.toArray();
  23190. },
  23191. convert: function Font_convert(fontName, font, properties) {
  23192. properties.fixedPitch = false;
  23193. if (properties.builtInEncoding) {
  23194. adjustToUnicode(properties, properties.builtInEncoding);
  23195. }
  23196. let glyphZeroId = 1;
  23197. if (font instanceof CFFFont) {
  23198. glyphZeroId = font.numGlyphs - 1;
  23199. }
  23200. var mapping = font.getGlyphMapping(properties);
  23201. var newMapping = adjustMapping(mapping, font.hasGlyphId.bind(font), glyphZeroId);
  23202. this.toFontChar = newMapping.toFontChar;
  23203. var numGlyphs = font.numGlyphs;
  23204. function getCharCodes(charCodeToGlyphId, glyphId) {
  23205. var charCodes = null;
  23206. for (var charCode in charCodeToGlyphId) {
  23207. if (glyphId === charCodeToGlyphId[charCode]) {
  23208. if (!charCodes) {
  23209. charCodes = [];
  23210. }
  23211. charCodes.push(charCode | 0);
  23212. }
  23213. }
  23214. return charCodes;
  23215. }
  23216. function createCharCode(charCodeToGlyphId, glyphId) {
  23217. for (var charCode in charCodeToGlyphId) {
  23218. if (glyphId === charCodeToGlyphId[charCode]) {
  23219. return charCode | 0;
  23220. }
  23221. }
  23222. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  23223. return newMapping.nextAvailableFontCharCode++;
  23224. }
  23225. var seacs = font.seacs;
  23226. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  23227. var matrix = properties.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  23228. var charset = font.getCharset();
  23229. var seacMap = Object.create(null);
  23230. for (var glyphId in seacs) {
  23231. glyphId |= 0;
  23232. var seac = seacs[glyphId];
  23233. var baseGlyphName = _encodings.StandardEncoding[seac[2]];
  23234. var accentGlyphName = _encodings.StandardEncoding[seac[3]];
  23235. var baseGlyphId = charset.indexOf(baseGlyphName);
  23236. var accentGlyphId = charset.indexOf(accentGlyphName);
  23237. if (baseGlyphId < 0 || accentGlyphId < 0) {
  23238. continue;
  23239. }
  23240. var accentOffset = {
  23241. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  23242. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  23243. };
  23244. var charCodes = getCharCodes(mapping, glyphId);
  23245. if (!charCodes) {
  23246. continue;
  23247. }
  23248. for (let i = 0, ii = charCodes.length; i < ii; i++) {
  23249. var charCode = charCodes[i];
  23250. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  23251. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  23252. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  23253. seacMap[charCode] = {
  23254. baseFontCharCode,
  23255. accentFontCharCode,
  23256. accentOffset
  23257. };
  23258. }
  23259. }
  23260. properties.seacMap = seacMap;
  23261. }
  23262. var unitsPerEm = 1 / (properties.fontMatrix || _util.FONT_IDENTITY_MATRIX)[0];
  23263. var builder = new OpenTypeFileBuilder("\x4F\x54\x54\x4F");
  23264. builder.addTable("CFF ", font.data);
  23265. builder.addTable("OS/2", createOS2Table(properties, newMapping.charCodeToGlyphId));
  23266. builder.addTable("cmap", createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  23267. builder.addTable("head", "\x00\x01\x00\x00" + "\x00\x00\x10\x00" + "\x00\x00\x00\x00" + "\x5F\x0F\x3C\xF5" + "\x00\x00" + safeString16(unitsPerEm) + "\x00\x00\x00\x00\x9e\x0b\x7e\x27" + "\x00\x00\x00\x00\x9e\x0b\x7e\x27" + "\x00\x00" + safeString16(properties.descent) + "\x0F\xFF" + safeString16(properties.ascent) + string16(properties.italicAngle ? 2 : 0) + "\x00\x11" + "\x00\x00" + "\x00\x00" + "\x00\x00");
  23268. builder.addTable("hhea", "\x00\x01\x00\x00" + safeString16(properties.ascent) + safeString16(properties.descent) + "\x00\x00" + "\xFF\xFF" + "\x00\x00" + "\x00\x00" + "\x00\x00" + safeString16(properties.capHeight) + safeString16(Math.tan(properties.italicAngle) * properties.xHeight) + "\x00\x00" + "\x00\x00" + "\x00\x00" + "\x00\x00" + "\x00\x00" + "\x00\x00" + string16(numGlyphs));
  23269. builder.addTable("hmtx", function fontFieldsHmtx() {
  23270. var charstrings = font.charstrings;
  23271. var cffWidths = font.cff ? font.cff.widths : null;
  23272. var hmtx = "\x00\x00\x00\x00";
  23273. for (let i = 1, ii = numGlyphs; i < ii; i++) {
  23274. var width = 0;
  23275. if (charstrings) {
  23276. var charstring = charstrings[i - 1];
  23277. width = "width" in charstring ? charstring.width : 0;
  23278. } else if (cffWidths) {
  23279. width = Math.ceil(cffWidths[i] || 0);
  23280. }
  23281. hmtx += string16(width) + string16(0);
  23282. }
  23283. return hmtx;
  23284. }());
  23285. builder.addTable("maxp", "\x00\x00\x50\x00" + string16(numGlyphs));
  23286. builder.addTable("name", createNameTable(fontName));
  23287. builder.addTable("post", createPostTable(properties));
  23288. return builder.toArray();
  23289. },
  23290. get spaceWidth() {
  23291. var possibleSpaceReplacements = ["space", "minus", "one", "i", "I"];
  23292. var width;
  23293. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  23294. var glyphName = possibleSpaceReplacements[i];
  23295. if (glyphName in this.widths) {
  23296. width = this.widths[glyphName];
  23297. break;
  23298. }
  23299. var glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  23300. var glyphUnicode = glyphsUnicodeMap[glyphName];
  23301. var charcode = 0;
  23302. if (this.composite && this.cMap.contains(glyphUnicode)) {
  23303. charcode = this.cMap.lookup(glyphUnicode);
  23304. }
  23305. if (!charcode && this.toUnicode) {
  23306. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  23307. }
  23308. if (charcode <= 0) {
  23309. charcode = glyphUnicode;
  23310. }
  23311. width = this.widths[charcode];
  23312. if (width) {
  23313. break;
  23314. }
  23315. }
  23316. width = width || this.defaultWidth;
  23317. return (0, _util.shadow)(this, "spaceWidth", width);
  23318. },
  23319. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  23320. var fontCharCode, width, operatorListId;
  23321. var widthCode = charcode;
  23322. if (this.cMap && this.cMap.contains(charcode)) {
  23323. widthCode = this.cMap.lookup(charcode);
  23324. }
  23325. width = this.widths[widthCode];
  23326. width = (0, _util.isNum)(width) ? width : this.defaultWidth;
  23327. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  23328. let unicode = this.toUnicode.get(charcode) || this.fallbackToUnicode.get(charcode) || charcode;
  23329. if (typeof unicode === "number") {
  23330. unicode = String.fromCharCode(unicode);
  23331. }
  23332. var isInFont = (charcode in this.toFontChar);
  23333. fontCharCode = this.toFontChar[charcode] || charcode;
  23334. if (this.missingFile) {
  23335. const glyphName = this.differences[charcode] || this.defaultEncoding[charcode];
  23336. if ((glyphName === ".notdef" || glyphName === "") && this.type === "Type1") {
  23337. fontCharCode = 0x20;
  23338. }
  23339. fontCharCode = (0, _unicode.mapSpecialUnicodeValues)(fontCharCode);
  23340. }
  23341. if (this.isType3Font) {
  23342. operatorListId = fontCharCode;
  23343. }
  23344. var accent = null;
  23345. if (this.seacMap && this.seacMap[charcode]) {
  23346. isInFont = true;
  23347. var seac = this.seacMap[charcode];
  23348. fontCharCode = seac.baseFontCharCode;
  23349. accent = {
  23350. fontChar: String.fromCodePoint(seac.accentFontCharCode),
  23351. offset: seac.accentOffset
  23352. };
  23353. }
  23354. let fontChar = "";
  23355. if (typeof fontCharCode === "number") {
  23356. if (fontCharCode <= 0x10ffff) {
  23357. fontChar = String.fromCodePoint(fontCharCode);
  23358. } else {
  23359. (0, _util.warn)(`charToGlyph - invalid fontCharCode: ${fontCharCode}`);
  23360. }
  23361. }
  23362. var glyph = this.glyphCache[charcode];
  23363. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  23364. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  23365. this.glyphCache[charcode] = glyph;
  23366. }
  23367. return glyph;
  23368. },
  23369. charsToGlyphs: function Font_charsToGlyphs(chars) {
  23370. var charsCache = this.charsCache;
  23371. var glyphs, glyph, charcode;
  23372. if (charsCache) {
  23373. glyphs = charsCache[chars];
  23374. if (glyphs) {
  23375. return glyphs;
  23376. }
  23377. }
  23378. if (!charsCache) {
  23379. charsCache = this.charsCache = Object.create(null);
  23380. }
  23381. glyphs = [];
  23382. var charsCacheKey = chars;
  23383. var i = 0,
  23384. ii;
  23385. if (this.cMap) {
  23386. var c = Object.create(null);
  23387. while (i < chars.length) {
  23388. this.cMap.readCharCode(chars, i, c);
  23389. charcode = c.charcode;
  23390. var length = c.length;
  23391. i += length;
  23392. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  23393. glyph = this.charToGlyph(charcode, isSpace);
  23394. glyphs.push(glyph);
  23395. }
  23396. } else {
  23397. for (i = 0, ii = chars.length; i < ii; ++i) {
  23398. charcode = chars.charCodeAt(i);
  23399. glyph = this.charToGlyph(charcode, charcode === 0x20);
  23400. glyphs.push(glyph);
  23401. }
  23402. }
  23403. return charsCache[charsCacheKey] = glyphs;
  23404. },
  23405. get glyphCacheValues() {
  23406. return Object.values(this.glyphCache);
  23407. }
  23408. };
  23409. return Font;
  23410. }();
  23411. exports.Font = Font;
  23412. var ErrorFont = function ErrorFontClosure() {
  23413. function ErrorFont(error) {
  23414. this.error = error;
  23415. this.loadedName = "g_font_error";
  23416. this.missingFile = true;
  23417. }
  23418. ErrorFont.prototype = {
  23419. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  23420. return [];
  23421. },
  23422. exportData(extraProperties = false) {
  23423. return {
  23424. error: this.error
  23425. };
  23426. }
  23427. };
  23428. return ErrorFont;
  23429. }();
  23430. exports.ErrorFont = ErrorFont;
  23431. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  23432. var charCodeToGlyphId = Object.create(null);
  23433. var glyphId, charCode, baseEncoding;
  23434. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  23435. if (properties.baseEncodingName) {
  23436. baseEncoding = (0, _encodings.getEncoding)(properties.baseEncodingName);
  23437. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  23438. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  23439. if (glyphId >= 0) {
  23440. charCodeToGlyphId[charCode] = glyphId;
  23441. } else {
  23442. charCodeToGlyphId[charCode] = 0;
  23443. }
  23444. }
  23445. } else if (isSymbolicFont) {
  23446. for (charCode in builtInEncoding) {
  23447. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  23448. }
  23449. } else {
  23450. baseEncoding = _encodings.StandardEncoding;
  23451. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  23452. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  23453. if (glyphId >= 0) {
  23454. charCodeToGlyphId[charCode] = glyphId;
  23455. } else {
  23456. charCodeToGlyphId[charCode] = 0;
  23457. }
  23458. }
  23459. }
  23460. var differences = properties.differences,
  23461. glyphsUnicodeMap;
  23462. if (differences) {
  23463. for (charCode in differences) {
  23464. var glyphName = differences[charCode];
  23465. glyphId = glyphNames.indexOf(glyphName);
  23466. if (glyphId === -1) {
  23467. if (!glyphsUnicodeMap) {
  23468. glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  23469. }
  23470. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  23471. if (standardGlyphName !== glyphName) {
  23472. glyphId = glyphNames.indexOf(standardGlyphName);
  23473. }
  23474. }
  23475. if (glyphId >= 0) {
  23476. charCodeToGlyphId[charCode] = glyphId;
  23477. } else {
  23478. charCodeToGlyphId[charCode] = 0;
  23479. }
  23480. }
  23481. }
  23482. return charCodeToGlyphId;
  23483. }
  23484. var Type1Font = function Type1FontClosure() {
  23485. function findBlock(streamBytes, signature, startIndex) {
  23486. var streamBytesLength = streamBytes.length;
  23487. var signatureLength = signature.length;
  23488. var scanLength = streamBytesLength - signatureLength;
  23489. var i = startIndex,
  23490. j,
  23491. found = false;
  23492. while (i < scanLength) {
  23493. j = 0;
  23494. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  23495. j++;
  23496. }
  23497. if (j >= signatureLength) {
  23498. i += j;
  23499. while (i < streamBytesLength && (0, _core_utils.isWhiteSpace)(streamBytes[i])) {
  23500. i++;
  23501. }
  23502. found = true;
  23503. break;
  23504. }
  23505. i++;
  23506. }
  23507. return {
  23508. found,
  23509. length: i
  23510. };
  23511. }
  23512. function getHeaderBlock(stream, suggestedLength) {
  23513. var EEXEC_SIGNATURE = [0x65, 0x65, 0x78, 0x65, 0x63];
  23514. var streamStartPos = stream.pos;
  23515. var headerBytes, headerBytesLength, block;
  23516. try {
  23517. headerBytes = stream.getBytes(suggestedLength);
  23518. headerBytesLength = headerBytes.length;
  23519. } catch (ex) {
  23520. if (ex instanceof _core_utils.MissingDataException) {
  23521. throw ex;
  23522. }
  23523. }
  23524. if (headerBytesLength === suggestedLength) {
  23525. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  23526. if (block.found && block.length === suggestedLength) {
  23527. return {
  23528. stream: new _stream.Stream(headerBytes),
  23529. length: suggestedLength
  23530. };
  23531. }
  23532. }
  23533. (0, _util.warn)('Invalid "Length1" property in Type1 font -- trying to recover.');
  23534. stream.pos = streamStartPos;
  23535. var SCAN_BLOCK_LENGTH = 2048;
  23536. var actualLength;
  23537. while (true) {
  23538. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  23539. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  23540. if (block.length === 0) {
  23541. break;
  23542. }
  23543. stream.pos += block.length;
  23544. if (block.found) {
  23545. actualLength = stream.pos - streamStartPos;
  23546. break;
  23547. }
  23548. }
  23549. stream.pos = streamStartPos;
  23550. if (actualLength) {
  23551. return {
  23552. stream: new _stream.Stream(stream.getBytes(actualLength)),
  23553. length: actualLength
  23554. };
  23555. }
  23556. (0, _util.warn)('Unable to recover "Length1" property in Type1 font -- using as is.');
  23557. return {
  23558. stream: new _stream.Stream(stream.getBytes(suggestedLength)),
  23559. length: suggestedLength
  23560. };
  23561. }
  23562. function getEexecBlock(stream, suggestedLength) {
  23563. var eexecBytes = stream.getBytes();
  23564. return {
  23565. stream: new _stream.Stream(eexecBytes),
  23566. length: eexecBytes.length
  23567. };
  23568. }
  23569. function Type1Font(name, file, properties) {
  23570. var PFB_HEADER_SIZE = 6;
  23571. var headerBlockLength = properties.length1;
  23572. var eexecBlockLength = properties.length2;
  23573. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  23574. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  23575. if (pfbHeaderPresent) {
  23576. file.skip(PFB_HEADER_SIZE);
  23577. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  23578. }
  23579. var headerBlock = getHeaderBlock(file, headerBlockLength);
  23580. var headerBlockParser = new _type1_parser.Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  23581. headerBlockParser.extractFontHeader(properties);
  23582. if (pfbHeaderPresent) {
  23583. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  23584. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  23585. }
  23586. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  23587. var eexecBlockParser = new _type1_parser.Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  23588. var data = eexecBlockParser.extractFontProgram(properties);
  23589. for (const key in data.properties) {
  23590. properties[key] = data.properties[key];
  23591. }
  23592. var charstrings = data.charstrings;
  23593. var type2Charstrings = this.getType2Charstrings(charstrings);
  23594. var subrs = this.getType2Subrs(data.subrs);
  23595. this.charstrings = charstrings;
  23596. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  23597. this.seacs = this.getSeacs(data.charstrings);
  23598. }
  23599. Type1Font.prototype = {
  23600. get numGlyphs() {
  23601. return this.charstrings.length + 1;
  23602. },
  23603. getCharset: function Type1Font_getCharset() {
  23604. var charset = [".notdef"];
  23605. var charstrings = this.charstrings;
  23606. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  23607. charset.push(charstrings[glyphId].glyphName);
  23608. }
  23609. return charset;
  23610. },
  23611. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  23612. var charstrings = this.charstrings;
  23613. if (properties.composite) {
  23614. const charCodeToGlyphId = Object.create(null);
  23615. for (let glyphId = 0, charstringsLen = charstrings.length; glyphId < charstringsLen; glyphId++) {
  23616. const charCode = properties.cMap.charCodeOf(glyphId);
  23617. charCodeToGlyphId[charCode] = glyphId + 1;
  23618. }
  23619. return charCodeToGlyphId;
  23620. }
  23621. var glyphNames = [".notdef"],
  23622. glyphId;
  23623. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  23624. glyphNames.push(charstrings[glyphId].glyphName);
  23625. }
  23626. var encoding = properties.builtInEncoding;
  23627. if (encoding) {
  23628. var builtInEncoding = Object.create(null);
  23629. for (var charCode in encoding) {
  23630. glyphId = glyphNames.indexOf(encoding[charCode]);
  23631. if (glyphId >= 0) {
  23632. builtInEncoding[charCode] = glyphId;
  23633. }
  23634. }
  23635. }
  23636. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  23637. },
  23638. hasGlyphId: function Type1Font_hasGlyphID(id) {
  23639. if (id < 0 || id >= this.numGlyphs) {
  23640. return false;
  23641. }
  23642. if (id === 0) {
  23643. return true;
  23644. }
  23645. var glyph = this.charstrings[id - 1];
  23646. return glyph.charstring.length > 0;
  23647. },
  23648. getSeacs: function Type1Font_getSeacs(charstrings) {
  23649. var i, ii;
  23650. var seacMap = [];
  23651. for (i = 0, ii = charstrings.length; i < ii; i++) {
  23652. var charstring = charstrings[i];
  23653. if (charstring.seac) {
  23654. seacMap[i + 1] = charstring.seac;
  23655. }
  23656. }
  23657. return seacMap;
  23658. },
  23659. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  23660. var type2Charstrings = [];
  23661. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  23662. type2Charstrings.push(type1Charstrings[i].charstring);
  23663. }
  23664. return type2Charstrings;
  23665. },
  23666. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  23667. var bias = 0;
  23668. var count = type1Subrs.length;
  23669. if (count < 1133) {
  23670. bias = 107;
  23671. } else if (count < 33769) {
  23672. bias = 1131;
  23673. } else {
  23674. bias = 32768;
  23675. }
  23676. var type2Subrs = [];
  23677. var i;
  23678. for (i = 0; i < bias; i++) {
  23679. type2Subrs.push([0x0b]);
  23680. }
  23681. for (i = 0; i < count; i++) {
  23682. type2Subrs.push(type1Subrs[i]);
  23683. }
  23684. return type2Subrs;
  23685. },
  23686. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  23687. var cff = new _cff_parser.CFF();
  23688. cff.header = new _cff_parser.CFFHeader(1, 0, 4, 4);
  23689. cff.names = [name];
  23690. var topDict = new _cff_parser.CFFTopDict();
  23691. topDict.setByName("version", 391);
  23692. topDict.setByName("Notice", 392);
  23693. topDict.setByName("FullName", 393);
  23694. topDict.setByName("FamilyName", 394);
  23695. topDict.setByName("Weight", 395);
  23696. topDict.setByName("Encoding", null);
  23697. topDict.setByName("FontMatrix", properties.fontMatrix);
  23698. topDict.setByName("FontBBox", properties.bbox);
  23699. topDict.setByName("charset", null);
  23700. topDict.setByName("CharStrings", null);
  23701. topDict.setByName("Private", null);
  23702. cff.topDict = topDict;
  23703. var strings = new _cff_parser.CFFStrings();
  23704. strings.add("Version 0.11");
  23705. strings.add("See original notice");
  23706. strings.add(name);
  23707. strings.add(name);
  23708. strings.add("Medium");
  23709. cff.strings = strings;
  23710. cff.globalSubrIndex = new _cff_parser.CFFIndex();
  23711. var count = glyphs.length;
  23712. var charsetArray = [".notdef"];
  23713. var i, ii;
  23714. for (i = 0; i < count; i++) {
  23715. const glyphName = charstrings[i].glyphName;
  23716. const index = _cff_parser.CFFStandardStrings.indexOf(glyphName);
  23717. if (index === -1) {
  23718. strings.add(glyphName);
  23719. }
  23720. charsetArray.push(glyphName);
  23721. }
  23722. cff.charset = new _cff_parser.CFFCharset(false, 0, charsetArray);
  23723. var charStringsIndex = new _cff_parser.CFFIndex();
  23724. charStringsIndex.add([0x8b, 0x0e]);
  23725. for (i = 0; i < count; i++) {
  23726. charStringsIndex.add(glyphs[i]);
  23727. }
  23728. cff.charStrings = charStringsIndex;
  23729. var privateDict = new _cff_parser.CFFPrivateDict();
  23730. privateDict.setByName("Subrs", null);
  23731. var fields = ["BlueValues", "OtherBlues", "FamilyBlues", "FamilyOtherBlues", "StemSnapH", "StemSnapV", "BlueShift", "BlueFuzz", "BlueScale", "LanguageGroup", "ExpansionFactor", "ForceBold", "StdHW", "StdVW"];
  23732. for (i = 0, ii = fields.length; i < ii; i++) {
  23733. var field = fields[i];
  23734. if (!(field in properties.privateData)) {
  23735. continue;
  23736. }
  23737. var value = properties.privateData[field];
  23738. if (Array.isArray(value)) {
  23739. for (var j = value.length - 1; j > 0; j--) {
  23740. value[j] -= value[j - 1];
  23741. }
  23742. }
  23743. privateDict.setByName(field, value);
  23744. }
  23745. cff.topDict.privateDict = privateDict;
  23746. var subrIndex = new _cff_parser.CFFIndex();
  23747. for (i = 0, ii = subrs.length; i < ii; i++) {
  23748. subrIndex.add(subrs[i]);
  23749. }
  23750. privateDict.subrsIndex = subrIndex;
  23751. var compiler = new _cff_parser.CFFCompiler(cff);
  23752. return compiler.compile();
  23753. }
  23754. };
  23755. return Type1Font;
  23756. }();
  23757. var CFFFont = function CFFFontClosure() {
  23758. function CFFFont(file, properties) {
  23759. this.properties = properties;
  23760. var parser = new _cff_parser.CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  23761. this.cff = parser.parse();
  23762. this.cff.duplicateFirstGlyph();
  23763. var compiler = new _cff_parser.CFFCompiler(this.cff);
  23764. this.seacs = this.cff.seacs;
  23765. try {
  23766. this.data = compiler.compile();
  23767. } catch (e) {
  23768. (0, _util.warn)("Failed to compile font " + properties.loadedName);
  23769. this.data = file;
  23770. }
  23771. }
  23772. CFFFont.prototype = {
  23773. get numGlyphs() {
  23774. return this.cff.charStrings.count;
  23775. },
  23776. getCharset: function CFFFont_getCharset() {
  23777. return this.cff.charset.charset;
  23778. },
  23779. getGlyphMapping: function CFFFont_getGlyphMapping() {
  23780. var cff = this.cff;
  23781. var properties = this.properties;
  23782. var charsets = cff.charset.charset;
  23783. var charCodeToGlyphId;
  23784. var glyphId;
  23785. if (properties.composite) {
  23786. charCodeToGlyphId = Object.create(null);
  23787. let charCode;
  23788. if (cff.isCIDFont) {
  23789. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  23790. var cid = charsets[glyphId];
  23791. charCode = properties.cMap.charCodeOf(cid);
  23792. charCodeToGlyphId[charCode] = glyphId;
  23793. }
  23794. } else {
  23795. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  23796. charCode = properties.cMap.charCodeOf(glyphId);
  23797. charCodeToGlyphId[charCode] = glyphId;
  23798. }
  23799. }
  23800. return charCodeToGlyphId;
  23801. }
  23802. var encoding = cff.encoding ? cff.encoding.encoding : null;
  23803. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  23804. return charCodeToGlyphId;
  23805. },
  23806. hasGlyphId: function CFFFont_hasGlyphID(id) {
  23807. return this.cff.hasGlyphId(id);
  23808. }
  23809. };
  23810. return CFFFont;
  23811. }();
  23812. /***/ }),
  23813. /* 31 */
  23814. /***/ (function(module, exports, __w_pdfjs_require__) {
  23815. "use strict";
  23816. Object.defineProperty(exports, "__esModule", {
  23817. value: true
  23818. });
  23819. exports.CFFFDSelect = exports.CFFCompiler = exports.CFFPrivateDict = exports.CFFTopDict = exports.CFFCharset = exports.CFFIndex = exports.CFFStrings = exports.CFFHeader = exports.CFF = exports.CFFParser = exports.CFFStandardStrings = void 0;
  23820. var _util = __w_pdfjs_require__(2);
  23821. var _charsets = __w_pdfjs_require__(32);
  23822. var _encodings = __w_pdfjs_require__(33);
  23823. var MAX_SUBR_NESTING = 10;
  23824. var CFFStandardStrings = [".notdef", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "exclamdown", "cent", "sterling", "fraction", "yen", "florin", "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi", "fl", "endash", "dagger", "daggerdbl", "periodcentered", "paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright", "guillemotright", "ellipsis", "perthousand", "questiondown", "grave", "acute", "circumflex", "tilde", "macron", "breve", "dotaccent", "dieresis", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "emdash", "AE", "ordfeminine", "Lslash", "Oslash", "OE", "ordmasculine", "ae", "dotlessi", "lslash", "oslash", "oe", "germandbls", "onesuperior", "logicalnot", "mu", "trademark", "Eth", "onehalf", "plusminus", "Thorn", "onequarter", "divide", "brokenbar", "degree", "thorn", "threequarters", "twosuperior", "registered", "minus", "eth", "multiply", "threesuperior", "copyright", "Aacute", "Acircumflex", "Adieresis", "Agrave", "Aring", "Atilde", "Ccedilla", "Eacute", "Ecircumflex", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Ntilde", "Oacute", "Ocircumflex", "Odieresis", "Ograve", "Otilde", "Scaron", "Uacute", "Ucircumflex", "Udieresis", "Ugrave", "Yacute", "Ydieresis", "Zcaron", "aacute", "acircumflex", "adieresis", "agrave", "aring", "atilde", "ccedilla", "eacute", "ecircumflex", "edieresis", "egrave", "iacute", "icircumflex", "idieresis", "igrave", "ntilde", "oacute", "ocircumflex", "odieresis", "ograve", "otilde", "scaron", "uacute", "ucircumflex", "udieresis", "ugrave", "yacute", "ydieresis", "zcaron", "exclamsmall", "Hungarumlautsmall", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "commasuperior", "threequartersemdash", "periodsuperior", "questionsmall", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior", "ff", "ffi", "ffl", "parenleftinferior", "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah", "Tildesmall", "exclamdownsmall", "centoldstyle", "Lslashsmall", "Scaronsmall", "Zcaronsmall", "Dieresissmall", "Brevesmall", "Caronsmall", "Dotaccentsmall", "Macronsmall", "figuredash", "hypheninferior", "Ogoneksmall", "Ringsmall", "Cedillasmall", "questiondownsmall", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", "Acircumflexsmall", "Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall", "Igravesmall", "Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", "Odieresissmall", "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall", "001.000", "001.001", "001.002", "001.003", "Black", "Bold", "Book", "Light", "Medium", "Regular", "Roman", "Semibold"];
  23825. exports.CFFStandardStrings = CFFStandardStrings;
  23826. const NUM_STANDARD_CFF_STRINGS = 391;
  23827. var CFFParser = function CFFParserClosure() {
  23828. var CharstringValidationData = [null, {
  23829. id: "hstem",
  23830. min: 2,
  23831. stackClearing: true,
  23832. stem: true
  23833. }, null, {
  23834. id: "vstem",
  23835. min: 2,
  23836. stackClearing: true,
  23837. stem: true
  23838. }, {
  23839. id: "vmoveto",
  23840. min: 1,
  23841. stackClearing: true
  23842. }, {
  23843. id: "rlineto",
  23844. min: 2,
  23845. resetStack: true
  23846. }, {
  23847. id: "hlineto",
  23848. min: 1,
  23849. resetStack: true
  23850. }, {
  23851. id: "vlineto",
  23852. min: 1,
  23853. resetStack: true
  23854. }, {
  23855. id: "rrcurveto",
  23856. min: 6,
  23857. resetStack: true
  23858. }, null, {
  23859. id: "callsubr",
  23860. min: 1,
  23861. undefStack: true
  23862. }, {
  23863. id: "return",
  23864. min: 0,
  23865. undefStack: true
  23866. }, null, null, {
  23867. id: "endchar",
  23868. min: 0,
  23869. stackClearing: true
  23870. }, null, null, null, {
  23871. id: "hstemhm",
  23872. min: 2,
  23873. stackClearing: true,
  23874. stem: true
  23875. }, {
  23876. id: "hintmask",
  23877. min: 0,
  23878. stackClearing: true
  23879. }, {
  23880. id: "cntrmask",
  23881. min: 0,
  23882. stackClearing: true
  23883. }, {
  23884. id: "rmoveto",
  23885. min: 2,
  23886. stackClearing: true
  23887. }, {
  23888. id: "hmoveto",
  23889. min: 1,
  23890. stackClearing: true
  23891. }, {
  23892. id: "vstemhm",
  23893. min: 2,
  23894. stackClearing: true,
  23895. stem: true
  23896. }, {
  23897. id: "rcurveline",
  23898. min: 8,
  23899. resetStack: true
  23900. }, {
  23901. id: "rlinecurve",
  23902. min: 8,
  23903. resetStack: true
  23904. }, {
  23905. id: "vvcurveto",
  23906. min: 4,
  23907. resetStack: true
  23908. }, {
  23909. id: "hhcurveto",
  23910. min: 4,
  23911. resetStack: true
  23912. }, null, {
  23913. id: "callgsubr",
  23914. min: 1,
  23915. undefStack: true
  23916. }, {
  23917. id: "vhcurveto",
  23918. min: 4,
  23919. resetStack: true
  23920. }, {
  23921. id: "hvcurveto",
  23922. min: 4,
  23923. resetStack: true
  23924. }];
  23925. var CharstringValidationData12 = [null, null, null, {
  23926. id: "and",
  23927. min: 2,
  23928. stackDelta: -1
  23929. }, {
  23930. id: "or",
  23931. min: 2,
  23932. stackDelta: -1
  23933. }, {
  23934. id: "not",
  23935. min: 1,
  23936. stackDelta: 0
  23937. }, null, null, null, {
  23938. id: "abs",
  23939. min: 1,
  23940. stackDelta: 0
  23941. }, {
  23942. id: "add",
  23943. min: 2,
  23944. stackDelta: -1,
  23945. stackFn: function stack_div(stack, index) {
  23946. stack[index - 2] = stack[index - 2] + stack[index - 1];
  23947. }
  23948. }, {
  23949. id: "sub",
  23950. min: 2,
  23951. stackDelta: -1,
  23952. stackFn: function stack_div(stack, index) {
  23953. stack[index - 2] = stack[index - 2] - stack[index - 1];
  23954. }
  23955. }, {
  23956. id: "div",
  23957. min: 2,
  23958. stackDelta: -1,
  23959. stackFn: function stack_div(stack, index) {
  23960. stack[index - 2] = stack[index - 2] / stack[index - 1];
  23961. }
  23962. }, null, {
  23963. id: "neg",
  23964. min: 1,
  23965. stackDelta: 0,
  23966. stackFn: function stack_div(stack, index) {
  23967. stack[index - 1] = -stack[index - 1];
  23968. }
  23969. }, {
  23970. id: "eq",
  23971. min: 2,
  23972. stackDelta: -1
  23973. }, null, null, {
  23974. id: "drop",
  23975. min: 1,
  23976. stackDelta: -1
  23977. }, null, {
  23978. id: "put",
  23979. min: 2,
  23980. stackDelta: -2
  23981. }, {
  23982. id: "get",
  23983. min: 1,
  23984. stackDelta: 0
  23985. }, {
  23986. id: "ifelse",
  23987. min: 4,
  23988. stackDelta: -3
  23989. }, {
  23990. id: "random",
  23991. min: 0,
  23992. stackDelta: 1
  23993. }, {
  23994. id: "mul",
  23995. min: 2,
  23996. stackDelta: -1,
  23997. stackFn: function stack_div(stack, index) {
  23998. stack[index - 2] = stack[index - 2] * stack[index - 1];
  23999. }
  24000. }, null, {
  24001. id: "sqrt",
  24002. min: 1,
  24003. stackDelta: 0
  24004. }, {
  24005. id: "dup",
  24006. min: 1,
  24007. stackDelta: 1
  24008. }, {
  24009. id: "exch",
  24010. min: 2,
  24011. stackDelta: 0
  24012. }, {
  24013. id: "index",
  24014. min: 2,
  24015. stackDelta: 0
  24016. }, {
  24017. id: "roll",
  24018. min: 3,
  24019. stackDelta: -2
  24020. }, null, null, null, {
  24021. id: "hflex",
  24022. min: 7,
  24023. resetStack: true
  24024. }, {
  24025. id: "flex",
  24026. min: 13,
  24027. resetStack: true
  24028. }, {
  24029. id: "hflex1",
  24030. min: 9,
  24031. resetStack: true
  24032. }, {
  24033. id: "flex1",
  24034. min: 11,
  24035. resetStack: true
  24036. }];
  24037. class CFFParser {
  24038. constructor(file, properties, seacAnalysisEnabled) {
  24039. this.bytes = file.getBytes();
  24040. this.properties = properties;
  24041. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  24042. }
  24043. parse() {
  24044. var properties = this.properties;
  24045. var cff = new CFF();
  24046. this.cff = cff;
  24047. var header = this.parseHeader();
  24048. var nameIndex = this.parseIndex(header.endPos);
  24049. var topDictIndex = this.parseIndex(nameIndex.endPos);
  24050. var stringIndex = this.parseIndex(topDictIndex.endPos);
  24051. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  24052. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  24053. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  24054. cff.header = header.obj;
  24055. cff.names = this.parseNameIndex(nameIndex.obj);
  24056. cff.strings = this.parseStringIndex(stringIndex.obj);
  24057. cff.topDict = topDict;
  24058. cff.globalSubrIndex = globalSubrIndex.obj;
  24059. this.parsePrivateDict(cff.topDict);
  24060. cff.isCIDFont = topDict.hasName("ROS");
  24061. var charStringOffset = topDict.getByName("CharStrings");
  24062. var charStringIndex = this.parseIndex(charStringOffset).obj;
  24063. var fontMatrix = topDict.getByName("FontMatrix");
  24064. if (fontMatrix) {
  24065. properties.fontMatrix = fontMatrix;
  24066. }
  24067. var fontBBox = topDict.getByName("FontBBox");
  24068. if (fontBBox) {
  24069. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  24070. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  24071. properties.ascentScaled = true;
  24072. }
  24073. var charset, encoding;
  24074. if (cff.isCIDFont) {
  24075. var fdArrayIndex = this.parseIndex(topDict.getByName("FDArray")).obj;
  24076. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  24077. var dictRaw = fdArrayIndex.get(i);
  24078. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  24079. this.parsePrivateDict(fontDict);
  24080. cff.fdArray.push(fontDict);
  24081. }
  24082. encoding = null;
  24083. charset = this.parseCharsets(topDict.getByName("charset"), charStringIndex.count, cff.strings, true);
  24084. cff.fdSelect = this.parseFDSelect(topDict.getByName("FDSelect"), charStringIndex.count);
  24085. } else {
  24086. charset = this.parseCharsets(topDict.getByName("charset"), charStringIndex.count, cff.strings, false);
  24087. encoding = this.parseEncoding(topDict.getByName("Encoding"), properties, cff.strings, charset.charset);
  24088. }
  24089. cff.charset = charset;
  24090. cff.encoding = encoding;
  24091. var charStringsAndSeacs = this.parseCharStrings({
  24092. charStrings: charStringIndex,
  24093. localSubrIndex: topDict.privateDict.subrsIndex,
  24094. globalSubrIndex: globalSubrIndex.obj,
  24095. fdSelect: cff.fdSelect,
  24096. fdArray: cff.fdArray,
  24097. privateDict: topDict.privateDict
  24098. });
  24099. cff.charStrings = charStringsAndSeacs.charStrings;
  24100. cff.seacs = charStringsAndSeacs.seacs;
  24101. cff.widths = charStringsAndSeacs.widths;
  24102. return cff;
  24103. }
  24104. parseHeader() {
  24105. var bytes = this.bytes;
  24106. var bytesLength = bytes.length;
  24107. var offset = 0;
  24108. while (offset < bytesLength && bytes[offset] !== 1) {
  24109. ++offset;
  24110. }
  24111. if (offset >= bytesLength) {
  24112. throw new _util.FormatError("Invalid CFF header");
  24113. }
  24114. if (offset !== 0) {
  24115. (0, _util.info)("cff data is shifted");
  24116. bytes = bytes.subarray(offset);
  24117. this.bytes = bytes;
  24118. }
  24119. var major = bytes[0];
  24120. var minor = bytes[1];
  24121. var hdrSize = bytes[2];
  24122. var offSize = bytes[3];
  24123. var header = new CFFHeader(major, minor, hdrSize, offSize);
  24124. return {
  24125. obj: header,
  24126. endPos: hdrSize
  24127. };
  24128. }
  24129. parseDict(dict) {
  24130. var pos = 0;
  24131. function parseOperand() {
  24132. var value = dict[pos++];
  24133. if (value === 30) {
  24134. return parseFloatOperand();
  24135. } else if (value === 28) {
  24136. value = dict[pos++];
  24137. value = (value << 24 | dict[pos++] << 16) >> 16;
  24138. return value;
  24139. } else if (value === 29) {
  24140. value = dict[pos++];
  24141. value = value << 8 | dict[pos++];
  24142. value = value << 8 | dict[pos++];
  24143. value = value << 8 | dict[pos++];
  24144. return value;
  24145. } else if (value >= 32 && value <= 246) {
  24146. return value - 139;
  24147. } else if (value >= 247 && value <= 250) {
  24148. return (value - 247) * 256 + dict[pos++] + 108;
  24149. } else if (value >= 251 && value <= 254) {
  24150. return -((value - 251) * 256) - dict[pos++] - 108;
  24151. }
  24152. (0, _util.warn)('CFFParser_parseDict: "' + value + '" is a reserved command.');
  24153. return NaN;
  24154. }
  24155. function parseFloatOperand() {
  24156. var str = "";
  24157. var eof = 15;
  24158. const lookup = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "E", "E-", null, "-"];
  24159. var length = dict.length;
  24160. while (pos < length) {
  24161. var b = dict[pos++];
  24162. var b1 = b >> 4;
  24163. var b2 = b & 15;
  24164. if (b1 === eof) {
  24165. break;
  24166. }
  24167. str += lookup[b1];
  24168. if (b2 === eof) {
  24169. break;
  24170. }
  24171. str += lookup[b2];
  24172. }
  24173. return parseFloat(str);
  24174. }
  24175. var operands = [];
  24176. var entries = [];
  24177. pos = 0;
  24178. var end = dict.length;
  24179. while (pos < end) {
  24180. var b = dict[pos];
  24181. if (b <= 21) {
  24182. if (b === 12) {
  24183. b = b << 8 | dict[++pos];
  24184. }
  24185. entries.push([b, operands]);
  24186. operands = [];
  24187. ++pos;
  24188. } else {
  24189. operands.push(parseOperand());
  24190. }
  24191. }
  24192. return entries;
  24193. }
  24194. parseIndex(pos) {
  24195. var cffIndex = new CFFIndex();
  24196. var bytes = this.bytes;
  24197. var count = bytes[pos++] << 8 | bytes[pos++];
  24198. var offsets = [];
  24199. var end = pos;
  24200. var i, ii;
  24201. if (count !== 0) {
  24202. var offsetSize = bytes[pos++];
  24203. var startPos = pos + (count + 1) * offsetSize - 1;
  24204. for (i = 0, ii = count + 1; i < ii; ++i) {
  24205. var offset = 0;
  24206. for (var j = 0; j < offsetSize; ++j) {
  24207. offset <<= 8;
  24208. offset += bytes[pos++];
  24209. }
  24210. offsets.push(startPos + offset);
  24211. }
  24212. end = offsets[count];
  24213. }
  24214. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  24215. var offsetStart = offsets[i];
  24216. var offsetEnd = offsets[i + 1];
  24217. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  24218. }
  24219. return {
  24220. obj: cffIndex,
  24221. endPos: end
  24222. };
  24223. }
  24224. parseNameIndex(index) {
  24225. var names = [];
  24226. for (var i = 0, ii = index.count; i < ii; ++i) {
  24227. var name = index.get(i);
  24228. names.push((0, _util.bytesToString)(name));
  24229. }
  24230. return names;
  24231. }
  24232. parseStringIndex(index) {
  24233. var strings = new CFFStrings();
  24234. for (var i = 0, ii = index.count; i < ii; ++i) {
  24235. var data = index.get(i);
  24236. strings.add((0, _util.bytesToString)(data));
  24237. }
  24238. return strings;
  24239. }
  24240. createDict(Type, dict, strings) {
  24241. var cffDict = new Type(strings);
  24242. for (var i = 0, ii = dict.length; i < ii; ++i) {
  24243. var pair = dict[i];
  24244. var key = pair[0];
  24245. var value = pair[1];
  24246. cffDict.setByKey(key, value);
  24247. }
  24248. return cffDict;
  24249. }
  24250. parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  24251. if (!data || state.callDepth > MAX_SUBR_NESTING) {
  24252. return false;
  24253. }
  24254. var stackSize = state.stackSize;
  24255. var stack = state.stack;
  24256. var length = data.length;
  24257. for (var j = 0; j < length;) {
  24258. var value = data[j++];
  24259. var validationCommand = null;
  24260. if (value === 12) {
  24261. var q = data[j++];
  24262. if (q === 0) {
  24263. data[j - 2] = 139;
  24264. data[j - 1] = 22;
  24265. stackSize = 0;
  24266. } else {
  24267. validationCommand = CharstringValidationData12[q];
  24268. }
  24269. } else if (value === 28) {
  24270. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  24271. j += 2;
  24272. stackSize++;
  24273. } else if (value === 14) {
  24274. if (stackSize >= 4) {
  24275. stackSize -= 4;
  24276. if (this.seacAnalysisEnabled) {
  24277. state.seac = stack.slice(stackSize, stackSize + 4);
  24278. return false;
  24279. }
  24280. }
  24281. validationCommand = CharstringValidationData[value];
  24282. } else if (value >= 32 && value <= 246) {
  24283. stack[stackSize] = value - 139;
  24284. stackSize++;
  24285. } else if (value >= 247 && value <= 254) {
  24286. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  24287. j++;
  24288. stackSize++;
  24289. } else if (value === 255) {
  24290. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  24291. j += 4;
  24292. stackSize++;
  24293. } else if (value === 19 || value === 20) {
  24294. state.hints += stackSize >> 1;
  24295. j += state.hints + 7 >> 3;
  24296. stackSize %= 2;
  24297. validationCommand = CharstringValidationData[value];
  24298. } else if (value === 10 || value === 29) {
  24299. var subrsIndex;
  24300. if (value === 10) {
  24301. subrsIndex = localSubrIndex;
  24302. } else {
  24303. subrsIndex = globalSubrIndex;
  24304. }
  24305. if (!subrsIndex) {
  24306. validationCommand = CharstringValidationData[value];
  24307. (0, _util.warn)("Missing subrsIndex for " + validationCommand.id);
  24308. return false;
  24309. }
  24310. var bias = 32768;
  24311. if (subrsIndex.count < 1240) {
  24312. bias = 107;
  24313. } else if (subrsIndex.count < 33900) {
  24314. bias = 1131;
  24315. }
  24316. var subrNumber = stack[--stackSize] + bias;
  24317. if (subrNumber < 0 || subrNumber >= subrsIndex.count || isNaN(subrNumber)) {
  24318. validationCommand = CharstringValidationData[value];
  24319. (0, _util.warn)("Out of bounds subrIndex for " + validationCommand.id);
  24320. return false;
  24321. }
  24322. state.stackSize = stackSize;
  24323. state.callDepth++;
  24324. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  24325. if (!valid) {
  24326. return false;
  24327. }
  24328. state.callDepth--;
  24329. stackSize = state.stackSize;
  24330. continue;
  24331. } else if (value === 11) {
  24332. state.stackSize = stackSize;
  24333. return true;
  24334. } else {
  24335. validationCommand = CharstringValidationData[value];
  24336. }
  24337. if (validationCommand) {
  24338. if (validationCommand.stem) {
  24339. state.hints += stackSize >> 1;
  24340. if (value === 3 || value === 23) {
  24341. state.hasVStems = true;
  24342. } else if (state.hasVStems && (value === 1 || value === 18)) {
  24343. (0, _util.warn)("CFF stem hints are in wrong order");
  24344. data[j - 1] = value === 1 ? 3 : 23;
  24345. }
  24346. }
  24347. if ("min" in validationCommand) {
  24348. if (!state.undefStack && stackSize < validationCommand.min) {
  24349. (0, _util.warn)("Not enough parameters for " + validationCommand.id + "; actual: " + stackSize + ", expected: " + validationCommand.min);
  24350. return false;
  24351. }
  24352. }
  24353. if (state.firstStackClearing && validationCommand.stackClearing) {
  24354. state.firstStackClearing = false;
  24355. stackSize -= validationCommand.min;
  24356. if (stackSize >= 2 && validationCommand.stem) {
  24357. stackSize %= 2;
  24358. } else if (stackSize > 1) {
  24359. (0, _util.warn)("Found too many parameters for stack-clearing command");
  24360. }
  24361. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  24362. state.width = stack[stackSize - 1];
  24363. }
  24364. }
  24365. if ("stackDelta" in validationCommand) {
  24366. if ("stackFn" in validationCommand) {
  24367. validationCommand.stackFn(stack, stackSize);
  24368. }
  24369. stackSize += validationCommand.stackDelta;
  24370. } else if (validationCommand.stackClearing) {
  24371. stackSize = 0;
  24372. } else if (validationCommand.resetStack) {
  24373. stackSize = 0;
  24374. state.undefStack = false;
  24375. } else if (validationCommand.undefStack) {
  24376. stackSize = 0;
  24377. state.undefStack = true;
  24378. state.firstStackClearing = false;
  24379. }
  24380. }
  24381. }
  24382. state.stackSize = stackSize;
  24383. return true;
  24384. }
  24385. parseCharStrings({
  24386. charStrings,
  24387. localSubrIndex,
  24388. globalSubrIndex,
  24389. fdSelect,
  24390. fdArray,
  24391. privateDict
  24392. }) {
  24393. var seacs = [];
  24394. var widths = [];
  24395. var count = charStrings.count;
  24396. for (var i = 0; i < count; i++) {
  24397. var charstring = charStrings.get(i);
  24398. var state = {
  24399. callDepth: 0,
  24400. stackSize: 0,
  24401. stack: [],
  24402. undefStack: true,
  24403. hints: 0,
  24404. firstStackClearing: true,
  24405. seac: null,
  24406. width: null,
  24407. hasVStems: false
  24408. };
  24409. var valid = true;
  24410. var localSubrToUse = null;
  24411. var privateDictToUse = privateDict;
  24412. if (fdSelect && fdArray.length) {
  24413. var fdIndex = fdSelect.getFDIndex(i);
  24414. if (fdIndex === -1) {
  24415. (0, _util.warn)("Glyph index is not in fd select.");
  24416. valid = false;
  24417. }
  24418. if (fdIndex >= fdArray.length) {
  24419. (0, _util.warn)("Invalid fd index for glyph index.");
  24420. valid = false;
  24421. }
  24422. if (valid) {
  24423. privateDictToUse = fdArray[fdIndex].privateDict;
  24424. localSubrToUse = privateDictToUse.subrsIndex;
  24425. }
  24426. } else if (localSubrIndex) {
  24427. localSubrToUse = localSubrIndex;
  24428. }
  24429. if (valid) {
  24430. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  24431. }
  24432. if (state.width !== null) {
  24433. const nominalWidth = privateDictToUse.getByName("nominalWidthX");
  24434. widths[i] = nominalWidth + state.width;
  24435. } else {
  24436. const defaultWidth = privateDictToUse.getByName("defaultWidthX");
  24437. widths[i] = defaultWidth;
  24438. }
  24439. if (state.seac !== null) {
  24440. seacs[i] = state.seac;
  24441. }
  24442. if (!valid) {
  24443. charStrings.set(i, new Uint8Array([14]));
  24444. }
  24445. }
  24446. return {
  24447. charStrings,
  24448. seacs,
  24449. widths
  24450. };
  24451. }
  24452. emptyPrivateDictionary(parentDict) {
  24453. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  24454. parentDict.setByKey(18, [0, 0]);
  24455. parentDict.privateDict = privateDict;
  24456. }
  24457. parsePrivateDict(parentDict) {
  24458. if (!parentDict.hasName("Private")) {
  24459. this.emptyPrivateDictionary(parentDict);
  24460. return;
  24461. }
  24462. var privateOffset = parentDict.getByName("Private");
  24463. if (!Array.isArray(privateOffset) || privateOffset.length !== 2) {
  24464. parentDict.removeByName("Private");
  24465. return;
  24466. }
  24467. var size = privateOffset[0];
  24468. var offset = privateOffset[1];
  24469. if (size === 0 || offset >= this.bytes.length) {
  24470. this.emptyPrivateDictionary(parentDict);
  24471. return;
  24472. }
  24473. var privateDictEnd = offset + size;
  24474. var dictData = this.bytes.subarray(offset, privateDictEnd);
  24475. var dict = this.parseDict(dictData);
  24476. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  24477. parentDict.privateDict = privateDict;
  24478. if (!privateDict.getByName("Subrs")) {
  24479. return;
  24480. }
  24481. var subrsOffset = privateDict.getByName("Subrs");
  24482. var relativeOffset = offset + subrsOffset;
  24483. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  24484. this.emptyPrivateDictionary(parentDict);
  24485. return;
  24486. }
  24487. var subrsIndex = this.parseIndex(relativeOffset);
  24488. privateDict.subrsIndex = subrsIndex.obj;
  24489. }
  24490. parseCharsets(pos, length, strings, cid) {
  24491. if (pos === 0) {
  24492. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, _charsets.ISOAdobeCharset);
  24493. } else if (pos === 1) {
  24494. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, _charsets.ExpertCharset);
  24495. } else if (pos === 2) {
  24496. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, _charsets.ExpertSubsetCharset);
  24497. }
  24498. var bytes = this.bytes;
  24499. var start = pos;
  24500. var format = bytes[pos++];
  24501. const charset = [cid ? 0 : ".notdef"];
  24502. var id, count, i;
  24503. length -= 1;
  24504. switch (format) {
  24505. case 0:
  24506. for (i = 0; i < length; i++) {
  24507. id = bytes[pos++] << 8 | bytes[pos++];
  24508. charset.push(cid ? id : strings.get(id));
  24509. }
  24510. break;
  24511. case 1:
  24512. while (charset.length <= length) {
  24513. id = bytes[pos++] << 8 | bytes[pos++];
  24514. count = bytes[pos++];
  24515. for (i = 0; i <= count; i++) {
  24516. charset.push(cid ? id++ : strings.get(id++));
  24517. }
  24518. }
  24519. break;
  24520. case 2:
  24521. while (charset.length <= length) {
  24522. id = bytes[pos++] << 8 | bytes[pos++];
  24523. count = bytes[pos++] << 8 | bytes[pos++];
  24524. for (i = 0; i <= count; i++) {
  24525. charset.push(cid ? id++ : strings.get(id++));
  24526. }
  24527. }
  24528. break;
  24529. default:
  24530. throw new _util.FormatError("Unknown charset format");
  24531. }
  24532. var end = pos;
  24533. var raw = bytes.subarray(start, end);
  24534. return new CFFCharset(false, format, charset, raw);
  24535. }
  24536. parseEncoding(pos, properties, strings, charset) {
  24537. var encoding = Object.create(null);
  24538. var bytes = this.bytes;
  24539. var predefined = false;
  24540. var format, i, ii;
  24541. var raw = null;
  24542. function readSupplement() {
  24543. var supplementsCount = bytes[pos++];
  24544. for (i = 0; i < supplementsCount; i++) {
  24545. var code = bytes[pos++];
  24546. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  24547. encoding[code] = charset.indexOf(strings.get(sid));
  24548. }
  24549. }
  24550. if (pos === 0 || pos === 1) {
  24551. predefined = true;
  24552. format = pos;
  24553. var baseEncoding = pos ? _encodings.ExpertEncoding : _encodings.StandardEncoding;
  24554. for (i = 0, ii = charset.length; i < ii; i++) {
  24555. var index = baseEncoding.indexOf(charset[i]);
  24556. if (index !== -1) {
  24557. encoding[index] = i;
  24558. }
  24559. }
  24560. } else {
  24561. var dataStart = pos;
  24562. format = bytes[pos++];
  24563. switch (format & 0x7f) {
  24564. case 0:
  24565. var glyphsCount = bytes[pos++];
  24566. for (i = 1; i <= glyphsCount; i++) {
  24567. encoding[bytes[pos++]] = i;
  24568. }
  24569. break;
  24570. case 1:
  24571. var rangesCount = bytes[pos++];
  24572. var gid = 1;
  24573. for (i = 0; i < rangesCount; i++) {
  24574. var start = bytes[pos++];
  24575. var left = bytes[pos++];
  24576. for (var j = start; j <= start + left; j++) {
  24577. encoding[j] = gid++;
  24578. }
  24579. }
  24580. break;
  24581. default:
  24582. throw new _util.FormatError(`Unknown encoding format: ${format} in CFF`);
  24583. }
  24584. var dataEnd = pos;
  24585. if (format & 0x80) {
  24586. bytes[dataStart] &= 0x7f;
  24587. readSupplement();
  24588. }
  24589. raw = bytes.subarray(dataStart, dataEnd);
  24590. }
  24591. format = format & 0x7f;
  24592. return new CFFEncoding(predefined, format, encoding, raw);
  24593. }
  24594. parseFDSelect(pos, length) {
  24595. var bytes = this.bytes;
  24596. var format = bytes[pos++];
  24597. var fdSelect = [];
  24598. var i;
  24599. switch (format) {
  24600. case 0:
  24601. for (i = 0; i < length; ++i) {
  24602. var id = bytes[pos++];
  24603. fdSelect.push(id);
  24604. }
  24605. break;
  24606. case 3:
  24607. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  24608. for (i = 0; i < rangesCount; ++i) {
  24609. var first = bytes[pos++] << 8 | bytes[pos++];
  24610. if (i === 0 && first !== 0) {
  24611. (0, _util.warn)("parseFDSelect: The first range must have a first GID of 0" + " -- trying to recover.");
  24612. first = 0;
  24613. }
  24614. var fdIndex = bytes[pos++];
  24615. var next = bytes[pos] << 8 | bytes[pos + 1];
  24616. for (var j = first; j < next; ++j) {
  24617. fdSelect.push(fdIndex);
  24618. }
  24619. }
  24620. pos += 2;
  24621. break;
  24622. default:
  24623. throw new _util.FormatError(`parseFDSelect: Unknown format "${format}".`);
  24624. }
  24625. if (fdSelect.length !== length) {
  24626. throw new _util.FormatError("parseFDSelect: Invalid font data.");
  24627. }
  24628. return new CFFFDSelect(format, fdSelect);
  24629. }
  24630. }
  24631. return CFFParser;
  24632. }();
  24633. exports.CFFParser = CFFParser;
  24634. class CFF {
  24635. constructor() {
  24636. this.header = null;
  24637. this.names = [];
  24638. this.topDict = null;
  24639. this.strings = new CFFStrings();
  24640. this.globalSubrIndex = null;
  24641. this.encoding = null;
  24642. this.charset = null;
  24643. this.charStrings = null;
  24644. this.fdArray = [];
  24645. this.fdSelect = null;
  24646. this.isCIDFont = false;
  24647. }
  24648. duplicateFirstGlyph() {
  24649. if (this.charStrings.count >= 65535) {
  24650. (0, _util.warn)("Not enough space in charstrings to duplicate first glyph.");
  24651. return;
  24652. }
  24653. var glyphZero = this.charStrings.get(0);
  24654. this.charStrings.add(glyphZero);
  24655. if (this.isCIDFont) {
  24656. this.fdSelect.fdSelect.push(this.fdSelect.fdSelect[0]);
  24657. }
  24658. }
  24659. hasGlyphId(id) {
  24660. if (id < 0 || id >= this.charStrings.count) {
  24661. return false;
  24662. }
  24663. var glyph = this.charStrings.get(id);
  24664. return glyph.length > 0;
  24665. }
  24666. }
  24667. exports.CFF = CFF;
  24668. class CFFHeader {
  24669. constructor(major, minor, hdrSize, offSize) {
  24670. this.major = major;
  24671. this.minor = minor;
  24672. this.hdrSize = hdrSize;
  24673. this.offSize = offSize;
  24674. }
  24675. }
  24676. exports.CFFHeader = CFFHeader;
  24677. class CFFStrings {
  24678. constructor() {
  24679. this.strings = [];
  24680. }
  24681. get(index) {
  24682. if (index >= 0 && index <= NUM_STANDARD_CFF_STRINGS - 1) {
  24683. return CFFStandardStrings[index];
  24684. }
  24685. if (index - NUM_STANDARD_CFF_STRINGS <= this.strings.length) {
  24686. return this.strings[index - NUM_STANDARD_CFF_STRINGS];
  24687. }
  24688. return CFFStandardStrings[0];
  24689. }
  24690. getSID(str) {
  24691. let index = CFFStandardStrings.indexOf(str);
  24692. if (index !== -1) {
  24693. return index;
  24694. }
  24695. index = this.strings.indexOf(str);
  24696. if (index !== -1) {
  24697. return index + NUM_STANDARD_CFF_STRINGS;
  24698. }
  24699. return -1;
  24700. }
  24701. add(value) {
  24702. this.strings.push(value);
  24703. }
  24704. get count() {
  24705. return this.strings.length;
  24706. }
  24707. }
  24708. exports.CFFStrings = CFFStrings;
  24709. class CFFIndex {
  24710. constructor() {
  24711. this.objects = [];
  24712. this.length = 0;
  24713. }
  24714. add(data) {
  24715. this.length += data.length;
  24716. this.objects.push(data);
  24717. }
  24718. set(index, data) {
  24719. this.length += data.length - this.objects[index].length;
  24720. this.objects[index] = data;
  24721. }
  24722. get(index) {
  24723. return this.objects[index];
  24724. }
  24725. get count() {
  24726. return this.objects.length;
  24727. }
  24728. }
  24729. exports.CFFIndex = CFFIndex;
  24730. class CFFDict {
  24731. constructor(tables, strings) {
  24732. this.keyToNameMap = tables.keyToNameMap;
  24733. this.nameToKeyMap = tables.nameToKeyMap;
  24734. this.defaults = tables.defaults;
  24735. this.types = tables.types;
  24736. this.opcodes = tables.opcodes;
  24737. this.order = tables.order;
  24738. this.strings = strings;
  24739. this.values = Object.create(null);
  24740. }
  24741. setByKey(key, value) {
  24742. if (!(key in this.keyToNameMap)) {
  24743. return false;
  24744. }
  24745. var valueLength = value.length;
  24746. if (valueLength === 0) {
  24747. return true;
  24748. }
  24749. for (var i = 0; i < valueLength; i++) {
  24750. if (isNaN(value[i])) {
  24751. (0, _util.warn)('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  24752. return true;
  24753. }
  24754. }
  24755. var type = this.types[key];
  24756. if (type === "num" || type === "sid" || type === "offset") {
  24757. value = value[0];
  24758. }
  24759. this.values[key] = value;
  24760. return true;
  24761. }
  24762. setByName(name, value) {
  24763. if (!(name in this.nameToKeyMap)) {
  24764. throw new _util.FormatError(`Invalid dictionary name "${name}"`);
  24765. }
  24766. this.values[this.nameToKeyMap[name]] = value;
  24767. }
  24768. hasName(name) {
  24769. return this.nameToKeyMap[name] in this.values;
  24770. }
  24771. getByName(name) {
  24772. if (!(name in this.nameToKeyMap)) {
  24773. throw new _util.FormatError(`Invalid dictionary name ${name}"`);
  24774. }
  24775. var key = this.nameToKeyMap[name];
  24776. if (!(key in this.values)) {
  24777. return this.defaults[key];
  24778. }
  24779. return this.values[key];
  24780. }
  24781. removeByName(name) {
  24782. delete this.values[this.nameToKeyMap[name]];
  24783. }
  24784. static createTables(layout) {
  24785. var tables = {
  24786. keyToNameMap: {},
  24787. nameToKeyMap: {},
  24788. defaults: {},
  24789. types: {},
  24790. opcodes: {},
  24791. order: []
  24792. };
  24793. for (var i = 0, ii = layout.length; i < ii; ++i) {
  24794. var entry = layout[i];
  24795. var key = Array.isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  24796. tables.keyToNameMap[key] = entry[1];
  24797. tables.nameToKeyMap[entry[1]] = key;
  24798. tables.types[key] = entry[2];
  24799. tables.defaults[key] = entry[3];
  24800. tables.opcodes[key] = Array.isArray(entry[0]) ? entry[0] : [entry[0]];
  24801. tables.order.push(key);
  24802. }
  24803. return tables;
  24804. }
  24805. }
  24806. var CFFTopDict = function CFFTopDictClosure() {
  24807. var layout = [[[12, 30], "ROS", ["sid", "sid", "num"], null], [[12, 20], "SyntheticBase", "num", null], [0, "version", "sid", null], [1, "Notice", "sid", null], [[12, 0], "Copyright", "sid", null], [2, "FullName", "sid", null], [3, "FamilyName", "sid", null], [4, "Weight", "sid", null], [[12, 1], "isFixedPitch", "num", 0], [[12, 2], "ItalicAngle", "num", 0], [[12, 3], "UnderlinePosition", "num", -100], [[12, 4], "UnderlineThickness", "num", 50], [[12, 5], "PaintType", "num", 0], [[12, 6], "CharstringType", "num", 2], [[12, 7], "FontMatrix", ["num", "num", "num", "num", "num", "num"], [0.001, 0, 0, 0.001, 0, 0]], [13, "UniqueID", "num", null], [5, "FontBBox", ["num", "num", "num", "num"], [0, 0, 0, 0]], [[12, 8], "StrokeWidth", "num", 0], [14, "XUID", "array", null], [15, "charset", "offset", 0], [16, "Encoding", "offset", 0], [17, "CharStrings", "offset", 0], [18, "Private", ["offset", "offset"], null], [[12, 21], "PostScript", "sid", null], [[12, 22], "BaseFontName", "sid", null], [[12, 23], "BaseFontBlend", "delta", null], [[12, 31], "CIDFontVersion", "num", 0], [[12, 32], "CIDFontRevision", "num", 0], [[12, 33], "CIDFontType", "num", 0], [[12, 34], "CIDCount", "num", 8720], [[12, 35], "UIDBase", "num", null], [[12, 37], "FDSelect", "offset", null], [[12, 36], "FDArray", "offset", null], [[12, 38], "FontName", "sid", null]];
  24808. var tables = null;
  24809. class CFFTopDict extends CFFDict {
  24810. constructor(strings) {
  24811. if (tables === null) {
  24812. tables = CFFDict.createTables(layout);
  24813. }
  24814. super(tables, strings);
  24815. this.privateDict = null;
  24816. }
  24817. }
  24818. return CFFTopDict;
  24819. }();
  24820. exports.CFFTopDict = CFFTopDict;
  24821. var CFFPrivateDict = function CFFPrivateDictClosure() {
  24822. var layout = [[6, "BlueValues", "delta", null], [7, "OtherBlues", "delta", null], [8, "FamilyBlues", "delta", null], [9, "FamilyOtherBlues", "delta", null], [[12, 9], "BlueScale", "num", 0.039625], [[12, 10], "BlueShift", "num", 7], [[12, 11], "BlueFuzz", "num", 1], [10, "StdHW", "num", null], [11, "StdVW", "num", null], [[12, 12], "StemSnapH", "delta", null], [[12, 13], "StemSnapV", "delta", null], [[12, 14], "ForceBold", "num", 0], [[12, 17], "LanguageGroup", "num", 0], [[12, 18], "ExpansionFactor", "num", 0.06], [[12, 19], "initialRandomSeed", "num", 0], [20, "defaultWidthX", "num", 0], [21, "nominalWidthX", "num", 0], [19, "Subrs", "offset", null]];
  24823. var tables = null;
  24824. class CFFPrivateDict extends CFFDict {
  24825. constructor(strings) {
  24826. if (tables === null) {
  24827. tables = CFFDict.createTables(layout);
  24828. }
  24829. super(tables, strings);
  24830. this.subrsIndex = null;
  24831. }
  24832. }
  24833. return CFFPrivateDict;
  24834. }();
  24835. exports.CFFPrivateDict = CFFPrivateDict;
  24836. var CFFCharsetPredefinedTypes = {
  24837. ISO_ADOBE: 0,
  24838. EXPERT: 1,
  24839. EXPERT_SUBSET: 2
  24840. };
  24841. class CFFCharset {
  24842. constructor(predefined, format, charset, raw) {
  24843. this.predefined = predefined;
  24844. this.format = format;
  24845. this.charset = charset;
  24846. this.raw = raw;
  24847. }
  24848. }
  24849. exports.CFFCharset = CFFCharset;
  24850. class CFFEncoding {
  24851. constructor(predefined, format, encoding, raw) {
  24852. this.predefined = predefined;
  24853. this.format = format;
  24854. this.encoding = encoding;
  24855. this.raw = raw;
  24856. }
  24857. }
  24858. class CFFFDSelect {
  24859. constructor(format, fdSelect) {
  24860. this.format = format;
  24861. this.fdSelect = fdSelect;
  24862. }
  24863. getFDIndex(glyphIndex) {
  24864. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  24865. return -1;
  24866. }
  24867. return this.fdSelect[glyphIndex];
  24868. }
  24869. }
  24870. exports.CFFFDSelect = CFFFDSelect;
  24871. class CFFOffsetTracker {
  24872. constructor() {
  24873. this.offsets = Object.create(null);
  24874. }
  24875. isTracking(key) {
  24876. return key in this.offsets;
  24877. }
  24878. track(key, location) {
  24879. if (key in this.offsets) {
  24880. throw new _util.FormatError(`Already tracking location of ${key}`);
  24881. }
  24882. this.offsets[key] = location;
  24883. }
  24884. offset(value) {
  24885. for (var key in this.offsets) {
  24886. this.offsets[key] += value;
  24887. }
  24888. }
  24889. setEntryLocation(key, values, output) {
  24890. if (!(key in this.offsets)) {
  24891. throw new _util.FormatError(`Not tracking location of ${key}`);
  24892. }
  24893. var data = output.data;
  24894. var dataOffset = this.offsets[key];
  24895. var size = 5;
  24896. for (var i = 0, ii = values.length; i < ii; ++i) {
  24897. var offset0 = i * size + dataOffset;
  24898. var offset1 = offset0 + 1;
  24899. var offset2 = offset0 + 2;
  24900. var offset3 = offset0 + 3;
  24901. var offset4 = offset0 + 4;
  24902. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  24903. throw new _util.FormatError("writing to an offset that is not empty");
  24904. }
  24905. var value = values[i];
  24906. data[offset0] = 0x1d;
  24907. data[offset1] = value >> 24 & 0xff;
  24908. data[offset2] = value >> 16 & 0xff;
  24909. data[offset3] = value >> 8 & 0xff;
  24910. data[offset4] = value & 0xff;
  24911. }
  24912. }
  24913. }
  24914. class CFFCompiler {
  24915. constructor(cff) {
  24916. this.cff = cff;
  24917. }
  24918. compile() {
  24919. var cff = this.cff;
  24920. var output = {
  24921. data: [],
  24922. length: 0,
  24923. add: function CFFCompiler_add(data) {
  24924. this.data = this.data.concat(data);
  24925. this.length = this.data.length;
  24926. }
  24927. };
  24928. var header = this.compileHeader(cff.header);
  24929. output.add(header);
  24930. var nameIndex = this.compileNameIndex(cff.names);
  24931. output.add(nameIndex);
  24932. if (cff.isCIDFont) {
  24933. if (cff.topDict.hasName("FontMatrix")) {
  24934. var base = cff.topDict.getByName("FontMatrix");
  24935. cff.topDict.removeByName("FontMatrix");
  24936. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  24937. var subDict = cff.fdArray[i];
  24938. var matrix = base.slice(0);
  24939. if (subDict.hasName("FontMatrix")) {
  24940. matrix = _util.Util.transform(matrix, subDict.getByName("FontMatrix"));
  24941. }
  24942. subDict.setByName("FontMatrix", matrix);
  24943. }
  24944. }
  24945. }
  24946. cff.topDict.setByName("charset", 0);
  24947. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  24948. output.add(compiled.output);
  24949. var topDictTracker = compiled.trackers[0];
  24950. var stringIndex = this.compileStringIndex(cff.strings.strings);
  24951. output.add(stringIndex);
  24952. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  24953. output.add(globalSubrIndex);
  24954. if (cff.encoding && cff.topDict.hasName("Encoding")) {
  24955. if (cff.encoding.predefined) {
  24956. topDictTracker.setEntryLocation("Encoding", [cff.encoding.format], output);
  24957. } else {
  24958. var encoding = this.compileEncoding(cff.encoding);
  24959. topDictTracker.setEntryLocation("Encoding", [output.length], output);
  24960. output.add(encoding);
  24961. }
  24962. }
  24963. var charset = this.compileCharset(cff.charset, cff.charStrings.count, cff.strings, cff.isCIDFont);
  24964. topDictTracker.setEntryLocation("charset", [output.length], output);
  24965. output.add(charset);
  24966. var charStrings = this.compileCharStrings(cff.charStrings);
  24967. topDictTracker.setEntryLocation("CharStrings", [output.length], output);
  24968. output.add(charStrings);
  24969. if (cff.isCIDFont) {
  24970. topDictTracker.setEntryLocation("FDSelect", [output.length], output);
  24971. var fdSelect = this.compileFDSelect(cff.fdSelect);
  24972. output.add(fdSelect);
  24973. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  24974. topDictTracker.setEntryLocation("FDArray", [output.length], output);
  24975. output.add(compiled.output);
  24976. var fontDictTrackers = compiled.trackers;
  24977. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  24978. }
  24979. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  24980. output.add([0]);
  24981. return output.data;
  24982. }
  24983. encodeNumber(value) {
  24984. if (Number.isInteger(value)) {
  24985. return this.encodeInteger(value);
  24986. }
  24987. return this.encodeFloat(value);
  24988. }
  24989. static get EncodeFloatRegExp() {
  24990. return (0, _util.shadow)(this, "EncodeFloatRegExp", /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/);
  24991. }
  24992. encodeFloat(num) {
  24993. var value = num.toString();
  24994. var m = CFFCompiler.EncodeFloatRegExp.exec(value);
  24995. if (m) {
  24996. var epsilon = parseFloat("1e" + ((m[2] ? +m[2] : 0) + m[1].length));
  24997. value = (Math.round(num * epsilon) / epsilon).toString();
  24998. }
  24999. var nibbles = "";
  25000. var i, ii;
  25001. for (i = 0, ii = value.length; i < ii; ++i) {
  25002. var a = value[i];
  25003. if (a === "e") {
  25004. nibbles += value[++i] === "-" ? "c" : "b";
  25005. } else if (a === ".") {
  25006. nibbles += "a";
  25007. } else if (a === "-") {
  25008. nibbles += "e";
  25009. } else {
  25010. nibbles += a;
  25011. }
  25012. }
  25013. nibbles += nibbles.length & 1 ? "f" : "ff";
  25014. var out = [30];
  25015. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  25016. out.push(parseInt(nibbles.substring(i, i + 2), 16));
  25017. }
  25018. return out;
  25019. }
  25020. encodeInteger(value) {
  25021. var code;
  25022. if (value >= -107 && value <= 107) {
  25023. code = [value + 139];
  25024. } else if (value >= 108 && value <= 1131) {
  25025. value = value - 108;
  25026. code = [(value >> 8) + 247, value & 0xff];
  25027. } else if (value >= -1131 && value <= -108) {
  25028. value = -value - 108;
  25029. code = [(value >> 8) + 251, value & 0xff];
  25030. } else if (value >= -32768 && value <= 32767) {
  25031. code = [0x1c, value >> 8 & 0xff, value & 0xff];
  25032. } else {
  25033. code = [0x1d, value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff];
  25034. }
  25035. return code;
  25036. }
  25037. compileHeader(header) {
  25038. return [header.major, header.minor, header.hdrSize, header.offSize];
  25039. }
  25040. compileNameIndex(names) {
  25041. var nameIndex = new CFFIndex();
  25042. for (var i = 0, ii = names.length; i < ii; ++i) {
  25043. var name = names[i];
  25044. var length = Math.min(name.length, 127);
  25045. var sanitizedName = new Array(length);
  25046. for (var j = 0; j < length; j++) {
  25047. var char = name[j];
  25048. if (char < "!" || char > "~" || char === "[" || char === "]" || char === "(" || char === ")" || char === "{" || char === "}" || char === "<" || char === ">" || char === "/" || char === "%") {
  25049. char = "_";
  25050. }
  25051. sanitizedName[j] = char;
  25052. }
  25053. sanitizedName = sanitizedName.join("");
  25054. if (sanitizedName === "") {
  25055. sanitizedName = "Bad_Font_Name";
  25056. }
  25057. nameIndex.add((0, _util.stringToBytes)(sanitizedName));
  25058. }
  25059. return this.compileIndex(nameIndex);
  25060. }
  25061. compileTopDicts(dicts, length, removeCidKeys) {
  25062. var fontDictTrackers = [];
  25063. var fdArrayIndex = new CFFIndex();
  25064. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  25065. var fontDict = dicts[i];
  25066. if (removeCidKeys) {
  25067. fontDict.removeByName("CIDFontVersion");
  25068. fontDict.removeByName("CIDFontRevision");
  25069. fontDict.removeByName("CIDFontType");
  25070. fontDict.removeByName("CIDCount");
  25071. fontDict.removeByName("UIDBase");
  25072. }
  25073. var fontDictTracker = new CFFOffsetTracker();
  25074. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  25075. fontDictTrackers.push(fontDictTracker);
  25076. fdArrayIndex.add(fontDictData);
  25077. fontDictTracker.offset(length);
  25078. }
  25079. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  25080. return {
  25081. trackers: fontDictTrackers,
  25082. output: fdArrayIndex
  25083. };
  25084. }
  25085. compilePrivateDicts(dicts, trackers, output) {
  25086. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  25087. var fontDict = dicts[i];
  25088. var privateDict = fontDict.privateDict;
  25089. if (!privateDict || !fontDict.hasName("Private")) {
  25090. throw new _util.FormatError("There must be a private dictionary.");
  25091. }
  25092. var privateDictTracker = new CFFOffsetTracker();
  25093. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  25094. var outputLength = output.length;
  25095. privateDictTracker.offset(outputLength);
  25096. if (!privateDictData.length) {
  25097. outputLength = 0;
  25098. }
  25099. trackers[i].setEntryLocation("Private", [privateDictData.length, outputLength], output);
  25100. output.add(privateDictData);
  25101. if (privateDict.subrsIndex && privateDict.hasName("Subrs")) {
  25102. var subrs = this.compileIndex(privateDict.subrsIndex);
  25103. privateDictTracker.setEntryLocation("Subrs", [privateDictData.length], output);
  25104. output.add(subrs);
  25105. }
  25106. }
  25107. }
  25108. compileDict(dict, offsetTracker) {
  25109. var out = [];
  25110. var order = dict.order;
  25111. for (var i = 0; i < order.length; ++i) {
  25112. var key = order[i];
  25113. if (!(key in dict.values)) {
  25114. continue;
  25115. }
  25116. var values = dict.values[key];
  25117. var types = dict.types[key];
  25118. if (!Array.isArray(types)) {
  25119. types = [types];
  25120. }
  25121. if (!Array.isArray(values)) {
  25122. values = [values];
  25123. }
  25124. if (values.length === 0) {
  25125. continue;
  25126. }
  25127. for (var j = 0, jj = types.length; j < jj; ++j) {
  25128. var type = types[j];
  25129. var value = values[j];
  25130. switch (type) {
  25131. case "num":
  25132. case "sid":
  25133. out = out.concat(this.encodeNumber(value));
  25134. break;
  25135. case "offset":
  25136. var name = dict.keyToNameMap[key];
  25137. if (!offsetTracker.isTracking(name)) {
  25138. offsetTracker.track(name, out.length);
  25139. }
  25140. out = out.concat([0x1d, 0, 0, 0, 0]);
  25141. break;
  25142. case "array":
  25143. case "delta":
  25144. out = out.concat(this.encodeNumber(value));
  25145. for (var k = 1, kk = values.length; k < kk; ++k) {
  25146. out = out.concat(this.encodeNumber(values[k]));
  25147. }
  25148. break;
  25149. default:
  25150. throw new _util.FormatError(`Unknown data type of ${type}`);
  25151. }
  25152. }
  25153. out = out.concat(dict.opcodes[key]);
  25154. }
  25155. return out;
  25156. }
  25157. compileStringIndex(strings) {
  25158. var stringIndex = new CFFIndex();
  25159. for (var i = 0, ii = strings.length; i < ii; ++i) {
  25160. stringIndex.add((0, _util.stringToBytes)(strings[i]));
  25161. }
  25162. return this.compileIndex(stringIndex);
  25163. }
  25164. compileGlobalSubrIndex() {
  25165. var globalSubrIndex = this.cff.globalSubrIndex;
  25166. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  25167. }
  25168. compileCharStrings(charStrings) {
  25169. var charStringsIndex = new CFFIndex();
  25170. for (var i = 0; i < charStrings.count; i++) {
  25171. var glyph = charStrings.get(i);
  25172. if (glyph.length === 0) {
  25173. charStringsIndex.add(new Uint8Array([0x8b, 0x0e]));
  25174. continue;
  25175. }
  25176. charStringsIndex.add(glyph);
  25177. }
  25178. return this.compileIndex(charStringsIndex);
  25179. }
  25180. compileCharset(charset, numGlyphs, strings, isCIDFont) {
  25181. let out;
  25182. const numGlyphsLessNotDef = numGlyphs - 1;
  25183. if (isCIDFont) {
  25184. out = new Uint8Array([2, 0, 0, numGlyphsLessNotDef >> 8 & 0xff, numGlyphsLessNotDef & 0xff]);
  25185. } else {
  25186. const length = 1 + numGlyphsLessNotDef * 2;
  25187. out = new Uint8Array(length);
  25188. out[0] = 0;
  25189. let charsetIndex = 0;
  25190. const numCharsets = charset.charset.length;
  25191. let warned = false;
  25192. for (let i = 1; i < out.length; i += 2) {
  25193. let sid = 0;
  25194. if (charsetIndex < numCharsets) {
  25195. const name = charset.charset[charsetIndex++];
  25196. sid = strings.getSID(name);
  25197. if (sid === -1) {
  25198. sid = 0;
  25199. if (!warned) {
  25200. warned = true;
  25201. (0, _util.warn)(`Couldn't find ${name} in CFF strings`);
  25202. }
  25203. }
  25204. }
  25205. out[i] = sid >> 8 & 0xff;
  25206. out[i + 1] = sid & 0xff;
  25207. }
  25208. }
  25209. return this.compileTypedArray(out);
  25210. }
  25211. compileEncoding(encoding) {
  25212. return this.compileTypedArray(encoding.raw);
  25213. }
  25214. compileFDSelect(fdSelect) {
  25215. const format = fdSelect.format;
  25216. let out, i;
  25217. switch (format) {
  25218. case 0:
  25219. out = new Uint8Array(1 + fdSelect.fdSelect.length);
  25220. out[0] = format;
  25221. for (i = 0; i < fdSelect.fdSelect.length; i++) {
  25222. out[i + 1] = fdSelect.fdSelect[i];
  25223. }
  25224. break;
  25225. case 3:
  25226. const start = 0;
  25227. let lastFD = fdSelect.fdSelect[0];
  25228. const ranges = [format, 0, 0, start >> 8 & 0xff, start & 0xff, lastFD];
  25229. for (i = 1; i < fdSelect.fdSelect.length; i++) {
  25230. const currentFD = fdSelect.fdSelect[i];
  25231. if (currentFD !== lastFD) {
  25232. ranges.push(i >> 8 & 0xff, i & 0xff, currentFD);
  25233. lastFD = currentFD;
  25234. }
  25235. }
  25236. const numRanges = (ranges.length - 3) / 3;
  25237. ranges[1] = numRanges >> 8 & 0xff;
  25238. ranges[2] = numRanges & 0xff;
  25239. ranges.push(i >> 8 & 0xff, i & 0xff);
  25240. out = new Uint8Array(ranges);
  25241. break;
  25242. }
  25243. return this.compileTypedArray(out);
  25244. }
  25245. compileTypedArray(data) {
  25246. var out = [];
  25247. for (var i = 0, ii = data.length; i < ii; ++i) {
  25248. out[i] = data[i];
  25249. }
  25250. return out;
  25251. }
  25252. compileIndex(index, trackers = []) {
  25253. var objects = index.objects;
  25254. var count = objects.length;
  25255. if (count === 0) {
  25256. return [0, 0, 0];
  25257. }
  25258. var data = [count >> 8 & 0xff, count & 0xff];
  25259. var lastOffset = 1,
  25260. i;
  25261. for (i = 0; i < count; ++i) {
  25262. lastOffset += objects[i].length;
  25263. }
  25264. var offsetSize;
  25265. if (lastOffset < 0x100) {
  25266. offsetSize = 1;
  25267. } else if (lastOffset < 0x10000) {
  25268. offsetSize = 2;
  25269. } else if (lastOffset < 0x1000000) {
  25270. offsetSize = 3;
  25271. } else {
  25272. offsetSize = 4;
  25273. }
  25274. data.push(offsetSize);
  25275. var relativeOffset = 1;
  25276. for (i = 0; i < count + 1; i++) {
  25277. if (offsetSize === 1) {
  25278. data.push(relativeOffset & 0xff);
  25279. } else if (offsetSize === 2) {
  25280. data.push(relativeOffset >> 8 & 0xff, relativeOffset & 0xff);
  25281. } else if (offsetSize === 3) {
  25282. data.push(relativeOffset >> 16 & 0xff, relativeOffset >> 8 & 0xff, relativeOffset & 0xff);
  25283. } else {
  25284. data.push(relativeOffset >>> 24 & 0xff, relativeOffset >> 16 & 0xff, relativeOffset >> 8 & 0xff, relativeOffset & 0xff);
  25285. }
  25286. if (objects[i]) {
  25287. relativeOffset += objects[i].length;
  25288. }
  25289. }
  25290. for (i = 0; i < count; i++) {
  25291. if (trackers[i]) {
  25292. trackers[i].offset(data.length);
  25293. }
  25294. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  25295. data.push(objects[i][j]);
  25296. }
  25297. }
  25298. return data;
  25299. }
  25300. }
  25301. exports.CFFCompiler = CFFCompiler;
  25302. /***/ }),
  25303. /* 32 */
  25304. /***/ (function(module, exports, __w_pdfjs_require__) {
  25305. "use strict";
  25306. Object.defineProperty(exports, "__esModule", {
  25307. value: true
  25308. });
  25309. exports.ExpertSubsetCharset = exports.ExpertCharset = exports.ISOAdobeCharset = void 0;
  25310. const ISOAdobeCharset = [".notdef", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "exclamdown", "cent", "sterling", "fraction", "yen", "florin", "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi", "fl", "endash", "dagger", "daggerdbl", "periodcentered", "paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright", "guillemotright", "ellipsis", "perthousand", "questiondown", "grave", "acute", "circumflex", "tilde", "macron", "breve", "dotaccent", "dieresis", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "emdash", "AE", "ordfeminine", "Lslash", "Oslash", "OE", "ordmasculine", "ae", "dotlessi", "lslash", "oslash", "oe", "germandbls", "onesuperior", "logicalnot", "mu", "trademark", "Eth", "onehalf", "plusminus", "Thorn", "onequarter", "divide", "brokenbar", "degree", "thorn", "threequarters", "twosuperior", "registered", "minus", "eth", "multiply", "threesuperior", "copyright", "Aacute", "Acircumflex", "Adieresis", "Agrave", "Aring", "Atilde", "Ccedilla", "Eacute", "Ecircumflex", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Ntilde", "Oacute", "Ocircumflex", "Odieresis", "Ograve", "Otilde", "Scaron", "Uacute", "Ucircumflex", "Udieresis", "Ugrave", "Yacute", "Ydieresis", "Zcaron", "aacute", "acircumflex", "adieresis", "agrave", "aring", "atilde", "ccedilla", "eacute", "ecircumflex", "edieresis", "egrave", "iacute", "icircumflex", "idieresis", "igrave", "ntilde", "oacute", "ocircumflex", "odieresis", "ograve", "otilde", "scaron", "uacute", "ucircumflex", "udieresis", "ugrave", "yacute", "ydieresis", "zcaron"];
  25311. exports.ISOAdobeCharset = ISOAdobeCharset;
  25312. const ExpertCharset = [".notdef", "space", "exclamsmall", "Hungarumlautsmall", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "colon", "semicolon", "commasuperior", "threequartersemdash", "periodsuperior", "questionsmall", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah", "Tildesmall", "exclamdownsmall", "centoldstyle", "Lslashsmall", "Scaronsmall", "Zcaronsmall", "Dieresissmall", "Brevesmall", "Caronsmall", "Dotaccentsmall", "Macronsmall", "figuredash", "hypheninferior", "Ogoneksmall", "Ringsmall", "Cedillasmall", "onequarter", "onehalf", "threequarters", "questiondownsmall", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "onesuperior", "twosuperior", "threesuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", "Acircumflexsmall", "Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall", "Igravesmall", "Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", "Odieresissmall", "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall"];
  25313. exports.ExpertCharset = ExpertCharset;
  25314. const ExpertSubsetCharset = [".notdef", "space", "dollaroldstyle", "dollarsuperior", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "colon", "semicolon", "commasuperior", "threequartersemdash", "periodsuperior", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", "parenrightinferior", "hyphensuperior", "colonmonetary", "onefitted", "rupiah", "centoldstyle", "figuredash", "hypheninferior", "onequarter", "onehalf", "threequarters", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "onesuperior", "twosuperior", "threesuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior"];
  25315. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  25316. /***/ }),
  25317. /* 33 */
  25318. /***/ (function(module, exports, __w_pdfjs_require__) {
  25319. "use strict";
  25320. Object.defineProperty(exports, "__esModule", {
  25321. value: true
  25322. });
  25323. exports.getEncoding = getEncoding;
  25324. exports.ExpertEncoding = exports.ZapfDingbatsEncoding = exports.SymbolSetEncoding = exports.MacRomanEncoding = exports.StandardEncoding = exports.WinAnsiEncoding = void 0;
  25325. const ExpertEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclamsmall", "Hungarumlautsmall", "", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "colon", "semicolon", "commasuperior", "threequartersemdash", "periodsuperior", "questionsmall", "", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "", "", "", "isuperior", "", "", "lsuperior", "msuperior", "nsuperior", "osuperior", "", "", "rsuperior", "ssuperior", "tsuperior", "", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", "", "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah", "Tildesmall", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "exclamdownsmall", "centoldstyle", "Lslashsmall", "", "", "Scaronsmall", "Zcaronsmall", "Dieresissmall", "Brevesmall", "Caronsmall", "", "Dotaccentsmall", "", "", "Macronsmall", "", "", "figuredash", "hypheninferior", "", "", "Ogoneksmall", "Ringsmall", "Cedillasmall", "", "", "", "onequarter", "onehalf", "threequarters", "questiondownsmall", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "", "", "zerosuperior", "onesuperior", "twosuperior", "threesuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", "Acircumflexsmall", "Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall", "Igravesmall", "Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", "Odieresissmall", "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall"];
  25326. exports.ExpertEncoding = ExpertEncoding;
  25327. const MacExpertEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclamsmall", "Hungarumlautsmall", "centoldstyle", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "colon", "semicolon", "", "threequartersemdash", "", "questionsmall", "", "", "", "", "Ethsmall", "", "", "onequarter", "onehalf", "threequarters", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "", "", "", "", "", "", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", "", "parenrightinferior", "Circumflexsmall", "hypheninferior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah", "Tildesmall", "", "", "asuperior", "centsuperior", "", "", "", "", "Aacutesmall", "Agravesmall", "Acircumflexsmall", "Adieresissmall", "Atildesmall", "Aringsmall", "Ccedillasmall", "Eacutesmall", "Egravesmall", "Ecircumflexsmall", "Edieresissmall", "Iacutesmall", "Igravesmall", "Icircumflexsmall", "Idieresissmall", "Ntildesmall", "Oacutesmall", "Ogravesmall", "Ocircumflexsmall", "Odieresissmall", "Otildesmall", "Uacutesmall", "Ugravesmall", "Ucircumflexsmall", "Udieresissmall", "", "eightsuperior", "fourinferior", "threeinferior", "sixinferior", "eightinferior", "seveninferior", "Scaronsmall", "", "centinferior", "twoinferior", "", "Dieresissmall", "", "Caronsmall", "osuperior", "fiveinferior", "", "commainferior", "periodinferior", "Yacutesmall", "", "dollarinferior", "", "", "Thornsmall", "", "nineinferior", "zeroinferior", "Zcaronsmall", "AEsmall", "Oslashsmall", "questiondownsmall", "oneinferior", "Lslashsmall", "", "", "", "", "", "", "Cedillasmall", "", "", "", "", "", "OEsmall", "figuredash", "hyphensuperior", "", "", "", "", "exclamdownsmall", "", "Ydieresissmall", "", "onesuperior", "twosuperior", "threesuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "ninesuperior", "zerosuperior", "", "esuperior", "rsuperior", "tsuperior", "", "", "isuperior", "ssuperior", "dsuperior", "", "", "", "", "", "lsuperior", "Ogoneksmall", "Brevesmall", "Macronsmall", "bsuperior", "nsuperior", "msuperior", "commasuperior", "periodsuperior", "Dotaccentsmall", "Ringsmall", "", "", "", ""];
  25328. const MacRomanEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "", "Adieresis", "Aring", "Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis", "aacute", "agrave", "acircumflex", "adieresis", "atilde", "aring", "ccedilla", "eacute", "egrave", "ecircumflex", "edieresis", "iacute", "igrave", "icircumflex", "idieresis", "ntilde", "oacute", "ograve", "ocircumflex", "odieresis", "otilde", "uacute", "ugrave", "ucircumflex", "udieresis", "dagger", "degree", "cent", "sterling", "section", "bullet", "paragraph", "germandbls", "registered", "copyright", "trademark", "acute", "dieresis", "notequal", "AE", "Oslash", "infinity", "plusminus", "lessequal", "greaterequal", "yen", "mu", "partialdiff", "summation", "product", "pi", "integral", "ordfeminine", "ordmasculine", "Omega", "ae", "oslash", "questiondown", "exclamdown", "logicalnot", "radical", "florin", "approxequal", "Delta", "guillemotleft", "guillemotright", "ellipsis", "space", "Agrave", "Atilde", "Otilde", "OE", "oe", "endash", "emdash", "quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide", "lozenge", "ydieresis", "Ydieresis", "fraction", "currency", "guilsinglleft", "guilsinglright", "fi", "fl", "daggerdbl", "periodcentered", "quotesinglbase", "quotedblbase", "perthousand", "Acircumflex", "Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex", "apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave", "dotlessi", "circumflex", "tilde", "macron", "breve", "dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek", "caron"];
  25329. exports.MacRomanEncoding = MacRomanEncoding;
  25330. const StandardEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "exclamdown", "cent", "sterling", "fraction", "yen", "florin", "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi", "fl", "", "endash", "dagger", "daggerdbl", "periodcentered", "", "paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright", "guillemotright", "ellipsis", "perthousand", "", "questiondown", "", "grave", "acute", "circumflex", "tilde", "macron", "breve", "dotaccent", "dieresis", "", "ring", "cedilla", "", "hungarumlaut", "ogonek", "caron", "emdash", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "AE", "", "ordfeminine", "", "", "", "", "Lslash", "Oslash", "OE", "ordmasculine", "", "", "", "", "", "ae", "", "", "", "dotlessi", "", "", "lslash", "oslash", "oe", "germandbls", "", "", "", ""];
  25331. exports.StandardEncoding = StandardEncoding;
  25332. const WinAnsiEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "bullet", "Euro", "bullet", "quotesinglbase", "florin", "quotedblbase", "ellipsis", "dagger", "daggerdbl", "circumflex", "perthousand", "Scaron", "guilsinglleft", "OE", "bullet", "Zcaron", "bullet", "bullet", "quoteleft", "quoteright", "quotedblleft", "quotedblright", "bullet", "endash", "emdash", "tilde", "trademark", "scaron", "guilsinglright", "oe", "bullet", "zcaron", "Ydieresis", "space", "exclamdown", "cent", "sterling", "currency", "yen", "brokenbar", "section", "dieresis", "copyright", "ordfeminine", "guillemotleft", "logicalnot", "hyphen", "registered", "macron", "degree", "plusminus", "twosuperior", "threesuperior", "acute", "mu", "paragraph", "periodcentered", "cedilla", "onesuperior", "ordmasculine", "guillemotright", "onequarter", "onehalf", "threequarters", "questiondown", "Agrave", "Aacute", "Acircumflex", "Atilde", "Adieresis", "Aring", "AE", "Ccedilla", "Egrave", "Eacute", "Ecircumflex", "Edieresis", "Igrave", "Iacute", "Icircumflex", "Idieresis", "Eth", "Ntilde", "Ograve", "Oacute", "Ocircumflex", "Otilde", "Odieresis", "multiply", "Oslash", "Ugrave", "Uacute", "Ucircumflex", "Udieresis", "Yacute", "Thorn", "germandbls", "agrave", "aacute", "acircumflex", "atilde", "adieresis", "aring", "ae", "ccedilla", "egrave", "eacute", "ecircumflex", "edieresis", "igrave", "iacute", "icircumflex", "idieresis", "eth", "ntilde", "ograve", "oacute", "ocircumflex", "otilde", "odieresis", "divide", "oslash", "ugrave", "uacute", "ucircumflex", "udieresis", "yacute", "thorn", "ydieresis"];
  25333. exports.WinAnsiEncoding = WinAnsiEncoding;
  25334. const SymbolSetEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclam", "universal", "numbersign", "existential", "percent", "ampersand", "suchthat", "parenleft", "parenright", "asteriskmath", "plus", "comma", "minus", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "congruent", "Alpha", "Beta", "Chi", "Delta", "Epsilon", "Phi", "Gamma", "Eta", "Iota", "theta1", "Kappa", "Lambda", "Mu", "Nu", "Omicron", "Pi", "Theta", "Rho", "Sigma", "Tau", "Upsilon", "sigma1", "Omega", "Xi", "Psi", "Zeta", "bracketleft", "therefore", "bracketright", "perpendicular", "underscore", "radicalex", "alpha", "beta", "chi", "delta", "epsilon", "phi", "gamma", "eta", "iota", "phi1", "kappa", "lambda", "mu", "nu", "omicron", "pi", "theta", "rho", "sigma", "tau", "upsilon", "omega1", "omega", "xi", "psi", "zeta", "braceleft", "bar", "braceright", "similar", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "Euro", "Upsilon1", "minute", "lessequal", "fraction", "infinity", "florin", "club", "diamond", "heart", "spade", "arrowboth", "arrowleft", "arrowup", "arrowright", "arrowdown", "degree", "plusminus", "second", "greaterequal", "multiply", "proportional", "partialdiff", "bullet", "divide", "notequal", "equivalence", "approxequal", "ellipsis", "arrowvertex", "arrowhorizex", "carriagereturn", "aleph", "Ifraktur", "Rfraktur", "weierstrass", "circlemultiply", "circleplus", "emptyset", "intersection", "union", "propersuperset", "reflexsuperset", "notsubset", "propersubset", "reflexsubset", "element", "notelement", "angle", "gradient", "registerserif", "copyrightserif", "trademarkserif", "product", "radical", "dotmath", "logicalnot", "logicaland", "logicalor", "arrowdblboth", "arrowdblleft", "arrowdblup", "arrowdblright", "arrowdbldown", "lozenge", "angleleft", "registersans", "copyrightsans", "trademarksans", "summation", "parenlefttp", "parenleftex", "parenleftbt", "bracketlefttp", "bracketleftex", "bracketleftbt", "bracelefttp", "braceleftmid", "braceleftbt", "braceex", "", "angleright", "integral", "integraltp", "integralex", "integralbt", "parenrighttp", "parenrightex", "parenrightbt", "bracketrighttp", "bracketrightex", "bracketrightbt", "bracerighttp", "bracerightmid", "bracerightbt", ""];
  25335. exports.SymbolSetEncoding = SymbolSetEncoding;
  25336. const ZapfDingbatsEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "a1", "a2", "a202", "a3", "a4", "a5", "a119", "a118", "a117", "a11", "a12", "a13", "a14", "a15", "a16", "a105", "a17", "a18", "a19", "a20", "a21", "a22", "a23", "a24", "a25", "a26", "a27", "a28", "a6", "a7", "a8", "a9", "a10", "a29", "a30", "a31", "a32", "a33", "a34", "a35", "a36", "a37", "a38", "a39", "a40", "a41", "a42", "a43", "a44", "a45", "a46", "a47", "a48", "a49", "a50", "a51", "a52", "a53", "a54", "a55", "a56", "a57", "a58", "a59", "a60", "a61", "a62", "a63", "a64", "a65", "a66", "a67", "a68", "a69", "a70", "a71", "a72", "a73", "a74", "a203", "a75", "a204", "a76", "a77", "a78", "a79", "a81", "a82", "a83", "a84", "a97", "a98", "a99", "a100", "", "a89", "a90", "a93", "a94", "a91", "a92", "a205", "a85", "a206", "a86", "a87", "a88", "a95", "a96", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "a101", "a102", "a103", "a104", "a106", "a107", "a108", "a112", "a111", "a110", "a109", "a120", "a121", "a122", "a123", "a124", "a125", "a126", "a127", "a128", "a129", "a130", "a131", "a132", "a133", "a134", "a135", "a136", "a137", "a138", "a139", "a140", "a141", "a142", "a143", "a144", "a145", "a146", "a147", "a148", "a149", "a150", "a151", "a152", "a153", "a154", "a155", "a156", "a157", "a158", "a159", "a160", "a161", "a163", "a164", "a196", "a165", "a192", "a166", "a167", "a168", "a169", "a170", "a171", "a172", "a173", "a162", "a174", "a175", "a176", "a177", "a178", "a179", "a193", "a180", "a199", "a181", "a200", "a182", "", "a201", "a183", "a184", "a197", "a185", "a194", "a198", "a186", "a195", "a187", "a188", "a189", "a190", "a191", ""];
  25337. exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
  25338. function getEncoding(encodingName) {
  25339. switch (encodingName) {
  25340. case "WinAnsiEncoding":
  25341. return WinAnsiEncoding;
  25342. case "StandardEncoding":
  25343. return StandardEncoding;
  25344. case "MacRomanEncoding":
  25345. return MacRomanEncoding;
  25346. case "SymbolSetEncoding":
  25347. return SymbolSetEncoding;
  25348. case "ZapfDingbatsEncoding":
  25349. return ZapfDingbatsEncoding;
  25350. case "ExpertEncoding":
  25351. return ExpertEncoding;
  25352. case "MacExpertEncoding":
  25353. return MacExpertEncoding;
  25354. default:
  25355. return null;
  25356. }
  25357. }
  25358. /***/ }),
  25359. /* 34 */
  25360. /***/ (function(module, exports, __w_pdfjs_require__) {
  25361. var getLookupTableFactory = __w_pdfjs_require__(8).getLookupTableFactory;
  25362. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  25363. t.A = 0x0041;
  25364. t.AE = 0x00c6;
  25365. t.AEacute = 0x01fc;
  25366. t.AEmacron = 0x01e2;
  25367. t.AEsmall = 0xf7e6;
  25368. t.Aacute = 0x00c1;
  25369. t.Aacutesmall = 0xf7e1;
  25370. t.Abreve = 0x0102;
  25371. t.Abreveacute = 0x1eae;
  25372. t.Abrevecyrillic = 0x04d0;
  25373. t.Abrevedotbelow = 0x1eb6;
  25374. t.Abrevegrave = 0x1eb0;
  25375. t.Abrevehookabove = 0x1eb2;
  25376. t.Abrevetilde = 0x1eb4;
  25377. t.Acaron = 0x01cd;
  25378. t.Acircle = 0x24b6;
  25379. t.Acircumflex = 0x00c2;
  25380. t.Acircumflexacute = 0x1ea4;
  25381. t.Acircumflexdotbelow = 0x1eac;
  25382. t.Acircumflexgrave = 0x1ea6;
  25383. t.Acircumflexhookabove = 0x1ea8;
  25384. t.Acircumflexsmall = 0xf7e2;
  25385. t.Acircumflextilde = 0x1eaa;
  25386. t.Acute = 0xf6c9;
  25387. t.Acutesmall = 0xf7b4;
  25388. t.Acyrillic = 0x0410;
  25389. t.Adblgrave = 0x0200;
  25390. t.Adieresis = 0x00c4;
  25391. t.Adieresiscyrillic = 0x04d2;
  25392. t.Adieresismacron = 0x01de;
  25393. t.Adieresissmall = 0xf7e4;
  25394. t.Adotbelow = 0x1ea0;
  25395. t.Adotmacron = 0x01e0;
  25396. t.Agrave = 0x00c0;
  25397. t.Agravesmall = 0xf7e0;
  25398. t.Ahookabove = 0x1ea2;
  25399. t.Aiecyrillic = 0x04d4;
  25400. t.Ainvertedbreve = 0x0202;
  25401. t.Alpha = 0x0391;
  25402. t.Alphatonos = 0x0386;
  25403. t.Amacron = 0x0100;
  25404. t.Amonospace = 0xff21;
  25405. t.Aogonek = 0x0104;
  25406. t.Aring = 0x00c5;
  25407. t.Aringacute = 0x01fa;
  25408. t.Aringbelow = 0x1e00;
  25409. t.Aringsmall = 0xf7e5;
  25410. t.Asmall = 0xf761;
  25411. t.Atilde = 0x00c3;
  25412. t.Atildesmall = 0xf7e3;
  25413. t.Aybarmenian = 0x0531;
  25414. t.B = 0x0042;
  25415. t.Bcircle = 0x24b7;
  25416. t.Bdotaccent = 0x1e02;
  25417. t.Bdotbelow = 0x1e04;
  25418. t.Becyrillic = 0x0411;
  25419. t.Benarmenian = 0x0532;
  25420. t.Beta = 0x0392;
  25421. t.Bhook = 0x0181;
  25422. t.Blinebelow = 0x1e06;
  25423. t.Bmonospace = 0xff22;
  25424. t.Brevesmall = 0xf6f4;
  25425. t.Bsmall = 0xf762;
  25426. t.Btopbar = 0x0182;
  25427. t.C = 0x0043;
  25428. t.Caarmenian = 0x053e;
  25429. t.Cacute = 0x0106;
  25430. t.Caron = 0xf6ca;
  25431. t.Caronsmall = 0xf6f5;
  25432. t.Ccaron = 0x010c;
  25433. t.Ccedilla = 0x00c7;
  25434. t.Ccedillaacute = 0x1e08;
  25435. t.Ccedillasmall = 0xf7e7;
  25436. t.Ccircle = 0x24b8;
  25437. t.Ccircumflex = 0x0108;
  25438. t.Cdot = 0x010a;
  25439. t.Cdotaccent = 0x010a;
  25440. t.Cedillasmall = 0xf7b8;
  25441. t.Chaarmenian = 0x0549;
  25442. t.Cheabkhasiancyrillic = 0x04bc;
  25443. t.Checyrillic = 0x0427;
  25444. t.Chedescenderabkhasiancyrillic = 0x04be;
  25445. t.Chedescendercyrillic = 0x04b6;
  25446. t.Chedieresiscyrillic = 0x04f4;
  25447. t.Cheharmenian = 0x0543;
  25448. t.Chekhakassiancyrillic = 0x04cb;
  25449. t.Cheverticalstrokecyrillic = 0x04b8;
  25450. t.Chi = 0x03a7;
  25451. t.Chook = 0x0187;
  25452. t.Circumflexsmall = 0xf6f6;
  25453. t.Cmonospace = 0xff23;
  25454. t.Coarmenian = 0x0551;
  25455. t.Csmall = 0xf763;
  25456. t.D = 0x0044;
  25457. t.DZ = 0x01f1;
  25458. t.DZcaron = 0x01c4;
  25459. t.Daarmenian = 0x0534;
  25460. t.Dafrican = 0x0189;
  25461. t.Dcaron = 0x010e;
  25462. t.Dcedilla = 0x1e10;
  25463. t.Dcircle = 0x24b9;
  25464. t.Dcircumflexbelow = 0x1e12;
  25465. t.Dcroat = 0x0110;
  25466. t.Ddotaccent = 0x1e0a;
  25467. t.Ddotbelow = 0x1e0c;
  25468. t.Decyrillic = 0x0414;
  25469. t.Deicoptic = 0x03ee;
  25470. t.Delta = 0x2206;
  25471. t.Deltagreek = 0x0394;
  25472. t.Dhook = 0x018a;
  25473. t.Dieresis = 0xf6cb;
  25474. t.DieresisAcute = 0xf6cc;
  25475. t.DieresisGrave = 0xf6cd;
  25476. t.Dieresissmall = 0xf7a8;
  25477. t.Digammagreek = 0x03dc;
  25478. t.Djecyrillic = 0x0402;
  25479. t.Dlinebelow = 0x1e0e;
  25480. t.Dmonospace = 0xff24;
  25481. t.Dotaccentsmall = 0xf6f7;
  25482. t.Dslash = 0x0110;
  25483. t.Dsmall = 0xf764;
  25484. t.Dtopbar = 0x018b;
  25485. t.Dz = 0x01f2;
  25486. t.Dzcaron = 0x01c5;
  25487. t.Dzeabkhasiancyrillic = 0x04e0;
  25488. t.Dzecyrillic = 0x0405;
  25489. t.Dzhecyrillic = 0x040f;
  25490. t.E = 0x0045;
  25491. t.Eacute = 0x00c9;
  25492. t.Eacutesmall = 0xf7e9;
  25493. t.Ebreve = 0x0114;
  25494. t.Ecaron = 0x011a;
  25495. t.Ecedillabreve = 0x1e1c;
  25496. t.Echarmenian = 0x0535;
  25497. t.Ecircle = 0x24ba;
  25498. t.Ecircumflex = 0x00ca;
  25499. t.Ecircumflexacute = 0x1ebe;
  25500. t.Ecircumflexbelow = 0x1e18;
  25501. t.Ecircumflexdotbelow = 0x1ec6;
  25502. t.Ecircumflexgrave = 0x1ec0;
  25503. t.Ecircumflexhookabove = 0x1ec2;
  25504. t.Ecircumflexsmall = 0xf7ea;
  25505. t.Ecircumflextilde = 0x1ec4;
  25506. t.Ecyrillic = 0x0404;
  25507. t.Edblgrave = 0x0204;
  25508. t.Edieresis = 0x00cb;
  25509. t.Edieresissmall = 0xf7eb;
  25510. t.Edot = 0x0116;
  25511. t.Edotaccent = 0x0116;
  25512. t.Edotbelow = 0x1eb8;
  25513. t.Efcyrillic = 0x0424;
  25514. t.Egrave = 0x00c8;
  25515. t.Egravesmall = 0xf7e8;
  25516. t.Eharmenian = 0x0537;
  25517. t.Ehookabove = 0x1eba;
  25518. t.Eightroman = 0x2167;
  25519. t.Einvertedbreve = 0x0206;
  25520. t.Eiotifiedcyrillic = 0x0464;
  25521. t.Elcyrillic = 0x041b;
  25522. t.Elevenroman = 0x216a;
  25523. t.Emacron = 0x0112;
  25524. t.Emacronacute = 0x1e16;
  25525. t.Emacrongrave = 0x1e14;
  25526. t.Emcyrillic = 0x041c;
  25527. t.Emonospace = 0xff25;
  25528. t.Encyrillic = 0x041d;
  25529. t.Endescendercyrillic = 0x04a2;
  25530. t.Eng = 0x014a;
  25531. t.Enghecyrillic = 0x04a4;
  25532. t.Enhookcyrillic = 0x04c7;
  25533. t.Eogonek = 0x0118;
  25534. t.Eopen = 0x0190;
  25535. t.Epsilon = 0x0395;
  25536. t.Epsilontonos = 0x0388;
  25537. t.Ercyrillic = 0x0420;
  25538. t.Ereversed = 0x018e;
  25539. t.Ereversedcyrillic = 0x042d;
  25540. t.Escyrillic = 0x0421;
  25541. t.Esdescendercyrillic = 0x04aa;
  25542. t.Esh = 0x01a9;
  25543. t.Esmall = 0xf765;
  25544. t.Eta = 0x0397;
  25545. t.Etarmenian = 0x0538;
  25546. t.Etatonos = 0x0389;
  25547. t.Eth = 0x00d0;
  25548. t.Ethsmall = 0xf7f0;
  25549. t.Etilde = 0x1ebc;
  25550. t.Etildebelow = 0x1e1a;
  25551. t.Euro = 0x20ac;
  25552. t.Ezh = 0x01b7;
  25553. t.Ezhcaron = 0x01ee;
  25554. t.Ezhreversed = 0x01b8;
  25555. t.F = 0x0046;
  25556. t.Fcircle = 0x24bb;
  25557. t.Fdotaccent = 0x1e1e;
  25558. t.Feharmenian = 0x0556;
  25559. t.Feicoptic = 0x03e4;
  25560. t.Fhook = 0x0191;
  25561. t.Fitacyrillic = 0x0472;
  25562. t.Fiveroman = 0x2164;
  25563. t.Fmonospace = 0xff26;
  25564. t.Fourroman = 0x2163;
  25565. t.Fsmall = 0xf766;
  25566. t.G = 0x0047;
  25567. t.GBsquare = 0x3387;
  25568. t.Gacute = 0x01f4;
  25569. t.Gamma = 0x0393;
  25570. t.Gammaafrican = 0x0194;
  25571. t.Gangiacoptic = 0x03ea;
  25572. t.Gbreve = 0x011e;
  25573. t.Gcaron = 0x01e6;
  25574. t.Gcedilla = 0x0122;
  25575. t.Gcircle = 0x24bc;
  25576. t.Gcircumflex = 0x011c;
  25577. t.Gcommaaccent = 0x0122;
  25578. t.Gdot = 0x0120;
  25579. t.Gdotaccent = 0x0120;
  25580. t.Gecyrillic = 0x0413;
  25581. t.Ghadarmenian = 0x0542;
  25582. t.Ghemiddlehookcyrillic = 0x0494;
  25583. t.Ghestrokecyrillic = 0x0492;
  25584. t.Gheupturncyrillic = 0x0490;
  25585. t.Ghook = 0x0193;
  25586. t.Gimarmenian = 0x0533;
  25587. t.Gjecyrillic = 0x0403;
  25588. t.Gmacron = 0x1e20;
  25589. t.Gmonospace = 0xff27;
  25590. t.Grave = 0xf6ce;
  25591. t.Gravesmall = 0xf760;
  25592. t.Gsmall = 0xf767;
  25593. t.Gsmallhook = 0x029b;
  25594. t.Gstroke = 0x01e4;
  25595. t.H = 0x0048;
  25596. t.H18533 = 0x25cf;
  25597. t.H18543 = 0x25aa;
  25598. t.H18551 = 0x25ab;
  25599. t.H22073 = 0x25a1;
  25600. t.HPsquare = 0x33cb;
  25601. t.Haabkhasiancyrillic = 0x04a8;
  25602. t.Hadescendercyrillic = 0x04b2;
  25603. t.Hardsigncyrillic = 0x042a;
  25604. t.Hbar = 0x0126;
  25605. t.Hbrevebelow = 0x1e2a;
  25606. t.Hcedilla = 0x1e28;
  25607. t.Hcircle = 0x24bd;
  25608. t.Hcircumflex = 0x0124;
  25609. t.Hdieresis = 0x1e26;
  25610. t.Hdotaccent = 0x1e22;
  25611. t.Hdotbelow = 0x1e24;
  25612. t.Hmonospace = 0xff28;
  25613. t.Hoarmenian = 0x0540;
  25614. t.Horicoptic = 0x03e8;
  25615. t.Hsmall = 0xf768;
  25616. t.Hungarumlaut = 0xf6cf;
  25617. t.Hungarumlautsmall = 0xf6f8;
  25618. t.Hzsquare = 0x3390;
  25619. t.I = 0x0049;
  25620. t.IAcyrillic = 0x042f;
  25621. t.IJ = 0x0132;
  25622. t.IUcyrillic = 0x042e;
  25623. t.Iacute = 0x00cd;
  25624. t.Iacutesmall = 0xf7ed;
  25625. t.Ibreve = 0x012c;
  25626. t.Icaron = 0x01cf;
  25627. t.Icircle = 0x24be;
  25628. t.Icircumflex = 0x00ce;
  25629. t.Icircumflexsmall = 0xf7ee;
  25630. t.Icyrillic = 0x0406;
  25631. t.Idblgrave = 0x0208;
  25632. t.Idieresis = 0x00cf;
  25633. t.Idieresisacute = 0x1e2e;
  25634. t.Idieresiscyrillic = 0x04e4;
  25635. t.Idieresissmall = 0xf7ef;
  25636. t.Idot = 0x0130;
  25637. t.Idotaccent = 0x0130;
  25638. t.Idotbelow = 0x1eca;
  25639. t.Iebrevecyrillic = 0x04d6;
  25640. t.Iecyrillic = 0x0415;
  25641. t.Ifraktur = 0x2111;
  25642. t.Igrave = 0x00cc;
  25643. t.Igravesmall = 0xf7ec;
  25644. t.Ihookabove = 0x1ec8;
  25645. t.Iicyrillic = 0x0418;
  25646. t.Iinvertedbreve = 0x020a;
  25647. t.Iishortcyrillic = 0x0419;
  25648. t.Imacron = 0x012a;
  25649. t.Imacroncyrillic = 0x04e2;
  25650. t.Imonospace = 0xff29;
  25651. t.Iniarmenian = 0x053b;
  25652. t.Iocyrillic = 0x0401;
  25653. t.Iogonek = 0x012e;
  25654. t.Iota = 0x0399;
  25655. t.Iotaafrican = 0x0196;
  25656. t.Iotadieresis = 0x03aa;
  25657. t.Iotatonos = 0x038a;
  25658. t.Ismall = 0xf769;
  25659. t.Istroke = 0x0197;
  25660. t.Itilde = 0x0128;
  25661. t.Itildebelow = 0x1e2c;
  25662. t.Izhitsacyrillic = 0x0474;
  25663. t.Izhitsadblgravecyrillic = 0x0476;
  25664. t.J = 0x004a;
  25665. t.Jaarmenian = 0x0541;
  25666. t.Jcircle = 0x24bf;
  25667. t.Jcircumflex = 0x0134;
  25668. t.Jecyrillic = 0x0408;
  25669. t.Jheharmenian = 0x054b;
  25670. t.Jmonospace = 0xff2a;
  25671. t.Jsmall = 0xf76a;
  25672. t.K = 0x004b;
  25673. t.KBsquare = 0x3385;
  25674. t.KKsquare = 0x33cd;
  25675. t.Kabashkircyrillic = 0x04a0;
  25676. t.Kacute = 0x1e30;
  25677. t.Kacyrillic = 0x041a;
  25678. t.Kadescendercyrillic = 0x049a;
  25679. t.Kahookcyrillic = 0x04c3;
  25680. t.Kappa = 0x039a;
  25681. t.Kastrokecyrillic = 0x049e;
  25682. t.Kaverticalstrokecyrillic = 0x049c;
  25683. t.Kcaron = 0x01e8;
  25684. t.Kcedilla = 0x0136;
  25685. t.Kcircle = 0x24c0;
  25686. t.Kcommaaccent = 0x0136;
  25687. t.Kdotbelow = 0x1e32;
  25688. t.Keharmenian = 0x0554;
  25689. t.Kenarmenian = 0x053f;
  25690. t.Khacyrillic = 0x0425;
  25691. t.Kheicoptic = 0x03e6;
  25692. t.Khook = 0x0198;
  25693. t.Kjecyrillic = 0x040c;
  25694. t.Klinebelow = 0x1e34;
  25695. t.Kmonospace = 0xff2b;
  25696. t.Koppacyrillic = 0x0480;
  25697. t.Koppagreek = 0x03de;
  25698. t.Ksicyrillic = 0x046e;
  25699. t.Ksmall = 0xf76b;
  25700. t.L = 0x004c;
  25701. t.LJ = 0x01c7;
  25702. t.LL = 0xf6bf;
  25703. t.Lacute = 0x0139;
  25704. t.Lambda = 0x039b;
  25705. t.Lcaron = 0x013d;
  25706. t.Lcedilla = 0x013b;
  25707. t.Lcircle = 0x24c1;
  25708. t.Lcircumflexbelow = 0x1e3c;
  25709. t.Lcommaaccent = 0x013b;
  25710. t.Ldot = 0x013f;
  25711. t.Ldotaccent = 0x013f;
  25712. t.Ldotbelow = 0x1e36;
  25713. t.Ldotbelowmacron = 0x1e38;
  25714. t.Liwnarmenian = 0x053c;
  25715. t.Lj = 0x01c8;
  25716. t.Ljecyrillic = 0x0409;
  25717. t.Llinebelow = 0x1e3a;
  25718. t.Lmonospace = 0xff2c;
  25719. t.Lslash = 0x0141;
  25720. t.Lslashsmall = 0xf6f9;
  25721. t.Lsmall = 0xf76c;
  25722. t.M = 0x004d;
  25723. t.MBsquare = 0x3386;
  25724. t.Macron = 0xf6d0;
  25725. t.Macronsmall = 0xf7af;
  25726. t.Macute = 0x1e3e;
  25727. t.Mcircle = 0x24c2;
  25728. t.Mdotaccent = 0x1e40;
  25729. t.Mdotbelow = 0x1e42;
  25730. t.Menarmenian = 0x0544;
  25731. t.Mmonospace = 0xff2d;
  25732. t.Msmall = 0xf76d;
  25733. t.Mturned = 0x019c;
  25734. t.Mu = 0x039c;
  25735. t.N = 0x004e;
  25736. t.NJ = 0x01ca;
  25737. t.Nacute = 0x0143;
  25738. t.Ncaron = 0x0147;
  25739. t.Ncedilla = 0x0145;
  25740. t.Ncircle = 0x24c3;
  25741. t.Ncircumflexbelow = 0x1e4a;
  25742. t.Ncommaaccent = 0x0145;
  25743. t.Ndotaccent = 0x1e44;
  25744. t.Ndotbelow = 0x1e46;
  25745. t.Nhookleft = 0x019d;
  25746. t.Nineroman = 0x2168;
  25747. t.Nj = 0x01cb;
  25748. t.Njecyrillic = 0x040a;
  25749. t.Nlinebelow = 0x1e48;
  25750. t.Nmonospace = 0xff2e;
  25751. t.Nowarmenian = 0x0546;
  25752. t.Nsmall = 0xf76e;
  25753. t.Ntilde = 0x00d1;
  25754. t.Ntildesmall = 0xf7f1;
  25755. t.Nu = 0x039d;
  25756. t.O = 0x004f;
  25757. t.OE = 0x0152;
  25758. t.OEsmall = 0xf6fa;
  25759. t.Oacute = 0x00d3;
  25760. t.Oacutesmall = 0xf7f3;
  25761. t.Obarredcyrillic = 0x04e8;
  25762. t.Obarreddieresiscyrillic = 0x04ea;
  25763. t.Obreve = 0x014e;
  25764. t.Ocaron = 0x01d1;
  25765. t.Ocenteredtilde = 0x019f;
  25766. t.Ocircle = 0x24c4;
  25767. t.Ocircumflex = 0x00d4;
  25768. t.Ocircumflexacute = 0x1ed0;
  25769. t.Ocircumflexdotbelow = 0x1ed8;
  25770. t.Ocircumflexgrave = 0x1ed2;
  25771. t.Ocircumflexhookabove = 0x1ed4;
  25772. t.Ocircumflexsmall = 0xf7f4;
  25773. t.Ocircumflextilde = 0x1ed6;
  25774. t.Ocyrillic = 0x041e;
  25775. t.Odblacute = 0x0150;
  25776. t.Odblgrave = 0x020c;
  25777. t.Odieresis = 0x00d6;
  25778. t.Odieresiscyrillic = 0x04e6;
  25779. t.Odieresissmall = 0xf7f6;
  25780. t.Odotbelow = 0x1ecc;
  25781. t.Ogoneksmall = 0xf6fb;
  25782. t.Ograve = 0x00d2;
  25783. t.Ogravesmall = 0xf7f2;
  25784. t.Oharmenian = 0x0555;
  25785. t.Ohm = 0x2126;
  25786. t.Ohookabove = 0x1ece;
  25787. t.Ohorn = 0x01a0;
  25788. t.Ohornacute = 0x1eda;
  25789. t.Ohorndotbelow = 0x1ee2;
  25790. t.Ohorngrave = 0x1edc;
  25791. t.Ohornhookabove = 0x1ede;
  25792. t.Ohorntilde = 0x1ee0;
  25793. t.Ohungarumlaut = 0x0150;
  25794. t.Oi = 0x01a2;
  25795. t.Oinvertedbreve = 0x020e;
  25796. t.Omacron = 0x014c;
  25797. t.Omacronacute = 0x1e52;
  25798. t.Omacrongrave = 0x1e50;
  25799. t.Omega = 0x2126;
  25800. t.Omegacyrillic = 0x0460;
  25801. t.Omegagreek = 0x03a9;
  25802. t.Omegaroundcyrillic = 0x047a;
  25803. t.Omegatitlocyrillic = 0x047c;
  25804. t.Omegatonos = 0x038f;
  25805. t.Omicron = 0x039f;
  25806. t.Omicrontonos = 0x038c;
  25807. t.Omonospace = 0xff2f;
  25808. t.Oneroman = 0x2160;
  25809. t.Oogonek = 0x01ea;
  25810. t.Oogonekmacron = 0x01ec;
  25811. t.Oopen = 0x0186;
  25812. t.Oslash = 0x00d8;
  25813. t.Oslashacute = 0x01fe;
  25814. t.Oslashsmall = 0xf7f8;
  25815. t.Osmall = 0xf76f;
  25816. t.Ostrokeacute = 0x01fe;
  25817. t.Otcyrillic = 0x047e;
  25818. t.Otilde = 0x00d5;
  25819. t.Otildeacute = 0x1e4c;
  25820. t.Otildedieresis = 0x1e4e;
  25821. t.Otildesmall = 0xf7f5;
  25822. t.P = 0x0050;
  25823. t.Pacute = 0x1e54;
  25824. t.Pcircle = 0x24c5;
  25825. t.Pdotaccent = 0x1e56;
  25826. t.Pecyrillic = 0x041f;
  25827. t.Peharmenian = 0x054a;
  25828. t.Pemiddlehookcyrillic = 0x04a6;
  25829. t.Phi = 0x03a6;
  25830. t.Phook = 0x01a4;
  25831. t.Pi = 0x03a0;
  25832. t.Piwrarmenian = 0x0553;
  25833. t.Pmonospace = 0xff30;
  25834. t.Psi = 0x03a8;
  25835. t.Psicyrillic = 0x0470;
  25836. t.Psmall = 0xf770;
  25837. t.Q = 0x0051;
  25838. t.Qcircle = 0x24c6;
  25839. t.Qmonospace = 0xff31;
  25840. t.Qsmall = 0xf771;
  25841. t.R = 0x0052;
  25842. t.Raarmenian = 0x054c;
  25843. t.Racute = 0x0154;
  25844. t.Rcaron = 0x0158;
  25845. t.Rcedilla = 0x0156;
  25846. t.Rcircle = 0x24c7;
  25847. t.Rcommaaccent = 0x0156;
  25848. t.Rdblgrave = 0x0210;
  25849. t.Rdotaccent = 0x1e58;
  25850. t.Rdotbelow = 0x1e5a;
  25851. t.Rdotbelowmacron = 0x1e5c;
  25852. t.Reharmenian = 0x0550;
  25853. t.Rfraktur = 0x211c;
  25854. t.Rho = 0x03a1;
  25855. t.Ringsmall = 0xf6fc;
  25856. t.Rinvertedbreve = 0x0212;
  25857. t.Rlinebelow = 0x1e5e;
  25858. t.Rmonospace = 0xff32;
  25859. t.Rsmall = 0xf772;
  25860. t.Rsmallinverted = 0x0281;
  25861. t.Rsmallinvertedsuperior = 0x02b6;
  25862. t.S = 0x0053;
  25863. t.SF010000 = 0x250c;
  25864. t.SF020000 = 0x2514;
  25865. t.SF030000 = 0x2510;
  25866. t.SF040000 = 0x2518;
  25867. t.SF050000 = 0x253c;
  25868. t.SF060000 = 0x252c;
  25869. t.SF070000 = 0x2534;
  25870. t.SF080000 = 0x251c;
  25871. t.SF090000 = 0x2524;
  25872. t.SF100000 = 0x2500;
  25873. t.SF110000 = 0x2502;
  25874. t.SF190000 = 0x2561;
  25875. t.SF200000 = 0x2562;
  25876. t.SF210000 = 0x2556;
  25877. t.SF220000 = 0x2555;
  25878. t.SF230000 = 0x2563;
  25879. t.SF240000 = 0x2551;
  25880. t.SF250000 = 0x2557;
  25881. t.SF260000 = 0x255d;
  25882. t.SF270000 = 0x255c;
  25883. t.SF280000 = 0x255b;
  25884. t.SF360000 = 0x255e;
  25885. t.SF370000 = 0x255f;
  25886. t.SF380000 = 0x255a;
  25887. t.SF390000 = 0x2554;
  25888. t.SF400000 = 0x2569;
  25889. t.SF410000 = 0x2566;
  25890. t.SF420000 = 0x2560;
  25891. t.SF430000 = 0x2550;
  25892. t.SF440000 = 0x256c;
  25893. t.SF450000 = 0x2567;
  25894. t.SF460000 = 0x2568;
  25895. t.SF470000 = 0x2564;
  25896. t.SF480000 = 0x2565;
  25897. t.SF490000 = 0x2559;
  25898. t.SF500000 = 0x2558;
  25899. t.SF510000 = 0x2552;
  25900. t.SF520000 = 0x2553;
  25901. t.SF530000 = 0x256b;
  25902. t.SF540000 = 0x256a;
  25903. t.Sacute = 0x015a;
  25904. t.Sacutedotaccent = 0x1e64;
  25905. t.Sampigreek = 0x03e0;
  25906. t.Scaron = 0x0160;
  25907. t.Scarondotaccent = 0x1e66;
  25908. t.Scaronsmall = 0xf6fd;
  25909. t.Scedilla = 0x015e;
  25910. t.Schwa = 0x018f;
  25911. t.Schwacyrillic = 0x04d8;
  25912. t.Schwadieresiscyrillic = 0x04da;
  25913. t.Scircle = 0x24c8;
  25914. t.Scircumflex = 0x015c;
  25915. t.Scommaaccent = 0x0218;
  25916. t.Sdotaccent = 0x1e60;
  25917. t.Sdotbelow = 0x1e62;
  25918. t.Sdotbelowdotaccent = 0x1e68;
  25919. t.Seharmenian = 0x054d;
  25920. t.Sevenroman = 0x2166;
  25921. t.Shaarmenian = 0x0547;
  25922. t.Shacyrillic = 0x0428;
  25923. t.Shchacyrillic = 0x0429;
  25924. t.Sheicoptic = 0x03e2;
  25925. t.Shhacyrillic = 0x04ba;
  25926. t.Shimacoptic = 0x03ec;
  25927. t.Sigma = 0x03a3;
  25928. t.Sixroman = 0x2165;
  25929. t.Smonospace = 0xff33;
  25930. t.Softsigncyrillic = 0x042c;
  25931. t.Ssmall = 0xf773;
  25932. t.Stigmagreek = 0x03da;
  25933. t.T = 0x0054;
  25934. t.Tau = 0x03a4;
  25935. t.Tbar = 0x0166;
  25936. t.Tcaron = 0x0164;
  25937. t.Tcedilla = 0x0162;
  25938. t.Tcircle = 0x24c9;
  25939. t.Tcircumflexbelow = 0x1e70;
  25940. t.Tcommaaccent = 0x0162;
  25941. t.Tdotaccent = 0x1e6a;
  25942. t.Tdotbelow = 0x1e6c;
  25943. t.Tecyrillic = 0x0422;
  25944. t.Tedescendercyrillic = 0x04ac;
  25945. t.Tenroman = 0x2169;
  25946. t.Tetsecyrillic = 0x04b4;
  25947. t.Theta = 0x0398;
  25948. t.Thook = 0x01ac;
  25949. t.Thorn = 0x00de;
  25950. t.Thornsmall = 0xf7fe;
  25951. t.Threeroman = 0x2162;
  25952. t.Tildesmall = 0xf6fe;
  25953. t.Tiwnarmenian = 0x054f;
  25954. t.Tlinebelow = 0x1e6e;
  25955. t.Tmonospace = 0xff34;
  25956. t.Toarmenian = 0x0539;
  25957. t.Tonefive = 0x01bc;
  25958. t.Tonesix = 0x0184;
  25959. t.Tonetwo = 0x01a7;
  25960. t.Tretroflexhook = 0x01ae;
  25961. t.Tsecyrillic = 0x0426;
  25962. t.Tshecyrillic = 0x040b;
  25963. t.Tsmall = 0xf774;
  25964. t.Twelveroman = 0x216b;
  25965. t.Tworoman = 0x2161;
  25966. t.U = 0x0055;
  25967. t.Uacute = 0x00da;
  25968. t.Uacutesmall = 0xf7fa;
  25969. t.Ubreve = 0x016c;
  25970. t.Ucaron = 0x01d3;
  25971. t.Ucircle = 0x24ca;
  25972. t.Ucircumflex = 0x00db;
  25973. t.Ucircumflexbelow = 0x1e76;
  25974. t.Ucircumflexsmall = 0xf7fb;
  25975. t.Ucyrillic = 0x0423;
  25976. t.Udblacute = 0x0170;
  25977. t.Udblgrave = 0x0214;
  25978. t.Udieresis = 0x00dc;
  25979. t.Udieresisacute = 0x01d7;
  25980. t.Udieresisbelow = 0x1e72;
  25981. t.Udieresiscaron = 0x01d9;
  25982. t.Udieresiscyrillic = 0x04f0;
  25983. t.Udieresisgrave = 0x01db;
  25984. t.Udieresismacron = 0x01d5;
  25985. t.Udieresissmall = 0xf7fc;
  25986. t.Udotbelow = 0x1ee4;
  25987. t.Ugrave = 0x00d9;
  25988. t.Ugravesmall = 0xf7f9;
  25989. t.Uhookabove = 0x1ee6;
  25990. t.Uhorn = 0x01af;
  25991. t.Uhornacute = 0x1ee8;
  25992. t.Uhorndotbelow = 0x1ef0;
  25993. t.Uhorngrave = 0x1eea;
  25994. t.Uhornhookabove = 0x1eec;
  25995. t.Uhorntilde = 0x1eee;
  25996. t.Uhungarumlaut = 0x0170;
  25997. t.Uhungarumlautcyrillic = 0x04f2;
  25998. t.Uinvertedbreve = 0x0216;
  25999. t.Ukcyrillic = 0x0478;
  26000. t.Umacron = 0x016a;
  26001. t.Umacroncyrillic = 0x04ee;
  26002. t.Umacrondieresis = 0x1e7a;
  26003. t.Umonospace = 0xff35;
  26004. t.Uogonek = 0x0172;
  26005. t.Upsilon = 0x03a5;
  26006. t.Upsilon1 = 0x03d2;
  26007. t.Upsilonacutehooksymbolgreek = 0x03d3;
  26008. t.Upsilonafrican = 0x01b1;
  26009. t.Upsilondieresis = 0x03ab;
  26010. t.Upsilondieresishooksymbolgreek = 0x03d4;
  26011. t.Upsilonhooksymbol = 0x03d2;
  26012. t.Upsilontonos = 0x038e;
  26013. t.Uring = 0x016e;
  26014. t.Ushortcyrillic = 0x040e;
  26015. t.Usmall = 0xf775;
  26016. t.Ustraightcyrillic = 0x04ae;
  26017. t.Ustraightstrokecyrillic = 0x04b0;
  26018. t.Utilde = 0x0168;
  26019. t.Utildeacute = 0x1e78;
  26020. t.Utildebelow = 0x1e74;
  26021. t.V = 0x0056;
  26022. t.Vcircle = 0x24cb;
  26023. t.Vdotbelow = 0x1e7e;
  26024. t.Vecyrillic = 0x0412;
  26025. t.Vewarmenian = 0x054e;
  26026. t.Vhook = 0x01b2;
  26027. t.Vmonospace = 0xff36;
  26028. t.Voarmenian = 0x0548;
  26029. t.Vsmall = 0xf776;
  26030. t.Vtilde = 0x1e7c;
  26031. t.W = 0x0057;
  26032. t.Wacute = 0x1e82;
  26033. t.Wcircle = 0x24cc;
  26034. t.Wcircumflex = 0x0174;
  26035. t.Wdieresis = 0x1e84;
  26036. t.Wdotaccent = 0x1e86;
  26037. t.Wdotbelow = 0x1e88;
  26038. t.Wgrave = 0x1e80;
  26039. t.Wmonospace = 0xff37;
  26040. t.Wsmall = 0xf777;
  26041. t.X = 0x0058;
  26042. t.Xcircle = 0x24cd;
  26043. t.Xdieresis = 0x1e8c;
  26044. t.Xdotaccent = 0x1e8a;
  26045. t.Xeharmenian = 0x053d;
  26046. t.Xi = 0x039e;
  26047. t.Xmonospace = 0xff38;
  26048. t.Xsmall = 0xf778;
  26049. t.Y = 0x0059;
  26050. t.Yacute = 0x00dd;
  26051. t.Yacutesmall = 0xf7fd;
  26052. t.Yatcyrillic = 0x0462;
  26053. t.Ycircle = 0x24ce;
  26054. t.Ycircumflex = 0x0176;
  26055. t.Ydieresis = 0x0178;
  26056. t.Ydieresissmall = 0xf7ff;
  26057. t.Ydotaccent = 0x1e8e;
  26058. t.Ydotbelow = 0x1ef4;
  26059. t.Yericyrillic = 0x042b;
  26060. t.Yerudieresiscyrillic = 0x04f8;
  26061. t.Ygrave = 0x1ef2;
  26062. t.Yhook = 0x01b3;
  26063. t.Yhookabove = 0x1ef6;
  26064. t.Yiarmenian = 0x0545;
  26065. t.Yicyrillic = 0x0407;
  26066. t.Yiwnarmenian = 0x0552;
  26067. t.Ymonospace = 0xff39;
  26068. t.Ysmall = 0xf779;
  26069. t.Ytilde = 0x1ef8;
  26070. t.Yusbigcyrillic = 0x046a;
  26071. t.Yusbigiotifiedcyrillic = 0x046c;
  26072. t.Yuslittlecyrillic = 0x0466;
  26073. t.Yuslittleiotifiedcyrillic = 0x0468;
  26074. t.Z = 0x005a;
  26075. t.Zaarmenian = 0x0536;
  26076. t.Zacute = 0x0179;
  26077. t.Zcaron = 0x017d;
  26078. t.Zcaronsmall = 0xf6ff;
  26079. t.Zcircle = 0x24cf;
  26080. t.Zcircumflex = 0x1e90;
  26081. t.Zdot = 0x017b;
  26082. t.Zdotaccent = 0x017b;
  26083. t.Zdotbelow = 0x1e92;
  26084. t.Zecyrillic = 0x0417;
  26085. t.Zedescendercyrillic = 0x0498;
  26086. t.Zedieresiscyrillic = 0x04de;
  26087. t.Zeta = 0x0396;
  26088. t.Zhearmenian = 0x053a;
  26089. t.Zhebrevecyrillic = 0x04c1;
  26090. t.Zhecyrillic = 0x0416;
  26091. t.Zhedescendercyrillic = 0x0496;
  26092. t.Zhedieresiscyrillic = 0x04dc;
  26093. t.Zlinebelow = 0x1e94;
  26094. t.Zmonospace = 0xff3a;
  26095. t.Zsmall = 0xf77a;
  26096. t.Zstroke = 0x01b5;
  26097. t.a = 0x0061;
  26098. t.aabengali = 0x0986;
  26099. t.aacute = 0x00e1;
  26100. t.aadeva = 0x0906;
  26101. t.aagujarati = 0x0a86;
  26102. t.aagurmukhi = 0x0a06;
  26103. t.aamatragurmukhi = 0x0a3e;
  26104. t.aarusquare = 0x3303;
  26105. t.aavowelsignbengali = 0x09be;
  26106. t.aavowelsigndeva = 0x093e;
  26107. t.aavowelsigngujarati = 0x0abe;
  26108. t.abbreviationmarkarmenian = 0x055f;
  26109. t.abbreviationsigndeva = 0x0970;
  26110. t.abengali = 0x0985;
  26111. t.abopomofo = 0x311a;
  26112. t.abreve = 0x0103;
  26113. t.abreveacute = 0x1eaf;
  26114. t.abrevecyrillic = 0x04d1;
  26115. t.abrevedotbelow = 0x1eb7;
  26116. t.abrevegrave = 0x1eb1;
  26117. t.abrevehookabove = 0x1eb3;
  26118. t.abrevetilde = 0x1eb5;
  26119. t.acaron = 0x01ce;
  26120. t.acircle = 0x24d0;
  26121. t.acircumflex = 0x00e2;
  26122. t.acircumflexacute = 0x1ea5;
  26123. t.acircumflexdotbelow = 0x1ead;
  26124. t.acircumflexgrave = 0x1ea7;
  26125. t.acircumflexhookabove = 0x1ea9;
  26126. t.acircumflextilde = 0x1eab;
  26127. t.acute = 0x00b4;
  26128. t.acutebelowcmb = 0x0317;
  26129. t.acutecmb = 0x0301;
  26130. t.acutecomb = 0x0301;
  26131. t.acutedeva = 0x0954;
  26132. t.acutelowmod = 0x02cf;
  26133. t.acutetonecmb = 0x0341;
  26134. t.acyrillic = 0x0430;
  26135. t.adblgrave = 0x0201;
  26136. t.addakgurmukhi = 0x0a71;
  26137. t.adeva = 0x0905;
  26138. t.adieresis = 0x00e4;
  26139. t.adieresiscyrillic = 0x04d3;
  26140. t.adieresismacron = 0x01df;
  26141. t.adotbelow = 0x1ea1;
  26142. t.adotmacron = 0x01e1;
  26143. t.ae = 0x00e6;
  26144. t.aeacute = 0x01fd;
  26145. t.aekorean = 0x3150;
  26146. t.aemacron = 0x01e3;
  26147. t.afii00208 = 0x2015;
  26148. t.afii08941 = 0x20a4;
  26149. t.afii10017 = 0x0410;
  26150. t.afii10018 = 0x0411;
  26151. t.afii10019 = 0x0412;
  26152. t.afii10020 = 0x0413;
  26153. t.afii10021 = 0x0414;
  26154. t.afii10022 = 0x0415;
  26155. t.afii10023 = 0x0401;
  26156. t.afii10024 = 0x0416;
  26157. t.afii10025 = 0x0417;
  26158. t.afii10026 = 0x0418;
  26159. t.afii10027 = 0x0419;
  26160. t.afii10028 = 0x041a;
  26161. t.afii10029 = 0x041b;
  26162. t.afii10030 = 0x041c;
  26163. t.afii10031 = 0x041d;
  26164. t.afii10032 = 0x041e;
  26165. t.afii10033 = 0x041f;
  26166. t.afii10034 = 0x0420;
  26167. t.afii10035 = 0x0421;
  26168. t.afii10036 = 0x0422;
  26169. t.afii10037 = 0x0423;
  26170. t.afii10038 = 0x0424;
  26171. t.afii10039 = 0x0425;
  26172. t.afii10040 = 0x0426;
  26173. t.afii10041 = 0x0427;
  26174. t.afii10042 = 0x0428;
  26175. t.afii10043 = 0x0429;
  26176. t.afii10044 = 0x042a;
  26177. t.afii10045 = 0x042b;
  26178. t.afii10046 = 0x042c;
  26179. t.afii10047 = 0x042d;
  26180. t.afii10048 = 0x042e;
  26181. t.afii10049 = 0x042f;
  26182. t.afii10050 = 0x0490;
  26183. t.afii10051 = 0x0402;
  26184. t.afii10052 = 0x0403;
  26185. t.afii10053 = 0x0404;
  26186. t.afii10054 = 0x0405;
  26187. t.afii10055 = 0x0406;
  26188. t.afii10056 = 0x0407;
  26189. t.afii10057 = 0x0408;
  26190. t.afii10058 = 0x0409;
  26191. t.afii10059 = 0x040a;
  26192. t.afii10060 = 0x040b;
  26193. t.afii10061 = 0x040c;
  26194. t.afii10062 = 0x040e;
  26195. t.afii10063 = 0xf6c4;
  26196. t.afii10064 = 0xf6c5;
  26197. t.afii10065 = 0x0430;
  26198. t.afii10066 = 0x0431;
  26199. t.afii10067 = 0x0432;
  26200. t.afii10068 = 0x0433;
  26201. t.afii10069 = 0x0434;
  26202. t.afii10070 = 0x0435;
  26203. t.afii10071 = 0x0451;
  26204. t.afii10072 = 0x0436;
  26205. t.afii10073 = 0x0437;
  26206. t.afii10074 = 0x0438;
  26207. t.afii10075 = 0x0439;
  26208. t.afii10076 = 0x043a;
  26209. t.afii10077 = 0x043b;
  26210. t.afii10078 = 0x043c;
  26211. t.afii10079 = 0x043d;
  26212. t.afii10080 = 0x043e;
  26213. t.afii10081 = 0x043f;
  26214. t.afii10082 = 0x0440;
  26215. t.afii10083 = 0x0441;
  26216. t.afii10084 = 0x0442;
  26217. t.afii10085 = 0x0443;
  26218. t.afii10086 = 0x0444;
  26219. t.afii10087 = 0x0445;
  26220. t.afii10088 = 0x0446;
  26221. t.afii10089 = 0x0447;
  26222. t.afii10090 = 0x0448;
  26223. t.afii10091 = 0x0449;
  26224. t.afii10092 = 0x044a;
  26225. t.afii10093 = 0x044b;
  26226. t.afii10094 = 0x044c;
  26227. t.afii10095 = 0x044d;
  26228. t.afii10096 = 0x044e;
  26229. t.afii10097 = 0x044f;
  26230. t.afii10098 = 0x0491;
  26231. t.afii10099 = 0x0452;
  26232. t.afii10100 = 0x0453;
  26233. t.afii10101 = 0x0454;
  26234. t.afii10102 = 0x0455;
  26235. t.afii10103 = 0x0456;
  26236. t.afii10104 = 0x0457;
  26237. t.afii10105 = 0x0458;
  26238. t.afii10106 = 0x0459;
  26239. t.afii10107 = 0x045a;
  26240. t.afii10108 = 0x045b;
  26241. t.afii10109 = 0x045c;
  26242. t.afii10110 = 0x045e;
  26243. t.afii10145 = 0x040f;
  26244. t.afii10146 = 0x0462;
  26245. t.afii10147 = 0x0472;
  26246. t.afii10148 = 0x0474;
  26247. t.afii10192 = 0xf6c6;
  26248. t.afii10193 = 0x045f;
  26249. t.afii10194 = 0x0463;
  26250. t.afii10195 = 0x0473;
  26251. t.afii10196 = 0x0475;
  26252. t.afii10831 = 0xf6c7;
  26253. t.afii10832 = 0xf6c8;
  26254. t.afii10846 = 0x04d9;
  26255. t.afii299 = 0x200e;
  26256. t.afii300 = 0x200f;
  26257. t.afii301 = 0x200d;
  26258. t.afii57381 = 0x066a;
  26259. t.afii57388 = 0x060c;
  26260. t.afii57392 = 0x0660;
  26261. t.afii57393 = 0x0661;
  26262. t.afii57394 = 0x0662;
  26263. t.afii57395 = 0x0663;
  26264. t.afii57396 = 0x0664;
  26265. t.afii57397 = 0x0665;
  26266. t.afii57398 = 0x0666;
  26267. t.afii57399 = 0x0667;
  26268. t.afii57400 = 0x0668;
  26269. t.afii57401 = 0x0669;
  26270. t.afii57403 = 0x061b;
  26271. t.afii57407 = 0x061f;
  26272. t.afii57409 = 0x0621;
  26273. t.afii57410 = 0x0622;
  26274. t.afii57411 = 0x0623;
  26275. t.afii57412 = 0x0624;
  26276. t.afii57413 = 0x0625;
  26277. t.afii57414 = 0x0626;
  26278. t.afii57415 = 0x0627;
  26279. t.afii57416 = 0x0628;
  26280. t.afii57417 = 0x0629;
  26281. t.afii57418 = 0x062a;
  26282. t.afii57419 = 0x062b;
  26283. t.afii57420 = 0x062c;
  26284. t.afii57421 = 0x062d;
  26285. t.afii57422 = 0x062e;
  26286. t.afii57423 = 0x062f;
  26287. t.afii57424 = 0x0630;
  26288. t.afii57425 = 0x0631;
  26289. t.afii57426 = 0x0632;
  26290. t.afii57427 = 0x0633;
  26291. t.afii57428 = 0x0634;
  26292. t.afii57429 = 0x0635;
  26293. t.afii57430 = 0x0636;
  26294. t.afii57431 = 0x0637;
  26295. t.afii57432 = 0x0638;
  26296. t.afii57433 = 0x0639;
  26297. t.afii57434 = 0x063a;
  26298. t.afii57440 = 0x0640;
  26299. t.afii57441 = 0x0641;
  26300. t.afii57442 = 0x0642;
  26301. t.afii57443 = 0x0643;
  26302. t.afii57444 = 0x0644;
  26303. t.afii57445 = 0x0645;
  26304. t.afii57446 = 0x0646;
  26305. t.afii57448 = 0x0648;
  26306. t.afii57449 = 0x0649;
  26307. t.afii57450 = 0x064a;
  26308. t.afii57451 = 0x064b;
  26309. t.afii57452 = 0x064c;
  26310. t.afii57453 = 0x064d;
  26311. t.afii57454 = 0x064e;
  26312. t.afii57455 = 0x064f;
  26313. t.afii57456 = 0x0650;
  26314. t.afii57457 = 0x0651;
  26315. t.afii57458 = 0x0652;
  26316. t.afii57470 = 0x0647;
  26317. t.afii57505 = 0x06a4;
  26318. t.afii57506 = 0x067e;
  26319. t.afii57507 = 0x0686;
  26320. t.afii57508 = 0x0698;
  26321. t.afii57509 = 0x06af;
  26322. t.afii57511 = 0x0679;
  26323. t.afii57512 = 0x0688;
  26324. t.afii57513 = 0x0691;
  26325. t.afii57514 = 0x06ba;
  26326. t.afii57519 = 0x06d2;
  26327. t.afii57534 = 0x06d5;
  26328. t.afii57636 = 0x20aa;
  26329. t.afii57645 = 0x05be;
  26330. t.afii57658 = 0x05c3;
  26331. t.afii57664 = 0x05d0;
  26332. t.afii57665 = 0x05d1;
  26333. t.afii57666 = 0x05d2;
  26334. t.afii57667 = 0x05d3;
  26335. t.afii57668 = 0x05d4;
  26336. t.afii57669 = 0x05d5;
  26337. t.afii57670 = 0x05d6;
  26338. t.afii57671 = 0x05d7;
  26339. t.afii57672 = 0x05d8;
  26340. t.afii57673 = 0x05d9;
  26341. t.afii57674 = 0x05da;
  26342. t.afii57675 = 0x05db;
  26343. t.afii57676 = 0x05dc;
  26344. t.afii57677 = 0x05dd;
  26345. t.afii57678 = 0x05de;
  26346. t.afii57679 = 0x05df;
  26347. t.afii57680 = 0x05e0;
  26348. t.afii57681 = 0x05e1;
  26349. t.afii57682 = 0x05e2;
  26350. t.afii57683 = 0x05e3;
  26351. t.afii57684 = 0x05e4;
  26352. t.afii57685 = 0x05e5;
  26353. t.afii57686 = 0x05e6;
  26354. t.afii57687 = 0x05e7;
  26355. t.afii57688 = 0x05e8;
  26356. t.afii57689 = 0x05e9;
  26357. t.afii57690 = 0x05ea;
  26358. t.afii57694 = 0xfb2a;
  26359. t.afii57695 = 0xfb2b;
  26360. t.afii57700 = 0xfb4b;
  26361. t.afii57705 = 0xfb1f;
  26362. t.afii57716 = 0x05f0;
  26363. t.afii57717 = 0x05f1;
  26364. t.afii57718 = 0x05f2;
  26365. t.afii57723 = 0xfb35;
  26366. t.afii57793 = 0x05b4;
  26367. t.afii57794 = 0x05b5;
  26368. t.afii57795 = 0x05b6;
  26369. t.afii57796 = 0x05bb;
  26370. t.afii57797 = 0x05b8;
  26371. t.afii57798 = 0x05b7;
  26372. t.afii57799 = 0x05b0;
  26373. t.afii57800 = 0x05b2;
  26374. t.afii57801 = 0x05b1;
  26375. t.afii57802 = 0x05b3;
  26376. t.afii57803 = 0x05c2;
  26377. t.afii57804 = 0x05c1;
  26378. t.afii57806 = 0x05b9;
  26379. t.afii57807 = 0x05bc;
  26380. t.afii57839 = 0x05bd;
  26381. t.afii57841 = 0x05bf;
  26382. t.afii57842 = 0x05c0;
  26383. t.afii57929 = 0x02bc;
  26384. t.afii61248 = 0x2105;
  26385. t.afii61289 = 0x2113;
  26386. t.afii61352 = 0x2116;
  26387. t.afii61573 = 0x202c;
  26388. t.afii61574 = 0x202d;
  26389. t.afii61575 = 0x202e;
  26390. t.afii61664 = 0x200c;
  26391. t.afii63167 = 0x066d;
  26392. t.afii64937 = 0x02bd;
  26393. t.agrave = 0x00e0;
  26394. t.agujarati = 0x0a85;
  26395. t.agurmukhi = 0x0a05;
  26396. t.ahiragana = 0x3042;
  26397. t.ahookabove = 0x1ea3;
  26398. t.aibengali = 0x0990;
  26399. t.aibopomofo = 0x311e;
  26400. t.aideva = 0x0910;
  26401. t.aiecyrillic = 0x04d5;
  26402. t.aigujarati = 0x0a90;
  26403. t.aigurmukhi = 0x0a10;
  26404. t.aimatragurmukhi = 0x0a48;
  26405. t.ainarabic = 0x0639;
  26406. t.ainfinalarabic = 0xfeca;
  26407. t.aininitialarabic = 0xfecb;
  26408. t.ainmedialarabic = 0xfecc;
  26409. t.ainvertedbreve = 0x0203;
  26410. t.aivowelsignbengali = 0x09c8;
  26411. t.aivowelsigndeva = 0x0948;
  26412. t.aivowelsigngujarati = 0x0ac8;
  26413. t.akatakana = 0x30a2;
  26414. t.akatakanahalfwidth = 0xff71;
  26415. t.akorean = 0x314f;
  26416. t.alef = 0x05d0;
  26417. t.alefarabic = 0x0627;
  26418. t.alefdageshhebrew = 0xfb30;
  26419. t.aleffinalarabic = 0xfe8e;
  26420. t.alefhamzaabovearabic = 0x0623;
  26421. t.alefhamzaabovefinalarabic = 0xfe84;
  26422. t.alefhamzabelowarabic = 0x0625;
  26423. t.alefhamzabelowfinalarabic = 0xfe88;
  26424. t.alefhebrew = 0x05d0;
  26425. t.aleflamedhebrew = 0xfb4f;
  26426. t.alefmaddaabovearabic = 0x0622;
  26427. t.alefmaddaabovefinalarabic = 0xfe82;
  26428. t.alefmaksuraarabic = 0x0649;
  26429. t.alefmaksurafinalarabic = 0xfef0;
  26430. t.alefmaksurainitialarabic = 0xfef3;
  26431. t.alefmaksuramedialarabic = 0xfef4;
  26432. t.alefpatahhebrew = 0xfb2e;
  26433. t.alefqamatshebrew = 0xfb2f;
  26434. t.aleph = 0x2135;
  26435. t.allequal = 0x224c;
  26436. t.alpha = 0x03b1;
  26437. t.alphatonos = 0x03ac;
  26438. t.amacron = 0x0101;
  26439. t.amonospace = 0xff41;
  26440. t.ampersand = 0x0026;
  26441. t.ampersandmonospace = 0xff06;
  26442. t.ampersandsmall = 0xf726;
  26443. t.amsquare = 0x33c2;
  26444. t.anbopomofo = 0x3122;
  26445. t.angbopomofo = 0x3124;
  26446. t.angbracketleft = 0x3008;
  26447. t.angbracketright = 0x3009;
  26448. t.angkhankhuthai = 0x0e5a;
  26449. t.angle = 0x2220;
  26450. t.anglebracketleft = 0x3008;
  26451. t.anglebracketleftvertical = 0xfe3f;
  26452. t.anglebracketright = 0x3009;
  26453. t.anglebracketrightvertical = 0xfe40;
  26454. t.angleleft = 0x2329;
  26455. t.angleright = 0x232a;
  26456. t.angstrom = 0x212b;
  26457. t.anoteleia = 0x0387;
  26458. t.anudattadeva = 0x0952;
  26459. t.anusvarabengali = 0x0982;
  26460. t.anusvaradeva = 0x0902;
  26461. t.anusvaragujarati = 0x0a82;
  26462. t.aogonek = 0x0105;
  26463. t.apaatosquare = 0x3300;
  26464. t.aparen = 0x249c;
  26465. t.apostrophearmenian = 0x055a;
  26466. t.apostrophemod = 0x02bc;
  26467. t.apple = 0xf8ff;
  26468. t.approaches = 0x2250;
  26469. t.approxequal = 0x2248;
  26470. t.approxequalorimage = 0x2252;
  26471. t.approximatelyequal = 0x2245;
  26472. t.araeaekorean = 0x318e;
  26473. t.araeakorean = 0x318d;
  26474. t.arc = 0x2312;
  26475. t.arighthalfring = 0x1e9a;
  26476. t.aring = 0x00e5;
  26477. t.aringacute = 0x01fb;
  26478. t.aringbelow = 0x1e01;
  26479. t.arrowboth = 0x2194;
  26480. t.arrowdashdown = 0x21e3;
  26481. t.arrowdashleft = 0x21e0;
  26482. t.arrowdashright = 0x21e2;
  26483. t.arrowdashup = 0x21e1;
  26484. t.arrowdblboth = 0x21d4;
  26485. t.arrowdbldown = 0x21d3;
  26486. t.arrowdblleft = 0x21d0;
  26487. t.arrowdblright = 0x21d2;
  26488. t.arrowdblup = 0x21d1;
  26489. t.arrowdown = 0x2193;
  26490. t.arrowdownleft = 0x2199;
  26491. t.arrowdownright = 0x2198;
  26492. t.arrowdownwhite = 0x21e9;
  26493. t.arrowheaddownmod = 0x02c5;
  26494. t.arrowheadleftmod = 0x02c2;
  26495. t.arrowheadrightmod = 0x02c3;
  26496. t.arrowheadupmod = 0x02c4;
  26497. t.arrowhorizex = 0xf8e7;
  26498. t.arrowleft = 0x2190;
  26499. t.arrowleftdbl = 0x21d0;
  26500. t.arrowleftdblstroke = 0x21cd;
  26501. t.arrowleftoverright = 0x21c6;
  26502. t.arrowleftwhite = 0x21e6;
  26503. t.arrowright = 0x2192;
  26504. t.arrowrightdblstroke = 0x21cf;
  26505. t.arrowrightheavy = 0x279e;
  26506. t.arrowrightoverleft = 0x21c4;
  26507. t.arrowrightwhite = 0x21e8;
  26508. t.arrowtableft = 0x21e4;
  26509. t.arrowtabright = 0x21e5;
  26510. t.arrowup = 0x2191;
  26511. t.arrowupdn = 0x2195;
  26512. t.arrowupdnbse = 0x21a8;
  26513. t.arrowupdownbase = 0x21a8;
  26514. t.arrowupleft = 0x2196;
  26515. t.arrowupleftofdown = 0x21c5;
  26516. t.arrowupright = 0x2197;
  26517. t.arrowupwhite = 0x21e7;
  26518. t.arrowvertex = 0xf8e6;
  26519. t.asciicircum = 0x005e;
  26520. t.asciicircummonospace = 0xff3e;
  26521. t.asciitilde = 0x007e;
  26522. t.asciitildemonospace = 0xff5e;
  26523. t.ascript = 0x0251;
  26524. t.ascriptturned = 0x0252;
  26525. t.asmallhiragana = 0x3041;
  26526. t.asmallkatakana = 0x30a1;
  26527. t.asmallkatakanahalfwidth = 0xff67;
  26528. t.asterisk = 0x002a;
  26529. t.asteriskaltonearabic = 0x066d;
  26530. t.asteriskarabic = 0x066d;
  26531. t.asteriskmath = 0x2217;
  26532. t.asteriskmonospace = 0xff0a;
  26533. t.asterisksmall = 0xfe61;
  26534. t.asterism = 0x2042;
  26535. t.asuperior = 0xf6e9;
  26536. t.asymptoticallyequal = 0x2243;
  26537. t.at = 0x0040;
  26538. t.atilde = 0x00e3;
  26539. t.atmonospace = 0xff20;
  26540. t.atsmall = 0xfe6b;
  26541. t.aturned = 0x0250;
  26542. t.aubengali = 0x0994;
  26543. t.aubopomofo = 0x3120;
  26544. t.audeva = 0x0914;
  26545. t.augujarati = 0x0a94;
  26546. t.augurmukhi = 0x0a14;
  26547. t.aulengthmarkbengali = 0x09d7;
  26548. t.aumatragurmukhi = 0x0a4c;
  26549. t.auvowelsignbengali = 0x09cc;
  26550. t.auvowelsigndeva = 0x094c;
  26551. t.auvowelsigngujarati = 0x0acc;
  26552. t.avagrahadeva = 0x093d;
  26553. t.aybarmenian = 0x0561;
  26554. t.ayin = 0x05e2;
  26555. t.ayinaltonehebrew = 0xfb20;
  26556. t.ayinhebrew = 0x05e2;
  26557. t.b = 0x0062;
  26558. t.babengali = 0x09ac;
  26559. t.backslash = 0x005c;
  26560. t.backslashmonospace = 0xff3c;
  26561. t.badeva = 0x092c;
  26562. t.bagujarati = 0x0aac;
  26563. t.bagurmukhi = 0x0a2c;
  26564. t.bahiragana = 0x3070;
  26565. t.bahtthai = 0x0e3f;
  26566. t.bakatakana = 0x30d0;
  26567. t.bar = 0x007c;
  26568. t.barmonospace = 0xff5c;
  26569. t.bbopomofo = 0x3105;
  26570. t.bcircle = 0x24d1;
  26571. t.bdotaccent = 0x1e03;
  26572. t.bdotbelow = 0x1e05;
  26573. t.beamedsixteenthnotes = 0x266c;
  26574. t.because = 0x2235;
  26575. t.becyrillic = 0x0431;
  26576. t.beharabic = 0x0628;
  26577. t.behfinalarabic = 0xfe90;
  26578. t.behinitialarabic = 0xfe91;
  26579. t.behiragana = 0x3079;
  26580. t.behmedialarabic = 0xfe92;
  26581. t.behmeeminitialarabic = 0xfc9f;
  26582. t.behmeemisolatedarabic = 0xfc08;
  26583. t.behnoonfinalarabic = 0xfc6d;
  26584. t.bekatakana = 0x30d9;
  26585. t.benarmenian = 0x0562;
  26586. t.bet = 0x05d1;
  26587. t.beta = 0x03b2;
  26588. t.betasymbolgreek = 0x03d0;
  26589. t.betdagesh = 0xfb31;
  26590. t.betdageshhebrew = 0xfb31;
  26591. t.bethebrew = 0x05d1;
  26592. t.betrafehebrew = 0xfb4c;
  26593. t.bhabengali = 0x09ad;
  26594. t.bhadeva = 0x092d;
  26595. t.bhagujarati = 0x0aad;
  26596. t.bhagurmukhi = 0x0a2d;
  26597. t.bhook = 0x0253;
  26598. t.bihiragana = 0x3073;
  26599. t.bikatakana = 0x30d3;
  26600. t.bilabialclick = 0x0298;
  26601. t.bindigurmukhi = 0x0a02;
  26602. t.birusquare = 0x3331;
  26603. t.blackcircle = 0x25cf;
  26604. t.blackdiamond = 0x25c6;
  26605. t.blackdownpointingtriangle = 0x25bc;
  26606. t.blackleftpointingpointer = 0x25c4;
  26607. t.blackleftpointingtriangle = 0x25c0;
  26608. t.blacklenticularbracketleft = 0x3010;
  26609. t.blacklenticularbracketleftvertical = 0xfe3b;
  26610. t.blacklenticularbracketright = 0x3011;
  26611. t.blacklenticularbracketrightvertical = 0xfe3c;
  26612. t.blacklowerlefttriangle = 0x25e3;
  26613. t.blacklowerrighttriangle = 0x25e2;
  26614. t.blackrectangle = 0x25ac;
  26615. t.blackrightpointingpointer = 0x25ba;
  26616. t.blackrightpointingtriangle = 0x25b6;
  26617. t.blacksmallsquare = 0x25aa;
  26618. t.blacksmilingface = 0x263b;
  26619. t.blacksquare = 0x25a0;
  26620. t.blackstar = 0x2605;
  26621. t.blackupperlefttriangle = 0x25e4;
  26622. t.blackupperrighttriangle = 0x25e5;
  26623. t.blackuppointingsmalltriangle = 0x25b4;
  26624. t.blackuppointingtriangle = 0x25b2;
  26625. t.blank = 0x2423;
  26626. t.blinebelow = 0x1e07;
  26627. t.block = 0x2588;
  26628. t.bmonospace = 0xff42;
  26629. t.bobaimaithai = 0x0e1a;
  26630. t.bohiragana = 0x307c;
  26631. t.bokatakana = 0x30dc;
  26632. t.bparen = 0x249d;
  26633. t.bqsquare = 0x33c3;
  26634. t.braceex = 0xf8f4;
  26635. t.braceleft = 0x007b;
  26636. t.braceleftbt = 0xf8f3;
  26637. t.braceleftmid = 0xf8f2;
  26638. t.braceleftmonospace = 0xff5b;
  26639. t.braceleftsmall = 0xfe5b;
  26640. t.bracelefttp = 0xf8f1;
  26641. t.braceleftvertical = 0xfe37;
  26642. t.braceright = 0x007d;
  26643. t.bracerightbt = 0xf8fe;
  26644. t.bracerightmid = 0xf8fd;
  26645. t.bracerightmonospace = 0xff5d;
  26646. t.bracerightsmall = 0xfe5c;
  26647. t.bracerighttp = 0xf8fc;
  26648. t.bracerightvertical = 0xfe38;
  26649. t.bracketleft = 0x005b;
  26650. t.bracketleftbt = 0xf8f0;
  26651. t.bracketleftex = 0xf8ef;
  26652. t.bracketleftmonospace = 0xff3b;
  26653. t.bracketlefttp = 0xf8ee;
  26654. t.bracketright = 0x005d;
  26655. t.bracketrightbt = 0xf8fb;
  26656. t.bracketrightex = 0xf8fa;
  26657. t.bracketrightmonospace = 0xff3d;
  26658. t.bracketrighttp = 0xf8f9;
  26659. t.breve = 0x02d8;
  26660. t.brevebelowcmb = 0x032e;
  26661. t.brevecmb = 0x0306;
  26662. t.breveinvertedbelowcmb = 0x032f;
  26663. t.breveinvertedcmb = 0x0311;
  26664. t.breveinverteddoublecmb = 0x0361;
  26665. t.bridgebelowcmb = 0x032a;
  26666. t.bridgeinvertedbelowcmb = 0x033a;
  26667. t.brokenbar = 0x00a6;
  26668. t.bstroke = 0x0180;
  26669. t.bsuperior = 0xf6ea;
  26670. t.btopbar = 0x0183;
  26671. t.buhiragana = 0x3076;
  26672. t.bukatakana = 0x30d6;
  26673. t.bullet = 0x2022;
  26674. t.bulletinverse = 0x25d8;
  26675. t.bulletoperator = 0x2219;
  26676. t.bullseye = 0x25ce;
  26677. t.c = 0x0063;
  26678. t.caarmenian = 0x056e;
  26679. t.cabengali = 0x099a;
  26680. t.cacute = 0x0107;
  26681. t.cadeva = 0x091a;
  26682. t.cagujarati = 0x0a9a;
  26683. t.cagurmukhi = 0x0a1a;
  26684. t.calsquare = 0x3388;
  26685. t.candrabindubengali = 0x0981;
  26686. t.candrabinducmb = 0x0310;
  26687. t.candrabindudeva = 0x0901;
  26688. t.candrabindugujarati = 0x0a81;
  26689. t.capslock = 0x21ea;
  26690. t.careof = 0x2105;
  26691. t.caron = 0x02c7;
  26692. t.caronbelowcmb = 0x032c;
  26693. t.caroncmb = 0x030c;
  26694. t.carriagereturn = 0x21b5;
  26695. t.cbopomofo = 0x3118;
  26696. t.ccaron = 0x010d;
  26697. t.ccedilla = 0x00e7;
  26698. t.ccedillaacute = 0x1e09;
  26699. t.ccircle = 0x24d2;
  26700. t.ccircumflex = 0x0109;
  26701. t.ccurl = 0x0255;
  26702. t.cdot = 0x010b;
  26703. t.cdotaccent = 0x010b;
  26704. t.cdsquare = 0x33c5;
  26705. t.cedilla = 0x00b8;
  26706. t.cedillacmb = 0x0327;
  26707. t.cent = 0x00a2;
  26708. t.centigrade = 0x2103;
  26709. t.centinferior = 0xf6df;
  26710. t.centmonospace = 0xffe0;
  26711. t.centoldstyle = 0xf7a2;
  26712. t.centsuperior = 0xf6e0;
  26713. t.chaarmenian = 0x0579;
  26714. t.chabengali = 0x099b;
  26715. t.chadeva = 0x091b;
  26716. t.chagujarati = 0x0a9b;
  26717. t.chagurmukhi = 0x0a1b;
  26718. t.chbopomofo = 0x3114;
  26719. t.cheabkhasiancyrillic = 0x04bd;
  26720. t.checkmark = 0x2713;
  26721. t.checyrillic = 0x0447;
  26722. t.chedescenderabkhasiancyrillic = 0x04bf;
  26723. t.chedescendercyrillic = 0x04b7;
  26724. t.chedieresiscyrillic = 0x04f5;
  26725. t.cheharmenian = 0x0573;
  26726. t.chekhakassiancyrillic = 0x04cc;
  26727. t.cheverticalstrokecyrillic = 0x04b9;
  26728. t.chi = 0x03c7;
  26729. t.chieuchacirclekorean = 0x3277;
  26730. t.chieuchaparenkorean = 0x3217;
  26731. t.chieuchcirclekorean = 0x3269;
  26732. t.chieuchkorean = 0x314a;
  26733. t.chieuchparenkorean = 0x3209;
  26734. t.chochangthai = 0x0e0a;
  26735. t.chochanthai = 0x0e08;
  26736. t.chochingthai = 0x0e09;
  26737. t.chochoethai = 0x0e0c;
  26738. t.chook = 0x0188;
  26739. t.cieucacirclekorean = 0x3276;
  26740. t.cieucaparenkorean = 0x3216;
  26741. t.cieuccirclekorean = 0x3268;
  26742. t.cieuckorean = 0x3148;
  26743. t.cieucparenkorean = 0x3208;
  26744. t.cieucuparenkorean = 0x321c;
  26745. t.circle = 0x25cb;
  26746. t.circlecopyrt = 0x00a9;
  26747. t.circlemultiply = 0x2297;
  26748. t.circleot = 0x2299;
  26749. t.circleplus = 0x2295;
  26750. t.circlepostalmark = 0x3036;
  26751. t.circlewithlefthalfblack = 0x25d0;
  26752. t.circlewithrighthalfblack = 0x25d1;
  26753. t.circumflex = 0x02c6;
  26754. t.circumflexbelowcmb = 0x032d;
  26755. t.circumflexcmb = 0x0302;
  26756. t.clear = 0x2327;
  26757. t.clickalveolar = 0x01c2;
  26758. t.clickdental = 0x01c0;
  26759. t.clicklateral = 0x01c1;
  26760. t.clickretroflex = 0x01c3;
  26761. t.club = 0x2663;
  26762. t.clubsuitblack = 0x2663;
  26763. t.clubsuitwhite = 0x2667;
  26764. t.cmcubedsquare = 0x33a4;
  26765. t.cmonospace = 0xff43;
  26766. t.cmsquaredsquare = 0x33a0;
  26767. t.coarmenian = 0x0581;
  26768. t.colon = 0x003a;
  26769. t.colonmonetary = 0x20a1;
  26770. t.colonmonospace = 0xff1a;
  26771. t.colonsign = 0x20a1;
  26772. t.colonsmall = 0xfe55;
  26773. t.colontriangularhalfmod = 0x02d1;
  26774. t.colontriangularmod = 0x02d0;
  26775. t.comma = 0x002c;
  26776. t.commaabovecmb = 0x0313;
  26777. t.commaaboverightcmb = 0x0315;
  26778. t.commaaccent = 0xf6c3;
  26779. t.commaarabic = 0x060c;
  26780. t.commaarmenian = 0x055d;
  26781. t.commainferior = 0xf6e1;
  26782. t.commamonospace = 0xff0c;
  26783. t.commareversedabovecmb = 0x0314;
  26784. t.commareversedmod = 0x02bd;
  26785. t.commasmall = 0xfe50;
  26786. t.commasuperior = 0xf6e2;
  26787. t.commaturnedabovecmb = 0x0312;
  26788. t.commaturnedmod = 0x02bb;
  26789. t.compass = 0x263c;
  26790. t.congruent = 0x2245;
  26791. t.contourintegral = 0x222e;
  26792. t.control = 0x2303;
  26793. t.controlACK = 0x0006;
  26794. t.controlBEL = 0x0007;
  26795. t.controlBS = 0x0008;
  26796. t.controlCAN = 0x0018;
  26797. t.controlCR = 0x000d;
  26798. t.controlDC1 = 0x0011;
  26799. t.controlDC2 = 0x0012;
  26800. t.controlDC3 = 0x0013;
  26801. t.controlDC4 = 0x0014;
  26802. t.controlDEL = 0x007f;
  26803. t.controlDLE = 0x0010;
  26804. t.controlEM = 0x0019;
  26805. t.controlENQ = 0x0005;
  26806. t.controlEOT = 0x0004;
  26807. t.controlESC = 0x001b;
  26808. t.controlETB = 0x0017;
  26809. t.controlETX = 0x0003;
  26810. t.controlFF = 0x000c;
  26811. t.controlFS = 0x001c;
  26812. t.controlGS = 0x001d;
  26813. t.controlHT = 0x0009;
  26814. t.controlLF = 0x000a;
  26815. t.controlNAK = 0x0015;
  26816. t.controlNULL = 0x0000;
  26817. t.controlRS = 0x001e;
  26818. t.controlSI = 0x000f;
  26819. t.controlSO = 0x000e;
  26820. t.controlSOT = 0x0002;
  26821. t.controlSTX = 0x0001;
  26822. t.controlSUB = 0x001a;
  26823. t.controlSYN = 0x0016;
  26824. t.controlUS = 0x001f;
  26825. t.controlVT = 0x000b;
  26826. t.copyright = 0x00a9;
  26827. t.copyrightsans = 0xf8e9;
  26828. t.copyrightserif = 0xf6d9;
  26829. t.cornerbracketleft = 0x300c;
  26830. t.cornerbracketlefthalfwidth = 0xff62;
  26831. t.cornerbracketleftvertical = 0xfe41;
  26832. t.cornerbracketright = 0x300d;
  26833. t.cornerbracketrighthalfwidth = 0xff63;
  26834. t.cornerbracketrightvertical = 0xfe42;
  26835. t.corporationsquare = 0x337f;
  26836. t.cosquare = 0x33c7;
  26837. t.coverkgsquare = 0x33c6;
  26838. t.cparen = 0x249e;
  26839. t.cruzeiro = 0x20a2;
  26840. t.cstretched = 0x0297;
  26841. t.curlyand = 0x22cf;
  26842. t.curlyor = 0x22ce;
  26843. t.currency = 0x00a4;
  26844. t.cyrBreve = 0xf6d1;
  26845. t.cyrFlex = 0xf6d2;
  26846. t.cyrbreve = 0xf6d4;
  26847. t.cyrflex = 0xf6d5;
  26848. t.d = 0x0064;
  26849. t.daarmenian = 0x0564;
  26850. t.dabengali = 0x09a6;
  26851. t.dadarabic = 0x0636;
  26852. t.dadeva = 0x0926;
  26853. t.dadfinalarabic = 0xfebe;
  26854. t.dadinitialarabic = 0xfebf;
  26855. t.dadmedialarabic = 0xfec0;
  26856. t.dagesh = 0x05bc;
  26857. t.dageshhebrew = 0x05bc;
  26858. t.dagger = 0x2020;
  26859. t.daggerdbl = 0x2021;
  26860. t.dagujarati = 0x0aa6;
  26861. t.dagurmukhi = 0x0a26;
  26862. t.dahiragana = 0x3060;
  26863. t.dakatakana = 0x30c0;
  26864. t.dalarabic = 0x062f;
  26865. t.dalet = 0x05d3;
  26866. t.daletdagesh = 0xfb33;
  26867. t.daletdageshhebrew = 0xfb33;
  26868. t.dalethebrew = 0x05d3;
  26869. t.dalfinalarabic = 0xfeaa;
  26870. t.dammaarabic = 0x064f;
  26871. t.dammalowarabic = 0x064f;
  26872. t.dammatanaltonearabic = 0x064c;
  26873. t.dammatanarabic = 0x064c;
  26874. t.danda = 0x0964;
  26875. t.dargahebrew = 0x05a7;
  26876. t.dargalefthebrew = 0x05a7;
  26877. t.dasiapneumatacyrilliccmb = 0x0485;
  26878. t.dblGrave = 0xf6d3;
  26879. t.dblanglebracketleft = 0x300a;
  26880. t.dblanglebracketleftvertical = 0xfe3d;
  26881. t.dblanglebracketright = 0x300b;
  26882. t.dblanglebracketrightvertical = 0xfe3e;
  26883. t.dblarchinvertedbelowcmb = 0x032b;
  26884. t.dblarrowleft = 0x21d4;
  26885. t.dblarrowright = 0x21d2;
  26886. t.dbldanda = 0x0965;
  26887. t.dblgrave = 0xf6d6;
  26888. t.dblgravecmb = 0x030f;
  26889. t.dblintegral = 0x222c;
  26890. t.dbllowline = 0x2017;
  26891. t.dbllowlinecmb = 0x0333;
  26892. t.dbloverlinecmb = 0x033f;
  26893. t.dblprimemod = 0x02ba;
  26894. t.dblverticalbar = 0x2016;
  26895. t.dblverticallineabovecmb = 0x030e;
  26896. t.dbopomofo = 0x3109;
  26897. t.dbsquare = 0x33c8;
  26898. t.dcaron = 0x010f;
  26899. t.dcedilla = 0x1e11;
  26900. t.dcircle = 0x24d3;
  26901. t.dcircumflexbelow = 0x1e13;
  26902. t.dcroat = 0x0111;
  26903. t.ddabengali = 0x09a1;
  26904. t.ddadeva = 0x0921;
  26905. t.ddagujarati = 0x0aa1;
  26906. t.ddagurmukhi = 0x0a21;
  26907. t.ddalarabic = 0x0688;
  26908. t.ddalfinalarabic = 0xfb89;
  26909. t.dddhadeva = 0x095c;
  26910. t.ddhabengali = 0x09a2;
  26911. t.ddhadeva = 0x0922;
  26912. t.ddhagujarati = 0x0aa2;
  26913. t.ddhagurmukhi = 0x0a22;
  26914. t.ddotaccent = 0x1e0b;
  26915. t.ddotbelow = 0x1e0d;
  26916. t.decimalseparatorarabic = 0x066b;
  26917. t.decimalseparatorpersian = 0x066b;
  26918. t.decyrillic = 0x0434;
  26919. t.degree = 0x00b0;
  26920. t.dehihebrew = 0x05ad;
  26921. t.dehiragana = 0x3067;
  26922. t.deicoptic = 0x03ef;
  26923. t.dekatakana = 0x30c7;
  26924. t.deleteleft = 0x232b;
  26925. t.deleteright = 0x2326;
  26926. t.delta = 0x03b4;
  26927. t.deltaturned = 0x018d;
  26928. t.denominatorminusonenumeratorbengali = 0x09f8;
  26929. t.dezh = 0x02a4;
  26930. t.dhabengali = 0x09a7;
  26931. t.dhadeva = 0x0927;
  26932. t.dhagujarati = 0x0aa7;
  26933. t.dhagurmukhi = 0x0a27;
  26934. t.dhook = 0x0257;
  26935. t.dialytikatonos = 0x0385;
  26936. t.dialytikatonoscmb = 0x0344;
  26937. t.diamond = 0x2666;
  26938. t.diamondsuitwhite = 0x2662;
  26939. t.dieresis = 0x00a8;
  26940. t.dieresisacute = 0xf6d7;
  26941. t.dieresisbelowcmb = 0x0324;
  26942. t.dieresiscmb = 0x0308;
  26943. t.dieresisgrave = 0xf6d8;
  26944. t.dieresistonos = 0x0385;
  26945. t.dihiragana = 0x3062;
  26946. t.dikatakana = 0x30c2;
  26947. t.dittomark = 0x3003;
  26948. t.divide = 0x00f7;
  26949. t.divides = 0x2223;
  26950. t.divisionslash = 0x2215;
  26951. t.djecyrillic = 0x0452;
  26952. t.dkshade = 0x2593;
  26953. t.dlinebelow = 0x1e0f;
  26954. t.dlsquare = 0x3397;
  26955. t.dmacron = 0x0111;
  26956. t.dmonospace = 0xff44;
  26957. t.dnblock = 0x2584;
  26958. t.dochadathai = 0x0e0e;
  26959. t.dodekthai = 0x0e14;
  26960. t.dohiragana = 0x3069;
  26961. t.dokatakana = 0x30c9;
  26962. t.dollar = 0x0024;
  26963. t.dollarinferior = 0xf6e3;
  26964. t.dollarmonospace = 0xff04;
  26965. t.dollaroldstyle = 0xf724;
  26966. t.dollarsmall = 0xfe69;
  26967. t.dollarsuperior = 0xf6e4;
  26968. t.dong = 0x20ab;
  26969. t.dorusquare = 0x3326;
  26970. t.dotaccent = 0x02d9;
  26971. t.dotaccentcmb = 0x0307;
  26972. t.dotbelowcmb = 0x0323;
  26973. t.dotbelowcomb = 0x0323;
  26974. t.dotkatakana = 0x30fb;
  26975. t.dotlessi = 0x0131;
  26976. t.dotlessj = 0xf6be;
  26977. t.dotlessjstrokehook = 0x0284;
  26978. t.dotmath = 0x22c5;
  26979. t.dottedcircle = 0x25cc;
  26980. t.doubleyodpatah = 0xfb1f;
  26981. t.doubleyodpatahhebrew = 0xfb1f;
  26982. t.downtackbelowcmb = 0x031e;
  26983. t.downtackmod = 0x02d5;
  26984. t.dparen = 0x249f;
  26985. t.dsuperior = 0xf6eb;
  26986. t.dtail = 0x0256;
  26987. t.dtopbar = 0x018c;
  26988. t.duhiragana = 0x3065;
  26989. t.dukatakana = 0x30c5;
  26990. t.dz = 0x01f3;
  26991. t.dzaltone = 0x02a3;
  26992. t.dzcaron = 0x01c6;
  26993. t.dzcurl = 0x02a5;
  26994. t.dzeabkhasiancyrillic = 0x04e1;
  26995. t.dzecyrillic = 0x0455;
  26996. t.dzhecyrillic = 0x045f;
  26997. t.e = 0x0065;
  26998. t.eacute = 0x00e9;
  26999. t.earth = 0x2641;
  27000. t.ebengali = 0x098f;
  27001. t.ebopomofo = 0x311c;
  27002. t.ebreve = 0x0115;
  27003. t.ecandradeva = 0x090d;
  27004. t.ecandragujarati = 0x0a8d;
  27005. t.ecandravowelsigndeva = 0x0945;
  27006. t.ecandravowelsigngujarati = 0x0ac5;
  27007. t.ecaron = 0x011b;
  27008. t.ecedillabreve = 0x1e1d;
  27009. t.echarmenian = 0x0565;
  27010. t.echyiwnarmenian = 0x0587;
  27011. t.ecircle = 0x24d4;
  27012. t.ecircumflex = 0x00ea;
  27013. t.ecircumflexacute = 0x1ebf;
  27014. t.ecircumflexbelow = 0x1e19;
  27015. t.ecircumflexdotbelow = 0x1ec7;
  27016. t.ecircumflexgrave = 0x1ec1;
  27017. t.ecircumflexhookabove = 0x1ec3;
  27018. t.ecircumflextilde = 0x1ec5;
  27019. t.ecyrillic = 0x0454;
  27020. t.edblgrave = 0x0205;
  27021. t.edeva = 0x090f;
  27022. t.edieresis = 0x00eb;
  27023. t.edot = 0x0117;
  27024. t.edotaccent = 0x0117;
  27025. t.edotbelow = 0x1eb9;
  27026. t.eegurmukhi = 0x0a0f;
  27027. t.eematragurmukhi = 0x0a47;
  27028. t.efcyrillic = 0x0444;
  27029. t.egrave = 0x00e8;
  27030. t.egujarati = 0x0a8f;
  27031. t.eharmenian = 0x0567;
  27032. t.ehbopomofo = 0x311d;
  27033. t.ehiragana = 0x3048;
  27034. t.ehookabove = 0x1ebb;
  27035. t.eibopomofo = 0x311f;
  27036. t.eight = 0x0038;
  27037. t.eightarabic = 0x0668;
  27038. t.eightbengali = 0x09ee;
  27039. t.eightcircle = 0x2467;
  27040. t.eightcircleinversesansserif = 0x2791;
  27041. t.eightdeva = 0x096e;
  27042. t.eighteencircle = 0x2471;
  27043. t.eighteenparen = 0x2485;
  27044. t.eighteenperiod = 0x2499;
  27045. t.eightgujarati = 0x0aee;
  27046. t.eightgurmukhi = 0x0a6e;
  27047. t.eighthackarabic = 0x0668;
  27048. t.eighthangzhou = 0x3028;
  27049. t.eighthnotebeamed = 0x266b;
  27050. t.eightideographicparen = 0x3227;
  27051. t.eightinferior = 0x2088;
  27052. t.eightmonospace = 0xff18;
  27053. t.eightoldstyle = 0xf738;
  27054. t.eightparen = 0x247b;
  27055. t.eightperiod = 0x248f;
  27056. t.eightpersian = 0x06f8;
  27057. t.eightroman = 0x2177;
  27058. t.eightsuperior = 0x2078;
  27059. t.eightthai = 0x0e58;
  27060. t.einvertedbreve = 0x0207;
  27061. t.eiotifiedcyrillic = 0x0465;
  27062. t.ekatakana = 0x30a8;
  27063. t.ekatakanahalfwidth = 0xff74;
  27064. t.ekonkargurmukhi = 0x0a74;
  27065. t.ekorean = 0x3154;
  27066. t.elcyrillic = 0x043b;
  27067. t.element = 0x2208;
  27068. t.elevencircle = 0x246a;
  27069. t.elevenparen = 0x247e;
  27070. t.elevenperiod = 0x2492;
  27071. t.elevenroman = 0x217a;
  27072. t.ellipsis = 0x2026;
  27073. t.ellipsisvertical = 0x22ee;
  27074. t.emacron = 0x0113;
  27075. t.emacronacute = 0x1e17;
  27076. t.emacrongrave = 0x1e15;
  27077. t.emcyrillic = 0x043c;
  27078. t.emdash = 0x2014;
  27079. t.emdashvertical = 0xfe31;
  27080. t.emonospace = 0xff45;
  27081. t.emphasismarkarmenian = 0x055b;
  27082. t.emptyset = 0x2205;
  27083. t.enbopomofo = 0x3123;
  27084. t.encyrillic = 0x043d;
  27085. t.endash = 0x2013;
  27086. t.endashvertical = 0xfe32;
  27087. t.endescendercyrillic = 0x04a3;
  27088. t.eng = 0x014b;
  27089. t.engbopomofo = 0x3125;
  27090. t.enghecyrillic = 0x04a5;
  27091. t.enhookcyrillic = 0x04c8;
  27092. t.enspace = 0x2002;
  27093. t.eogonek = 0x0119;
  27094. t.eokorean = 0x3153;
  27095. t.eopen = 0x025b;
  27096. t.eopenclosed = 0x029a;
  27097. t.eopenreversed = 0x025c;
  27098. t.eopenreversedclosed = 0x025e;
  27099. t.eopenreversedhook = 0x025d;
  27100. t.eparen = 0x24a0;
  27101. t.epsilon = 0x03b5;
  27102. t.epsilontonos = 0x03ad;
  27103. t.equal = 0x003d;
  27104. t.equalmonospace = 0xff1d;
  27105. t.equalsmall = 0xfe66;
  27106. t.equalsuperior = 0x207c;
  27107. t.equivalence = 0x2261;
  27108. t.erbopomofo = 0x3126;
  27109. t.ercyrillic = 0x0440;
  27110. t.ereversed = 0x0258;
  27111. t.ereversedcyrillic = 0x044d;
  27112. t.escyrillic = 0x0441;
  27113. t.esdescendercyrillic = 0x04ab;
  27114. t.esh = 0x0283;
  27115. t.eshcurl = 0x0286;
  27116. t.eshortdeva = 0x090e;
  27117. t.eshortvowelsigndeva = 0x0946;
  27118. t.eshreversedloop = 0x01aa;
  27119. t.eshsquatreversed = 0x0285;
  27120. t.esmallhiragana = 0x3047;
  27121. t.esmallkatakana = 0x30a7;
  27122. t.esmallkatakanahalfwidth = 0xff6a;
  27123. t.estimated = 0x212e;
  27124. t.esuperior = 0xf6ec;
  27125. t.eta = 0x03b7;
  27126. t.etarmenian = 0x0568;
  27127. t.etatonos = 0x03ae;
  27128. t.eth = 0x00f0;
  27129. t.etilde = 0x1ebd;
  27130. t.etildebelow = 0x1e1b;
  27131. t.etnahtafoukhhebrew = 0x0591;
  27132. t.etnahtafoukhlefthebrew = 0x0591;
  27133. t.etnahtahebrew = 0x0591;
  27134. t.etnahtalefthebrew = 0x0591;
  27135. t.eturned = 0x01dd;
  27136. t.eukorean = 0x3161;
  27137. t.euro = 0x20ac;
  27138. t.evowelsignbengali = 0x09c7;
  27139. t.evowelsigndeva = 0x0947;
  27140. t.evowelsigngujarati = 0x0ac7;
  27141. t.exclam = 0x0021;
  27142. t.exclamarmenian = 0x055c;
  27143. t.exclamdbl = 0x203c;
  27144. t.exclamdown = 0x00a1;
  27145. t.exclamdownsmall = 0xf7a1;
  27146. t.exclammonospace = 0xff01;
  27147. t.exclamsmall = 0xf721;
  27148. t.existential = 0x2203;
  27149. t.ezh = 0x0292;
  27150. t.ezhcaron = 0x01ef;
  27151. t.ezhcurl = 0x0293;
  27152. t.ezhreversed = 0x01b9;
  27153. t.ezhtail = 0x01ba;
  27154. t.f = 0x0066;
  27155. t.fadeva = 0x095e;
  27156. t.fagurmukhi = 0x0a5e;
  27157. t.fahrenheit = 0x2109;
  27158. t.fathaarabic = 0x064e;
  27159. t.fathalowarabic = 0x064e;
  27160. t.fathatanarabic = 0x064b;
  27161. t.fbopomofo = 0x3108;
  27162. t.fcircle = 0x24d5;
  27163. t.fdotaccent = 0x1e1f;
  27164. t.feharabic = 0x0641;
  27165. t.feharmenian = 0x0586;
  27166. t.fehfinalarabic = 0xfed2;
  27167. t.fehinitialarabic = 0xfed3;
  27168. t.fehmedialarabic = 0xfed4;
  27169. t.feicoptic = 0x03e5;
  27170. t.female = 0x2640;
  27171. t.ff = 0xfb00;
  27172. t.f_f = 0xfb00;
  27173. t.ffi = 0xfb03;
  27174. t.ffl = 0xfb04;
  27175. t.fi = 0xfb01;
  27176. t.fifteencircle = 0x246e;
  27177. t.fifteenparen = 0x2482;
  27178. t.fifteenperiod = 0x2496;
  27179. t.figuredash = 0x2012;
  27180. t.filledbox = 0x25a0;
  27181. t.filledrect = 0x25ac;
  27182. t.finalkaf = 0x05da;
  27183. t.finalkafdagesh = 0xfb3a;
  27184. t.finalkafdageshhebrew = 0xfb3a;
  27185. t.finalkafhebrew = 0x05da;
  27186. t.finalmem = 0x05dd;
  27187. t.finalmemhebrew = 0x05dd;
  27188. t.finalnun = 0x05df;
  27189. t.finalnunhebrew = 0x05df;
  27190. t.finalpe = 0x05e3;
  27191. t.finalpehebrew = 0x05e3;
  27192. t.finaltsadi = 0x05e5;
  27193. t.finaltsadihebrew = 0x05e5;
  27194. t.firsttonechinese = 0x02c9;
  27195. t.fisheye = 0x25c9;
  27196. t.fitacyrillic = 0x0473;
  27197. t.five = 0x0035;
  27198. t.fivearabic = 0x0665;
  27199. t.fivebengali = 0x09eb;
  27200. t.fivecircle = 0x2464;
  27201. t.fivecircleinversesansserif = 0x278e;
  27202. t.fivedeva = 0x096b;
  27203. t.fiveeighths = 0x215d;
  27204. t.fivegujarati = 0x0aeb;
  27205. t.fivegurmukhi = 0x0a6b;
  27206. t.fivehackarabic = 0x0665;
  27207. t.fivehangzhou = 0x3025;
  27208. t.fiveideographicparen = 0x3224;
  27209. t.fiveinferior = 0x2085;
  27210. t.fivemonospace = 0xff15;
  27211. t.fiveoldstyle = 0xf735;
  27212. t.fiveparen = 0x2478;
  27213. t.fiveperiod = 0x248c;
  27214. t.fivepersian = 0x06f5;
  27215. t.fiveroman = 0x2174;
  27216. t.fivesuperior = 0x2075;
  27217. t.fivethai = 0x0e55;
  27218. t.fl = 0xfb02;
  27219. t.florin = 0x0192;
  27220. t.fmonospace = 0xff46;
  27221. t.fmsquare = 0x3399;
  27222. t.fofanthai = 0x0e1f;
  27223. t.fofathai = 0x0e1d;
  27224. t.fongmanthai = 0x0e4f;
  27225. t.forall = 0x2200;
  27226. t.four = 0x0034;
  27227. t.fourarabic = 0x0664;
  27228. t.fourbengali = 0x09ea;
  27229. t.fourcircle = 0x2463;
  27230. t.fourcircleinversesansserif = 0x278d;
  27231. t.fourdeva = 0x096a;
  27232. t.fourgujarati = 0x0aea;
  27233. t.fourgurmukhi = 0x0a6a;
  27234. t.fourhackarabic = 0x0664;
  27235. t.fourhangzhou = 0x3024;
  27236. t.fourideographicparen = 0x3223;
  27237. t.fourinferior = 0x2084;
  27238. t.fourmonospace = 0xff14;
  27239. t.fournumeratorbengali = 0x09f7;
  27240. t.fouroldstyle = 0xf734;
  27241. t.fourparen = 0x2477;
  27242. t.fourperiod = 0x248b;
  27243. t.fourpersian = 0x06f4;
  27244. t.fourroman = 0x2173;
  27245. t.foursuperior = 0x2074;
  27246. t.fourteencircle = 0x246d;
  27247. t.fourteenparen = 0x2481;
  27248. t.fourteenperiod = 0x2495;
  27249. t.fourthai = 0x0e54;
  27250. t.fourthtonechinese = 0x02cb;
  27251. t.fparen = 0x24a1;
  27252. t.fraction = 0x2044;
  27253. t.franc = 0x20a3;
  27254. t.g = 0x0067;
  27255. t.gabengali = 0x0997;
  27256. t.gacute = 0x01f5;
  27257. t.gadeva = 0x0917;
  27258. t.gafarabic = 0x06af;
  27259. t.gaffinalarabic = 0xfb93;
  27260. t.gafinitialarabic = 0xfb94;
  27261. t.gafmedialarabic = 0xfb95;
  27262. t.gagujarati = 0x0a97;
  27263. t.gagurmukhi = 0x0a17;
  27264. t.gahiragana = 0x304c;
  27265. t.gakatakana = 0x30ac;
  27266. t.gamma = 0x03b3;
  27267. t.gammalatinsmall = 0x0263;
  27268. t.gammasuperior = 0x02e0;
  27269. t.gangiacoptic = 0x03eb;
  27270. t.gbopomofo = 0x310d;
  27271. t.gbreve = 0x011f;
  27272. t.gcaron = 0x01e7;
  27273. t.gcedilla = 0x0123;
  27274. t.gcircle = 0x24d6;
  27275. t.gcircumflex = 0x011d;
  27276. t.gcommaaccent = 0x0123;
  27277. t.gdot = 0x0121;
  27278. t.gdotaccent = 0x0121;
  27279. t.gecyrillic = 0x0433;
  27280. t.gehiragana = 0x3052;
  27281. t.gekatakana = 0x30b2;
  27282. t.geometricallyequal = 0x2251;
  27283. t.gereshaccenthebrew = 0x059c;
  27284. t.gereshhebrew = 0x05f3;
  27285. t.gereshmuqdamhebrew = 0x059d;
  27286. t.germandbls = 0x00df;
  27287. t.gershayimaccenthebrew = 0x059e;
  27288. t.gershayimhebrew = 0x05f4;
  27289. t.getamark = 0x3013;
  27290. t.ghabengali = 0x0998;
  27291. t.ghadarmenian = 0x0572;
  27292. t.ghadeva = 0x0918;
  27293. t.ghagujarati = 0x0a98;
  27294. t.ghagurmukhi = 0x0a18;
  27295. t.ghainarabic = 0x063a;
  27296. t.ghainfinalarabic = 0xfece;
  27297. t.ghaininitialarabic = 0xfecf;
  27298. t.ghainmedialarabic = 0xfed0;
  27299. t.ghemiddlehookcyrillic = 0x0495;
  27300. t.ghestrokecyrillic = 0x0493;
  27301. t.gheupturncyrillic = 0x0491;
  27302. t.ghhadeva = 0x095a;
  27303. t.ghhagurmukhi = 0x0a5a;
  27304. t.ghook = 0x0260;
  27305. t.ghzsquare = 0x3393;
  27306. t.gihiragana = 0x304e;
  27307. t.gikatakana = 0x30ae;
  27308. t.gimarmenian = 0x0563;
  27309. t.gimel = 0x05d2;
  27310. t.gimeldagesh = 0xfb32;
  27311. t.gimeldageshhebrew = 0xfb32;
  27312. t.gimelhebrew = 0x05d2;
  27313. t.gjecyrillic = 0x0453;
  27314. t.glottalinvertedstroke = 0x01be;
  27315. t.glottalstop = 0x0294;
  27316. t.glottalstopinverted = 0x0296;
  27317. t.glottalstopmod = 0x02c0;
  27318. t.glottalstopreversed = 0x0295;
  27319. t.glottalstopreversedmod = 0x02c1;
  27320. t.glottalstopreversedsuperior = 0x02e4;
  27321. t.glottalstopstroke = 0x02a1;
  27322. t.glottalstopstrokereversed = 0x02a2;
  27323. t.gmacron = 0x1e21;
  27324. t.gmonospace = 0xff47;
  27325. t.gohiragana = 0x3054;
  27326. t.gokatakana = 0x30b4;
  27327. t.gparen = 0x24a2;
  27328. t.gpasquare = 0x33ac;
  27329. t.gradient = 0x2207;
  27330. t.grave = 0x0060;
  27331. t.gravebelowcmb = 0x0316;
  27332. t.gravecmb = 0x0300;
  27333. t.gravecomb = 0x0300;
  27334. t.gravedeva = 0x0953;
  27335. t.gravelowmod = 0x02ce;
  27336. t.gravemonospace = 0xff40;
  27337. t.gravetonecmb = 0x0340;
  27338. t.greater = 0x003e;
  27339. t.greaterequal = 0x2265;
  27340. t.greaterequalorless = 0x22db;
  27341. t.greatermonospace = 0xff1e;
  27342. t.greaterorequivalent = 0x2273;
  27343. t.greaterorless = 0x2277;
  27344. t.greateroverequal = 0x2267;
  27345. t.greatersmall = 0xfe65;
  27346. t.gscript = 0x0261;
  27347. t.gstroke = 0x01e5;
  27348. t.guhiragana = 0x3050;
  27349. t.guillemotleft = 0x00ab;
  27350. t.guillemotright = 0x00bb;
  27351. t.guilsinglleft = 0x2039;
  27352. t.guilsinglright = 0x203a;
  27353. t.gukatakana = 0x30b0;
  27354. t.guramusquare = 0x3318;
  27355. t.gysquare = 0x33c9;
  27356. t.h = 0x0068;
  27357. t.haabkhasiancyrillic = 0x04a9;
  27358. t.haaltonearabic = 0x06c1;
  27359. t.habengali = 0x09b9;
  27360. t.hadescendercyrillic = 0x04b3;
  27361. t.hadeva = 0x0939;
  27362. t.hagujarati = 0x0ab9;
  27363. t.hagurmukhi = 0x0a39;
  27364. t.haharabic = 0x062d;
  27365. t.hahfinalarabic = 0xfea2;
  27366. t.hahinitialarabic = 0xfea3;
  27367. t.hahiragana = 0x306f;
  27368. t.hahmedialarabic = 0xfea4;
  27369. t.haitusquare = 0x332a;
  27370. t.hakatakana = 0x30cf;
  27371. t.hakatakanahalfwidth = 0xff8a;
  27372. t.halantgurmukhi = 0x0a4d;
  27373. t.hamzaarabic = 0x0621;
  27374. t.hamzalowarabic = 0x0621;
  27375. t.hangulfiller = 0x3164;
  27376. t.hardsigncyrillic = 0x044a;
  27377. t.harpoonleftbarbup = 0x21bc;
  27378. t.harpoonrightbarbup = 0x21c0;
  27379. t.hasquare = 0x33ca;
  27380. t.hatafpatah = 0x05b2;
  27381. t.hatafpatah16 = 0x05b2;
  27382. t.hatafpatah23 = 0x05b2;
  27383. t.hatafpatah2f = 0x05b2;
  27384. t.hatafpatahhebrew = 0x05b2;
  27385. t.hatafpatahnarrowhebrew = 0x05b2;
  27386. t.hatafpatahquarterhebrew = 0x05b2;
  27387. t.hatafpatahwidehebrew = 0x05b2;
  27388. t.hatafqamats = 0x05b3;
  27389. t.hatafqamats1b = 0x05b3;
  27390. t.hatafqamats28 = 0x05b3;
  27391. t.hatafqamats34 = 0x05b3;
  27392. t.hatafqamatshebrew = 0x05b3;
  27393. t.hatafqamatsnarrowhebrew = 0x05b3;
  27394. t.hatafqamatsquarterhebrew = 0x05b3;
  27395. t.hatafqamatswidehebrew = 0x05b3;
  27396. t.hatafsegol = 0x05b1;
  27397. t.hatafsegol17 = 0x05b1;
  27398. t.hatafsegol24 = 0x05b1;
  27399. t.hatafsegol30 = 0x05b1;
  27400. t.hatafsegolhebrew = 0x05b1;
  27401. t.hatafsegolnarrowhebrew = 0x05b1;
  27402. t.hatafsegolquarterhebrew = 0x05b1;
  27403. t.hatafsegolwidehebrew = 0x05b1;
  27404. t.hbar = 0x0127;
  27405. t.hbopomofo = 0x310f;
  27406. t.hbrevebelow = 0x1e2b;
  27407. t.hcedilla = 0x1e29;
  27408. t.hcircle = 0x24d7;
  27409. t.hcircumflex = 0x0125;
  27410. t.hdieresis = 0x1e27;
  27411. t.hdotaccent = 0x1e23;
  27412. t.hdotbelow = 0x1e25;
  27413. t.he = 0x05d4;
  27414. t.heart = 0x2665;
  27415. t.heartsuitblack = 0x2665;
  27416. t.heartsuitwhite = 0x2661;
  27417. t.hedagesh = 0xfb34;
  27418. t.hedageshhebrew = 0xfb34;
  27419. t.hehaltonearabic = 0x06c1;
  27420. t.heharabic = 0x0647;
  27421. t.hehebrew = 0x05d4;
  27422. t.hehfinalaltonearabic = 0xfba7;
  27423. t.hehfinalalttwoarabic = 0xfeea;
  27424. t.hehfinalarabic = 0xfeea;
  27425. t.hehhamzaabovefinalarabic = 0xfba5;
  27426. t.hehhamzaaboveisolatedarabic = 0xfba4;
  27427. t.hehinitialaltonearabic = 0xfba8;
  27428. t.hehinitialarabic = 0xfeeb;
  27429. t.hehiragana = 0x3078;
  27430. t.hehmedialaltonearabic = 0xfba9;
  27431. t.hehmedialarabic = 0xfeec;
  27432. t.heiseierasquare = 0x337b;
  27433. t.hekatakana = 0x30d8;
  27434. t.hekatakanahalfwidth = 0xff8d;
  27435. t.hekutaarusquare = 0x3336;
  27436. t.henghook = 0x0267;
  27437. t.herutusquare = 0x3339;
  27438. t.het = 0x05d7;
  27439. t.hethebrew = 0x05d7;
  27440. t.hhook = 0x0266;
  27441. t.hhooksuperior = 0x02b1;
  27442. t.hieuhacirclekorean = 0x327b;
  27443. t.hieuhaparenkorean = 0x321b;
  27444. t.hieuhcirclekorean = 0x326d;
  27445. t.hieuhkorean = 0x314e;
  27446. t.hieuhparenkorean = 0x320d;
  27447. t.hihiragana = 0x3072;
  27448. t.hikatakana = 0x30d2;
  27449. t.hikatakanahalfwidth = 0xff8b;
  27450. t.hiriq = 0x05b4;
  27451. t.hiriq14 = 0x05b4;
  27452. t.hiriq21 = 0x05b4;
  27453. t.hiriq2d = 0x05b4;
  27454. t.hiriqhebrew = 0x05b4;
  27455. t.hiriqnarrowhebrew = 0x05b4;
  27456. t.hiriqquarterhebrew = 0x05b4;
  27457. t.hiriqwidehebrew = 0x05b4;
  27458. t.hlinebelow = 0x1e96;
  27459. t.hmonospace = 0xff48;
  27460. t.hoarmenian = 0x0570;
  27461. t.hohipthai = 0x0e2b;
  27462. t.hohiragana = 0x307b;
  27463. t.hokatakana = 0x30db;
  27464. t.hokatakanahalfwidth = 0xff8e;
  27465. t.holam = 0x05b9;
  27466. t.holam19 = 0x05b9;
  27467. t.holam26 = 0x05b9;
  27468. t.holam32 = 0x05b9;
  27469. t.holamhebrew = 0x05b9;
  27470. t.holamnarrowhebrew = 0x05b9;
  27471. t.holamquarterhebrew = 0x05b9;
  27472. t.holamwidehebrew = 0x05b9;
  27473. t.honokhukthai = 0x0e2e;
  27474. t.hookabovecomb = 0x0309;
  27475. t.hookcmb = 0x0309;
  27476. t.hookpalatalizedbelowcmb = 0x0321;
  27477. t.hookretroflexbelowcmb = 0x0322;
  27478. t.hoonsquare = 0x3342;
  27479. t.horicoptic = 0x03e9;
  27480. t.horizontalbar = 0x2015;
  27481. t.horncmb = 0x031b;
  27482. t.hotsprings = 0x2668;
  27483. t.house = 0x2302;
  27484. t.hparen = 0x24a3;
  27485. t.hsuperior = 0x02b0;
  27486. t.hturned = 0x0265;
  27487. t.huhiragana = 0x3075;
  27488. t.huiitosquare = 0x3333;
  27489. t.hukatakana = 0x30d5;
  27490. t.hukatakanahalfwidth = 0xff8c;
  27491. t.hungarumlaut = 0x02dd;
  27492. t.hungarumlautcmb = 0x030b;
  27493. t.hv = 0x0195;
  27494. t.hyphen = 0x002d;
  27495. t.hypheninferior = 0xf6e5;
  27496. t.hyphenmonospace = 0xff0d;
  27497. t.hyphensmall = 0xfe63;
  27498. t.hyphensuperior = 0xf6e6;
  27499. t.hyphentwo = 0x2010;
  27500. t.i = 0x0069;
  27501. t.iacute = 0x00ed;
  27502. t.iacyrillic = 0x044f;
  27503. t.ibengali = 0x0987;
  27504. t.ibopomofo = 0x3127;
  27505. t.ibreve = 0x012d;
  27506. t.icaron = 0x01d0;
  27507. t.icircle = 0x24d8;
  27508. t.icircumflex = 0x00ee;
  27509. t.icyrillic = 0x0456;
  27510. t.idblgrave = 0x0209;
  27511. t.ideographearthcircle = 0x328f;
  27512. t.ideographfirecircle = 0x328b;
  27513. t.ideographicallianceparen = 0x323f;
  27514. t.ideographiccallparen = 0x323a;
  27515. t.ideographiccentrecircle = 0x32a5;
  27516. t.ideographicclose = 0x3006;
  27517. t.ideographiccomma = 0x3001;
  27518. t.ideographiccommaleft = 0xff64;
  27519. t.ideographiccongratulationparen = 0x3237;
  27520. t.ideographiccorrectcircle = 0x32a3;
  27521. t.ideographicearthparen = 0x322f;
  27522. t.ideographicenterpriseparen = 0x323d;
  27523. t.ideographicexcellentcircle = 0x329d;
  27524. t.ideographicfestivalparen = 0x3240;
  27525. t.ideographicfinancialcircle = 0x3296;
  27526. t.ideographicfinancialparen = 0x3236;
  27527. t.ideographicfireparen = 0x322b;
  27528. t.ideographichaveparen = 0x3232;
  27529. t.ideographichighcircle = 0x32a4;
  27530. t.ideographiciterationmark = 0x3005;
  27531. t.ideographiclaborcircle = 0x3298;
  27532. t.ideographiclaborparen = 0x3238;
  27533. t.ideographicleftcircle = 0x32a7;
  27534. t.ideographiclowcircle = 0x32a6;
  27535. t.ideographicmedicinecircle = 0x32a9;
  27536. t.ideographicmetalparen = 0x322e;
  27537. t.ideographicmoonparen = 0x322a;
  27538. t.ideographicnameparen = 0x3234;
  27539. t.ideographicperiod = 0x3002;
  27540. t.ideographicprintcircle = 0x329e;
  27541. t.ideographicreachparen = 0x3243;
  27542. t.ideographicrepresentparen = 0x3239;
  27543. t.ideographicresourceparen = 0x323e;
  27544. t.ideographicrightcircle = 0x32a8;
  27545. t.ideographicsecretcircle = 0x3299;
  27546. t.ideographicselfparen = 0x3242;
  27547. t.ideographicsocietyparen = 0x3233;
  27548. t.ideographicspace = 0x3000;
  27549. t.ideographicspecialparen = 0x3235;
  27550. t.ideographicstockparen = 0x3231;
  27551. t.ideographicstudyparen = 0x323b;
  27552. t.ideographicsunparen = 0x3230;
  27553. t.ideographicsuperviseparen = 0x323c;
  27554. t.ideographicwaterparen = 0x322c;
  27555. t.ideographicwoodparen = 0x322d;
  27556. t.ideographiczero = 0x3007;
  27557. t.ideographmetalcircle = 0x328e;
  27558. t.ideographmooncircle = 0x328a;
  27559. t.ideographnamecircle = 0x3294;
  27560. t.ideographsuncircle = 0x3290;
  27561. t.ideographwatercircle = 0x328c;
  27562. t.ideographwoodcircle = 0x328d;
  27563. t.ideva = 0x0907;
  27564. t.idieresis = 0x00ef;
  27565. t.idieresisacute = 0x1e2f;
  27566. t.idieresiscyrillic = 0x04e5;
  27567. t.idotbelow = 0x1ecb;
  27568. t.iebrevecyrillic = 0x04d7;
  27569. t.iecyrillic = 0x0435;
  27570. t.ieungacirclekorean = 0x3275;
  27571. t.ieungaparenkorean = 0x3215;
  27572. t.ieungcirclekorean = 0x3267;
  27573. t.ieungkorean = 0x3147;
  27574. t.ieungparenkorean = 0x3207;
  27575. t.igrave = 0x00ec;
  27576. t.igujarati = 0x0a87;
  27577. t.igurmukhi = 0x0a07;
  27578. t.ihiragana = 0x3044;
  27579. t.ihookabove = 0x1ec9;
  27580. t.iibengali = 0x0988;
  27581. t.iicyrillic = 0x0438;
  27582. t.iideva = 0x0908;
  27583. t.iigujarati = 0x0a88;
  27584. t.iigurmukhi = 0x0a08;
  27585. t.iimatragurmukhi = 0x0a40;
  27586. t.iinvertedbreve = 0x020b;
  27587. t.iishortcyrillic = 0x0439;
  27588. t.iivowelsignbengali = 0x09c0;
  27589. t.iivowelsigndeva = 0x0940;
  27590. t.iivowelsigngujarati = 0x0ac0;
  27591. t.ij = 0x0133;
  27592. t.ikatakana = 0x30a4;
  27593. t.ikatakanahalfwidth = 0xff72;
  27594. t.ikorean = 0x3163;
  27595. t.ilde = 0x02dc;
  27596. t.iluyhebrew = 0x05ac;
  27597. t.imacron = 0x012b;
  27598. t.imacroncyrillic = 0x04e3;
  27599. t.imageorapproximatelyequal = 0x2253;
  27600. t.imatragurmukhi = 0x0a3f;
  27601. t.imonospace = 0xff49;
  27602. t.increment = 0x2206;
  27603. t.infinity = 0x221e;
  27604. t.iniarmenian = 0x056b;
  27605. t.integral = 0x222b;
  27606. t.integralbottom = 0x2321;
  27607. t.integralbt = 0x2321;
  27608. t.integralex = 0xf8f5;
  27609. t.integraltop = 0x2320;
  27610. t.integraltp = 0x2320;
  27611. t.intersection = 0x2229;
  27612. t.intisquare = 0x3305;
  27613. t.invbullet = 0x25d8;
  27614. t.invcircle = 0x25d9;
  27615. t.invsmileface = 0x263b;
  27616. t.iocyrillic = 0x0451;
  27617. t.iogonek = 0x012f;
  27618. t.iota = 0x03b9;
  27619. t.iotadieresis = 0x03ca;
  27620. t.iotadieresistonos = 0x0390;
  27621. t.iotalatin = 0x0269;
  27622. t.iotatonos = 0x03af;
  27623. t.iparen = 0x24a4;
  27624. t.irigurmukhi = 0x0a72;
  27625. t.ismallhiragana = 0x3043;
  27626. t.ismallkatakana = 0x30a3;
  27627. t.ismallkatakanahalfwidth = 0xff68;
  27628. t.issharbengali = 0x09fa;
  27629. t.istroke = 0x0268;
  27630. t.isuperior = 0xf6ed;
  27631. t.iterationhiragana = 0x309d;
  27632. t.iterationkatakana = 0x30fd;
  27633. t.itilde = 0x0129;
  27634. t.itildebelow = 0x1e2d;
  27635. t.iubopomofo = 0x3129;
  27636. t.iucyrillic = 0x044e;
  27637. t.ivowelsignbengali = 0x09bf;
  27638. t.ivowelsigndeva = 0x093f;
  27639. t.ivowelsigngujarati = 0x0abf;
  27640. t.izhitsacyrillic = 0x0475;
  27641. t.izhitsadblgravecyrillic = 0x0477;
  27642. t.j = 0x006a;
  27643. t.jaarmenian = 0x0571;
  27644. t.jabengali = 0x099c;
  27645. t.jadeva = 0x091c;
  27646. t.jagujarati = 0x0a9c;
  27647. t.jagurmukhi = 0x0a1c;
  27648. t.jbopomofo = 0x3110;
  27649. t.jcaron = 0x01f0;
  27650. t.jcircle = 0x24d9;
  27651. t.jcircumflex = 0x0135;
  27652. t.jcrossedtail = 0x029d;
  27653. t.jdotlessstroke = 0x025f;
  27654. t.jecyrillic = 0x0458;
  27655. t.jeemarabic = 0x062c;
  27656. t.jeemfinalarabic = 0xfe9e;
  27657. t.jeeminitialarabic = 0xfe9f;
  27658. t.jeemmedialarabic = 0xfea0;
  27659. t.jeharabic = 0x0698;
  27660. t.jehfinalarabic = 0xfb8b;
  27661. t.jhabengali = 0x099d;
  27662. t.jhadeva = 0x091d;
  27663. t.jhagujarati = 0x0a9d;
  27664. t.jhagurmukhi = 0x0a1d;
  27665. t.jheharmenian = 0x057b;
  27666. t.jis = 0x3004;
  27667. t.jmonospace = 0xff4a;
  27668. t.jparen = 0x24a5;
  27669. t.jsuperior = 0x02b2;
  27670. t.k = 0x006b;
  27671. t.kabashkircyrillic = 0x04a1;
  27672. t.kabengali = 0x0995;
  27673. t.kacute = 0x1e31;
  27674. t.kacyrillic = 0x043a;
  27675. t.kadescendercyrillic = 0x049b;
  27676. t.kadeva = 0x0915;
  27677. t.kaf = 0x05db;
  27678. t.kafarabic = 0x0643;
  27679. t.kafdagesh = 0xfb3b;
  27680. t.kafdageshhebrew = 0xfb3b;
  27681. t.kaffinalarabic = 0xfeda;
  27682. t.kafhebrew = 0x05db;
  27683. t.kafinitialarabic = 0xfedb;
  27684. t.kafmedialarabic = 0xfedc;
  27685. t.kafrafehebrew = 0xfb4d;
  27686. t.kagujarati = 0x0a95;
  27687. t.kagurmukhi = 0x0a15;
  27688. t.kahiragana = 0x304b;
  27689. t.kahookcyrillic = 0x04c4;
  27690. t.kakatakana = 0x30ab;
  27691. t.kakatakanahalfwidth = 0xff76;
  27692. t.kappa = 0x03ba;
  27693. t.kappasymbolgreek = 0x03f0;
  27694. t.kapyeounmieumkorean = 0x3171;
  27695. t.kapyeounphieuphkorean = 0x3184;
  27696. t.kapyeounpieupkorean = 0x3178;
  27697. t.kapyeounssangpieupkorean = 0x3179;
  27698. t.karoriisquare = 0x330d;
  27699. t.kashidaautoarabic = 0x0640;
  27700. t.kashidaautonosidebearingarabic = 0x0640;
  27701. t.kasmallkatakana = 0x30f5;
  27702. t.kasquare = 0x3384;
  27703. t.kasraarabic = 0x0650;
  27704. t.kasratanarabic = 0x064d;
  27705. t.kastrokecyrillic = 0x049f;
  27706. t.katahiraprolongmarkhalfwidth = 0xff70;
  27707. t.kaverticalstrokecyrillic = 0x049d;
  27708. t.kbopomofo = 0x310e;
  27709. t.kcalsquare = 0x3389;
  27710. t.kcaron = 0x01e9;
  27711. t.kcedilla = 0x0137;
  27712. t.kcircle = 0x24da;
  27713. t.kcommaaccent = 0x0137;
  27714. t.kdotbelow = 0x1e33;
  27715. t.keharmenian = 0x0584;
  27716. t.kehiragana = 0x3051;
  27717. t.kekatakana = 0x30b1;
  27718. t.kekatakanahalfwidth = 0xff79;
  27719. t.kenarmenian = 0x056f;
  27720. t.kesmallkatakana = 0x30f6;
  27721. t.kgreenlandic = 0x0138;
  27722. t.khabengali = 0x0996;
  27723. t.khacyrillic = 0x0445;
  27724. t.khadeva = 0x0916;
  27725. t.khagujarati = 0x0a96;
  27726. t.khagurmukhi = 0x0a16;
  27727. t.khaharabic = 0x062e;
  27728. t.khahfinalarabic = 0xfea6;
  27729. t.khahinitialarabic = 0xfea7;
  27730. t.khahmedialarabic = 0xfea8;
  27731. t.kheicoptic = 0x03e7;
  27732. t.khhadeva = 0x0959;
  27733. t.khhagurmukhi = 0x0a59;
  27734. t.khieukhacirclekorean = 0x3278;
  27735. t.khieukhaparenkorean = 0x3218;
  27736. t.khieukhcirclekorean = 0x326a;
  27737. t.khieukhkorean = 0x314b;
  27738. t.khieukhparenkorean = 0x320a;
  27739. t.khokhaithai = 0x0e02;
  27740. t.khokhonthai = 0x0e05;
  27741. t.khokhuatthai = 0x0e03;
  27742. t.khokhwaithai = 0x0e04;
  27743. t.khomutthai = 0x0e5b;
  27744. t.khook = 0x0199;
  27745. t.khorakhangthai = 0x0e06;
  27746. t.khzsquare = 0x3391;
  27747. t.kihiragana = 0x304d;
  27748. t.kikatakana = 0x30ad;
  27749. t.kikatakanahalfwidth = 0xff77;
  27750. t.kiroguramusquare = 0x3315;
  27751. t.kiromeetorusquare = 0x3316;
  27752. t.kirosquare = 0x3314;
  27753. t.kiyeokacirclekorean = 0x326e;
  27754. t.kiyeokaparenkorean = 0x320e;
  27755. t.kiyeokcirclekorean = 0x3260;
  27756. t.kiyeokkorean = 0x3131;
  27757. t.kiyeokparenkorean = 0x3200;
  27758. t.kiyeoksioskorean = 0x3133;
  27759. t.kjecyrillic = 0x045c;
  27760. t.klinebelow = 0x1e35;
  27761. t.klsquare = 0x3398;
  27762. t.kmcubedsquare = 0x33a6;
  27763. t.kmonospace = 0xff4b;
  27764. t.kmsquaredsquare = 0x33a2;
  27765. t.kohiragana = 0x3053;
  27766. t.kohmsquare = 0x33c0;
  27767. t.kokaithai = 0x0e01;
  27768. t.kokatakana = 0x30b3;
  27769. t.kokatakanahalfwidth = 0xff7a;
  27770. t.kooposquare = 0x331e;
  27771. t.koppacyrillic = 0x0481;
  27772. t.koreanstandardsymbol = 0x327f;
  27773. t.koroniscmb = 0x0343;
  27774. t.kparen = 0x24a6;
  27775. t.kpasquare = 0x33aa;
  27776. t.ksicyrillic = 0x046f;
  27777. t.ktsquare = 0x33cf;
  27778. t.kturned = 0x029e;
  27779. t.kuhiragana = 0x304f;
  27780. t.kukatakana = 0x30af;
  27781. t.kukatakanahalfwidth = 0xff78;
  27782. t.kvsquare = 0x33b8;
  27783. t.kwsquare = 0x33be;
  27784. t.l = 0x006c;
  27785. t.labengali = 0x09b2;
  27786. t.lacute = 0x013a;
  27787. t.ladeva = 0x0932;
  27788. t.lagujarati = 0x0ab2;
  27789. t.lagurmukhi = 0x0a32;
  27790. t.lakkhangyaothai = 0x0e45;
  27791. t.lamaleffinalarabic = 0xfefc;
  27792. t.lamalefhamzaabovefinalarabic = 0xfef8;
  27793. t.lamalefhamzaaboveisolatedarabic = 0xfef7;
  27794. t.lamalefhamzabelowfinalarabic = 0xfefa;
  27795. t.lamalefhamzabelowisolatedarabic = 0xfef9;
  27796. t.lamalefisolatedarabic = 0xfefb;
  27797. t.lamalefmaddaabovefinalarabic = 0xfef6;
  27798. t.lamalefmaddaaboveisolatedarabic = 0xfef5;
  27799. t.lamarabic = 0x0644;
  27800. t.lambda = 0x03bb;
  27801. t.lambdastroke = 0x019b;
  27802. t.lamed = 0x05dc;
  27803. t.lameddagesh = 0xfb3c;
  27804. t.lameddageshhebrew = 0xfb3c;
  27805. t.lamedhebrew = 0x05dc;
  27806. t.lamfinalarabic = 0xfede;
  27807. t.lamhahinitialarabic = 0xfcca;
  27808. t.laminitialarabic = 0xfedf;
  27809. t.lamjeeminitialarabic = 0xfcc9;
  27810. t.lamkhahinitialarabic = 0xfccb;
  27811. t.lamlamhehisolatedarabic = 0xfdf2;
  27812. t.lammedialarabic = 0xfee0;
  27813. t.lammeemhahinitialarabic = 0xfd88;
  27814. t.lammeeminitialarabic = 0xfccc;
  27815. t.largecircle = 0x25ef;
  27816. t.lbar = 0x019a;
  27817. t.lbelt = 0x026c;
  27818. t.lbopomofo = 0x310c;
  27819. t.lcaron = 0x013e;
  27820. t.lcedilla = 0x013c;
  27821. t.lcircle = 0x24db;
  27822. t.lcircumflexbelow = 0x1e3d;
  27823. t.lcommaaccent = 0x013c;
  27824. t.ldot = 0x0140;
  27825. t.ldotaccent = 0x0140;
  27826. t.ldotbelow = 0x1e37;
  27827. t.ldotbelowmacron = 0x1e39;
  27828. t.leftangleabovecmb = 0x031a;
  27829. t.lefttackbelowcmb = 0x0318;
  27830. t.less = 0x003c;
  27831. t.lessequal = 0x2264;
  27832. t.lessequalorgreater = 0x22da;
  27833. t.lessmonospace = 0xff1c;
  27834. t.lessorequivalent = 0x2272;
  27835. t.lessorgreater = 0x2276;
  27836. t.lessoverequal = 0x2266;
  27837. t.lesssmall = 0xfe64;
  27838. t.lezh = 0x026e;
  27839. t.lfblock = 0x258c;
  27840. t.lhookretroflex = 0x026d;
  27841. t.lira = 0x20a4;
  27842. t.liwnarmenian = 0x056c;
  27843. t.lj = 0x01c9;
  27844. t.ljecyrillic = 0x0459;
  27845. t.ll = 0xf6c0;
  27846. t.lladeva = 0x0933;
  27847. t.llagujarati = 0x0ab3;
  27848. t.llinebelow = 0x1e3b;
  27849. t.llladeva = 0x0934;
  27850. t.llvocalicbengali = 0x09e1;
  27851. t.llvocalicdeva = 0x0961;
  27852. t.llvocalicvowelsignbengali = 0x09e3;
  27853. t.llvocalicvowelsigndeva = 0x0963;
  27854. t.lmiddletilde = 0x026b;
  27855. t.lmonospace = 0xff4c;
  27856. t.lmsquare = 0x33d0;
  27857. t.lochulathai = 0x0e2c;
  27858. t.logicaland = 0x2227;
  27859. t.logicalnot = 0x00ac;
  27860. t.logicalnotreversed = 0x2310;
  27861. t.logicalor = 0x2228;
  27862. t.lolingthai = 0x0e25;
  27863. t.longs = 0x017f;
  27864. t.lowlinecenterline = 0xfe4e;
  27865. t.lowlinecmb = 0x0332;
  27866. t.lowlinedashed = 0xfe4d;
  27867. t.lozenge = 0x25ca;
  27868. t.lparen = 0x24a7;
  27869. t.lslash = 0x0142;
  27870. t.lsquare = 0x2113;
  27871. t.lsuperior = 0xf6ee;
  27872. t.ltshade = 0x2591;
  27873. t.luthai = 0x0e26;
  27874. t.lvocalicbengali = 0x098c;
  27875. t.lvocalicdeva = 0x090c;
  27876. t.lvocalicvowelsignbengali = 0x09e2;
  27877. t.lvocalicvowelsigndeva = 0x0962;
  27878. t.lxsquare = 0x33d3;
  27879. t.m = 0x006d;
  27880. t.mabengali = 0x09ae;
  27881. t.macron = 0x00af;
  27882. t.macronbelowcmb = 0x0331;
  27883. t.macroncmb = 0x0304;
  27884. t.macronlowmod = 0x02cd;
  27885. t.macronmonospace = 0xffe3;
  27886. t.macute = 0x1e3f;
  27887. t.madeva = 0x092e;
  27888. t.magujarati = 0x0aae;
  27889. t.magurmukhi = 0x0a2e;
  27890. t.mahapakhhebrew = 0x05a4;
  27891. t.mahapakhlefthebrew = 0x05a4;
  27892. t.mahiragana = 0x307e;
  27893. t.maichattawalowleftthai = 0xf895;
  27894. t.maichattawalowrightthai = 0xf894;
  27895. t.maichattawathai = 0x0e4b;
  27896. t.maichattawaupperleftthai = 0xf893;
  27897. t.maieklowleftthai = 0xf88c;
  27898. t.maieklowrightthai = 0xf88b;
  27899. t.maiekthai = 0x0e48;
  27900. t.maiekupperleftthai = 0xf88a;
  27901. t.maihanakatleftthai = 0xf884;
  27902. t.maihanakatthai = 0x0e31;
  27903. t.maitaikhuleftthai = 0xf889;
  27904. t.maitaikhuthai = 0x0e47;
  27905. t.maitholowleftthai = 0xf88f;
  27906. t.maitholowrightthai = 0xf88e;
  27907. t.maithothai = 0x0e49;
  27908. t.maithoupperleftthai = 0xf88d;
  27909. t.maitrilowleftthai = 0xf892;
  27910. t.maitrilowrightthai = 0xf891;
  27911. t.maitrithai = 0x0e4a;
  27912. t.maitriupperleftthai = 0xf890;
  27913. t.maiyamokthai = 0x0e46;
  27914. t.makatakana = 0x30de;
  27915. t.makatakanahalfwidth = 0xff8f;
  27916. t.male = 0x2642;
  27917. t.mansyonsquare = 0x3347;
  27918. t.maqafhebrew = 0x05be;
  27919. t.mars = 0x2642;
  27920. t.masoracirclehebrew = 0x05af;
  27921. t.masquare = 0x3383;
  27922. t.mbopomofo = 0x3107;
  27923. t.mbsquare = 0x33d4;
  27924. t.mcircle = 0x24dc;
  27925. t.mcubedsquare = 0x33a5;
  27926. t.mdotaccent = 0x1e41;
  27927. t.mdotbelow = 0x1e43;
  27928. t.meemarabic = 0x0645;
  27929. t.meemfinalarabic = 0xfee2;
  27930. t.meeminitialarabic = 0xfee3;
  27931. t.meemmedialarabic = 0xfee4;
  27932. t.meemmeeminitialarabic = 0xfcd1;
  27933. t.meemmeemisolatedarabic = 0xfc48;
  27934. t.meetorusquare = 0x334d;
  27935. t.mehiragana = 0x3081;
  27936. t.meizierasquare = 0x337e;
  27937. t.mekatakana = 0x30e1;
  27938. t.mekatakanahalfwidth = 0xff92;
  27939. t.mem = 0x05de;
  27940. t.memdagesh = 0xfb3e;
  27941. t.memdageshhebrew = 0xfb3e;
  27942. t.memhebrew = 0x05de;
  27943. t.menarmenian = 0x0574;
  27944. t.merkhahebrew = 0x05a5;
  27945. t.merkhakefulahebrew = 0x05a6;
  27946. t.merkhakefulalefthebrew = 0x05a6;
  27947. t.merkhalefthebrew = 0x05a5;
  27948. t.mhook = 0x0271;
  27949. t.mhzsquare = 0x3392;
  27950. t.middledotkatakanahalfwidth = 0xff65;
  27951. t.middot = 0x00b7;
  27952. t.mieumacirclekorean = 0x3272;
  27953. t.mieumaparenkorean = 0x3212;
  27954. t.mieumcirclekorean = 0x3264;
  27955. t.mieumkorean = 0x3141;
  27956. t.mieumpansioskorean = 0x3170;
  27957. t.mieumparenkorean = 0x3204;
  27958. t.mieumpieupkorean = 0x316e;
  27959. t.mieumsioskorean = 0x316f;
  27960. t.mihiragana = 0x307f;
  27961. t.mikatakana = 0x30df;
  27962. t.mikatakanahalfwidth = 0xff90;
  27963. t.minus = 0x2212;
  27964. t.minusbelowcmb = 0x0320;
  27965. t.minuscircle = 0x2296;
  27966. t.minusmod = 0x02d7;
  27967. t.minusplus = 0x2213;
  27968. t.minute = 0x2032;
  27969. t.miribaarusquare = 0x334a;
  27970. t.mirisquare = 0x3349;
  27971. t.mlonglegturned = 0x0270;
  27972. t.mlsquare = 0x3396;
  27973. t.mmcubedsquare = 0x33a3;
  27974. t.mmonospace = 0xff4d;
  27975. t.mmsquaredsquare = 0x339f;
  27976. t.mohiragana = 0x3082;
  27977. t.mohmsquare = 0x33c1;
  27978. t.mokatakana = 0x30e2;
  27979. t.mokatakanahalfwidth = 0xff93;
  27980. t.molsquare = 0x33d6;
  27981. t.momathai = 0x0e21;
  27982. t.moverssquare = 0x33a7;
  27983. t.moverssquaredsquare = 0x33a8;
  27984. t.mparen = 0x24a8;
  27985. t.mpasquare = 0x33ab;
  27986. t.mssquare = 0x33b3;
  27987. t.msuperior = 0xf6ef;
  27988. t.mturned = 0x026f;
  27989. t.mu = 0x00b5;
  27990. t.mu1 = 0x00b5;
  27991. t.muasquare = 0x3382;
  27992. t.muchgreater = 0x226b;
  27993. t.muchless = 0x226a;
  27994. t.mufsquare = 0x338c;
  27995. t.mugreek = 0x03bc;
  27996. t.mugsquare = 0x338d;
  27997. t.muhiragana = 0x3080;
  27998. t.mukatakana = 0x30e0;
  27999. t.mukatakanahalfwidth = 0xff91;
  28000. t.mulsquare = 0x3395;
  28001. t.multiply = 0x00d7;
  28002. t.mumsquare = 0x339b;
  28003. t.munahhebrew = 0x05a3;
  28004. t.munahlefthebrew = 0x05a3;
  28005. t.musicalnote = 0x266a;
  28006. t.musicalnotedbl = 0x266b;
  28007. t.musicflatsign = 0x266d;
  28008. t.musicsharpsign = 0x266f;
  28009. t.mussquare = 0x33b2;
  28010. t.muvsquare = 0x33b6;
  28011. t.muwsquare = 0x33bc;
  28012. t.mvmegasquare = 0x33b9;
  28013. t.mvsquare = 0x33b7;
  28014. t.mwmegasquare = 0x33bf;
  28015. t.mwsquare = 0x33bd;
  28016. t.n = 0x006e;
  28017. t.nabengali = 0x09a8;
  28018. t.nabla = 0x2207;
  28019. t.nacute = 0x0144;
  28020. t.nadeva = 0x0928;
  28021. t.nagujarati = 0x0aa8;
  28022. t.nagurmukhi = 0x0a28;
  28023. t.nahiragana = 0x306a;
  28024. t.nakatakana = 0x30ca;
  28025. t.nakatakanahalfwidth = 0xff85;
  28026. t.napostrophe = 0x0149;
  28027. t.nasquare = 0x3381;
  28028. t.nbopomofo = 0x310b;
  28029. t.nbspace = 0x00a0;
  28030. t.ncaron = 0x0148;
  28031. t.ncedilla = 0x0146;
  28032. t.ncircle = 0x24dd;
  28033. t.ncircumflexbelow = 0x1e4b;
  28034. t.ncommaaccent = 0x0146;
  28035. t.ndotaccent = 0x1e45;
  28036. t.ndotbelow = 0x1e47;
  28037. t.nehiragana = 0x306d;
  28038. t.nekatakana = 0x30cd;
  28039. t.nekatakanahalfwidth = 0xff88;
  28040. t.newsheqelsign = 0x20aa;
  28041. t.nfsquare = 0x338b;
  28042. t.ngabengali = 0x0999;
  28043. t.ngadeva = 0x0919;
  28044. t.ngagujarati = 0x0a99;
  28045. t.ngagurmukhi = 0x0a19;
  28046. t.ngonguthai = 0x0e07;
  28047. t.nhiragana = 0x3093;
  28048. t.nhookleft = 0x0272;
  28049. t.nhookretroflex = 0x0273;
  28050. t.nieunacirclekorean = 0x326f;
  28051. t.nieunaparenkorean = 0x320f;
  28052. t.nieuncieuckorean = 0x3135;
  28053. t.nieuncirclekorean = 0x3261;
  28054. t.nieunhieuhkorean = 0x3136;
  28055. t.nieunkorean = 0x3134;
  28056. t.nieunpansioskorean = 0x3168;
  28057. t.nieunparenkorean = 0x3201;
  28058. t.nieunsioskorean = 0x3167;
  28059. t.nieuntikeutkorean = 0x3166;
  28060. t.nihiragana = 0x306b;
  28061. t.nikatakana = 0x30cb;
  28062. t.nikatakanahalfwidth = 0xff86;
  28063. t.nikhahitleftthai = 0xf899;
  28064. t.nikhahitthai = 0x0e4d;
  28065. t.nine = 0x0039;
  28066. t.ninearabic = 0x0669;
  28067. t.ninebengali = 0x09ef;
  28068. t.ninecircle = 0x2468;
  28069. t.ninecircleinversesansserif = 0x2792;
  28070. t.ninedeva = 0x096f;
  28071. t.ninegujarati = 0x0aef;
  28072. t.ninegurmukhi = 0x0a6f;
  28073. t.ninehackarabic = 0x0669;
  28074. t.ninehangzhou = 0x3029;
  28075. t.nineideographicparen = 0x3228;
  28076. t.nineinferior = 0x2089;
  28077. t.ninemonospace = 0xff19;
  28078. t.nineoldstyle = 0xf739;
  28079. t.nineparen = 0x247c;
  28080. t.nineperiod = 0x2490;
  28081. t.ninepersian = 0x06f9;
  28082. t.nineroman = 0x2178;
  28083. t.ninesuperior = 0x2079;
  28084. t.nineteencircle = 0x2472;
  28085. t.nineteenparen = 0x2486;
  28086. t.nineteenperiod = 0x249a;
  28087. t.ninethai = 0x0e59;
  28088. t.nj = 0x01cc;
  28089. t.njecyrillic = 0x045a;
  28090. t.nkatakana = 0x30f3;
  28091. t.nkatakanahalfwidth = 0xff9d;
  28092. t.nlegrightlong = 0x019e;
  28093. t.nlinebelow = 0x1e49;
  28094. t.nmonospace = 0xff4e;
  28095. t.nmsquare = 0x339a;
  28096. t.nnabengali = 0x09a3;
  28097. t.nnadeva = 0x0923;
  28098. t.nnagujarati = 0x0aa3;
  28099. t.nnagurmukhi = 0x0a23;
  28100. t.nnnadeva = 0x0929;
  28101. t.nohiragana = 0x306e;
  28102. t.nokatakana = 0x30ce;
  28103. t.nokatakanahalfwidth = 0xff89;
  28104. t.nonbreakingspace = 0x00a0;
  28105. t.nonenthai = 0x0e13;
  28106. t.nonuthai = 0x0e19;
  28107. t.noonarabic = 0x0646;
  28108. t.noonfinalarabic = 0xfee6;
  28109. t.noonghunnaarabic = 0x06ba;
  28110. t.noonghunnafinalarabic = 0xfb9f;
  28111. t.nooninitialarabic = 0xfee7;
  28112. t.noonjeeminitialarabic = 0xfcd2;
  28113. t.noonjeemisolatedarabic = 0xfc4b;
  28114. t.noonmedialarabic = 0xfee8;
  28115. t.noonmeeminitialarabic = 0xfcd5;
  28116. t.noonmeemisolatedarabic = 0xfc4e;
  28117. t.noonnoonfinalarabic = 0xfc8d;
  28118. t.notcontains = 0x220c;
  28119. t.notelement = 0x2209;
  28120. t.notelementof = 0x2209;
  28121. t.notequal = 0x2260;
  28122. t.notgreater = 0x226f;
  28123. t.notgreaternorequal = 0x2271;
  28124. t.notgreaternorless = 0x2279;
  28125. t.notidentical = 0x2262;
  28126. t.notless = 0x226e;
  28127. t.notlessnorequal = 0x2270;
  28128. t.notparallel = 0x2226;
  28129. t.notprecedes = 0x2280;
  28130. t.notsubset = 0x2284;
  28131. t.notsucceeds = 0x2281;
  28132. t.notsuperset = 0x2285;
  28133. t.nowarmenian = 0x0576;
  28134. t.nparen = 0x24a9;
  28135. t.nssquare = 0x33b1;
  28136. t.nsuperior = 0x207f;
  28137. t.ntilde = 0x00f1;
  28138. t.nu = 0x03bd;
  28139. t.nuhiragana = 0x306c;
  28140. t.nukatakana = 0x30cc;
  28141. t.nukatakanahalfwidth = 0xff87;
  28142. t.nuktabengali = 0x09bc;
  28143. t.nuktadeva = 0x093c;
  28144. t.nuktagujarati = 0x0abc;
  28145. t.nuktagurmukhi = 0x0a3c;
  28146. t.numbersign = 0x0023;
  28147. t.numbersignmonospace = 0xff03;
  28148. t.numbersignsmall = 0xfe5f;
  28149. t.numeralsigngreek = 0x0374;
  28150. t.numeralsignlowergreek = 0x0375;
  28151. t.numero = 0x2116;
  28152. t.nun = 0x05e0;
  28153. t.nundagesh = 0xfb40;
  28154. t.nundageshhebrew = 0xfb40;
  28155. t.nunhebrew = 0x05e0;
  28156. t.nvsquare = 0x33b5;
  28157. t.nwsquare = 0x33bb;
  28158. t.nyabengali = 0x099e;
  28159. t.nyadeva = 0x091e;
  28160. t.nyagujarati = 0x0a9e;
  28161. t.nyagurmukhi = 0x0a1e;
  28162. t.o = 0x006f;
  28163. t.oacute = 0x00f3;
  28164. t.oangthai = 0x0e2d;
  28165. t.obarred = 0x0275;
  28166. t.obarredcyrillic = 0x04e9;
  28167. t.obarreddieresiscyrillic = 0x04eb;
  28168. t.obengali = 0x0993;
  28169. t.obopomofo = 0x311b;
  28170. t.obreve = 0x014f;
  28171. t.ocandradeva = 0x0911;
  28172. t.ocandragujarati = 0x0a91;
  28173. t.ocandravowelsigndeva = 0x0949;
  28174. t.ocandravowelsigngujarati = 0x0ac9;
  28175. t.ocaron = 0x01d2;
  28176. t.ocircle = 0x24de;
  28177. t.ocircumflex = 0x00f4;
  28178. t.ocircumflexacute = 0x1ed1;
  28179. t.ocircumflexdotbelow = 0x1ed9;
  28180. t.ocircumflexgrave = 0x1ed3;
  28181. t.ocircumflexhookabove = 0x1ed5;
  28182. t.ocircumflextilde = 0x1ed7;
  28183. t.ocyrillic = 0x043e;
  28184. t.odblacute = 0x0151;
  28185. t.odblgrave = 0x020d;
  28186. t.odeva = 0x0913;
  28187. t.odieresis = 0x00f6;
  28188. t.odieresiscyrillic = 0x04e7;
  28189. t.odotbelow = 0x1ecd;
  28190. t.oe = 0x0153;
  28191. t.oekorean = 0x315a;
  28192. t.ogonek = 0x02db;
  28193. t.ogonekcmb = 0x0328;
  28194. t.ograve = 0x00f2;
  28195. t.ogujarati = 0x0a93;
  28196. t.oharmenian = 0x0585;
  28197. t.ohiragana = 0x304a;
  28198. t.ohookabove = 0x1ecf;
  28199. t.ohorn = 0x01a1;
  28200. t.ohornacute = 0x1edb;
  28201. t.ohorndotbelow = 0x1ee3;
  28202. t.ohorngrave = 0x1edd;
  28203. t.ohornhookabove = 0x1edf;
  28204. t.ohorntilde = 0x1ee1;
  28205. t.ohungarumlaut = 0x0151;
  28206. t.oi = 0x01a3;
  28207. t.oinvertedbreve = 0x020f;
  28208. t.okatakana = 0x30aa;
  28209. t.okatakanahalfwidth = 0xff75;
  28210. t.okorean = 0x3157;
  28211. t.olehebrew = 0x05ab;
  28212. t.omacron = 0x014d;
  28213. t.omacronacute = 0x1e53;
  28214. t.omacrongrave = 0x1e51;
  28215. t.omdeva = 0x0950;
  28216. t.omega = 0x03c9;
  28217. t.omega1 = 0x03d6;
  28218. t.omegacyrillic = 0x0461;
  28219. t.omegalatinclosed = 0x0277;
  28220. t.omegaroundcyrillic = 0x047b;
  28221. t.omegatitlocyrillic = 0x047d;
  28222. t.omegatonos = 0x03ce;
  28223. t.omgujarati = 0x0ad0;
  28224. t.omicron = 0x03bf;
  28225. t.omicrontonos = 0x03cc;
  28226. t.omonospace = 0xff4f;
  28227. t.one = 0x0031;
  28228. t.onearabic = 0x0661;
  28229. t.onebengali = 0x09e7;
  28230. t.onecircle = 0x2460;
  28231. t.onecircleinversesansserif = 0x278a;
  28232. t.onedeva = 0x0967;
  28233. t.onedotenleader = 0x2024;
  28234. t.oneeighth = 0x215b;
  28235. t.onefitted = 0xf6dc;
  28236. t.onegujarati = 0x0ae7;
  28237. t.onegurmukhi = 0x0a67;
  28238. t.onehackarabic = 0x0661;
  28239. t.onehalf = 0x00bd;
  28240. t.onehangzhou = 0x3021;
  28241. t.oneideographicparen = 0x3220;
  28242. t.oneinferior = 0x2081;
  28243. t.onemonospace = 0xff11;
  28244. t.onenumeratorbengali = 0x09f4;
  28245. t.oneoldstyle = 0xf731;
  28246. t.oneparen = 0x2474;
  28247. t.oneperiod = 0x2488;
  28248. t.onepersian = 0x06f1;
  28249. t.onequarter = 0x00bc;
  28250. t.oneroman = 0x2170;
  28251. t.onesuperior = 0x00b9;
  28252. t.onethai = 0x0e51;
  28253. t.onethird = 0x2153;
  28254. t.oogonek = 0x01eb;
  28255. t.oogonekmacron = 0x01ed;
  28256. t.oogurmukhi = 0x0a13;
  28257. t.oomatragurmukhi = 0x0a4b;
  28258. t.oopen = 0x0254;
  28259. t.oparen = 0x24aa;
  28260. t.openbullet = 0x25e6;
  28261. t.option = 0x2325;
  28262. t.ordfeminine = 0x00aa;
  28263. t.ordmasculine = 0x00ba;
  28264. t.orthogonal = 0x221f;
  28265. t.oshortdeva = 0x0912;
  28266. t.oshortvowelsigndeva = 0x094a;
  28267. t.oslash = 0x00f8;
  28268. t.oslashacute = 0x01ff;
  28269. t.osmallhiragana = 0x3049;
  28270. t.osmallkatakana = 0x30a9;
  28271. t.osmallkatakanahalfwidth = 0xff6b;
  28272. t.ostrokeacute = 0x01ff;
  28273. t.osuperior = 0xf6f0;
  28274. t.otcyrillic = 0x047f;
  28275. t.otilde = 0x00f5;
  28276. t.otildeacute = 0x1e4d;
  28277. t.otildedieresis = 0x1e4f;
  28278. t.oubopomofo = 0x3121;
  28279. t.overline = 0x203e;
  28280. t.overlinecenterline = 0xfe4a;
  28281. t.overlinecmb = 0x0305;
  28282. t.overlinedashed = 0xfe49;
  28283. t.overlinedblwavy = 0xfe4c;
  28284. t.overlinewavy = 0xfe4b;
  28285. t.overscore = 0x00af;
  28286. t.ovowelsignbengali = 0x09cb;
  28287. t.ovowelsigndeva = 0x094b;
  28288. t.ovowelsigngujarati = 0x0acb;
  28289. t.p = 0x0070;
  28290. t.paampssquare = 0x3380;
  28291. t.paasentosquare = 0x332b;
  28292. t.pabengali = 0x09aa;
  28293. t.pacute = 0x1e55;
  28294. t.padeva = 0x092a;
  28295. t.pagedown = 0x21df;
  28296. t.pageup = 0x21de;
  28297. t.pagujarati = 0x0aaa;
  28298. t.pagurmukhi = 0x0a2a;
  28299. t.pahiragana = 0x3071;
  28300. t.paiyannoithai = 0x0e2f;
  28301. t.pakatakana = 0x30d1;
  28302. t.palatalizationcyrilliccmb = 0x0484;
  28303. t.palochkacyrillic = 0x04c0;
  28304. t.pansioskorean = 0x317f;
  28305. t.paragraph = 0x00b6;
  28306. t.parallel = 0x2225;
  28307. t.parenleft = 0x0028;
  28308. t.parenleftaltonearabic = 0xfd3e;
  28309. t.parenleftbt = 0xf8ed;
  28310. t.parenleftex = 0xf8ec;
  28311. t.parenleftinferior = 0x208d;
  28312. t.parenleftmonospace = 0xff08;
  28313. t.parenleftsmall = 0xfe59;
  28314. t.parenleftsuperior = 0x207d;
  28315. t.parenlefttp = 0xf8eb;
  28316. t.parenleftvertical = 0xfe35;
  28317. t.parenright = 0x0029;
  28318. t.parenrightaltonearabic = 0xfd3f;
  28319. t.parenrightbt = 0xf8f8;
  28320. t.parenrightex = 0xf8f7;
  28321. t.parenrightinferior = 0x208e;
  28322. t.parenrightmonospace = 0xff09;
  28323. t.parenrightsmall = 0xfe5a;
  28324. t.parenrightsuperior = 0x207e;
  28325. t.parenrighttp = 0xf8f6;
  28326. t.parenrightvertical = 0xfe36;
  28327. t.partialdiff = 0x2202;
  28328. t.paseqhebrew = 0x05c0;
  28329. t.pashtahebrew = 0x0599;
  28330. t.pasquare = 0x33a9;
  28331. t.patah = 0x05b7;
  28332. t.patah11 = 0x05b7;
  28333. t.patah1d = 0x05b7;
  28334. t.patah2a = 0x05b7;
  28335. t.patahhebrew = 0x05b7;
  28336. t.patahnarrowhebrew = 0x05b7;
  28337. t.patahquarterhebrew = 0x05b7;
  28338. t.patahwidehebrew = 0x05b7;
  28339. t.pazerhebrew = 0x05a1;
  28340. t.pbopomofo = 0x3106;
  28341. t.pcircle = 0x24df;
  28342. t.pdotaccent = 0x1e57;
  28343. t.pe = 0x05e4;
  28344. t.pecyrillic = 0x043f;
  28345. t.pedagesh = 0xfb44;
  28346. t.pedageshhebrew = 0xfb44;
  28347. t.peezisquare = 0x333b;
  28348. t.pefinaldageshhebrew = 0xfb43;
  28349. t.peharabic = 0x067e;
  28350. t.peharmenian = 0x057a;
  28351. t.pehebrew = 0x05e4;
  28352. t.pehfinalarabic = 0xfb57;
  28353. t.pehinitialarabic = 0xfb58;
  28354. t.pehiragana = 0x307a;
  28355. t.pehmedialarabic = 0xfb59;
  28356. t.pekatakana = 0x30da;
  28357. t.pemiddlehookcyrillic = 0x04a7;
  28358. t.perafehebrew = 0xfb4e;
  28359. t.percent = 0x0025;
  28360. t.percentarabic = 0x066a;
  28361. t.percentmonospace = 0xff05;
  28362. t.percentsmall = 0xfe6a;
  28363. t.period = 0x002e;
  28364. t.periodarmenian = 0x0589;
  28365. t.periodcentered = 0x00b7;
  28366. t.periodhalfwidth = 0xff61;
  28367. t.periodinferior = 0xf6e7;
  28368. t.periodmonospace = 0xff0e;
  28369. t.periodsmall = 0xfe52;
  28370. t.periodsuperior = 0xf6e8;
  28371. t.perispomenigreekcmb = 0x0342;
  28372. t.perpendicular = 0x22a5;
  28373. t.perthousand = 0x2030;
  28374. t.peseta = 0x20a7;
  28375. t.pfsquare = 0x338a;
  28376. t.phabengali = 0x09ab;
  28377. t.phadeva = 0x092b;
  28378. t.phagujarati = 0x0aab;
  28379. t.phagurmukhi = 0x0a2b;
  28380. t.phi = 0x03c6;
  28381. t.phi1 = 0x03d5;
  28382. t.phieuphacirclekorean = 0x327a;
  28383. t.phieuphaparenkorean = 0x321a;
  28384. t.phieuphcirclekorean = 0x326c;
  28385. t.phieuphkorean = 0x314d;
  28386. t.phieuphparenkorean = 0x320c;
  28387. t.philatin = 0x0278;
  28388. t.phinthuthai = 0x0e3a;
  28389. t.phisymbolgreek = 0x03d5;
  28390. t.phook = 0x01a5;
  28391. t.phophanthai = 0x0e1e;
  28392. t.phophungthai = 0x0e1c;
  28393. t.phosamphaothai = 0x0e20;
  28394. t.pi = 0x03c0;
  28395. t.pieupacirclekorean = 0x3273;
  28396. t.pieupaparenkorean = 0x3213;
  28397. t.pieupcieuckorean = 0x3176;
  28398. t.pieupcirclekorean = 0x3265;
  28399. t.pieupkiyeokkorean = 0x3172;
  28400. t.pieupkorean = 0x3142;
  28401. t.pieupparenkorean = 0x3205;
  28402. t.pieupsioskiyeokkorean = 0x3174;
  28403. t.pieupsioskorean = 0x3144;
  28404. t.pieupsiostikeutkorean = 0x3175;
  28405. t.pieupthieuthkorean = 0x3177;
  28406. t.pieuptikeutkorean = 0x3173;
  28407. t.pihiragana = 0x3074;
  28408. t.pikatakana = 0x30d4;
  28409. t.pisymbolgreek = 0x03d6;
  28410. t.piwrarmenian = 0x0583;
  28411. t.plus = 0x002b;
  28412. t.plusbelowcmb = 0x031f;
  28413. t.pluscircle = 0x2295;
  28414. t.plusminus = 0x00b1;
  28415. t.plusmod = 0x02d6;
  28416. t.plusmonospace = 0xff0b;
  28417. t.plussmall = 0xfe62;
  28418. t.plussuperior = 0x207a;
  28419. t.pmonospace = 0xff50;
  28420. t.pmsquare = 0x33d8;
  28421. t.pohiragana = 0x307d;
  28422. t.pointingindexdownwhite = 0x261f;
  28423. t.pointingindexleftwhite = 0x261c;
  28424. t.pointingindexrightwhite = 0x261e;
  28425. t.pointingindexupwhite = 0x261d;
  28426. t.pokatakana = 0x30dd;
  28427. t.poplathai = 0x0e1b;
  28428. t.postalmark = 0x3012;
  28429. t.postalmarkface = 0x3020;
  28430. t.pparen = 0x24ab;
  28431. t.precedes = 0x227a;
  28432. t.prescription = 0x211e;
  28433. t.primemod = 0x02b9;
  28434. t.primereversed = 0x2035;
  28435. t.product = 0x220f;
  28436. t.projective = 0x2305;
  28437. t.prolongedkana = 0x30fc;
  28438. t.propellor = 0x2318;
  28439. t.propersubset = 0x2282;
  28440. t.propersuperset = 0x2283;
  28441. t.proportion = 0x2237;
  28442. t.proportional = 0x221d;
  28443. t.psi = 0x03c8;
  28444. t.psicyrillic = 0x0471;
  28445. t.psilipneumatacyrilliccmb = 0x0486;
  28446. t.pssquare = 0x33b0;
  28447. t.puhiragana = 0x3077;
  28448. t.pukatakana = 0x30d7;
  28449. t.pvsquare = 0x33b4;
  28450. t.pwsquare = 0x33ba;
  28451. t.q = 0x0071;
  28452. t.qadeva = 0x0958;
  28453. t.qadmahebrew = 0x05a8;
  28454. t.qafarabic = 0x0642;
  28455. t.qaffinalarabic = 0xfed6;
  28456. t.qafinitialarabic = 0xfed7;
  28457. t.qafmedialarabic = 0xfed8;
  28458. t.qamats = 0x05b8;
  28459. t.qamats10 = 0x05b8;
  28460. t.qamats1a = 0x05b8;
  28461. t.qamats1c = 0x05b8;
  28462. t.qamats27 = 0x05b8;
  28463. t.qamats29 = 0x05b8;
  28464. t.qamats33 = 0x05b8;
  28465. t.qamatsde = 0x05b8;
  28466. t.qamatshebrew = 0x05b8;
  28467. t.qamatsnarrowhebrew = 0x05b8;
  28468. t.qamatsqatanhebrew = 0x05b8;
  28469. t.qamatsqatannarrowhebrew = 0x05b8;
  28470. t.qamatsqatanquarterhebrew = 0x05b8;
  28471. t.qamatsqatanwidehebrew = 0x05b8;
  28472. t.qamatsquarterhebrew = 0x05b8;
  28473. t.qamatswidehebrew = 0x05b8;
  28474. t.qarneyparahebrew = 0x059f;
  28475. t.qbopomofo = 0x3111;
  28476. t.qcircle = 0x24e0;
  28477. t.qhook = 0x02a0;
  28478. t.qmonospace = 0xff51;
  28479. t.qof = 0x05e7;
  28480. t.qofdagesh = 0xfb47;
  28481. t.qofdageshhebrew = 0xfb47;
  28482. t.qofhebrew = 0x05e7;
  28483. t.qparen = 0x24ac;
  28484. t.quarternote = 0x2669;
  28485. t.qubuts = 0x05bb;
  28486. t.qubuts18 = 0x05bb;
  28487. t.qubuts25 = 0x05bb;
  28488. t.qubuts31 = 0x05bb;
  28489. t.qubutshebrew = 0x05bb;
  28490. t.qubutsnarrowhebrew = 0x05bb;
  28491. t.qubutsquarterhebrew = 0x05bb;
  28492. t.qubutswidehebrew = 0x05bb;
  28493. t.question = 0x003f;
  28494. t.questionarabic = 0x061f;
  28495. t.questionarmenian = 0x055e;
  28496. t.questiondown = 0x00bf;
  28497. t.questiondownsmall = 0xf7bf;
  28498. t.questiongreek = 0x037e;
  28499. t.questionmonospace = 0xff1f;
  28500. t.questionsmall = 0xf73f;
  28501. t.quotedbl = 0x0022;
  28502. t.quotedblbase = 0x201e;
  28503. t.quotedblleft = 0x201c;
  28504. t.quotedblmonospace = 0xff02;
  28505. t.quotedblprime = 0x301e;
  28506. t.quotedblprimereversed = 0x301d;
  28507. t.quotedblright = 0x201d;
  28508. t.quoteleft = 0x2018;
  28509. t.quoteleftreversed = 0x201b;
  28510. t.quotereversed = 0x201b;
  28511. t.quoteright = 0x2019;
  28512. t.quoterightn = 0x0149;
  28513. t.quotesinglbase = 0x201a;
  28514. t.quotesingle = 0x0027;
  28515. t.quotesinglemonospace = 0xff07;
  28516. t.r = 0x0072;
  28517. t.raarmenian = 0x057c;
  28518. t.rabengali = 0x09b0;
  28519. t.racute = 0x0155;
  28520. t.radeva = 0x0930;
  28521. t.radical = 0x221a;
  28522. t.radicalex = 0xf8e5;
  28523. t.radoverssquare = 0x33ae;
  28524. t.radoverssquaredsquare = 0x33af;
  28525. t.radsquare = 0x33ad;
  28526. t.rafe = 0x05bf;
  28527. t.rafehebrew = 0x05bf;
  28528. t.ragujarati = 0x0ab0;
  28529. t.ragurmukhi = 0x0a30;
  28530. t.rahiragana = 0x3089;
  28531. t.rakatakana = 0x30e9;
  28532. t.rakatakanahalfwidth = 0xff97;
  28533. t.ralowerdiagonalbengali = 0x09f1;
  28534. t.ramiddlediagonalbengali = 0x09f0;
  28535. t.ramshorn = 0x0264;
  28536. t.ratio = 0x2236;
  28537. t.rbopomofo = 0x3116;
  28538. t.rcaron = 0x0159;
  28539. t.rcedilla = 0x0157;
  28540. t.rcircle = 0x24e1;
  28541. t.rcommaaccent = 0x0157;
  28542. t.rdblgrave = 0x0211;
  28543. t.rdotaccent = 0x1e59;
  28544. t.rdotbelow = 0x1e5b;
  28545. t.rdotbelowmacron = 0x1e5d;
  28546. t.referencemark = 0x203b;
  28547. t.reflexsubset = 0x2286;
  28548. t.reflexsuperset = 0x2287;
  28549. t.registered = 0x00ae;
  28550. t.registersans = 0xf8e8;
  28551. t.registerserif = 0xf6da;
  28552. t.reharabic = 0x0631;
  28553. t.reharmenian = 0x0580;
  28554. t.rehfinalarabic = 0xfeae;
  28555. t.rehiragana = 0x308c;
  28556. t.rekatakana = 0x30ec;
  28557. t.rekatakanahalfwidth = 0xff9a;
  28558. t.resh = 0x05e8;
  28559. t.reshdageshhebrew = 0xfb48;
  28560. t.reshhebrew = 0x05e8;
  28561. t.reversedtilde = 0x223d;
  28562. t.reviahebrew = 0x0597;
  28563. t.reviamugrashhebrew = 0x0597;
  28564. t.revlogicalnot = 0x2310;
  28565. t.rfishhook = 0x027e;
  28566. t.rfishhookreversed = 0x027f;
  28567. t.rhabengali = 0x09dd;
  28568. t.rhadeva = 0x095d;
  28569. t.rho = 0x03c1;
  28570. t.rhook = 0x027d;
  28571. t.rhookturned = 0x027b;
  28572. t.rhookturnedsuperior = 0x02b5;
  28573. t.rhosymbolgreek = 0x03f1;
  28574. t.rhotichookmod = 0x02de;
  28575. t.rieulacirclekorean = 0x3271;
  28576. t.rieulaparenkorean = 0x3211;
  28577. t.rieulcirclekorean = 0x3263;
  28578. t.rieulhieuhkorean = 0x3140;
  28579. t.rieulkiyeokkorean = 0x313a;
  28580. t.rieulkiyeoksioskorean = 0x3169;
  28581. t.rieulkorean = 0x3139;
  28582. t.rieulmieumkorean = 0x313b;
  28583. t.rieulpansioskorean = 0x316c;
  28584. t.rieulparenkorean = 0x3203;
  28585. t.rieulphieuphkorean = 0x313f;
  28586. t.rieulpieupkorean = 0x313c;
  28587. t.rieulpieupsioskorean = 0x316b;
  28588. t.rieulsioskorean = 0x313d;
  28589. t.rieulthieuthkorean = 0x313e;
  28590. t.rieultikeutkorean = 0x316a;
  28591. t.rieulyeorinhieuhkorean = 0x316d;
  28592. t.rightangle = 0x221f;
  28593. t.righttackbelowcmb = 0x0319;
  28594. t.righttriangle = 0x22bf;
  28595. t.rihiragana = 0x308a;
  28596. t.rikatakana = 0x30ea;
  28597. t.rikatakanahalfwidth = 0xff98;
  28598. t.ring = 0x02da;
  28599. t.ringbelowcmb = 0x0325;
  28600. t.ringcmb = 0x030a;
  28601. t.ringhalfleft = 0x02bf;
  28602. t.ringhalfleftarmenian = 0x0559;
  28603. t.ringhalfleftbelowcmb = 0x031c;
  28604. t.ringhalfleftcentered = 0x02d3;
  28605. t.ringhalfright = 0x02be;
  28606. t.ringhalfrightbelowcmb = 0x0339;
  28607. t.ringhalfrightcentered = 0x02d2;
  28608. t.rinvertedbreve = 0x0213;
  28609. t.rittorusquare = 0x3351;
  28610. t.rlinebelow = 0x1e5f;
  28611. t.rlongleg = 0x027c;
  28612. t.rlonglegturned = 0x027a;
  28613. t.rmonospace = 0xff52;
  28614. t.rohiragana = 0x308d;
  28615. t.rokatakana = 0x30ed;
  28616. t.rokatakanahalfwidth = 0xff9b;
  28617. t.roruathai = 0x0e23;
  28618. t.rparen = 0x24ad;
  28619. t.rrabengali = 0x09dc;
  28620. t.rradeva = 0x0931;
  28621. t.rragurmukhi = 0x0a5c;
  28622. t.rreharabic = 0x0691;
  28623. t.rrehfinalarabic = 0xfb8d;
  28624. t.rrvocalicbengali = 0x09e0;
  28625. t.rrvocalicdeva = 0x0960;
  28626. t.rrvocalicgujarati = 0x0ae0;
  28627. t.rrvocalicvowelsignbengali = 0x09c4;
  28628. t.rrvocalicvowelsigndeva = 0x0944;
  28629. t.rrvocalicvowelsigngujarati = 0x0ac4;
  28630. t.rsuperior = 0xf6f1;
  28631. t.rtblock = 0x2590;
  28632. t.rturned = 0x0279;
  28633. t.rturnedsuperior = 0x02b4;
  28634. t.ruhiragana = 0x308b;
  28635. t.rukatakana = 0x30eb;
  28636. t.rukatakanahalfwidth = 0xff99;
  28637. t.rupeemarkbengali = 0x09f2;
  28638. t.rupeesignbengali = 0x09f3;
  28639. t.rupiah = 0xf6dd;
  28640. t.ruthai = 0x0e24;
  28641. t.rvocalicbengali = 0x098b;
  28642. t.rvocalicdeva = 0x090b;
  28643. t.rvocalicgujarati = 0x0a8b;
  28644. t.rvocalicvowelsignbengali = 0x09c3;
  28645. t.rvocalicvowelsigndeva = 0x0943;
  28646. t.rvocalicvowelsigngujarati = 0x0ac3;
  28647. t.s = 0x0073;
  28648. t.sabengali = 0x09b8;
  28649. t.sacute = 0x015b;
  28650. t.sacutedotaccent = 0x1e65;
  28651. t.sadarabic = 0x0635;
  28652. t.sadeva = 0x0938;
  28653. t.sadfinalarabic = 0xfeba;
  28654. t.sadinitialarabic = 0xfebb;
  28655. t.sadmedialarabic = 0xfebc;
  28656. t.sagujarati = 0x0ab8;
  28657. t.sagurmukhi = 0x0a38;
  28658. t.sahiragana = 0x3055;
  28659. t.sakatakana = 0x30b5;
  28660. t.sakatakanahalfwidth = 0xff7b;
  28661. t.sallallahoualayhewasallamarabic = 0xfdfa;
  28662. t.samekh = 0x05e1;
  28663. t.samekhdagesh = 0xfb41;
  28664. t.samekhdageshhebrew = 0xfb41;
  28665. t.samekhhebrew = 0x05e1;
  28666. t.saraaathai = 0x0e32;
  28667. t.saraaethai = 0x0e41;
  28668. t.saraaimaimalaithai = 0x0e44;
  28669. t.saraaimaimuanthai = 0x0e43;
  28670. t.saraamthai = 0x0e33;
  28671. t.saraathai = 0x0e30;
  28672. t.saraethai = 0x0e40;
  28673. t.saraiileftthai = 0xf886;
  28674. t.saraiithai = 0x0e35;
  28675. t.saraileftthai = 0xf885;
  28676. t.saraithai = 0x0e34;
  28677. t.saraothai = 0x0e42;
  28678. t.saraueeleftthai = 0xf888;
  28679. t.saraueethai = 0x0e37;
  28680. t.saraueleftthai = 0xf887;
  28681. t.sarauethai = 0x0e36;
  28682. t.sarauthai = 0x0e38;
  28683. t.sarauuthai = 0x0e39;
  28684. t.sbopomofo = 0x3119;
  28685. t.scaron = 0x0161;
  28686. t.scarondotaccent = 0x1e67;
  28687. t.scedilla = 0x015f;
  28688. t.schwa = 0x0259;
  28689. t.schwacyrillic = 0x04d9;
  28690. t.schwadieresiscyrillic = 0x04db;
  28691. t.schwahook = 0x025a;
  28692. t.scircle = 0x24e2;
  28693. t.scircumflex = 0x015d;
  28694. t.scommaaccent = 0x0219;
  28695. t.sdotaccent = 0x1e61;
  28696. t.sdotbelow = 0x1e63;
  28697. t.sdotbelowdotaccent = 0x1e69;
  28698. t.seagullbelowcmb = 0x033c;
  28699. t.second = 0x2033;
  28700. t.secondtonechinese = 0x02ca;
  28701. t.section = 0x00a7;
  28702. t.seenarabic = 0x0633;
  28703. t.seenfinalarabic = 0xfeb2;
  28704. t.seeninitialarabic = 0xfeb3;
  28705. t.seenmedialarabic = 0xfeb4;
  28706. t.segol = 0x05b6;
  28707. t.segol13 = 0x05b6;
  28708. t.segol1f = 0x05b6;
  28709. t.segol2c = 0x05b6;
  28710. t.segolhebrew = 0x05b6;
  28711. t.segolnarrowhebrew = 0x05b6;
  28712. t.segolquarterhebrew = 0x05b6;
  28713. t.segoltahebrew = 0x0592;
  28714. t.segolwidehebrew = 0x05b6;
  28715. t.seharmenian = 0x057d;
  28716. t.sehiragana = 0x305b;
  28717. t.sekatakana = 0x30bb;
  28718. t.sekatakanahalfwidth = 0xff7e;
  28719. t.semicolon = 0x003b;
  28720. t.semicolonarabic = 0x061b;
  28721. t.semicolonmonospace = 0xff1b;
  28722. t.semicolonsmall = 0xfe54;
  28723. t.semivoicedmarkkana = 0x309c;
  28724. t.semivoicedmarkkanahalfwidth = 0xff9f;
  28725. t.sentisquare = 0x3322;
  28726. t.sentosquare = 0x3323;
  28727. t.seven = 0x0037;
  28728. t.sevenarabic = 0x0667;
  28729. t.sevenbengali = 0x09ed;
  28730. t.sevencircle = 0x2466;
  28731. t.sevencircleinversesansserif = 0x2790;
  28732. t.sevendeva = 0x096d;
  28733. t.seveneighths = 0x215e;
  28734. t.sevengujarati = 0x0aed;
  28735. t.sevengurmukhi = 0x0a6d;
  28736. t.sevenhackarabic = 0x0667;
  28737. t.sevenhangzhou = 0x3027;
  28738. t.sevenideographicparen = 0x3226;
  28739. t.seveninferior = 0x2087;
  28740. t.sevenmonospace = 0xff17;
  28741. t.sevenoldstyle = 0xf737;
  28742. t.sevenparen = 0x247a;
  28743. t.sevenperiod = 0x248e;
  28744. t.sevenpersian = 0x06f7;
  28745. t.sevenroman = 0x2176;
  28746. t.sevensuperior = 0x2077;
  28747. t.seventeencircle = 0x2470;
  28748. t.seventeenparen = 0x2484;
  28749. t.seventeenperiod = 0x2498;
  28750. t.seventhai = 0x0e57;
  28751. t.sfthyphen = 0x00ad;
  28752. t.shaarmenian = 0x0577;
  28753. t.shabengali = 0x09b6;
  28754. t.shacyrillic = 0x0448;
  28755. t.shaddaarabic = 0x0651;
  28756. t.shaddadammaarabic = 0xfc61;
  28757. t.shaddadammatanarabic = 0xfc5e;
  28758. t.shaddafathaarabic = 0xfc60;
  28759. t.shaddakasraarabic = 0xfc62;
  28760. t.shaddakasratanarabic = 0xfc5f;
  28761. t.shade = 0x2592;
  28762. t.shadedark = 0x2593;
  28763. t.shadelight = 0x2591;
  28764. t.shademedium = 0x2592;
  28765. t.shadeva = 0x0936;
  28766. t.shagujarati = 0x0ab6;
  28767. t.shagurmukhi = 0x0a36;
  28768. t.shalshelethebrew = 0x0593;
  28769. t.shbopomofo = 0x3115;
  28770. t.shchacyrillic = 0x0449;
  28771. t.sheenarabic = 0x0634;
  28772. t.sheenfinalarabic = 0xfeb6;
  28773. t.sheeninitialarabic = 0xfeb7;
  28774. t.sheenmedialarabic = 0xfeb8;
  28775. t.sheicoptic = 0x03e3;
  28776. t.sheqel = 0x20aa;
  28777. t.sheqelhebrew = 0x20aa;
  28778. t.sheva = 0x05b0;
  28779. t.sheva115 = 0x05b0;
  28780. t.sheva15 = 0x05b0;
  28781. t.sheva22 = 0x05b0;
  28782. t.sheva2e = 0x05b0;
  28783. t.shevahebrew = 0x05b0;
  28784. t.shevanarrowhebrew = 0x05b0;
  28785. t.shevaquarterhebrew = 0x05b0;
  28786. t.shevawidehebrew = 0x05b0;
  28787. t.shhacyrillic = 0x04bb;
  28788. t.shimacoptic = 0x03ed;
  28789. t.shin = 0x05e9;
  28790. t.shindagesh = 0xfb49;
  28791. t.shindageshhebrew = 0xfb49;
  28792. t.shindageshshindot = 0xfb2c;
  28793. t.shindageshshindothebrew = 0xfb2c;
  28794. t.shindageshsindot = 0xfb2d;
  28795. t.shindageshsindothebrew = 0xfb2d;
  28796. t.shindothebrew = 0x05c1;
  28797. t.shinhebrew = 0x05e9;
  28798. t.shinshindot = 0xfb2a;
  28799. t.shinshindothebrew = 0xfb2a;
  28800. t.shinsindot = 0xfb2b;
  28801. t.shinsindothebrew = 0xfb2b;
  28802. t.shook = 0x0282;
  28803. t.sigma = 0x03c3;
  28804. t.sigma1 = 0x03c2;
  28805. t.sigmafinal = 0x03c2;
  28806. t.sigmalunatesymbolgreek = 0x03f2;
  28807. t.sihiragana = 0x3057;
  28808. t.sikatakana = 0x30b7;
  28809. t.sikatakanahalfwidth = 0xff7c;
  28810. t.siluqhebrew = 0x05bd;
  28811. t.siluqlefthebrew = 0x05bd;
  28812. t.similar = 0x223c;
  28813. t.sindothebrew = 0x05c2;
  28814. t.siosacirclekorean = 0x3274;
  28815. t.siosaparenkorean = 0x3214;
  28816. t.sioscieuckorean = 0x317e;
  28817. t.sioscirclekorean = 0x3266;
  28818. t.sioskiyeokkorean = 0x317a;
  28819. t.sioskorean = 0x3145;
  28820. t.siosnieunkorean = 0x317b;
  28821. t.siosparenkorean = 0x3206;
  28822. t.siospieupkorean = 0x317d;
  28823. t.siostikeutkorean = 0x317c;
  28824. t.six = 0x0036;
  28825. t.sixarabic = 0x0666;
  28826. t.sixbengali = 0x09ec;
  28827. t.sixcircle = 0x2465;
  28828. t.sixcircleinversesansserif = 0x278f;
  28829. t.sixdeva = 0x096c;
  28830. t.sixgujarati = 0x0aec;
  28831. t.sixgurmukhi = 0x0a6c;
  28832. t.sixhackarabic = 0x0666;
  28833. t.sixhangzhou = 0x3026;
  28834. t.sixideographicparen = 0x3225;
  28835. t.sixinferior = 0x2086;
  28836. t.sixmonospace = 0xff16;
  28837. t.sixoldstyle = 0xf736;
  28838. t.sixparen = 0x2479;
  28839. t.sixperiod = 0x248d;
  28840. t.sixpersian = 0x06f6;
  28841. t.sixroman = 0x2175;
  28842. t.sixsuperior = 0x2076;
  28843. t.sixteencircle = 0x246f;
  28844. t.sixteencurrencydenominatorbengali = 0x09f9;
  28845. t.sixteenparen = 0x2483;
  28846. t.sixteenperiod = 0x2497;
  28847. t.sixthai = 0x0e56;
  28848. t.slash = 0x002f;
  28849. t.slashmonospace = 0xff0f;
  28850. t.slong = 0x017f;
  28851. t.slongdotaccent = 0x1e9b;
  28852. t.smileface = 0x263a;
  28853. t.smonospace = 0xff53;
  28854. t.sofpasuqhebrew = 0x05c3;
  28855. t.softhyphen = 0x00ad;
  28856. t.softsigncyrillic = 0x044c;
  28857. t.sohiragana = 0x305d;
  28858. t.sokatakana = 0x30bd;
  28859. t.sokatakanahalfwidth = 0xff7f;
  28860. t.soliduslongoverlaycmb = 0x0338;
  28861. t.solidusshortoverlaycmb = 0x0337;
  28862. t.sorusithai = 0x0e29;
  28863. t.sosalathai = 0x0e28;
  28864. t.sosothai = 0x0e0b;
  28865. t.sosuathai = 0x0e2a;
  28866. t.space = 0x0020;
  28867. t.spacehackarabic = 0x0020;
  28868. t.spade = 0x2660;
  28869. t.spadesuitblack = 0x2660;
  28870. t.spadesuitwhite = 0x2664;
  28871. t.sparen = 0x24ae;
  28872. t.squarebelowcmb = 0x033b;
  28873. t.squarecc = 0x33c4;
  28874. t.squarecm = 0x339d;
  28875. t.squarediagonalcrosshatchfill = 0x25a9;
  28876. t.squarehorizontalfill = 0x25a4;
  28877. t.squarekg = 0x338f;
  28878. t.squarekm = 0x339e;
  28879. t.squarekmcapital = 0x33ce;
  28880. t.squareln = 0x33d1;
  28881. t.squarelog = 0x33d2;
  28882. t.squaremg = 0x338e;
  28883. t.squaremil = 0x33d5;
  28884. t.squaremm = 0x339c;
  28885. t.squaremsquared = 0x33a1;
  28886. t.squareorthogonalcrosshatchfill = 0x25a6;
  28887. t.squareupperlefttolowerrightfill = 0x25a7;
  28888. t.squareupperrighttolowerleftfill = 0x25a8;
  28889. t.squareverticalfill = 0x25a5;
  28890. t.squarewhitewithsmallblack = 0x25a3;
  28891. t.srsquare = 0x33db;
  28892. t.ssabengali = 0x09b7;
  28893. t.ssadeva = 0x0937;
  28894. t.ssagujarati = 0x0ab7;
  28895. t.ssangcieuckorean = 0x3149;
  28896. t.ssanghieuhkorean = 0x3185;
  28897. t.ssangieungkorean = 0x3180;
  28898. t.ssangkiyeokkorean = 0x3132;
  28899. t.ssangnieunkorean = 0x3165;
  28900. t.ssangpieupkorean = 0x3143;
  28901. t.ssangsioskorean = 0x3146;
  28902. t.ssangtikeutkorean = 0x3138;
  28903. t.ssuperior = 0xf6f2;
  28904. t.sterling = 0x00a3;
  28905. t.sterlingmonospace = 0xffe1;
  28906. t.strokelongoverlaycmb = 0x0336;
  28907. t.strokeshortoverlaycmb = 0x0335;
  28908. t.subset = 0x2282;
  28909. t.subsetnotequal = 0x228a;
  28910. t.subsetorequal = 0x2286;
  28911. t.succeeds = 0x227b;
  28912. t.suchthat = 0x220b;
  28913. t.suhiragana = 0x3059;
  28914. t.sukatakana = 0x30b9;
  28915. t.sukatakanahalfwidth = 0xff7d;
  28916. t.sukunarabic = 0x0652;
  28917. t.summation = 0x2211;
  28918. t.sun = 0x263c;
  28919. t.superset = 0x2283;
  28920. t.supersetnotequal = 0x228b;
  28921. t.supersetorequal = 0x2287;
  28922. t.svsquare = 0x33dc;
  28923. t.syouwaerasquare = 0x337c;
  28924. t.t = 0x0074;
  28925. t.tabengali = 0x09a4;
  28926. t.tackdown = 0x22a4;
  28927. t.tackleft = 0x22a3;
  28928. t.tadeva = 0x0924;
  28929. t.tagujarati = 0x0aa4;
  28930. t.tagurmukhi = 0x0a24;
  28931. t.taharabic = 0x0637;
  28932. t.tahfinalarabic = 0xfec2;
  28933. t.tahinitialarabic = 0xfec3;
  28934. t.tahiragana = 0x305f;
  28935. t.tahmedialarabic = 0xfec4;
  28936. t.taisyouerasquare = 0x337d;
  28937. t.takatakana = 0x30bf;
  28938. t.takatakanahalfwidth = 0xff80;
  28939. t.tatweelarabic = 0x0640;
  28940. t.tau = 0x03c4;
  28941. t.tav = 0x05ea;
  28942. t.tavdages = 0xfb4a;
  28943. t.tavdagesh = 0xfb4a;
  28944. t.tavdageshhebrew = 0xfb4a;
  28945. t.tavhebrew = 0x05ea;
  28946. t.tbar = 0x0167;
  28947. t.tbopomofo = 0x310a;
  28948. t.tcaron = 0x0165;
  28949. t.tccurl = 0x02a8;
  28950. t.tcedilla = 0x0163;
  28951. t.tcheharabic = 0x0686;
  28952. t.tchehfinalarabic = 0xfb7b;
  28953. t.tchehinitialarabic = 0xfb7c;
  28954. t.tchehmedialarabic = 0xfb7d;
  28955. t.tcircle = 0x24e3;
  28956. t.tcircumflexbelow = 0x1e71;
  28957. t.tcommaaccent = 0x0163;
  28958. t.tdieresis = 0x1e97;
  28959. t.tdotaccent = 0x1e6b;
  28960. t.tdotbelow = 0x1e6d;
  28961. t.tecyrillic = 0x0442;
  28962. t.tedescendercyrillic = 0x04ad;
  28963. t.teharabic = 0x062a;
  28964. t.tehfinalarabic = 0xfe96;
  28965. t.tehhahinitialarabic = 0xfca2;
  28966. t.tehhahisolatedarabic = 0xfc0c;
  28967. t.tehinitialarabic = 0xfe97;
  28968. t.tehiragana = 0x3066;
  28969. t.tehjeeminitialarabic = 0xfca1;
  28970. t.tehjeemisolatedarabic = 0xfc0b;
  28971. t.tehmarbutaarabic = 0x0629;
  28972. t.tehmarbutafinalarabic = 0xfe94;
  28973. t.tehmedialarabic = 0xfe98;
  28974. t.tehmeeminitialarabic = 0xfca4;
  28975. t.tehmeemisolatedarabic = 0xfc0e;
  28976. t.tehnoonfinalarabic = 0xfc73;
  28977. t.tekatakana = 0x30c6;
  28978. t.tekatakanahalfwidth = 0xff83;
  28979. t.telephone = 0x2121;
  28980. t.telephoneblack = 0x260e;
  28981. t.telishagedolahebrew = 0x05a0;
  28982. t.telishaqetanahebrew = 0x05a9;
  28983. t.tencircle = 0x2469;
  28984. t.tenideographicparen = 0x3229;
  28985. t.tenparen = 0x247d;
  28986. t.tenperiod = 0x2491;
  28987. t.tenroman = 0x2179;
  28988. t.tesh = 0x02a7;
  28989. t.tet = 0x05d8;
  28990. t.tetdagesh = 0xfb38;
  28991. t.tetdageshhebrew = 0xfb38;
  28992. t.tethebrew = 0x05d8;
  28993. t.tetsecyrillic = 0x04b5;
  28994. t.tevirhebrew = 0x059b;
  28995. t.tevirlefthebrew = 0x059b;
  28996. t.thabengali = 0x09a5;
  28997. t.thadeva = 0x0925;
  28998. t.thagujarati = 0x0aa5;
  28999. t.thagurmukhi = 0x0a25;
  29000. t.thalarabic = 0x0630;
  29001. t.thalfinalarabic = 0xfeac;
  29002. t.thanthakhatlowleftthai = 0xf898;
  29003. t.thanthakhatlowrightthai = 0xf897;
  29004. t.thanthakhatthai = 0x0e4c;
  29005. t.thanthakhatupperleftthai = 0xf896;
  29006. t.theharabic = 0x062b;
  29007. t.thehfinalarabic = 0xfe9a;
  29008. t.thehinitialarabic = 0xfe9b;
  29009. t.thehmedialarabic = 0xfe9c;
  29010. t.thereexists = 0x2203;
  29011. t.therefore = 0x2234;
  29012. t.theta = 0x03b8;
  29013. t.theta1 = 0x03d1;
  29014. t.thetasymbolgreek = 0x03d1;
  29015. t.thieuthacirclekorean = 0x3279;
  29016. t.thieuthaparenkorean = 0x3219;
  29017. t.thieuthcirclekorean = 0x326b;
  29018. t.thieuthkorean = 0x314c;
  29019. t.thieuthparenkorean = 0x320b;
  29020. t.thirteencircle = 0x246c;
  29021. t.thirteenparen = 0x2480;
  29022. t.thirteenperiod = 0x2494;
  29023. t.thonangmonthothai = 0x0e11;
  29024. t.thook = 0x01ad;
  29025. t.thophuthaothai = 0x0e12;
  29026. t.thorn = 0x00fe;
  29027. t.thothahanthai = 0x0e17;
  29028. t.thothanthai = 0x0e10;
  29029. t.thothongthai = 0x0e18;
  29030. t.thothungthai = 0x0e16;
  29031. t.thousandcyrillic = 0x0482;
  29032. t.thousandsseparatorarabic = 0x066c;
  29033. t.thousandsseparatorpersian = 0x066c;
  29034. t.three = 0x0033;
  29035. t.threearabic = 0x0663;
  29036. t.threebengali = 0x09e9;
  29037. t.threecircle = 0x2462;
  29038. t.threecircleinversesansserif = 0x278c;
  29039. t.threedeva = 0x0969;
  29040. t.threeeighths = 0x215c;
  29041. t.threegujarati = 0x0ae9;
  29042. t.threegurmukhi = 0x0a69;
  29043. t.threehackarabic = 0x0663;
  29044. t.threehangzhou = 0x3023;
  29045. t.threeideographicparen = 0x3222;
  29046. t.threeinferior = 0x2083;
  29047. t.threemonospace = 0xff13;
  29048. t.threenumeratorbengali = 0x09f6;
  29049. t.threeoldstyle = 0xf733;
  29050. t.threeparen = 0x2476;
  29051. t.threeperiod = 0x248a;
  29052. t.threepersian = 0x06f3;
  29053. t.threequarters = 0x00be;
  29054. t.threequartersemdash = 0xf6de;
  29055. t.threeroman = 0x2172;
  29056. t.threesuperior = 0x00b3;
  29057. t.threethai = 0x0e53;
  29058. t.thzsquare = 0x3394;
  29059. t.tihiragana = 0x3061;
  29060. t.tikatakana = 0x30c1;
  29061. t.tikatakanahalfwidth = 0xff81;
  29062. t.tikeutacirclekorean = 0x3270;
  29063. t.tikeutaparenkorean = 0x3210;
  29064. t.tikeutcirclekorean = 0x3262;
  29065. t.tikeutkorean = 0x3137;
  29066. t.tikeutparenkorean = 0x3202;
  29067. t.tilde = 0x02dc;
  29068. t.tildebelowcmb = 0x0330;
  29069. t.tildecmb = 0x0303;
  29070. t.tildecomb = 0x0303;
  29071. t.tildedoublecmb = 0x0360;
  29072. t.tildeoperator = 0x223c;
  29073. t.tildeoverlaycmb = 0x0334;
  29074. t.tildeverticalcmb = 0x033e;
  29075. t.timescircle = 0x2297;
  29076. t.tipehahebrew = 0x0596;
  29077. t.tipehalefthebrew = 0x0596;
  29078. t.tippigurmukhi = 0x0a70;
  29079. t.titlocyrilliccmb = 0x0483;
  29080. t.tiwnarmenian = 0x057f;
  29081. t.tlinebelow = 0x1e6f;
  29082. t.tmonospace = 0xff54;
  29083. t.toarmenian = 0x0569;
  29084. t.tohiragana = 0x3068;
  29085. t.tokatakana = 0x30c8;
  29086. t.tokatakanahalfwidth = 0xff84;
  29087. t.tonebarextrahighmod = 0x02e5;
  29088. t.tonebarextralowmod = 0x02e9;
  29089. t.tonebarhighmod = 0x02e6;
  29090. t.tonebarlowmod = 0x02e8;
  29091. t.tonebarmidmod = 0x02e7;
  29092. t.tonefive = 0x01bd;
  29093. t.tonesix = 0x0185;
  29094. t.tonetwo = 0x01a8;
  29095. t.tonos = 0x0384;
  29096. t.tonsquare = 0x3327;
  29097. t.topatakthai = 0x0e0f;
  29098. t.tortoiseshellbracketleft = 0x3014;
  29099. t.tortoiseshellbracketleftsmall = 0xfe5d;
  29100. t.tortoiseshellbracketleftvertical = 0xfe39;
  29101. t.tortoiseshellbracketright = 0x3015;
  29102. t.tortoiseshellbracketrightsmall = 0xfe5e;
  29103. t.tortoiseshellbracketrightvertical = 0xfe3a;
  29104. t.totaothai = 0x0e15;
  29105. t.tpalatalhook = 0x01ab;
  29106. t.tparen = 0x24af;
  29107. t.trademark = 0x2122;
  29108. t.trademarksans = 0xf8ea;
  29109. t.trademarkserif = 0xf6db;
  29110. t.tretroflexhook = 0x0288;
  29111. t.triagdn = 0x25bc;
  29112. t.triaglf = 0x25c4;
  29113. t.triagrt = 0x25ba;
  29114. t.triagup = 0x25b2;
  29115. t.ts = 0x02a6;
  29116. t.tsadi = 0x05e6;
  29117. t.tsadidagesh = 0xfb46;
  29118. t.tsadidageshhebrew = 0xfb46;
  29119. t.tsadihebrew = 0x05e6;
  29120. t.tsecyrillic = 0x0446;
  29121. t.tsere = 0x05b5;
  29122. t.tsere12 = 0x05b5;
  29123. t.tsere1e = 0x05b5;
  29124. t.tsere2b = 0x05b5;
  29125. t.tserehebrew = 0x05b5;
  29126. t.tserenarrowhebrew = 0x05b5;
  29127. t.tserequarterhebrew = 0x05b5;
  29128. t.tserewidehebrew = 0x05b5;
  29129. t.tshecyrillic = 0x045b;
  29130. t.tsuperior = 0xf6f3;
  29131. t.ttabengali = 0x099f;
  29132. t.ttadeva = 0x091f;
  29133. t.ttagujarati = 0x0a9f;
  29134. t.ttagurmukhi = 0x0a1f;
  29135. t.tteharabic = 0x0679;
  29136. t.ttehfinalarabic = 0xfb67;
  29137. t.ttehinitialarabic = 0xfb68;
  29138. t.ttehmedialarabic = 0xfb69;
  29139. t.tthabengali = 0x09a0;
  29140. t.tthadeva = 0x0920;
  29141. t.tthagujarati = 0x0aa0;
  29142. t.tthagurmukhi = 0x0a20;
  29143. t.tturned = 0x0287;
  29144. t.tuhiragana = 0x3064;
  29145. t.tukatakana = 0x30c4;
  29146. t.tukatakanahalfwidth = 0xff82;
  29147. t.tusmallhiragana = 0x3063;
  29148. t.tusmallkatakana = 0x30c3;
  29149. t.tusmallkatakanahalfwidth = 0xff6f;
  29150. t.twelvecircle = 0x246b;
  29151. t.twelveparen = 0x247f;
  29152. t.twelveperiod = 0x2493;
  29153. t.twelveroman = 0x217b;
  29154. t.twentycircle = 0x2473;
  29155. t.twentyhangzhou = 0x5344;
  29156. t.twentyparen = 0x2487;
  29157. t.twentyperiod = 0x249b;
  29158. t.two = 0x0032;
  29159. t.twoarabic = 0x0662;
  29160. t.twobengali = 0x09e8;
  29161. t.twocircle = 0x2461;
  29162. t.twocircleinversesansserif = 0x278b;
  29163. t.twodeva = 0x0968;
  29164. t.twodotenleader = 0x2025;
  29165. t.twodotleader = 0x2025;
  29166. t.twodotleadervertical = 0xfe30;
  29167. t.twogujarati = 0x0ae8;
  29168. t.twogurmukhi = 0x0a68;
  29169. t.twohackarabic = 0x0662;
  29170. t.twohangzhou = 0x3022;
  29171. t.twoideographicparen = 0x3221;
  29172. t.twoinferior = 0x2082;
  29173. t.twomonospace = 0xff12;
  29174. t.twonumeratorbengali = 0x09f5;
  29175. t.twooldstyle = 0xf732;
  29176. t.twoparen = 0x2475;
  29177. t.twoperiod = 0x2489;
  29178. t.twopersian = 0x06f2;
  29179. t.tworoman = 0x2171;
  29180. t.twostroke = 0x01bb;
  29181. t.twosuperior = 0x00b2;
  29182. t.twothai = 0x0e52;
  29183. t.twothirds = 0x2154;
  29184. t.u = 0x0075;
  29185. t.uacute = 0x00fa;
  29186. t.ubar = 0x0289;
  29187. t.ubengali = 0x0989;
  29188. t.ubopomofo = 0x3128;
  29189. t.ubreve = 0x016d;
  29190. t.ucaron = 0x01d4;
  29191. t.ucircle = 0x24e4;
  29192. t.ucircumflex = 0x00fb;
  29193. t.ucircumflexbelow = 0x1e77;
  29194. t.ucyrillic = 0x0443;
  29195. t.udattadeva = 0x0951;
  29196. t.udblacute = 0x0171;
  29197. t.udblgrave = 0x0215;
  29198. t.udeva = 0x0909;
  29199. t.udieresis = 0x00fc;
  29200. t.udieresisacute = 0x01d8;
  29201. t.udieresisbelow = 0x1e73;
  29202. t.udieresiscaron = 0x01da;
  29203. t.udieresiscyrillic = 0x04f1;
  29204. t.udieresisgrave = 0x01dc;
  29205. t.udieresismacron = 0x01d6;
  29206. t.udotbelow = 0x1ee5;
  29207. t.ugrave = 0x00f9;
  29208. t.ugujarati = 0x0a89;
  29209. t.ugurmukhi = 0x0a09;
  29210. t.uhiragana = 0x3046;
  29211. t.uhookabove = 0x1ee7;
  29212. t.uhorn = 0x01b0;
  29213. t.uhornacute = 0x1ee9;
  29214. t.uhorndotbelow = 0x1ef1;
  29215. t.uhorngrave = 0x1eeb;
  29216. t.uhornhookabove = 0x1eed;
  29217. t.uhorntilde = 0x1eef;
  29218. t.uhungarumlaut = 0x0171;
  29219. t.uhungarumlautcyrillic = 0x04f3;
  29220. t.uinvertedbreve = 0x0217;
  29221. t.ukatakana = 0x30a6;
  29222. t.ukatakanahalfwidth = 0xff73;
  29223. t.ukcyrillic = 0x0479;
  29224. t.ukorean = 0x315c;
  29225. t.umacron = 0x016b;
  29226. t.umacroncyrillic = 0x04ef;
  29227. t.umacrondieresis = 0x1e7b;
  29228. t.umatragurmukhi = 0x0a41;
  29229. t.umonospace = 0xff55;
  29230. t.underscore = 0x005f;
  29231. t.underscoredbl = 0x2017;
  29232. t.underscoremonospace = 0xff3f;
  29233. t.underscorevertical = 0xfe33;
  29234. t.underscorewavy = 0xfe4f;
  29235. t.union = 0x222a;
  29236. t.universal = 0x2200;
  29237. t.uogonek = 0x0173;
  29238. t.uparen = 0x24b0;
  29239. t.upblock = 0x2580;
  29240. t.upperdothebrew = 0x05c4;
  29241. t.upsilon = 0x03c5;
  29242. t.upsilondieresis = 0x03cb;
  29243. t.upsilondieresistonos = 0x03b0;
  29244. t.upsilonlatin = 0x028a;
  29245. t.upsilontonos = 0x03cd;
  29246. t.uptackbelowcmb = 0x031d;
  29247. t.uptackmod = 0x02d4;
  29248. t.uragurmukhi = 0x0a73;
  29249. t.uring = 0x016f;
  29250. t.ushortcyrillic = 0x045e;
  29251. t.usmallhiragana = 0x3045;
  29252. t.usmallkatakana = 0x30a5;
  29253. t.usmallkatakanahalfwidth = 0xff69;
  29254. t.ustraightcyrillic = 0x04af;
  29255. t.ustraightstrokecyrillic = 0x04b1;
  29256. t.utilde = 0x0169;
  29257. t.utildeacute = 0x1e79;
  29258. t.utildebelow = 0x1e75;
  29259. t.uubengali = 0x098a;
  29260. t.uudeva = 0x090a;
  29261. t.uugujarati = 0x0a8a;
  29262. t.uugurmukhi = 0x0a0a;
  29263. t.uumatragurmukhi = 0x0a42;
  29264. t.uuvowelsignbengali = 0x09c2;
  29265. t.uuvowelsigndeva = 0x0942;
  29266. t.uuvowelsigngujarati = 0x0ac2;
  29267. t.uvowelsignbengali = 0x09c1;
  29268. t.uvowelsigndeva = 0x0941;
  29269. t.uvowelsigngujarati = 0x0ac1;
  29270. t.v = 0x0076;
  29271. t.vadeva = 0x0935;
  29272. t.vagujarati = 0x0ab5;
  29273. t.vagurmukhi = 0x0a35;
  29274. t.vakatakana = 0x30f7;
  29275. t.vav = 0x05d5;
  29276. t.vavdagesh = 0xfb35;
  29277. t.vavdagesh65 = 0xfb35;
  29278. t.vavdageshhebrew = 0xfb35;
  29279. t.vavhebrew = 0x05d5;
  29280. t.vavholam = 0xfb4b;
  29281. t.vavholamhebrew = 0xfb4b;
  29282. t.vavvavhebrew = 0x05f0;
  29283. t.vavyodhebrew = 0x05f1;
  29284. t.vcircle = 0x24e5;
  29285. t.vdotbelow = 0x1e7f;
  29286. t.vecyrillic = 0x0432;
  29287. t.veharabic = 0x06a4;
  29288. t.vehfinalarabic = 0xfb6b;
  29289. t.vehinitialarabic = 0xfb6c;
  29290. t.vehmedialarabic = 0xfb6d;
  29291. t.vekatakana = 0x30f9;
  29292. t.venus = 0x2640;
  29293. t.verticalbar = 0x007c;
  29294. t.verticallineabovecmb = 0x030d;
  29295. t.verticallinebelowcmb = 0x0329;
  29296. t.verticallinelowmod = 0x02cc;
  29297. t.verticallinemod = 0x02c8;
  29298. t.vewarmenian = 0x057e;
  29299. t.vhook = 0x028b;
  29300. t.vikatakana = 0x30f8;
  29301. t.viramabengali = 0x09cd;
  29302. t.viramadeva = 0x094d;
  29303. t.viramagujarati = 0x0acd;
  29304. t.visargabengali = 0x0983;
  29305. t.visargadeva = 0x0903;
  29306. t.visargagujarati = 0x0a83;
  29307. t.vmonospace = 0xff56;
  29308. t.voarmenian = 0x0578;
  29309. t.voicediterationhiragana = 0x309e;
  29310. t.voicediterationkatakana = 0x30fe;
  29311. t.voicedmarkkana = 0x309b;
  29312. t.voicedmarkkanahalfwidth = 0xff9e;
  29313. t.vokatakana = 0x30fa;
  29314. t.vparen = 0x24b1;
  29315. t.vtilde = 0x1e7d;
  29316. t.vturned = 0x028c;
  29317. t.vuhiragana = 0x3094;
  29318. t.vukatakana = 0x30f4;
  29319. t.w = 0x0077;
  29320. t.wacute = 0x1e83;
  29321. t.waekorean = 0x3159;
  29322. t.wahiragana = 0x308f;
  29323. t.wakatakana = 0x30ef;
  29324. t.wakatakanahalfwidth = 0xff9c;
  29325. t.wakorean = 0x3158;
  29326. t.wasmallhiragana = 0x308e;
  29327. t.wasmallkatakana = 0x30ee;
  29328. t.wattosquare = 0x3357;
  29329. t.wavedash = 0x301c;
  29330. t.wavyunderscorevertical = 0xfe34;
  29331. t.wawarabic = 0x0648;
  29332. t.wawfinalarabic = 0xfeee;
  29333. t.wawhamzaabovearabic = 0x0624;
  29334. t.wawhamzaabovefinalarabic = 0xfe86;
  29335. t.wbsquare = 0x33dd;
  29336. t.wcircle = 0x24e6;
  29337. t.wcircumflex = 0x0175;
  29338. t.wdieresis = 0x1e85;
  29339. t.wdotaccent = 0x1e87;
  29340. t.wdotbelow = 0x1e89;
  29341. t.wehiragana = 0x3091;
  29342. t.weierstrass = 0x2118;
  29343. t.wekatakana = 0x30f1;
  29344. t.wekorean = 0x315e;
  29345. t.weokorean = 0x315d;
  29346. t.wgrave = 0x1e81;
  29347. t.whitebullet = 0x25e6;
  29348. t.whitecircle = 0x25cb;
  29349. t.whitecircleinverse = 0x25d9;
  29350. t.whitecornerbracketleft = 0x300e;
  29351. t.whitecornerbracketleftvertical = 0xfe43;
  29352. t.whitecornerbracketright = 0x300f;
  29353. t.whitecornerbracketrightvertical = 0xfe44;
  29354. t.whitediamond = 0x25c7;
  29355. t.whitediamondcontainingblacksmalldiamond = 0x25c8;
  29356. t.whitedownpointingsmalltriangle = 0x25bf;
  29357. t.whitedownpointingtriangle = 0x25bd;
  29358. t.whiteleftpointingsmalltriangle = 0x25c3;
  29359. t.whiteleftpointingtriangle = 0x25c1;
  29360. t.whitelenticularbracketleft = 0x3016;
  29361. t.whitelenticularbracketright = 0x3017;
  29362. t.whiterightpointingsmalltriangle = 0x25b9;
  29363. t.whiterightpointingtriangle = 0x25b7;
  29364. t.whitesmallsquare = 0x25ab;
  29365. t.whitesmilingface = 0x263a;
  29366. t.whitesquare = 0x25a1;
  29367. t.whitestar = 0x2606;
  29368. t.whitetelephone = 0x260f;
  29369. t.whitetortoiseshellbracketleft = 0x3018;
  29370. t.whitetortoiseshellbracketright = 0x3019;
  29371. t.whiteuppointingsmalltriangle = 0x25b5;
  29372. t.whiteuppointingtriangle = 0x25b3;
  29373. t.wihiragana = 0x3090;
  29374. t.wikatakana = 0x30f0;
  29375. t.wikorean = 0x315f;
  29376. t.wmonospace = 0xff57;
  29377. t.wohiragana = 0x3092;
  29378. t.wokatakana = 0x30f2;
  29379. t.wokatakanahalfwidth = 0xff66;
  29380. t.won = 0x20a9;
  29381. t.wonmonospace = 0xffe6;
  29382. t.wowaenthai = 0x0e27;
  29383. t.wparen = 0x24b2;
  29384. t.wring = 0x1e98;
  29385. t.wsuperior = 0x02b7;
  29386. t.wturned = 0x028d;
  29387. t.wynn = 0x01bf;
  29388. t.x = 0x0078;
  29389. t.xabovecmb = 0x033d;
  29390. t.xbopomofo = 0x3112;
  29391. t.xcircle = 0x24e7;
  29392. t.xdieresis = 0x1e8d;
  29393. t.xdotaccent = 0x1e8b;
  29394. t.xeharmenian = 0x056d;
  29395. t.xi = 0x03be;
  29396. t.xmonospace = 0xff58;
  29397. t.xparen = 0x24b3;
  29398. t.xsuperior = 0x02e3;
  29399. t.y = 0x0079;
  29400. t.yaadosquare = 0x334e;
  29401. t.yabengali = 0x09af;
  29402. t.yacute = 0x00fd;
  29403. t.yadeva = 0x092f;
  29404. t.yaekorean = 0x3152;
  29405. t.yagujarati = 0x0aaf;
  29406. t.yagurmukhi = 0x0a2f;
  29407. t.yahiragana = 0x3084;
  29408. t.yakatakana = 0x30e4;
  29409. t.yakatakanahalfwidth = 0xff94;
  29410. t.yakorean = 0x3151;
  29411. t.yamakkanthai = 0x0e4e;
  29412. t.yasmallhiragana = 0x3083;
  29413. t.yasmallkatakana = 0x30e3;
  29414. t.yasmallkatakanahalfwidth = 0xff6c;
  29415. t.yatcyrillic = 0x0463;
  29416. t.ycircle = 0x24e8;
  29417. t.ycircumflex = 0x0177;
  29418. t.ydieresis = 0x00ff;
  29419. t.ydotaccent = 0x1e8f;
  29420. t.ydotbelow = 0x1ef5;
  29421. t.yeharabic = 0x064a;
  29422. t.yehbarreearabic = 0x06d2;
  29423. t.yehbarreefinalarabic = 0xfbaf;
  29424. t.yehfinalarabic = 0xfef2;
  29425. t.yehhamzaabovearabic = 0x0626;
  29426. t.yehhamzaabovefinalarabic = 0xfe8a;
  29427. t.yehhamzaaboveinitialarabic = 0xfe8b;
  29428. t.yehhamzaabovemedialarabic = 0xfe8c;
  29429. t.yehinitialarabic = 0xfef3;
  29430. t.yehmedialarabic = 0xfef4;
  29431. t.yehmeeminitialarabic = 0xfcdd;
  29432. t.yehmeemisolatedarabic = 0xfc58;
  29433. t.yehnoonfinalarabic = 0xfc94;
  29434. t.yehthreedotsbelowarabic = 0x06d1;
  29435. t.yekorean = 0x3156;
  29436. t.yen = 0x00a5;
  29437. t.yenmonospace = 0xffe5;
  29438. t.yeokorean = 0x3155;
  29439. t.yeorinhieuhkorean = 0x3186;
  29440. t.yerahbenyomohebrew = 0x05aa;
  29441. t.yerahbenyomolefthebrew = 0x05aa;
  29442. t.yericyrillic = 0x044b;
  29443. t.yerudieresiscyrillic = 0x04f9;
  29444. t.yesieungkorean = 0x3181;
  29445. t.yesieungpansioskorean = 0x3183;
  29446. t.yesieungsioskorean = 0x3182;
  29447. t.yetivhebrew = 0x059a;
  29448. t.ygrave = 0x1ef3;
  29449. t.yhook = 0x01b4;
  29450. t.yhookabove = 0x1ef7;
  29451. t.yiarmenian = 0x0575;
  29452. t.yicyrillic = 0x0457;
  29453. t.yikorean = 0x3162;
  29454. t.yinyang = 0x262f;
  29455. t.yiwnarmenian = 0x0582;
  29456. t.ymonospace = 0xff59;
  29457. t.yod = 0x05d9;
  29458. t.yoddagesh = 0xfb39;
  29459. t.yoddageshhebrew = 0xfb39;
  29460. t.yodhebrew = 0x05d9;
  29461. t.yodyodhebrew = 0x05f2;
  29462. t.yodyodpatahhebrew = 0xfb1f;
  29463. t.yohiragana = 0x3088;
  29464. t.yoikorean = 0x3189;
  29465. t.yokatakana = 0x30e8;
  29466. t.yokatakanahalfwidth = 0xff96;
  29467. t.yokorean = 0x315b;
  29468. t.yosmallhiragana = 0x3087;
  29469. t.yosmallkatakana = 0x30e7;
  29470. t.yosmallkatakanahalfwidth = 0xff6e;
  29471. t.yotgreek = 0x03f3;
  29472. t.yoyaekorean = 0x3188;
  29473. t.yoyakorean = 0x3187;
  29474. t.yoyakthai = 0x0e22;
  29475. t.yoyingthai = 0x0e0d;
  29476. t.yparen = 0x24b4;
  29477. t.ypogegrammeni = 0x037a;
  29478. t.ypogegrammenigreekcmb = 0x0345;
  29479. t.yr = 0x01a6;
  29480. t.yring = 0x1e99;
  29481. t.ysuperior = 0x02b8;
  29482. t.ytilde = 0x1ef9;
  29483. t.yturned = 0x028e;
  29484. t.yuhiragana = 0x3086;
  29485. t.yuikorean = 0x318c;
  29486. t.yukatakana = 0x30e6;
  29487. t.yukatakanahalfwidth = 0xff95;
  29488. t.yukorean = 0x3160;
  29489. t.yusbigcyrillic = 0x046b;
  29490. t.yusbigiotifiedcyrillic = 0x046d;
  29491. t.yuslittlecyrillic = 0x0467;
  29492. t.yuslittleiotifiedcyrillic = 0x0469;
  29493. t.yusmallhiragana = 0x3085;
  29494. t.yusmallkatakana = 0x30e5;
  29495. t.yusmallkatakanahalfwidth = 0xff6d;
  29496. t.yuyekorean = 0x318b;
  29497. t.yuyeokorean = 0x318a;
  29498. t.yyabengali = 0x09df;
  29499. t.yyadeva = 0x095f;
  29500. t.z = 0x007a;
  29501. t.zaarmenian = 0x0566;
  29502. t.zacute = 0x017a;
  29503. t.zadeva = 0x095b;
  29504. t.zagurmukhi = 0x0a5b;
  29505. t.zaharabic = 0x0638;
  29506. t.zahfinalarabic = 0xfec6;
  29507. t.zahinitialarabic = 0xfec7;
  29508. t.zahiragana = 0x3056;
  29509. t.zahmedialarabic = 0xfec8;
  29510. t.zainarabic = 0x0632;
  29511. t.zainfinalarabic = 0xfeb0;
  29512. t.zakatakana = 0x30b6;
  29513. t.zaqefgadolhebrew = 0x0595;
  29514. t.zaqefqatanhebrew = 0x0594;
  29515. t.zarqahebrew = 0x0598;
  29516. t.zayin = 0x05d6;
  29517. t.zayindagesh = 0xfb36;
  29518. t.zayindageshhebrew = 0xfb36;
  29519. t.zayinhebrew = 0x05d6;
  29520. t.zbopomofo = 0x3117;
  29521. t.zcaron = 0x017e;
  29522. t.zcircle = 0x24e9;
  29523. t.zcircumflex = 0x1e91;
  29524. t.zcurl = 0x0291;
  29525. t.zdot = 0x017c;
  29526. t.zdotaccent = 0x017c;
  29527. t.zdotbelow = 0x1e93;
  29528. t.zecyrillic = 0x0437;
  29529. t.zedescendercyrillic = 0x0499;
  29530. t.zedieresiscyrillic = 0x04df;
  29531. t.zehiragana = 0x305c;
  29532. t.zekatakana = 0x30bc;
  29533. t.zero = 0x0030;
  29534. t.zeroarabic = 0x0660;
  29535. t.zerobengali = 0x09e6;
  29536. t.zerodeva = 0x0966;
  29537. t.zerogujarati = 0x0ae6;
  29538. t.zerogurmukhi = 0x0a66;
  29539. t.zerohackarabic = 0x0660;
  29540. t.zeroinferior = 0x2080;
  29541. t.zeromonospace = 0xff10;
  29542. t.zerooldstyle = 0xf730;
  29543. t.zeropersian = 0x06f0;
  29544. t.zerosuperior = 0x2070;
  29545. t.zerothai = 0x0e50;
  29546. t.zerowidthjoiner = 0xfeff;
  29547. t.zerowidthnonjoiner = 0x200c;
  29548. t.zerowidthspace = 0x200b;
  29549. t.zeta = 0x03b6;
  29550. t.zhbopomofo = 0x3113;
  29551. t.zhearmenian = 0x056a;
  29552. t.zhebrevecyrillic = 0x04c2;
  29553. t.zhecyrillic = 0x0436;
  29554. t.zhedescendercyrillic = 0x0497;
  29555. t.zhedieresiscyrillic = 0x04dd;
  29556. t.zihiragana = 0x3058;
  29557. t.zikatakana = 0x30b8;
  29558. t.zinorhebrew = 0x05ae;
  29559. t.zlinebelow = 0x1e95;
  29560. t.zmonospace = 0xff5a;
  29561. t.zohiragana = 0x305e;
  29562. t.zokatakana = 0x30be;
  29563. t.zparen = 0x24b5;
  29564. t.zretroflexhook = 0x0290;
  29565. t.zstroke = 0x01b6;
  29566. t.zuhiragana = 0x305a;
  29567. t.zukatakana = 0x30ba;
  29568. t[".notdef"] = 0x0000;
  29569. t.angbracketleftbig = 0x2329;
  29570. t.angbracketleftBig = 0x2329;
  29571. t.angbracketleftbigg = 0x2329;
  29572. t.angbracketleftBigg = 0x2329;
  29573. t.angbracketrightBig = 0x232a;
  29574. t.angbracketrightbig = 0x232a;
  29575. t.angbracketrightBigg = 0x232a;
  29576. t.angbracketrightbigg = 0x232a;
  29577. t.arrowhookleft = 0x21aa;
  29578. t.arrowhookright = 0x21a9;
  29579. t.arrowlefttophalf = 0x21bc;
  29580. t.arrowleftbothalf = 0x21bd;
  29581. t.arrownortheast = 0x2197;
  29582. t.arrownorthwest = 0x2196;
  29583. t.arrowrighttophalf = 0x21c0;
  29584. t.arrowrightbothalf = 0x21c1;
  29585. t.arrowsoutheast = 0x2198;
  29586. t.arrowsouthwest = 0x2199;
  29587. t.backslashbig = 0x2216;
  29588. t.backslashBig = 0x2216;
  29589. t.backslashBigg = 0x2216;
  29590. t.backslashbigg = 0x2216;
  29591. t.bardbl = 0x2016;
  29592. t.bracehtipdownleft = 0xfe37;
  29593. t.bracehtipdownright = 0xfe37;
  29594. t.bracehtipupleft = 0xfe38;
  29595. t.bracehtipupright = 0xfe38;
  29596. t.braceleftBig = 0x007b;
  29597. t.braceleftbig = 0x007b;
  29598. t.braceleftbigg = 0x007b;
  29599. t.braceleftBigg = 0x007b;
  29600. t.bracerightBig = 0x007d;
  29601. t.bracerightbig = 0x007d;
  29602. t.bracerightbigg = 0x007d;
  29603. t.bracerightBigg = 0x007d;
  29604. t.bracketleftbig = 0x005b;
  29605. t.bracketleftBig = 0x005b;
  29606. t.bracketleftbigg = 0x005b;
  29607. t.bracketleftBigg = 0x005b;
  29608. t.bracketrightBig = 0x005d;
  29609. t.bracketrightbig = 0x005d;
  29610. t.bracketrightbigg = 0x005d;
  29611. t.bracketrightBigg = 0x005d;
  29612. t.ceilingleftbig = 0x2308;
  29613. t.ceilingleftBig = 0x2308;
  29614. t.ceilingleftBigg = 0x2308;
  29615. t.ceilingleftbigg = 0x2308;
  29616. t.ceilingrightbig = 0x2309;
  29617. t.ceilingrightBig = 0x2309;
  29618. t.ceilingrightbigg = 0x2309;
  29619. t.ceilingrightBigg = 0x2309;
  29620. t.circledotdisplay = 0x2299;
  29621. t.circledottext = 0x2299;
  29622. t.circlemultiplydisplay = 0x2297;
  29623. t.circlemultiplytext = 0x2297;
  29624. t.circleplusdisplay = 0x2295;
  29625. t.circleplustext = 0x2295;
  29626. t.contintegraldisplay = 0x222e;
  29627. t.contintegraltext = 0x222e;
  29628. t.coproductdisplay = 0x2210;
  29629. t.coproducttext = 0x2210;
  29630. t.floorleftBig = 0x230a;
  29631. t.floorleftbig = 0x230a;
  29632. t.floorleftbigg = 0x230a;
  29633. t.floorleftBigg = 0x230a;
  29634. t.floorrightbig = 0x230b;
  29635. t.floorrightBig = 0x230b;
  29636. t.floorrightBigg = 0x230b;
  29637. t.floorrightbigg = 0x230b;
  29638. t.hatwide = 0x0302;
  29639. t.hatwider = 0x0302;
  29640. t.hatwidest = 0x0302;
  29641. t.intercal = 0x1d40;
  29642. t.integraldisplay = 0x222b;
  29643. t.integraltext = 0x222b;
  29644. t.intersectiondisplay = 0x22c2;
  29645. t.intersectiontext = 0x22c2;
  29646. t.logicalanddisplay = 0x2227;
  29647. t.logicalandtext = 0x2227;
  29648. t.logicalordisplay = 0x2228;
  29649. t.logicalortext = 0x2228;
  29650. t.parenleftBig = 0x0028;
  29651. t.parenleftbig = 0x0028;
  29652. t.parenleftBigg = 0x0028;
  29653. t.parenleftbigg = 0x0028;
  29654. t.parenrightBig = 0x0029;
  29655. t.parenrightbig = 0x0029;
  29656. t.parenrightBigg = 0x0029;
  29657. t.parenrightbigg = 0x0029;
  29658. t.prime = 0x2032;
  29659. t.productdisplay = 0x220f;
  29660. t.producttext = 0x220f;
  29661. t.radicalbig = 0x221a;
  29662. t.radicalBig = 0x221a;
  29663. t.radicalBigg = 0x221a;
  29664. t.radicalbigg = 0x221a;
  29665. t.radicalbt = 0x221a;
  29666. t.radicaltp = 0x221a;
  29667. t.radicalvertex = 0x221a;
  29668. t.slashbig = 0x002f;
  29669. t.slashBig = 0x002f;
  29670. t.slashBigg = 0x002f;
  29671. t.slashbigg = 0x002f;
  29672. t.summationdisplay = 0x2211;
  29673. t.summationtext = 0x2211;
  29674. t.tildewide = 0x02dc;
  29675. t.tildewider = 0x02dc;
  29676. t.tildewidest = 0x02dc;
  29677. t.uniondisplay = 0x22c3;
  29678. t.unionmultidisplay = 0x228e;
  29679. t.unionmultitext = 0x228e;
  29680. t.unionsqdisplay = 0x2294;
  29681. t.unionsqtext = 0x2294;
  29682. t.uniontext = 0x22c3;
  29683. t.vextenddouble = 0x2225;
  29684. t.vextendsingle = 0x2223;
  29685. });
  29686. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  29687. t.space = 0x0020;
  29688. t.a1 = 0x2701;
  29689. t.a2 = 0x2702;
  29690. t.a202 = 0x2703;
  29691. t.a3 = 0x2704;
  29692. t.a4 = 0x260e;
  29693. t.a5 = 0x2706;
  29694. t.a119 = 0x2707;
  29695. t.a118 = 0x2708;
  29696. t.a117 = 0x2709;
  29697. t.a11 = 0x261b;
  29698. t.a12 = 0x261e;
  29699. t.a13 = 0x270c;
  29700. t.a14 = 0x270d;
  29701. t.a15 = 0x270e;
  29702. t.a16 = 0x270f;
  29703. t.a105 = 0x2710;
  29704. t.a17 = 0x2711;
  29705. t.a18 = 0x2712;
  29706. t.a19 = 0x2713;
  29707. t.a20 = 0x2714;
  29708. t.a21 = 0x2715;
  29709. t.a22 = 0x2716;
  29710. t.a23 = 0x2717;
  29711. t.a24 = 0x2718;
  29712. t.a25 = 0x2719;
  29713. t.a26 = 0x271a;
  29714. t.a27 = 0x271b;
  29715. t.a28 = 0x271c;
  29716. t.a6 = 0x271d;
  29717. t.a7 = 0x271e;
  29718. t.a8 = 0x271f;
  29719. t.a9 = 0x2720;
  29720. t.a10 = 0x2721;
  29721. t.a29 = 0x2722;
  29722. t.a30 = 0x2723;
  29723. t.a31 = 0x2724;
  29724. t.a32 = 0x2725;
  29725. t.a33 = 0x2726;
  29726. t.a34 = 0x2727;
  29727. t.a35 = 0x2605;
  29728. t.a36 = 0x2729;
  29729. t.a37 = 0x272a;
  29730. t.a38 = 0x272b;
  29731. t.a39 = 0x272c;
  29732. t.a40 = 0x272d;
  29733. t.a41 = 0x272e;
  29734. t.a42 = 0x272f;
  29735. t.a43 = 0x2730;
  29736. t.a44 = 0x2731;
  29737. t.a45 = 0x2732;
  29738. t.a46 = 0x2733;
  29739. t.a47 = 0x2734;
  29740. t.a48 = 0x2735;
  29741. t.a49 = 0x2736;
  29742. t.a50 = 0x2737;
  29743. t.a51 = 0x2738;
  29744. t.a52 = 0x2739;
  29745. t.a53 = 0x273a;
  29746. t.a54 = 0x273b;
  29747. t.a55 = 0x273c;
  29748. t.a56 = 0x273d;
  29749. t.a57 = 0x273e;
  29750. t.a58 = 0x273f;
  29751. t.a59 = 0x2740;
  29752. t.a60 = 0x2741;
  29753. t.a61 = 0x2742;
  29754. t.a62 = 0x2743;
  29755. t.a63 = 0x2744;
  29756. t.a64 = 0x2745;
  29757. t.a65 = 0x2746;
  29758. t.a66 = 0x2747;
  29759. t.a67 = 0x2748;
  29760. t.a68 = 0x2749;
  29761. t.a69 = 0x274a;
  29762. t.a70 = 0x274b;
  29763. t.a71 = 0x25cf;
  29764. t.a72 = 0x274d;
  29765. t.a73 = 0x25a0;
  29766. t.a74 = 0x274f;
  29767. t.a203 = 0x2750;
  29768. t.a75 = 0x2751;
  29769. t.a204 = 0x2752;
  29770. t.a76 = 0x25b2;
  29771. t.a77 = 0x25bc;
  29772. t.a78 = 0x25c6;
  29773. t.a79 = 0x2756;
  29774. t.a81 = 0x25d7;
  29775. t.a82 = 0x2758;
  29776. t.a83 = 0x2759;
  29777. t.a84 = 0x275a;
  29778. t.a97 = 0x275b;
  29779. t.a98 = 0x275c;
  29780. t.a99 = 0x275d;
  29781. t.a100 = 0x275e;
  29782. t.a101 = 0x2761;
  29783. t.a102 = 0x2762;
  29784. t.a103 = 0x2763;
  29785. t.a104 = 0x2764;
  29786. t.a106 = 0x2765;
  29787. t.a107 = 0x2766;
  29788. t.a108 = 0x2767;
  29789. t.a112 = 0x2663;
  29790. t.a111 = 0x2666;
  29791. t.a110 = 0x2665;
  29792. t.a109 = 0x2660;
  29793. t.a120 = 0x2460;
  29794. t.a121 = 0x2461;
  29795. t.a122 = 0x2462;
  29796. t.a123 = 0x2463;
  29797. t.a124 = 0x2464;
  29798. t.a125 = 0x2465;
  29799. t.a126 = 0x2466;
  29800. t.a127 = 0x2467;
  29801. t.a128 = 0x2468;
  29802. t.a129 = 0x2469;
  29803. t.a130 = 0x2776;
  29804. t.a131 = 0x2777;
  29805. t.a132 = 0x2778;
  29806. t.a133 = 0x2779;
  29807. t.a134 = 0x277a;
  29808. t.a135 = 0x277b;
  29809. t.a136 = 0x277c;
  29810. t.a137 = 0x277d;
  29811. t.a138 = 0x277e;
  29812. t.a139 = 0x277f;
  29813. t.a140 = 0x2780;
  29814. t.a141 = 0x2781;
  29815. t.a142 = 0x2782;
  29816. t.a143 = 0x2783;
  29817. t.a144 = 0x2784;
  29818. t.a145 = 0x2785;
  29819. t.a146 = 0x2786;
  29820. t.a147 = 0x2787;
  29821. t.a148 = 0x2788;
  29822. t.a149 = 0x2789;
  29823. t.a150 = 0x278a;
  29824. t.a151 = 0x278b;
  29825. t.a152 = 0x278c;
  29826. t.a153 = 0x278d;
  29827. t.a154 = 0x278e;
  29828. t.a155 = 0x278f;
  29829. t.a156 = 0x2790;
  29830. t.a157 = 0x2791;
  29831. t.a158 = 0x2792;
  29832. t.a159 = 0x2793;
  29833. t.a160 = 0x2794;
  29834. t.a161 = 0x2192;
  29835. t.a163 = 0x2194;
  29836. t.a164 = 0x2195;
  29837. t.a196 = 0x2798;
  29838. t.a165 = 0x2799;
  29839. t.a192 = 0x279a;
  29840. t.a166 = 0x279b;
  29841. t.a167 = 0x279c;
  29842. t.a168 = 0x279d;
  29843. t.a169 = 0x279e;
  29844. t.a170 = 0x279f;
  29845. t.a171 = 0x27a0;
  29846. t.a172 = 0x27a1;
  29847. t.a173 = 0x27a2;
  29848. t.a162 = 0x27a3;
  29849. t.a174 = 0x27a4;
  29850. t.a175 = 0x27a5;
  29851. t.a176 = 0x27a6;
  29852. t.a177 = 0x27a7;
  29853. t.a178 = 0x27a8;
  29854. t.a179 = 0x27a9;
  29855. t.a193 = 0x27aa;
  29856. t.a180 = 0x27ab;
  29857. t.a199 = 0x27ac;
  29858. t.a181 = 0x27ad;
  29859. t.a200 = 0x27ae;
  29860. t.a182 = 0x27af;
  29861. t.a201 = 0x27b1;
  29862. t.a183 = 0x27b2;
  29863. t.a184 = 0x27b3;
  29864. t.a197 = 0x27b4;
  29865. t.a185 = 0x27b5;
  29866. t.a194 = 0x27b6;
  29867. t.a198 = 0x27b7;
  29868. t.a186 = 0x27b8;
  29869. t.a195 = 0x27b9;
  29870. t.a187 = 0x27ba;
  29871. t.a188 = 0x27bb;
  29872. t.a189 = 0x27bc;
  29873. t.a190 = 0x27bd;
  29874. t.a191 = 0x27be;
  29875. t.a89 = 0x2768;
  29876. t.a90 = 0x2769;
  29877. t.a93 = 0x276a;
  29878. t.a94 = 0x276b;
  29879. t.a91 = 0x276c;
  29880. t.a92 = 0x276d;
  29881. t.a205 = 0x276e;
  29882. t.a85 = 0x276f;
  29883. t.a206 = 0x2770;
  29884. t.a86 = 0x2771;
  29885. t.a87 = 0x2772;
  29886. t.a88 = 0x2773;
  29887. t.a95 = 0x2774;
  29888. t.a96 = 0x2775;
  29889. t[".notdef"] = 0x0000;
  29890. });
  29891. exports.getGlyphsUnicode = getGlyphsUnicode;
  29892. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  29893. /***/ }),
  29894. /* 35 */
  29895. /***/ (function(module, exports, __w_pdfjs_require__) {
  29896. "use strict";
  29897. Object.defineProperty(exports, "__esModule", {
  29898. value: true
  29899. });
  29900. exports.getSupplementalGlyphMapForCalibri = exports.getSupplementalGlyphMapForArialBlack = exports.getGlyphMapForStandardFonts = exports.getSymbolsFonts = exports.getSerifFonts = exports.getNonStdFontMap = exports.getStdFontMap = void 0;
  29901. var _core_utils = __w_pdfjs_require__(8);
  29902. const getStdFontMap = (0, _core_utils.getLookupTableFactory)(function (t) {
  29903. t.ArialNarrow = "Helvetica";
  29904. t["ArialNarrow-Bold"] = "Helvetica-Bold";
  29905. t["ArialNarrow-BoldItalic"] = "Helvetica-BoldOblique";
  29906. t["ArialNarrow-Italic"] = "Helvetica-Oblique";
  29907. t.ArialBlack = "Helvetica";
  29908. t["ArialBlack-Bold"] = "Helvetica-Bold";
  29909. t["ArialBlack-BoldItalic"] = "Helvetica-BoldOblique";
  29910. t["ArialBlack-Italic"] = "Helvetica-Oblique";
  29911. t["Arial-Black"] = "Helvetica";
  29912. t["Arial-Black-Bold"] = "Helvetica-Bold";
  29913. t["Arial-Black-BoldItalic"] = "Helvetica-BoldOblique";
  29914. t["Arial-Black-Italic"] = "Helvetica-Oblique";
  29915. t.Arial = "Helvetica";
  29916. t["Arial-Bold"] = "Helvetica-Bold";
  29917. t["Arial-BoldItalic"] = "Helvetica-BoldOblique";
  29918. t["Arial-Italic"] = "Helvetica-Oblique";
  29919. t["Arial-BoldItalicMT"] = "Helvetica-BoldOblique";
  29920. t["Arial-BoldMT"] = "Helvetica-Bold";
  29921. t["Arial-ItalicMT"] = "Helvetica-Oblique";
  29922. t.ArialMT = "Helvetica";
  29923. t["Courier-Bold"] = "Courier-Bold";
  29924. t["Courier-BoldItalic"] = "Courier-BoldOblique";
  29925. t["Courier-Italic"] = "Courier-Oblique";
  29926. t.CourierNew = "Courier";
  29927. t["CourierNew-Bold"] = "Courier-Bold";
  29928. t["CourierNew-BoldItalic"] = "Courier-BoldOblique";
  29929. t["CourierNew-Italic"] = "Courier-Oblique";
  29930. t["CourierNewPS-BoldItalicMT"] = "Courier-BoldOblique";
  29931. t["CourierNewPS-BoldMT"] = "Courier-Bold";
  29932. t["CourierNewPS-ItalicMT"] = "Courier-Oblique";
  29933. t.CourierNewPSMT = "Courier";
  29934. t.Helvetica = "Helvetica";
  29935. t["Helvetica-Bold"] = "Helvetica-Bold";
  29936. t["Helvetica-BoldItalic"] = "Helvetica-BoldOblique";
  29937. t["Helvetica-BoldOblique"] = "Helvetica-BoldOblique";
  29938. t["Helvetica-Italic"] = "Helvetica-Oblique";
  29939. t["Helvetica-Oblique"] = "Helvetica-Oblique";
  29940. t["Symbol-Bold"] = "Symbol";
  29941. t["Symbol-BoldItalic"] = "Symbol";
  29942. t["Symbol-Italic"] = "Symbol";
  29943. t.TimesNewRoman = "Times-Roman";
  29944. t["TimesNewRoman-Bold"] = "Times-Bold";
  29945. t["TimesNewRoman-BoldItalic"] = "Times-BoldItalic";
  29946. t["TimesNewRoman-Italic"] = "Times-Italic";
  29947. t.TimesNewRomanPS = "Times-Roman";
  29948. t["TimesNewRomanPS-Bold"] = "Times-Bold";
  29949. t["TimesNewRomanPS-BoldItalic"] = "Times-BoldItalic";
  29950. t["TimesNewRomanPS-BoldItalicMT"] = "Times-BoldItalic";
  29951. t["TimesNewRomanPS-BoldMT"] = "Times-Bold";
  29952. t["TimesNewRomanPS-Italic"] = "Times-Italic";
  29953. t["TimesNewRomanPS-ItalicMT"] = "Times-Italic";
  29954. t.TimesNewRomanPSMT = "Times-Roman";
  29955. t["TimesNewRomanPSMT-Bold"] = "Times-Bold";
  29956. t["TimesNewRomanPSMT-BoldItalic"] = "Times-BoldItalic";
  29957. t["TimesNewRomanPSMT-Italic"] = "Times-Italic";
  29958. });
  29959. exports.getStdFontMap = getStdFontMap;
  29960. const getNonStdFontMap = (0, _core_utils.getLookupTableFactory)(function (t) {
  29961. t.Calibri = "Helvetica";
  29962. t["Calibri-Bold"] = "Helvetica-Bold";
  29963. t["Calibri-BoldItalic"] = "Helvetica-BoldOblique";
  29964. t["Calibri-Italic"] = "Helvetica-Oblique";
  29965. t.CenturyGothic = "Helvetica";
  29966. t["CenturyGothic-Bold"] = "Helvetica-Bold";
  29967. t["CenturyGothic-BoldItalic"] = "Helvetica-BoldOblique";
  29968. t["CenturyGothic-Italic"] = "Helvetica-Oblique";
  29969. t.ComicSansMS = "Comic Sans MS";
  29970. t["ComicSansMS-Bold"] = "Comic Sans MS-Bold";
  29971. t["ComicSansMS-BoldItalic"] = "Comic Sans MS-BoldItalic";
  29972. t["ComicSansMS-Italic"] = "Comic Sans MS-Italic";
  29973. t.LucidaConsole = "Courier";
  29974. t["LucidaConsole-Bold"] = "Courier-Bold";
  29975. t["LucidaConsole-BoldItalic"] = "Courier-BoldOblique";
  29976. t["LucidaConsole-Italic"] = "Courier-Oblique";
  29977. t["LucidaSans-Demi"] = "Helvetica-Bold";
  29978. t["MS-Gothic"] = "MS Gothic";
  29979. t["MS-Gothic-Bold"] = "MS Gothic-Bold";
  29980. t["MS-Gothic-BoldItalic"] = "MS Gothic-BoldItalic";
  29981. t["MS-Gothic-Italic"] = "MS Gothic-Italic";
  29982. t["MS-Mincho"] = "MS Mincho";
  29983. t["MS-Mincho-Bold"] = "MS Mincho-Bold";
  29984. t["MS-Mincho-BoldItalic"] = "MS Mincho-BoldItalic";
  29985. t["MS-Mincho-Italic"] = "MS Mincho-Italic";
  29986. t["MS-PGothic"] = "MS PGothic";
  29987. t["MS-PGothic-Bold"] = "MS PGothic-Bold";
  29988. t["MS-PGothic-BoldItalic"] = "MS PGothic-BoldItalic";
  29989. t["MS-PGothic-Italic"] = "MS PGothic-Italic";
  29990. t["MS-PMincho"] = "MS PMincho";
  29991. t["MS-PMincho-Bold"] = "MS PMincho-Bold";
  29992. t["MS-PMincho-BoldItalic"] = "MS PMincho-BoldItalic";
  29993. t["MS-PMincho-Italic"] = "MS PMincho-Italic";
  29994. t.NuptialScript = "Times-Italic";
  29995. t.SegoeUISymbol = "Helvetica";
  29996. t.Wingdings = "ZapfDingbats";
  29997. t["Wingdings-Regular"] = "ZapfDingbats";
  29998. });
  29999. exports.getNonStdFontMap = getNonStdFontMap;
  30000. const getSerifFonts = (0, _core_utils.getLookupTableFactory)(function (t) {
  30001. t["Adobe Jenson"] = true;
  30002. t["Adobe Text"] = true;
  30003. t.Albertus = true;
  30004. t.Aldus = true;
  30005. t.Alexandria = true;
  30006. t.Algerian = true;
  30007. t["American Typewriter"] = true;
  30008. t.Antiqua = true;
  30009. t.Apex = true;
  30010. t.Arno = true;
  30011. t.Aster = true;
  30012. t.Aurora = true;
  30013. t.Baskerville = true;
  30014. t.Bell = true;
  30015. t.Bembo = true;
  30016. t["Bembo Schoolbook"] = true;
  30017. t.Benguiat = true;
  30018. t["Berkeley Old Style"] = true;
  30019. t["Bernhard Modern"] = true;
  30020. t["Berthold City"] = true;
  30021. t.Bodoni = true;
  30022. t["Bauer Bodoni"] = true;
  30023. t["Book Antiqua"] = true;
  30024. t.Bookman = true;
  30025. t["Bordeaux Roman"] = true;
  30026. t["Californian FB"] = true;
  30027. t.Calisto = true;
  30028. t.Calvert = true;
  30029. t.Capitals = true;
  30030. t.Cambria = true;
  30031. t.Cartier = true;
  30032. t.Caslon = true;
  30033. t.Catull = true;
  30034. t.Centaur = true;
  30035. t["Century Old Style"] = true;
  30036. t["Century Schoolbook"] = true;
  30037. t.Chaparral = true;
  30038. t["Charis SIL"] = true;
  30039. t.Cheltenham = true;
  30040. t["Cholla Slab"] = true;
  30041. t.Clarendon = true;
  30042. t.Clearface = true;
  30043. t.Cochin = true;
  30044. t.Colonna = true;
  30045. t["Computer Modern"] = true;
  30046. t["Concrete Roman"] = true;
  30047. t.Constantia = true;
  30048. t["Cooper Black"] = true;
  30049. t.Corona = true;
  30050. t.Ecotype = true;
  30051. t.Egyptienne = true;
  30052. t.Elephant = true;
  30053. t.Excelsior = true;
  30054. t.Fairfield = true;
  30055. t["FF Scala"] = true;
  30056. t.Folkard = true;
  30057. t.Footlight = true;
  30058. t.FreeSerif = true;
  30059. t["Friz Quadrata"] = true;
  30060. t.Garamond = true;
  30061. t.Gentium = true;
  30062. t.Georgia = true;
  30063. t.Gloucester = true;
  30064. t["Goudy Old Style"] = true;
  30065. t["Goudy Schoolbook"] = true;
  30066. t["Goudy Pro Font"] = true;
  30067. t.Granjon = true;
  30068. t["Guardian Egyptian"] = true;
  30069. t.Heather = true;
  30070. t.Hercules = true;
  30071. t["High Tower Text"] = true;
  30072. t.Hiroshige = true;
  30073. t["Hoefler Text"] = true;
  30074. t["Humana Serif"] = true;
  30075. t.Imprint = true;
  30076. t["Ionic No. 5"] = true;
  30077. t.Janson = true;
  30078. t.Joanna = true;
  30079. t.Korinna = true;
  30080. t.Lexicon = true;
  30081. t["Liberation Serif"] = true;
  30082. t["Linux Libertine"] = true;
  30083. t.Literaturnaya = true;
  30084. t.Lucida = true;
  30085. t["Lucida Bright"] = true;
  30086. t.Melior = true;
  30087. t.Memphis = true;
  30088. t.Miller = true;
  30089. t.Minion = true;
  30090. t.Modern = true;
  30091. t["Mona Lisa"] = true;
  30092. t["Mrs Eaves"] = true;
  30093. t["MS Serif"] = true;
  30094. t["Museo Slab"] = true;
  30095. t["New York"] = true;
  30096. t["Nimbus Roman"] = true;
  30097. t["NPS Rawlinson Roadway"] = true;
  30098. t.NuptialScript = true;
  30099. t.Palatino = true;
  30100. t.Perpetua = true;
  30101. t.Plantin = true;
  30102. t["Plantin Schoolbook"] = true;
  30103. t.Playbill = true;
  30104. t["Poor Richard"] = true;
  30105. t["Rawlinson Roadway"] = true;
  30106. t.Renault = true;
  30107. t.Requiem = true;
  30108. t.Rockwell = true;
  30109. t.Roman = true;
  30110. t["Rotis Serif"] = true;
  30111. t.Sabon = true;
  30112. t.Scala = true;
  30113. t.Seagull = true;
  30114. t.Sistina = true;
  30115. t.Souvenir = true;
  30116. t.STIX = true;
  30117. t["Stone Informal"] = true;
  30118. t["Stone Serif"] = true;
  30119. t.Sylfaen = true;
  30120. t.Times = true;
  30121. t.Trajan = true;
  30122. t["Trinité"] = true;
  30123. t["Trump Mediaeval"] = true;
  30124. t.Utopia = true;
  30125. t["Vale Type"] = true;
  30126. t["Bitstream Vera"] = true;
  30127. t["Vera Serif"] = true;
  30128. t.Versailles = true;
  30129. t.Wanted = true;
  30130. t.Weiss = true;
  30131. t["Wide Latin"] = true;
  30132. t.Windsor = true;
  30133. t.XITS = true;
  30134. });
  30135. exports.getSerifFonts = getSerifFonts;
  30136. const getSymbolsFonts = (0, _core_utils.getLookupTableFactory)(function (t) {
  30137. t.Dingbats = true;
  30138. t.Symbol = true;
  30139. t.ZapfDingbats = true;
  30140. });
  30141. exports.getSymbolsFonts = getSymbolsFonts;
  30142. const getGlyphMapForStandardFonts = (0, _core_utils.getLookupTableFactory)(function (t) {
  30143. t[2] = 10;
  30144. t[3] = 32;
  30145. t[4] = 33;
  30146. t[5] = 34;
  30147. t[6] = 35;
  30148. t[7] = 36;
  30149. t[8] = 37;
  30150. t[9] = 38;
  30151. t[10] = 39;
  30152. t[11] = 40;
  30153. t[12] = 41;
  30154. t[13] = 42;
  30155. t[14] = 43;
  30156. t[15] = 44;
  30157. t[16] = 45;
  30158. t[17] = 46;
  30159. t[18] = 47;
  30160. t[19] = 48;
  30161. t[20] = 49;
  30162. t[21] = 50;
  30163. t[22] = 51;
  30164. t[23] = 52;
  30165. t[24] = 53;
  30166. t[25] = 54;
  30167. t[26] = 55;
  30168. t[27] = 56;
  30169. t[28] = 57;
  30170. t[29] = 58;
  30171. t[30] = 894;
  30172. t[31] = 60;
  30173. t[32] = 61;
  30174. t[33] = 62;
  30175. t[34] = 63;
  30176. t[35] = 64;
  30177. t[36] = 65;
  30178. t[37] = 66;
  30179. t[38] = 67;
  30180. t[39] = 68;
  30181. t[40] = 69;
  30182. t[41] = 70;
  30183. t[42] = 71;
  30184. t[43] = 72;
  30185. t[44] = 73;
  30186. t[45] = 74;
  30187. t[46] = 75;
  30188. t[47] = 76;
  30189. t[48] = 77;
  30190. t[49] = 78;
  30191. t[50] = 79;
  30192. t[51] = 80;
  30193. t[52] = 81;
  30194. t[53] = 82;
  30195. t[54] = 83;
  30196. t[55] = 84;
  30197. t[56] = 85;
  30198. t[57] = 86;
  30199. t[58] = 87;
  30200. t[59] = 88;
  30201. t[60] = 89;
  30202. t[61] = 90;
  30203. t[62] = 91;
  30204. t[63] = 92;
  30205. t[64] = 93;
  30206. t[65] = 94;
  30207. t[66] = 95;
  30208. t[67] = 96;
  30209. t[68] = 97;
  30210. t[69] = 98;
  30211. t[70] = 99;
  30212. t[71] = 100;
  30213. t[72] = 101;
  30214. t[73] = 102;
  30215. t[74] = 103;
  30216. t[75] = 104;
  30217. t[76] = 105;
  30218. t[77] = 106;
  30219. t[78] = 107;
  30220. t[79] = 108;
  30221. t[80] = 109;
  30222. t[81] = 110;
  30223. t[82] = 111;
  30224. t[83] = 112;
  30225. t[84] = 113;
  30226. t[85] = 114;
  30227. t[86] = 115;
  30228. t[87] = 116;
  30229. t[88] = 117;
  30230. t[89] = 118;
  30231. t[90] = 119;
  30232. t[91] = 120;
  30233. t[92] = 121;
  30234. t[93] = 122;
  30235. t[94] = 123;
  30236. t[95] = 124;
  30237. t[96] = 125;
  30238. t[97] = 126;
  30239. t[98] = 196;
  30240. t[99] = 197;
  30241. t[100] = 199;
  30242. t[101] = 201;
  30243. t[102] = 209;
  30244. t[103] = 214;
  30245. t[104] = 220;
  30246. t[105] = 225;
  30247. t[106] = 224;
  30248. t[107] = 226;
  30249. t[108] = 228;
  30250. t[109] = 227;
  30251. t[110] = 229;
  30252. t[111] = 231;
  30253. t[112] = 233;
  30254. t[113] = 232;
  30255. t[114] = 234;
  30256. t[115] = 235;
  30257. t[116] = 237;
  30258. t[117] = 236;
  30259. t[118] = 238;
  30260. t[119] = 239;
  30261. t[120] = 241;
  30262. t[121] = 243;
  30263. t[122] = 242;
  30264. t[123] = 244;
  30265. t[124] = 246;
  30266. t[125] = 245;
  30267. t[126] = 250;
  30268. t[127] = 249;
  30269. t[128] = 251;
  30270. t[129] = 252;
  30271. t[130] = 8224;
  30272. t[131] = 176;
  30273. t[132] = 162;
  30274. t[133] = 163;
  30275. t[134] = 167;
  30276. t[135] = 8226;
  30277. t[136] = 182;
  30278. t[137] = 223;
  30279. t[138] = 174;
  30280. t[139] = 169;
  30281. t[140] = 8482;
  30282. t[141] = 180;
  30283. t[142] = 168;
  30284. t[143] = 8800;
  30285. t[144] = 198;
  30286. t[145] = 216;
  30287. t[146] = 8734;
  30288. t[147] = 177;
  30289. t[148] = 8804;
  30290. t[149] = 8805;
  30291. t[150] = 165;
  30292. t[151] = 181;
  30293. t[152] = 8706;
  30294. t[153] = 8721;
  30295. t[154] = 8719;
  30296. t[156] = 8747;
  30297. t[157] = 170;
  30298. t[158] = 186;
  30299. t[159] = 8486;
  30300. t[160] = 230;
  30301. t[161] = 248;
  30302. t[162] = 191;
  30303. t[163] = 161;
  30304. t[164] = 172;
  30305. t[165] = 8730;
  30306. t[166] = 402;
  30307. t[167] = 8776;
  30308. t[168] = 8710;
  30309. t[169] = 171;
  30310. t[170] = 187;
  30311. t[171] = 8230;
  30312. t[210] = 218;
  30313. t[223] = 711;
  30314. t[224] = 321;
  30315. t[225] = 322;
  30316. t[227] = 353;
  30317. t[229] = 382;
  30318. t[234] = 253;
  30319. t[252] = 263;
  30320. t[253] = 268;
  30321. t[254] = 269;
  30322. t[258] = 258;
  30323. t[260] = 260;
  30324. t[261] = 261;
  30325. t[265] = 280;
  30326. t[266] = 281;
  30327. t[268] = 283;
  30328. t[269] = 313;
  30329. t[275] = 323;
  30330. t[276] = 324;
  30331. t[278] = 328;
  30332. t[284] = 345;
  30333. t[285] = 346;
  30334. t[286] = 347;
  30335. t[292] = 367;
  30336. t[295] = 377;
  30337. t[296] = 378;
  30338. t[298] = 380;
  30339. t[305] = 963;
  30340. t[306] = 964;
  30341. t[307] = 966;
  30342. t[308] = 8215;
  30343. t[309] = 8252;
  30344. t[310] = 8319;
  30345. t[311] = 8359;
  30346. t[312] = 8592;
  30347. t[313] = 8593;
  30348. t[337] = 9552;
  30349. t[493] = 1039;
  30350. t[494] = 1040;
  30351. t[705] = 1524;
  30352. t[706] = 8362;
  30353. t[710] = 64288;
  30354. t[711] = 64298;
  30355. t[759] = 1617;
  30356. t[761] = 1776;
  30357. t[763] = 1778;
  30358. t[775] = 1652;
  30359. t[777] = 1764;
  30360. t[778] = 1780;
  30361. t[779] = 1781;
  30362. t[780] = 1782;
  30363. t[782] = 771;
  30364. t[783] = 64726;
  30365. t[786] = 8363;
  30366. t[788] = 8532;
  30367. t[790] = 768;
  30368. t[791] = 769;
  30369. t[792] = 768;
  30370. t[795] = 803;
  30371. t[797] = 64336;
  30372. t[798] = 64337;
  30373. t[799] = 64342;
  30374. t[800] = 64343;
  30375. t[801] = 64344;
  30376. t[802] = 64345;
  30377. t[803] = 64362;
  30378. t[804] = 64363;
  30379. t[805] = 64364;
  30380. t[2424] = 7821;
  30381. t[2425] = 7822;
  30382. t[2426] = 7823;
  30383. t[2427] = 7824;
  30384. t[2428] = 7825;
  30385. t[2429] = 7826;
  30386. t[2430] = 7827;
  30387. t[2433] = 7682;
  30388. t[2678] = 8045;
  30389. t[2679] = 8046;
  30390. t[2830] = 1552;
  30391. t[2838] = 686;
  30392. t[2840] = 751;
  30393. t[2842] = 753;
  30394. t[2843] = 754;
  30395. t[2844] = 755;
  30396. t[2846] = 757;
  30397. t[2856] = 767;
  30398. t[2857] = 848;
  30399. t[2858] = 849;
  30400. t[2862] = 853;
  30401. t[2863] = 854;
  30402. t[2864] = 855;
  30403. t[2865] = 861;
  30404. t[2866] = 862;
  30405. t[2906] = 7460;
  30406. t[2908] = 7462;
  30407. t[2909] = 7463;
  30408. t[2910] = 7464;
  30409. t[2912] = 7466;
  30410. t[2913] = 7467;
  30411. t[2914] = 7468;
  30412. t[2916] = 7470;
  30413. t[2917] = 7471;
  30414. t[2918] = 7472;
  30415. t[2920] = 7474;
  30416. t[2921] = 7475;
  30417. t[2922] = 7476;
  30418. t[2924] = 7478;
  30419. t[2925] = 7479;
  30420. t[2926] = 7480;
  30421. t[2928] = 7482;
  30422. t[2929] = 7483;
  30423. t[2930] = 7484;
  30424. t[2932] = 7486;
  30425. t[2933] = 7487;
  30426. t[2934] = 7488;
  30427. t[2936] = 7490;
  30428. t[2937] = 7491;
  30429. t[2938] = 7492;
  30430. t[2940] = 7494;
  30431. t[2941] = 7495;
  30432. t[2942] = 7496;
  30433. t[2944] = 7498;
  30434. t[2946] = 7500;
  30435. t[2948] = 7502;
  30436. t[2950] = 7504;
  30437. t[2951] = 7505;
  30438. t[2952] = 7506;
  30439. t[2954] = 7508;
  30440. t[2955] = 7509;
  30441. t[2956] = 7510;
  30442. t[2958] = 7512;
  30443. t[2959] = 7513;
  30444. t[2960] = 7514;
  30445. t[2962] = 7516;
  30446. t[2963] = 7517;
  30447. t[2964] = 7518;
  30448. t[2966] = 7520;
  30449. t[2967] = 7521;
  30450. t[2968] = 7522;
  30451. t[2970] = 7524;
  30452. t[2971] = 7525;
  30453. t[2972] = 7526;
  30454. t[2974] = 7528;
  30455. t[2975] = 7529;
  30456. t[2976] = 7530;
  30457. t[2978] = 1537;
  30458. t[2979] = 1538;
  30459. t[2980] = 1539;
  30460. t[2982] = 1549;
  30461. t[2983] = 1551;
  30462. t[2984] = 1552;
  30463. t[2986] = 1554;
  30464. t[2987] = 1555;
  30465. t[2988] = 1556;
  30466. t[2990] = 1623;
  30467. t[2991] = 1624;
  30468. t[2995] = 1775;
  30469. t[2999] = 1791;
  30470. t[3002] = 64290;
  30471. t[3003] = 64291;
  30472. t[3004] = 64292;
  30473. t[3006] = 64294;
  30474. t[3007] = 64295;
  30475. t[3008] = 64296;
  30476. t[3011] = 1900;
  30477. t[3014] = 8223;
  30478. t[3015] = 8244;
  30479. t[3017] = 7532;
  30480. t[3018] = 7533;
  30481. t[3019] = 7534;
  30482. t[3075] = 7590;
  30483. t[3076] = 7591;
  30484. t[3079] = 7594;
  30485. t[3080] = 7595;
  30486. t[3083] = 7598;
  30487. t[3084] = 7599;
  30488. t[3087] = 7602;
  30489. t[3088] = 7603;
  30490. t[3091] = 7606;
  30491. t[3092] = 7607;
  30492. t[3095] = 7610;
  30493. t[3096] = 7611;
  30494. t[3099] = 7614;
  30495. t[3100] = 7615;
  30496. t[3103] = 7618;
  30497. t[3104] = 7619;
  30498. t[3107] = 8337;
  30499. t[3108] = 8338;
  30500. t[3116] = 1884;
  30501. t[3119] = 1885;
  30502. t[3120] = 1885;
  30503. t[3123] = 1886;
  30504. t[3124] = 1886;
  30505. t[3127] = 1887;
  30506. t[3128] = 1887;
  30507. t[3131] = 1888;
  30508. t[3132] = 1888;
  30509. t[3135] = 1889;
  30510. t[3136] = 1889;
  30511. t[3139] = 1890;
  30512. t[3140] = 1890;
  30513. t[3143] = 1891;
  30514. t[3144] = 1891;
  30515. t[3147] = 1892;
  30516. t[3148] = 1892;
  30517. t[3153] = 580;
  30518. t[3154] = 581;
  30519. t[3157] = 584;
  30520. t[3158] = 585;
  30521. t[3161] = 588;
  30522. t[3162] = 589;
  30523. t[3165] = 891;
  30524. t[3166] = 892;
  30525. t[3169] = 1274;
  30526. t[3170] = 1275;
  30527. t[3173] = 1278;
  30528. t[3174] = 1279;
  30529. t[3181] = 7622;
  30530. t[3182] = 7623;
  30531. t[3282] = 11799;
  30532. t[3316] = 578;
  30533. t[3379] = 42785;
  30534. t[3393] = 1159;
  30535. t[3416] = 8377;
  30536. });
  30537. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  30538. const getSupplementalGlyphMapForArialBlack = (0, _core_utils.getLookupTableFactory)(function (t) {
  30539. t[227] = 322;
  30540. t[264] = 261;
  30541. t[291] = 346;
  30542. });
  30543. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  30544. const getSupplementalGlyphMapForCalibri = (0, _core_utils.getLookupTableFactory)(function (t) {
  30545. t[1] = 32;
  30546. t[4] = 65;
  30547. t[17] = 66;
  30548. t[18] = 67;
  30549. t[24] = 68;
  30550. t[28] = 69;
  30551. t[38] = 70;
  30552. t[39] = 71;
  30553. t[44] = 72;
  30554. t[47] = 73;
  30555. t[58] = 74;
  30556. t[60] = 75;
  30557. t[62] = 76;
  30558. t[68] = 77;
  30559. t[69] = 78;
  30560. t[75] = 79;
  30561. t[87] = 80;
  30562. t[89] = 81;
  30563. t[90] = 82;
  30564. t[94] = 83;
  30565. t[100] = 84;
  30566. t[104] = 85;
  30567. t[115] = 86;
  30568. t[116] = 87;
  30569. t[121] = 88;
  30570. t[122] = 89;
  30571. t[127] = 90;
  30572. t[258] = 97;
  30573. t[268] = 261;
  30574. t[271] = 98;
  30575. t[272] = 99;
  30576. t[273] = 263;
  30577. t[282] = 100;
  30578. t[286] = 101;
  30579. t[295] = 281;
  30580. t[296] = 102;
  30581. t[336] = 103;
  30582. t[346] = 104;
  30583. t[349] = 105;
  30584. t[361] = 106;
  30585. t[364] = 107;
  30586. t[367] = 108;
  30587. t[371] = 322;
  30588. t[373] = 109;
  30589. t[374] = 110;
  30590. t[381] = 111;
  30591. t[383] = 243;
  30592. t[393] = 112;
  30593. t[395] = 113;
  30594. t[396] = 114;
  30595. t[400] = 115;
  30596. t[401] = 347;
  30597. t[410] = 116;
  30598. t[437] = 117;
  30599. t[448] = 118;
  30600. t[449] = 119;
  30601. t[454] = 120;
  30602. t[455] = 121;
  30603. t[460] = 122;
  30604. t[463] = 380;
  30605. t[853] = 44;
  30606. t[855] = 58;
  30607. t[856] = 46;
  30608. t[876] = 47;
  30609. t[878] = 45;
  30610. t[882] = 45;
  30611. t[894] = 40;
  30612. t[895] = 41;
  30613. t[896] = 91;
  30614. t[897] = 93;
  30615. t[923] = 64;
  30616. t[1004] = 48;
  30617. t[1005] = 49;
  30618. t[1006] = 50;
  30619. t[1007] = 51;
  30620. t[1008] = 52;
  30621. t[1009] = 53;
  30622. t[1010] = 54;
  30623. t[1011] = 55;
  30624. t[1012] = 56;
  30625. t[1013] = 57;
  30626. t[1081] = 37;
  30627. t[1085] = 43;
  30628. t[1086] = 45;
  30629. });
  30630. exports.getSupplementalGlyphMapForCalibri = getSupplementalGlyphMapForCalibri;
  30631. /***/ }),
  30632. /* 36 */
  30633. /***/ (function(module, exports, __w_pdfjs_require__) {
  30634. var getLookupTableFactory = __w_pdfjs_require__(8).getLookupTableFactory;
  30635. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  30636. t[63721] = 0x00a9;
  30637. t[63193] = 0x00a9;
  30638. t[63720] = 0x00ae;
  30639. t[63194] = 0x00ae;
  30640. t[63722] = 0x2122;
  30641. t[63195] = 0x2122;
  30642. t[63729] = 0x23a7;
  30643. t[63730] = 0x23a8;
  30644. t[63731] = 0x23a9;
  30645. t[63740] = 0x23ab;
  30646. t[63741] = 0x23ac;
  30647. t[63742] = 0x23ad;
  30648. t[63726] = 0x23a1;
  30649. t[63727] = 0x23a2;
  30650. t[63728] = 0x23a3;
  30651. t[63737] = 0x23a4;
  30652. t[63738] = 0x23a5;
  30653. t[63739] = 0x23a6;
  30654. t[63723] = 0x239b;
  30655. t[63724] = 0x239c;
  30656. t[63725] = 0x239d;
  30657. t[63734] = 0x239e;
  30658. t[63735] = 0x239f;
  30659. t[63736] = 0x23a0;
  30660. });
  30661. function mapSpecialUnicodeValues(code) {
  30662. if (code >= 0xfff0 && code <= 0xffff) {
  30663. return 0;
  30664. } else if (code >= 0xf600 && code <= 0xf8ff) {
  30665. return getSpecialPUASymbols()[code] || code;
  30666. } else if (code === 0x00ad) {
  30667. return 0x002d;
  30668. }
  30669. return code;
  30670. }
  30671. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  30672. var unicode = glyphsUnicodeMap[name];
  30673. if (unicode !== undefined) {
  30674. return unicode;
  30675. }
  30676. if (!name) {
  30677. return -1;
  30678. }
  30679. if (name[0] === "u") {
  30680. var nameLen = name.length, hexStr;
  30681. if (nameLen === 7 && name[1] === "n" && name[2] === "i") {
  30682. hexStr = name.substring(3);
  30683. } else if (nameLen >= 5 && nameLen <= 7) {
  30684. hexStr = name.substring(1);
  30685. } else {
  30686. return -1;
  30687. }
  30688. if (hexStr === hexStr.toUpperCase()) {
  30689. unicode = parseInt(hexStr, 16);
  30690. if (unicode >= 0) {
  30691. return unicode;
  30692. }
  30693. }
  30694. }
  30695. return -1;
  30696. }
  30697. var UnicodeRanges = [
  30698. {
  30699. begin: 0x0000,
  30700. end: 0x007f
  30701. },
  30702. {
  30703. begin: 0x0080,
  30704. end: 0x00ff
  30705. },
  30706. {
  30707. begin: 0x0100,
  30708. end: 0x017f
  30709. },
  30710. {
  30711. begin: 0x0180,
  30712. end: 0x024f
  30713. },
  30714. {
  30715. begin: 0x0250,
  30716. end: 0x02af
  30717. },
  30718. {
  30719. begin: 0x02b0,
  30720. end: 0x02ff
  30721. },
  30722. {
  30723. begin: 0x0300,
  30724. end: 0x036f
  30725. },
  30726. {
  30727. begin: 0x0370,
  30728. end: 0x03ff
  30729. },
  30730. {
  30731. begin: 0x2c80,
  30732. end: 0x2cff
  30733. },
  30734. {
  30735. begin: 0x0400,
  30736. end: 0x04ff
  30737. },
  30738. {
  30739. begin: 0x0530,
  30740. end: 0x058f
  30741. },
  30742. {
  30743. begin: 0x0590,
  30744. end: 0x05ff
  30745. },
  30746. {
  30747. begin: 0xa500,
  30748. end: 0xa63f
  30749. },
  30750. {
  30751. begin: 0x0600,
  30752. end: 0x06ff
  30753. },
  30754. {
  30755. begin: 0x07c0,
  30756. end: 0x07ff
  30757. },
  30758. {
  30759. begin: 0x0900,
  30760. end: 0x097f
  30761. },
  30762. {
  30763. begin: 0x0980,
  30764. end: 0x09ff
  30765. },
  30766. {
  30767. begin: 0x0a00,
  30768. end: 0x0a7f
  30769. },
  30770. {
  30771. begin: 0x0a80,
  30772. end: 0x0aff
  30773. },
  30774. {
  30775. begin: 0x0b00,
  30776. end: 0x0b7f
  30777. },
  30778. {
  30779. begin: 0x0b80,
  30780. end: 0x0bff
  30781. },
  30782. {
  30783. begin: 0x0c00,
  30784. end: 0x0c7f
  30785. },
  30786. {
  30787. begin: 0x0c80,
  30788. end: 0x0cff
  30789. },
  30790. {
  30791. begin: 0x0d00,
  30792. end: 0x0d7f
  30793. },
  30794. {
  30795. begin: 0x0e00,
  30796. end: 0x0e7f
  30797. },
  30798. {
  30799. begin: 0x0e80,
  30800. end: 0x0eff
  30801. },
  30802. {
  30803. begin: 0x10a0,
  30804. end: 0x10ff
  30805. },
  30806. {
  30807. begin: 0x1b00,
  30808. end: 0x1b7f
  30809. },
  30810. {
  30811. begin: 0x1100,
  30812. end: 0x11ff
  30813. },
  30814. {
  30815. begin: 0x1e00,
  30816. end: 0x1eff
  30817. },
  30818. {
  30819. begin: 0x1f00,
  30820. end: 0x1fff
  30821. },
  30822. {
  30823. begin: 0x2000,
  30824. end: 0x206f
  30825. },
  30826. {
  30827. begin: 0x2070,
  30828. end: 0x209f
  30829. },
  30830. {
  30831. begin: 0x20a0,
  30832. end: 0x20cf
  30833. },
  30834. {
  30835. begin: 0x20d0,
  30836. end: 0x20ff
  30837. },
  30838. {
  30839. begin: 0x2100,
  30840. end: 0x214f
  30841. },
  30842. {
  30843. begin: 0x2150,
  30844. end: 0x218f
  30845. },
  30846. {
  30847. begin: 0x2190,
  30848. end: 0x21ff
  30849. },
  30850. {
  30851. begin: 0x2200,
  30852. end: 0x22ff
  30853. },
  30854. {
  30855. begin: 0x2300,
  30856. end: 0x23ff
  30857. },
  30858. {
  30859. begin: 0x2400,
  30860. end: 0x243f
  30861. },
  30862. {
  30863. begin: 0x2440,
  30864. end: 0x245f
  30865. },
  30866. {
  30867. begin: 0x2460,
  30868. end: 0x24ff
  30869. },
  30870. {
  30871. begin: 0x2500,
  30872. end: 0x257f
  30873. },
  30874. {
  30875. begin: 0x2580,
  30876. end: 0x259f
  30877. },
  30878. {
  30879. begin: 0x25a0,
  30880. end: 0x25ff
  30881. },
  30882. {
  30883. begin: 0x2600,
  30884. end: 0x26ff
  30885. },
  30886. {
  30887. begin: 0x2700,
  30888. end: 0x27bf
  30889. },
  30890. {
  30891. begin: 0x3000,
  30892. end: 0x303f
  30893. },
  30894. {
  30895. begin: 0x3040,
  30896. end: 0x309f
  30897. },
  30898. {
  30899. begin: 0x30a0,
  30900. end: 0x30ff
  30901. },
  30902. {
  30903. begin: 0x3100,
  30904. end: 0x312f
  30905. },
  30906. {
  30907. begin: 0x3130,
  30908. end: 0x318f
  30909. },
  30910. {
  30911. begin: 0xa840,
  30912. end: 0xa87f
  30913. },
  30914. {
  30915. begin: 0x3200,
  30916. end: 0x32ff
  30917. },
  30918. {
  30919. begin: 0x3300,
  30920. end: 0x33ff
  30921. },
  30922. {
  30923. begin: 0xac00,
  30924. end: 0xd7af
  30925. },
  30926. {
  30927. begin: 0xd800,
  30928. end: 0xdfff
  30929. },
  30930. {
  30931. begin: 0x10900,
  30932. end: 0x1091f
  30933. },
  30934. {
  30935. begin: 0x4e00,
  30936. end: 0x9fff
  30937. },
  30938. {
  30939. begin: 0xe000,
  30940. end: 0xf8ff
  30941. },
  30942. {
  30943. begin: 0x31c0,
  30944. end: 0x31ef
  30945. },
  30946. {
  30947. begin: 0xfb00,
  30948. end: 0xfb4f
  30949. },
  30950. {
  30951. begin: 0xfb50,
  30952. end: 0xfdff
  30953. },
  30954. {
  30955. begin: 0xfe20,
  30956. end: 0xfe2f
  30957. },
  30958. {
  30959. begin: 0xfe10,
  30960. end: 0xfe1f
  30961. },
  30962. {
  30963. begin: 0xfe50,
  30964. end: 0xfe6f
  30965. },
  30966. {
  30967. begin: 0xfe70,
  30968. end: 0xfeff
  30969. },
  30970. {
  30971. begin: 0xff00,
  30972. end: 0xffef
  30973. },
  30974. {
  30975. begin: 0xfff0,
  30976. end: 0xffff
  30977. },
  30978. {
  30979. begin: 0x0f00,
  30980. end: 0x0fff
  30981. },
  30982. {
  30983. begin: 0x0700,
  30984. end: 0x074f
  30985. },
  30986. {
  30987. begin: 0x0780,
  30988. end: 0x07bf
  30989. },
  30990. {
  30991. begin: 0x0d80,
  30992. end: 0x0dff
  30993. },
  30994. {
  30995. begin: 0x1000,
  30996. end: 0x109f
  30997. },
  30998. {
  30999. begin: 0x1200,
  31000. end: 0x137f
  31001. },
  31002. {
  31003. begin: 0x13a0,
  31004. end: 0x13ff
  31005. },
  31006. {
  31007. begin: 0x1400,
  31008. end: 0x167f
  31009. },
  31010. {
  31011. begin: 0x1680,
  31012. end: 0x169f
  31013. },
  31014. {
  31015. begin: 0x16a0,
  31016. end: 0x16ff
  31017. },
  31018. {
  31019. begin: 0x1780,
  31020. end: 0x17ff
  31021. },
  31022. {
  31023. begin: 0x1800,
  31024. end: 0x18af
  31025. },
  31026. {
  31027. begin: 0x2800,
  31028. end: 0x28ff
  31029. },
  31030. {
  31031. begin: 0xa000,
  31032. end: 0xa48f
  31033. },
  31034. {
  31035. begin: 0x1700,
  31036. end: 0x171f
  31037. },
  31038. {
  31039. begin: 0x10300,
  31040. end: 0x1032f
  31041. },
  31042. {
  31043. begin: 0x10330,
  31044. end: 0x1034f
  31045. },
  31046. {
  31047. begin: 0x10400,
  31048. end: 0x1044f
  31049. },
  31050. {
  31051. begin: 0x1d000,
  31052. end: 0x1d0ff
  31053. },
  31054. {
  31055. begin: 0x1d400,
  31056. end: 0x1d7ff
  31057. },
  31058. {
  31059. begin: 0xff000,
  31060. end: 0xffffd
  31061. },
  31062. {
  31063. begin: 0xfe00,
  31064. end: 0xfe0f
  31065. },
  31066. {
  31067. begin: 0xe0000,
  31068. end: 0xe007f
  31069. },
  31070. {
  31071. begin: 0x1900,
  31072. end: 0x194f
  31073. },
  31074. {
  31075. begin: 0x1950,
  31076. end: 0x197f
  31077. },
  31078. {
  31079. begin: 0x1980,
  31080. end: 0x19df
  31081. },
  31082. {
  31083. begin: 0x1a00,
  31084. end: 0x1a1f
  31085. },
  31086. {
  31087. begin: 0x2c00,
  31088. end: 0x2c5f
  31089. },
  31090. {
  31091. begin: 0x2d30,
  31092. end: 0x2d7f
  31093. },
  31094. {
  31095. begin: 0x4dc0,
  31096. end: 0x4dff
  31097. },
  31098. {
  31099. begin: 0xa800,
  31100. end: 0xa82f
  31101. },
  31102. {
  31103. begin: 0x10000,
  31104. end: 0x1007f
  31105. },
  31106. {
  31107. begin: 0x10140,
  31108. end: 0x1018f
  31109. },
  31110. {
  31111. begin: 0x10380,
  31112. end: 0x1039f
  31113. },
  31114. {
  31115. begin: 0x103a0,
  31116. end: 0x103df
  31117. },
  31118. {
  31119. begin: 0x10450,
  31120. end: 0x1047f
  31121. },
  31122. {
  31123. begin: 0x10480,
  31124. end: 0x104af
  31125. },
  31126. {
  31127. begin: 0x10800,
  31128. end: 0x1083f
  31129. },
  31130. {
  31131. begin: 0x10a00,
  31132. end: 0x10a5f
  31133. },
  31134. {
  31135. begin: 0x1d300,
  31136. end: 0x1d35f
  31137. },
  31138. {
  31139. begin: 0x12000,
  31140. end: 0x123ff
  31141. },
  31142. {
  31143. begin: 0x1d360,
  31144. end: 0x1d37f
  31145. },
  31146. {
  31147. begin: 0x1b80,
  31148. end: 0x1bbf
  31149. },
  31150. {
  31151. begin: 0x1c00,
  31152. end: 0x1c4f
  31153. },
  31154. {
  31155. begin: 0x1c50,
  31156. end: 0x1c7f
  31157. },
  31158. {
  31159. begin: 0xa880,
  31160. end: 0xa8df
  31161. },
  31162. {
  31163. begin: 0xa900,
  31164. end: 0xa92f
  31165. },
  31166. {
  31167. begin: 0xa930,
  31168. end: 0xa95f
  31169. },
  31170. {
  31171. begin: 0xaa00,
  31172. end: 0xaa5f
  31173. },
  31174. {
  31175. begin: 0x10190,
  31176. end: 0x101cf
  31177. },
  31178. {
  31179. begin: 0x101d0,
  31180. end: 0x101ff
  31181. },
  31182. {
  31183. begin: 0x102a0,
  31184. end: 0x102df
  31185. },
  31186. {
  31187. begin: 0x1f030,
  31188. end: 0x1f09f
  31189. }
  31190. ];
  31191. function getUnicodeRangeFor(value) {
  31192. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  31193. var range = UnicodeRanges[i];
  31194. if (value >= range.begin && value < range.end) {
  31195. return i;
  31196. }
  31197. }
  31198. return -1;
  31199. }
  31200. function isRTLRangeFor(value) {
  31201. var range = UnicodeRanges[13];
  31202. if (value >= range.begin && value < range.end) {
  31203. return true;
  31204. }
  31205. range = UnicodeRanges[11];
  31206. if (value >= range.begin && value < range.end) {
  31207. return true;
  31208. }
  31209. return false;
  31210. }
  31211. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  31212. t["\u00A8"] = "\u0020\u0308";
  31213. t["\u00AF"] = "\u0020\u0304";
  31214. t["\u00B4"] = "\u0020\u0301";
  31215. t["\u00B5"] = "\u03BC";
  31216. t["\u00B8"] = "\u0020\u0327";
  31217. t["\u0132"] = "\u0049\u004A";
  31218. t["\u0133"] = "\u0069\u006A";
  31219. t["\u013F"] = "\u004C\u00B7";
  31220. t["\u0140"] = "\u006C\u00B7";
  31221. t["\u0149"] = "\u02BC\u006E";
  31222. t["\u017F"] = "\u0073";
  31223. t["\u01C4"] = "\u0044\u017D";
  31224. t["\u01C5"] = "\u0044\u017E";
  31225. t["\u01C6"] = "\u0064\u017E";
  31226. t["\u01C7"] = "\u004C\u004A";
  31227. t["\u01C8"] = "\u004C\u006A";
  31228. t["\u01C9"] = "\u006C\u006A";
  31229. t["\u01CA"] = "\u004E\u004A";
  31230. t["\u01CB"] = "\u004E\u006A";
  31231. t["\u01CC"] = "\u006E\u006A";
  31232. t["\u01F1"] = "\u0044\u005A";
  31233. t["\u01F2"] = "\u0044\u007A";
  31234. t["\u01F3"] = "\u0064\u007A";
  31235. t["\u02D8"] = "\u0020\u0306";
  31236. t["\u02D9"] = "\u0020\u0307";
  31237. t["\u02DA"] = "\u0020\u030A";
  31238. t["\u02DB"] = "\u0020\u0328";
  31239. t["\u02DC"] = "\u0020\u0303";
  31240. t["\u02DD"] = "\u0020\u030B";
  31241. t["\u037A"] = "\u0020\u0345";
  31242. t["\u0384"] = "\u0020\u0301";
  31243. t["\u03D0"] = "\u03B2";
  31244. t["\u03D1"] = "\u03B8";
  31245. t["\u03D2"] = "\u03A5";
  31246. t["\u03D5"] = "\u03C6";
  31247. t["\u03D6"] = "\u03C0";
  31248. t["\u03F0"] = "\u03BA";
  31249. t["\u03F1"] = "\u03C1";
  31250. t["\u03F2"] = "\u03C2";
  31251. t["\u03F4"] = "\u0398";
  31252. t["\u03F5"] = "\u03B5";
  31253. t["\u03F9"] = "\u03A3";
  31254. t["\u0587"] = "\u0565\u0582";
  31255. t["\u0675"] = "\u0627\u0674";
  31256. t["\u0676"] = "\u0648\u0674";
  31257. t["\u0677"] = "\u06C7\u0674";
  31258. t["\u0678"] = "\u064A\u0674";
  31259. t["\u0E33"] = "\u0E4D\u0E32";
  31260. t["\u0EB3"] = "\u0ECD\u0EB2";
  31261. t["\u0EDC"] = "\u0EAB\u0E99";
  31262. t["\u0EDD"] = "\u0EAB\u0EA1";
  31263. t["\u0F77"] = "\u0FB2\u0F81";
  31264. t["\u0F79"] = "\u0FB3\u0F81";
  31265. t["\u1E9A"] = "\u0061\u02BE";
  31266. t["\u1FBD"] = "\u0020\u0313";
  31267. t["\u1FBF"] = "\u0020\u0313";
  31268. t["\u1FC0"] = "\u0020\u0342";
  31269. t["\u1FFE"] = "\u0020\u0314";
  31270. t["\u2002"] = "\u0020";
  31271. t["\u2003"] = "\u0020";
  31272. t["\u2004"] = "\u0020";
  31273. t["\u2005"] = "\u0020";
  31274. t["\u2006"] = "\u0020";
  31275. t["\u2008"] = "\u0020";
  31276. t["\u2009"] = "\u0020";
  31277. t["\u200A"] = "\u0020";
  31278. t["\u2017"] = "\u0020\u0333";
  31279. t["\u2024"] = "\u002E";
  31280. t["\u2025"] = "\u002E\u002E";
  31281. t["\u2026"] = "\u002E\u002E\u002E";
  31282. t["\u2033"] = "\u2032\u2032";
  31283. t["\u2034"] = "\u2032\u2032\u2032";
  31284. t["\u2036"] = "\u2035\u2035";
  31285. t["\u2037"] = "\u2035\u2035\u2035";
  31286. t["\u203C"] = "\u0021\u0021";
  31287. t["\u203E"] = "\u0020\u0305";
  31288. t["\u2047"] = "\u003F\u003F";
  31289. t["\u2048"] = "\u003F\u0021";
  31290. t["\u2049"] = "\u0021\u003F";
  31291. t["\u2057"] = "\u2032\u2032\u2032\u2032";
  31292. t["\u205F"] = "\u0020";
  31293. t["\u20A8"] = "\u0052\u0073";
  31294. t["\u2100"] = "\u0061\u002F\u0063";
  31295. t["\u2101"] = "\u0061\u002F\u0073";
  31296. t["\u2103"] = "\u00B0\u0043";
  31297. t["\u2105"] = "\u0063\u002F\u006F";
  31298. t["\u2106"] = "\u0063\u002F\u0075";
  31299. t["\u2107"] = "\u0190";
  31300. t["\u2109"] = "\u00B0\u0046";
  31301. t["\u2116"] = "\u004E\u006F";
  31302. t["\u2121"] = "\u0054\u0045\u004C";
  31303. t["\u2135"] = "\u05D0";
  31304. t["\u2136"] = "\u05D1";
  31305. t["\u2137"] = "\u05D2";
  31306. t["\u2138"] = "\u05D3";
  31307. t["\u213B"] = "\u0046\u0041\u0058";
  31308. t["\u2160"] = "\u0049";
  31309. t["\u2161"] = "\u0049\u0049";
  31310. t["\u2162"] = "\u0049\u0049\u0049";
  31311. t["\u2163"] = "\u0049\u0056";
  31312. t["\u2164"] = "\u0056";
  31313. t["\u2165"] = "\u0056\u0049";
  31314. t["\u2166"] = "\u0056\u0049\u0049";
  31315. t["\u2167"] = "\u0056\u0049\u0049\u0049";
  31316. t["\u2168"] = "\u0049\u0058";
  31317. t["\u2169"] = "\u0058";
  31318. t["\u216A"] = "\u0058\u0049";
  31319. t["\u216B"] = "\u0058\u0049\u0049";
  31320. t["\u216C"] = "\u004C";
  31321. t["\u216D"] = "\u0043";
  31322. t["\u216E"] = "\u0044";
  31323. t["\u216F"] = "\u004D";
  31324. t["\u2170"] = "\u0069";
  31325. t["\u2171"] = "\u0069\u0069";
  31326. t["\u2172"] = "\u0069\u0069\u0069";
  31327. t["\u2173"] = "\u0069\u0076";
  31328. t["\u2174"] = "\u0076";
  31329. t["\u2175"] = "\u0076\u0069";
  31330. t["\u2176"] = "\u0076\u0069\u0069";
  31331. t["\u2177"] = "\u0076\u0069\u0069\u0069";
  31332. t["\u2178"] = "\u0069\u0078";
  31333. t["\u2179"] = "\u0078";
  31334. t["\u217A"] = "\u0078\u0069";
  31335. t["\u217B"] = "\u0078\u0069\u0069";
  31336. t["\u217C"] = "\u006C";
  31337. t["\u217D"] = "\u0063";
  31338. t["\u217E"] = "\u0064";
  31339. t["\u217F"] = "\u006D";
  31340. t["\u222C"] = "\u222B\u222B";
  31341. t["\u222D"] = "\u222B\u222B\u222B";
  31342. t["\u222F"] = "\u222E\u222E";
  31343. t["\u2230"] = "\u222E\u222E\u222E";
  31344. t["\u2474"] = "\u0028\u0031\u0029";
  31345. t["\u2475"] = "\u0028\u0032\u0029";
  31346. t["\u2476"] = "\u0028\u0033\u0029";
  31347. t["\u2477"] = "\u0028\u0034\u0029";
  31348. t["\u2478"] = "\u0028\u0035\u0029";
  31349. t["\u2479"] = "\u0028\u0036\u0029";
  31350. t["\u247A"] = "\u0028\u0037\u0029";
  31351. t["\u247B"] = "\u0028\u0038\u0029";
  31352. t["\u247C"] = "\u0028\u0039\u0029";
  31353. t["\u247D"] = "\u0028\u0031\u0030\u0029";
  31354. t["\u247E"] = "\u0028\u0031\u0031\u0029";
  31355. t["\u247F"] = "\u0028\u0031\u0032\u0029";
  31356. t["\u2480"] = "\u0028\u0031\u0033\u0029";
  31357. t["\u2481"] = "\u0028\u0031\u0034\u0029";
  31358. t["\u2482"] = "\u0028\u0031\u0035\u0029";
  31359. t["\u2483"] = "\u0028\u0031\u0036\u0029";
  31360. t["\u2484"] = "\u0028\u0031\u0037\u0029";
  31361. t["\u2485"] = "\u0028\u0031\u0038\u0029";
  31362. t["\u2486"] = "\u0028\u0031\u0039\u0029";
  31363. t["\u2487"] = "\u0028\u0032\u0030\u0029";
  31364. t["\u2488"] = "\u0031\u002E";
  31365. t["\u2489"] = "\u0032\u002E";
  31366. t["\u248A"] = "\u0033\u002E";
  31367. t["\u248B"] = "\u0034\u002E";
  31368. t["\u248C"] = "\u0035\u002E";
  31369. t["\u248D"] = "\u0036\u002E";
  31370. t["\u248E"] = "\u0037\u002E";
  31371. t["\u248F"] = "\u0038\u002E";
  31372. t["\u2490"] = "\u0039\u002E";
  31373. t["\u2491"] = "\u0031\u0030\u002E";
  31374. t["\u2492"] = "\u0031\u0031\u002E";
  31375. t["\u2493"] = "\u0031\u0032\u002E";
  31376. t["\u2494"] = "\u0031\u0033\u002E";
  31377. t["\u2495"] = "\u0031\u0034\u002E";
  31378. t["\u2496"] = "\u0031\u0035\u002E";
  31379. t["\u2497"] = "\u0031\u0036\u002E";
  31380. t["\u2498"] = "\u0031\u0037\u002E";
  31381. t["\u2499"] = "\u0031\u0038\u002E";
  31382. t["\u249A"] = "\u0031\u0039\u002E";
  31383. t["\u249B"] = "\u0032\u0030\u002E";
  31384. t["\u249C"] = "\u0028\u0061\u0029";
  31385. t["\u249D"] = "\u0028\u0062\u0029";
  31386. t["\u249E"] = "\u0028\u0063\u0029";
  31387. t["\u249F"] = "\u0028\u0064\u0029";
  31388. t["\u24A0"] = "\u0028\u0065\u0029";
  31389. t["\u24A1"] = "\u0028\u0066\u0029";
  31390. t["\u24A2"] = "\u0028\u0067\u0029";
  31391. t["\u24A3"] = "\u0028\u0068\u0029";
  31392. t["\u24A4"] = "\u0028\u0069\u0029";
  31393. t["\u24A5"] = "\u0028\u006A\u0029";
  31394. t["\u24A6"] = "\u0028\u006B\u0029";
  31395. t["\u24A7"] = "\u0028\u006C\u0029";
  31396. t["\u24A8"] = "\u0028\u006D\u0029";
  31397. t["\u24A9"] = "\u0028\u006E\u0029";
  31398. t["\u24AA"] = "\u0028\u006F\u0029";
  31399. t["\u24AB"] = "\u0028\u0070\u0029";
  31400. t["\u24AC"] = "\u0028\u0071\u0029";
  31401. t["\u24AD"] = "\u0028\u0072\u0029";
  31402. t["\u24AE"] = "\u0028\u0073\u0029";
  31403. t["\u24AF"] = "\u0028\u0074\u0029";
  31404. t["\u24B0"] = "\u0028\u0075\u0029";
  31405. t["\u24B1"] = "\u0028\u0076\u0029";
  31406. t["\u24B2"] = "\u0028\u0077\u0029";
  31407. t["\u24B3"] = "\u0028\u0078\u0029";
  31408. t["\u24B4"] = "\u0028\u0079\u0029";
  31409. t["\u24B5"] = "\u0028\u007A\u0029";
  31410. t["\u2A0C"] = "\u222B\u222B\u222B\u222B";
  31411. t["\u2A74"] = "\u003A\u003A\u003D";
  31412. t["\u2A75"] = "\u003D\u003D";
  31413. t["\u2A76"] = "\u003D\u003D\u003D";
  31414. t["\u2E9F"] = "\u6BCD";
  31415. t["\u2EF3"] = "\u9F9F";
  31416. t["\u2F00"] = "\u4E00";
  31417. t["\u2F01"] = "\u4E28";
  31418. t["\u2F02"] = "\u4E36";
  31419. t["\u2F03"] = "\u4E3F";
  31420. t["\u2F04"] = "\u4E59";
  31421. t["\u2F05"] = "\u4E85";
  31422. t["\u2F06"] = "\u4E8C";
  31423. t["\u2F07"] = "\u4EA0";
  31424. t["\u2F08"] = "\u4EBA";
  31425. t["\u2F09"] = "\u513F";
  31426. t["\u2F0A"] = "\u5165";
  31427. t["\u2F0B"] = "\u516B";
  31428. t["\u2F0C"] = "\u5182";
  31429. t["\u2F0D"] = "\u5196";
  31430. t["\u2F0E"] = "\u51AB";
  31431. t["\u2F0F"] = "\u51E0";
  31432. t["\u2F10"] = "\u51F5";
  31433. t["\u2F11"] = "\u5200";
  31434. t["\u2F12"] = "\u529B";
  31435. t["\u2F13"] = "\u52F9";
  31436. t["\u2F14"] = "\u5315";
  31437. t["\u2F15"] = "\u531A";
  31438. t["\u2F16"] = "\u5338";
  31439. t["\u2F17"] = "\u5341";
  31440. t["\u2F18"] = "\u535C";
  31441. t["\u2F19"] = "\u5369";
  31442. t["\u2F1A"] = "\u5382";
  31443. t["\u2F1B"] = "\u53B6";
  31444. t["\u2F1C"] = "\u53C8";
  31445. t["\u2F1D"] = "\u53E3";
  31446. t["\u2F1E"] = "\u56D7";
  31447. t["\u2F1F"] = "\u571F";
  31448. t["\u2F20"] = "\u58EB";
  31449. t["\u2F21"] = "\u5902";
  31450. t["\u2F22"] = "\u590A";
  31451. t["\u2F23"] = "\u5915";
  31452. t["\u2F24"] = "\u5927";
  31453. t["\u2F25"] = "\u5973";
  31454. t["\u2F26"] = "\u5B50";
  31455. t["\u2F27"] = "\u5B80";
  31456. t["\u2F28"] = "\u5BF8";
  31457. t["\u2F29"] = "\u5C0F";
  31458. t["\u2F2A"] = "\u5C22";
  31459. t["\u2F2B"] = "\u5C38";
  31460. t["\u2F2C"] = "\u5C6E";
  31461. t["\u2F2D"] = "\u5C71";
  31462. t["\u2F2E"] = "\u5DDB";
  31463. t["\u2F2F"] = "\u5DE5";
  31464. t["\u2F30"] = "\u5DF1";
  31465. t["\u2F31"] = "\u5DFE";
  31466. t["\u2F32"] = "\u5E72";
  31467. t["\u2F33"] = "\u5E7A";
  31468. t["\u2F34"] = "\u5E7F";
  31469. t["\u2F35"] = "\u5EF4";
  31470. t["\u2F36"] = "\u5EFE";
  31471. t["\u2F37"] = "\u5F0B";
  31472. t["\u2F38"] = "\u5F13";
  31473. t["\u2F39"] = "\u5F50";
  31474. t["\u2F3A"] = "\u5F61";
  31475. t["\u2F3B"] = "\u5F73";
  31476. t["\u2F3C"] = "\u5FC3";
  31477. t["\u2F3D"] = "\u6208";
  31478. t["\u2F3E"] = "\u6236";
  31479. t["\u2F3F"] = "\u624B";
  31480. t["\u2F40"] = "\u652F";
  31481. t["\u2F41"] = "\u6534";
  31482. t["\u2F42"] = "\u6587";
  31483. t["\u2F43"] = "\u6597";
  31484. t["\u2F44"] = "\u65A4";
  31485. t["\u2F45"] = "\u65B9";
  31486. t["\u2F46"] = "\u65E0";
  31487. t["\u2F47"] = "\u65E5";
  31488. t["\u2F48"] = "\u66F0";
  31489. t["\u2F49"] = "\u6708";
  31490. t["\u2F4A"] = "\u6728";
  31491. t["\u2F4B"] = "\u6B20";
  31492. t["\u2F4C"] = "\u6B62";
  31493. t["\u2F4D"] = "\u6B79";
  31494. t["\u2F4E"] = "\u6BB3";
  31495. t["\u2F4F"] = "\u6BCB";
  31496. t["\u2F50"] = "\u6BD4";
  31497. t["\u2F51"] = "\u6BDB";
  31498. t["\u2F52"] = "\u6C0F";
  31499. t["\u2F53"] = "\u6C14";
  31500. t["\u2F54"] = "\u6C34";
  31501. t["\u2F55"] = "\u706B";
  31502. t["\u2F56"] = "\u722A";
  31503. t["\u2F57"] = "\u7236";
  31504. t["\u2F58"] = "\u723B";
  31505. t["\u2F59"] = "\u723F";
  31506. t["\u2F5A"] = "\u7247";
  31507. t["\u2F5B"] = "\u7259";
  31508. t["\u2F5C"] = "\u725B";
  31509. t["\u2F5D"] = "\u72AC";
  31510. t["\u2F5E"] = "\u7384";
  31511. t["\u2F5F"] = "\u7389";
  31512. t["\u2F60"] = "\u74DC";
  31513. t["\u2F61"] = "\u74E6";
  31514. t["\u2F62"] = "\u7518";
  31515. t["\u2F63"] = "\u751F";
  31516. t["\u2F64"] = "\u7528";
  31517. t["\u2F65"] = "\u7530";
  31518. t["\u2F66"] = "\u758B";
  31519. t["\u2F67"] = "\u7592";
  31520. t["\u2F68"] = "\u7676";
  31521. t["\u2F69"] = "\u767D";
  31522. t["\u2F6A"] = "\u76AE";
  31523. t["\u2F6B"] = "\u76BF";
  31524. t["\u2F6C"] = "\u76EE";
  31525. t["\u2F6D"] = "\u77DB";
  31526. t["\u2F6E"] = "\u77E2";
  31527. t["\u2F6F"] = "\u77F3";
  31528. t["\u2F70"] = "\u793A";
  31529. t["\u2F71"] = "\u79B8";
  31530. t["\u2F72"] = "\u79BE";
  31531. t["\u2F73"] = "\u7A74";
  31532. t["\u2F74"] = "\u7ACB";
  31533. t["\u2F75"] = "\u7AF9";
  31534. t["\u2F76"] = "\u7C73";
  31535. t["\u2F77"] = "\u7CF8";
  31536. t["\u2F78"] = "\u7F36";
  31537. t["\u2F79"] = "\u7F51";
  31538. t["\u2F7A"] = "\u7F8A";
  31539. t["\u2F7B"] = "\u7FBD";
  31540. t["\u2F7C"] = "\u8001";
  31541. t["\u2F7D"] = "\u800C";
  31542. t["\u2F7E"] = "\u8012";
  31543. t["\u2F7F"] = "\u8033";
  31544. t["\u2F80"] = "\u807F";
  31545. t["\u2F81"] = "\u8089";
  31546. t["\u2F82"] = "\u81E3";
  31547. t["\u2F83"] = "\u81EA";
  31548. t["\u2F84"] = "\u81F3";
  31549. t["\u2F85"] = "\u81FC";
  31550. t["\u2F86"] = "\u820C";
  31551. t["\u2F87"] = "\u821B";
  31552. t["\u2F88"] = "\u821F";
  31553. t["\u2F89"] = "\u826E";
  31554. t["\u2F8A"] = "\u8272";
  31555. t["\u2F8B"] = "\u8278";
  31556. t["\u2F8C"] = "\u864D";
  31557. t["\u2F8D"] = "\u866B";
  31558. t["\u2F8E"] = "\u8840";
  31559. t["\u2F8F"] = "\u884C";
  31560. t["\u2F90"] = "\u8863";
  31561. t["\u2F91"] = "\u897E";
  31562. t["\u2F92"] = "\u898B";
  31563. t["\u2F93"] = "\u89D2";
  31564. t["\u2F94"] = "\u8A00";
  31565. t["\u2F95"] = "\u8C37";
  31566. t["\u2F96"] = "\u8C46";
  31567. t["\u2F97"] = "\u8C55";
  31568. t["\u2F98"] = "\u8C78";
  31569. t["\u2F99"] = "\u8C9D";
  31570. t["\u2F9A"] = "\u8D64";
  31571. t["\u2F9B"] = "\u8D70";
  31572. t["\u2F9C"] = "\u8DB3";
  31573. t["\u2F9D"] = "\u8EAB";
  31574. t["\u2F9E"] = "\u8ECA";
  31575. t["\u2F9F"] = "\u8F9B";
  31576. t["\u2FA0"] = "\u8FB0";
  31577. t["\u2FA1"] = "\u8FB5";
  31578. t["\u2FA2"] = "\u9091";
  31579. t["\u2FA3"] = "\u9149";
  31580. t["\u2FA4"] = "\u91C6";
  31581. t["\u2FA5"] = "\u91CC";
  31582. t["\u2FA6"] = "\u91D1";
  31583. t["\u2FA7"] = "\u9577";
  31584. t["\u2FA8"] = "\u9580";
  31585. t["\u2FA9"] = "\u961C";
  31586. t["\u2FAA"] = "\u96B6";
  31587. t["\u2FAB"] = "\u96B9";
  31588. t["\u2FAC"] = "\u96E8";
  31589. t["\u2FAD"] = "\u9751";
  31590. t["\u2FAE"] = "\u975E";
  31591. t["\u2FAF"] = "\u9762";
  31592. t["\u2FB0"] = "\u9769";
  31593. t["\u2FB1"] = "\u97CB";
  31594. t["\u2FB2"] = "\u97ED";
  31595. t["\u2FB3"] = "\u97F3";
  31596. t["\u2FB4"] = "\u9801";
  31597. t["\u2FB5"] = "\u98A8";
  31598. t["\u2FB6"] = "\u98DB";
  31599. t["\u2FB7"] = "\u98DF";
  31600. t["\u2FB8"] = "\u9996";
  31601. t["\u2FB9"] = "\u9999";
  31602. t["\u2FBA"] = "\u99AC";
  31603. t["\u2FBB"] = "\u9AA8";
  31604. t["\u2FBC"] = "\u9AD8";
  31605. t["\u2FBD"] = "\u9ADF";
  31606. t["\u2FBE"] = "\u9B25";
  31607. t["\u2FBF"] = "\u9B2F";
  31608. t["\u2FC0"] = "\u9B32";
  31609. t["\u2FC1"] = "\u9B3C";
  31610. t["\u2FC2"] = "\u9B5A";
  31611. t["\u2FC3"] = "\u9CE5";
  31612. t["\u2FC4"] = "\u9E75";
  31613. t["\u2FC5"] = "\u9E7F";
  31614. t["\u2FC6"] = "\u9EA5";
  31615. t["\u2FC7"] = "\u9EBB";
  31616. t["\u2FC8"] = "\u9EC3";
  31617. t["\u2FC9"] = "\u9ECD";
  31618. t["\u2FCA"] = "\u9ED1";
  31619. t["\u2FCB"] = "\u9EF9";
  31620. t["\u2FCC"] = "\u9EFD";
  31621. t["\u2FCD"] = "\u9F0E";
  31622. t["\u2FCE"] = "\u9F13";
  31623. t["\u2FCF"] = "\u9F20";
  31624. t["\u2FD0"] = "\u9F3B";
  31625. t["\u2FD1"] = "\u9F4A";
  31626. t["\u2FD2"] = "\u9F52";
  31627. t["\u2FD3"] = "\u9F8D";
  31628. t["\u2FD4"] = "\u9F9C";
  31629. t["\u2FD5"] = "\u9FA0";
  31630. t["\u3036"] = "\u3012";
  31631. t["\u3038"] = "\u5341";
  31632. t["\u3039"] = "\u5344";
  31633. t["\u303A"] = "\u5345";
  31634. t["\u309B"] = "\u0020\u3099";
  31635. t["\u309C"] = "\u0020\u309A";
  31636. t["\u3131"] = "\u1100";
  31637. t["\u3132"] = "\u1101";
  31638. t["\u3133"] = "\u11AA";
  31639. t["\u3134"] = "\u1102";
  31640. t["\u3135"] = "\u11AC";
  31641. t["\u3136"] = "\u11AD";
  31642. t["\u3137"] = "\u1103";
  31643. t["\u3138"] = "\u1104";
  31644. t["\u3139"] = "\u1105";
  31645. t["\u313A"] = "\u11B0";
  31646. t["\u313B"] = "\u11B1";
  31647. t["\u313C"] = "\u11B2";
  31648. t["\u313D"] = "\u11B3";
  31649. t["\u313E"] = "\u11B4";
  31650. t["\u313F"] = "\u11B5";
  31651. t["\u3140"] = "\u111A";
  31652. t["\u3141"] = "\u1106";
  31653. t["\u3142"] = "\u1107";
  31654. t["\u3143"] = "\u1108";
  31655. t["\u3144"] = "\u1121";
  31656. t["\u3145"] = "\u1109";
  31657. t["\u3146"] = "\u110A";
  31658. t["\u3147"] = "\u110B";
  31659. t["\u3148"] = "\u110C";
  31660. t["\u3149"] = "\u110D";
  31661. t["\u314A"] = "\u110E";
  31662. t["\u314B"] = "\u110F";
  31663. t["\u314C"] = "\u1110";
  31664. t["\u314D"] = "\u1111";
  31665. t["\u314E"] = "\u1112";
  31666. t["\u314F"] = "\u1161";
  31667. t["\u3150"] = "\u1162";
  31668. t["\u3151"] = "\u1163";
  31669. t["\u3152"] = "\u1164";
  31670. t["\u3153"] = "\u1165";
  31671. t["\u3154"] = "\u1166";
  31672. t["\u3155"] = "\u1167";
  31673. t["\u3156"] = "\u1168";
  31674. t["\u3157"] = "\u1169";
  31675. t["\u3158"] = "\u116A";
  31676. t["\u3159"] = "\u116B";
  31677. t["\u315A"] = "\u116C";
  31678. t["\u315B"] = "\u116D";
  31679. t["\u315C"] = "\u116E";
  31680. t["\u315D"] = "\u116F";
  31681. t["\u315E"] = "\u1170";
  31682. t["\u315F"] = "\u1171";
  31683. t["\u3160"] = "\u1172";
  31684. t["\u3161"] = "\u1173";
  31685. t["\u3162"] = "\u1174";
  31686. t["\u3163"] = "\u1175";
  31687. t["\u3164"] = "\u1160";
  31688. t["\u3165"] = "\u1114";
  31689. t["\u3166"] = "\u1115";
  31690. t["\u3167"] = "\u11C7";
  31691. t["\u3168"] = "\u11C8";
  31692. t["\u3169"] = "\u11CC";
  31693. t["\u316A"] = "\u11CE";
  31694. t["\u316B"] = "\u11D3";
  31695. t["\u316C"] = "\u11D7";
  31696. t["\u316D"] = "\u11D9";
  31697. t["\u316E"] = "\u111C";
  31698. t["\u316F"] = "\u11DD";
  31699. t["\u3170"] = "\u11DF";
  31700. t["\u3171"] = "\u111D";
  31701. t["\u3172"] = "\u111E";
  31702. t["\u3173"] = "\u1120";
  31703. t["\u3174"] = "\u1122";
  31704. t["\u3175"] = "\u1123";
  31705. t["\u3176"] = "\u1127";
  31706. t["\u3177"] = "\u1129";
  31707. t["\u3178"] = "\u112B";
  31708. t["\u3179"] = "\u112C";
  31709. t["\u317A"] = "\u112D";
  31710. t["\u317B"] = "\u112E";
  31711. t["\u317C"] = "\u112F";
  31712. t["\u317D"] = "\u1132";
  31713. t["\u317E"] = "\u1136";
  31714. t["\u317F"] = "\u1140";
  31715. t["\u3180"] = "\u1147";
  31716. t["\u3181"] = "\u114C";
  31717. t["\u3182"] = "\u11F1";
  31718. t["\u3183"] = "\u11F2";
  31719. t["\u3184"] = "\u1157";
  31720. t["\u3185"] = "\u1158";
  31721. t["\u3186"] = "\u1159";
  31722. t["\u3187"] = "\u1184";
  31723. t["\u3188"] = "\u1185";
  31724. t["\u3189"] = "\u1188";
  31725. t["\u318A"] = "\u1191";
  31726. t["\u318B"] = "\u1192";
  31727. t["\u318C"] = "\u1194";
  31728. t["\u318D"] = "\u119E";
  31729. t["\u318E"] = "\u11A1";
  31730. t["\u3200"] = "\u0028\u1100\u0029";
  31731. t["\u3201"] = "\u0028\u1102\u0029";
  31732. t["\u3202"] = "\u0028\u1103\u0029";
  31733. t["\u3203"] = "\u0028\u1105\u0029";
  31734. t["\u3204"] = "\u0028\u1106\u0029";
  31735. t["\u3205"] = "\u0028\u1107\u0029";
  31736. t["\u3206"] = "\u0028\u1109\u0029";
  31737. t["\u3207"] = "\u0028\u110B\u0029";
  31738. t["\u3208"] = "\u0028\u110C\u0029";
  31739. t["\u3209"] = "\u0028\u110E\u0029";
  31740. t["\u320A"] = "\u0028\u110F\u0029";
  31741. t["\u320B"] = "\u0028\u1110\u0029";
  31742. t["\u320C"] = "\u0028\u1111\u0029";
  31743. t["\u320D"] = "\u0028\u1112\u0029";
  31744. t["\u320E"] = "\u0028\u1100\u1161\u0029";
  31745. t["\u320F"] = "\u0028\u1102\u1161\u0029";
  31746. t["\u3210"] = "\u0028\u1103\u1161\u0029";
  31747. t["\u3211"] = "\u0028\u1105\u1161\u0029";
  31748. t["\u3212"] = "\u0028\u1106\u1161\u0029";
  31749. t["\u3213"] = "\u0028\u1107\u1161\u0029";
  31750. t["\u3214"] = "\u0028\u1109\u1161\u0029";
  31751. t["\u3215"] = "\u0028\u110B\u1161\u0029";
  31752. t["\u3216"] = "\u0028\u110C\u1161\u0029";
  31753. t["\u3217"] = "\u0028\u110E\u1161\u0029";
  31754. t["\u3218"] = "\u0028\u110F\u1161\u0029";
  31755. t["\u3219"] = "\u0028\u1110\u1161\u0029";
  31756. t["\u321A"] = "\u0028\u1111\u1161\u0029";
  31757. t["\u321B"] = "\u0028\u1112\u1161\u0029";
  31758. t["\u321C"] = "\u0028\u110C\u116E\u0029";
  31759. t["\u321D"] = "\u0028\u110B\u1169\u110C\u1165\u11AB\u0029";
  31760. t["\u321E"] = "\u0028\u110B\u1169\u1112\u116E\u0029";
  31761. t["\u3220"] = "\u0028\u4E00\u0029";
  31762. t["\u3221"] = "\u0028\u4E8C\u0029";
  31763. t["\u3222"] = "\u0028\u4E09\u0029";
  31764. t["\u3223"] = "\u0028\u56DB\u0029";
  31765. t["\u3224"] = "\u0028\u4E94\u0029";
  31766. t["\u3225"] = "\u0028\u516D\u0029";
  31767. t["\u3226"] = "\u0028\u4E03\u0029";
  31768. t["\u3227"] = "\u0028\u516B\u0029";
  31769. t["\u3228"] = "\u0028\u4E5D\u0029";
  31770. t["\u3229"] = "\u0028\u5341\u0029";
  31771. t["\u322A"] = "\u0028\u6708\u0029";
  31772. t["\u322B"] = "\u0028\u706B\u0029";
  31773. t["\u322C"] = "\u0028\u6C34\u0029";
  31774. t["\u322D"] = "\u0028\u6728\u0029";
  31775. t["\u322E"] = "\u0028\u91D1\u0029";
  31776. t["\u322F"] = "\u0028\u571F\u0029";
  31777. t["\u3230"] = "\u0028\u65E5\u0029";
  31778. t["\u3231"] = "\u0028\u682A\u0029";
  31779. t["\u3232"] = "\u0028\u6709\u0029";
  31780. t["\u3233"] = "\u0028\u793E\u0029";
  31781. t["\u3234"] = "\u0028\u540D\u0029";
  31782. t["\u3235"] = "\u0028\u7279\u0029";
  31783. t["\u3236"] = "\u0028\u8CA1\u0029";
  31784. t["\u3237"] = "\u0028\u795D\u0029";
  31785. t["\u3238"] = "\u0028\u52B4\u0029";
  31786. t["\u3239"] = "\u0028\u4EE3\u0029";
  31787. t["\u323A"] = "\u0028\u547C\u0029";
  31788. t["\u323B"] = "\u0028\u5B66\u0029";
  31789. t["\u323C"] = "\u0028\u76E3\u0029";
  31790. t["\u323D"] = "\u0028\u4F01\u0029";
  31791. t["\u323E"] = "\u0028\u8CC7\u0029";
  31792. t["\u323F"] = "\u0028\u5354\u0029";
  31793. t["\u3240"] = "\u0028\u796D\u0029";
  31794. t["\u3241"] = "\u0028\u4F11\u0029";
  31795. t["\u3242"] = "\u0028\u81EA\u0029";
  31796. t["\u3243"] = "\u0028\u81F3\u0029";
  31797. t["\u32C0"] = "\u0031\u6708";
  31798. t["\u32C1"] = "\u0032\u6708";
  31799. t["\u32C2"] = "\u0033\u6708";
  31800. t["\u32C3"] = "\u0034\u6708";
  31801. t["\u32C4"] = "\u0035\u6708";
  31802. t["\u32C5"] = "\u0036\u6708";
  31803. t["\u32C6"] = "\u0037\u6708";
  31804. t["\u32C7"] = "\u0038\u6708";
  31805. t["\u32C8"] = "\u0039\u6708";
  31806. t["\u32C9"] = "\u0031\u0030\u6708";
  31807. t["\u32CA"] = "\u0031\u0031\u6708";
  31808. t["\u32CB"] = "\u0031\u0032\u6708";
  31809. t["\u3358"] = "\u0030\u70B9";
  31810. t["\u3359"] = "\u0031\u70B9";
  31811. t["\u335A"] = "\u0032\u70B9";
  31812. t["\u335B"] = "\u0033\u70B9";
  31813. t["\u335C"] = "\u0034\u70B9";
  31814. t["\u335D"] = "\u0035\u70B9";
  31815. t["\u335E"] = "\u0036\u70B9";
  31816. t["\u335F"] = "\u0037\u70B9";
  31817. t["\u3360"] = "\u0038\u70B9";
  31818. t["\u3361"] = "\u0039\u70B9";
  31819. t["\u3362"] = "\u0031\u0030\u70B9";
  31820. t["\u3363"] = "\u0031\u0031\u70B9";
  31821. t["\u3364"] = "\u0031\u0032\u70B9";
  31822. t["\u3365"] = "\u0031\u0033\u70B9";
  31823. t["\u3366"] = "\u0031\u0034\u70B9";
  31824. t["\u3367"] = "\u0031\u0035\u70B9";
  31825. t["\u3368"] = "\u0031\u0036\u70B9";
  31826. t["\u3369"] = "\u0031\u0037\u70B9";
  31827. t["\u336A"] = "\u0031\u0038\u70B9";
  31828. t["\u336B"] = "\u0031\u0039\u70B9";
  31829. t["\u336C"] = "\u0032\u0030\u70B9";
  31830. t["\u336D"] = "\u0032\u0031\u70B9";
  31831. t["\u336E"] = "\u0032\u0032\u70B9";
  31832. t["\u336F"] = "\u0032\u0033\u70B9";
  31833. t["\u3370"] = "\u0032\u0034\u70B9";
  31834. t["\u33E0"] = "\u0031\u65E5";
  31835. t["\u33E1"] = "\u0032\u65E5";
  31836. t["\u33E2"] = "\u0033\u65E5";
  31837. t["\u33E3"] = "\u0034\u65E5";
  31838. t["\u33E4"] = "\u0035\u65E5";
  31839. t["\u33E5"] = "\u0036\u65E5";
  31840. t["\u33E6"] = "\u0037\u65E5";
  31841. t["\u33E7"] = "\u0038\u65E5";
  31842. t["\u33E8"] = "\u0039\u65E5";
  31843. t["\u33E9"] = "\u0031\u0030\u65E5";
  31844. t["\u33EA"] = "\u0031\u0031\u65E5";
  31845. t["\u33EB"] = "\u0031\u0032\u65E5";
  31846. t["\u33EC"] = "\u0031\u0033\u65E5";
  31847. t["\u33ED"] = "\u0031\u0034\u65E5";
  31848. t["\u33EE"] = "\u0031\u0035\u65E5";
  31849. t["\u33EF"] = "\u0031\u0036\u65E5";
  31850. t["\u33F0"] = "\u0031\u0037\u65E5";
  31851. t["\u33F1"] = "\u0031\u0038\u65E5";
  31852. t["\u33F2"] = "\u0031\u0039\u65E5";
  31853. t["\u33F3"] = "\u0032\u0030\u65E5";
  31854. t["\u33F4"] = "\u0032\u0031\u65E5";
  31855. t["\u33F5"] = "\u0032\u0032\u65E5";
  31856. t["\u33F6"] = "\u0032\u0033\u65E5";
  31857. t["\u33F7"] = "\u0032\u0034\u65E5";
  31858. t["\u33F8"] = "\u0032\u0035\u65E5";
  31859. t["\u33F9"] = "\u0032\u0036\u65E5";
  31860. t["\u33FA"] = "\u0032\u0037\u65E5";
  31861. t["\u33FB"] = "\u0032\u0038\u65E5";
  31862. t["\u33FC"] = "\u0032\u0039\u65E5";
  31863. t["\u33FD"] = "\u0033\u0030\u65E5";
  31864. t["\u33FE"] = "\u0033\u0031\u65E5";
  31865. t["\uFB00"] = "\u0066\u0066";
  31866. t["\uFB01"] = "\u0066\u0069";
  31867. t["\uFB02"] = "\u0066\u006C";
  31868. t["\uFB03"] = "\u0066\u0066\u0069";
  31869. t["\uFB04"] = "\u0066\u0066\u006C";
  31870. t["\uFB05"] = "\u017F\u0074";
  31871. t["\uFB06"] = "\u0073\u0074";
  31872. t["\uFB13"] = "\u0574\u0576";
  31873. t["\uFB14"] = "\u0574\u0565";
  31874. t["\uFB15"] = "\u0574\u056B";
  31875. t["\uFB16"] = "\u057E\u0576";
  31876. t["\uFB17"] = "\u0574\u056D";
  31877. t["\uFB4F"] = "\u05D0\u05DC";
  31878. t["\uFB50"] = "\u0671";
  31879. t["\uFB51"] = "\u0671";
  31880. t["\uFB52"] = "\u067B";
  31881. t["\uFB53"] = "\u067B";
  31882. t["\uFB54"] = "\u067B";
  31883. t["\uFB55"] = "\u067B";
  31884. t["\uFB56"] = "\u067E";
  31885. t["\uFB57"] = "\u067E";
  31886. t["\uFB58"] = "\u067E";
  31887. t["\uFB59"] = "\u067E";
  31888. t["\uFB5A"] = "\u0680";
  31889. t["\uFB5B"] = "\u0680";
  31890. t["\uFB5C"] = "\u0680";
  31891. t["\uFB5D"] = "\u0680";
  31892. t["\uFB5E"] = "\u067A";
  31893. t["\uFB5F"] = "\u067A";
  31894. t["\uFB60"] = "\u067A";
  31895. t["\uFB61"] = "\u067A";
  31896. t["\uFB62"] = "\u067F";
  31897. t["\uFB63"] = "\u067F";
  31898. t["\uFB64"] = "\u067F";
  31899. t["\uFB65"] = "\u067F";
  31900. t["\uFB66"] = "\u0679";
  31901. t["\uFB67"] = "\u0679";
  31902. t["\uFB68"] = "\u0679";
  31903. t["\uFB69"] = "\u0679";
  31904. t["\uFB6A"] = "\u06A4";
  31905. t["\uFB6B"] = "\u06A4";
  31906. t["\uFB6C"] = "\u06A4";
  31907. t["\uFB6D"] = "\u06A4";
  31908. t["\uFB6E"] = "\u06A6";
  31909. t["\uFB6F"] = "\u06A6";
  31910. t["\uFB70"] = "\u06A6";
  31911. t["\uFB71"] = "\u06A6";
  31912. t["\uFB72"] = "\u0684";
  31913. t["\uFB73"] = "\u0684";
  31914. t["\uFB74"] = "\u0684";
  31915. t["\uFB75"] = "\u0684";
  31916. t["\uFB76"] = "\u0683";
  31917. t["\uFB77"] = "\u0683";
  31918. t["\uFB78"] = "\u0683";
  31919. t["\uFB79"] = "\u0683";
  31920. t["\uFB7A"] = "\u0686";
  31921. t["\uFB7B"] = "\u0686";
  31922. t["\uFB7C"] = "\u0686";
  31923. t["\uFB7D"] = "\u0686";
  31924. t["\uFB7E"] = "\u0687";
  31925. t["\uFB7F"] = "\u0687";
  31926. t["\uFB80"] = "\u0687";
  31927. t["\uFB81"] = "\u0687";
  31928. t["\uFB82"] = "\u068D";
  31929. t["\uFB83"] = "\u068D";
  31930. t["\uFB84"] = "\u068C";
  31931. t["\uFB85"] = "\u068C";
  31932. t["\uFB86"] = "\u068E";
  31933. t["\uFB87"] = "\u068E";
  31934. t["\uFB88"] = "\u0688";
  31935. t["\uFB89"] = "\u0688";
  31936. t["\uFB8A"] = "\u0698";
  31937. t["\uFB8B"] = "\u0698";
  31938. t["\uFB8C"] = "\u0691";
  31939. t["\uFB8D"] = "\u0691";
  31940. t["\uFB8E"] = "\u06A9";
  31941. t["\uFB8F"] = "\u06A9";
  31942. t["\uFB90"] = "\u06A9";
  31943. t["\uFB91"] = "\u06A9";
  31944. t["\uFB92"] = "\u06AF";
  31945. t["\uFB93"] = "\u06AF";
  31946. t["\uFB94"] = "\u06AF";
  31947. t["\uFB95"] = "\u06AF";
  31948. t["\uFB96"] = "\u06B3";
  31949. t["\uFB97"] = "\u06B3";
  31950. t["\uFB98"] = "\u06B3";
  31951. t["\uFB99"] = "\u06B3";
  31952. t["\uFB9A"] = "\u06B1";
  31953. t["\uFB9B"] = "\u06B1";
  31954. t["\uFB9C"] = "\u06B1";
  31955. t["\uFB9D"] = "\u06B1";
  31956. t["\uFB9E"] = "\u06BA";
  31957. t["\uFB9F"] = "\u06BA";
  31958. t["\uFBA0"] = "\u06BB";
  31959. t["\uFBA1"] = "\u06BB";
  31960. t["\uFBA2"] = "\u06BB";
  31961. t["\uFBA3"] = "\u06BB";
  31962. t["\uFBA4"] = "\u06C0";
  31963. t["\uFBA5"] = "\u06C0";
  31964. t["\uFBA6"] = "\u06C1";
  31965. t["\uFBA7"] = "\u06C1";
  31966. t["\uFBA8"] = "\u06C1";
  31967. t["\uFBA9"] = "\u06C1";
  31968. t["\uFBAA"] = "\u06BE";
  31969. t["\uFBAB"] = "\u06BE";
  31970. t["\uFBAC"] = "\u06BE";
  31971. t["\uFBAD"] = "\u06BE";
  31972. t["\uFBAE"] = "\u06D2";
  31973. t["\uFBAF"] = "\u06D2";
  31974. t["\uFBB0"] = "\u06D3";
  31975. t["\uFBB1"] = "\u06D3";
  31976. t["\uFBD3"] = "\u06AD";
  31977. t["\uFBD4"] = "\u06AD";
  31978. t["\uFBD5"] = "\u06AD";
  31979. t["\uFBD6"] = "\u06AD";
  31980. t["\uFBD7"] = "\u06C7";
  31981. t["\uFBD8"] = "\u06C7";
  31982. t["\uFBD9"] = "\u06C6";
  31983. t["\uFBDA"] = "\u06C6";
  31984. t["\uFBDB"] = "\u06C8";
  31985. t["\uFBDC"] = "\u06C8";
  31986. t["\uFBDD"] = "\u0677";
  31987. t["\uFBDE"] = "\u06CB";
  31988. t["\uFBDF"] = "\u06CB";
  31989. t["\uFBE0"] = "\u06C5";
  31990. t["\uFBE1"] = "\u06C5";
  31991. t["\uFBE2"] = "\u06C9";
  31992. t["\uFBE3"] = "\u06C9";
  31993. t["\uFBE4"] = "\u06D0";
  31994. t["\uFBE5"] = "\u06D0";
  31995. t["\uFBE6"] = "\u06D0";
  31996. t["\uFBE7"] = "\u06D0";
  31997. t["\uFBE8"] = "\u0649";
  31998. t["\uFBE9"] = "\u0649";
  31999. t["\uFBEA"] = "\u0626\u0627";
  32000. t["\uFBEB"] = "\u0626\u0627";
  32001. t["\uFBEC"] = "\u0626\u06D5";
  32002. t["\uFBED"] = "\u0626\u06D5";
  32003. t["\uFBEE"] = "\u0626\u0648";
  32004. t["\uFBEF"] = "\u0626\u0648";
  32005. t["\uFBF0"] = "\u0626\u06C7";
  32006. t["\uFBF1"] = "\u0626\u06C7";
  32007. t["\uFBF2"] = "\u0626\u06C6";
  32008. t["\uFBF3"] = "\u0626\u06C6";
  32009. t["\uFBF4"] = "\u0626\u06C8";
  32010. t["\uFBF5"] = "\u0626\u06C8";
  32011. t["\uFBF6"] = "\u0626\u06D0";
  32012. t["\uFBF7"] = "\u0626\u06D0";
  32013. t["\uFBF8"] = "\u0626\u06D0";
  32014. t["\uFBF9"] = "\u0626\u0649";
  32015. t["\uFBFA"] = "\u0626\u0649";
  32016. t["\uFBFB"] = "\u0626\u0649";
  32017. t["\uFBFC"] = "\u06CC";
  32018. t["\uFBFD"] = "\u06CC";
  32019. t["\uFBFE"] = "\u06CC";
  32020. t["\uFBFF"] = "\u06CC";
  32021. t["\uFC00"] = "\u0626\u062C";
  32022. t["\uFC01"] = "\u0626\u062D";
  32023. t["\uFC02"] = "\u0626\u0645";
  32024. t["\uFC03"] = "\u0626\u0649";
  32025. t["\uFC04"] = "\u0626\u064A";
  32026. t["\uFC05"] = "\u0628\u062C";
  32027. t["\uFC06"] = "\u0628\u062D";
  32028. t["\uFC07"] = "\u0628\u062E";
  32029. t["\uFC08"] = "\u0628\u0645";
  32030. t["\uFC09"] = "\u0628\u0649";
  32031. t["\uFC0A"] = "\u0628\u064A";
  32032. t["\uFC0B"] = "\u062A\u062C";
  32033. t["\uFC0C"] = "\u062A\u062D";
  32034. t["\uFC0D"] = "\u062A\u062E";
  32035. t["\uFC0E"] = "\u062A\u0645";
  32036. t["\uFC0F"] = "\u062A\u0649";
  32037. t["\uFC10"] = "\u062A\u064A";
  32038. t["\uFC11"] = "\u062B\u062C";
  32039. t["\uFC12"] = "\u062B\u0645";
  32040. t["\uFC13"] = "\u062B\u0649";
  32041. t["\uFC14"] = "\u062B\u064A";
  32042. t["\uFC15"] = "\u062C\u062D";
  32043. t["\uFC16"] = "\u062C\u0645";
  32044. t["\uFC17"] = "\u062D\u062C";
  32045. t["\uFC18"] = "\u062D\u0645";
  32046. t["\uFC19"] = "\u062E\u062C";
  32047. t["\uFC1A"] = "\u062E\u062D";
  32048. t["\uFC1B"] = "\u062E\u0645";
  32049. t["\uFC1C"] = "\u0633\u062C";
  32050. t["\uFC1D"] = "\u0633\u062D";
  32051. t["\uFC1E"] = "\u0633\u062E";
  32052. t["\uFC1F"] = "\u0633\u0645";
  32053. t["\uFC20"] = "\u0635\u062D";
  32054. t["\uFC21"] = "\u0635\u0645";
  32055. t["\uFC22"] = "\u0636\u062C";
  32056. t["\uFC23"] = "\u0636\u062D";
  32057. t["\uFC24"] = "\u0636\u062E";
  32058. t["\uFC25"] = "\u0636\u0645";
  32059. t["\uFC26"] = "\u0637\u062D";
  32060. t["\uFC27"] = "\u0637\u0645";
  32061. t["\uFC28"] = "\u0638\u0645";
  32062. t["\uFC29"] = "\u0639\u062C";
  32063. t["\uFC2A"] = "\u0639\u0645";
  32064. t["\uFC2B"] = "\u063A\u062C";
  32065. t["\uFC2C"] = "\u063A\u0645";
  32066. t["\uFC2D"] = "\u0641\u062C";
  32067. t["\uFC2E"] = "\u0641\u062D";
  32068. t["\uFC2F"] = "\u0641\u062E";
  32069. t["\uFC30"] = "\u0641\u0645";
  32070. t["\uFC31"] = "\u0641\u0649";
  32071. t["\uFC32"] = "\u0641\u064A";
  32072. t["\uFC33"] = "\u0642\u062D";
  32073. t["\uFC34"] = "\u0642\u0645";
  32074. t["\uFC35"] = "\u0642\u0649";
  32075. t["\uFC36"] = "\u0642\u064A";
  32076. t["\uFC37"] = "\u0643\u0627";
  32077. t["\uFC38"] = "\u0643\u062C";
  32078. t["\uFC39"] = "\u0643\u062D";
  32079. t["\uFC3A"] = "\u0643\u062E";
  32080. t["\uFC3B"] = "\u0643\u0644";
  32081. t["\uFC3C"] = "\u0643\u0645";
  32082. t["\uFC3D"] = "\u0643\u0649";
  32083. t["\uFC3E"] = "\u0643\u064A";
  32084. t["\uFC3F"] = "\u0644\u062C";
  32085. t["\uFC40"] = "\u0644\u062D";
  32086. t["\uFC41"] = "\u0644\u062E";
  32087. t["\uFC42"] = "\u0644\u0645";
  32088. t["\uFC43"] = "\u0644\u0649";
  32089. t["\uFC44"] = "\u0644\u064A";
  32090. t["\uFC45"] = "\u0645\u062C";
  32091. t["\uFC46"] = "\u0645\u062D";
  32092. t["\uFC47"] = "\u0645\u062E";
  32093. t["\uFC48"] = "\u0645\u0645";
  32094. t["\uFC49"] = "\u0645\u0649";
  32095. t["\uFC4A"] = "\u0645\u064A";
  32096. t["\uFC4B"] = "\u0646\u062C";
  32097. t["\uFC4C"] = "\u0646\u062D";
  32098. t["\uFC4D"] = "\u0646\u062E";
  32099. t["\uFC4E"] = "\u0646\u0645";
  32100. t["\uFC4F"] = "\u0646\u0649";
  32101. t["\uFC50"] = "\u0646\u064A";
  32102. t["\uFC51"] = "\u0647\u062C";
  32103. t["\uFC52"] = "\u0647\u0645";
  32104. t["\uFC53"] = "\u0647\u0649";
  32105. t["\uFC54"] = "\u0647\u064A";
  32106. t["\uFC55"] = "\u064A\u062C";
  32107. t["\uFC56"] = "\u064A\u062D";
  32108. t["\uFC57"] = "\u064A\u062E";
  32109. t["\uFC58"] = "\u064A\u0645";
  32110. t["\uFC59"] = "\u064A\u0649";
  32111. t["\uFC5A"] = "\u064A\u064A";
  32112. t["\uFC5B"] = "\u0630\u0670";
  32113. t["\uFC5C"] = "\u0631\u0670";
  32114. t["\uFC5D"] = "\u0649\u0670";
  32115. t["\uFC5E"] = "\u0020\u064C\u0651";
  32116. t["\uFC5F"] = "\u0020\u064D\u0651";
  32117. t["\uFC60"] = "\u0020\u064E\u0651";
  32118. t["\uFC61"] = "\u0020\u064F\u0651";
  32119. t["\uFC62"] = "\u0020\u0650\u0651";
  32120. t["\uFC63"] = "\u0020\u0651\u0670";
  32121. t["\uFC64"] = "\u0626\u0631";
  32122. t["\uFC65"] = "\u0626\u0632";
  32123. t["\uFC66"] = "\u0626\u0645";
  32124. t["\uFC67"] = "\u0626\u0646";
  32125. t["\uFC68"] = "\u0626\u0649";
  32126. t["\uFC69"] = "\u0626\u064A";
  32127. t["\uFC6A"] = "\u0628\u0631";
  32128. t["\uFC6B"] = "\u0628\u0632";
  32129. t["\uFC6C"] = "\u0628\u0645";
  32130. t["\uFC6D"] = "\u0628\u0646";
  32131. t["\uFC6E"] = "\u0628\u0649";
  32132. t["\uFC6F"] = "\u0628\u064A";
  32133. t["\uFC70"] = "\u062A\u0631";
  32134. t["\uFC71"] = "\u062A\u0632";
  32135. t["\uFC72"] = "\u062A\u0645";
  32136. t["\uFC73"] = "\u062A\u0646";
  32137. t["\uFC74"] = "\u062A\u0649";
  32138. t["\uFC75"] = "\u062A\u064A";
  32139. t["\uFC76"] = "\u062B\u0631";
  32140. t["\uFC77"] = "\u062B\u0632";
  32141. t["\uFC78"] = "\u062B\u0645";
  32142. t["\uFC79"] = "\u062B\u0646";
  32143. t["\uFC7A"] = "\u062B\u0649";
  32144. t["\uFC7B"] = "\u062B\u064A";
  32145. t["\uFC7C"] = "\u0641\u0649";
  32146. t["\uFC7D"] = "\u0641\u064A";
  32147. t["\uFC7E"] = "\u0642\u0649";
  32148. t["\uFC7F"] = "\u0642\u064A";
  32149. t["\uFC80"] = "\u0643\u0627";
  32150. t["\uFC81"] = "\u0643\u0644";
  32151. t["\uFC82"] = "\u0643\u0645";
  32152. t["\uFC83"] = "\u0643\u0649";
  32153. t["\uFC84"] = "\u0643\u064A";
  32154. t["\uFC85"] = "\u0644\u0645";
  32155. t["\uFC86"] = "\u0644\u0649";
  32156. t["\uFC87"] = "\u0644\u064A";
  32157. t["\uFC88"] = "\u0645\u0627";
  32158. t["\uFC89"] = "\u0645\u0645";
  32159. t["\uFC8A"] = "\u0646\u0631";
  32160. t["\uFC8B"] = "\u0646\u0632";
  32161. t["\uFC8C"] = "\u0646\u0645";
  32162. t["\uFC8D"] = "\u0646\u0646";
  32163. t["\uFC8E"] = "\u0646\u0649";
  32164. t["\uFC8F"] = "\u0646\u064A";
  32165. t["\uFC90"] = "\u0649\u0670";
  32166. t["\uFC91"] = "\u064A\u0631";
  32167. t["\uFC92"] = "\u064A\u0632";
  32168. t["\uFC93"] = "\u064A\u0645";
  32169. t["\uFC94"] = "\u064A\u0646";
  32170. t["\uFC95"] = "\u064A\u0649";
  32171. t["\uFC96"] = "\u064A\u064A";
  32172. t["\uFC97"] = "\u0626\u062C";
  32173. t["\uFC98"] = "\u0626\u062D";
  32174. t["\uFC99"] = "\u0626\u062E";
  32175. t["\uFC9A"] = "\u0626\u0645";
  32176. t["\uFC9B"] = "\u0626\u0647";
  32177. t["\uFC9C"] = "\u0628\u062C";
  32178. t["\uFC9D"] = "\u0628\u062D";
  32179. t["\uFC9E"] = "\u0628\u062E";
  32180. t["\uFC9F"] = "\u0628\u0645";
  32181. t["\uFCA0"] = "\u0628\u0647";
  32182. t["\uFCA1"] = "\u062A\u062C";
  32183. t["\uFCA2"] = "\u062A\u062D";
  32184. t["\uFCA3"] = "\u062A\u062E";
  32185. t["\uFCA4"] = "\u062A\u0645";
  32186. t["\uFCA5"] = "\u062A\u0647";
  32187. t["\uFCA6"] = "\u062B\u0645";
  32188. t["\uFCA7"] = "\u062C\u062D";
  32189. t["\uFCA8"] = "\u062C\u0645";
  32190. t["\uFCA9"] = "\u062D\u062C";
  32191. t["\uFCAA"] = "\u062D\u0645";
  32192. t["\uFCAB"] = "\u062E\u062C";
  32193. t["\uFCAC"] = "\u062E\u0645";
  32194. t["\uFCAD"] = "\u0633\u062C";
  32195. t["\uFCAE"] = "\u0633\u062D";
  32196. t["\uFCAF"] = "\u0633\u062E";
  32197. t["\uFCB0"] = "\u0633\u0645";
  32198. t["\uFCB1"] = "\u0635\u062D";
  32199. t["\uFCB2"] = "\u0635\u062E";
  32200. t["\uFCB3"] = "\u0635\u0645";
  32201. t["\uFCB4"] = "\u0636\u062C";
  32202. t["\uFCB5"] = "\u0636\u062D";
  32203. t["\uFCB6"] = "\u0636\u062E";
  32204. t["\uFCB7"] = "\u0636\u0645";
  32205. t["\uFCB8"] = "\u0637\u062D";
  32206. t["\uFCB9"] = "\u0638\u0645";
  32207. t["\uFCBA"] = "\u0639\u062C";
  32208. t["\uFCBB"] = "\u0639\u0645";
  32209. t["\uFCBC"] = "\u063A\u062C";
  32210. t["\uFCBD"] = "\u063A\u0645";
  32211. t["\uFCBE"] = "\u0641\u062C";
  32212. t["\uFCBF"] = "\u0641\u062D";
  32213. t["\uFCC0"] = "\u0641\u062E";
  32214. t["\uFCC1"] = "\u0641\u0645";
  32215. t["\uFCC2"] = "\u0642\u062D";
  32216. t["\uFCC3"] = "\u0642\u0645";
  32217. t["\uFCC4"] = "\u0643\u062C";
  32218. t["\uFCC5"] = "\u0643\u062D";
  32219. t["\uFCC6"] = "\u0643\u062E";
  32220. t["\uFCC7"] = "\u0643\u0644";
  32221. t["\uFCC8"] = "\u0643\u0645";
  32222. t["\uFCC9"] = "\u0644\u062C";
  32223. t["\uFCCA"] = "\u0644\u062D";
  32224. t["\uFCCB"] = "\u0644\u062E";
  32225. t["\uFCCC"] = "\u0644\u0645";
  32226. t["\uFCCD"] = "\u0644\u0647";
  32227. t["\uFCCE"] = "\u0645\u062C";
  32228. t["\uFCCF"] = "\u0645\u062D";
  32229. t["\uFCD0"] = "\u0645\u062E";
  32230. t["\uFCD1"] = "\u0645\u0645";
  32231. t["\uFCD2"] = "\u0646\u062C";
  32232. t["\uFCD3"] = "\u0646\u062D";
  32233. t["\uFCD4"] = "\u0646\u062E";
  32234. t["\uFCD5"] = "\u0646\u0645";
  32235. t["\uFCD6"] = "\u0646\u0647";
  32236. t["\uFCD7"] = "\u0647\u062C";
  32237. t["\uFCD8"] = "\u0647\u0645";
  32238. t["\uFCD9"] = "\u0647\u0670";
  32239. t["\uFCDA"] = "\u064A\u062C";
  32240. t["\uFCDB"] = "\u064A\u062D";
  32241. t["\uFCDC"] = "\u064A\u062E";
  32242. t["\uFCDD"] = "\u064A\u0645";
  32243. t["\uFCDE"] = "\u064A\u0647";
  32244. t["\uFCDF"] = "\u0626\u0645";
  32245. t["\uFCE0"] = "\u0626\u0647";
  32246. t["\uFCE1"] = "\u0628\u0645";
  32247. t["\uFCE2"] = "\u0628\u0647";
  32248. t["\uFCE3"] = "\u062A\u0645";
  32249. t["\uFCE4"] = "\u062A\u0647";
  32250. t["\uFCE5"] = "\u062B\u0645";
  32251. t["\uFCE6"] = "\u062B\u0647";
  32252. t["\uFCE7"] = "\u0633\u0645";
  32253. t["\uFCE8"] = "\u0633\u0647";
  32254. t["\uFCE9"] = "\u0634\u0645";
  32255. t["\uFCEA"] = "\u0634\u0647";
  32256. t["\uFCEB"] = "\u0643\u0644";
  32257. t["\uFCEC"] = "\u0643\u0645";
  32258. t["\uFCED"] = "\u0644\u0645";
  32259. t["\uFCEE"] = "\u0646\u0645";
  32260. t["\uFCEF"] = "\u0646\u0647";
  32261. t["\uFCF0"] = "\u064A\u0645";
  32262. t["\uFCF1"] = "\u064A\u0647";
  32263. t["\uFCF2"] = "\u0640\u064E\u0651";
  32264. t["\uFCF3"] = "\u0640\u064F\u0651";
  32265. t["\uFCF4"] = "\u0640\u0650\u0651";
  32266. t["\uFCF5"] = "\u0637\u0649";
  32267. t["\uFCF6"] = "\u0637\u064A";
  32268. t["\uFCF7"] = "\u0639\u0649";
  32269. t["\uFCF8"] = "\u0639\u064A";
  32270. t["\uFCF9"] = "\u063A\u0649";
  32271. t["\uFCFA"] = "\u063A\u064A";
  32272. t["\uFCFB"] = "\u0633\u0649";
  32273. t["\uFCFC"] = "\u0633\u064A";
  32274. t["\uFCFD"] = "\u0634\u0649";
  32275. t["\uFCFE"] = "\u0634\u064A";
  32276. t["\uFCFF"] = "\u062D\u0649";
  32277. t["\uFD00"] = "\u062D\u064A";
  32278. t["\uFD01"] = "\u062C\u0649";
  32279. t["\uFD02"] = "\u062C\u064A";
  32280. t["\uFD03"] = "\u062E\u0649";
  32281. t["\uFD04"] = "\u062E\u064A";
  32282. t["\uFD05"] = "\u0635\u0649";
  32283. t["\uFD06"] = "\u0635\u064A";
  32284. t["\uFD07"] = "\u0636\u0649";
  32285. t["\uFD08"] = "\u0636\u064A";
  32286. t["\uFD09"] = "\u0634\u062C";
  32287. t["\uFD0A"] = "\u0634\u062D";
  32288. t["\uFD0B"] = "\u0634\u062E";
  32289. t["\uFD0C"] = "\u0634\u0645";
  32290. t["\uFD0D"] = "\u0634\u0631";
  32291. t["\uFD0E"] = "\u0633\u0631";
  32292. t["\uFD0F"] = "\u0635\u0631";
  32293. t["\uFD10"] = "\u0636\u0631";
  32294. t["\uFD11"] = "\u0637\u0649";
  32295. t["\uFD12"] = "\u0637\u064A";
  32296. t["\uFD13"] = "\u0639\u0649";
  32297. t["\uFD14"] = "\u0639\u064A";
  32298. t["\uFD15"] = "\u063A\u0649";
  32299. t["\uFD16"] = "\u063A\u064A";
  32300. t["\uFD17"] = "\u0633\u0649";
  32301. t["\uFD18"] = "\u0633\u064A";
  32302. t["\uFD19"] = "\u0634\u0649";
  32303. t["\uFD1A"] = "\u0634\u064A";
  32304. t["\uFD1B"] = "\u062D\u0649";
  32305. t["\uFD1C"] = "\u062D\u064A";
  32306. t["\uFD1D"] = "\u062C\u0649";
  32307. t["\uFD1E"] = "\u062C\u064A";
  32308. t["\uFD1F"] = "\u062E\u0649";
  32309. t["\uFD20"] = "\u062E\u064A";
  32310. t["\uFD21"] = "\u0635\u0649";
  32311. t["\uFD22"] = "\u0635\u064A";
  32312. t["\uFD23"] = "\u0636\u0649";
  32313. t["\uFD24"] = "\u0636\u064A";
  32314. t["\uFD25"] = "\u0634\u062C";
  32315. t["\uFD26"] = "\u0634\u062D";
  32316. t["\uFD27"] = "\u0634\u062E";
  32317. t["\uFD28"] = "\u0634\u0645";
  32318. t["\uFD29"] = "\u0634\u0631";
  32319. t["\uFD2A"] = "\u0633\u0631";
  32320. t["\uFD2B"] = "\u0635\u0631";
  32321. t["\uFD2C"] = "\u0636\u0631";
  32322. t["\uFD2D"] = "\u0634\u062C";
  32323. t["\uFD2E"] = "\u0634\u062D";
  32324. t["\uFD2F"] = "\u0634\u062E";
  32325. t["\uFD30"] = "\u0634\u0645";
  32326. t["\uFD31"] = "\u0633\u0647";
  32327. t["\uFD32"] = "\u0634\u0647";
  32328. t["\uFD33"] = "\u0637\u0645";
  32329. t["\uFD34"] = "\u0633\u062C";
  32330. t["\uFD35"] = "\u0633\u062D";
  32331. t["\uFD36"] = "\u0633\u062E";
  32332. t["\uFD37"] = "\u0634\u062C";
  32333. t["\uFD38"] = "\u0634\u062D";
  32334. t["\uFD39"] = "\u0634\u062E";
  32335. t["\uFD3A"] = "\u0637\u0645";
  32336. t["\uFD3B"] = "\u0638\u0645";
  32337. t["\uFD3C"] = "\u0627\u064B";
  32338. t["\uFD3D"] = "\u0627\u064B";
  32339. t["\uFD50"] = "\u062A\u062C\u0645";
  32340. t["\uFD51"] = "\u062A\u062D\u062C";
  32341. t["\uFD52"] = "\u062A\u062D\u062C";
  32342. t["\uFD53"] = "\u062A\u062D\u0645";
  32343. t["\uFD54"] = "\u062A\u062E\u0645";
  32344. t["\uFD55"] = "\u062A\u0645\u062C";
  32345. t["\uFD56"] = "\u062A\u0645\u062D";
  32346. t["\uFD57"] = "\u062A\u0645\u062E";
  32347. t["\uFD58"] = "\u062C\u0645\u062D";
  32348. t["\uFD59"] = "\u062C\u0645\u062D";
  32349. t["\uFD5A"] = "\u062D\u0645\u064A";
  32350. t["\uFD5B"] = "\u062D\u0645\u0649";
  32351. t["\uFD5C"] = "\u0633\u062D\u062C";
  32352. t["\uFD5D"] = "\u0633\u062C\u062D";
  32353. t["\uFD5E"] = "\u0633\u062C\u0649";
  32354. t["\uFD5F"] = "\u0633\u0645\u062D";
  32355. t["\uFD60"] = "\u0633\u0645\u062D";
  32356. t["\uFD61"] = "\u0633\u0645\u062C";
  32357. t["\uFD62"] = "\u0633\u0645\u0645";
  32358. t["\uFD63"] = "\u0633\u0645\u0645";
  32359. t["\uFD64"] = "\u0635\u062D\u062D";
  32360. t["\uFD65"] = "\u0635\u062D\u062D";
  32361. t["\uFD66"] = "\u0635\u0645\u0645";
  32362. t["\uFD67"] = "\u0634\u062D\u0645";
  32363. t["\uFD68"] = "\u0634\u062D\u0645";
  32364. t["\uFD69"] = "\u0634\u062C\u064A";
  32365. t["\uFD6A"] = "\u0634\u0645\u062E";
  32366. t["\uFD6B"] = "\u0634\u0645\u062E";
  32367. t["\uFD6C"] = "\u0634\u0645\u0645";
  32368. t["\uFD6D"] = "\u0634\u0645\u0645";
  32369. t["\uFD6E"] = "\u0636\u062D\u0649";
  32370. t["\uFD6F"] = "\u0636\u062E\u0645";
  32371. t["\uFD70"] = "\u0636\u062E\u0645";
  32372. t["\uFD71"] = "\u0637\u0645\u062D";
  32373. t["\uFD72"] = "\u0637\u0645\u062D";
  32374. t["\uFD73"] = "\u0637\u0645\u0645";
  32375. t["\uFD74"] = "\u0637\u0645\u064A";
  32376. t["\uFD75"] = "\u0639\u062C\u0645";
  32377. t["\uFD76"] = "\u0639\u0645\u0645";
  32378. t["\uFD77"] = "\u0639\u0645\u0645";
  32379. t["\uFD78"] = "\u0639\u0645\u0649";
  32380. t["\uFD79"] = "\u063A\u0645\u0645";
  32381. t["\uFD7A"] = "\u063A\u0645\u064A";
  32382. t["\uFD7B"] = "\u063A\u0645\u0649";
  32383. t["\uFD7C"] = "\u0641\u062E\u0645";
  32384. t["\uFD7D"] = "\u0641\u062E\u0645";
  32385. t["\uFD7E"] = "\u0642\u0645\u062D";
  32386. t["\uFD7F"] = "\u0642\u0645\u0645";
  32387. t["\uFD80"] = "\u0644\u062D\u0645";
  32388. t["\uFD81"] = "\u0644\u062D\u064A";
  32389. t["\uFD82"] = "\u0644\u062D\u0649";
  32390. t["\uFD83"] = "\u0644\u062C\u062C";
  32391. t["\uFD84"] = "\u0644\u062C\u062C";
  32392. t["\uFD85"] = "\u0644\u062E\u0645";
  32393. t["\uFD86"] = "\u0644\u062E\u0645";
  32394. t["\uFD87"] = "\u0644\u0645\u062D";
  32395. t["\uFD88"] = "\u0644\u0645\u062D";
  32396. t["\uFD89"] = "\u0645\u062D\u062C";
  32397. t["\uFD8A"] = "\u0645\u062D\u0645";
  32398. t["\uFD8B"] = "\u0645\u062D\u064A";
  32399. t["\uFD8C"] = "\u0645\u062C\u062D";
  32400. t["\uFD8D"] = "\u0645\u062C\u0645";
  32401. t["\uFD8E"] = "\u0645\u062E\u062C";
  32402. t["\uFD8F"] = "\u0645\u062E\u0645";
  32403. t["\uFD92"] = "\u0645\u062C\u062E";
  32404. t["\uFD93"] = "\u0647\u0645\u062C";
  32405. t["\uFD94"] = "\u0647\u0645\u0645";
  32406. t["\uFD95"] = "\u0646\u062D\u0645";
  32407. t["\uFD96"] = "\u0646\u062D\u0649";
  32408. t["\uFD97"] = "\u0646\u062C\u0645";
  32409. t["\uFD98"] = "\u0646\u062C\u0645";
  32410. t["\uFD99"] = "\u0646\u062C\u0649";
  32411. t["\uFD9A"] = "\u0646\u0645\u064A";
  32412. t["\uFD9B"] = "\u0646\u0645\u0649";
  32413. t["\uFD9C"] = "\u064A\u0645\u0645";
  32414. t["\uFD9D"] = "\u064A\u0645\u0645";
  32415. t["\uFD9E"] = "\u0628\u062E\u064A";
  32416. t["\uFD9F"] = "\u062A\u062C\u064A";
  32417. t["\uFDA0"] = "\u062A\u062C\u0649";
  32418. t["\uFDA1"] = "\u062A\u062E\u064A";
  32419. t["\uFDA2"] = "\u062A\u062E\u0649";
  32420. t["\uFDA3"] = "\u062A\u0645\u064A";
  32421. t["\uFDA4"] = "\u062A\u0645\u0649";
  32422. t["\uFDA5"] = "\u062C\u0645\u064A";
  32423. t["\uFDA6"] = "\u062C\u062D\u0649";
  32424. t["\uFDA7"] = "\u062C\u0645\u0649";
  32425. t["\uFDA8"] = "\u0633\u062E\u0649";
  32426. t["\uFDA9"] = "\u0635\u062D\u064A";
  32427. t["\uFDAA"] = "\u0634\u062D\u064A";
  32428. t["\uFDAB"] = "\u0636\u062D\u064A";
  32429. t["\uFDAC"] = "\u0644\u062C\u064A";
  32430. t["\uFDAD"] = "\u0644\u0645\u064A";
  32431. t["\uFDAE"] = "\u064A\u062D\u064A";
  32432. t["\uFDAF"] = "\u064A\u062C\u064A";
  32433. t["\uFDB0"] = "\u064A\u0645\u064A";
  32434. t["\uFDB1"] = "\u0645\u0645\u064A";
  32435. t["\uFDB2"] = "\u0642\u0645\u064A";
  32436. t["\uFDB3"] = "\u0646\u062D\u064A";
  32437. t["\uFDB4"] = "\u0642\u0645\u062D";
  32438. t["\uFDB5"] = "\u0644\u062D\u0645";
  32439. t["\uFDB6"] = "\u0639\u0645\u064A";
  32440. t["\uFDB7"] = "\u0643\u0645\u064A";
  32441. t["\uFDB8"] = "\u0646\u062C\u062D";
  32442. t["\uFDB9"] = "\u0645\u062E\u064A";
  32443. t["\uFDBA"] = "\u0644\u062C\u0645";
  32444. t["\uFDBB"] = "\u0643\u0645\u0645";
  32445. t["\uFDBC"] = "\u0644\u062C\u0645";
  32446. t["\uFDBD"] = "\u0646\u062C\u062D";
  32447. t["\uFDBE"] = "\u062C\u062D\u064A";
  32448. t["\uFDBF"] = "\u062D\u062C\u064A";
  32449. t["\uFDC0"] = "\u0645\u062C\u064A";
  32450. t["\uFDC1"] = "\u0641\u0645\u064A";
  32451. t["\uFDC2"] = "\u0628\u062D\u064A";
  32452. t["\uFDC3"] = "\u0643\u0645\u0645";
  32453. t["\uFDC4"] = "\u0639\u062C\u0645";
  32454. t["\uFDC5"] = "\u0635\u0645\u0645";
  32455. t["\uFDC6"] = "\u0633\u062E\u064A";
  32456. t["\uFDC7"] = "\u0646\u062C\u064A";
  32457. t["\uFE49"] = "\u203E";
  32458. t["\uFE4A"] = "\u203E";
  32459. t["\uFE4B"] = "\u203E";
  32460. t["\uFE4C"] = "\u203E";
  32461. t["\uFE4D"] = "\u005F";
  32462. t["\uFE4E"] = "\u005F";
  32463. t["\uFE4F"] = "\u005F";
  32464. t["\uFE80"] = "\u0621";
  32465. t["\uFE81"] = "\u0622";
  32466. t["\uFE82"] = "\u0622";
  32467. t["\uFE83"] = "\u0623";
  32468. t["\uFE84"] = "\u0623";
  32469. t["\uFE85"] = "\u0624";
  32470. t["\uFE86"] = "\u0624";
  32471. t["\uFE87"] = "\u0625";
  32472. t["\uFE88"] = "\u0625";
  32473. t["\uFE89"] = "\u0626";
  32474. t["\uFE8A"] = "\u0626";
  32475. t["\uFE8B"] = "\u0626";
  32476. t["\uFE8C"] = "\u0626";
  32477. t["\uFE8D"] = "\u0627";
  32478. t["\uFE8E"] = "\u0627";
  32479. t["\uFE8F"] = "\u0628";
  32480. t["\uFE90"] = "\u0628";
  32481. t["\uFE91"] = "\u0628";
  32482. t["\uFE92"] = "\u0628";
  32483. t["\uFE93"] = "\u0629";
  32484. t["\uFE94"] = "\u0629";
  32485. t["\uFE95"] = "\u062A";
  32486. t["\uFE96"] = "\u062A";
  32487. t["\uFE97"] = "\u062A";
  32488. t["\uFE98"] = "\u062A";
  32489. t["\uFE99"] = "\u062B";
  32490. t["\uFE9A"] = "\u062B";
  32491. t["\uFE9B"] = "\u062B";
  32492. t["\uFE9C"] = "\u062B";
  32493. t["\uFE9D"] = "\u062C";
  32494. t["\uFE9E"] = "\u062C";
  32495. t["\uFE9F"] = "\u062C";
  32496. t["\uFEA0"] = "\u062C";
  32497. t["\uFEA1"] = "\u062D";
  32498. t["\uFEA2"] = "\u062D";
  32499. t["\uFEA3"] = "\u062D";
  32500. t["\uFEA4"] = "\u062D";
  32501. t["\uFEA5"] = "\u062E";
  32502. t["\uFEA6"] = "\u062E";
  32503. t["\uFEA7"] = "\u062E";
  32504. t["\uFEA8"] = "\u062E";
  32505. t["\uFEA9"] = "\u062F";
  32506. t["\uFEAA"] = "\u062F";
  32507. t["\uFEAB"] = "\u0630";
  32508. t["\uFEAC"] = "\u0630";
  32509. t["\uFEAD"] = "\u0631";
  32510. t["\uFEAE"] = "\u0631";
  32511. t["\uFEAF"] = "\u0632";
  32512. t["\uFEB0"] = "\u0632";
  32513. t["\uFEB1"] = "\u0633";
  32514. t["\uFEB2"] = "\u0633";
  32515. t["\uFEB3"] = "\u0633";
  32516. t["\uFEB4"] = "\u0633";
  32517. t["\uFEB5"] = "\u0634";
  32518. t["\uFEB6"] = "\u0634";
  32519. t["\uFEB7"] = "\u0634";
  32520. t["\uFEB8"] = "\u0634";
  32521. t["\uFEB9"] = "\u0635";
  32522. t["\uFEBA"] = "\u0635";
  32523. t["\uFEBB"] = "\u0635";
  32524. t["\uFEBC"] = "\u0635";
  32525. t["\uFEBD"] = "\u0636";
  32526. t["\uFEBE"] = "\u0636";
  32527. t["\uFEBF"] = "\u0636";
  32528. t["\uFEC0"] = "\u0636";
  32529. t["\uFEC1"] = "\u0637";
  32530. t["\uFEC2"] = "\u0637";
  32531. t["\uFEC3"] = "\u0637";
  32532. t["\uFEC4"] = "\u0637";
  32533. t["\uFEC5"] = "\u0638";
  32534. t["\uFEC6"] = "\u0638";
  32535. t["\uFEC7"] = "\u0638";
  32536. t["\uFEC8"] = "\u0638";
  32537. t["\uFEC9"] = "\u0639";
  32538. t["\uFECA"] = "\u0639";
  32539. t["\uFECB"] = "\u0639";
  32540. t["\uFECC"] = "\u0639";
  32541. t["\uFECD"] = "\u063A";
  32542. t["\uFECE"] = "\u063A";
  32543. t["\uFECF"] = "\u063A";
  32544. t["\uFED0"] = "\u063A";
  32545. t["\uFED1"] = "\u0641";
  32546. t["\uFED2"] = "\u0641";
  32547. t["\uFED3"] = "\u0641";
  32548. t["\uFED4"] = "\u0641";
  32549. t["\uFED5"] = "\u0642";
  32550. t["\uFED6"] = "\u0642";
  32551. t["\uFED7"] = "\u0642";
  32552. t["\uFED8"] = "\u0642";
  32553. t["\uFED9"] = "\u0643";
  32554. t["\uFEDA"] = "\u0643";
  32555. t["\uFEDB"] = "\u0643";
  32556. t["\uFEDC"] = "\u0643";
  32557. t["\uFEDD"] = "\u0644";
  32558. t["\uFEDE"] = "\u0644";
  32559. t["\uFEDF"] = "\u0644";
  32560. t["\uFEE0"] = "\u0644";
  32561. t["\uFEE1"] = "\u0645";
  32562. t["\uFEE2"] = "\u0645";
  32563. t["\uFEE3"] = "\u0645";
  32564. t["\uFEE4"] = "\u0645";
  32565. t["\uFEE5"] = "\u0646";
  32566. t["\uFEE6"] = "\u0646";
  32567. t["\uFEE7"] = "\u0646";
  32568. t["\uFEE8"] = "\u0646";
  32569. t["\uFEE9"] = "\u0647";
  32570. t["\uFEEA"] = "\u0647";
  32571. t["\uFEEB"] = "\u0647";
  32572. t["\uFEEC"] = "\u0647";
  32573. t["\uFEED"] = "\u0648";
  32574. t["\uFEEE"] = "\u0648";
  32575. t["\uFEEF"] = "\u0649";
  32576. t["\uFEF0"] = "\u0649";
  32577. t["\uFEF1"] = "\u064A";
  32578. t["\uFEF2"] = "\u064A";
  32579. t["\uFEF3"] = "\u064A";
  32580. t["\uFEF4"] = "\u064A";
  32581. t["\uFEF5"] = "\u0644\u0622";
  32582. t["\uFEF6"] = "\u0644\u0622";
  32583. t["\uFEF7"] = "\u0644\u0623";
  32584. t["\uFEF8"] = "\u0644\u0623";
  32585. t["\uFEF9"] = "\u0644\u0625";
  32586. t["\uFEFA"] = "\u0644\u0625";
  32587. t["\uFEFB"] = "\u0644\u0627";
  32588. t["\uFEFC"] = "\u0644\u0627";
  32589. });
  32590. function reverseIfRtl(chars) {
  32591. var charsLength = chars.length;
  32592. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  32593. return chars;
  32594. }
  32595. var s = "";
  32596. for (var ii = charsLength - 1; ii >= 0; ii--) {
  32597. s += chars[ii];
  32598. }
  32599. return s;
  32600. }
  32601. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  32602. exports.reverseIfRtl = reverseIfRtl;
  32603. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  32604. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  32605. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  32606. /***/ }),
  32607. /* 37 */
  32608. /***/ (function(module, exports, __w_pdfjs_require__) {
  32609. "use strict";
  32610. Object.defineProperty(exports, "__esModule", {
  32611. value: true
  32612. });
  32613. exports.FontRendererFactory = void 0;
  32614. var _util = __w_pdfjs_require__(2);
  32615. var _cff_parser = __w_pdfjs_require__(31);
  32616. var _glyphlist = __w_pdfjs_require__(34);
  32617. var _encodings = __w_pdfjs_require__(33);
  32618. var _stream = __w_pdfjs_require__(12);
  32619. var FontRendererFactory = function FontRendererFactoryClosure() {
  32620. function getLong(data, offset) {
  32621. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  32622. }
  32623. function getUshort(data, offset) {
  32624. return data[offset] << 8 | data[offset + 1];
  32625. }
  32626. function getSubroutineBias(subrs) {
  32627. const numSubrs = subrs.length;
  32628. let bias = 32768;
  32629. if (numSubrs < 1240) {
  32630. bias = 107;
  32631. } else if (numSubrs < 33900) {
  32632. bias = 1131;
  32633. }
  32634. return bias;
  32635. }
  32636. function parseCmap(data, start, end) {
  32637. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  32638. var format = getUshort(data, start + offset);
  32639. var ranges, p, i;
  32640. if (format === 4) {
  32641. getUshort(data, start + offset + 2);
  32642. var segCount = getUshort(data, start + offset + 6) >> 1;
  32643. p = start + offset + 14;
  32644. ranges = [];
  32645. for (i = 0; i < segCount; i++, p += 2) {
  32646. ranges[i] = {
  32647. end: getUshort(data, p)
  32648. };
  32649. }
  32650. p += 2;
  32651. for (i = 0; i < segCount; i++, p += 2) {
  32652. ranges[i].start = getUshort(data, p);
  32653. }
  32654. for (i = 0; i < segCount; i++, p += 2) {
  32655. ranges[i].idDelta = getUshort(data, p);
  32656. }
  32657. for (i = 0; i < segCount; i++, p += 2) {
  32658. var idOffset = getUshort(data, p);
  32659. if (idOffset === 0) {
  32660. continue;
  32661. }
  32662. ranges[i].ids = [];
  32663. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  32664. ranges[i].ids[j] = getUshort(data, p + idOffset);
  32665. idOffset += 2;
  32666. }
  32667. }
  32668. return ranges;
  32669. } else if (format === 12) {
  32670. getLong(data, start + offset + 4);
  32671. var groups = getLong(data, start + offset + 12);
  32672. p = start + offset + 16;
  32673. ranges = [];
  32674. for (i = 0; i < groups; i++) {
  32675. ranges.push({
  32676. start: getLong(data, p),
  32677. end: getLong(data, p + 4),
  32678. idDelta: getLong(data, p + 8) - getLong(data, p)
  32679. });
  32680. p += 12;
  32681. }
  32682. return ranges;
  32683. }
  32684. throw new _util.FormatError(`unsupported cmap: ${format}`);
  32685. }
  32686. function parseCff(data, start, end, seacAnalysisEnabled) {
  32687. var properties = {};
  32688. var parser = new _cff_parser.CFFParser(new _stream.Stream(data, start, end - start), properties, seacAnalysisEnabled);
  32689. var cff = parser.parse();
  32690. return {
  32691. glyphs: cff.charStrings.objects,
  32692. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  32693. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects,
  32694. isCFFCIDFont: cff.isCIDFont,
  32695. fdSelect: cff.fdSelect,
  32696. fdArray: cff.fdArray
  32697. };
  32698. }
  32699. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  32700. var itemSize, itemDecode;
  32701. if (isGlyphLocationsLong) {
  32702. itemSize = 4;
  32703. itemDecode = function fontItemDecodeLong(data, offset) {
  32704. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  32705. };
  32706. } else {
  32707. itemSize = 2;
  32708. itemDecode = function fontItemDecode(data, offset) {
  32709. return data[offset] << 9 | data[offset + 1] << 1;
  32710. };
  32711. }
  32712. var glyphs = [];
  32713. var startOffset = itemDecode(loca, 0);
  32714. for (var j = itemSize; j < loca.length; j += itemSize) {
  32715. var endOffset = itemDecode(loca, j);
  32716. glyphs.push(glyf.subarray(startOffset, endOffset));
  32717. startOffset = endOffset;
  32718. }
  32719. return glyphs;
  32720. }
  32721. function lookupCmap(ranges, unicode) {
  32722. var code = unicode.codePointAt(0),
  32723. gid = 0;
  32724. var l = 0,
  32725. r = ranges.length - 1;
  32726. while (l < r) {
  32727. var c = l + r + 1 >> 1;
  32728. if (code < ranges[c].start) {
  32729. r = c - 1;
  32730. } else {
  32731. l = c;
  32732. }
  32733. }
  32734. if (ranges[l].start <= code && code <= ranges[l].end) {
  32735. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xffff;
  32736. }
  32737. return {
  32738. charCode: code,
  32739. glyphId: gid
  32740. };
  32741. }
  32742. function compileGlyf(code, cmds, font) {
  32743. function moveTo(x, y) {
  32744. cmds.push({
  32745. cmd: "moveTo",
  32746. args: [x, y]
  32747. });
  32748. }
  32749. function lineTo(x, y) {
  32750. cmds.push({
  32751. cmd: "lineTo",
  32752. args: [x, y]
  32753. });
  32754. }
  32755. function quadraticCurveTo(xa, ya, x, y) {
  32756. cmds.push({
  32757. cmd: "quadraticCurveTo",
  32758. args: [xa, ya, x, y]
  32759. });
  32760. }
  32761. var i = 0;
  32762. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  32763. var flags;
  32764. var x = 0,
  32765. y = 0;
  32766. i += 10;
  32767. if (numberOfContours < 0) {
  32768. do {
  32769. flags = code[i] << 8 | code[i + 1];
  32770. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  32771. i += 4;
  32772. var arg1, arg2;
  32773. if (flags & 0x01) {
  32774. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  32775. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  32776. i += 4;
  32777. } else {
  32778. arg1 = code[i++];
  32779. arg2 = code[i++];
  32780. }
  32781. if (flags & 0x02) {
  32782. x = arg1;
  32783. y = arg2;
  32784. } else {
  32785. x = 0;
  32786. y = 0;
  32787. }
  32788. var scaleX = 1,
  32789. scaleY = 1,
  32790. scale01 = 0,
  32791. scale10 = 0;
  32792. if (flags & 0x08) {
  32793. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  32794. i += 2;
  32795. } else if (flags & 0x40) {
  32796. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  32797. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  32798. i += 4;
  32799. } else if (flags & 0x80) {
  32800. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  32801. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  32802. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  32803. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  32804. i += 8;
  32805. }
  32806. var subglyph = font.glyphs[glyphIndex];
  32807. if (subglyph) {
  32808. cmds.push({
  32809. cmd: "save"
  32810. });
  32811. cmds.push({
  32812. cmd: "transform",
  32813. args: [scaleX, scale01, scale10, scaleY, x, y]
  32814. });
  32815. compileGlyf(subglyph, cmds, font);
  32816. cmds.push({
  32817. cmd: "restore"
  32818. });
  32819. }
  32820. } while (flags & 0x20);
  32821. } else {
  32822. var endPtsOfContours = [];
  32823. var j, jj;
  32824. for (j = 0; j < numberOfContours; j++) {
  32825. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  32826. i += 2;
  32827. }
  32828. var instructionLength = code[i] << 8 | code[i + 1];
  32829. i += 2 + instructionLength;
  32830. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  32831. var points = [];
  32832. while (points.length < numberOfPoints) {
  32833. flags = code[i++];
  32834. var repeat = 1;
  32835. if (flags & 0x08) {
  32836. repeat += code[i++];
  32837. }
  32838. while (repeat-- > 0) {
  32839. points.push({
  32840. flags
  32841. });
  32842. }
  32843. }
  32844. for (j = 0; j < numberOfPoints; j++) {
  32845. switch (points[j].flags & 0x12) {
  32846. case 0x00:
  32847. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  32848. i += 2;
  32849. break;
  32850. case 0x02:
  32851. x -= code[i++];
  32852. break;
  32853. case 0x12:
  32854. x += code[i++];
  32855. break;
  32856. }
  32857. points[j].x = x;
  32858. }
  32859. for (j = 0; j < numberOfPoints; j++) {
  32860. switch (points[j].flags & 0x24) {
  32861. case 0x00:
  32862. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  32863. i += 2;
  32864. break;
  32865. case 0x04:
  32866. y -= code[i++];
  32867. break;
  32868. case 0x24:
  32869. y += code[i++];
  32870. break;
  32871. }
  32872. points[j].y = y;
  32873. }
  32874. var startPoint = 0;
  32875. for (i = 0; i < numberOfContours; i++) {
  32876. var endPoint = endPtsOfContours[i];
  32877. var contour = points.slice(startPoint, endPoint + 1);
  32878. if (contour[0].flags & 1) {
  32879. contour.push(contour[0]);
  32880. } else if (contour[contour.length - 1].flags & 1) {
  32881. contour.unshift(contour[contour.length - 1]);
  32882. } else {
  32883. var p = {
  32884. flags: 1,
  32885. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  32886. y: (contour[0].y + contour[contour.length - 1].y) / 2
  32887. };
  32888. contour.unshift(p);
  32889. contour.push(p);
  32890. }
  32891. moveTo(contour[0].x, contour[0].y);
  32892. for (j = 1, jj = contour.length; j < jj; j++) {
  32893. if (contour[j].flags & 1) {
  32894. lineTo(contour[j].x, contour[j].y);
  32895. } else if (contour[j + 1].flags & 1) {
  32896. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  32897. j++;
  32898. } else {
  32899. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  32900. }
  32901. }
  32902. startPoint = endPoint + 1;
  32903. }
  32904. }
  32905. }
  32906. function compileCharString(charStringCode, cmds, font, glyphId) {
  32907. function moveTo(x, y) {
  32908. cmds.push({
  32909. cmd: "moveTo",
  32910. args: [x, y]
  32911. });
  32912. }
  32913. function lineTo(x, y) {
  32914. cmds.push({
  32915. cmd: "lineTo",
  32916. args: [x, y]
  32917. });
  32918. }
  32919. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  32920. cmds.push({
  32921. cmd: "bezierCurveTo",
  32922. args: [x1, y1, x2, y2, x, y]
  32923. });
  32924. }
  32925. var stack = [];
  32926. var x = 0,
  32927. y = 0;
  32928. var stems = 0;
  32929. function parse(code) {
  32930. var i = 0;
  32931. while (i < code.length) {
  32932. var stackClean = false;
  32933. var v = code[i++];
  32934. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  32935. switch (v) {
  32936. case 1:
  32937. stems += stack.length >> 1;
  32938. stackClean = true;
  32939. break;
  32940. case 3:
  32941. stems += stack.length >> 1;
  32942. stackClean = true;
  32943. break;
  32944. case 4:
  32945. y += stack.pop();
  32946. moveTo(x, y);
  32947. stackClean = true;
  32948. break;
  32949. case 5:
  32950. while (stack.length > 0) {
  32951. x += stack.shift();
  32952. y += stack.shift();
  32953. lineTo(x, y);
  32954. }
  32955. break;
  32956. case 6:
  32957. while (stack.length > 0) {
  32958. x += stack.shift();
  32959. lineTo(x, y);
  32960. if (stack.length === 0) {
  32961. break;
  32962. }
  32963. y += stack.shift();
  32964. lineTo(x, y);
  32965. }
  32966. break;
  32967. case 7:
  32968. while (stack.length > 0) {
  32969. y += stack.shift();
  32970. lineTo(x, y);
  32971. if (stack.length === 0) {
  32972. break;
  32973. }
  32974. x += stack.shift();
  32975. lineTo(x, y);
  32976. }
  32977. break;
  32978. case 8:
  32979. while (stack.length > 0) {
  32980. xa = x + stack.shift();
  32981. ya = y + stack.shift();
  32982. xb = xa + stack.shift();
  32983. yb = ya + stack.shift();
  32984. x = xb + stack.shift();
  32985. y = yb + stack.shift();
  32986. bezierCurveTo(xa, ya, xb, yb, x, y);
  32987. }
  32988. break;
  32989. case 10:
  32990. n = stack.pop();
  32991. subrCode = null;
  32992. if (font.isCFFCIDFont) {
  32993. const fdIndex = font.fdSelect.getFDIndex(glyphId);
  32994. if (fdIndex >= 0 && fdIndex < font.fdArray.length) {
  32995. const fontDict = font.fdArray[fdIndex];
  32996. let subrs;
  32997. if (fontDict.privateDict && fontDict.privateDict.subrsIndex) {
  32998. subrs = fontDict.privateDict.subrsIndex.objects;
  32999. }
  33000. if (subrs) {
  33001. n += getSubroutineBias(subrs);
  33002. subrCode = subrs[n];
  33003. }
  33004. } else {
  33005. (0, _util.warn)("Invalid fd index for glyph index.");
  33006. }
  33007. } else {
  33008. subrCode = font.subrs[n + font.subrsBias];
  33009. }
  33010. if (subrCode) {
  33011. parse(subrCode);
  33012. }
  33013. break;
  33014. case 11:
  33015. return;
  33016. case 12:
  33017. v = code[i++];
  33018. switch (v) {
  33019. case 34:
  33020. xa = x + stack.shift();
  33021. xb = xa + stack.shift();
  33022. y1 = y + stack.shift();
  33023. x = xb + stack.shift();
  33024. bezierCurveTo(xa, y, xb, y1, x, y1);
  33025. xa = x + stack.shift();
  33026. xb = xa + stack.shift();
  33027. x = xb + stack.shift();
  33028. bezierCurveTo(xa, y1, xb, y, x, y);
  33029. break;
  33030. case 35:
  33031. xa = x + stack.shift();
  33032. ya = y + stack.shift();
  33033. xb = xa + stack.shift();
  33034. yb = ya + stack.shift();
  33035. x = xb + stack.shift();
  33036. y = yb + stack.shift();
  33037. bezierCurveTo(xa, ya, xb, yb, x, y);
  33038. xa = x + stack.shift();
  33039. ya = y + stack.shift();
  33040. xb = xa + stack.shift();
  33041. yb = ya + stack.shift();
  33042. x = xb + stack.shift();
  33043. y = yb + stack.shift();
  33044. bezierCurveTo(xa, ya, xb, yb, x, y);
  33045. stack.pop();
  33046. break;
  33047. case 36:
  33048. xa = x + stack.shift();
  33049. y1 = y + stack.shift();
  33050. xb = xa + stack.shift();
  33051. y2 = y1 + stack.shift();
  33052. x = xb + stack.shift();
  33053. bezierCurveTo(xa, y1, xb, y2, x, y2);
  33054. xa = x + stack.shift();
  33055. xb = xa + stack.shift();
  33056. y3 = y2 + stack.shift();
  33057. x = xb + stack.shift();
  33058. bezierCurveTo(xa, y2, xb, y3, x, y);
  33059. break;
  33060. case 37:
  33061. var x0 = x,
  33062. y0 = y;
  33063. xa = x + stack.shift();
  33064. ya = y + stack.shift();
  33065. xb = xa + stack.shift();
  33066. yb = ya + stack.shift();
  33067. x = xb + stack.shift();
  33068. y = yb + stack.shift();
  33069. bezierCurveTo(xa, ya, xb, yb, x, y);
  33070. xa = x + stack.shift();
  33071. ya = y + stack.shift();
  33072. xb = xa + stack.shift();
  33073. yb = ya + stack.shift();
  33074. x = xb;
  33075. y = yb;
  33076. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  33077. x += stack.shift();
  33078. } else {
  33079. y += stack.shift();
  33080. }
  33081. bezierCurveTo(xa, ya, xb, yb, x, y);
  33082. break;
  33083. default:
  33084. throw new _util.FormatError(`unknown operator: 12 ${v}`);
  33085. }
  33086. break;
  33087. case 14:
  33088. if (stack.length >= 4) {
  33089. var achar = stack.pop();
  33090. var bchar = stack.pop();
  33091. y = stack.pop();
  33092. x = stack.pop();
  33093. cmds.push({
  33094. cmd: "save"
  33095. });
  33096. cmds.push({
  33097. cmd: "translate",
  33098. args: [x, y]
  33099. });
  33100. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[achar]]));
  33101. compileCharString(font.glyphs[cmap.glyphId], cmds, font, cmap.glyphId);
  33102. cmds.push({
  33103. cmd: "restore"
  33104. });
  33105. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[bchar]]));
  33106. compileCharString(font.glyphs[cmap.glyphId], cmds, font, cmap.glyphId);
  33107. }
  33108. return;
  33109. case 18:
  33110. stems += stack.length >> 1;
  33111. stackClean = true;
  33112. break;
  33113. case 19:
  33114. stems += stack.length >> 1;
  33115. i += stems + 7 >> 3;
  33116. stackClean = true;
  33117. break;
  33118. case 20:
  33119. stems += stack.length >> 1;
  33120. i += stems + 7 >> 3;
  33121. stackClean = true;
  33122. break;
  33123. case 21:
  33124. y += stack.pop();
  33125. x += stack.pop();
  33126. moveTo(x, y);
  33127. stackClean = true;
  33128. break;
  33129. case 22:
  33130. x += stack.pop();
  33131. moveTo(x, y);
  33132. stackClean = true;
  33133. break;
  33134. case 23:
  33135. stems += stack.length >> 1;
  33136. stackClean = true;
  33137. break;
  33138. case 24:
  33139. while (stack.length > 2) {
  33140. xa = x + stack.shift();
  33141. ya = y + stack.shift();
  33142. xb = xa + stack.shift();
  33143. yb = ya + stack.shift();
  33144. x = xb + stack.shift();
  33145. y = yb + stack.shift();
  33146. bezierCurveTo(xa, ya, xb, yb, x, y);
  33147. }
  33148. x += stack.shift();
  33149. y += stack.shift();
  33150. lineTo(x, y);
  33151. break;
  33152. case 25:
  33153. while (stack.length > 6) {
  33154. x += stack.shift();
  33155. y += stack.shift();
  33156. lineTo(x, y);
  33157. }
  33158. xa = x + stack.shift();
  33159. ya = y + stack.shift();
  33160. xb = xa + stack.shift();
  33161. yb = ya + stack.shift();
  33162. x = xb + stack.shift();
  33163. y = yb + stack.shift();
  33164. bezierCurveTo(xa, ya, xb, yb, x, y);
  33165. break;
  33166. case 26:
  33167. if (stack.length % 2) {
  33168. x += stack.shift();
  33169. }
  33170. while (stack.length > 0) {
  33171. xa = x;
  33172. ya = y + stack.shift();
  33173. xb = xa + stack.shift();
  33174. yb = ya + stack.shift();
  33175. x = xb;
  33176. y = yb + stack.shift();
  33177. bezierCurveTo(xa, ya, xb, yb, x, y);
  33178. }
  33179. break;
  33180. case 27:
  33181. if (stack.length % 2) {
  33182. y += stack.shift();
  33183. }
  33184. while (stack.length > 0) {
  33185. xa = x + stack.shift();
  33186. ya = y;
  33187. xb = xa + stack.shift();
  33188. yb = ya + stack.shift();
  33189. x = xb + stack.shift();
  33190. y = yb;
  33191. bezierCurveTo(xa, ya, xb, yb, x, y);
  33192. }
  33193. break;
  33194. case 28:
  33195. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  33196. i += 2;
  33197. break;
  33198. case 29:
  33199. n = stack.pop() + font.gsubrsBias;
  33200. subrCode = font.gsubrs[n];
  33201. if (subrCode) {
  33202. parse(subrCode);
  33203. }
  33204. break;
  33205. case 30:
  33206. while (stack.length > 0) {
  33207. xa = x;
  33208. ya = y + stack.shift();
  33209. xb = xa + stack.shift();
  33210. yb = ya + stack.shift();
  33211. x = xb + stack.shift();
  33212. y = yb + (stack.length === 1 ? stack.shift() : 0);
  33213. bezierCurveTo(xa, ya, xb, yb, x, y);
  33214. if (stack.length === 0) {
  33215. break;
  33216. }
  33217. xa = x + stack.shift();
  33218. ya = y;
  33219. xb = xa + stack.shift();
  33220. yb = ya + stack.shift();
  33221. y = yb + stack.shift();
  33222. x = xb + (stack.length === 1 ? stack.shift() : 0);
  33223. bezierCurveTo(xa, ya, xb, yb, x, y);
  33224. }
  33225. break;
  33226. case 31:
  33227. while (stack.length > 0) {
  33228. xa = x + stack.shift();
  33229. ya = y;
  33230. xb = xa + stack.shift();
  33231. yb = ya + stack.shift();
  33232. y = yb + stack.shift();
  33233. x = xb + (stack.length === 1 ? stack.shift() : 0);
  33234. bezierCurveTo(xa, ya, xb, yb, x, y);
  33235. if (stack.length === 0) {
  33236. break;
  33237. }
  33238. xa = x;
  33239. ya = y + stack.shift();
  33240. xb = xa + stack.shift();
  33241. yb = ya + stack.shift();
  33242. x = xb + stack.shift();
  33243. y = yb + (stack.length === 1 ? stack.shift() : 0);
  33244. bezierCurveTo(xa, ya, xb, yb, x, y);
  33245. }
  33246. break;
  33247. default:
  33248. if (v < 32) {
  33249. throw new _util.FormatError(`unknown operator: ${v}`);
  33250. }
  33251. if (v < 247) {
  33252. stack.push(v - 139);
  33253. } else if (v < 251) {
  33254. stack.push((v - 247) * 256 + code[i++] + 108);
  33255. } else if (v < 255) {
  33256. stack.push(-(v - 251) * 256 - code[i++] - 108);
  33257. } else {
  33258. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  33259. i += 4;
  33260. }
  33261. break;
  33262. }
  33263. if (stackClean) {
  33264. stack.length = 0;
  33265. }
  33266. }
  33267. }
  33268. parse(charStringCode);
  33269. }
  33270. const NOOP = [];
  33271. class CompiledFont {
  33272. constructor(fontMatrix) {
  33273. if (this.constructor === CompiledFont) {
  33274. (0, _util.unreachable)("Cannot initialize CompiledFont.");
  33275. }
  33276. this.fontMatrix = fontMatrix;
  33277. this.compiledGlyphs = Object.create(null);
  33278. this.compiledCharCodeToGlyphId = Object.create(null);
  33279. }
  33280. getPathJs(unicode) {
  33281. const cmap = lookupCmap(this.cmap, unicode);
  33282. let fn = this.compiledGlyphs[cmap.glyphId];
  33283. if (!fn) {
  33284. fn = this.compileGlyph(this.glyphs[cmap.glyphId], cmap.glyphId);
  33285. this.compiledGlyphs[cmap.glyphId] = fn;
  33286. }
  33287. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  33288. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  33289. }
  33290. return fn;
  33291. }
  33292. compileGlyph(code, glyphId) {
  33293. if (!code || code.length === 0 || code[0] === 14) {
  33294. return NOOP;
  33295. }
  33296. let fontMatrix = this.fontMatrix;
  33297. if (this.isCFFCIDFont) {
  33298. const fdIndex = this.fdSelect.getFDIndex(glyphId);
  33299. if (fdIndex >= 0 && fdIndex < this.fdArray.length) {
  33300. const fontDict = this.fdArray[fdIndex];
  33301. fontMatrix = fontDict.getByName("FontMatrix") || _util.FONT_IDENTITY_MATRIX;
  33302. } else {
  33303. (0, _util.warn)("Invalid fd index for glyph index.");
  33304. }
  33305. }
  33306. const cmds = [];
  33307. cmds.push({
  33308. cmd: "save"
  33309. });
  33310. cmds.push({
  33311. cmd: "transform",
  33312. args: fontMatrix.slice()
  33313. });
  33314. cmds.push({
  33315. cmd: "scale",
  33316. args: ["size", "-size"]
  33317. });
  33318. this.compileGlyphImpl(code, cmds, glyphId);
  33319. cmds.push({
  33320. cmd: "restore"
  33321. });
  33322. return cmds;
  33323. }
  33324. compileGlyphImpl() {
  33325. (0, _util.unreachable)("Children classes should implement this.");
  33326. }
  33327. hasBuiltPath(unicode) {
  33328. const cmap = lookupCmap(this.cmap, unicode);
  33329. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  33330. }
  33331. }
  33332. class TrueTypeCompiled extends CompiledFont {
  33333. constructor(glyphs, cmap, fontMatrix) {
  33334. super(fontMatrix || [0.000488, 0, 0, 0.000488, 0, 0]);
  33335. this.glyphs = glyphs;
  33336. this.cmap = cmap;
  33337. }
  33338. compileGlyphImpl(code, cmds) {
  33339. compileGlyf(code, cmds, this);
  33340. }
  33341. }
  33342. class Type2Compiled extends CompiledFont {
  33343. constructor(cffInfo, cmap, fontMatrix, glyphNameMap) {
  33344. super(fontMatrix || [0.001, 0, 0, 0.001, 0, 0]);
  33345. this.glyphs = cffInfo.glyphs;
  33346. this.gsubrs = cffInfo.gsubrs || [];
  33347. this.subrs = cffInfo.subrs || [];
  33348. this.cmap = cmap;
  33349. this.glyphNameMap = glyphNameMap || (0, _glyphlist.getGlyphsUnicode)();
  33350. this.gsubrsBias = getSubroutineBias(this.gsubrs);
  33351. this.subrsBias = getSubroutineBias(this.subrs);
  33352. this.isCFFCIDFont = cffInfo.isCFFCIDFont;
  33353. this.fdSelect = cffInfo.fdSelect;
  33354. this.fdArray = cffInfo.fdArray;
  33355. }
  33356. compileGlyphImpl(code, cmds, glyphId) {
  33357. compileCharString(code, cmds, this, glyphId);
  33358. }
  33359. }
  33360. return {
  33361. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  33362. var data = new Uint8Array(font.data);
  33363. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  33364. var numTables = getUshort(data, 4);
  33365. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  33366. var tag = (0, _util.bytesToString)(data.subarray(p, p + 4));
  33367. var offset = getLong(data, p + 8);
  33368. var length = getLong(data, p + 12);
  33369. switch (tag) {
  33370. case "cmap":
  33371. cmap = parseCmap(data, offset, offset + length);
  33372. break;
  33373. case "glyf":
  33374. glyf = data.subarray(offset, offset + length);
  33375. break;
  33376. case "loca":
  33377. loca = data.subarray(offset, offset + length);
  33378. break;
  33379. case "head":
  33380. unitsPerEm = getUshort(data, offset + 18);
  33381. indexToLocFormat = getUshort(data, offset + 50);
  33382. break;
  33383. case "CFF ":
  33384. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  33385. break;
  33386. }
  33387. }
  33388. if (glyf) {
  33389. var fontMatrix = !unitsPerEm ? font.fontMatrix : [1 / unitsPerEm, 0, 0, 1 / unitsPerEm, 0, 0];
  33390. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  33391. }
  33392. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  33393. }
  33394. };
  33395. }();
  33396. exports.FontRendererFactory = FontRendererFactory;
  33397. /***/ }),
  33398. /* 38 */
  33399. /***/ (function(module, exports, __w_pdfjs_require__) {
  33400. "use strict";
  33401. Object.defineProperty(exports, "__esModule", {
  33402. value: true
  33403. });
  33404. exports.Type1Parser = void 0;
  33405. var _encodings = __w_pdfjs_require__(33);
  33406. var _core_utils = __w_pdfjs_require__(8);
  33407. var _stream = __w_pdfjs_require__(12);
  33408. var _util = __w_pdfjs_require__(2);
  33409. var HINTING_ENABLED = false;
  33410. var Type1CharString = function Type1CharStringClosure() {
  33411. var COMMAND_MAP = {
  33412. hstem: [1],
  33413. vstem: [3],
  33414. vmoveto: [4],
  33415. rlineto: [5],
  33416. hlineto: [6],
  33417. vlineto: [7],
  33418. rrcurveto: [8],
  33419. callsubr: [10],
  33420. flex: [12, 35],
  33421. drop: [12, 18],
  33422. endchar: [14],
  33423. rmoveto: [21],
  33424. hmoveto: [22],
  33425. vhcurveto: [30],
  33426. hvcurveto: [31]
  33427. };
  33428. function Type1CharString() {
  33429. this.width = 0;
  33430. this.lsb = 0;
  33431. this.flexing = false;
  33432. this.output = [];
  33433. this.stack = [];
  33434. }
  33435. Type1CharString.prototype = {
  33436. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  33437. var count = encoded.length;
  33438. var error = false;
  33439. var wx, sbx, subrNumber;
  33440. for (var i = 0; i < count; i++) {
  33441. var value = encoded[i];
  33442. if (value < 32) {
  33443. if (value === 12) {
  33444. value = (value << 8) + encoded[++i];
  33445. }
  33446. switch (value) {
  33447. case 1:
  33448. if (!HINTING_ENABLED) {
  33449. this.stack = [];
  33450. break;
  33451. }
  33452. error = this.executeCommand(2, COMMAND_MAP.hstem);
  33453. break;
  33454. case 3:
  33455. if (!HINTING_ENABLED) {
  33456. this.stack = [];
  33457. break;
  33458. }
  33459. error = this.executeCommand(2, COMMAND_MAP.vstem);
  33460. break;
  33461. case 4:
  33462. if (this.flexing) {
  33463. if (this.stack.length < 1) {
  33464. error = true;
  33465. break;
  33466. }
  33467. var dy = this.stack.pop();
  33468. this.stack.push(0, dy);
  33469. break;
  33470. }
  33471. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  33472. break;
  33473. case 5:
  33474. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  33475. break;
  33476. case 6:
  33477. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  33478. break;
  33479. case 7:
  33480. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  33481. break;
  33482. case 8:
  33483. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  33484. break;
  33485. case 9:
  33486. this.stack = [];
  33487. break;
  33488. case 10:
  33489. if (this.stack.length < 1) {
  33490. error = true;
  33491. break;
  33492. }
  33493. subrNumber = this.stack.pop();
  33494. if (!subrs[subrNumber]) {
  33495. error = true;
  33496. break;
  33497. }
  33498. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  33499. break;
  33500. case 11:
  33501. return error;
  33502. case 13:
  33503. if (this.stack.length < 2) {
  33504. error = true;
  33505. break;
  33506. }
  33507. wx = this.stack.pop();
  33508. sbx = this.stack.pop();
  33509. this.lsb = sbx;
  33510. this.width = wx;
  33511. this.stack.push(wx, sbx);
  33512. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  33513. break;
  33514. case 14:
  33515. this.output.push(COMMAND_MAP.endchar[0]);
  33516. break;
  33517. case 21:
  33518. if (this.flexing) {
  33519. break;
  33520. }
  33521. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  33522. break;
  33523. case 22:
  33524. if (this.flexing) {
  33525. this.stack.push(0);
  33526. break;
  33527. }
  33528. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  33529. break;
  33530. case 30:
  33531. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  33532. break;
  33533. case 31:
  33534. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  33535. break;
  33536. case (12 << 8) + 0:
  33537. this.stack = [];
  33538. break;
  33539. case (12 << 8) + 1:
  33540. if (!HINTING_ENABLED) {
  33541. this.stack = [];
  33542. break;
  33543. }
  33544. error = this.executeCommand(2, COMMAND_MAP.vstem);
  33545. break;
  33546. case (12 << 8) + 2:
  33547. if (!HINTING_ENABLED) {
  33548. this.stack = [];
  33549. break;
  33550. }
  33551. error = this.executeCommand(2, COMMAND_MAP.hstem);
  33552. break;
  33553. case (12 << 8) + 6:
  33554. if (seacAnalysisEnabled) {
  33555. const asb = this.stack[this.stack.length - 5];
  33556. this.seac = this.stack.splice(-4, 4);
  33557. this.seac[0] += this.lsb - asb;
  33558. error = this.executeCommand(0, COMMAND_MAP.endchar);
  33559. } else {
  33560. error = this.executeCommand(4, COMMAND_MAP.endchar);
  33561. }
  33562. break;
  33563. case (12 << 8) + 7:
  33564. if (this.stack.length < 4) {
  33565. error = true;
  33566. break;
  33567. }
  33568. this.stack.pop();
  33569. wx = this.stack.pop();
  33570. var sby = this.stack.pop();
  33571. sbx = this.stack.pop();
  33572. this.lsb = sbx;
  33573. this.width = wx;
  33574. this.stack.push(wx, sbx, sby);
  33575. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  33576. break;
  33577. case (12 << 8) + 12:
  33578. if (this.stack.length < 2) {
  33579. error = true;
  33580. break;
  33581. }
  33582. var num2 = this.stack.pop();
  33583. var num1 = this.stack.pop();
  33584. this.stack.push(num1 / num2);
  33585. break;
  33586. case (12 << 8) + 16:
  33587. if (this.stack.length < 2) {
  33588. error = true;
  33589. break;
  33590. }
  33591. subrNumber = this.stack.pop();
  33592. var numArgs = this.stack.pop();
  33593. if (subrNumber === 0 && numArgs === 3) {
  33594. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  33595. this.stack.push(flexArgs[2] + flexArgs[0], flexArgs[3] + flexArgs[1], flexArgs[4], flexArgs[5], flexArgs[6], flexArgs[7], flexArgs[8], flexArgs[9], flexArgs[10], flexArgs[11], flexArgs[12], flexArgs[13], flexArgs[14]);
  33596. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  33597. this.flexing = false;
  33598. this.stack.push(flexArgs[15], flexArgs[16]);
  33599. } else if (subrNumber === 1 && numArgs === 0) {
  33600. this.flexing = true;
  33601. }
  33602. break;
  33603. case (12 << 8) + 17:
  33604. break;
  33605. case (12 << 8) + 33:
  33606. this.stack = [];
  33607. break;
  33608. default:
  33609. (0, _util.warn)('Unknown type 1 charstring command of "' + value + '"');
  33610. break;
  33611. }
  33612. if (error) {
  33613. break;
  33614. }
  33615. continue;
  33616. } else if (value <= 246) {
  33617. value = value - 139;
  33618. } else if (value <= 250) {
  33619. value = (value - 247) * 256 + encoded[++i] + 108;
  33620. } else if (value <= 254) {
  33621. value = -((value - 251) * 256) - encoded[++i] - 108;
  33622. } else {
  33623. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  33624. }
  33625. this.stack.push(value);
  33626. }
  33627. return error;
  33628. },
  33629. executeCommand(howManyArgs, command, keepStack) {
  33630. var stackLength = this.stack.length;
  33631. if (howManyArgs > stackLength) {
  33632. return true;
  33633. }
  33634. var start = stackLength - howManyArgs;
  33635. for (var i = start; i < stackLength; i++) {
  33636. var value = this.stack[i];
  33637. if (Number.isInteger(value)) {
  33638. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  33639. } else {
  33640. value = 65536 * value | 0;
  33641. this.output.push(255, value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  33642. }
  33643. }
  33644. this.output.push.apply(this.output, command);
  33645. if (keepStack) {
  33646. this.stack.splice(start, howManyArgs);
  33647. } else {
  33648. this.stack.length = 0;
  33649. }
  33650. return false;
  33651. }
  33652. };
  33653. return Type1CharString;
  33654. }();
  33655. var Type1Parser = function Type1ParserClosure() {
  33656. var EEXEC_ENCRYPT_KEY = 55665;
  33657. var CHAR_STRS_ENCRYPT_KEY = 4330;
  33658. function isHexDigit(code) {
  33659. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  33660. }
  33661. function decrypt(data, key, discardNumber) {
  33662. if (discardNumber >= data.length) {
  33663. return new Uint8Array(0);
  33664. }
  33665. var r = key | 0,
  33666. c1 = 52845,
  33667. c2 = 22719,
  33668. i,
  33669. j;
  33670. for (i = 0; i < discardNumber; i++) {
  33671. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  33672. }
  33673. var count = data.length - discardNumber;
  33674. var decrypted = new Uint8Array(count);
  33675. for (i = discardNumber, j = 0; j < count; i++, j++) {
  33676. var value = data[i];
  33677. decrypted[j] = value ^ r >> 8;
  33678. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  33679. }
  33680. return decrypted;
  33681. }
  33682. function decryptAscii(data, key, discardNumber) {
  33683. var r = key | 0,
  33684. c1 = 52845,
  33685. c2 = 22719;
  33686. var count = data.length,
  33687. maybeLength = count >>> 1;
  33688. var decrypted = new Uint8Array(maybeLength);
  33689. var i, j;
  33690. for (i = 0, j = 0; i < count; i++) {
  33691. var digit1 = data[i];
  33692. if (!isHexDigit(digit1)) {
  33693. continue;
  33694. }
  33695. i++;
  33696. var digit2;
  33697. while (i < count && !isHexDigit(digit2 = data[i])) {
  33698. i++;
  33699. }
  33700. if (i < count) {
  33701. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  33702. decrypted[j++] = value ^ r >> 8;
  33703. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  33704. }
  33705. }
  33706. return decrypted.slice(discardNumber, j);
  33707. }
  33708. function isSpecial(c) {
  33709. return c === 0x2f || c === 0x5b || c === 0x5d || c === 0x7b || c === 0x7d || c === 0x28 || c === 0x29;
  33710. }
  33711. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  33712. if (encrypted) {
  33713. var data = stream.getBytes();
  33714. var isBinary = !((isHexDigit(data[0]) || (0, _core_utils.isWhiteSpace)(data[0])) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]) && isHexDigit(data[4]) && isHexDigit(data[5]) && isHexDigit(data[6]) && isHexDigit(data[7]));
  33715. stream = new _stream.Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  33716. }
  33717. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  33718. this.stream = stream;
  33719. this.nextChar();
  33720. }
  33721. Type1Parser.prototype = {
  33722. readNumberArray: function Type1Parser_readNumberArray() {
  33723. this.getToken();
  33724. var array = [];
  33725. while (true) {
  33726. var token = this.getToken();
  33727. if (token === null || token === "]" || token === "}") {
  33728. break;
  33729. }
  33730. array.push(parseFloat(token || 0));
  33731. }
  33732. return array;
  33733. },
  33734. readNumber: function Type1Parser_readNumber() {
  33735. var token = this.getToken();
  33736. return parseFloat(token || 0);
  33737. },
  33738. readInt: function Type1Parser_readInt() {
  33739. var token = this.getToken();
  33740. return parseInt(token || 0, 10) | 0;
  33741. },
  33742. readBoolean: function Type1Parser_readBoolean() {
  33743. var token = this.getToken();
  33744. return token === "true" ? 1 : 0;
  33745. },
  33746. nextChar: function Type1_nextChar() {
  33747. return this.currentChar = this.stream.getByte();
  33748. },
  33749. getToken: function Type1Parser_getToken() {
  33750. var comment = false;
  33751. var ch = this.currentChar;
  33752. while (true) {
  33753. if (ch === -1) {
  33754. return null;
  33755. }
  33756. if (comment) {
  33757. if (ch === 0x0a || ch === 0x0d) {
  33758. comment = false;
  33759. }
  33760. } else if (ch === 0x25) {
  33761. comment = true;
  33762. } else if (!(0, _core_utils.isWhiteSpace)(ch)) {
  33763. break;
  33764. }
  33765. ch = this.nextChar();
  33766. }
  33767. if (isSpecial(ch)) {
  33768. this.nextChar();
  33769. return String.fromCharCode(ch);
  33770. }
  33771. var token = "";
  33772. do {
  33773. token += String.fromCharCode(ch);
  33774. ch = this.nextChar();
  33775. } while (ch >= 0 && !(0, _core_utils.isWhiteSpace)(ch) && !isSpecial(ch));
  33776. return token;
  33777. },
  33778. readCharStrings: function Type1Parser_readCharStrings(bytes, lenIV) {
  33779. if (lenIV === -1) {
  33780. return bytes;
  33781. }
  33782. return decrypt(bytes, CHAR_STRS_ENCRYPT_KEY, lenIV);
  33783. },
  33784. extractFontProgram: function Type1Parser_extractFontProgram(properties) {
  33785. var stream = this.stream;
  33786. var subrs = [],
  33787. charstrings = [];
  33788. var privateData = Object.create(null);
  33789. privateData.lenIV = 4;
  33790. var program = {
  33791. subrs: [],
  33792. charstrings: [],
  33793. properties: {
  33794. privateData
  33795. }
  33796. };
  33797. var token, length, data, lenIV, encoded;
  33798. while ((token = this.getToken()) !== null) {
  33799. if (token !== "/") {
  33800. continue;
  33801. }
  33802. token = this.getToken();
  33803. switch (token) {
  33804. case "CharStrings":
  33805. this.getToken();
  33806. this.getToken();
  33807. this.getToken();
  33808. this.getToken();
  33809. while (true) {
  33810. token = this.getToken();
  33811. if (token === null || token === "end") {
  33812. break;
  33813. }
  33814. if (token !== "/") {
  33815. continue;
  33816. }
  33817. var glyph = this.getToken();
  33818. length = this.readInt();
  33819. this.getToken();
  33820. data = length > 0 ? stream.getBytes(length) : new Uint8Array(0);
  33821. lenIV = program.properties.privateData.lenIV;
  33822. encoded = this.readCharStrings(data, lenIV);
  33823. this.nextChar();
  33824. token = this.getToken();
  33825. if (token === "noaccess") {
  33826. this.getToken();
  33827. }
  33828. charstrings.push({
  33829. glyph,
  33830. encoded
  33831. });
  33832. }
  33833. break;
  33834. case "Subrs":
  33835. this.readInt();
  33836. this.getToken();
  33837. while (this.getToken() === "dup") {
  33838. const index = this.readInt();
  33839. length = this.readInt();
  33840. this.getToken();
  33841. data = length > 0 ? stream.getBytes(length) : new Uint8Array(0);
  33842. lenIV = program.properties.privateData.lenIV;
  33843. encoded = this.readCharStrings(data, lenIV);
  33844. this.nextChar();
  33845. token = this.getToken();
  33846. if (token === "noaccess") {
  33847. this.getToken();
  33848. }
  33849. subrs[index] = encoded;
  33850. }
  33851. break;
  33852. case "BlueValues":
  33853. case "OtherBlues":
  33854. case "FamilyBlues":
  33855. case "FamilyOtherBlues":
  33856. var blueArray = this.readNumberArray();
  33857. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  33858. program.properties.privateData[token] = blueArray;
  33859. }
  33860. break;
  33861. case "StemSnapH":
  33862. case "StemSnapV":
  33863. program.properties.privateData[token] = this.readNumberArray();
  33864. break;
  33865. case "StdHW":
  33866. case "StdVW":
  33867. program.properties.privateData[token] = this.readNumberArray()[0];
  33868. break;
  33869. case "BlueShift":
  33870. case "lenIV":
  33871. case "BlueFuzz":
  33872. case "BlueScale":
  33873. case "LanguageGroup":
  33874. case "ExpansionFactor":
  33875. program.properties.privateData[token] = this.readNumber();
  33876. break;
  33877. case "ForceBold":
  33878. program.properties.privateData[token] = this.readBoolean();
  33879. break;
  33880. }
  33881. }
  33882. for (var i = 0; i < charstrings.length; i++) {
  33883. glyph = charstrings[i].glyph;
  33884. encoded = charstrings[i].encoded;
  33885. var charString = new Type1CharString();
  33886. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  33887. var output = charString.output;
  33888. if (error) {
  33889. output = [14];
  33890. }
  33891. const charStringObject = {
  33892. glyphName: glyph,
  33893. charstring: output,
  33894. width: charString.width,
  33895. lsb: charString.lsb,
  33896. seac: charString.seac
  33897. };
  33898. if (glyph === ".notdef") {
  33899. program.charstrings.unshift(charStringObject);
  33900. } else {
  33901. program.charstrings.push(charStringObject);
  33902. }
  33903. if (properties.builtInEncoding) {
  33904. const index = properties.builtInEncoding.indexOf(glyph);
  33905. if (index > -1 && properties.widths[index] === undefined && index >= properties.firstChar && index <= properties.lastChar) {
  33906. properties.widths[index] = charString.width;
  33907. }
  33908. }
  33909. }
  33910. return program;
  33911. },
  33912. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  33913. var token;
  33914. while ((token = this.getToken()) !== null) {
  33915. if (token !== "/") {
  33916. continue;
  33917. }
  33918. token = this.getToken();
  33919. switch (token) {
  33920. case "FontMatrix":
  33921. var matrix = this.readNumberArray();
  33922. properties.fontMatrix = matrix;
  33923. break;
  33924. case "Encoding":
  33925. var encodingArg = this.getToken();
  33926. var encoding;
  33927. if (!/^\d+$/.test(encodingArg)) {
  33928. encoding = (0, _encodings.getEncoding)(encodingArg);
  33929. } else {
  33930. encoding = [];
  33931. var size = parseInt(encodingArg, 10) | 0;
  33932. this.getToken();
  33933. for (var j = 0; j < size; j++) {
  33934. token = this.getToken();
  33935. while (token !== "dup" && token !== "def") {
  33936. token = this.getToken();
  33937. if (token === null) {
  33938. return;
  33939. }
  33940. }
  33941. if (token === "def") {
  33942. break;
  33943. }
  33944. var index = this.readInt();
  33945. this.getToken();
  33946. var glyph = this.getToken();
  33947. encoding[index] = glyph;
  33948. this.getToken();
  33949. }
  33950. }
  33951. properties.builtInEncoding = encoding;
  33952. break;
  33953. case "FontBBox":
  33954. var fontBBox = this.readNumberArray();
  33955. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  33956. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  33957. properties.ascentScaled = true;
  33958. break;
  33959. }
  33960. }
  33961. }
  33962. };
  33963. return Type1Parser;
  33964. }();
  33965. exports.Type1Parser = Type1Parser;
  33966. /***/ }),
  33967. /* 39 */
  33968. /***/ (function(module, exports, __w_pdfjs_require__) {
  33969. "use strict";
  33970. Object.defineProperty(exports, "__esModule", {
  33971. value: true
  33972. });
  33973. exports.getTilingPatternIR = getTilingPatternIR;
  33974. exports.Pattern = void 0;
  33975. var _util = __w_pdfjs_require__(2);
  33976. var _colorspace = __w_pdfjs_require__(23);
  33977. var _primitives = __w_pdfjs_require__(5);
  33978. var _core_utils = __w_pdfjs_require__(8);
  33979. var ShadingType = {
  33980. FUNCTION_BASED: 1,
  33981. AXIAL: 2,
  33982. RADIAL: 3,
  33983. FREE_FORM_MESH: 4,
  33984. LATTICE_FORM_MESH: 5,
  33985. COONS_PATCH_MESH: 6,
  33986. TENSOR_PATCH_MESH: 7
  33987. };
  33988. var Pattern = function PatternClosure() {
  33989. function Pattern() {
  33990. (0, _util.unreachable)("should not call Pattern constructor");
  33991. }
  33992. Pattern.prototype = {
  33993. getPattern: function Pattern_getPattern(ctx) {
  33994. (0, _util.unreachable)(`Should not call Pattern.getStyle: ${ctx}`);
  33995. }
  33996. };
  33997. Pattern.parseShading = function (shading, matrix, xref, res, handler, pdfFunctionFactory, localColorSpaceCache) {
  33998. var dict = (0, _primitives.isStream)(shading) ? shading.dict : shading;
  33999. var type = dict.get("ShadingType");
  34000. try {
  34001. switch (type) {
  34002. case ShadingType.AXIAL:
  34003. case ShadingType.RADIAL:
  34004. return new Shadings.RadialAxial(dict, matrix, xref, res, pdfFunctionFactory, localColorSpaceCache);
  34005. case ShadingType.FREE_FORM_MESH:
  34006. case ShadingType.LATTICE_FORM_MESH:
  34007. case ShadingType.COONS_PATCH_MESH:
  34008. case ShadingType.TENSOR_PATCH_MESH:
  34009. return new Shadings.Mesh(shading, matrix, xref, res, pdfFunctionFactory, localColorSpaceCache);
  34010. default:
  34011. throw new _util.FormatError("Unsupported ShadingType: " + type);
  34012. }
  34013. } catch (ex) {
  34014. if (ex instanceof _core_utils.MissingDataException) {
  34015. throw ex;
  34016. }
  34017. handler.send("UnsupportedFeature", {
  34018. featureId: _util.UNSUPPORTED_FEATURES.shadingPattern
  34019. });
  34020. (0, _util.warn)(ex);
  34021. return new Shadings.Dummy();
  34022. }
  34023. };
  34024. return Pattern;
  34025. }();
  34026. exports.Pattern = Pattern;
  34027. var Shadings = {};
  34028. Shadings.SMALL_NUMBER = 1e-6;
  34029. Shadings.RadialAxial = function RadialAxialClosure() {
  34030. function RadialAxial(dict, matrix, xref, resources, pdfFunctionFactory, localColorSpaceCache) {
  34031. this.matrix = matrix;
  34032. this.coordsArr = dict.getArray("Coords");
  34033. this.shadingType = dict.get("ShadingType");
  34034. this.type = "Pattern";
  34035. const cs = _colorspace.ColorSpace.parse({
  34036. cs: dict.getRaw("ColorSpace") || dict.getRaw("CS"),
  34037. xref,
  34038. resources,
  34039. pdfFunctionFactory,
  34040. localColorSpaceCache
  34041. });
  34042. this.cs = cs;
  34043. const bbox = dict.getArray("BBox");
  34044. if (Array.isArray(bbox) && bbox.length === 4) {
  34045. this.bbox = _util.Util.normalizeRect(bbox);
  34046. } else {
  34047. this.bbox = null;
  34048. }
  34049. var t0 = 0.0,
  34050. t1 = 1.0;
  34051. if (dict.has("Domain")) {
  34052. var domainArr = dict.getArray("Domain");
  34053. t0 = domainArr[0];
  34054. t1 = domainArr[1];
  34055. }
  34056. var extendStart = false,
  34057. extendEnd = false;
  34058. if (dict.has("Extend")) {
  34059. var extendArr = dict.getArray("Extend");
  34060. extendStart = extendArr[0];
  34061. extendEnd = extendArr[1];
  34062. }
  34063. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  34064. var x1 = this.coordsArr[0];
  34065. var y1 = this.coordsArr[1];
  34066. var r1 = this.coordsArr[2];
  34067. var x2 = this.coordsArr[3];
  34068. var y2 = this.coordsArr[4];
  34069. var r2 = this.coordsArr[5];
  34070. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  34071. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  34072. (0, _util.warn)("Unsupported radial gradient.");
  34073. }
  34074. }
  34075. this.extendStart = extendStart;
  34076. this.extendEnd = extendEnd;
  34077. var fnObj = dict.getRaw("Function");
  34078. var fn = pdfFunctionFactory.createFromArray(fnObj);
  34079. const NUMBER_OF_SAMPLES = 10;
  34080. const step = (t1 - t0) / NUMBER_OF_SAMPLES;
  34081. var colorStops = this.colorStops = [];
  34082. if (t0 >= t1 || step <= 0) {
  34083. (0, _util.info)("Bad shading domain.");
  34084. return;
  34085. }
  34086. var color = new Float32Array(cs.numComps),
  34087. ratio = new Float32Array(1);
  34088. var rgbColor;
  34089. for (let i = 0; i <= NUMBER_OF_SAMPLES; i++) {
  34090. ratio[0] = t0 + i * step;
  34091. fn(ratio, 0, color, 0);
  34092. rgbColor = cs.getRgb(color, 0);
  34093. var cssColor = _util.Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  34094. colorStops.push([i / NUMBER_OF_SAMPLES, cssColor]);
  34095. }
  34096. var background = "transparent";
  34097. if (dict.has("Background")) {
  34098. rgbColor = cs.getRgb(dict.get("Background"), 0);
  34099. background = _util.Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  34100. }
  34101. if (!extendStart) {
  34102. colorStops.unshift([0, background]);
  34103. colorStops[1][0] += Shadings.SMALL_NUMBER;
  34104. }
  34105. if (!extendEnd) {
  34106. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  34107. colorStops.push([1, background]);
  34108. }
  34109. this.colorStops = colorStops;
  34110. }
  34111. RadialAxial.prototype = {
  34112. getIR: function RadialAxial_getIR() {
  34113. var coordsArr = this.coordsArr;
  34114. var shadingType = this.shadingType;
  34115. var type, p0, p1, r0, r1;
  34116. if (shadingType === ShadingType.AXIAL) {
  34117. p0 = [coordsArr[0], coordsArr[1]];
  34118. p1 = [coordsArr[2], coordsArr[3]];
  34119. r0 = null;
  34120. r1 = null;
  34121. type = "axial";
  34122. } else if (shadingType === ShadingType.RADIAL) {
  34123. p0 = [coordsArr[0], coordsArr[1]];
  34124. p1 = [coordsArr[3], coordsArr[4]];
  34125. r0 = coordsArr[2];
  34126. r1 = coordsArr[5];
  34127. type = "radial";
  34128. } else {
  34129. (0, _util.unreachable)(`getPattern type unknown: ${shadingType}`);
  34130. }
  34131. var matrix = this.matrix;
  34132. if (matrix) {
  34133. p0 = _util.Util.applyTransform(p0, matrix);
  34134. p1 = _util.Util.applyTransform(p1, matrix);
  34135. if (shadingType === ShadingType.RADIAL) {
  34136. var scale = _util.Util.singularValueDecompose2dScale(matrix);
  34137. r0 *= scale[0];
  34138. r1 *= scale[1];
  34139. }
  34140. }
  34141. return ["RadialAxial", type, this.bbox, this.colorStops, p0, p1, r0, r1];
  34142. }
  34143. };
  34144. return RadialAxial;
  34145. }();
  34146. Shadings.Mesh = function MeshClosure() {
  34147. function MeshStreamReader(stream, context) {
  34148. this.stream = stream;
  34149. this.context = context;
  34150. this.buffer = 0;
  34151. this.bufferLength = 0;
  34152. var numComps = context.numComps;
  34153. this.tmpCompsBuf = new Float32Array(numComps);
  34154. var csNumComps = context.colorSpace.numComps;
  34155. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  34156. }
  34157. MeshStreamReader.prototype = {
  34158. get hasData() {
  34159. if (this.stream.end) {
  34160. return this.stream.pos < this.stream.end;
  34161. }
  34162. if (this.bufferLength > 0) {
  34163. return true;
  34164. }
  34165. var nextByte = this.stream.getByte();
  34166. if (nextByte < 0) {
  34167. return false;
  34168. }
  34169. this.buffer = nextByte;
  34170. this.bufferLength = 8;
  34171. return true;
  34172. },
  34173. readBits: function MeshStreamReader_readBits(n) {
  34174. var buffer = this.buffer;
  34175. var bufferLength = this.bufferLength;
  34176. if (n === 32) {
  34177. if (bufferLength === 0) {
  34178. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  34179. }
  34180. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  34181. var nextByte = this.stream.getByte();
  34182. this.buffer = nextByte & (1 << bufferLength) - 1;
  34183. return (buffer << 8 - bufferLength | (nextByte & 0xff) >> bufferLength) >>> 0;
  34184. }
  34185. if (n === 8 && bufferLength === 0) {
  34186. return this.stream.getByte();
  34187. }
  34188. while (bufferLength < n) {
  34189. buffer = buffer << 8 | this.stream.getByte();
  34190. bufferLength += 8;
  34191. }
  34192. bufferLength -= n;
  34193. this.bufferLength = bufferLength;
  34194. this.buffer = buffer & (1 << bufferLength) - 1;
  34195. return buffer >> bufferLength;
  34196. },
  34197. align: function MeshStreamReader_align() {
  34198. this.buffer = 0;
  34199. this.bufferLength = 0;
  34200. },
  34201. readFlag: function MeshStreamReader_readFlag() {
  34202. return this.readBits(this.context.bitsPerFlag);
  34203. },
  34204. readCoordinate: function MeshStreamReader_readCoordinate() {
  34205. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  34206. var xi = this.readBits(bitsPerCoordinate);
  34207. var yi = this.readBits(bitsPerCoordinate);
  34208. var decode = this.context.decode;
  34209. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  34210. return [xi * scale * (decode[1] - decode[0]) + decode[0], yi * scale * (decode[3] - decode[2]) + decode[2]];
  34211. },
  34212. readComponents: function MeshStreamReader_readComponents() {
  34213. var numComps = this.context.numComps;
  34214. var bitsPerComponent = this.context.bitsPerComponent;
  34215. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  34216. var decode = this.context.decode;
  34217. var components = this.tmpCompsBuf;
  34218. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  34219. var ci = this.readBits(bitsPerComponent);
  34220. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  34221. }
  34222. var color = this.tmpCsCompsBuf;
  34223. if (this.context.colorFn) {
  34224. this.context.colorFn(components, 0, color, 0);
  34225. }
  34226. return this.context.colorSpace.getRgb(color, 0);
  34227. }
  34228. };
  34229. function decodeType4Shading(mesh, reader) {
  34230. var coords = mesh.coords;
  34231. var colors = mesh.colors;
  34232. var operators = [];
  34233. var ps = [];
  34234. var verticesLeft = 0;
  34235. while (reader.hasData) {
  34236. var f = reader.readFlag();
  34237. var coord = reader.readCoordinate();
  34238. var color = reader.readComponents();
  34239. if (verticesLeft === 0) {
  34240. if (!(0 <= f && f <= 2)) {
  34241. throw new _util.FormatError("Unknown type4 flag");
  34242. }
  34243. switch (f) {
  34244. case 0:
  34245. verticesLeft = 3;
  34246. break;
  34247. case 1:
  34248. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  34249. verticesLeft = 1;
  34250. break;
  34251. case 2:
  34252. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  34253. verticesLeft = 1;
  34254. break;
  34255. }
  34256. operators.push(f);
  34257. }
  34258. ps.push(coords.length);
  34259. coords.push(coord);
  34260. colors.push(color);
  34261. verticesLeft--;
  34262. reader.align();
  34263. }
  34264. mesh.figures.push({
  34265. type: "triangles",
  34266. coords: new Int32Array(ps),
  34267. colors: new Int32Array(ps)
  34268. });
  34269. }
  34270. function decodeType5Shading(mesh, reader, verticesPerRow) {
  34271. var coords = mesh.coords;
  34272. var colors = mesh.colors;
  34273. var ps = [];
  34274. while (reader.hasData) {
  34275. var coord = reader.readCoordinate();
  34276. var color = reader.readComponents();
  34277. ps.push(coords.length);
  34278. coords.push(coord);
  34279. colors.push(color);
  34280. }
  34281. mesh.figures.push({
  34282. type: "lattice",
  34283. coords: new Int32Array(ps),
  34284. colors: new Int32Array(ps),
  34285. verticesPerRow
  34286. });
  34287. }
  34288. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  34289. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  34290. var TRIANGLE_DENSITY = 20;
  34291. var getB = function getBClosure() {
  34292. function buildB(count) {
  34293. var lut = [];
  34294. for (var i = 0; i <= count; i++) {
  34295. var t = i / count,
  34296. t_ = 1 - t;
  34297. lut.push(new Float32Array([t_ * t_ * t_, 3 * t * t_ * t_, 3 * t * t * t_, t * t * t]));
  34298. }
  34299. return lut;
  34300. }
  34301. var cache = [];
  34302. return function getB(count) {
  34303. if (!cache[count]) {
  34304. cache[count] = buildB(count);
  34305. }
  34306. return cache[count];
  34307. };
  34308. }();
  34309. function buildFigureFromPatch(mesh, index) {
  34310. var figure = mesh.figures[index];
  34311. (0, _util.assert)(figure.type === "patch", "Unexpected patch mesh figure");
  34312. var coords = mesh.coords,
  34313. colors = mesh.colors;
  34314. var pi = figure.coords;
  34315. var ci = figure.colors;
  34316. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  34317. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  34318. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  34319. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  34320. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  34321. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  34322. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  34323. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  34324. var verticesPerRow = splitXBy + 1;
  34325. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  34326. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  34327. var k = 0;
  34328. var cl = new Uint8Array(3),
  34329. cr = new Uint8Array(3);
  34330. var c0 = colors[ci[0]],
  34331. c1 = colors[ci[1]],
  34332. c2 = colors[ci[2]],
  34333. c3 = colors[ci[3]];
  34334. var bRow = getB(splitYBy),
  34335. bCol = getB(splitXBy);
  34336. for (var row = 0; row <= splitYBy; row++) {
  34337. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  34338. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  34339. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  34340. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  34341. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  34342. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  34343. for (var col = 0; col <= splitXBy; col++, k++) {
  34344. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  34345. continue;
  34346. }
  34347. var x = 0,
  34348. y = 0;
  34349. var q = 0;
  34350. for (var i = 0; i <= 3; i++) {
  34351. for (var j = 0; j <= 3; j++, q++) {
  34352. var m = bRow[row][i] * bCol[col][j];
  34353. x += coords[pi[q]][0] * m;
  34354. y += coords[pi[q]][1] * m;
  34355. }
  34356. }
  34357. figureCoords[k] = coords.length;
  34358. coords.push([x, y]);
  34359. figureColors[k] = colors.length;
  34360. var newColor = new Uint8Array(3);
  34361. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  34362. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  34363. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  34364. colors.push(newColor);
  34365. }
  34366. }
  34367. figureCoords[0] = pi[0];
  34368. figureColors[0] = ci[0];
  34369. figureCoords[splitXBy] = pi[3];
  34370. figureColors[splitXBy] = ci[1];
  34371. figureCoords[verticesPerRow * splitYBy] = pi[12];
  34372. figureColors[verticesPerRow * splitYBy] = ci[2];
  34373. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  34374. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  34375. mesh.figures[index] = {
  34376. type: "lattice",
  34377. coords: figureCoords,
  34378. colors: figureColors,
  34379. verticesPerRow
  34380. };
  34381. }
  34382. function decodeType6Shading(mesh, reader) {
  34383. var coords = mesh.coords;
  34384. var colors = mesh.colors;
  34385. var ps = new Int32Array(16);
  34386. var cs = new Int32Array(4);
  34387. while (reader.hasData) {
  34388. var f = reader.readFlag();
  34389. if (!(0 <= f && f <= 3)) {
  34390. throw new _util.FormatError("Unknown type6 flag");
  34391. }
  34392. var i, ii;
  34393. var pi = coords.length;
  34394. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  34395. coords.push(reader.readCoordinate());
  34396. }
  34397. var ci = colors.length;
  34398. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  34399. colors.push(reader.readComponents());
  34400. }
  34401. var tmp1, tmp2, tmp3, tmp4;
  34402. switch (f) {
  34403. case 0:
  34404. ps[12] = pi + 3;
  34405. ps[13] = pi + 4;
  34406. ps[14] = pi + 5;
  34407. ps[15] = pi + 6;
  34408. ps[8] = pi + 2;
  34409. ps[11] = pi + 7;
  34410. ps[4] = pi + 1;
  34411. ps[7] = pi + 8;
  34412. ps[0] = pi;
  34413. ps[1] = pi + 11;
  34414. ps[2] = pi + 10;
  34415. ps[3] = pi + 9;
  34416. cs[2] = ci + 1;
  34417. cs[3] = ci + 2;
  34418. cs[0] = ci;
  34419. cs[1] = ci + 3;
  34420. break;
  34421. case 1:
  34422. tmp1 = ps[12];
  34423. tmp2 = ps[13];
  34424. tmp3 = ps[14];
  34425. tmp4 = ps[15];
  34426. ps[12] = tmp4;
  34427. ps[13] = pi + 0;
  34428. ps[14] = pi + 1;
  34429. ps[15] = pi + 2;
  34430. ps[8] = tmp3;
  34431. ps[11] = pi + 3;
  34432. ps[4] = tmp2;
  34433. ps[7] = pi + 4;
  34434. ps[0] = tmp1;
  34435. ps[1] = pi + 7;
  34436. ps[2] = pi + 6;
  34437. ps[3] = pi + 5;
  34438. tmp1 = cs[2];
  34439. tmp2 = cs[3];
  34440. cs[2] = tmp2;
  34441. cs[3] = ci;
  34442. cs[0] = tmp1;
  34443. cs[1] = ci + 1;
  34444. break;
  34445. case 2:
  34446. tmp1 = ps[15];
  34447. tmp2 = ps[11];
  34448. ps[12] = ps[3];
  34449. ps[13] = pi + 0;
  34450. ps[14] = pi + 1;
  34451. ps[15] = pi + 2;
  34452. ps[8] = ps[7];
  34453. ps[11] = pi + 3;
  34454. ps[4] = tmp2;
  34455. ps[7] = pi + 4;
  34456. ps[0] = tmp1;
  34457. ps[1] = pi + 7;
  34458. ps[2] = pi + 6;
  34459. ps[3] = pi + 5;
  34460. tmp1 = cs[3];
  34461. cs[2] = cs[1];
  34462. cs[3] = ci;
  34463. cs[0] = tmp1;
  34464. cs[1] = ci + 1;
  34465. break;
  34466. case 3:
  34467. ps[12] = ps[0];
  34468. ps[13] = pi + 0;
  34469. ps[14] = pi + 1;
  34470. ps[15] = pi + 2;
  34471. ps[8] = ps[1];
  34472. ps[11] = pi + 3;
  34473. ps[4] = ps[2];
  34474. ps[7] = pi + 4;
  34475. ps[0] = ps[3];
  34476. ps[1] = pi + 7;
  34477. ps[2] = pi + 6;
  34478. ps[3] = pi + 5;
  34479. cs[2] = cs[0];
  34480. cs[3] = ci;
  34481. cs[0] = cs[1];
  34482. cs[1] = ci + 1;
  34483. break;
  34484. }
  34485. ps[5] = coords.length;
  34486. coords.push([(-4 * coords[ps[0]][0] - coords[ps[15]][0] + 6 * (coords[ps[4]][0] + coords[ps[1]][0]) - 2 * (coords[ps[12]][0] + coords[ps[3]][0]) + 3 * (coords[ps[13]][0] + coords[ps[7]][0])) / 9, (-4 * coords[ps[0]][1] - coords[ps[15]][1] + 6 * (coords[ps[4]][1] + coords[ps[1]][1]) - 2 * (coords[ps[12]][1] + coords[ps[3]][1]) + 3 * (coords[ps[13]][1] + coords[ps[7]][1])) / 9]);
  34487. ps[6] = coords.length;
  34488. coords.push([(-4 * coords[ps[3]][0] - coords[ps[12]][0] + 6 * (coords[ps[2]][0] + coords[ps[7]][0]) - 2 * (coords[ps[0]][0] + coords[ps[15]][0]) + 3 * (coords[ps[4]][0] + coords[ps[14]][0])) / 9, (-4 * coords[ps[3]][1] - coords[ps[12]][1] + 6 * (coords[ps[2]][1] + coords[ps[7]][1]) - 2 * (coords[ps[0]][1] + coords[ps[15]][1]) + 3 * (coords[ps[4]][1] + coords[ps[14]][1])) / 9]);
  34489. ps[9] = coords.length;
  34490. coords.push([(-4 * coords[ps[12]][0] - coords[ps[3]][0] + 6 * (coords[ps[8]][0] + coords[ps[13]][0]) - 2 * (coords[ps[0]][0] + coords[ps[15]][0]) + 3 * (coords[ps[11]][0] + coords[ps[1]][0])) / 9, (-4 * coords[ps[12]][1] - coords[ps[3]][1] + 6 * (coords[ps[8]][1] + coords[ps[13]][1]) - 2 * (coords[ps[0]][1] + coords[ps[15]][1]) + 3 * (coords[ps[11]][1] + coords[ps[1]][1])) / 9]);
  34491. ps[10] = coords.length;
  34492. coords.push([(-4 * coords[ps[15]][0] - coords[ps[0]][0] + 6 * (coords[ps[11]][0] + coords[ps[14]][0]) - 2 * (coords[ps[12]][0] + coords[ps[3]][0]) + 3 * (coords[ps[2]][0] + coords[ps[8]][0])) / 9, (-4 * coords[ps[15]][1] - coords[ps[0]][1] + 6 * (coords[ps[11]][1] + coords[ps[14]][1]) - 2 * (coords[ps[12]][1] + coords[ps[3]][1]) + 3 * (coords[ps[2]][1] + coords[ps[8]][1])) / 9]);
  34493. mesh.figures.push({
  34494. type: "patch",
  34495. coords: new Int32Array(ps),
  34496. colors: new Int32Array(cs)
  34497. });
  34498. }
  34499. }
  34500. function decodeType7Shading(mesh, reader) {
  34501. var coords = mesh.coords;
  34502. var colors = mesh.colors;
  34503. var ps = new Int32Array(16);
  34504. var cs = new Int32Array(4);
  34505. while (reader.hasData) {
  34506. var f = reader.readFlag();
  34507. if (!(0 <= f && f <= 3)) {
  34508. throw new _util.FormatError("Unknown type7 flag");
  34509. }
  34510. var i, ii;
  34511. var pi = coords.length;
  34512. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  34513. coords.push(reader.readCoordinate());
  34514. }
  34515. var ci = colors.length;
  34516. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  34517. colors.push(reader.readComponents());
  34518. }
  34519. var tmp1, tmp2, tmp3, tmp4;
  34520. switch (f) {
  34521. case 0:
  34522. ps[12] = pi + 3;
  34523. ps[13] = pi + 4;
  34524. ps[14] = pi + 5;
  34525. ps[15] = pi + 6;
  34526. ps[8] = pi + 2;
  34527. ps[9] = pi + 13;
  34528. ps[10] = pi + 14;
  34529. ps[11] = pi + 7;
  34530. ps[4] = pi + 1;
  34531. ps[5] = pi + 12;
  34532. ps[6] = pi + 15;
  34533. ps[7] = pi + 8;
  34534. ps[0] = pi;
  34535. ps[1] = pi + 11;
  34536. ps[2] = pi + 10;
  34537. ps[3] = pi + 9;
  34538. cs[2] = ci + 1;
  34539. cs[3] = ci + 2;
  34540. cs[0] = ci;
  34541. cs[1] = ci + 3;
  34542. break;
  34543. case 1:
  34544. tmp1 = ps[12];
  34545. tmp2 = ps[13];
  34546. tmp3 = ps[14];
  34547. tmp4 = ps[15];
  34548. ps[12] = tmp4;
  34549. ps[13] = pi + 0;
  34550. ps[14] = pi + 1;
  34551. ps[15] = pi + 2;
  34552. ps[8] = tmp3;
  34553. ps[9] = pi + 9;
  34554. ps[10] = pi + 10;
  34555. ps[11] = pi + 3;
  34556. ps[4] = tmp2;
  34557. ps[5] = pi + 8;
  34558. ps[6] = pi + 11;
  34559. ps[7] = pi + 4;
  34560. ps[0] = tmp1;
  34561. ps[1] = pi + 7;
  34562. ps[2] = pi + 6;
  34563. ps[3] = pi + 5;
  34564. tmp1 = cs[2];
  34565. tmp2 = cs[3];
  34566. cs[2] = tmp2;
  34567. cs[3] = ci;
  34568. cs[0] = tmp1;
  34569. cs[1] = ci + 1;
  34570. break;
  34571. case 2:
  34572. tmp1 = ps[15];
  34573. tmp2 = ps[11];
  34574. ps[12] = ps[3];
  34575. ps[13] = pi + 0;
  34576. ps[14] = pi + 1;
  34577. ps[15] = pi + 2;
  34578. ps[8] = ps[7];
  34579. ps[9] = pi + 9;
  34580. ps[10] = pi + 10;
  34581. ps[11] = pi + 3;
  34582. ps[4] = tmp2;
  34583. ps[5] = pi + 8;
  34584. ps[6] = pi + 11;
  34585. ps[7] = pi + 4;
  34586. ps[0] = tmp1;
  34587. ps[1] = pi + 7;
  34588. ps[2] = pi + 6;
  34589. ps[3] = pi + 5;
  34590. tmp1 = cs[3];
  34591. cs[2] = cs[1];
  34592. cs[3] = ci;
  34593. cs[0] = tmp1;
  34594. cs[1] = ci + 1;
  34595. break;
  34596. case 3:
  34597. ps[12] = ps[0];
  34598. ps[13] = pi + 0;
  34599. ps[14] = pi + 1;
  34600. ps[15] = pi + 2;
  34601. ps[8] = ps[1];
  34602. ps[9] = pi + 9;
  34603. ps[10] = pi + 10;
  34604. ps[11] = pi + 3;
  34605. ps[4] = ps[2];
  34606. ps[5] = pi + 8;
  34607. ps[6] = pi + 11;
  34608. ps[7] = pi + 4;
  34609. ps[0] = ps[3];
  34610. ps[1] = pi + 7;
  34611. ps[2] = pi + 6;
  34612. ps[3] = pi + 5;
  34613. cs[2] = cs[0];
  34614. cs[3] = ci;
  34615. cs[0] = cs[1];
  34616. cs[1] = ci + 1;
  34617. break;
  34618. }
  34619. mesh.figures.push({
  34620. type: "patch",
  34621. coords: new Int32Array(ps),
  34622. colors: new Int32Array(cs)
  34623. });
  34624. }
  34625. }
  34626. function updateBounds(mesh) {
  34627. var minX = mesh.coords[0][0],
  34628. minY = mesh.coords[0][1],
  34629. maxX = minX,
  34630. maxY = minY;
  34631. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  34632. var x = mesh.coords[i][0],
  34633. y = mesh.coords[i][1];
  34634. minX = minX > x ? x : minX;
  34635. minY = minY > y ? y : minY;
  34636. maxX = maxX < x ? x : maxX;
  34637. maxY = maxY < y ? y : maxY;
  34638. }
  34639. mesh.bounds = [minX, minY, maxX, maxY];
  34640. }
  34641. function packData(mesh) {
  34642. var i, ii, j, jj;
  34643. var coords = mesh.coords;
  34644. var coordsPacked = new Float32Array(coords.length * 2);
  34645. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  34646. var xy = coords[i];
  34647. coordsPacked[j++] = xy[0];
  34648. coordsPacked[j++] = xy[1];
  34649. }
  34650. mesh.coords = coordsPacked;
  34651. var colors = mesh.colors;
  34652. var colorsPacked = new Uint8Array(colors.length * 3);
  34653. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  34654. var c = colors[i];
  34655. colorsPacked[j++] = c[0];
  34656. colorsPacked[j++] = c[1];
  34657. colorsPacked[j++] = c[2];
  34658. }
  34659. mesh.colors = colorsPacked;
  34660. var figures = mesh.figures;
  34661. for (i = 0, ii = figures.length; i < ii; i++) {
  34662. var figure = figures[i],
  34663. ps = figure.coords,
  34664. cs = figure.colors;
  34665. for (j = 0, jj = ps.length; j < jj; j++) {
  34666. ps[j] *= 2;
  34667. cs[j] *= 3;
  34668. }
  34669. }
  34670. }
  34671. function Mesh(stream, matrix, xref, resources, pdfFunctionFactory, localColorSpaceCache) {
  34672. if (!(0, _primitives.isStream)(stream)) {
  34673. throw new _util.FormatError("Mesh data is not a stream");
  34674. }
  34675. var dict = stream.dict;
  34676. this.matrix = matrix;
  34677. this.shadingType = dict.get("ShadingType");
  34678. this.type = "Pattern";
  34679. const bbox = dict.getArray("BBox");
  34680. if (Array.isArray(bbox) && bbox.length === 4) {
  34681. this.bbox = _util.Util.normalizeRect(bbox);
  34682. } else {
  34683. this.bbox = null;
  34684. }
  34685. const cs = _colorspace.ColorSpace.parse({
  34686. cs: dict.getRaw("ColorSpace") || dict.getRaw("CS"),
  34687. xref,
  34688. resources,
  34689. pdfFunctionFactory,
  34690. localColorSpaceCache
  34691. });
  34692. this.cs = cs;
  34693. this.background = dict.has("Background") ? cs.getRgb(dict.get("Background"), 0) : null;
  34694. var fnObj = dict.getRaw("Function");
  34695. var fn = fnObj ? pdfFunctionFactory.createFromArray(fnObj) : null;
  34696. this.coords = [];
  34697. this.colors = [];
  34698. this.figures = [];
  34699. var decodeContext = {
  34700. bitsPerCoordinate: dict.get("BitsPerCoordinate"),
  34701. bitsPerComponent: dict.get("BitsPerComponent"),
  34702. bitsPerFlag: dict.get("BitsPerFlag"),
  34703. decode: dict.getArray("Decode"),
  34704. colorFn: fn,
  34705. colorSpace: cs,
  34706. numComps: fn ? 1 : cs.numComps
  34707. };
  34708. var reader = new MeshStreamReader(stream, decodeContext);
  34709. var patchMesh = false;
  34710. switch (this.shadingType) {
  34711. case ShadingType.FREE_FORM_MESH:
  34712. decodeType4Shading(this, reader);
  34713. break;
  34714. case ShadingType.LATTICE_FORM_MESH:
  34715. var verticesPerRow = dict.get("VerticesPerRow") | 0;
  34716. if (verticesPerRow < 2) {
  34717. throw new _util.FormatError("Invalid VerticesPerRow");
  34718. }
  34719. decodeType5Shading(this, reader, verticesPerRow);
  34720. break;
  34721. case ShadingType.COONS_PATCH_MESH:
  34722. decodeType6Shading(this, reader);
  34723. patchMesh = true;
  34724. break;
  34725. case ShadingType.TENSOR_PATCH_MESH:
  34726. decodeType7Shading(this, reader);
  34727. patchMesh = true;
  34728. break;
  34729. default:
  34730. (0, _util.unreachable)("Unsupported mesh type.");
  34731. break;
  34732. }
  34733. if (patchMesh) {
  34734. updateBounds(this);
  34735. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  34736. buildFigureFromPatch(this, i);
  34737. }
  34738. }
  34739. updateBounds(this);
  34740. packData(this);
  34741. }
  34742. Mesh.prototype = {
  34743. getIR: function Mesh_getIR() {
  34744. return ["Mesh", this.shadingType, this.coords, this.colors, this.figures, this.bounds, this.matrix, this.bbox, this.background];
  34745. }
  34746. };
  34747. return Mesh;
  34748. }();
  34749. Shadings.Dummy = function DummyClosure() {
  34750. function Dummy() {
  34751. this.type = "Pattern";
  34752. }
  34753. Dummy.prototype = {
  34754. getIR: function Dummy_getIR() {
  34755. return ["Dummy"];
  34756. }
  34757. };
  34758. return Dummy;
  34759. }();
  34760. function getTilingPatternIR(operatorList, dict, args) {
  34761. const matrix = dict.getArray("Matrix");
  34762. const bbox = _util.Util.normalizeRect(dict.getArray("BBox"));
  34763. const xstep = dict.get("XStep");
  34764. const ystep = dict.get("YStep");
  34765. const paintType = dict.get("PaintType");
  34766. const tilingType = dict.get("TilingType");
  34767. if (bbox[2] - bbox[0] === 0 || bbox[3] - bbox[1] === 0) {
  34768. throw new _util.FormatError(`Invalid getTilingPatternIR /BBox array: [${bbox}].`);
  34769. }
  34770. return ["TilingPattern", args, operatorList, matrix, bbox, xstep, ystep, paintType, tilingType];
  34771. }
  34772. /***/ }),
  34773. /* 40 */
  34774. /***/ (function(module, exports, __w_pdfjs_require__) {
  34775. "use strict";
  34776. Object.defineProperty(exports, "__esModule", {
  34777. value: true
  34778. });
  34779. exports.isPDFFunction = isPDFFunction;
  34780. exports.PostScriptCompiler = exports.PostScriptEvaluator = exports.PDFFunctionFactory = void 0;
  34781. var _primitives = __w_pdfjs_require__(5);
  34782. var _util = __w_pdfjs_require__(2);
  34783. var _ps_parser = __w_pdfjs_require__(41);
  34784. var _image_utils = __w_pdfjs_require__(24);
  34785. class PDFFunctionFactory {
  34786. constructor({
  34787. xref,
  34788. isEvalSupported = true
  34789. }) {
  34790. this.xref = xref;
  34791. this.isEvalSupported = isEvalSupported !== false;
  34792. this._localFunctionCache = null;
  34793. }
  34794. create(fn) {
  34795. const cachedFunction = this.getCached(fn);
  34796. if (cachedFunction) {
  34797. return cachedFunction;
  34798. }
  34799. const parsedFunction = PDFFunction.parse({
  34800. xref: this.xref,
  34801. isEvalSupported: this.isEvalSupported,
  34802. fn: fn instanceof _primitives.Ref ? this.xref.fetch(fn) : fn
  34803. });
  34804. this._cache(fn, parsedFunction);
  34805. return parsedFunction;
  34806. }
  34807. createFromArray(fnObj) {
  34808. const cachedFunction = this.getCached(fnObj);
  34809. if (cachedFunction) {
  34810. return cachedFunction;
  34811. }
  34812. const parsedFunction = PDFFunction.parseArray({
  34813. xref: this.xref,
  34814. isEvalSupported: this.isEvalSupported,
  34815. fnObj: fnObj instanceof _primitives.Ref ? this.xref.fetch(fnObj) : fnObj
  34816. });
  34817. this._cache(fnObj, parsedFunction);
  34818. return parsedFunction;
  34819. }
  34820. getCached(cacheKey) {
  34821. let fnRef;
  34822. if (cacheKey instanceof _primitives.Ref) {
  34823. fnRef = cacheKey;
  34824. } else if (cacheKey instanceof _primitives.Dict) {
  34825. fnRef = cacheKey.objId;
  34826. } else if ((0, _primitives.isStream)(cacheKey)) {
  34827. fnRef = cacheKey.dict && cacheKey.dict.objId;
  34828. }
  34829. if (fnRef) {
  34830. if (!this._localFunctionCache) {
  34831. this._localFunctionCache = new _image_utils.LocalFunctionCache();
  34832. }
  34833. const localFunction = this._localFunctionCache.getByRef(fnRef);
  34834. if (localFunction) {
  34835. return localFunction;
  34836. }
  34837. }
  34838. return null;
  34839. }
  34840. _cache(cacheKey, parsedFunction) {
  34841. if (!parsedFunction) {
  34842. throw new Error('PDFFunctionFactory._cache - expected "parsedFunction" argument.');
  34843. }
  34844. let fnRef;
  34845. if (cacheKey instanceof _primitives.Ref) {
  34846. fnRef = cacheKey;
  34847. } else if (cacheKey instanceof _primitives.Dict) {
  34848. fnRef = cacheKey.objId;
  34849. } else if ((0, _primitives.isStream)(cacheKey)) {
  34850. fnRef = cacheKey.dict && cacheKey.dict.objId;
  34851. }
  34852. if (fnRef) {
  34853. if (!this._localFunctionCache) {
  34854. this._localFunctionCache = new _image_utils.LocalFunctionCache();
  34855. }
  34856. this._localFunctionCache.set(null, fnRef, parsedFunction);
  34857. }
  34858. }
  34859. }
  34860. exports.PDFFunctionFactory = PDFFunctionFactory;
  34861. function toNumberArray(arr) {
  34862. if (!Array.isArray(arr)) {
  34863. return null;
  34864. }
  34865. const length = arr.length;
  34866. for (let i = 0; i < length; i++) {
  34867. if (typeof arr[i] !== "number") {
  34868. const result = new Array(length);
  34869. for (let j = 0; j < length; j++) {
  34870. result[j] = +arr[j];
  34871. }
  34872. return result;
  34873. }
  34874. }
  34875. return arr;
  34876. }
  34877. var PDFFunction = function PDFFunctionClosure() {
  34878. const CONSTRUCT_SAMPLED = 0;
  34879. const CONSTRUCT_INTERPOLATED = 2;
  34880. const CONSTRUCT_STICHED = 3;
  34881. const CONSTRUCT_POSTSCRIPT = 4;
  34882. return {
  34883. getSampleArray(size, outputSize, bps, stream) {
  34884. var i, ii;
  34885. var length = 1;
  34886. for (i = 0, ii = size.length; i < ii; i++) {
  34887. length *= size[i];
  34888. }
  34889. length *= outputSize;
  34890. var array = new Array(length);
  34891. var codeSize = 0;
  34892. var codeBuf = 0;
  34893. var sampleMul = 1.0 / (2.0 ** bps - 1);
  34894. var strBytes = stream.getBytes((length * bps + 7) / 8);
  34895. var strIdx = 0;
  34896. for (i = 0; i < length; i++) {
  34897. while (codeSize < bps) {
  34898. codeBuf <<= 8;
  34899. codeBuf |= strBytes[strIdx++];
  34900. codeSize += 8;
  34901. }
  34902. codeSize -= bps;
  34903. array[i] = (codeBuf >> codeSize) * sampleMul;
  34904. codeBuf &= (1 << codeSize) - 1;
  34905. }
  34906. return array;
  34907. },
  34908. getIR({
  34909. xref,
  34910. isEvalSupported,
  34911. fn
  34912. }) {
  34913. var dict = fn.dict;
  34914. if (!dict) {
  34915. dict = fn;
  34916. }
  34917. var types = [this.constructSampled, null, this.constructInterpolated, this.constructStiched, this.constructPostScript];
  34918. var typeNum = dict.get("FunctionType");
  34919. var typeFn = types[typeNum];
  34920. if (!typeFn) {
  34921. throw new _util.FormatError("Unknown type of function");
  34922. }
  34923. return typeFn.call(this, {
  34924. xref,
  34925. isEvalSupported,
  34926. fn,
  34927. dict
  34928. });
  34929. },
  34930. fromIR({
  34931. xref,
  34932. isEvalSupported,
  34933. IR
  34934. }) {
  34935. var type = IR[0];
  34936. switch (type) {
  34937. case CONSTRUCT_SAMPLED:
  34938. return this.constructSampledFromIR({
  34939. xref,
  34940. isEvalSupported,
  34941. IR
  34942. });
  34943. case CONSTRUCT_INTERPOLATED:
  34944. return this.constructInterpolatedFromIR({
  34945. xref,
  34946. isEvalSupported,
  34947. IR
  34948. });
  34949. case CONSTRUCT_STICHED:
  34950. return this.constructStichedFromIR({
  34951. xref,
  34952. isEvalSupported,
  34953. IR
  34954. });
  34955. default:
  34956. return this.constructPostScriptFromIR({
  34957. xref,
  34958. isEvalSupported,
  34959. IR
  34960. });
  34961. }
  34962. },
  34963. parse({
  34964. xref,
  34965. isEvalSupported,
  34966. fn
  34967. }) {
  34968. const IR = this.getIR({
  34969. xref,
  34970. isEvalSupported,
  34971. fn
  34972. });
  34973. return this.fromIR({
  34974. xref,
  34975. isEvalSupported,
  34976. IR
  34977. });
  34978. },
  34979. parseArray({
  34980. xref,
  34981. isEvalSupported,
  34982. fnObj
  34983. }) {
  34984. if (!Array.isArray(fnObj)) {
  34985. return this.parse({
  34986. xref,
  34987. isEvalSupported,
  34988. fn: fnObj
  34989. });
  34990. }
  34991. var fnArray = [];
  34992. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  34993. fnArray.push(this.parse({
  34994. xref,
  34995. isEvalSupported,
  34996. fn: xref.fetchIfRef(fnObj[j])
  34997. }));
  34998. }
  34999. return function (src, srcOffset, dest, destOffset) {
  35000. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  35001. fnArray[i](src, srcOffset, dest, destOffset + i);
  35002. }
  35003. };
  35004. },
  35005. constructSampled({
  35006. xref,
  35007. isEvalSupported,
  35008. fn,
  35009. dict
  35010. }) {
  35011. function toMultiArray(arr) {
  35012. var inputLength = arr.length;
  35013. var out = [];
  35014. var index = 0;
  35015. for (var i = 0; i < inputLength; i += 2) {
  35016. out[index] = [arr[i], arr[i + 1]];
  35017. ++index;
  35018. }
  35019. return out;
  35020. }
  35021. var domain = toNumberArray(dict.getArray("Domain"));
  35022. var range = toNumberArray(dict.getArray("Range"));
  35023. if (!domain || !range) {
  35024. throw new _util.FormatError("No domain or range");
  35025. }
  35026. var inputSize = domain.length / 2;
  35027. var outputSize = range.length / 2;
  35028. domain = toMultiArray(domain);
  35029. range = toMultiArray(range);
  35030. var size = toNumberArray(dict.getArray("Size"));
  35031. var bps = dict.get("BitsPerSample");
  35032. var order = dict.get("Order") || 1;
  35033. if (order !== 1) {
  35034. (0, _util.info)("No support for cubic spline interpolation: " + order);
  35035. }
  35036. var encode = toNumberArray(dict.getArray("Encode"));
  35037. if (!encode) {
  35038. encode = [];
  35039. for (var i = 0; i < inputSize; ++i) {
  35040. encode.push([0, size[i] - 1]);
  35041. }
  35042. } else {
  35043. encode = toMultiArray(encode);
  35044. }
  35045. var decode = toNumberArray(dict.getArray("Decode"));
  35046. if (!decode) {
  35047. decode = range;
  35048. } else {
  35049. decode = toMultiArray(decode);
  35050. }
  35051. var samples = this.getSampleArray(size, outputSize, bps, fn);
  35052. return [CONSTRUCT_SAMPLED, inputSize, domain, encode, decode, samples, size, outputSize, 2 ** bps - 1, range];
  35053. },
  35054. constructSampledFromIR({
  35055. xref,
  35056. isEvalSupported,
  35057. IR
  35058. }) {
  35059. function interpolate(x, xmin, xmax, ymin, ymax) {
  35060. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  35061. }
  35062. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  35063. var m = IR[1];
  35064. var domain = IR[2];
  35065. var encode = IR[3];
  35066. var decode = IR[4];
  35067. var samples = IR[5];
  35068. var size = IR[6];
  35069. var n = IR[7];
  35070. var range = IR[9];
  35071. var cubeVertices = 1 << m;
  35072. var cubeN = new Float64Array(cubeVertices);
  35073. var cubeVertex = new Uint32Array(cubeVertices);
  35074. var i, j;
  35075. for (j = 0; j < cubeVertices; j++) {
  35076. cubeN[j] = 1;
  35077. }
  35078. var k = n,
  35079. pos = 1;
  35080. for (i = 0; i < m; ++i) {
  35081. var domain_2i = domain[i][0];
  35082. var domain_2i_1 = domain[i][1];
  35083. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  35084. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  35085. var size_i = size[i];
  35086. e = Math.min(Math.max(e, 0), size_i - 1);
  35087. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  35088. var n0 = e0 + 1 - e;
  35089. var n1 = e - e0;
  35090. var offset0 = e0 * k;
  35091. var offset1 = offset0 + k;
  35092. for (j = 0; j < cubeVertices; j++) {
  35093. if (j & pos) {
  35094. cubeN[j] *= n1;
  35095. cubeVertex[j] += offset1;
  35096. } else {
  35097. cubeN[j] *= n0;
  35098. cubeVertex[j] += offset0;
  35099. }
  35100. }
  35101. k *= size_i;
  35102. pos <<= 1;
  35103. }
  35104. for (j = 0; j < n; ++j) {
  35105. var rj = 0;
  35106. for (i = 0; i < cubeVertices; i++) {
  35107. rj += samples[cubeVertex[i] + j] * cubeN[i];
  35108. }
  35109. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  35110. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  35111. }
  35112. };
  35113. },
  35114. constructInterpolated({
  35115. xref,
  35116. isEvalSupported,
  35117. fn,
  35118. dict
  35119. }) {
  35120. var c0 = toNumberArray(dict.getArray("C0")) || [0];
  35121. var c1 = toNumberArray(dict.getArray("C1")) || [1];
  35122. var n = dict.get("N");
  35123. var length = c0.length;
  35124. var diff = [];
  35125. for (var i = 0; i < length; ++i) {
  35126. diff.push(c1[i] - c0[i]);
  35127. }
  35128. return [CONSTRUCT_INTERPOLATED, c0, diff, n];
  35129. },
  35130. constructInterpolatedFromIR({
  35131. xref,
  35132. isEvalSupported,
  35133. IR
  35134. }) {
  35135. var c0 = IR[1];
  35136. var diff = IR[2];
  35137. var n = IR[3];
  35138. var length = diff.length;
  35139. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  35140. var x = n === 1 ? src[srcOffset] : src[srcOffset] ** n;
  35141. for (var j = 0; j < length; ++j) {
  35142. dest[destOffset + j] = c0[j] + x * diff[j];
  35143. }
  35144. };
  35145. },
  35146. constructStiched({
  35147. xref,
  35148. isEvalSupported,
  35149. fn,
  35150. dict
  35151. }) {
  35152. var domain = toNumberArray(dict.getArray("Domain"));
  35153. if (!domain) {
  35154. throw new _util.FormatError("No domain");
  35155. }
  35156. var inputSize = domain.length / 2;
  35157. if (inputSize !== 1) {
  35158. throw new _util.FormatError("Bad domain for stiched function");
  35159. }
  35160. var fnRefs = dict.get("Functions");
  35161. var fns = [];
  35162. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  35163. fns.push(this.parse({
  35164. xref,
  35165. isEvalSupported,
  35166. fn: xref.fetchIfRef(fnRefs[i])
  35167. }));
  35168. }
  35169. var bounds = toNumberArray(dict.getArray("Bounds"));
  35170. var encode = toNumberArray(dict.getArray("Encode"));
  35171. return [CONSTRUCT_STICHED, domain, bounds, encode, fns];
  35172. },
  35173. constructStichedFromIR({
  35174. xref,
  35175. isEvalSupported,
  35176. IR
  35177. }) {
  35178. var domain = IR[1];
  35179. var bounds = IR[2];
  35180. var encode = IR[3];
  35181. var fns = IR[4];
  35182. var tmpBuf = new Float32Array(1);
  35183. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  35184. var clip = function constructStichedFromIRClip(v, min, max) {
  35185. if (v > max) {
  35186. v = max;
  35187. } else if (v < min) {
  35188. v = min;
  35189. }
  35190. return v;
  35191. };
  35192. var v = clip(src[srcOffset], domain[0], domain[1]);
  35193. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  35194. if (v < bounds[i]) {
  35195. break;
  35196. }
  35197. }
  35198. var dmin = domain[0];
  35199. if (i > 0) {
  35200. dmin = bounds[i - 1];
  35201. }
  35202. var dmax = domain[1];
  35203. if (i < bounds.length) {
  35204. dmax = bounds[i];
  35205. }
  35206. var rmin = encode[2 * i];
  35207. var rmax = encode[2 * i + 1];
  35208. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  35209. fns[i](tmpBuf, 0, dest, destOffset);
  35210. };
  35211. },
  35212. constructPostScript({
  35213. xref,
  35214. isEvalSupported,
  35215. fn,
  35216. dict
  35217. }) {
  35218. var domain = toNumberArray(dict.getArray("Domain"));
  35219. var range = toNumberArray(dict.getArray("Range"));
  35220. if (!domain) {
  35221. throw new _util.FormatError("No domain.");
  35222. }
  35223. if (!range) {
  35224. throw new _util.FormatError("No range.");
  35225. }
  35226. var lexer = new _ps_parser.PostScriptLexer(fn);
  35227. var parser = new _ps_parser.PostScriptParser(lexer);
  35228. var code = parser.parse();
  35229. return [CONSTRUCT_POSTSCRIPT, domain, range, code];
  35230. },
  35231. constructPostScriptFromIR({
  35232. xref,
  35233. isEvalSupported,
  35234. IR
  35235. }) {
  35236. var domain = IR[1];
  35237. var range = IR[2];
  35238. var code = IR[3];
  35239. if (isEvalSupported && _util.IsEvalSupportedCached.value) {
  35240. const compiled = new PostScriptCompiler().compile(code, domain, range);
  35241. if (compiled) {
  35242. return new Function("src", "srcOffset", "dest", "destOffset", compiled);
  35243. }
  35244. }
  35245. (0, _util.info)("Unable to compile PS function");
  35246. var numOutputs = range.length >> 1;
  35247. var numInputs = domain.length >> 1;
  35248. var evaluator = new PostScriptEvaluator(code);
  35249. var cache = Object.create(null);
  35250. var MAX_CACHE_SIZE = 2048 * 4;
  35251. var cache_available = MAX_CACHE_SIZE;
  35252. var tmpBuf = new Float32Array(numInputs);
  35253. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  35254. var i, value;
  35255. var key = "";
  35256. var input = tmpBuf;
  35257. for (i = 0; i < numInputs; i++) {
  35258. value = src[srcOffset + i];
  35259. input[i] = value;
  35260. key += value + "_";
  35261. }
  35262. var cachedValue = cache[key];
  35263. if (cachedValue !== undefined) {
  35264. dest.set(cachedValue, destOffset);
  35265. return;
  35266. }
  35267. var output = new Float32Array(numOutputs);
  35268. var stack = evaluator.execute(input);
  35269. var stackIndex = stack.length - numOutputs;
  35270. for (i = 0; i < numOutputs; i++) {
  35271. value = stack[stackIndex + i];
  35272. var bound = range[i * 2];
  35273. if (value < bound) {
  35274. value = bound;
  35275. } else {
  35276. bound = range[i * 2 + 1];
  35277. if (value > bound) {
  35278. value = bound;
  35279. }
  35280. }
  35281. output[i] = value;
  35282. }
  35283. if (cache_available > 0) {
  35284. cache_available--;
  35285. cache[key] = output;
  35286. }
  35287. dest.set(output, destOffset);
  35288. };
  35289. }
  35290. };
  35291. }();
  35292. function isPDFFunction(v) {
  35293. var fnDict;
  35294. if (typeof v !== "object") {
  35295. return false;
  35296. } else if ((0, _primitives.isDict)(v)) {
  35297. fnDict = v;
  35298. } else if ((0, _primitives.isStream)(v)) {
  35299. fnDict = v.dict;
  35300. } else {
  35301. return false;
  35302. }
  35303. return fnDict.has("FunctionType");
  35304. }
  35305. var PostScriptStack = function PostScriptStackClosure() {
  35306. var MAX_STACK_SIZE = 100;
  35307. function PostScriptStack(initialStack) {
  35308. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  35309. }
  35310. PostScriptStack.prototype = {
  35311. push: function PostScriptStack_push(value) {
  35312. if (this.stack.length >= MAX_STACK_SIZE) {
  35313. throw new Error("PostScript function stack overflow.");
  35314. }
  35315. this.stack.push(value);
  35316. },
  35317. pop: function PostScriptStack_pop() {
  35318. if (this.stack.length <= 0) {
  35319. throw new Error("PostScript function stack underflow.");
  35320. }
  35321. return this.stack.pop();
  35322. },
  35323. copy: function PostScriptStack_copy(n) {
  35324. if (this.stack.length + n >= MAX_STACK_SIZE) {
  35325. throw new Error("PostScript function stack overflow.");
  35326. }
  35327. var stack = this.stack;
  35328. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  35329. stack.push(stack[i]);
  35330. }
  35331. },
  35332. index: function PostScriptStack_index(n) {
  35333. this.push(this.stack[this.stack.length - n - 1]);
  35334. },
  35335. roll: function PostScriptStack_roll(n, p) {
  35336. var stack = this.stack;
  35337. var l = stack.length - n;
  35338. var r = stack.length - 1,
  35339. c = l + (p - Math.floor(p / n) * n),
  35340. i,
  35341. j,
  35342. t;
  35343. for (i = l, j = r; i < j; i++, j--) {
  35344. t = stack[i];
  35345. stack[i] = stack[j];
  35346. stack[j] = t;
  35347. }
  35348. for (i = l, j = c - 1; i < j; i++, j--) {
  35349. t = stack[i];
  35350. stack[i] = stack[j];
  35351. stack[j] = t;
  35352. }
  35353. for (i = c, j = r; i < j; i++, j--) {
  35354. t = stack[i];
  35355. stack[i] = stack[j];
  35356. stack[j] = t;
  35357. }
  35358. }
  35359. };
  35360. return PostScriptStack;
  35361. }();
  35362. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  35363. function PostScriptEvaluator(operators) {
  35364. this.operators = operators;
  35365. }
  35366. PostScriptEvaluator.prototype = {
  35367. execute: function PostScriptEvaluator_execute(initialStack) {
  35368. var stack = new PostScriptStack(initialStack);
  35369. var counter = 0;
  35370. var operators = this.operators;
  35371. var length = operators.length;
  35372. var operator, a, b;
  35373. while (counter < length) {
  35374. operator = operators[counter++];
  35375. if (typeof operator === "number") {
  35376. stack.push(operator);
  35377. continue;
  35378. }
  35379. switch (operator) {
  35380. case "jz":
  35381. b = stack.pop();
  35382. a = stack.pop();
  35383. if (!a) {
  35384. counter = b;
  35385. }
  35386. break;
  35387. case "j":
  35388. a = stack.pop();
  35389. counter = a;
  35390. break;
  35391. case "abs":
  35392. a = stack.pop();
  35393. stack.push(Math.abs(a));
  35394. break;
  35395. case "add":
  35396. b = stack.pop();
  35397. a = stack.pop();
  35398. stack.push(a + b);
  35399. break;
  35400. case "and":
  35401. b = stack.pop();
  35402. a = stack.pop();
  35403. if ((0, _util.isBool)(a) && (0, _util.isBool)(b)) {
  35404. stack.push(a && b);
  35405. } else {
  35406. stack.push(a & b);
  35407. }
  35408. break;
  35409. case "atan":
  35410. a = stack.pop();
  35411. stack.push(Math.atan(a));
  35412. break;
  35413. case "bitshift":
  35414. b = stack.pop();
  35415. a = stack.pop();
  35416. if (a > 0) {
  35417. stack.push(a << b);
  35418. } else {
  35419. stack.push(a >> b);
  35420. }
  35421. break;
  35422. case "ceiling":
  35423. a = stack.pop();
  35424. stack.push(Math.ceil(a));
  35425. break;
  35426. case "copy":
  35427. a = stack.pop();
  35428. stack.copy(a);
  35429. break;
  35430. case "cos":
  35431. a = stack.pop();
  35432. stack.push(Math.cos(a));
  35433. break;
  35434. case "cvi":
  35435. a = stack.pop() | 0;
  35436. stack.push(a);
  35437. break;
  35438. case "cvr":
  35439. break;
  35440. case "div":
  35441. b = stack.pop();
  35442. a = stack.pop();
  35443. stack.push(a / b);
  35444. break;
  35445. case "dup":
  35446. stack.copy(1);
  35447. break;
  35448. case "eq":
  35449. b = stack.pop();
  35450. a = stack.pop();
  35451. stack.push(a === b);
  35452. break;
  35453. case "exch":
  35454. stack.roll(2, 1);
  35455. break;
  35456. case "exp":
  35457. b = stack.pop();
  35458. a = stack.pop();
  35459. stack.push(a ** b);
  35460. break;
  35461. case "false":
  35462. stack.push(false);
  35463. break;
  35464. case "floor":
  35465. a = stack.pop();
  35466. stack.push(Math.floor(a));
  35467. break;
  35468. case "ge":
  35469. b = stack.pop();
  35470. a = stack.pop();
  35471. stack.push(a >= b);
  35472. break;
  35473. case "gt":
  35474. b = stack.pop();
  35475. a = stack.pop();
  35476. stack.push(a > b);
  35477. break;
  35478. case "idiv":
  35479. b = stack.pop();
  35480. a = stack.pop();
  35481. stack.push(a / b | 0);
  35482. break;
  35483. case "index":
  35484. a = stack.pop();
  35485. stack.index(a);
  35486. break;
  35487. case "le":
  35488. b = stack.pop();
  35489. a = stack.pop();
  35490. stack.push(a <= b);
  35491. break;
  35492. case "ln":
  35493. a = stack.pop();
  35494. stack.push(Math.log(a));
  35495. break;
  35496. case "log":
  35497. a = stack.pop();
  35498. stack.push(Math.log(a) / Math.LN10);
  35499. break;
  35500. case "lt":
  35501. b = stack.pop();
  35502. a = stack.pop();
  35503. stack.push(a < b);
  35504. break;
  35505. case "mod":
  35506. b = stack.pop();
  35507. a = stack.pop();
  35508. stack.push(a % b);
  35509. break;
  35510. case "mul":
  35511. b = stack.pop();
  35512. a = stack.pop();
  35513. stack.push(a * b);
  35514. break;
  35515. case "ne":
  35516. b = stack.pop();
  35517. a = stack.pop();
  35518. stack.push(a !== b);
  35519. break;
  35520. case "neg":
  35521. a = stack.pop();
  35522. stack.push(-a);
  35523. break;
  35524. case "not":
  35525. a = stack.pop();
  35526. if ((0, _util.isBool)(a)) {
  35527. stack.push(!a);
  35528. } else {
  35529. stack.push(~a);
  35530. }
  35531. break;
  35532. case "or":
  35533. b = stack.pop();
  35534. a = stack.pop();
  35535. if ((0, _util.isBool)(a) && (0, _util.isBool)(b)) {
  35536. stack.push(a || b);
  35537. } else {
  35538. stack.push(a | b);
  35539. }
  35540. break;
  35541. case "pop":
  35542. stack.pop();
  35543. break;
  35544. case "roll":
  35545. b = stack.pop();
  35546. a = stack.pop();
  35547. stack.roll(a, b);
  35548. break;
  35549. case "round":
  35550. a = stack.pop();
  35551. stack.push(Math.round(a));
  35552. break;
  35553. case "sin":
  35554. a = stack.pop();
  35555. stack.push(Math.sin(a));
  35556. break;
  35557. case "sqrt":
  35558. a = stack.pop();
  35559. stack.push(Math.sqrt(a));
  35560. break;
  35561. case "sub":
  35562. b = stack.pop();
  35563. a = stack.pop();
  35564. stack.push(a - b);
  35565. break;
  35566. case "true":
  35567. stack.push(true);
  35568. break;
  35569. case "truncate":
  35570. a = stack.pop();
  35571. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  35572. stack.push(a);
  35573. break;
  35574. case "xor":
  35575. b = stack.pop();
  35576. a = stack.pop();
  35577. if ((0, _util.isBool)(a) && (0, _util.isBool)(b)) {
  35578. stack.push(a !== b);
  35579. } else {
  35580. stack.push(a ^ b);
  35581. }
  35582. break;
  35583. default:
  35584. throw new _util.FormatError(`Unknown operator ${operator}`);
  35585. }
  35586. }
  35587. return stack.stack;
  35588. }
  35589. };
  35590. return PostScriptEvaluator;
  35591. }();
  35592. exports.PostScriptEvaluator = PostScriptEvaluator;
  35593. var PostScriptCompiler = function PostScriptCompilerClosure() {
  35594. function AstNode(type) {
  35595. this.type = type;
  35596. }
  35597. AstNode.prototype.visit = function (visitor) {
  35598. (0, _util.unreachable)("abstract method");
  35599. };
  35600. function AstArgument(index, min, max) {
  35601. AstNode.call(this, "args");
  35602. this.index = index;
  35603. this.min = min;
  35604. this.max = max;
  35605. }
  35606. AstArgument.prototype = Object.create(AstNode.prototype);
  35607. AstArgument.prototype.visit = function (visitor) {
  35608. visitor.visitArgument(this);
  35609. };
  35610. function AstLiteral(number) {
  35611. AstNode.call(this, "literal");
  35612. this.number = number;
  35613. this.min = number;
  35614. this.max = number;
  35615. }
  35616. AstLiteral.prototype = Object.create(AstNode.prototype);
  35617. AstLiteral.prototype.visit = function (visitor) {
  35618. visitor.visitLiteral(this);
  35619. };
  35620. function AstBinaryOperation(op, arg1, arg2, min, max) {
  35621. AstNode.call(this, "binary");
  35622. this.op = op;
  35623. this.arg1 = arg1;
  35624. this.arg2 = arg2;
  35625. this.min = min;
  35626. this.max = max;
  35627. }
  35628. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  35629. AstBinaryOperation.prototype.visit = function (visitor) {
  35630. visitor.visitBinaryOperation(this);
  35631. };
  35632. function AstMin(arg, max) {
  35633. AstNode.call(this, "max");
  35634. this.arg = arg;
  35635. this.min = arg.min;
  35636. this.max = max;
  35637. }
  35638. AstMin.prototype = Object.create(AstNode.prototype);
  35639. AstMin.prototype.visit = function (visitor) {
  35640. visitor.visitMin(this);
  35641. };
  35642. function AstVariable(index, min, max) {
  35643. AstNode.call(this, "var");
  35644. this.index = index;
  35645. this.min = min;
  35646. this.max = max;
  35647. }
  35648. AstVariable.prototype = Object.create(AstNode.prototype);
  35649. AstVariable.prototype.visit = function (visitor) {
  35650. visitor.visitVariable(this);
  35651. };
  35652. function AstVariableDefinition(variable, arg) {
  35653. AstNode.call(this, "definition");
  35654. this.variable = variable;
  35655. this.arg = arg;
  35656. }
  35657. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  35658. AstVariableDefinition.prototype.visit = function (visitor) {
  35659. visitor.visitVariableDefinition(this);
  35660. };
  35661. function ExpressionBuilderVisitor() {
  35662. this.parts = [];
  35663. }
  35664. ExpressionBuilderVisitor.prototype = {
  35665. visitArgument(arg) {
  35666. this.parts.push("Math.max(", arg.min, ", Math.min(", arg.max, ", src[srcOffset + ", arg.index, "]))");
  35667. },
  35668. visitVariable(variable) {
  35669. this.parts.push("v", variable.index);
  35670. },
  35671. visitLiteral(literal) {
  35672. this.parts.push(literal.number);
  35673. },
  35674. visitBinaryOperation(operation) {
  35675. this.parts.push("(");
  35676. operation.arg1.visit(this);
  35677. this.parts.push(" ", operation.op, " ");
  35678. operation.arg2.visit(this);
  35679. this.parts.push(")");
  35680. },
  35681. visitVariableDefinition(definition) {
  35682. this.parts.push("var ");
  35683. definition.variable.visit(this);
  35684. this.parts.push(" = ");
  35685. definition.arg.visit(this);
  35686. this.parts.push(";");
  35687. },
  35688. visitMin(max) {
  35689. this.parts.push("Math.min(");
  35690. max.arg.visit(this);
  35691. this.parts.push(", ", max.max, ")");
  35692. },
  35693. toString() {
  35694. return this.parts.join("");
  35695. }
  35696. };
  35697. function buildAddOperation(num1, num2) {
  35698. if (num2.type === "literal" && num2.number === 0) {
  35699. return num1;
  35700. }
  35701. if (num1.type === "literal" && num1.number === 0) {
  35702. return num2;
  35703. }
  35704. if (num2.type === "literal" && num1.type === "literal") {
  35705. return new AstLiteral(num1.number + num2.number);
  35706. }
  35707. return new AstBinaryOperation("+", num1, num2, num1.min + num2.min, num1.max + num2.max);
  35708. }
  35709. function buildMulOperation(num1, num2) {
  35710. if (num2.type === "literal") {
  35711. if (num2.number === 0) {
  35712. return new AstLiteral(0);
  35713. } else if (num2.number === 1) {
  35714. return num1;
  35715. } else if (num1.type === "literal") {
  35716. return new AstLiteral(num1.number * num2.number);
  35717. }
  35718. }
  35719. if (num1.type === "literal") {
  35720. if (num1.number === 0) {
  35721. return new AstLiteral(0);
  35722. } else if (num1.number === 1) {
  35723. return num2;
  35724. }
  35725. }
  35726. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  35727. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  35728. return new AstBinaryOperation("*", num1, num2, min, max);
  35729. }
  35730. function buildSubOperation(num1, num2) {
  35731. if (num2.type === "literal") {
  35732. if (num2.number === 0) {
  35733. return num1;
  35734. } else if (num1.type === "literal") {
  35735. return new AstLiteral(num1.number - num2.number);
  35736. }
  35737. }
  35738. if (num2.type === "binary" && num2.op === "-" && num1.type === "literal" && num1.number === 1 && num2.arg1.type === "literal" && num2.arg1.number === 1) {
  35739. return num2.arg2;
  35740. }
  35741. return new AstBinaryOperation("-", num1, num2, num1.min - num2.max, num1.max - num2.min);
  35742. }
  35743. function buildMinOperation(num1, max) {
  35744. if (num1.min >= max) {
  35745. return new AstLiteral(max);
  35746. } else if (num1.max <= max) {
  35747. return num1;
  35748. }
  35749. return new AstMin(num1, max);
  35750. }
  35751. function PostScriptCompiler() {}
  35752. PostScriptCompiler.prototype = {
  35753. compile: function PostScriptCompiler_compile(code, domain, range) {
  35754. var stack = [];
  35755. var instructions = [];
  35756. var inputSize = domain.length >> 1,
  35757. outputSize = range.length >> 1;
  35758. var lastRegister = 0;
  35759. var n, j;
  35760. var num1, num2, ast1, ast2, tmpVar, item;
  35761. for (let i = 0; i < inputSize; i++) {
  35762. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  35763. }
  35764. for (let i = 0, ii = code.length; i < ii; i++) {
  35765. item = code[i];
  35766. if (typeof item === "number") {
  35767. stack.push(new AstLiteral(item));
  35768. continue;
  35769. }
  35770. switch (item) {
  35771. case "add":
  35772. if (stack.length < 2) {
  35773. return null;
  35774. }
  35775. num2 = stack.pop();
  35776. num1 = stack.pop();
  35777. stack.push(buildAddOperation(num1, num2));
  35778. break;
  35779. case "cvr":
  35780. if (stack.length < 1) {
  35781. return null;
  35782. }
  35783. break;
  35784. case "mul":
  35785. if (stack.length < 2) {
  35786. return null;
  35787. }
  35788. num2 = stack.pop();
  35789. num1 = stack.pop();
  35790. stack.push(buildMulOperation(num1, num2));
  35791. break;
  35792. case "sub":
  35793. if (stack.length < 2) {
  35794. return null;
  35795. }
  35796. num2 = stack.pop();
  35797. num1 = stack.pop();
  35798. stack.push(buildSubOperation(num1, num2));
  35799. break;
  35800. case "exch":
  35801. if (stack.length < 2) {
  35802. return null;
  35803. }
  35804. ast1 = stack.pop();
  35805. ast2 = stack.pop();
  35806. stack.push(ast1, ast2);
  35807. break;
  35808. case "pop":
  35809. if (stack.length < 1) {
  35810. return null;
  35811. }
  35812. stack.pop();
  35813. break;
  35814. case "index":
  35815. if (stack.length < 1) {
  35816. return null;
  35817. }
  35818. num1 = stack.pop();
  35819. if (num1.type !== "literal") {
  35820. return null;
  35821. }
  35822. n = num1.number;
  35823. if (n < 0 || !Number.isInteger(n) || stack.length < n) {
  35824. return null;
  35825. }
  35826. ast1 = stack[stack.length - n - 1];
  35827. if (ast1.type === "literal" || ast1.type === "var") {
  35828. stack.push(ast1);
  35829. break;
  35830. }
  35831. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  35832. stack[stack.length - n - 1] = tmpVar;
  35833. stack.push(tmpVar);
  35834. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  35835. break;
  35836. case "dup":
  35837. if (stack.length < 1) {
  35838. return null;
  35839. }
  35840. if (typeof code[i + 1] === "number" && code[i + 2] === "gt" && code[i + 3] === i + 7 && code[i + 4] === "jz" && code[i + 5] === "pop" && code[i + 6] === code[i + 1]) {
  35841. num1 = stack.pop();
  35842. stack.push(buildMinOperation(num1, code[i + 1]));
  35843. i += 6;
  35844. break;
  35845. }
  35846. ast1 = stack[stack.length - 1];
  35847. if (ast1.type === "literal" || ast1.type === "var") {
  35848. stack.push(ast1);
  35849. break;
  35850. }
  35851. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  35852. stack[stack.length - 1] = tmpVar;
  35853. stack.push(tmpVar);
  35854. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  35855. break;
  35856. case "roll":
  35857. if (stack.length < 2) {
  35858. return null;
  35859. }
  35860. num2 = stack.pop();
  35861. num1 = stack.pop();
  35862. if (num2.type !== "literal" || num1.type !== "literal") {
  35863. return null;
  35864. }
  35865. j = num2.number;
  35866. n = num1.number;
  35867. if (n <= 0 || !Number.isInteger(n) || !Number.isInteger(j) || stack.length < n) {
  35868. return null;
  35869. }
  35870. j = (j % n + n) % n;
  35871. if (j === 0) {
  35872. break;
  35873. }
  35874. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  35875. break;
  35876. default:
  35877. return null;
  35878. }
  35879. }
  35880. if (stack.length !== outputSize) {
  35881. return null;
  35882. }
  35883. var result = [];
  35884. instructions.forEach(function (instruction) {
  35885. var statementBuilder = new ExpressionBuilderVisitor();
  35886. instruction.visit(statementBuilder);
  35887. result.push(statementBuilder.toString());
  35888. });
  35889. stack.forEach(function (expr, i) {
  35890. var statementBuilder = new ExpressionBuilderVisitor();
  35891. expr.visit(statementBuilder);
  35892. var min = range[i * 2],
  35893. max = range[i * 2 + 1];
  35894. var out = [statementBuilder.toString()];
  35895. if (min > expr.min) {
  35896. out.unshift("Math.max(", min, ", ");
  35897. out.push(")");
  35898. }
  35899. if (max < expr.max) {
  35900. out.unshift("Math.min(", max, ", ");
  35901. out.push(")");
  35902. }
  35903. out.unshift("dest[destOffset + ", i, "] = ");
  35904. out.push(";");
  35905. result.push(out.join(""));
  35906. });
  35907. return result.join("\n");
  35908. }
  35909. };
  35910. return PostScriptCompiler;
  35911. }();
  35912. exports.PostScriptCompiler = PostScriptCompiler;
  35913. /***/ }),
  35914. /* 41 */
  35915. /***/ (function(module, exports, __w_pdfjs_require__) {
  35916. "use strict";
  35917. Object.defineProperty(exports, "__esModule", {
  35918. value: true
  35919. });
  35920. exports.PostScriptParser = exports.PostScriptLexer = void 0;
  35921. var _util = __w_pdfjs_require__(2);
  35922. var _primitives = __w_pdfjs_require__(5);
  35923. var _core_utils = __w_pdfjs_require__(8);
  35924. class PostScriptParser {
  35925. constructor(lexer) {
  35926. this.lexer = lexer;
  35927. this.operators = [];
  35928. this.token = null;
  35929. this.prev = null;
  35930. }
  35931. nextToken() {
  35932. this.prev = this.token;
  35933. this.token = this.lexer.getToken();
  35934. }
  35935. accept(type) {
  35936. if (this.token.type === type) {
  35937. this.nextToken();
  35938. return true;
  35939. }
  35940. return false;
  35941. }
  35942. expect(type) {
  35943. if (this.accept(type)) {
  35944. return true;
  35945. }
  35946. throw new _util.FormatError(`Unexpected symbol: found ${this.token.type} expected ${type}.`);
  35947. }
  35948. parse() {
  35949. this.nextToken();
  35950. this.expect(PostScriptTokenTypes.LBRACE);
  35951. this.parseBlock();
  35952. this.expect(PostScriptTokenTypes.RBRACE);
  35953. return this.operators;
  35954. }
  35955. parseBlock() {
  35956. while (true) {
  35957. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  35958. this.operators.push(this.prev.value);
  35959. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  35960. this.operators.push(this.prev.value);
  35961. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  35962. this.parseCondition();
  35963. } else {
  35964. return;
  35965. }
  35966. }
  35967. }
  35968. parseCondition() {
  35969. const conditionLocation = this.operators.length;
  35970. this.operators.push(null, null);
  35971. this.parseBlock();
  35972. this.expect(PostScriptTokenTypes.RBRACE);
  35973. if (this.accept(PostScriptTokenTypes.IF)) {
  35974. this.operators[conditionLocation] = this.operators.length;
  35975. this.operators[conditionLocation + 1] = "jz";
  35976. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  35977. const jumpLocation = this.operators.length;
  35978. this.operators.push(null, null);
  35979. const endOfTrue = this.operators.length;
  35980. this.parseBlock();
  35981. this.expect(PostScriptTokenTypes.RBRACE);
  35982. this.expect(PostScriptTokenTypes.IFELSE);
  35983. this.operators[jumpLocation] = this.operators.length;
  35984. this.operators[jumpLocation + 1] = "j";
  35985. this.operators[conditionLocation] = endOfTrue;
  35986. this.operators[conditionLocation + 1] = "jz";
  35987. } else {
  35988. throw new _util.FormatError("PS Function: error parsing conditional.");
  35989. }
  35990. }
  35991. }
  35992. exports.PostScriptParser = PostScriptParser;
  35993. const PostScriptTokenTypes = {
  35994. LBRACE: 0,
  35995. RBRACE: 1,
  35996. NUMBER: 2,
  35997. OPERATOR: 3,
  35998. IF: 4,
  35999. IFELSE: 5
  36000. };
  36001. const PostScriptToken = function PostScriptTokenClosure() {
  36002. const opCache = Object.create(null);
  36003. class PostScriptToken {
  36004. constructor(type, value) {
  36005. this.type = type;
  36006. this.value = value;
  36007. }
  36008. static getOperator(op) {
  36009. const opValue = opCache[op];
  36010. if (opValue) {
  36011. return opValue;
  36012. }
  36013. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  36014. }
  36015. static get LBRACE() {
  36016. return (0, _util.shadow)(this, "LBRACE", new PostScriptToken(PostScriptTokenTypes.LBRACE, "{"));
  36017. }
  36018. static get RBRACE() {
  36019. return (0, _util.shadow)(this, "RBRACE", new PostScriptToken(PostScriptTokenTypes.RBRACE, "}"));
  36020. }
  36021. static get IF() {
  36022. return (0, _util.shadow)(this, "IF", new PostScriptToken(PostScriptTokenTypes.IF, "IF"));
  36023. }
  36024. static get IFELSE() {
  36025. return (0, _util.shadow)(this, "IFELSE", new PostScriptToken(PostScriptTokenTypes.IFELSE, "IFELSE"));
  36026. }
  36027. }
  36028. return PostScriptToken;
  36029. }();
  36030. class PostScriptLexer {
  36031. constructor(stream) {
  36032. this.stream = stream;
  36033. this.nextChar();
  36034. this.strBuf = [];
  36035. }
  36036. nextChar() {
  36037. return this.currentChar = this.stream.getByte();
  36038. }
  36039. getToken() {
  36040. let comment = false;
  36041. let ch = this.currentChar;
  36042. while (true) {
  36043. if (ch < 0) {
  36044. return _primitives.EOF;
  36045. }
  36046. if (comment) {
  36047. if (ch === 0x0a || ch === 0x0d) {
  36048. comment = false;
  36049. }
  36050. } else if (ch === 0x25) {
  36051. comment = true;
  36052. } else if (!(0, _core_utils.isWhiteSpace)(ch)) {
  36053. break;
  36054. }
  36055. ch = this.nextChar();
  36056. }
  36057. switch (ch | 0) {
  36058. case 0x30:
  36059. case 0x31:
  36060. case 0x32:
  36061. case 0x33:
  36062. case 0x34:
  36063. case 0x35:
  36064. case 0x36:
  36065. case 0x37:
  36066. case 0x38:
  36067. case 0x39:
  36068. case 0x2b:
  36069. case 0x2d:
  36070. case 0x2e:
  36071. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  36072. case 0x7b:
  36073. this.nextChar();
  36074. return PostScriptToken.LBRACE;
  36075. case 0x7d:
  36076. this.nextChar();
  36077. return PostScriptToken.RBRACE;
  36078. }
  36079. const strBuf = this.strBuf;
  36080. strBuf.length = 0;
  36081. strBuf[0] = String.fromCharCode(ch);
  36082. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5a || ch >= 0x61 && ch <= 0x7a)) {
  36083. strBuf.push(String.fromCharCode(ch));
  36084. }
  36085. const str = strBuf.join("");
  36086. switch (str.toLowerCase()) {
  36087. case "if":
  36088. return PostScriptToken.IF;
  36089. case "ifelse":
  36090. return PostScriptToken.IFELSE;
  36091. default:
  36092. return PostScriptToken.getOperator(str);
  36093. }
  36094. }
  36095. getNumber() {
  36096. let ch = this.currentChar;
  36097. const strBuf = this.strBuf;
  36098. strBuf.length = 0;
  36099. strBuf[0] = String.fromCharCode(ch);
  36100. while ((ch = this.nextChar()) >= 0) {
  36101. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2d || ch === 0x2e) {
  36102. strBuf.push(String.fromCharCode(ch));
  36103. } else {
  36104. break;
  36105. }
  36106. }
  36107. const value = parseFloat(strBuf.join(""));
  36108. if (isNaN(value)) {
  36109. throw new _util.FormatError(`Invalid floating point number: ${value}`);
  36110. }
  36111. return value;
  36112. }
  36113. }
  36114. exports.PostScriptLexer = PostScriptLexer;
  36115. /***/ }),
  36116. /* 42 */
  36117. /***/ (function(module, exports, __w_pdfjs_require__) {
  36118. "use strict";
  36119. Object.defineProperty(exports, "__esModule", {
  36120. value: true
  36121. });
  36122. exports.bidi = bidi;
  36123. var _util = __w_pdfjs_require__(2);
  36124. var baseTypes = ["BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "S", "B", "S", "WS", "B", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "B", "B", "B", "S", "WS", "ON", "ON", "ET", "ET", "ET", "ON", "ON", "ON", "ON", "ON", "ES", "CS", "ES", "CS", "CS", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "CS", "ON", "ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "ON", "ON", "ON", "BN", "BN", "BN", "BN", "BN", "BN", "B", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "CS", "ON", "ET", "ET", "ET", "ET", "ON", "ON", "ON", "ON", "L", "ON", "ON", "BN", "ON", "ON", "ET", "ET", "EN", "EN", "ON", "L", "ON", "ON", "ON", "EN", "L", "ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "L", "L", "L", "L", "L", "L", "L", "L"];
  36125. var arabicTypes = ["AN", "AN", "AN", "AN", "AN", "AN", "ON", "ON", "AL", "ET", "ET", "AL", "CS", "AL", "ON", "ON", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "ET", "AN", "AN", "AL", "AL", "AL", "NSM", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AN", "ON", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "NSM", "NSM", "ON", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "AL", "AL", "AL", "AL", "AL", "AL"];
  36126. function isOdd(i) {
  36127. return (i & 1) !== 0;
  36128. }
  36129. function isEven(i) {
  36130. return (i & 1) === 0;
  36131. }
  36132. function findUnequal(arr, start, value) {
  36133. for (var j = start, jj = arr.length; j < jj; ++j) {
  36134. if (arr[j] !== value) {
  36135. return j;
  36136. }
  36137. }
  36138. return j;
  36139. }
  36140. function setValues(arr, start, end, value) {
  36141. for (var j = start; j < end; ++j) {
  36142. arr[j] = value;
  36143. }
  36144. }
  36145. function reverseValues(arr, start, end) {
  36146. for (var i = start, j = end - 1; i < j; ++i, --j) {
  36147. var temp = arr[i];
  36148. arr[i] = arr[j];
  36149. arr[j] = temp;
  36150. }
  36151. }
  36152. function createBidiText(str, isLTR, vertical = false) {
  36153. let dir = "ltr";
  36154. if (vertical) {
  36155. dir = "ttb";
  36156. } else if (!isLTR) {
  36157. dir = "rtl";
  36158. }
  36159. return {
  36160. str,
  36161. dir
  36162. };
  36163. }
  36164. var chars = [];
  36165. var types = [];
  36166. function bidi(str, startLevel, vertical) {
  36167. var isLTR = true;
  36168. var strLength = str.length;
  36169. if (strLength === 0 || vertical) {
  36170. return createBidiText(str, isLTR, vertical);
  36171. }
  36172. chars.length = strLength;
  36173. types.length = strLength;
  36174. var numBidi = 0;
  36175. var i, ii;
  36176. for (i = 0; i < strLength; ++i) {
  36177. chars[i] = str.charAt(i);
  36178. var charCode = str.charCodeAt(i);
  36179. var charType = "L";
  36180. if (charCode <= 0x00ff) {
  36181. charType = baseTypes[charCode];
  36182. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  36183. charType = "R";
  36184. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  36185. charType = arabicTypes[charCode & 0xff];
  36186. if (!charType) {
  36187. (0, _util.warn)("Bidi: invalid Unicode character " + charCode.toString(16));
  36188. }
  36189. } else if (0x0700 <= charCode && charCode <= 0x08ac) {
  36190. charType = "AL";
  36191. }
  36192. if (charType === "R" || charType === "AL" || charType === "AN") {
  36193. numBidi++;
  36194. }
  36195. types[i] = charType;
  36196. }
  36197. if (numBidi === 0) {
  36198. isLTR = true;
  36199. return createBidiText(str, isLTR);
  36200. }
  36201. if (startLevel === -1) {
  36202. if (numBidi / strLength < 0.3) {
  36203. isLTR = true;
  36204. startLevel = 0;
  36205. } else {
  36206. isLTR = false;
  36207. startLevel = 1;
  36208. }
  36209. }
  36210. var levels = [];
  36211. for (i = 0; i < strLength; ++i) {
  36212. levels[i] = startLevel;
  36213. }
  36214. var e = isOdd(startLevel) ? "R" : "L";
  36215. var sor = e;
  36216. var eor = sor;
  36217. var lastType = sor;
  36218. for (i = 0; i < strLength; ++i) {
  36219. if (types[i] === "NSM") {
  36220. types[i] = lastType;
  36221. } else {
  36222. lastType = types[i];
  36223. }
  36224. }
  36225. lastType = sor;
  36226. var t;
  36227. for (i = 0; i < strLength; ++i) {
  36228. t = types[i];
  36229. if (t === "EN") {
  36230. types[i] = lastType === "AL" ? "AN" : "EN";
  36231. } else if (t === "R" || t === "L" || t === "AL") {
  36232. lastType = t;
  36233. }
  36234. }
  36235. for (i = 0; i < strLength; ++i) {
  36236. t = types[i];
  36237. if (t === "AL") {
  36238. types[i] = "R";
  36239. }
  36240. }
  36241. for (i = 1; i < strLength - 1; ++i) {
  36242. if (types[i] === "ES" && types[i - 1] === "EN" && types[i + 1] === "EN") {
  36243. types[i] = "EN";
  36244. }
  36245. if (types[i] === "CS" && (types[i - 1] === "EN" || types[i - 1] === "AN") && types[i + 1] === types[i - 1]) {
  36246. types[i] = types[i - 1];
  36247. }
  36248. }
  36249. for (i = 0; i < strLength; ++i) {
  36250. if (types[i] === "EN") {
  36251. var j;
  36252. for (j = i - 1; j >= 0; --j) {
  36253. if (types[j] !== "ET") {
  36254. break;
  36255. }
  36256. types[j] = "EN";
  36257. }
  36258. for (j = i + 1; j < strLength; ++j) {
  36259. if (types[j] !== "ET") {
  36260. break;
  36261. }
  36262. types[j] = "EN";
  36263. }
  36264. }
  36265. }
  36266. for (i = 0; i < strLength; ++i) {
  36267. t = types[i];
  36268. if (t === "WS" || t === "ES" || t === "ET" || t === "CS") {
  36269. types[i] = "ON";
  36270. }
  36271. }
  36272. lastType = sor;
  36273. for (i = 0; i < strLength; ++i) {
  36274. t = types[i];
  36275. if (t === "EN") {
  36276. types[i] = lastType === "L" ? "L" : "EN";
  36277. } else if (t === "R" || t === "L") {
  36278. lastType = t;
  36279. }
  36280. }
  36281. for (i = 0; i < strLength; ++i) {
  36282. if (types[i] === "ON") {
  36283. var end = findUnequal(types, i + 1, "ON");
  36284. var before = sor;
  36285. if (i > 0) {
  36286. before = types[i - 1];
  36287. }
  36288. var after = eor;
  36289. if (end + 1 < strLength) {
  36290. after = types[end + 1];
  36291. }
  36292. if (before !== "L") {
  36293. before = "R";
  36294. }
  36295. if (after !== "L") {
  36296. after = "R";
  36297. }
  36298. if (before === after) {
  36299. setValues(types, i, end, before);
  36300. }
  36301. i = end - 1;
  36302. }
  36303. }
  36304. for (i = 0; i < strLength; ++i) {
  36305. if (types[i] === "ON") {
  36306. types[i] = e;
  36307. }
  36308. }
  36309. for (i = 0; i < strLength; ++i) {
  36310. t = types[i];
  36311. if (isEven(levels[i])) {
  36312. if (t === "R") {
  36313. levels[i] += 1;
  36314. } else if (t === "AN" || t === "EN") {
  36315. levels[i] += 2;
  36316. }
  36317. } else {
  36318. if (t === "L" || t === "AN" || t === "EN") {
  36319. levels[i] += 1;
  36320. }
  36321. }
  36322. }
  36323. var highestLevel = -1;
  36324. var lowestOddLevel = 99;
  36325. var level;
  36326. for (i = 0, ii = levels.length; i < ii; ++i) {
  36327. level = levels[i];
  36328. if (highestLevel < level) {
  36329. highestLevel = level;
  36330. }
  36331. if (lowestOddLevel > level && isOdd(level)) {
  36332. lowestOddLevel = level;
  36333. }
  36334. }
  36335. for (level = highestLevel; level >= lowestOddLevel; --level) {
  36336. var start = -1;
  36337. for (i = 0, ii = levels.length; i < ii; ++i) {
  36338. if (levels[i] < level) {
  36339. if (start >= 0) {
  36340. reverseValues(chars, start, i);
  36341. start = -1;
  36342. }
  36343. } else if (start < 0) {
  36344. start = i;
  36345. }
  36346. }
  36347. if (start >= 0) {
  36348. reverseValues(chars, start, levels.length);
  36349. }
  36350. }
  36351. for (i = 0, ii = chars.length; i < ii; ++i) {
  36352. var ch = chars[i];
  36353. if (ch === "<" || ch === ">") {
  36354. chars[i] = "";
  36355. }
  36356. }
  36357. return createBidiText(chars.join(""), isLTR);
  36358. }
  36359. /***/ }),
  36360. /* 43 */
  36361. /***/ (function(module, exports, __w_pdfjs_require__) {
  36362. "use strict";
  36363. Object.defineProperty(exports, "__esModule", {
  36364. value: true
  36365. });
  36366. exports.getMetrics = void 0;
  36367. var _core_utils = __w_pdfjs_require__(8);
  36368. var getMetrics = (0, _core_utils.getLookupTableFactory)(function (t) {
  36369. t.Courier = 600;
  36370. t["Courier-Bold"] = 600;
  36371. t["Courier-BoldOblique"] = 600;
  36372. t["Courier-Oblique"] = 600;
  36373. t.Helvetica = (0, _core_utils.getLookupTableFactory)(function (t) {
  36374. t.space = 278;
  36375. t.exclam = 278;
  36376. t.quotedbl = 355;
  36377. t.numbersign = 556;
  36378. t.dollar = 556;
  36379. t.percent = 889;
  36380. t.ampersand = 667;
  36381. t.quoteright = 222;
  36382. t.parenleft = 333;
  36383. t.parenright = 333;
  36384. t.asterisk = 389;
  36385. t.plus = 584;
  36386. t.comma = 278;
  36387. t.hyphen = 333;
  36388. t.period = 278;
  36389. t.slash = 278;
  36390. t.zero = 556;
  36391. t.one = 556;
  36392. t.two = 556;
  36393. t.three = 556;
  36394. t.four = 556;
  36395. t.five = 556;
  36396. t.six = 556;
  36397. t.seven = 556;
  36398. t.eight = 556;
  36399. t.nine = 556;
  36400. t.colon = 278;
  36401. t.semicolon = 278;
  36402. t.less = 584;
  36403. t.equal = 584;
  36404. t.greater = 584;
  36405. t.question = 556;
  36406. t.at = 1015;
  36407. t.A = 667;
  36408. t.B = 667;
  36409. t.C = 722;
  36410. t.D = 722;
  36411. t.E = 667;
  36412. t.F = 611;
  36413. t.G = 778;
  36414. t.H = 722;
  36415. t.I = 278;
  36416. t.J = 500;
  36417. t.K = 667;
  36418. t.L = 556;
  36419. t.M = 833;
  36420. t.N = 722;
  36421. t.O = 778;
  36422. t.P = 667;
  36423. t.Q = 778;
  36424. t.R = 722;
  36425. t.S = 667;
  36426. t.T = 611;
  36427. t.U = 722;
  36428. t.V = 667;
  36429. t.W = 944;
  36430. t.X = 667;
  36431. t.Y = 667;
  36432. t.Z = 611;
  36433. t.bracketleft = 278;
  36434. t.backslash = 278;
  36435. t.bracketright = 278;
  36436. t.asciicircum = 469;
  36437. t.underscore = 556;
  36438. t.quoteleft = 222;
  36439. t.a = 556;
  36440. t.b = 556;
  36441. t.c = 500;
  36442. t.d = 556;
  36443. t.e = 556;
  36444. t.f = 278;
  36445. t.g = 556;
  36446. t.h = 556;
  36447. t.i = 222;
  36448. t.j = 222;
  36449. t.k = 500;
  36450. t.l = 222;
  36451. t.m = 833;
  36452. t.n = 556;
  36453. t.o = 556;
  36454. t.p = 556;
  36455. t.q = 556;
  36456. t.r = 333;
  36457. t.s = 500;
  36458. t.t = 278;
  36459. t.u = 556;
  36460. t.v = 500;
  36461. t.w = 722;
  36462. t.x = 500;
  36463. t.y = 500;
  36464. t.z = 500;
  36465. t.braceleft = 334;
  36466. t.bar = 260;
  36467. t.braceright = 334;
  36468. t.asciitilde = 584;
  36469. t.exclamdown = 333;
  36470. t.cent = 556;
  36471. t.sterling = 556;
  36472. t.fraction = 167;
  36473. t.yen = 556;
  36474. t.florin = 556;
  36475. t.section = 556;
  36476. t.currency = 556;
  36477. t.quotesingle = 191;
  36478. t.quotedblleft = 333;
  36479. t.guillemotleft = 556;
  36480. t.guilsinglleft = 333;
  36481. t.guilsinglright = 333;
  36482. t.fi = 500;
  36483. t.fl = 500;
  36484. t.endash = 556;
  36485. t.dagger = 556;
  36486. t.daggerdbl = 556;
  36487. t.periodcentered = 278;
  36488. t.paragraph = 537;
  36489. t.bullet = 350;
  36490. t.quotesinglbase = 222;
  36491. t.quotedblbase = 333;
  36492. t.quotedblright = 333;
  36493. t.guillemotright = 556;
  36494. t.ellipsis = 1000;
  36495. t.perthousand = 1000;
  36496. t.questiondown = 611;
  36497. t.grave = 333;
  36498. t.acute = 333;
  36499. t.circumflex = 333;
  36500. t.tilde = 333;
  36501. t.macron = 333;
  36502. t.breve = 333;
  36503. t.dotaccent = 333;
  36504. t.dieresis = 333;
  36505. t.ring = 333;
  36506. t.cedilla = 333;
  36507. t.hungarumlaut = 333;
  36508. t.ogonek = 333;
  36509. t.caron = 333;
  36510. t.emdash = 1000;
  36511. t.AE = 1000;
  36512. t.ordfeminine = 370;
  36513. t.Lslash = 556;
  36514. t.Oslash = 778;
  36515. t.OE = 1000;
  36516. t.ordmasculine = 365;
  36517. t.ae = 889;
  36518. t.dotlessi = 278;
  36519. t.lslash = 222;
  36520. t.oslash = 611;
  36521. t.oe = 944;
  36522. t.germandbls = 611;
  36523. t.Idieresis = 278;
  36524. t.eacute = 556;
  36525. t.abreve = 556;
  36526. t.uhungarumlaut = 556;
  36527. t.ecaron = 556;
  36528. t.Ydieresis = 667;
  36529. t.divide = 584;
  36530. t.Yacute = 667;
  36531. t.Acircumflex = 667;
  36532. t.aacute = 556;
  36533. t.Ucircumflex = 722;
  36534. t.yacute = 500;
  36535. t.scommaaccent = 500;
  36536. t.ecircumflex = 556;
  36537. t.Uring = 722;
  36538. t.Udieresis = 722;
  36539. t.aogonek = 556;
  36540. t.Uacute = 722;
  36541. t.uogonek = 556;
  36542. t.Edieresis = 667;
  36543. t.Dcroat = 722;
  36544. t.commaaccent = 250;
  36545. t.copyright = 737;
  36546. t.Emacron = 667;
  36547. t.ccaron = 500;
  36548. t.aring = 556;
  36549. t.Ncommaaccent = 722;
  36550. t.lacute = 222;
  36551. t.agrave = 556;
  36552. t.Tcommaaccent = 611;
  36553. t.Cacute = 722;
  36554. t.atilde = 556;
  36555. t.Edotaccent = 667;
  36556. t.scaron = 500;
  36557. t.scedilla = 500;
  36558. t.iacute = 278;
  36559. t.lozenge = 471;
  36560. t.Rcaron = 722;
  36561. t.Gcommaaccent = 778;
  36562. t.ucircumflex = 556;
  36563. t.acircumflex = 556;
  36564. t.Amacron = 667;
  36565. t.rcaron = 333;
  36566. t.ccedilla = 500;
  36567. t.Zdotaccent = 611;
  36568. t.Thorn = 667;
  36569. t.Omacron = 778;
  36570. t.Racute = 722;
  36571. t.Sacute = 667;
  36572. t.dcaron = 643;
  36573. t.Umacron = 722;
  36574. t.uring = 556;
  36575. t.threesuperior = 333;
  36576. t.Ograve = 778;
  36577. t.Agrave = 667;
  36578. t.Abreve = 667;
  36579. t.multiply = 584;
  36580. t.uacute = 556;
  36581. t.Tcaron = 611;
  36582. t.partialdiff = 476;
  36583. t.ydieresis = 500;
  36584. t.Nacute = 722;
  36585. t.icircumflex = 278;
  36586. t.Ecircumflex = 667;
  36587. t.adieresis = 556;
  36588. t.edieresis = 556;
  36589. t.cacute = 500;
  36590. t.nacute = 556;
  36591. t.umacron = 556;
  36592. t.Ncaron = 722;
  36593. t.Iacute = 278;
  36594. t.plusminus = 584;
  36595. t.brokenbar = 260;
  36596. t.registered = 737;
  36597. t.Gbreve = 778;
  36598. t.Idotaccent = 278;
  36599. t.summation = 600;
  36600. t.Egrave = 667;
  36601. t.racute = 333;
  36602. t.omacron = 556;
  36603. t.Zacute = 611;
  36604. t.Zcaron = 611;
  36605. t.greaterequal = 549;
  36606. t.Eth = 722;
  36607. t.Ccedilla = 722;
  36608. t.lcommaaccent = 222;
  36609. t.tcaron = 317;
  36610. t.eogonek = 556;
  36611. t.Uogonek = 722;
  36612. t.Aacute = 667;
  36613. t.Adieresis = 667;
  36614. t.egrave = 556;
  36615. t.zacute = 500;
  36616. t.iogonek = 222;
  36617. t.Oacute = 778;
  36618. t.oacute = 556;
  36619. t.amacron = 556;
  36620. t.sacute = 500;
  36621. t.idieresis = 278;
  36622. t.Ocircumflex = 778;
  36623. t.Ugrave = 722;
  36624. t.Delta = 612;
  36625. t.thorn = 556;
  36626. t.twosuperior = 333;
  36627. t.Odieresis = 778;
  36628. t.mu = 556;
  36629. t.igrave = 278;
  36630. t.ohungarumlaut = 556;
  36631. t.Eogonek = 667;
  36632. t.dcroat = 556;
  36633. t.threequarters = 834;
  36634. t.Scedilla = 667;
  36635. t.lcaron = 299;
  36636. t.Kcommaaccent = 667;
  36637. t.Lacute = 556;
  36638. t.trademark = 1000;
  36639. t.edotaccent = 556;
  36640. t.Igrave = 278;
  36641. t.Imacron = 278;
  36642. t.Lcaron = 556;
  36643. t.onehalf = 834;
  36644. t.lessequal = 549;
  36645. t.ocircumflex = 556;
  36646. t.ntilde = 556;
  36647. t.Uhungarumlaut = 722;
  36648. t.Eacute = 667;
  36649. t.emacron = 556;
  36650. t.gbreve = 556;
  36651. t.onequarter = 834;
  36652. t.Scaron = 667;
  36653. t.Scommaaccent = 667;
  36654. t.Ohungarumlaut = 778;
  36655. t.degree = 400;
  36656. t.ograve = 556;
  36657. t.Ccaron = 722;
  36658. t.ugrave = 556;
  36659. t.radical = 453;
  36660. t.Dcaron = 722;
  36661. t.rcommaaccent = 333;
  36662. t.Ntilde = 722;
  36663. t.otilde = 556;
  36664. t.Rcommaaccent = 722;
  36665. t.Lcommaaccent = 556;
  36666. t.Atilde = 667;
  36667. t.Aogonek = 667;
  36668. t.Aring = 667;
  36669. t.Otilde = 778;
  36670. t.zdotaccent = 500;
  36671. t.Ecaron = 667;
  36672. t.Iogonek = 278;
  36673. t.kcommaaccent = 500;
  36674. t.minus = 584;
  36675. t.Icircumflex = 278;
  36676. t.ncaron = 556;
  36677. t.tcommaaccent = 278;
  36678. t.logicalnot = 584;
  36679. t.odieresis = 556;
  36680. t.udieresis = 556;
  36681. t.notequal = 549;
  36682. t.gcommaaccent = 556;
  36683. t.eth = 556;
  36684. t.zcaron = 500;
  36685. t.ncommaaccent = 556;
  36686. t.onesuperior = 333;
  36687. t.imacron = 278;
  36688. t.Euro = 556;
  36689. });
  36690. t["Helvetica-Bold"] = (0, _core_utils.getLookupTableFactory)(function (t) {
  36691. t.space = 278;
  36692. t.exclam = 333;
  36693. t.quotedbl = 474;
  36694. t.numbersign = 556;
  36695. t.dollar = 556;
  36696. t.percent = 889;
  36697. t.ampersand = 722;
  36698. t.quoteright = 278;
  36699. t.parenleft = 333;
  36700. t.parenright = 333;
  36701. t.asterisk = 389;
  36702. t.plus = 584;
  36703. t.comma = 278;
  36704. t.hyphen = 333;
  36705. t.period = 278;
  36706. t.slash = 278;
  36707. t.zero = 556;
  36708. t.one = 556;
  36709. t.two = 556;
  36710. t.three = 556;
  36711. t.four = 556;
  36712. t.five = 556;
  36713. t.six = 556;
  36714. t.seven = 556;
  36715. t.eight = 556;
  36716. t.nine = 556;
  36717. t.colon = 333;
  36718. t.semicolon = 333;
  36719. t.less = 584;
  36720. t.equal = 584;
  36721. t.greater = 584;
  36722. t.question = 611;
  36723. t.at = 975;
  36724. t.A = 722;
  36725. t.B = 722;
  36726. t.C = 722;
  36727. t.D = 722;
  36728. t.E = 667;
  36729. t.F = 611;
  36730. t.G = 778;
  36731. t.H = 722;
  36732. t.I = 278;
  36733. t.J = 556;
  36734. t.K = 722;
  36735. t.L = 611;
  36736. t.M = 833;
  36737. t.N = 722;
  36738. t.O = 778;
  36739. t.P = 667;
  36740. t.Q = 778;
  36741. t.R = 722;
  36742. t.S = 667;
  36743. t.T = 611;
  36744. t.U = 722;
  36745. t.V = 667;
  36746. t.W = 944;
  36747. t.X = 667;
  36748. t.Y = 667;
  36749. t.Z = 611;
  36750. t.bracketleft = 333;
  36751. t.backslash = 278;
  36752. t.bracketright = 333;
  36753. t.asciicircum = 584;
  36754. t.underscore = 556;
  36755. t.quoteleft = 278;
  36756. t.a = 556;
  36757. t.b = 611;
  36758. t.c = 556;
  36759. t.d = 611;
  36760. t.e = 556;
  36761. t.f = 333;
  36762. t.g = 611;
  36763. t.h = 611;
  36764. t.i = 278;
  36765. t.j = 278;
  36766. t.k = 556;
  36767. t.l = 278;
  36768. t.m = 889;
  36769. t.n = 611;
  36770. t.o = 611;
  36771. t.p = 611;
  36772. t.q = 611;
  36773. t.r = 389;
  36774. t.s = 556;
  36775. t.t = 333;
  36776. t.u = 611;
  36777. t.v = 556;
  36778. t.w = 778;
  36779. t.x = 556;
  36780. t.y = 556;
  36781. t.z = 500;
  36782. t.braceleft = 389;
  36783. t.bar = 280;
  36784. t.braceright = 389;
  36785. t.asciitilde = 584;
  36786. t.exclamdown = 333;
  36787. t.cent = 556;
  36788. t.sterling = 556;
  36789. t.fraction = 167;
  36790. t.yen = 556;
  36791. t.florin = 556;
  36792. t.section = 556;
  36793. t.currency = 556;
  36794. t.quotesingle = 238;
  36795. t.quotedblleft = 500;
  36796. t.guillemotleft = 556;
  36797. t.guilsinglleft = 333;
  36798. t.guilsinglright = 333;
  36799. t.fi = 611;
  36800. t.fl = 611;
  36801. t.endash = 556;
  36802. t.dagger = 556;
  36803. t.daggerdbl = 556;
  36804. t.periodcentered = 278;
  36805. t.paragraph = 556;
  36806. t.bullet = 350;
  36807. t.quotesinglbase = 278;
  36808. t.quotedblbase = 500;
  36809. t.quotedblright = 500;
  36810. t.guillemotright = 556;
  36811. t.ellipsis = 1000;
  36812. t.perthousand = 1000;
  36813. t.questiondown = 611;
  36814. t.grave = 333;
  36815. t.acute = 333;
  36816. t.circumflex = 333;
  36817. t.tilde = 333;
  36818. t.macron = 333;
  36819. t.breve = 333;
  36820. t.dotaccent = 333;
  36821. t.dieresis = 333;
  36822. t.ring = 333;
  36823. t.cedilla = 333;
  36824. t.hungarumlaut = 333;
  36825. t.ogonek = 333;
  36826. t.caron = 333;
  36827. t.emdash = 1000;
  36828. t.AE = 1000;
  36829. t.ordfeminine = 370;
  36830. t.Lslash = 611;
  36831. t.Oslash = 778;
  36832. t.OE = 1000;
  36833. t.ordmasculine = 365;
  36834. t.ae = 889;
  36835. t.dotlessi = 278;
  36836. t.lslash = 278;
  36837. t.oslash = 611;
  36838. t.oe = 944;
  36839. t.germandbls = 611;
  36840. t.Idieresis = 278;
  36841. t.eacute = 556;
  36842. t.abreve = 556;
  36843. t.uhungarumlaut = 611;
  36844. t.ecaron = 556;
  36845. t.Ydieresis = 667;
  36846. t.divide = 584;
  36847. t.Yacute = 667;
  36848. t.Acircumflex = 722;
  36849. t.aacute = 556;
  36850. t.Ucircumflex = 722;
  36851. t.yacute = 556;
  36852. t.scommaaccent = 556;
  36853. t.ecircumflex = 556;
  36854. t.Uring = 722;
  36855. t.Udieresis = 722;
  36856. t.aogonek = 556;
  36857. t.Uacute = 722;
  36858. t.uogonek = 611;
  36859. t.Edieresis = 667;
  36860. t.Dcroat = 722;
  36861. t.commaaccent = 250;
  36862. t.copyright = 737;
  36863. t.Emacron = 667;
  36864. t.ccaron = 556;
  36865. t.aring = 556;
  36866. t.Ncommaaccent = 722;
  36867. t.lacute = 278;
  36868. t.agrave = 556;
  36869. t.Tcommaaccent = 611;
  36870. t.Cacute = 722;
  36871. t.atilde = 556;
  36872. t.Edotaccent = 667;
  36873. t.scaron = 556;
  36874. t.scedilla = 556;
  36875. t.iacute = 278;
  36876. t.lozenge = 494;
  36877. t.Rcaron = 722;
  36878. t.Gcommaaccent = 778;
  36879. t.ucircumflex = 611;
  36880. t.acircumflex = 556;
  36881. t.Amacron = 722;
  36882. t.rcaron = 389;
  36883. t.ccedilla = 556;
  36884. t.Zdotaccent = 611;
  36885. t.Thorn = 667;
  36886. t.Omacron = 778;
  36887. t.Racute = 722;
  36888. t.Sacute = 667;
  36889. t.dcaron = 743;
  36890. t.Umacron = 722;
  36891. t.uring = 611;
  36892. t.threesuperior = 333;
  36893. t.Ograve = 778;
  36894. t.Agrave = 722;
  36895. t.Abreve = 722;
  36896. t.multiply = 584;
  36897. t.uacute = 611;
  36898. t.Tcaron = 611;
  36899. t.partialdiff = 494;
  36900. t.ydieresis = 556;
  36901. t.Nacute = 722;
  36902. t.icircumflex = 278;
  36903. t.Ecircumflex = 667;
  36904. t.adieresis = 556;
  36905. t.edieresis = 556;
  36906. t.cacute = 556;
  36907. t.nacute = 611;
  36908. t.umacron = 611;
  36909. t.Ncaron = 722;
  36910. t.Iacute = 278;
  36911. t.plusminus = 584;
  36912. t.brokenbar = 280;
  36913. t.registered = 737;
  36914. t.Gbreve = 778;
  36915. t.Idotaccent = 278;
  36916. t.summation = 600;
  36917. t.Egrave = 667;
  36918. t.racute = 389;
  36919. t.omacron = 611;
  36920. t.Zacute = 611;
  36921. t.Zcaron = 611;
  36922. t.greaterequal = 549;
  36923. t.Eth = 722;
  36924. t.Ccedilla = 722;
  36925. t.lcommaaccent = 278;
  36926. t.tcaron = 389;
  36927. t.eogonek = 556;
  36928. t.Uogonek = 722;
  36929. t.Aacute = 722;
  36930. t.Adieresis = 722;
  36931. t.egrave = 556;
  36932. t.zacute = 500;
  36933. t.iogonek = 278;
  36934. t.Oacute = 778;
  36935. t.oacute = 611;
  36936. t.amacron = 556;
  36937. t.sacute = 556;
  36938. t.idieresis = 278;
  36939. t.Ocircumflex = 778;
  36940. t.Ugrave = 722;
  36941. t.Delta = 612;
  36942. t.thorn = 611;
  36943. t.twosuperior = 333;
  36944. t.Odieresis = 778;
  36945. t.mu = 611;
  36946. t.igrave = 278;
  36947. t.ohungarumlaut = 611;
  36948. t.Eogonek = 667;
  36949. t.dcroat = 611;
  36950. t.threequarters = 834;
  36951. t.Scedilla = 667;
  36952. t.lcaron = 400;
  36953. t.Kcommaaccent = 722;
  36954. t.Lacute = 611;
  36955. t.trademark = 1000;
  36956. t.edotaccent = 556;
  36957. t.Igrave = 278;
  36958. t.Imacron = 278;
  36959. t.Lcaron = 611;
  36960. t.onehalf = 834;
  36961. t.lessequal = 549;
  36962. t.ocircumflex = 611;
  36963. t.ntilde = 611;
  36964. t.Uhungarumlaut = 722;
  36965. t.Eacute = 667;
  36966. t.emacron = 556;
  36967. t.gbreve = 611;
  36968. t.onequarter = 834;
  36969. t.Scaron = 667;
  36970. t.Scommaaccent = 667;
  36971. t.Ohungarumlaut = 778;
  36972. t.degree = 400;
  36973. t.ograve = 611;
  36974. t.Ccaron = 722;
  36975. t.ugrave = 611;
  36976. t.radical = 549;
  36977. t.Dcaron = 722;
  36978. t.rcommaaccent = 389;
  36979. t.Ntilde = 722;
  36980. t.otilde = 611;
  36981. t.Rcommaaccent = 722;
  36982. t.Lcommaaccent = 611;
  36983. t.Atilde = 722;
  36984. t.Aogonek = 722;
  36985. t.Aring = 722;
  36986. t.Otilde = 778;
  36987. t.zdotaccent = 500;
  36988. t.Ecaron = 667;
  36989. t.Iogonek = 278;
  36990. t.kcommaaccent = 556;
  36991. t.minus = 584;
  36992. t.Icircumflex = 278;
  36993. t.ncaron = 611;
  36994. t.tcommaaccent = 333;
  36995. t.logicalnot = 584;
  36996. t.odieresis = 611;
  36997. t.udieresis = 611;
  36998. t.notequal = 549;
  36999. t.gcommaaccent = 611;
  37000. t.eth = 611;
  37001. t.zcaron = 500;
  37002. t.ncommaaccent = 611;
  37003. t.onesuperior = 333;
  37004. t.imacron = 278;
  37005. t.Euro = 556;
  37006. });
  37007. t["Helvetica-BoldOblique"] = (0, _core_utils.getLookupTableFactory)(function (t) {
  37008. t.space = 278;
  37009. t.exclam = 333;
  37010. t.quotedbl = 474;
  37011. t.numbersign = 556;
  37012. t.dollar = 556;
  37013. t.percent = 889;
  37014. t.ampersand = 722;
  37015. t.quoteright = 278;
  37016. t.parenleft = 333;
  37017. t.parenright = 333;
  37018. t.asterisk = 389;
  37019. t.plus = 584;
  37020. t.comma = 278;
  37021. t.hyphen = 333;
  37022. t.period = 278;
  37023. t.slash = 278;
  37024. t.zero = 556;
  37025. t.one = 556;
  37026. t.two = 556;
  37027. t.three = 556;
  37028. t.four = 556;
  37029. t.five = 556;
  37030. t.six = 556;
  37031. t.seven = 556;
  37032. t.eight = 556;
  37033. t.nine = 556;
  37034. t.colon = 333;
  37035. t.semicolon = 333;
  37036. t.less = 584;
  37037. t.equal = 584;
  37038. t.greater = 584;
  37039. t.question = 611;
  37040. t.at = 975;
  37041. t.A = 722;
  37042. t.B = 722;
  37043. t.C = 722;
  37044. t.D = 722;
  37045. t.E = 667;
  37046. t.F = 611;
  37047. t.G = 778;
  37048. t.H = 722;
  37049. t.I = 278;
  37050. t.J = 556;
  37051. t.K = 722;
  37052. t.L = 611;
  37053. t.M = 833;
  37054. t.N = 722;
  37055. t.O = 778;
  37056. t.P = 667;
  37057. t.Q = 778;
  37058. t.R = 722;
  37059. t.S = 667;
  37060. t.T = 611;
  37061. t.U = 722;
  37062. t.V = 667;
  37063. t.W = 944;
  37064. t.X = 667;
  37065. t.Y = 667;
  37066. t.Z = 611;
  37067. t.bracketleft = 333;
  37068. t.backslash = 278;
  37069. t.bracketright = 333;
  37070. t.asciicircum = 584;
  37071. t.underscore = 556;
  37072. t.quoteleft = 278;
  37073. t.a = 556;
  37074. t.b = 611;
  37075. t.c = 556;
  37076. t.d = 611;
  37077. t.e = 556;
  37078. t.f = 333;
  37079. t.g = 611;
  37080. t.h = 611;
  37081. t.i = 278;
  37082. t.j = 278;
  37083. t.k = 556;
  37084. t.l = 278;
  37085. t.m = 889;
  37086. t.n = 611;
  37087. t.o = 611;
  37088. t.p = 611;
  37089. t.q = 611;
  37090. t.r = 389;
  37091. t.s = 556;
  37092. t.t = 333;
  37093. t.u = 611;
  37094. t.v = 556;
  37095. t.w = 778;
  37096. t.x = 556;
  37097. t.y = 556;
  37098. t.z = 500;
  37099. t.braceleft = 389;
  37100. t.bar = 280;
  37101. t.braceright = 389;
  37102. t.asciitilde = 584;
  37103. t.exclamdown = 333;
  37104. t.cent = 556;
  37105. t.sterling = 556;
  37106. t.fraction = 167;
  37107. t.yen = 556;
  37108. t.florin = 556;
  37109. t.section = 556;
  37110. t.currency = 556;
  37111. t.quotesingle = 238;
  37112. t.quotedblleft = 500;
  37113. t.guillemotleft = 556;
  37114. t.guilsinglleft = 333;
  37115. t.guilsinglright = 333;
  37116. t.fi = 611;
  37117. t.fl = 611;
  37118. t.endash = 556;
  37119. t.dagger = 556;
  37120. t.daggerdbl = 556;
  37121. t.periodcentered = 278;
  37122. t.paragraph = 556;
  37123. t.bullet = 350;
  37124. t.quotesinglbase = 278;
  37125. t.quotedblbase = 500;
  37126. t.quotedblright = 500;
  37127. t.guillemotright = 556;
  37128. t.ellipsis = 1000;
  37129. t.perthousand = 1000;
  37130. t.questiondown = 611;
  37131. t.grave = 333;
  37132. t.acute = 333;
  37133. t.circumflex = 333;
  37134. t.tilde = 333;
  37135. t.macron = 333;
  37136. t.breve = 333;
  37137. t.dotaccent = 333;
  37138. t.dieresis = 333;
  37139. t.ring = 333;
  37140. t.cedilla = 333;
  37141. t.hungarumlaut = 333;
  37142. t.ogonek = 333;
  37143. t.caron = 333;
  37144. t.emdash = 1000;
  37145. t.AE = 1000;
  37146. t.ordfeminine = 370;
  37147. t.Lslash = 611;
  37148. t.Oslash = 778;
  37149. t.OE = 1000;
  37150. t.ordmasculine = 365;
  37151. t.ae = 889;
  37152. t.dotlessi = 278;
  37153. t.lslash = 278;
  37154. t.oslash = 611;
  37155. t.oe = 944;
  37156. t.germandbls = 611;
  37157. t.Idieresis = 278;
  37158. t.eacute = 556;
  37159. t.abreve = 556;
  37160. t.uhungarumlaut = 611;
  37161. t.ecaron = 556;
  37162. t.Ydieresis = 667;
  37163. t.divide = 584;
  37164. t.Yacute = 667;
  37165. t.Acircumflex = 722;
  37166. t.aacute = 556;
  37167. t.Ucircumflex = 722;
  37168. t.yacute = 556;
  37169. t.scommaaccent = 556;
  37170. t.ecircumflex = 556;
  37171. t.Uring = 722;
  37172. t.Udieresis = 722;
  37173. t.aogonek = 556;
  37174. t.Uacute = 722;
  37175. t.uogonek = 611;
  37176. t.Edieresis = 667;
  37177. t.Dcroat = 722;
  37178. t.commaaccent = 250;
  37179. t.copyright = 737;
  37180. t.Emacron = 667;
  37181. t.ccaron = 556;
  37182. t.aring = 556;
  37183. t.Ncommaaccent = 722;
  37184. t.lacute = 278;
  37185. t.agrave = 556;
  37186. t.Tcommaaccent = 611;
  37187. t.Cacute = 722;
  37188. t.atilde = 556;
  37189. t.Edotaccent = 667;
  37190. t.scaron = 556;
  37191. t.scedilla = 556;
  37192. t.iacute = 278;
  37193. t.lozenge = 494;
  37194. t.Rcaron = 722;
  37195. t.Gcommaaccent = 778;
  37196. t.ucircumflex = 611;
  37197. t.acircumflex = 556;
  37198. t.Amacron = 722;
  37199. t.rcaron = 389;
  37200. t.ccedilla = 556;
  37201. t.Zdotaccent = 611;
  37202. t.Thorn = 667;
  37203. t.Omacron = 778;
  37204. t.Racute = 722;
  37205. t.Sacute = 667;
  37206. t.dcaron = 743;
  37207. t.Umacron = 722;
  37208. t.uring = 611;
  37209. t.threesuperior = 333;
  37210. t.Ograve = 778;
  37211. t.Agrave = 722;
  37212. t.Abreve = 722;
  37213. t.multiply = 584;
  37214. t.uacute = 611;
  37215. t.Tcaron = 611;
  37216. t.partialdiff = 494;
  37217. t.ydieresis = 556;
  37218. t.Nacute = 722;
  37219. t.icircumflex = 278;
  37220. t.Ecircumflex = 667;
  37221. t.adieresis = 556;
  37222. t.edieresis = 556;
  37223. t.cacute = 556;
  37224. t.nacute = 611;
  37225. t.umacron = 611;
  37226. t.Ncaron = 722;
  37227. t.Iacute = 278;
  37228. t.plusminus = 584;
  37229. t.brokenbar = 280;
  37230. t.registered = 737;
  37231. t.Gbreve = 778;
  37232. t.Idotaccent = 278;
  37233. t.summation = 600;
  37234. t.Egrave = 667;
  37235. t.racute = 389;
  37236. t.omacron = 611;
  37237. t.Zacute = 611;
  37238. t.Zcaron = 611;
  37239. t.greaterequal = 549;
  37240. t.Eth = 722;
  37241. t.Ccedilla = 722;
  37242. t.lcommaaccent = 278;
  37243. t.tcaron = 389;
  37244. t.eogonek = 556;
  37245. t.Uogonek = 722;
  37246. t.Aacute = 722;
  37247. t.Adieresis = 722;
  37248. t.egrave = 556;
  37249. t.zacute = 500;
  37250. t.iogonek = 278;
  37251. t.Oacute = 778;
  37252. t.oacute = 611;
  37253. t.amacron = 556;
  37254. t.sacute = 556;
  37255. t.idieresis = 278;
  37256. t.Ocircumflex = 778;
  37257. t.Ugrave = 722;
  37258. t.Delta = 612;
  37259. t.thorn = 611;
  37260. t.twosuperior = 333;
  37261. t.Odieresis = 778;
  37262. t.mu = 611;
  37263. t.igrave = 278;
  37264. t.ohungarumlaut = 611;
  37265. t.Eogonek = 667;
  37266. t.dcroat = 611;
  37267. t.threequarters = 834;
  37268. t.Scedilla = 667;
  37269. t.lcaron = 400;
  37270. t.Kcommaaccent = 722;
  37271. t.Lacute = 611;
  37272. t.trademark = 1000;
  37273. t.edotaccent = 556;
  37274. t.Igrave = 278;
  37275. t.Imacron = 278;
  37276. t.Lcaron = 611;
  37277. t.onehalf = 834;
  37278. t.lessequal = 549;
  37279. t.ocircumflex = 611;
  37280. t.ntilde = 611;
  37281. t.Uhungarumlaut = 722;
  37282. t.Eacute = 667;
  37283. t.emacron = 556;
  37284. t.gbreve = 611;
  37285. t.onequarter = 834;
  37286. t.Scaron = 667;
  37287. t.Scommaaccent = 667;
  37288. t.Ohungarumlaut = 778;
  37289. t.degree = 400;
  37290. t.ograve = 611;
  37291. t.Ccaron = 722;
  37292. t.ugrave = 611;
  37293. t.radical = 549;
  37294. t.Dcaron = 722;
  37295. t.rcommaaccent = 389;
  37296. t.Ntilde = 722;
  37297. t.otilde = 611;
  37298. t.Rcommaaccent = 722;
  37299. t.Lcommaaccent = 611;
  37300. t.Atilde = 722;
  37301. t.Aogonek = 722;
  37302. t.Aring = 722;
  37303. t.Otilde = 778;
  37304. t.zdotaccent = 500;
  37305. t.Ecaron = 667;
  37306. t.Iogonek = 278;
  37307. t.kcommaaccent = 556;
  37308. t.minus = 584;
  37309. t.Icircumflex = 278;
  37310. t.ncaron = 611;
  37311. t.tcommaaccent = 333;
  37312. t.logicalnot = 584;
  37313. t.odieresis = 611;
  37314. t.udieresis = 611;
  37315. t.notequal = 549;
  37316. t.gcommaaccent = 611;
  37317. t.eth = 611;
  37318. t.zcaron = 500;
  37319. t.ncommaaccent = 611;
  37320. t.onesuperior = 333;
  37321. t.imacron = 278;
  37322. t.Euro = 556;
  37323. });
  37324. t["Helvetica-Oblique"] = (0, _core_utils.getLookupTableFactory)(function (t) {
  37325. t.space = 278;
  37326. t.exclam = 278;
  37327. t.quotedbl = 355;
  37328. t.numbersign = 556;
  37329. t.dollar = 556;
  37330. t.percent = 889;
  37331. t.ampersand = 667;
  37332. t.quoteright = 222;
  37333. t.parenleft = 333;
  37334. t.parenright = 333;
  37335. t.asterisk = 389;
  37336. t.plus = 584;
  37337. t.comma = 278;
  37338. t.hyphen = 333;
  37339. t.period = 278;
  37340. t.slash = 278;
  37341. t.zero = 556;
  37342. t.one = 556;
  37343. t.two = 556;
  37344. t.three = 556;
  37345. t.four = 556;
  37346. t.five = 556;
  37347. t.six = 556;
  37348. t.seven = 556;
  37349. t.eight = 556;
  37350. t.nine = 556;
  37351. t.colon = 278;
  37352. t.semicolon = 278;
  37353. t.less = 584;
  37354. t.equal = 584;
  37355. t.greater = 584;
  37356. t.question = 556;
  37357. t.at = 1015;
  37358. t.A = 667;
  37359. t.B = 667;
  37360. t.C = 722;
  37361. t.D = 722;
  37362. t.E = 667;
  37363. t.F = 611;
  37364. t.G = 778;
  37365. t.H = 722;
  37366. t.I = 278;
  37367. t.J = 500;
  37368. t.K = 667;
  37369. t.L = 556;
  37370. t.M = 833;
  37371. t.N = 722;
  37372. t.O = 778;
  37373. t.P = 667;
  37374. t.Q = 778;
  37375. t.R = 722;
  37376. t.S = 667;
  37377. t.T = 611;
  37378. t.U = 722;
  37379. t.V = 667;
  37380. t.W = 944;
  37381. t.X = 667;
  37382. t.Y = 667;
  37383. t.Z = 611;
  37384. t.bracketleft = 278;
  37385. t.backslash = 278;
  37386. t.bracketright = 278;
  37387. t.asciicircum = 469;
  37388. t.underscore = 556;
  37389. t.quoteleft = 222;
  37390. t.a = 556;
  37391. t.b = 556;
  37392. t.c = 500;
  37393. t.d = 556;
  37394. t.e = 556;
  37395. t.f = 278;
  37396. t.g = 556;
  37397. t.h = 556;
  37398. t.i = 222;
  37399. t.j = 222;
  37400. t.k = 500;
  37401. t.l = 222;
  37402. t.m = 833;
  37403. t.n = 556;
  37404. t.o = 556;
  37405. t.p = 556;
  37406. t.q = 556;
  37407. t.r = 333;
  37408. t.s = 500;
  37409. t.t = 278;
  37410. t.u = 556;
  37411. t.v = 500;
  37412. t.w = 722;
  37413. t.x = 500;
  37414. t.y = 500;
  37415. t.z = 500;
  37416. t.braceleft = 334;
  37417. t.bar = 260;
  37418. t.braceright = 334;
  37419. t.asciitilde = 584;
  37420. t.exclamdown = 333;
  37421. t.cent = 556;
  37422. t.sterling = 556;
  37423. t.fraction = 167;
  37424. t.yen = 556;
  37425. t.florin = 556;
  37426. t.section = 556;
  37427. t.currency = 556;
  37428. t.quotesingle = 191;
  37429. t.quotedblleft = 333;
  37430. t.guillemotleft = 556;
  37431. t.guilsinglleft = 333;
  37432. t.guilsinglright = 333;
  37433. t.fi = 500;
  37434. t.fl = 500;
  37435. t.endash = 556;
  37436. t.dagger = 556;
  37437. t.daggerdbl = 556;
  37438. t.periodcentered = 278;
  37439. t.paragraph = 537;
  37440. t.bullet = 350;
  37441. t.quotesinglbase = 222;
  37442. t.quotedblbase = 333;
  37443. t.quotedblright = 333;
  37444. t.guillemotright = 556;
  37445. t.ellipsis = 1000;
  37446. t.perthousand = 1000;
  37447. t.questiondown = 611;
  37448. t.grave = 333;
  37449. t.acute = 333;
  37450. t.circumflex = 333;
  37451. t.tilde = 333;
  37452. t.macron = 333;
  37453. t.breve = 333;
  37454. t.dotaccent = 333;
  37455. t.dieresis = 333;
  37456. t.ring = 333;
  37457. t.cedilla = 333;
  37458. t.hungarumlaut = 333;
  37459. t.ogonek = 333;
  37460. t.caron = 333;
  37461. t.emdash = 1000;
  37462. t.AE = 1000;
  37463. t.ordfeminine = 370;
  37464. t.Lslash = 556;
  37465. t.Oslash = 778;
  37466. t.OE = 1000;
  37467. t.ordmasculine = 365;
  37468. t.ae = 889;
  37469. t.dotlessi = 278;
  37470. t.lslash = 222;
  37471. t.oslash = 611;
  37472. t.oe = 944;
  37473. t.germandbls = 611;
  37474. t.Idieresis = 278;
  37475. t.eacute = 556;
  37476. t.abreve = 556;
  37477. t.uhungarumlaut = 556;
  37478. t.ecaron = 556;
  37479. t.Ydieresis = 667;
  37480. t.divide = 584;
  37481. t.Yacute = 667;
  37482. t.Acircumflex = 667;
  37483. t.aacute = 556;
  37484. t.Ucircumflex = 722;
  37485. t.yacute = 500;
  37486. t.scommaaccent = 500;
  37487. t.ecircumflex = 556;
  37488. t.Uring = 722;
  37489. t.Udieresis = 722;
  37490. t.aogonek = 556;
  37491. t.Uacute = 722;
  37492. t.uogonek = 556;
  37493. t.Edieresis = 667;
  37494. t.Dcroat = 722;
  37495. t.commaaccent = 250;
  37496. t.copyright = 737;
  37497. t.Emacron = 667;
  37498. t.ccaron = 500;
  37499. t.aring = 556;
  37500. t.Ncommaaccent = 722;
  37501. t.lacute = 222;
  37502. t.agrave = 556;
  37503. t.Tcommaaccent = 611;
  37504. t.Cacute = 722;
  37505. t.atilde = 556;
  37506. t.Edotaccent = 667;
  37507. t.scaron = 500;
  37508. t.scedilla = 500;
  37509. t.iacute = 278;
  37510. t.lozenge = 471;
  37511. t.Rcaron = 722;
  37512. t.Gcommaaccent = 778;
  37513. t.ucircumflex = 556;
  37514. t.acircumflex = 556;
  37515. t.Amacron = 667;
  37516. t.rcaron = 333;
  37517. t.ccedilla = 500;
  37518. t.Zdotaccent = 611;
  37519. t.Thorn = 667;
  37520. t.Omacron = 778;
  37521. t.Racute = 722;
  37522. t.Sacute = 667;
  37523. t.dcaron = 643;
  37524. t.Umacron = 722;
  37525. t.uring = 556;
  37526. t.threesuperior = 333;
  37527. t.Ograve = 778;
  37528. t.Agrave = 667;
  37529. t.Abreve = 667;
  37530. t.multiply = 584;
  37531. t.uacute = 556;
  37532. t.Tcaron = 611;
  37533. t.partialdiff = 476;
  37534. t.ydieresis = 500;
  37535. t.Nacute = 722;
  37536. t.icircumflex = 278;
  37537. t.Ecircumflex = 667;
  37538. t.adieresis = 556;
  37539. t.edieresis = 556;
  37540. t.cacute = 500;
  37541. t.nacute = 556;
  37542. t.umacron = 556;
  37543. t.Ncaron = 722;
  37544. t.Iacute = 278;
  37545. t.plusminus = 584;
  37546. t.brokenbar = 260;
  37547. t.registered = 737;
  37548. t.Gbreve = 778;
  37549. t.Idotaccent = 278;
  37550. t.summation = 600;
  37551. t.Egrave = 667;
  37552. t.racute = 333;
  37553. t.omacron = 556;
  37554. t.Zacute = 611;
  37555. t.Zcaron = 611;
  37556. t.greaterequal = 549;
  37557. t.Eth = 722;
  37558. t.Ccedilla = 722;
  37559. t.lcommaaccent = 222;
  37560. t.tcaron = 317;
  37561. t.eogonek = 556;
  37562. t.Uogonek = 722;
  37563. t.Aacute = 667;
  37564. t.Adieresis = 667;
  37565. t.egrave = 556;
  37566. t.zacute = 500;
  37567. t.iogonek = 222;
  37568. t.Oacute = 778;
  37569. t.oacute = 556;
  37570. t.amacron = 556;
  37571. t.sacute = 500;
  37572. t.idieresis = 278;
  37573. t.Ocircumflex = 778;
  37574. t.Ugrave = 722;
  37575. t.Delta = 612;
  37576. t.thorn = 556;
  37577. t.twosuperior = 333;
  37578. t.Odieresis = 778;
  37579. t.mu = 556;
  37580. t.igrave = 278;
  37581. t.ohungarumlaut = 556;
  37582. t.Eogonek = 667;
  37583. t.dcroat = 556;
  37584. t.threequarters = 834;
  37585. t.Scedilla = 667;
  37586. t.lcaron = 299;
  37587. t.Kcommaaccent = 667;
  37588. t.Lacute = 556;
  37589. t.trademark = 1000;
  37590. t.edotaccent = 556;
  37591. t.Igrave = 278;
  37592. t.Imacron = 278;
  37593. t.Lcaron = 556;
  37594. t.onehalf = 834;
  37595. t.lessequal = 549;
  37596. t.ocircumflex = 556;
  37597. t.ntilde = 556;
  37598. t.Uhungarumlaut = 722;
  37599. t.Eacute = 667;
  37600. t.emacron = 556;
  37601. t.gbreve = 556;
  37602. t.onequarter = 834;
  37603. t.Scaron = 667;
  37604. t.Scommaaccent = 667;
  37605. t.Ohungarumlaut = 778;
  37606. t.degree = 400;
  37607. t.ograve = 556;
  37608. t.Ccaron = 722;
  37609. t.ugrave = 556;
  37610. t.radical = 453;
  37611. t.Dcaron = 722;
  37612. t.rcommaaccent = 333;
  37613. t.Ntilde = 722;
  37614. t.otilde = 556;
  37615. t.Rcommaaccent = 722;
  37616. t.Lcommaaccent = 556;
  37617. t.Atilde = 667;
  37618. t.Aogonek = 667;
  37619. t.Aring = 667;
  37620. t.Otilde = 778;
  37621. t.zdotaccent = 500;
  37622. t.Ecaron = 667;
  37623. t.Iogonek = 278;
  37624. t.kcommaaccent = 500;
  37625. t.minus = 584;
  37626. t.Icircumflex = 278;
  37627. t.ncaron = 556;
  37628. t.tcommaaccent = 278;
  37629. t.logicalnot = 584;
  37630. t.odieresis = 556;
  37631. t.udieresis = 556;
  37632. t.notequal = 549;
  37633. t.gcommaaccent = 556;
  37634. t.eth = 556;
  37635. t.zcaron = 500;
  37636. t.ncommaaccent = 556;
  37637. t.onesuperior = 333;
  37638. t.imacron = 278;
  37639. t.Euro = 556;
  37640. });
  37641. t.Symbol = (0, _core_utils.getLookupTableFactory)(function (t) {
  37642. t.space = 250;
  37643. t.exclam = 333;
  37644. t.universal = 713;
  37645. t.numbersign = 500;
  37646. t.existential = 549;
  37647. t.percent = 833;
  37648. t.ampersand = 778;
  37649. t.suchthat = 439;
  37650. t.parenleft = 333;
  37651. t.parenright = 333;
  37652. t.asteriskmath = 500;
  37653. t.plus = 549;
  37654. t.comma = 250;
  37655. t.minus = 549;
  37656. t.period = 250;
  37657. t.slash = 278;
  37658. t.zero = 500;
  37659. t.one = 500;
  37660. t.two = 500;
  37661. t.three = 500;
  37662. t.four = 500;
  37663. t.five = 500;
  37664. t.six = 500;
  37665. t.seven = 500;
  37666. t.eight = 500;
  37667. t.nine = 500;
  37668. t.colon = 278;
  37669. t.semicolon = 278;
  37670. t.less = 549;
  37671. t.equal = 549;
  37672. t.greater = 549;
  37673. t.question = 444;
  37674. t.congruent = 549;
  37675. t.Alpha = 722;
  37676. t.Beta = 667;
  37677. t.Chi = 722;
  37678. t.Delta = 612;
  37679. t.Epsilon = 611;
  37680. t.Phi = 763;
  37681. t.Gamma = 603;
  37682. t.Eta = 722;
  37683. t.Iota = 333;
  37684. t.theta1 = 631;
  37685. t.Kappa = 722;
  37686. t.Lambda = 686;
  37687. t.Mu = 889;
  37688. t.Nu = 722;
  37689. t.Omicron = 722;
  37690. t.Pi = 768;
  37691. t.Theta = 741;
  37692. t.Rho = 556;
  37693. t.Sigma = 592;
  37694. t.Tau = 611;
  37695. t.Upsilon = 690;
  37696. t.sigma1 = 439;
  37697. t.Omega = 768;
  37698. t.Xi = 645;
  37699. t.Psi = 795;
  37700. t.Zeta = 611;
  37701. t.bracketleft = 333;
  37702. t.therefore = 863;
  37703. t.bracketright = 333;
  37704. t.perpendicular = 658;
  37705. t.underscore = 500;
  37706. t.radicalex = 500;
  37707. t.alpha = 631;
  37708. t.beta = 549;
  37709. t.chi = 549;
  37710. t.delta = 494;
  37711. t.epsilon = 439;
  37712. t.phi = 521;
  37713. t.gamma = 411;
  37714. t.eta = 603;
  37715. t.iota = 329;
  37716. t.phi1 = 603;
  37717. t.kappa = 549;
  37718. t.lambda = 549;
  37719. t.mu = 576;
  37720. t.nu = 521;
  37721. t.omicron = 549;
  37722. t.pi = 549;
  37723. t.theta = 521;
  37724. t.rho = 549;
  37725. t.sigma = 603;
  37726. t.tau = 439;
  37727. t.upsilon = 576;
  37728. t.omega1 = 713;
  37729. t.omega = 686;
  37730. t.xi = 493;
  37731. t.psi = 686;
  37732. t.zeta = 494;
  37733. t.braceleft = 480;
  37734. t.bar = 200;
  37735. t.braceright = 480;
  37736. t.similar = 549;
  37737. t.Euro = 750;
  37738. t.Upsilon1 = 620;
  37739. t.minute = 247;
  37740. t.lessequal = 549;
  37741. t.fraction = 167;
  37742. t.infinity = 713;
  37743. t.florin = 500;
  37744. t.club = 753;
  37745. t.diamond = 753;
  37746. t.heart = 753;
  37747. t.spade = 753;
  37748. t.arrowboth = 1042;
  37749. t.arrowleft = 987;
  37750. t.arrowup = 603;
  37751. t.arrowright = 987;
  37752. t.arrowdown = 603;
  37753. t.degree = 400;
  37754. t.plusminus = 549;
  37755. t.second = 411;
  37756. t.greaterequal = 549;
  37757. t.multiply = 549;
  37758. t.proportional = 713;
  37759. t.partialdiff = 494;
  37760. t.bullet = 460;
  37761. t.divide = 549;
  37762. t.notequal = 549;
  37763. t.equivalence = 549;
  37764. t.approxequal = 549;
  37765. t.ellipsis = 1000;
  37766. t.arrowvertex = 603;
  37767. t.arrowhorizex = 1000;
  37768. t.carriagereturn = 658;
  37769. t.aleph = 823;
  37770. t.Ifraktur = 686;
  37771. t.Rfraktur = 795;
  37772. t.weierstrass = 987;
  37773. t.circlemultiply = 768;
  37774. t.circleplus = 768;
  37775. t.emptyset = 823;
  37776. t.intersection = 768;
  37777. t.union = 768;
  37778. t.propersuperset = 713;
  37779. t.reflexsuperset = 713;
  37780. t.notsubset = 713;
  37781. t.propersubset = 713;
  37782. t.reflexsubset = 713;
  37783. t.element = 713;
  37784. t.notelement = 713;
  37785. t.angle = 768;
  37786. t.gradient = 713;
  37787. t.registerserif = 790;
  37788. t.copyrightserif = 790;
  37789. t.trademarkserif = 890;
  37790. t.product = 823;
  37791. t.radical = 549;
  37792. t.dotmath = 250;
  37793. t.logicalnot = 713;
  37794. t.logicaland = 603;
  37795. t.logicalor = 603;
  37796. t.arrowdblboth = 1042;
  37797. t.arrowdblleft = 987;
  37798. t.arrowdblup = 603;
  37799. t.arrowdblright = 987;
  37800. t.arrowdbldown = 603;
  37801. t.lozenge = 494;
  37802. t.angleleft = 329;
  37803. t.registersans = 790;
  37804. t.copyrightsans = 790;
  37805. t.trademarksans = 786;
  37806. t.summation = 713;
  37807. t.parenlefttp = 384;
  37808. t.parenleftex = 384;
  37809. t.parenleftbt = 384;
  37810. t.bracketlefttp = 384;
  37811. t.bracketleftex = 384;
  37812. t.bracketleftbt = 384;
  37813. t.bracelefttp = 494;
  37814. t.braceleftmid = 494;
  37815. t.braceleftbt = 494;
  37816. t.braceex = 494;
  37817. t.angleright = 329;
  37818. t.integral = 274;
  37819. t.integraltp = 686;
  37820. t.integralex = 686;
  37821. t.integralbt = 686;
  37822. t.parenrighttp = 384;
  37823. t.parenrightex = 384;
  37824. t.parenrightbt = 384;
  37825. t.bracketrighttp = 384;
  37826. t.bracketrightex = 384;
  37827. t.bracketrightbt = 384;
  37828. t.bracerighttp = 494;
  37829. t.bracerightmid = 494;
  37830. t.bracerightbt = 494;
  37831. t.apple = 790;
  37832. });
  37833. t["Times-Roman"] = (0, _core_utils.getLookupTableFactory)(function (t) {
  37834. t.space = 250;
  37835. t.exclam = 333;
  37836. t.quotedbl = 408;
  37837. t.numbersign = 500;
  37838. t.dollar = 500;
  37839. t.percent = 833;
  37840. t.ampersand = 778;
  37841. t.quoteright = 333;
  37842. t.parenleft = 333;
  37843. t.parenright = 333;
  37844. t.asterisk = 500;
  37845. t.plus = 564;
  37846. t.comma = 250;
  37847. t.hyphen = 333;
  37848. t.period = 250;
  37849. t.slash = 278;
  37850. t.zero = 500;
  37851. t.one = 500;
  37852. t.two = 500;
  37853. t.three = 500;
  37854. t.four = 500;
  37855. t.five = 500;
  37856. t.six = 500;
  37857. t.seven = 500;
  37858. t.eight = 500;
  37859. t.nine = 500;
  37860. t.colon = 278;
  37861. t.semicolon = 278;
  37862. t.less = 564;
  37863. t.equal = 564;
  37864. t.greater = 564;
  37865. t.question = 444;
  37866. t.at = 921;
  37867. t.A = 722;
  37868. t.B = 667;
  37869. t.C = 667;
  37870. t.D = 722;
  37871. t.E = 611;
  37872. t.F = 556;
  37873. t.G = 722;
  37874. t.H = 722;
  37875. t.I = 333;
  37876. t.J = 389;
  37877. t.K = 722;
  37878. t.L = 611;
  37879. t.M = 889;
  37880. t.N = 722;
  37881. t.O = 722;
  37882. t.P = 556;
  37883. t.Q = 722;
  37884. t.R = 667;
  37885. t.S = 556;
  37886. t.T = 611;
  37887. t.U = 722;
  37888. t.V = 722;
  37889. t.W = 944;
  37890. t.X = 722;
  37891. t.Y = 722;
  37892. t.Z = 611;
  37893. t.bracketleft = 333;
  37894. t.backslash = 278;
  37895. t.bracketright = 333;
  37896. t.asciicircum = 469;
  37897. t.underscore = 500;
  37898. t.quoteleft = 333;
  37899. t.a = 444;
  37900. t.b = 500;
  37901. t.c = 444;
  37902. t.d = 500;
  37903. t.e = 444;
  37904. t.f = 333;
  37905. t.g = 500;
  37906. t.h = 500;
  37907. t.i = 278;
  37908. t.j = 278;
  37909. t.k = 500;
  37910. t.l = 278;
  37911. t.m = 778;
  37912. t.n = 500;
  37913. t.o = 500;
  37914. t.p = 500;
  37915. t.q = 500;
  37916. t.r = 333;
  37917. t.s = 389;
  37918. t.t = 278;
  37919. t.u = 500;
  37920. t.v = 500;
  37921. t.w = 722;
  37922. t.x = 500;
  37923. t.y = 500;
  37924. t.z = 444;
  37925. t.braceleft = 480;
  37926. t.bar = 200;
  37927. t.braceright = 480;
  37928. t.asciitilde = 541;
  37929. t.exclamdown = 333;
  37930. t.cent = 500;
  37931. t.sterling = 500;
  37932. t.fraction = 167;
  37933. t.yen = 500;
  37934. t.florin = 500;
  37935. t.section = 500;
  37936. t.currency = 500;
  37937. t.quotesingle = 180;
  37938. t.quotedblleft = 444;
  37939. t.guillemotleft = 500;
  37940. t.guilsinglleft = 333;
  37941. t.guilsinglright = 333;
  37942. t.fi = 556;
  37943. t.fl = 556;
  37944. t.endash = 500;
  37945. t.dagger = 500;
  37946. t.daggerdbl = 500;
  37947. t.periodcentered = 250;
  37948. t.paragraph = 453;
  37949. t.bullet = 350;
  37950. t.quotesinglbase = 333;
  37951. t.quotedblbase = 444;
  37952. t.quotedblright = 444;
  37953. t.guillemotright = 500;
  37954. t.ellipsis = 1000;
  37955. t.perthousand = 1000;
  37956. t.questiondown = 444;
  37957. t.grave = 333;
  37958. t.acute = 333;
  37959. t.circumflex = 333;
  37960. t.tilde = 333;
  37961. t.macron = 333;
  37962. t.breve = 333;
  37963. t.dotaccent = 333;
  37964. t.dieresis = 333;
  37965. t.ring = 333;
  37966. t.cedilla = 333;
  37967. t.hungarumlaut = 333;
  37968. t.ogonek = 333;
  37969. t.caron = 333;
  37970. t.emdash = 1000;
  37971. t.AE = 889;
  37972. t.ordfeminine = 276;
  37973. t.Lslash = 611;
  37974. t.Oslash = 722;
  37975. t.OE = 889;
  37976. t.ordmasculine = 310;
  37977. t.ae = 667;
  37978. t.dotlessi = 278;
  37979. t.lslash = 278;
  37980. t.oslash = 500;
  37981. t.oe = 722;
  37982. t.germandbls = 500;
  37983. t.Idieresis = 333;
  37984. t.eacute = 444;
  37985. t.abreve = 444;
  37986. t.uhungarumlaut = 500;
  37987. t.ecaron = 444;
  37988. t.Ydieresis = 722;
  37989. t.divide = 564;
  37990. t.Yacute = 722;
  37991. t.Acircumflex = 722;
  37992. t.aacute = 444;
  37993. t.Ucircumflex = 722;
  37994. t.yacute = 500;
  37995. t.scommaaccent = 389;
  37996. t.ecircumflex = 444;
  37997. t.Uring = 722;
  37998. t.Udieresis = 722;
  37999. t.aogonek = 444;
  38000. t.Uacute = 722;
  38001. t.uogonek = 500;
  38002. t.Edieresis = 611;
  38003. t.Dcroat = 722;
  38004. t.commaaccent = 250;
  38005. t.copyright = 760;
  38006. t.Emacron = 611;
  38007. t.ccaron = 444;
  38008. t.aring = 444;
  38009. t.Ncommaaccent = 722;
  38010. t.lacute = 278;
  38011. t.agrave = 444;
  38012. t.Tcommaaccent = 611;
  38013. t.Cacute = 667;
  38014. t.atilde = 444;
  38015. t.Edotaccent = 611;
  38016. t.scaron = 389;
  38017. t.scedilla = 389;
  38018. t.iacute = 278;
  38019. t.lozenge = 471;
  38020. t.Rcaron = 667;
  38021. t.Gcommaaccent = 722;
  38022. t.ucircumflex = 500;
  38023. t.acircumflex = 444;
  38024. t.Amacron = 722;
  38025. t.rcaron = 333;
  38026. t.ccedilla = 444;
  38027. t.Zdotaccent = 611;
  38028. t.Thorn = 556;
  38029. t.Omacron = 722;
  38030. t.Racute = 667;
  38031. t.Sacute = 556;
  38032. t.dcaron = 588;
  38033. t.Umacron = 722;
  38034. t.uring = 500;
  38035. t.threesuperior = 300;
  38036. t.Ograve = 722;
  38037. t.Agrave = 722;
  38038. t.Abreve = 722;
  38039. t.multiply = 564;
  38040. t.uacute = 500;
  38041. t.Tcaron = 611;
  38042. t.partialdiff = 476;
  38043. t.ydieresis = 500;
  38044. t.Nacute = 722;
  38045. t.icircumflex = 278;
  38046. t.Ecircumflex = 611;
  38047. t.adieresis = 444;
  38048. t.edieresis = 444;
  38049. t.cacute = 444;
  38050. t.nacute = 500;
  38051. t.umacron = 500;
  38052. t.Ncaron = 722;
  38053. t.Iacute = 333;
  38054. t.plusminus = 564;
  38055. t.brokenbar = 200;
  38056. t.registered = 760;
  38057. t.Gbreve = 722;
  38058. t.Idotaccent = 333;
  38059. t.summation = 600;
  38060. t.Egrave = 611;
  38061. t.racute = 333;
  38062. t.omacron = 500;
  38063. t.Zacute = 611;
  38064. t.Zcaron = 611;
  38065. t.greaterequal = 549;
  38066. t.Eth = 722;
  38067. t.Ccedilla = 667;
  38068. t.lcommaaccent = 278;
  38069. t.tcaron = 326;
  38070. t.eogonek = 444;
  38071. t.Uogonek = 722;
  38072. t.Aacute = 722;
  38073. t.Adieresis = 722;
  38074. t.egrave = 444;
  38075. t.zacute = 444;
  38076. t.iogonek = 278;
  38077. t.Oacute = 722;
  38078. t.oacute = 500;
  38079. t.amacron = 444;
  38080. t.sacute = 389;
  38081. t.idieresis = 278;
  38082. t.Ocircumflex = 722;
  38083. t.Ugrave = 722;
  38084. t.Delta = 612;
  38085. t.thorn = 500;
  38086. t.twosuperior = 300;
  38087. t.Odieresis = 722;
  38088. t.mu = 500;
  38089. t.igrave = 278;
  38090. t.ohungarumlaut = 500;
  38091. t.Eogonek = 611;
  38092. t.dcroat = 500;
  38093. t.threequarters = 750;
  38094. t.Scedilla = 556;
  38095. t.lcaron = 344;
  38096. t.Kcommaaccent = 722;
  38097. t.Lacute = 611;
  38098. t.trademark = 980;
  38099. t.edotaccent = 444;
  38100. t.Igrave = 333;
  38101. t.Imacron = 333;
  38102. t.Lcaron = 611;
  38103. t.onehalf = 750;
  38104. t.lessequal = 549;
  38105. t.ocircumflex = 500;
  38106. t.ntilde = 500;
  38107. t.Uhungarumlaut = 722;
  38108. t.Eacute = 611;
  38109. t.emacron = 444;
  38110. t.gbreve = 500;
  38111. t.onequarter = 750;
  38112. t.Scaron = 556;
  38113. t.Scommaaccent = 556;
  38114. t.Ohungarumlaut = 722;
  38115. t.degree = 400;
  38116. t.ograve = 500;
  38117. t.Ccaron = 667;
  38118. t.ugrave = 500;
  38119. t.radical = 453;
  38120. t.Dcaron = 722;
  38121. t.rcommaaccent = 333;
  38122. t.Ntilde = 722;
  38123. t.otilde = 500;
  38124. t.Rcommaaccent = 667;
  38125. t.Lcommaaccent = 611;
  38126. t.Atilde = 722;
  38127. t.Aogonek = 722;
  38128. t.Aring = 722;
  38129. t.Otilde = 722;
  38130. t.zdotaccent = 444;
  38131. t.Ecaron = 611;
  38132. t.Iogonek = 333;
  38133. t.kcommaaccent = 500;
  38134. t.minus = 564;
  38135. t.Icircumflex = 333;
  38136. t.ncaron = 500;
  38137. t.tcommaaccent = 278;
  38138. t.logicalnot = 564;
  38139. t.odieresis = 500;
  38140. t.udieresis = 500;
  38141. t.notequal = 549;
  38142. t.gcommaaccent = 500;
  38143. t.eth = 500;
  38144. t.zcaron = 444;
  38145. t.ncommaaccent = 500;
  38146. t.onesuperior = 300;
  38147. t.imacron = 278;
  38148. t.Euro = 500;
  38149. });
  38150. t["Times-Bold"] = (0, _core_utils.getLookupTableFactory)(function (t) {
  38151. t.space = 250;
  38152. t.exclam = 333;
  38153. t.quotedbl = 555;
  38154. t.numbersign = 500;
  38155. t.dollar = 500;
  38156. t.percent = 1000;
  38157. t.ampersand = 833;
  38158. t.quoteright = 333;
  38159. t.parenleft = 333;
  38160. t.parenright = 333;
  38161. t.asterisk = 500;
  38162. t.plus = 570;
  38163. t.comma = 250;
  38164. t.hyphen = 333;
  38165. t.period = 250;
  38166. t.slash = 278;
  38167. t.zero = 500;
  38168. t.one = 500;
  38169. t.two = 500;
  38170. t.three = 500;
  38171. t.four = 500;
  38172. t.five = 500;
  38173. t.six = 500;
  38174. t.seven = 500;
  38175. t.eight = 500;
  38176. t.nine = 500;
  38177. t.colon = 333;
  38178. t.semicolon = 333;
  38179. t.less = 570;
  38180. t.equal = 570;
  38181. t.greater = 570;
  38182. t.question = 500;
  38183. t.at = 930;
  38184. t.A = 722;
  38185. t.B = 667;
  38186. t.C = 722;
  38187. t.D = 722;
  38188. t.E = 667;
  38189. t.F = 611;
  38190. t.G = 778;
  38191. t.H = 778;
  38192. t.I = 389;
  38193. t.J = 500;
  38194. t.K = 778;
  38195. t.L = 667;
  38196. t.M = 944;
  38197. t.N = 722;
  38198. t.O = 778;
  38199. t.P = 611;
  38200. t.Q = 778;
  38201. t.R = 722;
  38202. t.S = 556;
  38203. t.T = 667;
  38204. t.U = 722;
  38205. t.V = 722;
  38206. t.W = 1000;
  38207. t.X = 722;
  38208. t.Y = 722;
  38209. t.Z = 667;
  38210. t.bracketleft = 333;
  38211. t.backslash = 278;
  38212. t.bracketright = 333;
  38213. t.asciicircum = 581;
  38214. t.underscore = 500;
  38215. t.quoteleft = 333;
  38216. t.a = 500;
  38217. t.b = 556;
  38218. t.c = 444;
  38219. t.d = 556;
  38220. t.e = 444;
  38221. t.f = 333;
  38222. t.g = 500;
  38223. t.h = 556;
  38224. t.i = 278;
  38225. t.j = 333;
  38226. t.k = 556;
  38227. t.l = 278;
  38228. t.m = 833;
  38229. t.n = 556;
  38230. t.o = 500;
  38231. t.p = 556;
  38232. t.q = 556;
  38233. t.r = 444;
  38234. t.s = 389;
  38235. t.t = 333;
  38236. t.u = 556;
  38237. t.v = 500;
  38238. t.w = 722;
  38239. t.x = 500;
  38240. t.y = 500;
  38241. t.z = 444;
  38242. t.braceleft = 394;
  38243. t.bar = 220;
  38244. t.braceright = 394;
  38245. t.asciitilde = 520;
  38246. t.exclamdown = 333;
  38247. t.cent = 500;
  38248. t.sterling = 500;
  38249. t.fraction = 167;
  38250. t.yen = 500;
  38251. t.florin = 500;
  38252. t.section = 500;
  38253. t.currency = 500;
  38254. t.quotesingle = 278;
  38255. t.quotedblleft = 500;
  38256. t.guillemotleft = 500;
  38257. t.guilsinglleft = 333;
  38258. t.guilsinglright = 333;
  38259. t.fi = 556;
  38260. t.fl = 556;
  38261. t.endash = 500;
  38262. t.dagger = 500;
  38263. t.daggerdbl = 500;
  38264. t.periodcentered = 250;
  38265. t.paragraph = 540;
  38266. t.bullet = 350;
  38267. t.quotesinglbase = 333;
  38268. t.quotedblbase = 500;
  38269. t.quotedblright = 500;
  38270. t.guillemotright = 500;
  38271. t.ellipsis = 1000;
  38272. t.perthousand = 1000;
  38273. t.questiondown = 500;
  38274. t.grave = 333;
  38275. t.acute = 333;
  38276. t.circumflex = 333;
  38277. t.tilde = 333;
  38278. t.macron = 333;
  38279. t.breve = 333;
  38280. t.dotaccent = 333;
  38281. t.dieresis = 333;
  38282. t.ring = 333;
  38283. t.cedilla = 333;
  38284. t.hungarumlaut = 333;
  38285. t.ogonek = 333;
  38286. t.caron = 333;
  38287. t.emdash = 1000;
  38288. t.AE = 1000;
  38289. t.ordfeminine = 300;
  38290. t.Lslash = 667;
  38291. t.Oslash = 778;
  38292. t.OE = 1000;
  38293. t.ordmasculine = 330;
  38294. t.ae = 722;
  38295. t.dotlessi = 278;
  38296. t.lslash = 278;
  38297. t.oslash = 500;
  38298. t.oe = 722;
  38299. t.germandbls = 556;
  38300. t.Idieresis = 389;
  38301. t.eacute = 444;
  38302. t.abreve = 500;
  38303. t.uhungarumlaut = 556;
  38304. t.ecaron = 444;
  38305. t.Ydieresis = 722;
  38306. t.divide = 570;
  38307. t.Yacute = 722;
  38308. t.Acircumflex = 722;
  38309. t.aacute = 500;
  38310. t.Ucircumflex = 722;
  38311. t.yacute = 500;
  38312. t.scommaaccent = 389;
  38313. t.ecircumflex = 444;
  38314. t.Uring = 722;
  38315. t.Udieresis = 722;
  38316. t.aogonek = 500;
  38317. t.Uacute = 722;
  38318. t.uogonek = 556;
  38319. t.Edieresis = 667;
  38320. t.Dcroat = 722;
  38321. t.commaaccent = 250;
  38322. t.copyright = 747;
  38323. t.Emacron = 667;
  38324. t.ccaron = 444;
  38325. t.aring = 500;
  38326. t.Ncommaaccent = 722;
  38327. t.lacute = 278;
  38328. t.agrave = 500;
  38329. t.Tcommaaccent = 667;
  38330. t.Cacute = 722;
  38331. t.atilde = 500;
  38332. t.Edotaccent = 667;
  38333. t.scaron = 389;
  38334. t.scedilla = 389;
  38335. t.iacute = 278;
  38336. t.lozenge = 494;
  38337. t.Rcaron = 722;
  38338. t.Gcommaaccent = 778;
  38339. t.ucircumflex = 556;
  38340. t.acircumflex = 500;
  38341. t.Amacron = 722;
  38342. t.rcaron = 444;
  38343. t.ccedilla = 444;
  38344. t.Zdotaccent = 667;
  38345. t.Thorn = 611;
  38346. t.Omacron = 778;
  38347. t.Racute = 722;
  38348. t.Sacute = 556;
  38349. t.dcaron = 672;
  38350. t.Umacron = 722;
  38351. t.uring = 556;
  38352. t.threesuperior = 300;
  38353. t.Ograve = 778;
  38354. t.Agrave = 722;
  38355. t.Abreve = 722;
  38356. t.multiply = 570;
  38357. t.uacute = 556;
  38358. t.Tcaron = 667;
  38359. t.partialdiff = 494;
  38360. t.ydieresis = 500;
  38361. t.Nacute = 722;
  38362. t.icircumflex = 278;
  38363. t.Ecircumflex = 667;
  38364. t.adieresis = 500;
  38365. t.edieresis = 444;
  38366. t.cacute = 444;
  38367. t.nacute = 556;
  38368. t.umacron = 556;
  38369. t.Ncaron = 722;
  38370. t.Iacute = 389;
  38371. t.plusminus = 570;
  38372. t.brokenbar = 220;
  38373. t.registered = 747;
  38374. t.Gbreve = 778;
  38375. t.Idotaccent = 389;
  38376. t.summation = 600;
  38377. t.Egrave = 667;
  38378. t.racute = 444;
  38379. t.omacron = 500;
  38380. t.Zacute = 667;
  38381. t.Zcaron = 667;
  38382. t.greaterequal = 549;
  38383. t.Eth = 722;
  38384. t.Ccedilla = 722;
  38385. t.lcommaaccent = 278;
  38386. t.tcaron = 416;
  38387. t.eogonek = 444;
  38388. t.Uogonek = 722;
  38389. t.Aacute = 722;
  38390. t.Adieresis = 722;
  38391. t.egrave = 444;
  38392. t.zacute = 444;
  38393. t.iogonek = 278;
  38394. t.Oacute = 778;
  38395. t.oacute = 500;
  38396. t.amacron = 500;
  38397. t.sacute = 389;
  38398. t.idieresis = 278;
  38399. t.Ocircumflex = 778;
  38400. t.Ugrave = 722;
  38401. t.Delta = 612;
  38402. t.thorn = 556;
  38403. t.twosuperior = 300;
  38404. t.Odieresis = 778;
  38405. t.mu = 556;
  38406. t.igrave = 278;
  38407. t.ohungarumlaut = 500;
  38408. t.Eogonek = 667;
  38409. t.dcroat = 556;
  38410. t.threequarters = 750;
  38411. t.Scedilla = 556;
  38412. t.lcaron = 394;
  38413. t.Kcommaaccent = 778;
  38414. t.Lacute = 667;
  38415. t.trademark = 1000;
  38416. t.edotaccent = 444;
  38417. t.Igrave = 389;
  38418. t.Imacron = 389;
  38419. t.Lcaron = 667;
  38420. t.onehalf = 750;
  38421. t.lessequal = 549;
  38422. t.ocircumflex = 500;
  38423. t.ntilde = 556;
  38424. t.Uhungarumlaut = 722;
  38425. t.Eacute = 667;
  38426. t.emacron = 444;
  38427. t.gbreve = 500;
  38428. t.onequarter = 750;
  38429. t.Scaron = 556;
  38430. t.Scommaaccent = 556;
  38431. t.Ohungarumlaut = 778;
  38432. t.degree = 400;
  38433. t.ograve = 500;
  38434. t.Ccaron = 722;
  38435. t.ugrave = 556;
  38436. t.radical = 549;
  38437. t.Dcaron = 722;
  38438. t.rcommaaccent = 444;
  38439. t.Ntilde = 722;
  38440. t.otilde = 500;
  38441. t.Rcommaaccent = 722;
  38442. t.Lcommaaccent = 667;
  38443. t.Atilde = 722;
  38444. t.Aogonek = 722;
  38445. t.Aring = 722;
  38446. t.Otilde = 778;
  38447. t.zdotaccent = 444;
  38448. t.Ecaron = 667;
  38449. t.Iogonek = 389;
  38450. t.kcommaaccent = 556;
  38451. t.minus = 570;
  38452. t.Icircumflex = 389;
  38453. t.ncaron = 556;
  38454. t.tcommaaccent = 333;
  38455. t.logicalnot = 570;
  38456. t.odieresis = 500;
  38457. t.udieresis = 556;
  38458. t.notequal = 549;
  38459. t.gcommaaccent = 500;
  38460. t.eth = 500;
  38461. t.zcaron = 444;
  38462. t.ncommaaccent = 556;
  38463. t.onesuperior = 300;
  38464. t.imacron = 278;
  38465. t.Euro = 500;
  38466. });
  38467. t["Times-BoldItalic"] = (0, _core_utils.getLookupTableFactory)(function (t) {
  38468. t.space = 250;
  38469. t.exclam = 389;
  38470. t.quotedbl = 555;
  38471. t.numbersign = 500;
  38472. t.dollar = 500;
  38473. t.percent = 833;
  38474. t.ampersand = 778;
  38475. t.quoteright = 333;
  38476. t.parenleft = 333;
  38477. t.parenright = 333;
  38478. t.asterisk = 500;
  38479. t.plus = 570;
  38480. t.comma = 250;
  38481. t.hyphen = 333;
  38482. t.period = 250;
  38483. t.slash = 278;
  38484. t.zero = 500;
  38485. t.one = 500;
  38486. t.two = 500;
  38487. t.three = 500;
  38488. t.four = 500;
  38489. t.five = 500;
  38490. t.six = 500;
  38491. t.seven = 500;
  38492. t.eight = 500;
  38493. t.nine = 500;
  38494. t.colon = 333;
  38495. t.semicolon = 333;
  38496. t.less = 570;
  38497. t.equal = 570;
  38498. t.greater = 570;
  38499. t.question = 500;
  38500. t.at = 832;
  38501. t.A = 667;
  38502. t.B = 667;
  38503. t.C = 667;
  38504. t.D = 722;
  38505. t.E = 667;
  38506. t.F = 667;
  38507. t.G = 722;
  38508. t.H = 778;
  38509. t.I = 389;
  38510. t.J = 500;
  38511. t.K = 667;
  38512. t.L = 611;
  38513. t.M = 889;
  38514. t.N = 722;
  38515. t.O = 722;
  38516. t.P = 611;
  38517. t.Q = 722;
  38518. t.R = 667;
  38519. t.S = 556;
  38520. t.T = 611;
  38521. t.U = 722;
  38522. t.V = 667;
  38523. t.W = 889;
  38524. t.X = 667;
  38525. t.Y = 611;
  38526. t.Z = 611;
  38527. t.bracketleft = 333;
  38528. t.backslash = 278;
  38529. t.bracketright = 333;
  38530. t.asciicircum = 570;
  38531. t.underscore = 500;
  38532. t.quoteleft = 333;
  38533. t.a = 500;
  38534. t.b = 500;
  38535. t.c = 444;
  38536. t.d = 500;
  38537. t.e = 444;
  38538. t.f = 333;
  38539. t.g = 500;
  38540. t.h = 556;
  38541. t.i = 278;
  38542. t.j = 278;
  38543. t.k = 500;
  38544. t.l = 278;
  38545. t.m = 778;
  38546. t.n = 556;
  38547. t.o = 500;
  38548. t.p = 500;
  38549. t.q = 500;
  38550. t.r = 389;
  38551. t.s = 389;
  38552. t.t = 278;
  38553. t.u = 556;
  38554. t.v = 444;
  38555. t.w = 667;
  38556. t.x = 500;
  38557. t.y = 444;
  38558. t.z = 389;
  38559. t.braceleft = 348;
  38560. t.bar = 220;
  38561. t.braceright = 348;
  38562. t.asciitilde = 570;
  38563. t.exclamdown = 389;
  38564. t.cent = 500;
  38565. t.sterling = 500;
  38566. t.fraction = 167;
  38567. t.yen = 500;
  38568. t.florin = 500;
  38569. t.section = 500;
  38570. t.currency = 500;
  38571. t.quotesingle = 278;
  38572. t.quotedblleft = 500;
  38573. t.guillemotleft = 500;
  38574. t.guilsinglleft = 333;
  38575. t.guilsinglright = 333;
  38576. t.fi = 556;
  38577. t.fl = 556;
  38578. t.endash = 500;
  38579. t.dagger = 500;
  38580. t.daggerdbl = 500;
  38581. t.periodcentered = 250;
  38582. t.paragraph = 500;
  38583. t.bullet = 350;
  38584. t.quotesinglbase = 333;
  38585. t.quotedblbase = 500;
  38586. t.quotedblright = 500;
  38587. t.guillemotright = 500;
  38588. t.ellipsis = 1000;
  38589. t.perthousand = 1000;
  38590. t.questiondown = 500;
  38591. t.grave = 333;
  38592. t.acute = 333;
  38593. t.circumflex = 333;
  38594. t.tilde = 333;
  38595. t.macron = 333;
  38596. t.breve = 333;
  38597. t.dotaccent = 333;
  38598. t.dieresis = 333;
  38599. t.ring = 333;
  38600. t.cedilla = 333;
  38601. t.hungarumlaut = 333;
  38602. t.ogonek = 333;
  38603. t.caron = 333;
  38604. t.emdash = 1000;
  38605. t.AE = 944;
  38606. t.ordfeminine = 266;
  38607. t.Lslash = 611;
  38608. t.Oslash = 722;
  38609. t.OE = 944;
  38610. t.ordmasculine = 300;
  38611. t.ae = 722;
  38612. t.dotlessi = 278;
  38613. t.lslash = 278;
  38614. t.oslash = 500;
  38615. t.oe = 722;
  38616. t.germandbls = 500;
  38617. t.Idieresis = 389;
  38618. t.eacute = 444;
  38619. t.abreve = 500;
  38620. t.uhungarumlaut = 556;
  38621. t.ecaron = 444;
  38622. t.Ydieresis = 611;
  38623. t.divide = 570;
  38624. t.Yacute = 611;
  38625. t.Acircumflex = 667;
  38626. t.aacute = 500;
  38627. t.Ucircumflex = 722;
  38628. t.yacute = 444;
  38629. t.scommaaccent = 389;
  38630. t.ecircumflex = 444;
  38631. t.Uring = 722;
  38632. t.Udieresis = 722;
  38633. t.aogonek = 500;
  38634. t.Uacute = 722;
  38635. t.uogonek = 556;
  38636. t.Edieresis = 667;
  38637. t.Dcroat = 722;
  38638. t.commaaccent = 250;
  38639. t.copyright = 747;
  38640. t.Emacron = 667;
  38641. t.ccaron = 444;
  38642. t.aring = 500;
  38643. t.Ncommaaccent = 722;
  38644. t.lacute = 278;
  38645. t.agrave = 500;
  38646. t.Tcommaaccent = 611;
  38647. t.Cacute = 667;
  38648. t.atilde = 500;
  38649. t.Edotaccent = 667;
  38650. t.scaron = 389;
  38651. t.scedilla = 389;
  38652. t.iacute = 278;
  38653. t.lozenge = 494;
  38654. t.Rcaron = 667;
  38655. t.Gcommaaccent = 722;
  38656. t.ucircumflex = 556;
  38657. t.acircumflex = 500;
  38658. t.Amacron = 667;
  38659. t.rcaron = 389;
  38660. t.ccedilla = 444;
  38661. t.Zdotaccent = 611;
  38662. t.Thorn = 611;
  38663. t.Omacron = 722;
  38664. t.Racute = 667;
  38665. t.Sacute = 556;
  38666. t.dcaron = 608;
  38667. t.Umacron = 722;
  38668. t.uring = 556;
  38669. t.threesuperior = 300;
  38670. t.Ograve = 722;
  38671. t.Agrave = 667;
  38672. t.Abreve = 667;
  38673. t.multiply = 570;
  38674. t.uacute = 556;
  38675. t.Tcaron = 611;
  38676. t.partialdiff = 494;
  38677. t.ydieresis = 444;
  38678. t.Nacute = 722;
  38679. t.icircumflex = 278;
  38680. t.Ecircumflex = 667;
  38681. t.adieresis = 500;
  38682. t.edieresis = 444;
  38683. t.cacute = 444;
  38684. t.nacute = 556;
  38685. t.umacron = 556;
  38686. t.Ncaron = 722;
  38687. t.Iacute = 389;
  38688. t.plusminus = 570;
  38689. t.brokenbar = 220;
  38690. t.registered = 747;
  38691. t.Gbreve = 722;
  38692. t.Idotaccent = 389;
  38693. t.summation = 600;
  38694. t.Egrave = 667;
  38695. t.racute = 389;
  38696. t.omacron = 500;
  38697. t.Zacute = 611;
  38698. t.Zcaron = 611;
  38699. t.greaterequal = 549;
  38700. t.Eth = 722;
  38701. t.Ccedilla = 667;
  38702. t.lcommaaccent = 278;
  38703. t.tcaron = 366;
  38704. t.eogonek = 444;
  38705. t.Uogonek = 722;
  38706. t.Aacute = 667;
  38707. t.Adieresis = 667;
  38708. t.egrave = 444;
  38709. t.zacute = 389;
  38710. t.iogonek = 278;
  38711. t.Oacute = 722;
  38712. t.oacute = 500;
  38713. t.amacron = 500;
  38714. t.sacute = 389;
  38715. t.idieresis = 278;
  38716. t.Ocircumflex = 722;
  38717. t.Ugrave = 722;
  38718. t.Delta = 612;
  38719. t.thorn = 500;
  38720. t.twosuperior = 300;
  38721. t.Odieresis = 722;
  38722. t.mu = 576;
  38723. t.igrave = 278;
  38724. t.ohungarumlaut = 500;
  38725. t.Eogonek = 667;
  38726. t.dcroat = 500;
  38727. t.threequarters = 750;
  38728. t.Scedilla = 556;
  38729. t.lcaron = 382;
  38730. t.Kcommaaccent = 667;
  38731. t.Lacute = 611;
  38732. t.trademark = 1000;
  38733. t.edotaccent = 444;
  38734. t.Igrave = 389;
  38735. t.Imacron = 389;
  38736. t.Lcaron = 611;
  38737. t.onehalf = 750;
  38738. t.lessequal = 549;
  38739. t.ocircumflex = 500;
  38740. t.ntilde = 556;
  38741. t.Uhungarumlaut = 722;
  38742. t.Eacute = 667;
  38743. t.emacron = 444;
  38744. t.gbreve = 500;
  38745. t.onequarter = 750;
  38746. t.Scaron = 556;
  38747. t.Scommaaccent = 556;
  38748. t.Ohungarumlaut = 722;
  38749. t.degree = 400;
  38750. t.ograve = 500;
  38751. t.Ccaron = 667;
  38752. t.ugrave = 556;
  38753. t.radical = 549;
  38754. t.Dcaron = 722;
  38755. t.rcommaaccent = 389;
  38756. t.Ntilde = 722;
  38757. t.otilde = 500;
  38758. t.Rcommaaccent = 667;
  38759. t.Lcommaaccent = 611;
  38760. t.Atilde = 667;
  38761. t.Aogonek = 667;
  38762. t.Aring = 667;
  38763. t.Otilde = 722;
  38764. t.zdotaccent = 389;
  38765. t.Ecaron = 667;
  38766. t.Iogonek = 389;
  38767. t.kcommaaccent = 500;
  38768. t.minus = 606;
  38769. t.Icircumflex = 389;
  38770. t.ncaron = 556;
  38771. t.tcommaaccent = 278;
  38772. t.logicalnot = 606;
  38773. t.odieresis = 500;
  38774. t.udieresis = 556;
  38775. t.notequal = 549;
  38776. t.gcommaaccent = 500;
  38777. t.eth = 500;
  38778. t.zcaron = 389;
  38779. t.ncommaaccent = 556;
  38780. t.onesuperior = 300;
  38781. t.imacron = 278;
  38782. t.Euro = 500;
  38783. });
  38784. t["Times-Italic"] = (0, _core_utils.getLookupTableFactory)(function (t) {
  38785. t.space = 250;
  38786. t.exclam = 333;
  38787. t.quotedbl = 420;
  38788. t.numbersign = 500;
  38789. t.dollar = 500;
  38790. t.percent = 833;
  38791. t.ampersand = 778;
  38792. t.quoteright = 333;
  38793. t.parenleft = 333;
  38794. t.parenright = 333;
  38795. t.asterisk = 500;
  38796. t.plus = 675;
  38797. t.comma = 250;
  38798. t.hyphen = 333;
  38799. t.period = 250;
  38800. t.slash = 278;
  38801. t.zero = 500;
  38802. t.one = 500;
  38803. t.two = 500;
  38804. t.three = 500;
  38805. t.four = 500;
  38806. t.five = 500;
  38807. t.six = 500;
  38808. t.seven = 500;
  38809. t.eight = 500;
  38810. t.nine = 500;
  38811. t.colon = 333;
  38812. t.semicolon = 333;
  38813. t.less = 675;
  38814. t.equal = 675;
  38815. t.greater = 675;
  38816. t.question = 500;
  38817. t.at = 920;
  38818. t.A = 611;
  38819. t.B = 611;
  38820. t.C = 667;
  38821. t.D = 722;
  38822. t.E = 611;
  38823. t.F = 611;
  38824. t.G = 722;
  38825. t.H = 722;
  38826. t.I = 333;
  38827. t.J = 444;
  38828. t.K = 667;
  38829. t.L = 556;
  38830. t.M = 833;
  38831. t.N = 667;
  38832. t.O = 722;
  38833. t.P = 611;
  38834. t.Q = 722;
  38835. t.R = 611;
  38836. t.S = 500;
  38837. t.T = 556;
  38838. t.U = 722;
  38839. t.V = 611;
  38840. t.W = 833;
  38841. t.X = 611;
  38842. t.Y = 556;
  38843. t.Z = 556;
  38844. t.bracketleft = 389;
  38845. t.backslash = 278;
  38846. t.bracketright = 389;
  38847. t.asciicircum = 422;
  38848. t.underscore = 500;
  38849. t.quoteleft = 333;
  38850. t.a = 500;
  38851. t.b = 500;
  38852. t.c = 444;
  38853. t.d = 500;
  38854. t.e = 444;
  38855. t.f = 278;
  38856. t.g = 500;
  38857. t.h = 500;
  38858. t.i = 278;
  38859. t.j = 278;
  38860. t.k = 444;
  38861. t.l = 278;
  38862. t.m = 722;
  38863. t.n = 500;
  38864. t.o = 500;
  38865. t.p = 500;
  38866. t.q = 500;
  38867. t.r = 389;
  38868. t.s = 389;
  38869. t.t = 278;
  38870. t.u = 500;
  38871. t.v = 444;
  38872. t.w = 667;
  38873. t.x = 444;
  38874. t.y = 444;
  38875. t.z = 389;
  38876. t.braceleft = 400;
  38877. t.bar = 275;
  38878. t.braceright = 400;
  38879. t.asciitilde = 541;
  38880. t.exclamdown = 389;
  38881. t.cent = 500;
  38882. t.sterling = 500;
  38883. t.fraction = 167;
  38884. t.yen = 500;
  38885. t.florin = 500;
  38886. t.section = 500;
  38887. t.currency = 500;
  38888. t.quotesingle = 214;
  38889. t.quotedblleft = 556;
  38890. t.guillemotleft = 500;
  38891. t.guilsinglleft = 333;
  38892. t.guilsinglright = 333;
  38893. t.fi = 500;
  38894. t.fl = 500;
  38895. t.endash = 500;
  38896. t.dagger = 500;
  38897. t.daggerdbl = 500;
  38898. t.periodcentered = 250;
  38899. t.paragraph = 523;
  38900. t.bullet = 350;
  38901. t.quotesinglbase = 333;
  38902. t.quotedblbase = 556;
  38903. t.quotedblright = 556;
  38904. t.guillemotright = 500;
  38905. t.ellipsis = 889;
  38906. t.perthousand = 1000;
  38907. t.questiondown = 500;
  38908. t.grave = 333;
  38909. t.acute = 333;
  38910. t.circumflex = 333;
  38911. t.tilde = 333;
  38912. t.macron = 333;
  38913. t.breve = 333;
  38914. t.dotaccent = 333;
  38915. t.dieresis = 333;
  38916. t.ring = 333;
  38917. t.cedilla = 333;
  38918. t.hungarumlaut = 333;
  38919. t.ogonek = 333;
  38920. t.caron = 333;
  38921. t.emdash = 889;
  38922. t.AE = 889;
  38923. t.ordfeminine = 276;
  38924. t.Lslash = 556;
  38925. t.Oslash = 722;
  38926. t.OE = 944;
  38927. t.ordmasculine = 310;
  38928. t.ae = 667;
  38929. t.dotlessi = 278;
  38930. t.lslash = 278;
  38931. t.oslash = 500;
  38932. t.oe = 667;
  38933. t.germandbls = 500;
  38934. t.Idieresis = 333;
  38935. t.eacute = 444;
  38936. t.abreve = 500;
  38937. t.uhungarumlaut = 500;
  38938. t.ecaron = 444;
  38939. t.Ydieresis = 556;
  38940. t.divide = 675;
  38941. t.Yacute = 556;
  38942. t.Acircumflex = 611;
  38943. t.aacute = 500;
  38944. t.Ucircumflex = 722;
  38945. t.yacute = 444;
  38946. t.scommaaccent = 389;
  38947. t.ecircumflex = 444;
  38948. t.Uring = 722;
  38949. t.Udieresis = 722;
  38950. t.aogonek = 500;
  38951. t.Uacute = 722;
  38952. t.uogonek = 500;
  38953. t.Edieresis = 611;
  38954. t.Dcroat = 722;
  38955. t.commaaccent = 250;
  38956. t.copyright = 760;
  38957. t.Emacron = 611;
  38958. t.ccaron = 444;
  38959. t.aring = 500;
  38960. t.Ncommaaccent = 667;
  38961. t.lacute = 278;
  38962. t.agrave = 500;
  38963. t.Tcommaaccent = 556;
  38964. t.Cacute = 667;
  38965. t.atilde = 500;
  38966. t.Edotaccent = 611;
  38967. t.scaron = 389;
  38968. t.scedilla = 389;
  38969. t.iacute = 278;
  38970. t.lozenge = 471;
  38971. t.Rcaron = 611;
  38972. t.Gcommaaccent = 722;
  38973. t.ucircumflex = 500;
  38974. t.acircumflex = 500;
  38975. t.Amacron = 611;
  38976. t.rcaron = 389;
  38977. t.ccedilla = 444;
  38978. t.Zdotaccent = 556;
  38979. t.Thorn = 611;
  38980. t.Omacron = 722;
  38981. t.Racute = 611;
  38982. t.Sacute = 500;
  38983. t.dcaron = 544;
  38984. t.Umacron = 722;
  38985. t.uring = 500;
  38986. t.threesuperior = 300;
  38987. t.Ograve = 722;
  38988. t.Agrave = 611;
  38989. t.Abreve = 611;
  38990. t.multiply = 675;
  38991. t.uacute = 500;
  38992. t.Tcaron = 556;
  38993. t.partialdiff = 476;
  38994. t.ydieresis = 444;
  38995. t.Nacute = 667;
  38996. t.icircumflex = 278;
  38997. t.Ecircumflex = 611;
  38998. t.adieresis = 500;
  38999. t.edieresis = 444;
  39000. t.cacute = 444;
  39001. t.nacute = 500;
  39002. t.umacron = 500;
  39003. t.Ncaron = 667;
  39004. t.Iacute = 333;
  39005. t.plusminus = 675;
  39006. t.brokenbar = 275;
  39007. t.registered = 760;
  39008. t.Gbreve = 722;
  39009. t.Idotaccent = 333;
  39010. t.summation = 600;
  39011. t.Egrave = 611;
  39012. t.racute = 389;
  39013. t.omacron = 500;
  39014. t.Zacute = 556;
  39015. t.Zcaron = 556;
  39016. t.greaterequal = 549;
  39017. t.Eth = 722;
  39018. t.Ccedilla = 667;
  39019. t.lcommaaccent = 278;
  39020. t.tcaron = 300;
  39021. t.eogonek = 444;
  39022. t.Uogonek = 722;
  39023. t.Aacute = 611;
  39024. t.Adieresis = 611;
  39025. t.egrave = 444;
  39026. t.zacute = 389;
  39027. t.iogonek = 278;
  39028. t.Oacute = 722;
  39029. t.oacute = 500;
  39030. t.amacron = 500;
  39031. t.sacute = 389;
  39032. t.idieresis = 278;
  39033. t.Ocircumflex = 722;
  39034. t.Ugrave = 722;
  39035. t.Delta = 612;
  39036. t.thorn = 500;
  39037. t.twosuperior = 300;
  39038. t.Odieresis = 722;
  39039. t.mu = 500;
  39040. t.igrave = 278;
  39041. t.ohungarumlaut = 500;
  39042. t.Eogonek = 611;
  39043. t.dcroat = 500;
  39044. t.threequarters = 750;
  39045. t.Scedilla = 500;
  39046. t.lcaron = 300;
  39047. t.Kcommaaccent = 667;
  39048. t.Lacute = 556;
  39049. t.trademark = 980;
  39050. t.edotaccent = 444;
  39051. t.Igrave = 333;
  39052. t.Imacron = 333;
  39053. t.Lcaron = 611;
  39054. t.onehalf = 750;
  39055. t.lessequal = 549;
  39056. t.ocircumflex = 500;
  39057. t.ntilde = 500;
  39058. t.Uhungarumlaut = 722;
  39059. t.Eacute = 611;
  39060. t.emacron = 444;
  39061. t.gbreve = 500;
  39062. t.onequarter = 750;
  39063. t.Scaron = 500;
  39064. t.Scommaaccent = 500;
  39065. t.Ohungarumlaut = 722;
  39066. t.degree = 400;
  39067. t.ograve = 500;
  39068. t.Ccaron = 667;
  39069. t.ugrave = 500;
  39070. t.radical = 453;
  39071. t.Dcaron = 722;
  39072. t.rcommaaccent = 389;
  39073. t.Ntilde = 667;
  39074. t.otilde = 500;
  39075. t.Rcommaaccent = 611;
  39076. t.Lcommaaccent = 556;
  39077. t.Atilde = 611;
  39078. t.Aogonek = 611;
  39079. t.Aring = 611;
  39080. t.Otilde = 722;
  39081. t.zdotaccent = 389;
  39082. t.Ecaron = 611;
  39083. t.Iogonek = 333;
  39084. t.kcommaaccent = 444;
  39085. t.minus = 675;
  39086. t.Icircumflex = 333;
  39087. t.ncaron = 500;
  39088. t.tcommaaccent = 278;
  39089. t.logicalnot = 675;
  39090. t.odieresis = 500;
  39091. t.udieresis = 500;
  39092. t.notequal = 549;
  39093. t.gcommaaccent = 500;
  39094. t.eth = 500;
  39095. t.zcaron = 389;
  39096. t.ncommaaccent = 500;
  39097. t.onesuperior = 300;
  39098. t.imacron = 278;
  39099. t.Euro = 500;
  39100. });
  39101. t.ZapfDingbats = (0, _core_utils.getLookupTableFactory)(function (t) {
  39102. t.space = 278;
  39103. t.a1 = 974;
  39104. t.a2 = 961;
  39105. t.a202 = 974;
  39106. t.a3 = 980;
  39107. t.a4 = 719;
  39108. t.a5 = 789;
  39109. t.a119 = 790;
  39110. t.a118 = 791;
  39111. t.a117 = 690;
  39112. t.a11 = 960;
  39113. t.a12 = 939;
  39114. t.a13 = 549;
  39115. t.a14 = 855;
  39116. t.a15 = 911;
  39117. t.a16 = 933;
  39118. t.a105 = 911;
  39119. t.a17 = 945;
  39120. t.a18 = 974;
  39121. t.a19 = 755;
  39122. t.a20 = 846;
  39123. t.a21 = 762;
  39124. t.a22 = 761;
  39125. t.a23 = 571;
  39126. t.a24 = 677;
  39127. t.a25 = 763;
  39128. t.a26 = 760;
  39129. t.a27 = 759;
  39130. t.a28 = 754;
  39131. t.a6 = 494;
  39132. t.a7 = 552;
  39133. t.a8 = 537;
  39134. t.a9 = 577;
  39135. t.a10 = 692;
  39136. t.a29 = 786;
  39137. t.a30 = 788;
  39138. t.a31 = 788;
  39139. t.a32 = 790;
  39140. t.a33 = 793;
  39141. t.a34 = 794;
  39142. t.a35 = 816;
  39143. t.a36 = 823;
  39144. t.a37 = 789;
  39145. t.a38 = 841;
  39146. t.a39 = 823;
  39147. t.a40 = 833;
  39148. t.a41 = 816;
  39149. t.a42 = 831;
  39150. t.a43 = 923;
  39151. t.a44 = 744;
  39152. t.a45 = 723;
  39153. t.a46 = 749;
  39154. t.a47 = 790;
  39155. t.a48 = 792;
  39156. t.a49 = 695;
  39157. t.a50 = 776;
  39158. t.a51 = 768;
  39159. t.a52 = 792;
  39160. t.a53 = 759;
  39161. t.a54 = 707;
  39162. t.a55 = 708;
  39163. t.a56 = 682;
  39164. t.a57 = 701;
  39165. t.a58 = 826;
  39166. t.a59 = 815;
  39167. t.a60 = 789;
  39168. t.a61 = 789;
  39169. t.a62 = 707;
  39170. t.a63 = 687;
  39171. t.a64 = 696;
  39172. t.a65 = 689;
  39173. t.a66 = 786;
  39174. t.a67 = 787;
  39175. t.a68 = 713;
  39176. t.a69 = 791;
  39177. t.a70 = 785;
  39178. t.a71 = 791;
  39179. t.a72 = 873;
  39180. t.a73 = 761;
  39181. t.a74 = 762;
  39182. t.a203 = 762;
  39183. t.a75 = 759;
  39184. t.a204 = 759;
  39185. t.a76 = 892;
  39186. t.a77 = 892;
  39187. t.a78 = 788;
  39188. t.a79 = 784;
  39189. t.a81 = 438;
  39190. t.a82 = 138;
  39191. t.a83 = 277;
  39192. t.a84 = 415;
  39193. t.a97 = 392;
  39194. t.a98 = 392;
  39195. t.a99 = 668;
  39196. t.a100 = 668;
  39197. t.a89 = 390;
  39198. t.a90 = 390;
  39199. t.a93 = 317;
  39200. t.a94 = 317;
  39201. t.a91 = 276;
  39202. t.a92 = 276;
  39203. t.a205 = 509;
  39204. t.a85 = 509;
  39205. t.a206 = 410;
  39206. t.a86 = 410;
  39207. t.a87 = 234;
  39208. t.a88 = 234;
  39209. t.a95 = 334;
  39210. t.a96 = 334;
  39211. t.a101 = 732;
  39212. t.a102 = 544;
  39213. t.a103 = 544;
  39214. t.a104 = 910;
  39215. t.a106 = 667;
  39216. t.a107 = 760;
  39217. t.a108 = 760;
  39218. t.a112 = 776;
  39219. t.a111 = 595;
  39220. t.a110 = 694;
  39221. t.a109 = 626;
  39222. t.a120 = 788;
  39223. t.a121 = 788;
  39224. t.a122 = 788;
  39225. t.a123 = 788;
  39226. t.a124 = 788;
  39227. t.a125 = 788;
  39228. t.a126 = 788;
  39229. t.a127 = 788;
  39230. t.a128 = 788;
  39231. t.a129 = 788;
  39232. t.a130 = 788;
  39233. t.a131 = 788;
  39234. t.a132 = 788;
  39235. t.a133 = 788;
  39236. t.a134 = 788;
  39237. t.a135 = 788;
  39238. t.a136 = 788;
  39239. t.a137 = 788;
  39240. t.a138 = 788;
  39241. t.a139 = 788;
  39242. t.a140 = 788;
  39243. t.a141 = 788;
  39244. t.a142 = 788;
  39245. t.a143 = 788;
  39246. t.a144 = 788;
  39247. t.a145 = 788;
  39248. t.a146 = 788;
  39249. t.a147 = 788;
  39250. t.a148 = 788;
  39251. t.a149 = 788;
  39252. t.a150 = 788;
  39253. t.a151 = 788;
  39254. t.a152 = 788;
  39255. t.a153 = 788;
  39256. t.a154 = 788;
  39257. t.a155 = 788;
  39258. t.a156 = 788;
  39259. t.a157 = 788;
  39260. t.a158 = 788;
  39261. t.a159 = 788;
  39262. t.a160 = 894;
  39263. t.a161 = 838;
  39264. t.a163 = 1016;
  39265. t.a164 = 458;
  39266. t.a196 = 748;
  39267. t.a165 = 924;
  39268. t.a192 = 748;
  39269. t.a166 = 918;
  39270. t.a167 = 927;
  39271. t.a168 = 928;
  39272. t.a169 = 928;
  39273. t.a170 = 834;
  39274. t.a171 = 873;
  39275. t.a172 = 828;
  39276. t.a173 = 924;
  39277. t.a162 = 924;
  39278. t.a174 = 917;
  39279. t.a175 = 930;
  39280. t.a176 = 931;
  39281. t.a177 = 463;
  39282. t.a178 = 883;
  39283. t.a179 = 836;
  39284. t.a193 = 836;
  39285. t.a180 = 867;
  39286. t.a199 = 867;
  39287. t.a181 = 696;
  39288. t.a200 = 696;
  39289. t.a182 = 874;
  39290. t.a201 = 874;
  39291. t.a183 = 760;
  39292. t.a184 = 946;
  39293. t.a197 = 771;
  39294. t.a185 = 865;
  39295. t.a194 = 771;
  39296. t.a198 = 888;
  39297. t.a186 = 967;
  39298. t.a195 = 888;
  39299. t.a187 = 831;
  39300. t.a188 = 873;
  39301. t.a189 = 927;
  39302. t.a190 = 970;
  39303. t.a191 = 918;
  39304. });
  39305. });
  39306. exports.getMetrics = getMetrics;
  39307. /***/ }),
  39308. /* 44 */
  39309. /***/ (function(module, exports, __w_pdfjs_require__) {
  39310. "use strict";
  39311. Object.defineProperty(exports, "__esModule", {
  39312. value: true
  39313. });
  39314. exports.MurmurHash3_64 = void 0;
  39315. var _util = __w_pdfjs_require__(2);
  39316. const SEED = 0xc3d2e1f0;
  39317. const MASK_HIGH = 0xffff0000;
  39318. const MASK_LOW = 0xffff;
  39319. class MurmurHash3_64 {
  39320. constructor(seed) {
  39321. this.h1 = seed ? seed & 0xffffffff : SEED;
  39322. this.h2 = seed ? seed & 0xffffffff : SEED;
  39323. }
  39324. update(input) {
  39325. let data, length;
  39326. if ((0, _util.isString)(input)) {
  39327. data = new Uint8Array(input.length * 2);
  39328. length = 0;
  39329. for (let i = 0, ii = input.length; i < ii; i++) {
  39330. const code = input.charCodeAt(i);
  39331. if (code <= 0xff) {
  39332. data[length++] = code;
  39333. } else {
  39334. data[length++] = code >>> 8;
  39335. data[length++] = code & 0xff;
  39336. }
  39337. }
  39338. } else if ((0, _util.isArrayBuffer)(input)) {
  39339. data = input;
  39340. length = data.byteLength;
  39341. } else {
  39342. throw new Error("Wrong data format in MurmurHash3_64_update. " + "Input must be a string or array.");
  39343. }
  39344. const blockCounts = length >> 2;
  39345. const tailLength = length - blockCounts * 4;
  39346. const dataUint32 = new Uint32Array(data.buffer, 0, blockCounts);
  39347. let k1 = 0,
  39348. k2 = 0;
  39349. let h1 = this.h1,
  39350. h2 = this.h2;
  39351. const C1 = 0xcc9e2d51,
  39352. C2 = 0x1b873593;
  39353. const C1_LOW = C1 & MASK_LOW,
  39354. C2_LOW = C2 & MASK_LOW;
  39355. for (let i = 0; i < blockCounts; i++) {
  39356. if (i & 1) {
  39357. k1 = dataUint32[i];
  39358. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  39359. k1 = k1 << 15 | k1 >>> 17;
  39360. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  39361. h1 ^= k1;
  39362. h1 = h1 << 13 | h1 >>> 19;
  39363. h1 = h1 * 5 + 0xe6546b64;
  39364. } else {
  39365. k2 = dataUint32[i];
  39366. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  39367. k2 = k2 << 15 | k2 >>> 17;
  39368. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  39369. h2 ^= k2;
  39370. h2 = h2 << 13 | h2 >>> 19;
  39371. h2 = h2 * 5 + 0xe6546b64;
  39372. }
  39373. }
  39374. k1 = 0;
  39375. switch (tailLength) {
  39376. case 3:
  39377. k1 ^= data[blockCounts * 4 + 2] << 16;
  39378. case 2:
  39379. k1 ^= data[blockCounts * 4 + 1] << 8;
  39380. case 1:
  39381. k1 ^= data[blockCounts * 4];
  39382. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  39383. k1 = k1 << 15 | k1 >>> 17;
  39384. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  39385. if (blockCounts & 1) {
  39386. h1 ^= k1;
  39387. } else {
  39388. h2 ^= k1;
  39389. }
  39390. }
  39391. this.h1 = h1;
  39392. this.h2 = h2;
  39393. }
  39394. hexdigest() {
  39395. let h1 = this.h1,
  39396. h2 = this.h2;
  39397. h1 ^= h2 >>> 1;
  39398. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  39399. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  39400. h1 ^= h2 >>> 1;
  39401. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  39402. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  39403. h1 ^= h2 >>> 1;
  39404. const hex1 = (h1 >>> 0).toString(16),
  39405. hex2 = (h2 >>> 0).toString(16);
  39406. return hex1.padStart(8, "0") + hex2.padStart(8, "0");
  39407. }
  39408. }
  39409. exports.MurmurHash3_64 = MurmurHash3_64;
  39410. /***/ }),
  39411. /* 45 */
  39412. /***/ (function(module, exports, __w_pdfjs_require__) {
  39413. "use strict";
  39414. Object.defineProperty(exports, "__esModule", {
  39415. value: true
  39416. });
  39417. exports.PDFImage = void 0;
  39418. var _util = __w_pdfjs_require__(2);
  39419. var _primitives = __w_pdfjs_require__(5);
  39420. var _colorspace = __w_pdfjs_require__(23);
  39421. var _stream = __w_pdfjs_require__(12);
  39422. var _jpeg_stream = __w_pdfjs_require__(18);
  39423. var _jpx = __w_pdfjs_require__(21);
  39424. function decodeAndClamp(value, addend, coefficient, max) {
  39425. value = addend + value * coefficient;
  39426. if (value < 0) {
  39427. value = 0;
  39428. } else if (value > max) {
  39429. value = max;
  39430. }
  39431. return value;
  39432. }
  39433. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  39434. var length = w2 * h2;
  39435. let dest;
  39436. if (bpc <= 8) {
  39437. dest = new Uint8Array(length);
  39438. } else if (bpc <= 16) {
  39439. dest = new Uint16Array(length);
  39440. } else {
  39441. dest = new Uint32Array(length);
  39442. }
  39443. var xRatio = w1 / w2;
  39444. var yRatio = h1 / h2;
  39445. var i,
  39446. j,
  39447. py,
  39448. newIndex = 0,
  39449. oldIndex;
  39450. var xScaled = new Uint16Array(w2);
  39451. var w1Scanline = w1;
  39452. for (i = 0; i < w2; i++) {
  39453. xScaled[i] = Math.floor(i * xRatio);
  39454. }
  39455. for (i = 0; i < h2; i++) {
  39456. py = Math.floor(i * yRatio) * w1Scanline;
  39457. for (j = 0; j < w2; j++) {
  39458. oldIndex = py + xScaled[j];
  39459. dest[newIndex++] = src[oldIndex];
  39460. }
  39461. }
  39462. return dest;
  39463. }
  39464. class PDFImage {
  39465. constructor({
  39466. xref,
  39467. res,
  39468. image,
  39469. isInline = false,
  39470. smask = null,
  39471. mask = null,
  39472. isMask = false,
  39473. pdfFunctionFactory,
  39474. localColorSpaceCache
  39475. }) {
  39476. this.image = image;
  39477. var dict = image.dict;
  39478. const filter = dict.get("Filter");
  39479. if ((0, _primitives.isName)(filter)) {
  39480. switch (filter.name) {
  39481. case "JPXDecode":
  39482. var jpxImage = new _jpx.JpxImage();
  39483. jpxImage.parseImageProperties(image.stream);
  39484. image.stream.reset();
  39485. image.width = jpxImage.width;
  39486. image.height = jpxImage.height;
  39487. image.bitsPerComponent = jpxImage.bitsPerComponent;
  39488. image.numComps = jpxImage.componentsCount;
  39489. break;
  39490. case "JBIG2Decode":
  39491. image.bitsPerComponent = 1;
  39492. image.numComps = 1;
  39493. break;
  39494. }
  39495. }
  39496. let width = dict.get("Width", "W");
  39497. let height = dict.get("Height", "H");
  39498. if (Number.isInteger(image.width) && image.width > 0 && Number.isInteger(image.height) && image.height > 0 && (image.width !== width || image.height !== height)) {
  39499. (0, _util.warn)("PDFImage - using the Width/Height of the image data, " + "rather than the image dictionary.");
  39500. width = image.width;
  39501. height = image.height;
  39502. }
  39503. if (width < 1 || height < 1) {
  39504. throw new _util.FormatError(`Invalid image width: ${width} or height: ${height}`);
  39505. }
  39506. this.width = width;
  39507. this.height = height;
  39508. this.interpolate = dict.get("Interpolate", "I") || false;
  39509. this.imageMask = dict.get("ImageMask", "IM") || false;
  39510. this.matte = dict.get("Matte") || false;
  39511. var bitsPerComponent = image.bitsPerComponent;
  39512. if (!bitsPerComponent) {
  39513. bitsPerComponent = dict.get("BitsPerComponent", "BPC");
  39514. if (!bitsPerComponent) {
  39515. if (this.imageMask) {
  39516. bitsPerComponent = 1;
  39517. } else {
  39518. throw new _util.FormatError(`Bits per component missing in image: ${this.imageMask}`);
  39519. }
  39520. }
  39521. }
  39522. this.bpc = bitsPerComponent;
  39523. if (!this.imageMask) {
  39524. let colorSpace = dict.getRaw("ColorSpace") || dict.getRaw("CS");
  39525. if (!colorSpace) {
  39526. (0, _util.info)("JPX images (which do not require color spaces)");
  39527. switch (image.numComps) {
  39528. case 1:
  39529. colorSpace = _primitives.Name.get("DeviceGray");
  39530. break;
  39531. case 3:
  39532. colorSpace = _primitives.Name.get("DeviceRGB");
  39533. break;
  39534. case 4:
  39535. colorSpace = _primitives.Name.get("DeviceCMYK");
  39536. break;
  39537. default:
  39538. throw new Error(`JPX images with ${image.numComps} ` + "color components not supported.");
  39539. }
  39540. }
  39541. this.colorSpace = _colorspace.ColorSpace.parse({
  39542. cs: colorSpace,
  39543. xref,
  39544. resources: isInline ? res : null,
  39545. pdfFunctionFactory,
  39546. localColorSpaceCache
  39547. });
  39548. this.numComps = this.colorSpace.numComps;
  39549. }
  39550. this.decode = dict.getArray("Decode", "D");
  39551. this.needsDecode = false;
  39552. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode, bitsPerComponent) || isMask && !_colorspace.ColorSpace.isDefaultDecode(this.decode, 1))) {
  39553. this.needsDecode = true;
  39554. var max = (1 << bitsPerComponent) - 1;
  39555. this.decodeCoefficients = [];
  39556. this.decodeAddends = [];
  39557. const isIndexed = this.colorSpace && this.colorSpace.name === "Indexed";
  39558. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  39559. var dmin = this.decode[i];
  39560. var dmax = this.decode[i + 1];
  39561. this.decodeCoefficients[j] = isIndexed ? (dmax - dmin) / max : dmax - dmin;
  39562. this.decodeAddends[j] = isIndexed ? dmin : max * dmin;
  39563. }
  39564. }
  39565. if (smask) {
  39566. this.smask = new PDFImage({
  39567. xref,
  39568. res,
  39569. image: smask,
  39570. isInline,
  39571. pdfFunctionFactory,
  39572. localColorSpaceCache
  39573. });
  39574. } else if (mask) {
  39575. if ((0, _primitives.isStream)(mask)) {
  39576. var maskDict = mask.dict,
  39577. imageMask = maskDict.get("ImageMask", "IM");
  39578. if (!imageMask) {
  39579. (0, _util.warn)("Ignoring /Mask in image without /ImageMask.");
  39580. } else {
  39581. this.mask = new PDFImage({
  39582. xref,
  39583. res,
  39584. image: mask,
  39585. isInline,
  39586. isMask: true,
  39587. pdfFunctionFactory,
  39588. localColorSpaceCache
  39589. });
  39590. }
  39591. } else {
  39592. this.mask = mask;
  39593. }
  39594. }
  39595. }
  39596. static async buildImage({
  39597. xref,
  39598. res,
  39599. image,
  39600. isInline = false,
  39601. pdfFunctionFactory,
  39602. localColorSpaceCache
  39603. }) {
  39604. const imageData = image;
  39605. let smaskData = null;
  39606. let maskData = null;
  39607. const smask = image.dict.get("SMask");
  39608. const mask = image.dict.get("Mask");
  39609. if (smask) {
  39610. smaskData = smask;
  39611. } else if (mask) {
  39612. if ((0, _primitives.isStream)(mask) || Array.isArray(mask)) {
  39613. maskData = mask;
  39614. } else {
  39615. (0, _util.warn)("Unsupported mask format.");
  39616. }
  39617. }
  39618. return new PDFImage({
  39619. xref,
  39620. res,
  39621. image: imageData,
  39622. isInline,
  39623. smask: smaskData,
  39624. mask: maskData,
  39625. pdfFunctionFactory,
  39626. localColorSpaceCache
  39627. });
  39628. }
  39629. static createMask({
  39630. imgArray,
  39631. width,
  39632. height,
  39633. imageIsFromDecodeStream,
  39634. inverseDecode
  39635. }) {
  39636. var computedLength = (width + 7 >> 3) * height;
  39637. var actualLength = imgArray.byteLength;
  39638. var haveFullData = computedLength === actualLength;
  39639. var data, i;
  39640. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  39641. data = imgArray;
  39642. } else if (!inverseDecode) {
  39643. data = new Uint8ClampedArray(actualLength);
  39644. data.set(imgArray);
  39645. } else {
  39646. data = new Uint8ClampedArray(computedLength);
  39647. data.set(imgArray);
  39648. for (i = actualLength; i < computedLength; i++) {
  39649. data[i] = 0xff;
  39650. }
  39651. }
  39652. if (inverseDecode) {
  39653. for (i = 0; i < actualLength; i++) {
  39654. data[i] ^= 0xff;
  39655. }
  39656. }
  39657. return {
  39658. data,
  39659. width,
  39660. height
  39661. };
  39662. }
  39663. get drawWidth() {
  39664. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  39665. }
  39666. get drawHeight() {
  39667. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  39668. }
  39669. decodeBuffer(buffer) {
  39670. var bpc = this.bpc;
  39671. var numComps = this.numComps;
  39672. var decodeAddends = this.decodeAddends;
  39673. var decodeCoefficients = this.decodeCoefficients;
  39674. var max = (1 << bpc) - 1;
  39675. var i, ii;
  39676. if (bpc === 1) {
  39677. for (i = 0, ii = buffer.length; i < ii; i++) {
  39678. buffer[i] = +!buffer[i];
  39679. }
  39680. return;
  39681. }
  39682. var index = 0;
  39683. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  39684. for (var j = 0; j < numComps; j++) {
  39685. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  39686. index++;
  39687. }
  39688. }
  39689. }
  39690. getComponents(buffer) {
  39691. var bpc = this.bpc;
  39692. if (bpc === 8) {
  39693. return buffer;
  39694. }
  39695. var width = this.width;
  39696. var height = this.height;
  39697. var numComps = this.numComps;
  39698. var length = width * height * numComps;
  39699. var bufferPos = 0;
  39700. let output;
  39701. if (bpc <= 8) {
  39702. output = new Uint8Array(length);
  39703. } else if (bpc <= 16) {
  39704. output = new Uint16Array(length);
  39705. } else {
  39706. output = new Uint32Array(length);
  39707. }
  39708. var rowComps = width * numComps;
  39709. var max = (1 << bpc) - 1;
  39710. var i = 0,
  39711. ii,
  39712. buf;
  39713. if (bpc === 1) {
  39714. var mask, loop1End, loop2End;
  39715. for (var j = 0; j < height; j++) {
  39716. loop1End = i + (rowComps & ~7);
  39717. loop2End = i + rowComps;
  39718. while (i < loop1End) {
  39719. buf = buffer[bufferPos++];
  39720. output[i] = buf >> 7 & 1;
  39721. output[i + 1] = buf >> 6 & 1;
  39722. output[i + 2] = buf >> 5 & 1;
  39723. output[i + 3] = buf >> 4 & 1;
  39724. output[i + 4] = buf >> 3 & 1;
  39725. output[i + 5] = buf >> 2 & 1;
  39726. output[i + 6] = buf >> 1 & 1;
  39727. output[i + 7] = buf & 1;
  39728. i += 8;
  39729. }
  39730. if (i < loop2End) {
  39731. buf = buffer[bufferPos++];
  39732. mask = 128;
  39733. while (i < loop2End) {
  39734. output[i++] = +!!(buf & mask);
  39735. mask >>= 1;
  39736. }
  39737. }
  39738. }
  39739. } else {
  39740. var bits = 0;
  39741. buf = 0;
  39742. for (i = 0, ii = length; i < ii; ++i) {
  39743. if (i % rowComps === 0) {
  39744. buf = 0;
  39745. bits = 0;
  39746. }
  39747. while (bits < bpc) {
  39748. buf = buf << 8 | buffer[bufferPos++];
  39749. bits += 8;
  39750. }
  39751. var remainingBits = bits - bpc;
  39752. let value = buf >> remainingBits;
  39753. if (value < 0) {
  39754. value = 0;
  39755. } else if (value > max) {
  39756. value = max;
  39757. }
  39758. output[i] = value;
  39759. buf = buf & (1 << remainingBits) - 1;
  39760. bits = remainingBits;
  39761. }
  39762. }
  39763. return output;
  39764. }
  39765. fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  39766. var smask = this.smask;
  39767. var mask = this.mask;
  39768. var alphaBuf, sw, sh, i, ii, j;
  39769. if (smask) {
  39770. sw = smask.width;
  39771. sh = smask.height;
  39772. alphaBuf = new Uint8ClampedArray(sw * sh);
  39773. smask.fillGrayBuffer(alphaBuf);
  39774. if (sw !== width || sh !== height) {
  39775. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  39776. }
  39777. } else if (mask) {
  39778. if (mask instanceof PDFImage) {
  39779. sw = mask.width;
  39780. sh = mask.height;
  39781. alphaBuf = new Uint8ClampedArray(sw * sh);
  39782. mask.numComps = 1;
  39783. mask.fillGrayBuffer(alphaBuf);
  39784. for (i = 0, ii = sw * sh; i < ii; ++i) {
  39785. alphaBuf[i] = 255 - alphaBuf[i];
  39786. }
  39787. if (sw !== width || sh !== height) {
  39788. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  39789. }
  39790. } else if (Array.isArray(mask)) {
  39791. alphaBuf = new Uint8ClampedArray(width * height);
  39792. var numComps = this.numComps;
  39793. for (i = 0, ii = width * height; i < ii; ++i) {
  39794. var opacity = 0;
  39795. var imageOffset = i * numComps;
  39796. for (j = 0; j < numComps; ++j) {
  39797. var color = image[imageOffset + j];
  39798. var maskOffset = j * 2;
  39799. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  39800. opacity = 255;
  39801. break;
  39802. }
  39803. }
  39804. alphaBuf[i] = opacity;
  39805. }
  39806. } else {
  39807. throw new _util.FormatError("Unknown mask format.");
  39808. }
  39809. }
  39810. if (alphaBuf) {
  39811. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  39812. rgbaBuf[j] = alphaBuf[i];
  39813. }
  39814. } else {
  39815. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  39816. rgbaBuf[j] = 255;
  39817. }
  39818. }
  39819. }
  39820. undoPreblend(buffer, width, height) {
  39821. var matte = this.smask && this.smask.matte;
  39822. if (!matte) {
  39823. return;
  39824. }
  39825. var matteRgb = this.colorSpace.getRgb(matte, 0);
  39826. var matteR = matteRgb[0];
  39827. var matteG = matteRgb[1];
  39828. var matteB = matteRgb[2];
  39829. var length = width * height * 4;
  39830. for (var i = 0; i < length; i += 4) {
  39831. var alpha = buffer[i + 3];
  39832. if (alpha === 0) {
  39833. buffer[i] = 255;
  39834. buffer[i + 1] = 255;
  39835. buffer[i + 2] = 255;
  39836. continue;
  39837. }
  39838. var k = 255 / alpha;
  39839. buffer[i] = (buffer[i] - matteR) * k + matteR;
  39840. buffer[i + 1] = (buffer[i + 1] - matteG) * k + matteG;
  39841. buffer[i + 2] = (buffer[i + 2] - matteB) * k + matteB;
  39842. }
  39843. }
  39844. createImageData(forceRGBA = false) {
  39845. var drawWidth = this.drawWidth;
  39846. var drawHeight = this.drawHeight;
  39847. var imgData = {
  39848. width: drawWidth,
  39849. height: drawHeight,
  39850. kind: 0,
  39851. data: null
  39852. };
  39853. var numComps = this.numComps;
  39854. var originalWidth = this.width;
  39855. var originalHeight = this.height;
  39856. var bpc = this.bpc;
  39857. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  39858. var imgArray;
  39859. if (!forceRGBA) {
  39860. var kind;
  39861. if (this.colorSpace.name === "DeviceGray" && bpc === 1) {
  39862. kind = _util.ImageKind.GRAYSCALE_1BPP;
  39863. } else if (this.colorSpace.name === "DeviceRGB" && bpc === 8 && !this.needsDecode) {
  39864. kind = _util.ImageKind.RGB_24BPP;
  39865. }
  39866. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  39867. imgData.kind = kind;
  39868. imgArray = this.getImageBytes(originalHeight * rowBytes);
  39869. if (this.image instanceof _stream.DecodeStream) {
  39870. imgData.data = imgArray;
  39871. } else {
  39872. var newArray = new Uint8ClampedArray(imgArray.length);
  39873. newArray.set(imgArray);
  39874. imgData.data = newArray;
  39875. }
  39876. if (this.needsDecode) {
  39877. (0, _util.assert)(kind === _util.ImageKind.GRAYSCALE_1BPP, "PDFImage.createImageData: The image must be grayscale.");
  39878. var buffer = imgData.data;
  39879. for (var i = 0, ii = buffer.length; i < ii; i++) {
  39880. buffer[i] ^= 0xff;
  39881. }
  39882. }
  39883. return imgData;
  39884. }
  39885. if (this.image instanceof _jpeg_stream.JpegStream && !this.smask && !this.mask) {
  39886. let imageLength = originalHeight * rowBytes;
  39887. switch (this.colorSpace.name) {
  39888. case "DeviceGray":
  39889. imageLength *= 3;
  39890. case "DeviceRGB":
  39891. case "DeviceCMYK":
  39892. imgData.kind = _util.ImageKind.RGB_24BPP;
  39893. imgData.data = this.getImageBytes(imageLength, drawWidth, drawHeight, true);
  39894. return imgData;
  39895. }
  39896. }
  39897. }
  39898. imgArray = this.getImageBytes(originalHeight * rowBytes);
  39899. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  39900. var comps = this.getComponents(imgArray);
  39901. var alpha01, maybeUndoPreblend;
  39902. if (!forceRGBA && !this.smask && !this.mask) {
  39903. imgData.kind = _util.ImageKind.RGB_24BPP;
  39904. imgData.data = new Uint8ClampedArray(drawWidth * drawHeight * 3);
  39905. alpha01 = 0;
  39906. maybeUndoPreblend = false;
  39907. } else {
  39908. imgData.kind = _util.ImageKind.RGBA_32BPP;
  39909. imgData.data = new Uint8ClampedArray(drawWidth * drawHeight * 4);
  39910. alpha01 = 1;
  39911. maybeUndoPreblend = true;
  39912. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  39913. }
  39914. if (this.needsDecode) {
  39915. this.decodeBuffer(comps);
  39916. }
  39917. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  39918. if (maybeUndoPreblend) {
  39919. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  39920. }
  39921. return imgData;
  39922. }
  39923. fillGrayBuffer(buffer) {
  39924. var numComps = this.numComps;
  39925. if (numComps !== 1) {
  39926. throw new _util.FormatError(`Reading gray scale from a color image: ${numComps}`);
  39927. }
  39928. var width = this.width;
  39929. var height = this.height;
  39930. var bpc = this.bpc;
  39931. var rowBytes = width * numComps * bpc + 7 >> 3;
  39932. var imgArray = this.getImageBytes(height * rowBytes);
  39933. var comps = this.getComponents(imgArray);
  39934. var i, length;
  39935. if (bpc === 1) {
  39936. length = width * height;
  39937. if (this.needsDecode) {
  39938. for (i = 0; i < length; ++i) {
  39939. buffer[i] = comps[i] - 1 & 255;
  39940. }
  39941. } else {
  39942. for (i = 0; i < length; ++i) {
  39943. buffer[i] = -comps[i] & 255;
  39944. }
  39945. }
  39946. return;
  39947. }
  39948. if (this.needsDecode) {
  39949. this.decodeBuffer(comps);
  39950. }
  39951. length = width * height;
  39952. var scale = 255 / ((1 << bpc) - 1);
  39953. for (i = 0; i < length; ++i) {
  39954. buffer[i] = scale * comps[i];
  39955. }
  39956. }
  39957. getImageBytes(length, drawWidth, drawHeight, forceRGB = false) {
  39958. this.image.reset();
  39959. this.image.drawWidth = drawWidth || this.width;
  39960. this.image.drawHeight = drawHeight || this.height;
  39961. this.image.forceRGB = !!forceRGB;
  39962. return this.image.getBytes(length, true);
  39963. }
  39964. }
  39965. exports.PDFImage = PDFImage;
  39966. /***/ }),
  39967. /* 46 */
  39968. /***/ (function(module, exports, __w_pdfjs_require__) {
  39969. "use strict";
  39970. Object.defineProperty(exports, "__esModule", {
  39971. value: true
  39972. });
  39973. exports.MessageHandler = void 0;
  39974. var _util = __w_pdfjs_require__(2);
  39975. const CallbackKind = {
  39976. UNKNOWN: 0,
  39977. DATA: 1,
  39978. ERROR: 2
  39979. };
  39980. const StreamKind = {
  39981. UNKNOWN: 0,
  39982. CANCEL: 1,
  39983. CANCEL_COMPLETE: 2,
  39984. CLOSE: 3,
  39985. ENQUEUE: 4,
  39986. ERROR: 5,
  39987. PULL: 6,
  39988. PULL_COMPLETE: 7,
  39989. START_COMPLETE: 8
  39990. };
  39991. function wrapReason(reason) {
  39992. if (typeof reason !== "object" || reason === null) {
  39993. return reason;
  39994. }
  39995. switch (reason.name) {
  39996. case "AbortException":
  39997. return new _util.AbortException(reason.message);
  39998. case "MissingPDFException":
  39999. return new _util.MissingPDFException(reason.message);
  40000. case "UnexpectedResponseException":
  40001. return new _util.UnexpectedResponseException(reason.message, reason.status);
  40002. case "UnknownErrorException":
  40003. return new _util.UnknownErrorException(reason.message, reason.details);
  40004. default:
  40005. return new _util.UnknownErrorException(reason.message, reason.toString());
  40006. }
  40007. }
  40008. class MessageHandler {
  40009. constructor(sourceName, targetName, comObj) {
  40010. this.sourceName = sourceName;
  40011. this.targetName = targetName;
  40012. this.comObj = comObj;
  40013. this.callbackId = 1;
  40014. this.streamId = 1;
  40015. this.postMessageTransfers = true;
  40016. this.streamSinks = Object.create(null);
  40017. this.streamControllers = Object.create(null);
  40018. this.callbackCapabilities = Object.create(null);
  40019. this.actionHandler = Object.create(null);
  40020. this._onComObjOnMessage = event => {
  40021. const data = event.data;
  40022. if (data.targetName !== this.sourceName) {
  40023. return;
  40024. }
  40025. if (data.stream) {
  40026. this._processStreamMessage(data);
  40027. return;
  40028. }
  40029. if (data.callback) {
  40030. const callbackId = data.callbackId;
  40031. const capability = this.callbackCapabilities[callbackId];
  40032. if (!capability) {
  40033. throw new Error(`Cannot resolve callback ${callbackId}`);
  40034. }
  40035. delete this.callbackCapabilities[callbackId];
  40036. if (data.callback === CallbackKind.DATA) {
  40037. capability.resolve(data.data);
  40038. } else if (data.callback === CallbackKind.ERROR) {
  40039. capability.reject(wrapReason(data.reason));
  40040. } else {
  40041. throw new Error("Unexpected callback case");
  40042. }
  40043. return;
  40044. }
  40045. const action = this.actionHandler[data.action];
  40046. if (!action) {
  40047. throw new Error(`Unknown action from worker: ${data.action}`);
  40048. }
  40049. if (data.callbackId) {
  40050. const cbSourceName = this.sourceName;
  40051. const cbTargetName = data.sourceName;
  40052. new Promise(function (resolve) {
  40053. resolve(action(data.data));
  40054. }).then(function (result) {
  40055. comObj.postMessage({
  40056. sourceName: cbSourceName,
  40057. targetName: cbTargetName,
  40058. callback: CallbackKind.DATA,
  40059. callbackId: data.callbackId,
  40060. data: result
  40061. });
  40062. }, function (reason) {
  40063. comObj.postMessage({
  40064. sourceName: cbSourceName,
  40065. targetName: cbTargetName,
  40066. callback: CallbackKind.ERROR,
  40067. callbackId: data.callbackId,
  40068. reason: wrapReason(reason)
  40069. });
  40070. });
  40071. return;
  40072. }
  40073. if (data.streamId) {
  40074. this._createStreamSink(data);
  40075. return;
  40076. }
  40077. action(data.data);
  40078. };
  40079. comObj.addEventListener("message", this._onComObjOnMessage);
  40080. }
  40081. on(actionName, handler) {
  40082. const ah = this.actionHandler;
  40083. if (ah[actionName]) {
  40084. throw new Error(`There is already an actionName called "${actionName}"`);
  40085. }
  40086. ah[actionName] = handler;
  40087. }
  40088. send(actionName, data, transfers) {
  40089. this._postMessage({
  40090. sourceName: this.sourceName,
  40091. targetName: this.targetName,
  40092. action: actionName,
  40093. data
  40094. }, transfers);
  40095. }
  40096. sendWithPromise(actionName, data, transfers) {
  40097. const callbackId = this.callbackId++;
  40098. const capability = (0, _util.createPromiseCapability)();
  40099. this.callbackCapabilities[callbackId] = capability;
  40100. try {
  40101. this._postMessage({
  40102. sourceName: this.sourceName,
  40103. targetName: this.targetName,
  40104. action: actionName,
  40105. callbackId,
  40106. data
  40107. }, transfers);
  40108. } catch (ex) {
  40109. capability.reject(ex);
  40110. }
  40111. return capability.promise;
  40112. }
  40113. sendWithStream(actionName, data, queueingStrategy, transfers) {
  40114. const streamId = this.streamId++;
  40115. const sourceName = this.sourceName;
  40116. const targetName = this.targetName;
  40117. const comObj = this.comObj;
  40118. return new ReadableStream({
  40119. start: controller => {
  40120. const startCapability = (0, _util.createPromiseCapability)();
  40121. this.streamControllers[streamId] = {
  40122. controller,
  40123. startCall: startCapability,
  40124. pullCall: null,
  40125. cancelCall: null,
  40126. isClosed: false
  40127. };
  40128. this._postMessage({
  40129. sourceName,
  40130. targetName,
  40131. action: actionName,
  40132. streamId,
  40133. data,
  40134. desiredSize: controller.desiredSize
  40135. }, transfers);
  40136. return startCapability.promise;
  40137. },
  40138. pull: controller => {
  40139. const pullCapability = (0, _util.createPromiseCapability)();
  40140. this.streamControllers[streamId].pullCall = pullCapability;
  40141. comObj.postMessage({
  40142. sourceName,
  40143. targetName,
  40144. stream: StreamKind.PULL,
  40145. streamId,
  40146. desiredSize: controller.desiredSize
  40147. });
  40148. return pullCapability.promise;
  40149. },
  40150. cancel: reason => {
  40151. (0, _util.assert)(reason instanceof Error, "cancel must have a valid reason");
  40152. const cancelCapability = (0, _util.createPromiseCapability)();
  40153. this.streamControllers[streamId].cancelCall = cancelCapability;
  40154. this.streamControllers[streamId].isClosed = true;
  40155. comObj.postMessage({
  40156. sourceName,
  40157. targetName,
  40158. stream: StreamKind.CANCEL,
  40159. streamId,
  40160. reason: wrapReason(reason)
  40161. });
  40162. return cancelCapability.promise;
  40163. }
  40164. }, queueingStrategy);
  40165. }
  40166. _createStreamSink(data) {
  40167. const self = this;
  40168. const action = this.actionHandler[data.action];
  40169. const streamId = data.streamId;
  40170. const sourceName = this.sourceName;
  40171. const targetName = data.sourceName;
  40172. const comObj = this.comObj;
  40173. const streamSink = {
  40174. enqueue(chunk, size = 1, transfers) {
  40175. if (this.isCancelled) {
  40176. return;
  40177. }
  40178. const lastDesiredSize = this.desiredSize;
  40179. this.desiredSize -= size;
  40180. if (lastDesiredSize > 0 && this.desiredSize <= 0) {
  40181. this.sinkCapability = (0, _util.createPromiseCapability)();
  40182. this.ready = this.sinkCapability.promise;
  40183. }
  40184. self._postMessage({
  40185. sourceName,
  40186. targetName,
  40187. stream: StreamKind.ENQUEUE,
  40188. streamId,
  40189. chunk
  40190. }, transfers);
  40191. },
  40192. close() {
  40193. if (this.isCancelled) {
  40194. return;
  40195. }
  40196. this.isCancelled = true;
  40197. comObj.postMessage({
  40198. sourceName,
  40199. targetName,
  40200. stream: StreamKind.CLOSE,
  40201. streamId
  40202. });
  40203. delete self.streamSinks[streamId];
  40204. },
  40205. error(reason) {
  40206. (0, _util.assert)(reason instanceof Error, "error must have a valid reason");
  40207. if (this.isCancelled) {
  40208. return;
  40209. }
  40210. this.isCancelled = true;
  40211. comObj.postMessage({
  40212. sourceName,
  40213. targetName,
  40214. stream: StreamKind.ERROR,
  40215. streamId,
  40216. reason: wrapReason(reason)
  40217. });
  40218. },
  40219. sinkCapability: (0, _util.createPromiseCapability)(),
  40220. onPull: null,
  40221. onCancel: null,
  40222. isCancelled: false,
  40223. desiredSize: data.desiredSize,
  40224. ready: null
  40225. };
  40226. streamSink.sinkCapability.resolve();
  40227. streamSink.ready = streamSink.sinkCapability.promise;
  40228. this.streamSinks[streamId] = streamSink;
  40229. new Promise(function (resolve) {
  40230. resolve(action(data.data, streamSink));
  40231. }).then(function () {
  40232. comObj.postMessage({
  40233. sourceName,
  40234. targetName,
  40235. stream: StreamKind.START_COMPLETE,
  40236. streamId,
  40237. success: true
  40238. });
  40239. }, function (reason) {
  40240. comObj.postMessage({
  40241. sourceName,
  40242. targetName,
  40243. stream: StreamKind.START_COMPLETE,
  40244. streamId,
  40245. reason: wrapReason(reason)
  40246. });
  40247. });
  40248. }
  40249. _processStreamMessage(data) {
  40250. const streamId = data.streamId;
  40251. const sourceName = this.sourceName;
  40252. const targetName = data.sourceName;
  40253. const comObj = this.comObj;
  40254. switch (data.stream) {
  40255. case StreamKind.START_COMPLETE:
  40256. if (data.success) {
  40257. this.streamControllers[streamId].startCall.resolve();
  40258. } else {
  40259. this.streamControllers[streamId].startCall.reject(wrapReason(data.reason));
  40260. }
  40261. break;
  40262. case StreamKind.PULL_COMPLETE:
  40263. if (data.success) {
  40264. this.streamControllers[streamId].pullCall.resolve();
  40265. } else {
  40266. this.streamControllers[streamId].pullCall.reject(wrapReason(data.reason));
  40267. }
  40268. break;
  40269. case StreamKind.PULL:
  40270. if (!this.streamSinks[streamId]) {
  40271. comObj.postMessage({
  40272. sourceName,
  40273. targetName,
  40274. stream: StreamKind.PULL_COMPLETE,
  40275. streamId,
  40276. success: true
  40277. });
  40278. break;
  40279. }
  40280. if (this.streamSinks[streamId].desiredSize <= 0 && data.desiredSize > 0) {
  40281. this.streamSinks[streamId].sinkCapability.resolve();
  40282. }
  40283. this.streamSinks[streamId].desiredSize = data.desiredSize;
  40284. const {
  40285. onPull
  40286. } = this.streamSinks[data.streamId];
  40287. new Promise(function (resolve) {
  40288. resolve(onPull && onPull());
  40289. }).then(function () {
  40290. comObj.postMessage({
  40291. sourceName,
  40292. targetName,
  40293. stream: StreamKind.PULL_COMPLETE,
  40294. streamId,
  40295. success: true
  40296. });
  40297. }, function (reason) {
  40298. comObj.postMessage({
  40299. sourceName,
  40300. targetName,
  40301. stream: StreamKind.PULL_COMPLETE,
  40302. streamId,
  40303. reason: wrapReason(reason)
  40304. });
  40305. });
  40306. break;
  40307. case StreamKind.ENQUEUE:
  40308. (0, _util.assert)(this.streamControllers[streamId], "enqueue should have stream controller");
  40309. if (this.streamControllers[streamId].isClosed) {
  40310. break;
  40311. }
  40312. this.streamControllers[streamId].controller.enqueue(data.chunk);
  40313. break;
  40314. case StreamKind.CLOSE:
  40315. (0, _util.assert)(this.streamControllers[streamId], "close should have stream controller");
  40316. if (this.streamControllers[streamId].isClosed) {
  40317. break;
  40318. }
  40319. this.streamControllers[streamId].isClosed = true;
  40320. this.streamControllers[streamId].controller.close();
  40321. this._deleteStreamController(streamId);
  40322. break;
  40323. case StreamKind.ERROR:
  40324. (0, _util.assert)(this.streamControllers[streamId], "error should have stream controller");
  40325. this.streamControllers[streamId].controller.error(wrapReason(data.reason));
  40326. this._deleteStreamController(streamId);
  40327. break;
  40328. case StreamKind.CANCEL_COMPLETE:
  40329. if (data.success) {
  40330. this.streamControllers[streamId].cancelCall.resolve();
  40331. } else {
  40332. this.streamControllers[streamId].cancelCall.reject(wrapReason(data.reason));
  40333. }
  40334. this._deleteStreamController(streamId);
  40335. break;
  40336. case StreamKind.CANCEL:
  40337. if (!this.streamSinks[streamId]) {
  40338. break;
  40339. }
  40340. const {
  40341. onCancel
  40342. } = this.streamSinks[data.streamId];
  40343. new Promise(function (resolve) {
  40344. resolve(onCancel && onCancel(wrapReason(data.reason)));
  40345. }).then(function () {
  40346. comObj.postMessage({
  40347. sourceName,
  40348. targetName,
  40349. stream: StreamKind.CANCEL_COMPLETE,
  40350. streamId,
  40351. success: true
  40352. });
  40353. }, function (reason) {
  40354. comObj.postMessage({
  40355. sourceName,
  40356. targetName,
  40357. stream: StreamKind.CANCEL_COMPLETE,
  40358. streamId,
  40359. reason: wrapReason(reason)
  40360. });
  40361. });
  40362. this.streamSinks[streamId].sinkCapability.reject(wrapReason(data.reason));
  40363. this.streamSinks[streamId].isCancelled = true;
  40364. delete this.streamSinks[streamId];
  40365. break;
  40366. default:
  40367. throw new Error("Unexpected stream case");
  40368. }
  40369. }
  40370. async _deleteStreamController(streamId) {
  40371. await Promise.allSettled([this.streamControllers[streamId].startCall, this.streamControllers[streamId].pullCall, this.streamControllers[streamId].cancelCall].map(function (capability) {
  40372. return capability && capability.promise;
  40373. }));
  40374. delete this.streamControllers[streamId];
  40375. }
  40376. _postMessage(message, transfers) {
  40377. if (transfers && this.postMessageTransfers) {
  40378. this.comObj.postMessage(message, transfers);
  40379. } else {
  40380. this.comObj.postMessage(message);
  40381. }
  40382. }
  40383. destroy() {
  40384. this.comObj.removeEventListener("message", this._onComObjOnMessage);
  40385. }
  40386. }
  40387. exports.MessageHandler = MessageHandler;
  40388. /***/ }),
  40389. /* 47 */
  40390. /***/ (function(module, exports, __w_pdfjs_require__) {
  40391. "use strict";
  40392. Object.defineProperty(exports, "__esModule", {
  40393. value: true
  40394. });
  40395. exports.PDFWorkerStream = void 0;
  40396. var _util = __w_pdfjs_require__(2);
  40397. class PDFWorkerStream {
  40398. constructor(msgHandler) {
  40399. this._msgHandler = msgHandler;
  40400. this._contentLength = null;
  40401. this._fullRequestReader = null;
  40402. this._rangeRequestReaders = [];
  40403. }
  40404. getFullReader() {
  40405. (0, _util.assert)(!this._fullRequestReader, "PDFWorkerStream.getFullReader can only be called once.");
  40406. this._fullRequestReader = new PDFWorkerStreamReader(this._msgHandler);
  40407. return this._fullRequestReader;
  40408. }
  40409. getRangeReader(begin, end) {
  40410. const reader = new PDFWorkerStreamRangeReader(begin, end, this._msgHandler);
  40411. this._rangeRequestReaders.push(reader);
  40412. return reader;
  40413. }
  40414. cancelAllRequests(reason) {
  40415. if (this._fullRequestReader) {
  40416. this._fullRequestReader.cancel(reason);
  40417. }
  40418. const readers = this._rangeRequestReaders.slice(0);
  40419. readers.forEach(function (reader) {
  40420. reader.cancel(reason);
  40421. });
  40422. }
  40423. }
  40424. exports.PDFWorkerStream = PDFWorkerStream;
  40425. class PDFWorkerStreamReader {
  40426. constructor(msgHandler) {
  40427. this._msgHandler = msgHandler;
  40428. this.onProgress = null;
  40429. this._contentLength = null;
  40430. this._isRangeSupported = false;
  40431. this._isStreamingSupported = false;
  40432. const readableStream = this._msgHandler.sendWithStream("GetReader");
  40433. this._reader = readableStream.getReader();
  40434. this._headersReady = this._msgHandler.sendWithPromise("ReaderHeadersReady").then(data => {
  40435. this._isStreamingSupported = data.isStreamingSupported;
  40436. this._isRangeSupported = data.isRangeSupported;
  40437. this._contentLength = data.contentLength;
  40438. });
  40439. }
  40440. get headersReady() {
  40441. return this._headersReady;
  40442. }
  40443. get contentLength() {
  40444. return this._contentLength;
  40445. }
  40446. get isStreamingSupported() {
  40447. return this._isStreamingSupported;
  40448. }
  40449. get isRangeSupported() {
  40450. return this._isRangeSupported;
  40451. }
  40452. async read() {
  40453. const {
  40454. value,
  40455. done
  40456. } = await this._reader.read();
  40457. if (done) {
  40458. return {
  40459. value: undefined,
  40460. done: true
  40461. };
  40462. }
  40463. return {
  40464. value: value.buffer,
  40465. done: false
  40466. };
  40467. }
  40468. cancel(reason) {
  40469. this._reader.cancel(reason);
  40470. }
  40471. }
  40472. class PDFWorkerStreamRangeReader {
  40473. constructor(begin, end, msgHandler) {
  40474. this._msgHandler = msgHandler;
  40475. this.onProgress = null;
  40476. const readableStream = this._msgHandler.sendWithStream("GetRangeReader", {
  40477. begin,
  40478. end
  40479. });
  40480. this._reader = readableStream.getReader();
  40481. }
  40482. get isStreamingSupported() {
  40483. return false;
  40484. }
  40485. async read() {
  40486. const {
  40487. value,
  40488. done
  40489. } = await this._reader.read();
  40490. if (done) {
  40491. return {
  40492. value: undefined,
  40493. done: true
  40494. };
  40495. }
  40496. return {
  40497. value: value.buffer,
  40498. done: false
  40499. };
  40500. }
  40501. cancel(reason) {
  40502. this._reader.cancel(reason);
  40503. }
  40504. }
  40505. /***/ })
  40506. /******/ ]);
  40507. });
  40508. //# sourceMappingURL=pdf.worker.js.map