pdf.combined.js 1.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351
  1. /* Copyright 2017 Mozilla Foundation
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. (function webpackUniversalModuleDefinition(root, factory) {
  16. if(typeof exports === 'object' && typeof module === 'object')
  17. module.exports = factory();
  18. else if(typeof define === 'function' && define.amd)
  19. define("pdfjs-dist/build/pdf.combined", [], factory);
  20. else if(typeof exports === 'object')
  21. exports["pdfjs-dist/build/pdf.combined"] = factory();
  22. else
  23. root["pdfjs-dist/build/pdf.combined"] = root.pdfjsDistBuildPdfCombined = factory();
  24. })(this, function() {
  25. return /******/ (function(modules) { // webpackBootstrap
  26. /******/ // The module cache
  27. /******/ var installedModules = {};
  28. /******/ // The require function
  29. /******/ function __w_pdfjs_require__(moduleId) {
  30. /******/ // Check if module is in cache
  31. /******/ if(installedModules[moduleId])
  32. /******/ return installedModules[moduleId].exports;
  33. /******/ // Create a new module (and put it into the cache)
  34. /******/ var module = installedModules[moduleId] = {
  35. /******/ i: moduleId,
  36. /******/ l: false,
  37. /******/ exports: {}
  38. /******/ };
  39. /******/ // Execute the module function
  40. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  41. /******/ // Flag the module as loaded
  42. /******/ module.l = true;
  43. /******/ // Return the exports of the module
  44. /******/ return module.exports;
  45. /******/ }
  46. /******/ // expose the modules object (__webpack_modules__)
  47. /******/ __w_pdfjs_require__.m = modules;
  48. /******/ // expose the module cache
  49. /******/ __w_pdfjs_require__.c = installedModules;
  50. /******/ // identity function for calling harmony imports with the correct context
  51. /******/ __w_pdfjs_require__.i = function(value) { return value; };
  52. /******/ // define getter function for harmony exports
  53. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  54. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  55. /******/ Object.defineProperty(exports, name, {
  56. /******/ configurable: false,
  57. /******/ enumerable: true,
  58. /******/ get: getter
  59. /******/ });
  60. /******/ }
  61. /******/ };
  62. /******/ // getDefaultExport function for compatibility with non-harmony modules
  63. /******/ __w_pdfjs_require__.n = function(module) {
  64. /******/ var getter = module && module.__esModule ?
  65. /******/ function getDefault() { return module['default']; } :
  66. /******/ function getModuleExports() { return module; };
  67. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  68. /******/ return getter;
  69. /******/ };
  70. /******/ // Object.prototype.hasOwnProperty.call
  71. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  72. /******/ // __webpack_public_path__
  73. /******/ __w_pdfjs_require__.p = "";
  74. /******/ // Load entry module and return exports
  75. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 47);
  76. /******/ })
  77. /************************************************************************/
  78. /******/ ([
  79. /* 0 */
  80. /***/ (function(module, exports, __w_pdfjs_require__) {
  81. "use strict";
  82. /* WEBPACK VAR INJECTION */(function(global) {
  83. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  84. var FONT_IDENTITY_MATRIX = [
  85. 0.001,
  86. 0,
  87. 0,
  88. 0.001,
  89. 0,
  90. 0
  91. ];
  92. var TextRenderingMode = {
  93. FILL: 0,
  94. STROKE: 1,
  95. FILL_STROKE: 2,
  96. INVISIBLE: 3,
  97. FILL_ADD_TO_PATH: 4,
  98. STROKE_ADD_TO_PATH: 5,
  99. FILL_STROKE_ADD_TO_PATH: 6,
  100. ADD_TO_PATH: 7,
  101. FILL_STROKE_MASK: 3,
  102. ADD_TO_PATH_FLAG: 4
  103. };
  104. var ImageKind = {
  105. GRAYSCALE_1BPP: 1,
  106. RGB_24BPP: 2,
  107. RGBA_32BPP: 3
  108. };
  109. var AnnotationType = {
  110. TEXT: 1,
  111. LINK: 2,
  112. FREETEXT: 3,
  113. LINE: 4,
  114. SQUARE: 5,
  115. CIRCLE: 6,
  116. POLYGON: 7,
  117. POLYLINE: 8,
  118. HIGHLIGHT: 9,
  119. UNDERLINE: 10,
  120. SQUIGGLY: 11,
  121. STRIKEOUT: 12,
  122. STAMP: 13,
  123. CARET: 14,
  124. INK: 15,
  125. POPUP: 16,
  126. FILEATTACHMENT: 17,
  127. SOUND: 18,
  128. MOVIE: 19,
  129. WIDGET: 20,
  130. SCREEN: 21,
  131. PRINTERMARK: 22,
  132. TRAPNET: 23,
  133. WATERMARK: 24,
  134. THREED: 25,
  135. REDACT: 26
  136. };
  137. var AnnotationFlag = {
  138. INVISIBLE: 0x01,
  139. HIDDEN: 0x02,
  140. PRINT: 0x04,
  141. NOZOOM: 0x08,
  142. NOROTATE: 0x10,
  143. NOVIEW: 0x20,
  144. READONLY: 0x40,
  145. LOCKED: 0x80,
  146. TOGGLENOVIEW: 0x100,
  147. LOCKEDCONTENTS: 0x200
  148. };
  149. var AnnotationFieldFlag = {
  150. READONLY: 0x0000001,
  151. REQUIRED: 0x0000002,
  152. NOEXPORT: 0x0000004,
  153. MULTILINE: 0x0001000,
  154. PASSWORD: 0x0002000,
  155. NOTOGGLETOOFF: 0x0004000,
  156. RADIO: 0x0008000,
  157. PUSHBUTTON: 0x0010000,
  158. COMBO: 0x0020000,
  159. EDIT: 0x0040000,
  160. SORT: 0x0080000,
  161. FILESELECT: 0x0100000,
  162. MULTISELECT: 0x0200000,
  163. DONOTSPELLCHECK: 0x0400000,
  164. DONOTSCROLL: 0x0800000,
  165. COMB: 0x1000000,
  166. RICHTEXT: 0x2000000,
  167. RADIOSINUNISON: 0x2000000,
  168. COMMITONSELCHANGE: 0x4000000
  169. };
  170. var AnnotationBorderStyleType = {
  171. SOLID: 1,
  172. DASHED: 2,
  173. BEVELED: 3,
  174. INSET: 4,
  175. UNDERLINE: 5
  176. };
  177. var StreamType = {
  178. UNKNOWN: 0,
  179. FLATE: 1,
  180. LZW: 2,
  181. DCT: 3,
  182. JPX: 4,
  183. JBIG: 5,
  184. A85: 6,
  185. AHX: 7,
  186. CCF: 8,
  187. RL: 9
  188. };
  189. var FontType = {
  190. UNKNOWN: 0,
  191. TYPE1: 1,
  192. TYPE1C: 2,
  193. CIDFONTTYPE0: 3,
  194. CIDFONTTYPE0C: 4,
  195. TRUETYPE: 5,
  196. CIDFONTTYPE2: 6,
  197. TYPE3: 7,
  198. OPENTYPE: 8,
  199. TYPE0: 9,
  200. MMTYPE1: 10
  201. };
  202. var VERBOSITY_LEVELS = {
  203. errors: 0,
  204. warnings: 1,
  205. infos: 5
  206. };
  207. var CMapCompressionType = {
  208. NONE: 0,
  209. BINARY: 1,
  210. STREAM: 2
  211. };
  212. var OPS = {
  213. dependency: 1,
  214. setLineWidth: 2,
  215. setLineCap: 3,
  216. setLineJoin: 4,
  217. setMiterLimit: 5,
  218. setDash: 6,
  219. setRenderingIntent: 7,
  220. setFlatness: 8,
  221. setGState: 9,
  222. save: 10,
  223. restore: 11,
  224. transform: 12,
  225. moveTo: 13,
  226. lineTo: 14,
  227. curveTo: 15,
  228. curveTo2: 16,
  229. curveTo3: 17,
  230. closePath: 18,
  231. rectangle: 19,
  232. stroke: 20,
  233. closeStroke: 21,
  234. fill: 22,
  235. eoFill: 23,
  236. fillStroke: 24,
  237. eoFillStroke: 25,
  238. closeFillStroke: 26,
  239. closeEOFillStroke: 27,
  240. endPath: 28,
  241. clip: 29,
  242. eoClip: 30,
  243. beginText: 31,
  244. endText: 32,
  245. setCharSpacing: 33,
  246. setWordSpacing: 34,
  247. setHScale: 35,
  248. setLeading: 36,
  249. setFont: 37,
  250. setTextRenderingMode: 38,
  251. setTextRise: 39,
  252. moveText: 40,
  253. setLeadingMoveText: 41,
  254. setTextMatrix: 42,
  255. nextLine: 43,
  256. showText: 44,
  257. showSpacedText: 45,
  258. nextLineShowText: 46,
  259. nextLineSetSpacingShowText: 47,
  260. setCharWidth: 48,
  261. setCharWidthAndBounds: 49,
  262. setStrokeColorSpace: 50,
  263. setFillColorSpace: 51,
  264. setStrokeColor: 52,
  265. setStrokeColorN: 53,
  266. setFillColor: 54,
  267. setFillColorN: 55,
  268. setStrokeGray: 56,
  269. setFillGray: 57,
  270. setStrokeRGBColor: 58,
  271. setFillRGBColor: 59,
  272. setStrokeCMYKColor: 60,
  273. setFillCMYKColor: 61,
  274. shadingFill: 62,
  275. beginInlineImage: 63,
  276. beginImageData: 64,
  277. endInlineImage: 65,
  278. paintXObject: 66,
  279. markPoint: 67,
  280. markPointProps: 68,
  281. beginMarkedContent: 69,
  282. beginMarkedContentProps: 70,
  283. endMarkedContent: 71,
  284. beginCompat: 72,
  285. endCompat: 73,
  286. paintFormXObjectBegin: 74,
  287. paintFormXObjectEnd: 75,
  288. beginGroup: 76,
  289. endGroup: 77,
  290. beginAnnotations: 78,
  291. endAnnotations: 79,
  292. beginAnnotation: 80,
  293. endAnnotation: 81,
  294. paintJpegXObject: 82,
  295. paintImageMaskXObject: 83,
  296. paintImageMaskXObjectGroup: 84,
  297. paintImageXObject: 85,
  298. paintInlineImageXObject: 86,
  299. paintInlineImageXObjectGroup: 87,
  300. paintImageXObjectRepeat: 88,
  301. paintImageMaskXObjectRepeat: 89,
  302. paintSolidColorImageMask: 90,
  303. constructPath: 91
  304. };
  305. var verbosity = VERBOSITY_LEVELS.warnings;
  306. function setVerbosityLevel(level) {
  307. verbosity = level;
  308. }
  309. function getVerbosityLevel() {
  310. return verbosity;
  311. }
  312. function info(msg) {
  313. if (verbosity >= VERBOSITY_LEVELS.infos) {
  314. console.log('Info: ' + msg);
  315. }
  316. }
  317. function warn(msg) {
  318. if (verbosity >= VERBOSITY_LEVELS.warnings) {
  319. console.log('Warning: ' + msg);
  320. }
  321. }
  322. function deprecated(details) {
  323. console.log('Deprecated API usage: ' + details);
  324. }
  325. function error(msg) {
  326. if (verbosity >= VERBOSITY_LEVELS.errors) {
  327. console.log('Error: ' + msg);
  328. console.log(backtrace());
  329. }
  330. throw new Error(msg);
  331. }
  332. function backtrace() {
  333. try {
  334. throw new Error();
  335. } catch (e) {
  336. return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
  337. }
  338. }
  339. function assert(cond, msg) {
  340. if (!cond) {
  341. error(msg);
  342. }
  343. }
  344. var UNSUPPORTED_FEATURES = {
  345. unknown: 'unknown',
  346. forms: 'forms',
  347. javaScript: 'javaScript',
  348. smask: 'smask',
  349. shadingPattern: 'shadingPattern',
  350. font: 'font'
  351. };
  352. function isSameOrigin(baseUrl, otherUrl) {
  353. try {
  354. var base = new URL(baseUrl);
  355. if (!base.origin || base.origin === 'null') {
  356. return false;
  357. }
  358. } catch (e) {
  359. return false;
  360. }
  361. var other = new URL(otherUrl, base);
  362. return base.origin === other.origin;
  363. }
  364. function isValidProtocol(url) {
  365. if (!url) {
  366. return false;
  367. }
  368. switch (url.protocol) {
  369. case 'http:':
  370. case 'https:':
  371. case 'ftp:':
  372. case 'mailto:':
  373. case 'tel:':
  374. return true;
  375. default:
  376. return false;
  377. }
  378. }
  379. function createValidAbsoluteUrl(url, baseUrl) {
  380. if (!url) {
  381. return null;
  382. }
  383. try {
  384. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  385. if (isValidProtocol(absoluteUrl)) {
  386. return absoluteUrl;
  387. }
  388. } catch (ex) {
  389. }
  390. return null;
  391. }
  392. function shadow(obj, prop, value) {
  393. Object.defineProperty(obj, prop, {
  394. value: value,
  395. enumerable: true,
  396. configurable: true,
  397. writable: false
  398. });
  399. return value;
  400. }
  401. function getLookupTableFactory(initializer) {
  402. var lookup;
  403. return function () {
  404. if (initializer) {
  405. lookup = Object.create(null);
  406. initializer(lookup);
  407. initializer = null;
  408. }
  409. return lookup;
  410. };
  411. }
  412. var PasswordResponses = {
  413. NEED_PASSWORD: 1,
  414. INCORRECT_PASSWORD: 2
  415. };
  416. var PasswordException = function PasswordExceptionClosure() {
  417. function PasswordException(msg, code) {
  418. this.name = 'PasswordException';
  419. this.message = msg;
  420. this.code = code;
  421. }
  422. PasswordException.prototype = new Error();
  423. PasswordException.constructor = PasswordException;
  424. return PasswordException;
  425. }();
  426. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  427. function UnknownErrorException(msg, details) {
  428. this.name = 'UnknownErrorException';
  429. this.message = msg;
  430. this.details = details;
  431. }
  432. UnknownErrorException.prototype = new Error();
  433. UnknownErrorException.constructor = UnknownErrorException;
  434. return UnknownErrorException;
  435. }();
  436. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  437. function InvalidPDFException(msg) {
  438. this.name = 'InvalidPDFException';
  439. this.message = msg;
  440. }
  441. InvalidPDFException.prototype = new Error();
  442. InvalidPDFException.constructor = InvalidPDFException;
  443. return InvalidPDFException;
  444. }();
  445. var MissingPDFException = function MissingPDFExceptionClosure() {
  446. function MissingPDFException(msg) {
  447. this.name = 'MissingPDFException';
  448. this.message = msg;
  449. }
  450. MissingPDFException.prototype = new Error();
  451. MissingPDFException.constructor = MissingPDFException;
  452. return MissingPDFException;
  453. }();
  454. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  455. function UnexpectedResponseException(msg, status) {
  456. this.name = 'UnexpectedResponseException';
  457. this.message = msg;
  458. this.status = status;
  459. }
  460. UnexpectedResponseException.prototype = new Error();
  461. UnexpectedResponseException.constructor = UnexpectedResponseException;
  462. return UnexpectedResponseException;
  463. }();
  464. var NotImplementedException = function NotImplementedExceptionClosure() {
  465. function NotImplementedException(msg) {
  466. this.message = msg;
  467. }
  468. NotImplementedException.prototype = new Error();
  469. NotImplementedException.prototype.name = 'NotImplementedException';
  470. NotImplementedException.constructor = NotImplementedException;
  471. return NotImplementedException;
  472. }();
  473. var MissingDataException = function MissingDataExceptionClosure() {
  474. function MissingDataException(begin, end) {
  475. this.begin = begin;
  476. this.end = end;
  477. this.message = 'Missing data [' + begin + ', ' + end + ')';
  478. }
  479. MissingDataException.prototype = new Error();
  480. MissingDataException.prototype.name = 'MissingDataException';
  481. MissingDataException.constructor = MissingDataException;
  482. return MissingDataException;
  483. }();
  484. var XRefParseException = function XRefParseExceptionClosure() {
  485. function XRefParseException(msg) {
  486. this.message = msg;
  487. }
  488. XRefParseException.prototype = new Error();
  489. XRefParseException.prototype.name = 'XRefParseException';
  490. XRefParseException.constructor = XRefParseException;
  491. return XRefParseException;
  492. }();
  493. var NullCharactersRegExp = /\x00/g;
  494. function removeNullCharacters(str) {
  495. if (typeof str !== 'string') {
  496. warn('The argument for removeNullCharacters must be a string.');
  497. return str;
  498. }
  499. return str.replace(NullCharactersRegExp, '');
  500. }
  501. function bytesToString(bytes) {
  502. assert(bytes !== null && typeof bytes === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  503. var length = bytes.length;
  504. var MAX_ARGUMENT_COUNT = 8192;
  505. if (length < MAX_ARGUMENT_COUNT) {
  506. return String.fromCharCode.apply(null, bytes);
  507. }
  508. var strBuf = [];
  509. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  510. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  511. var chunk = bytes.subarray(i, chunkEnd);
  512. strBuf.push(String.fromCharCode.apply(null, chunk));
  513. }
  514. return strBuf.join('');
  515. }
  516. function stringToBytes(str) {
  517. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  518. var length = str.length;
  519. var bytes = new Uint8Array(length);
  520. for (var i = 0; i < length; ++i) {
  521. bytes[i] = str.charCodeAt(i) & 0xFF;
  522. }
  523. return bytes;
  524. }
  525. function arrayByteLength(arr) {
  526. if (arr.length !== undefined) {
  527. return arr.length;
  528. }
  529. assert(arr.byteLength !== undefined);
  530. return arr.byteLength;
  531. }
  532. function arraysToBytes(arr) {
  533. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  534. return arr[0];
  535. }
  536. var resultLength = 0;
  537. var i, ii = arr.length;
  538. var item, itemLength;
  539. for (i = 0; i < ii; i++) {
  540. item = arr[i];
  541. itemLength = arrayByteLength(item);
  542. resultLength += itemLength;
  543. }
  544. var pos = 0;
  545. var data = new Uint8Array(resultLength);
  546. for (i = 0; i < ii; i++) {
  547. item = arr[i];
  548. if (!(item instanceof Uint8Array)) {
  549. if (typeof item === 'string') {
  550. item = stringToBytes(item);
  551. } else {
  552. item = new Uint8Array(item);
  553. }
  554. }
  555. itemLength = item.byteLength;
  556. data.set(item, pos);
  557. pos += itemLength;
  558. }
  559. return data;
  560. }
  561. function string32(value) {
  562. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  563. }
  564. function log2(x) {
  565. var n = 1, i = 0;
  566. while (x > n) {
  567. n <<= 1;
  568. i++;
  569. }
  570. return i;
  571. }
  572. function readInt8(data, start) {
  573. return data[start] << 24 >> 24;
  574. }
  575. function readUint16(data, offset) {
  576. return data[offset] << 8 | data[offset + 1];
  577. }
  578. function readUint32(data, offset) {
  579. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  580. }
  581. function isLittleEndian() {
  582. var buffer8 = new Uint8Array(2);
  583. buffer8[0] = 1;
  584. var buffer16 = new Uint16Array(buffer8.buffer);
  585. return buffer16[0] === 1;
  586. }
  587. function isEvalSupported() {
  588. try {
  589. new Function('');
  590. return true;
  591. } catch (e) {
  592. return false;
  593. }
  594. }
  595. var Uint32ArrayView = function Uint32ArrayViewClosure() {
  596. function Uint32ArrayView(buffer, length) {
  597. this.buffer = buffer;
  598. this.byteLength = buffer.length;
  599. this.length = length === undefined ? this.byteLength >> 2 : length;
  600. ensureUint32ArrayViewProps(this.length);
  601. }
  602. Uint32ArrayView.prototype = Object.create(null);
  603. var uint32ArrayViewSetters = 0;
  604. function createUint32ArrayProp(index) {
  605. return {
  606. get: function () {
  607. var buffer = this.buffer, offset = index << 2;
  608. return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0;
  609. },
  610. set: function (value) {
  611. var buffer = this.buffer, offset = index << 2;
  612. buffer[offset] = value & 255;
  613. buffer[offset + 1] = value >> 8 & 255;
  614. buffer[offset + 2] = value >> 16 & 255;
  615. buffer[offset + 3] = value >>> 24 & 255;
  616. }
  617. };
  618. }
  619. function ensureUint32ArrayViewProps(length) {
  620. while (uint32ArrayViewSetters < length) {
  621. Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters));
  622. uint32ArrayViewSetters++;
  623. }
  624. }
  625. return Uint32ArrayView;
  626. }();
  627. exports.Uint32ArrayView = Uint32ArrayView;
  628. var IDENTITY_MATRIX = [
  629. 1,
  630. 0,
  631. 0,
  632. 1,
  633. 0,
  634. 0
  635. ];
  636. var Util = function UtilClosure() {
  637. function Util() {
  638. }
  639. var rgbBuf = [
  640. 'rgb(',
  641. 0,
  642. ',',
  643. 0,
  644. ',',
  645. 0,
  646. ')'
  647. ];
  648. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  649. rgbBuf[1] = r;
  650. rgbBuf[3] = g;
  651. rgbBuf[5] = b;
  652. return rgbBuf.join('');
  653. };
  654. Util.transform = function Util_transform(m1, m2) {
  655. return [
  656. m1[0] * m2[0] + m1[2] * m2[1],
  657. m1[1] * m2[0] + m1[3] * m2[1],
  658. m1[0] * m2[2] + m1[2] * m2[3],
  659. m1[1] * m2[2] + m1[3] * m2[3],
  660. m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
  661. m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
  662. ];
  663. };
  664. Util.applyTransform = function Util_applyTransform(p, m) {
  665. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  666. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  667. return [
  668. xt,
  669. yt
  670. ];
  671. };
  672. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  673. var d = m[0] * m[3] - m[1] * m[2];
  674. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  675. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  676. return [
  677. xt,
  678. yt
  679. ];
  680. };
  681. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  682. var p1 = Util.applyTransform(r, m);
  683. var p2 = Util.applyTransform(r.slice(2, 4), m);
  684. var p3 = Util.applyTransform([
  685. r[0],
  686. r[3]
  687. ], m);
  688. var p4 = Util.applyTransform([
  689. r[2],
  690. r[1]
  691. ], m);
  692. return [
  693. Math.min(p1[0], p2[0], p3[0], p4[0]),
  694. Math.min(p1[1], p2[1], p3[1], p4[1]),
  695. Math.max(p1[0], p2[0], p3[0], p4[0]),
  696. Math.max(p1[1], p2[1], p3[1], p4[1])
  697. ];
  698. };
  699. Util.inverseTransform = function Util_inverseTransform(m) {
  700. var d = m[0] * m[3] - m[1] * m[2];
  701. return [
  702. m[3] / d,
  703. -m[1] / d,
  704. -m[2] / d,
  705. m[0] / d,
  706. (m[2] * m[5] - m[4] * m[3]) / d,
  707. (m[4] * m[1] - m[5] * m[0]) / d
  708. ];
  709. };
  710. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  711. return [
  712. m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
  713. m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
  714. m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
  715. ];
  716. };
  717. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  718. var transpose = [
  719. m[0],
  720. m[2],
  721. m[1],
  722. m[3]
  723. ];
  724. var a = m[0] * transpose[0] + m[1] * transpose[2];
  725. var b = m[0] * transpose[1] + m[1] * transpose[3];
  726. var c = m[2] * transpose[0] + m[3] * transpose[2];
  727. var d = m[2] * transpose[1] + m[3] * transpose[3];
  728. var first = (a + d) / 2;
  729. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  730. var sx = first + second || 1;
  731. var sy = first - second || 1;
  732. return [
  733. Math.sqrt(sx),
  734. Math.sqrt(sy)
  735. ];
  736. };
  737. Util.normalizeRect = function Util_normalizeRect(rect) {
  738. var r = rect.slice(0);
  739. if (rect[0] > rect[2]) {
  740. r[0] = rect[2];
  741. r[2] = rect[0];
  742. }
  743. if (rect[1] > rect[3]) {
  744. r[1] = rect[3];
  745. r[3] = rect[1];
  746. }
  747. return r;
  748. };
  749. Util.intersect = function Util_intersect(rect1, rect2) {
  750. function compare(a, b) {
  751. return a - b;
  752. }
  753. var orderedX = [
  754. rect1[0],
  755. rect1[2],
  756. rect2[0],
  757. rect2[2]
  758. ].sort(compare), orderedY = [
  759. rect1[1],
  760. rect1[3],
  761. rect2[1],
  762. rect2[3]
  763. ].sort(compare), result = [];
  764. rect1 = Util.normalizeRect(rect1);
  765. rect2 = Util.normalizeRect(rect2);
  766. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  767. result[0] = orderedX[1];
  768. result[2] = orderedX[2];
  769. } else {
  770. return false;
  771. }
  772. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  773. result[1] = orderedY[1];
  774. result[3] = orderedY[2];
  775. } else {
  776. return false;
  777. }
  778. return result;
  779. };
  780. Util.sign = function Util_sign(num) {
  781. return num < 0 ? -1 : 1;
  782. };
  783. var ROMAN_NUMBER_MAP = [
  784. '',
  785. 'C',
  786. 'CC',
  787. 'CCC',
  788. 'CD',
  789. 'D',
  790. 'DC',
  791. 'DCC',
  792. 'DCCC',
  793. 'CM',
  794. '',
  795. 'X',
  796. 'XX',
  797. 'XXX',
  798. 'XL',
  799. 'L',
  800. 'LX',
  801. 'LXX',
  802. 'LXXX',
  803. 'XC',
  804. '',
  805. 'I',
  806. 'II',
  807. 'III',
  808. 'IV',
  809. 'V',
  810. 'VI',
  811. 'VII',
  812. 'VIII',
  813. 'IX'
  814. ];
  815. Util.toRoman = function Util_toRoman(number, lowerCase) {
  816. assert(isInt(number) && number > 0, 'The number should be a positive integer.');
  817. var pos, romanBuf = [];
  818. while (number >= 1000) {
  819. number -= 1000;
  820. romanBuf.push('M');
  821. }
  822. pos = number / 100 | 0;
  823. number %= 100;
  824. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  825. pos = number / 10 | 0;
  826. number %= 10;
  827. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  828. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  829. var romanStr = romanBuf.join('');
  830. return lowerCase ? romanStr.toLowerCase() : romanStr;
  831. };
  832. Util.appendToArray = function Util_appendToArray(arr1, arr2) {
  833. Array.prototype.push.apply(arr1, arr2);
  834. };
  835. Util.prependToArray = function Util_prependToArray(arr1, arr2) {
  836. Array.prototype.unshift.apply(arr1, arr2);
  837. };
  838. Util.extendObj = function extendObj(obj1, obj2) {
  839. for (var key in obj2) {
  840. obj1[key] = obj2[key];
  841. }
  842. };
  843. Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
  844. while (dict && !dict.has(name)) {
  845. dict = dict.get('Parent');
  846. }
  847. if (!dict) {
  848. return null;
  849. }
  850. return getArray ? dict.getArray(name) : dict.get(name);
  851. };
  852. Util.inherit = function Util_inherit(sub, base, prototype) {
  853. sub.prototype = Object.create(base.prototype);
  854. sub.prototype.constructor = sub;
  855. for (var prop in prototype) {
  856. sub.prototype[prop] = prototype[prop];
  857. }
  858. };
  859. Util.loadScript = function Util_loadScript(src, callback) {
  860. var script = document.createElement('script');
  861. var loaded = false;
  862. script.setAttribute('src', src);
  863. if (callback) {
  864. script.onload = function () {
  865. if (!loaded) {
  866. callback();
  867. }
  868. loaded = true;
  869. };
  870. }
  871. document.getElementsByTagName('head')[0].appendChild(script);
  872. };
  873. return Util;
  874. }();
  875. var PageViewport = function PageViewportClosure() {
  876. function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
  877. this.viewBox = viewBox;
  878. this.scale = scale;
  879. this.rotation = rotation;
  880. this.offsetX = offsetX;
  881. this.offsetY = offsetY;
  882. var centerX = (viewBox[2] + viewBox[0]) / 2;
  883. var centerY = (viewBox[3] + viewBox[1]) / 2;
  884. var rotateA, rotateB, rotateC, rotateD;
  885. rotation = rotation % 360;
  886. rotation = rotation < 0 ? rotation + 360 : rotation;
  887. switch (rotation) {
  888. case 180:
  889. rotateA = -1;
  890. rotateB = 0;
  891. rotateC = 0;
  892. rotateD = 1;
  893. break;
  894. case 90:
  895. rotateA = 0;
  896. rotateB = 1;
  897. rotateC = 1;
  898. rotateD = 0;
  899. break;
  900. case 270:
  901. rotateA = 0;
  902. rotateB = -1;
  903. rotateC = -1;
  904. rotateD = 0;
  905. break;
  906. default:
  907. rotateA = 1;
  908. rotateB = 0;
  909. rotateC = 0;
  910. rotateD = -1;
  911. break;
  912. }
  913. if (dontFlip) {
  914. rotateC = -rotateC;
  915. rotateD = -rotateD;
  916. }
  917. var offsetCanvasX, offsetCanvasY;
  918. var width, height;
  919. if (rotateA === 0) {
  920. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  921. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  922. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  923. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  924. } else {
  925. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  926. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  927. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  928. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  929. }
  930. this.transform = [
  931. rotateA * scale,
  932. rotateB * scale,
  933. rotateC * scale,
  934. rotateD * scale,
  935. offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
  936. offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
  937. ];
  938. this.width = width;
  939. this.height = height;
  940. this.fontScale = scale;
  941. }
  942. PageViewport.prototype = {
  943. clone: function PageViewPort_clone(args) {
  944. args = args || {};
  945. var scale = 'scale' in args ? args.scale : this.scale;
  946. var rotation = 'rotation' in args ? args.rotation : this.rotation;
  947. return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
  948. },
  949. convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
  950. return Util.applyTransform([
  951. x,
  952. y
  953. ], this.transform);
  954. },
  955. convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
  956. var tl = Util.applyTransform([
  957. rect[0],
  958. rect[1]
  959. ], this.transform);
  960. var br = Util.applyTransform([
  961. rect[2],
  962. rect[3]
  963. ], this.transform);
  964. return [
  965. tl[0],
  966. tl[1],
  967. br[0],
  968. br[1]
  969. ];
  970. },
  971. convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
  972. return Util.applyInverseTransform([
  973. x,
  974. y
  975. ], this.transform);
  976. }
  977. };
  978. return PageViewport;
  979. }();
  980. var PDFStringTranslateTable = [
  981. 0,
  982. 0,
  983. 0,
  984. 0,
  985. 0,
  986. 0,
  987. 0,
  988. 0,
  989. 0,
  990. 0,
  991. 0,
  992. 0,
  993. 0,
  994. 0,
  995. 0,
  996. 0,
  997. 0,
  998. 0,
  999. 0,
  1000. 0,
  1001. 0,
  1002. 0,
  1003. 0,
  1004. 0,
  1005. 0x2D8,
  1006. 0x2C7,
  1007. 0x2C6,
  1008. 0x2D9,
  1009. 0x2DD,
  1010. 0x2DB,
  1011. 0x2DA,
  1012. 0x2DC,
  1013. 0,
  1014. 0,
  1015. 0,
  1016. 0,
  1017. 0,
  1018. 0,
  1019. 0,
  1020. 0,
  1021. 0,
  1022. 0,
  1023. 0,
  1024. 0,
  1025. 0,
  1026. 0,
  1027. 0,
  1028. 0,
  1029. 0,
  1030. 0,
  1031. 0,
  1032. 0,
  1033. 0,
  1034. 0,
  1035. 0,
  1036. 0,
  1037. 0,
  1038. 0,
  1039. 0,
  1040. 0,
  1041. 0,
  1042. 0,
  1043. 0,
  1044. 0,
  1045. 0,
  1046. 0,
  1047. 0,
  1048. 0,
  1049. 0,
  1050. 0,
  1051. 0,
  1052. 0,
  1053. 0,
  1054. 0,
  1055. 0,
  1056. 0,
  1057. 0,
  1058. 0,
  1059. 0,
  1060. 0,
  1061. 0,
  1062. 0,
  1063. 0,
  1064. 0,
  1065. 0,
  1066. 0,
  1067. 0,
  1068. 0,
  1069. 0,
  1070. 0,
  1071. 0,
  1072. 0,
  1073. 0,
  1074. 0,
  1075. 0,
  1076. 0,
  1077. 0,
  1078. 0,
  1079. 0,
  1080. 0,
  1081. 0,
  1082. 0,
  1083. 0,
  1084. 0,
  1085. 0,
  1086. 0,
  1087. 0,
  1088. 0,
  1089. 0,
  1090. 0,
  1091. 0,
  1092. 0,
  1093. 0,
  1094. 0,
  1095. 0,
  1096. 0,
  1097. 0,
  1098. 0,
  1099. 0,
  1100. 0,
  1101. 0,
  1102. 0,
  1103. 0,
  1104. 0,
  1105. 0,
  1106. 0,
  1107. 0,
  1108. 0,
  1109. 0x2022,
  1110. 0x2020,
  1111. 0x2021,
  1112. 0x2026,
  1113. 0x2014,
  1114. 0x2013,
  1115. 0x192,
  1116. 0x2044,
  1117. 0x2039,
  1118. 0x203A,
  1119. 0x2212,
  1120. 0x2030,
  1121. 0x201E,
  1122. 0x201C,
  1123. 0x201D,
  1124. 0x2018,
  1125. 0x2019,
  1126. 0x201A,
  1127. 0x2122,
  1128. 0xFB01,
  1129. 0xFB02,
  1130. 0x141,
  1131. 0x152,
  1132. 0x160,
  1133. 0x178,
  1134. 0x17D,
  1135. 0x131,
  1136. 0x142,
  1137. 0x153,
  1138. 0x161,
  1139. 0x17E,
  1140. 0,
  1141. 0x20AC
  1142. ];
  1143. function stringToPDFString(str) {
  1144. var i, n = str.length, strBuf = [];
  1145. if (str[0] === '\xFE' && str[1] === '\xFF') {
  1146. for (i = 2; i < n; i += 2) {
  1147. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  1148. }
  1149. } else {
  1150. for (i = 0; i < n; ++i) {
  1151. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  1152. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  1153. }
  1154. }
  1155. return strBuf.join('');
  1156. }
  1157. function stringToUTF8String(str) {
  1158. return decodeURIComponent(escape(str));
  1159. }
  1160. function utf8StringToString(str) {
  1161. return unescape(encodeURIComponent(str));
  1162. }
  1163. function isEmptyObj(obj) {
  1164. for (var key in obj) {
  1165. return false;
  1166. }
  1167. return true;
  1168. }
  1169. function isBool(v) {
  1170. return typeof v === 'boolean';
  1171. }
  1172. function isInt(v) {
  1173. return typeof v === 'number' && (v | 0) === v;
  1174. }
  1175. function isNum(v) {
  1176. return typeof v === 'number';
  1177. }
  1178. function isString(v) {
  1179. return typeof v === 'string';
  1180. }
  1181. function isArray(v) {
  1182. return v instanceof Array;
  1183. }
  1184. function isArrayBuffer(v) {
  1185. return typeof v === 'object' && v !== null && v.byteLength !== undefined;
  1186. }
  1187. function isSpace(ch) {
  1188. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  1189. }
  1190. function isNodeJS() {
  1191. if (typeof __pdfjsdev_webpack__ === 'undefined') {
  1192. return typeof process === 'object' && process + '' === '[object process]';
  1193. }
  1194. return false;
  1195. }
  1196. function createPromiseCapability() {
  1197. var capability = {};
  1198. capability.promise = new Promise(function (resolve, reject) {
  1199. capability.resolve = resolve;
  1200. capability.reject = reject;
  1201. });
  1202. return capability;
  1203. }
  1204. (function PromiseClosure() {
  1205. if (globalScope.Promise) {
  1206. if (typeof globalScope.Promise.all !== 'function') {
  1207. globalScope.Promise.all = function (iterable) {
  1208. var count = 0, results = [], resolve, reject;
  1209. var promise = new globalScope.Promise(function (resolve_, reject_) {
  1210. resolve = resolve_;
  1211. reject = reject_;
  1212. });
  1213. iterable.forEach(function (p, i) {
  1214. count++;
  1215. p.then(function (result) {
  1216. results[i] = result;
  1217. count--;
  1218. if (count === 0) {
  1219. resolve(results);
  1220. }
  1221. }, reject);
  1222. });
  1223. if (count === 0) {
  1224. resolve(results);
  1225. }
  1226. return promise;
  1227. };
  1228. }
  1229. if (typeof globalScope.Promise.resolve !== 'function') {
  1230. globalScope.Promise.resolve = function (value) {
  1231. return new globalScope.Promise(function (resolve) {
  1232. resolve(value);
  1233. });
  1234. };
  1235. }
  1236. if (typeof globalScope.Promise.reject !== 'function') {
  1237. globalScope.Promise.reject = function (reason) {
  1238. return new globalScope.Promise(function (resolve, reject) {
  1239. reject(reason);
  1240. });
  1241. };
  1242. }
  1243. if (typeof globalScope.Promise.prototype.catch !== 'function') {
  1244. globalScope.Promise.prototype.catch = function (onReject) {
  1245. return globalScope.Promise.prototype.then(undefined, onReject);
  1246. };
  1247. }
  1248. return;
  1249. }
  1250. var STATUS_PENDING = 0;
  1251. var STATUS_RESOLVED = 1;
  1252. var STATUS_REJECTED = 2;
  1253. var REJECTION_TIMEOUT = 500;
  1254. var HandlerManager = {
  1255. handlers: [],
  1256. running: false,
  1257. unhandledRejections: [],
  1258. pendingRejectionCheck: false,
  1259. scheduleHandlers: function scheduleHandlers(promise) {
  1260. if (promise._status === STATUS_PENDING) {
  1261. return;
  1262. }
  1263. this.handlers = this.handlers.concat(promise._handlers);
  1264. promise._handlers = [];
  1265. if (this.running) {
  1266. return;
  1267. }
  1268. this.running = true;
  1269. setTimeout(this.runHandlers.bind(this), 0);
  1270. },
  1271. runHandlers: function runHandlers() {
  1272. var RUN_TIMEOUT = 1;
  1273. var timeoutAt = Date.now() + RUN_TIMEOUT;
  1274. while (this.handlers.length > 0) {
  1275. var handler = this.handlers.shift();
  1276. var nextStatus = handler.thisPromise._status;
  1277. var nextValue = handler.thisPromise._value;
  1278. try {
  1279. if (nextStatus === STATUS_RESOLVED) {
  1280. if (typeof handler.onResolve === 'function') {
  1281. nextValue = handler.onResolve(nextValue);
  1282. }
  1283. } else if (typeof handler.onReject === 'function') {
  1284. nextValue = handler.onReject(nextValue);
  1285. nextStatus = STATUS_RESOLVED;
  1286. if (handler.thisPromise._unhandledRejection) {
  1287. this.removeUnhandeledRejection(handler.thisPromise);
  1288. }
  1289. }
  1290. } catch (ex) {
  1291. nextStatus = STATUS_REJECTED;
  1292. nextValue = ex;
  1293. }
  1294. handler.nextPromise._updateStatus(nextStatus, nextValue);
  1295. if (Date.now() >= timeoutAt) {
  1296. break;
  1297. }
  1298. }
  1299. if (this.handlers.length > 0) {
  1300. setTimeout(this.runHandlers.bind(this), 0);
  1301. return;
  1302. }
  1303. this.running = false;
  1304. },
  1305. addUnhandledRejection: function addUnhandledRejection(promise) {
  1306. this.unhandledRejections.push({
  1307. promise: promise,
  1308. time: Date.now()
  1309. });
  1310. this.scheduleRejectionCheck();
  1311. },
  1312. removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
  1313. promise._unhandledRejection = false;
  1314. for (var i = 0; i < this.unhandledRejections.length; i++) {
  1315. if (this.unhandledRejections[i].promise === promise) {
  1316. this.unhandledRejections.splice(i);
  1317. i--;
  1318. }
  1319. }
  1320. },
  1321. scheduleRejectionCheck: function scheduleRejectionCheck() {
  1322. if (this.pendingRejectionCheck) {
  1323. return;
  1324. }
  1325. this.pendingRejectionCheck = true;
  1326. setTimeout(function rejectionCheck() {
  1327. this.pendingRejectionCheck = false;
  1328. var now = Date.now();
  1329. for (var i = 0; i < this.unhandledRejections.length; i++) {
  1330. if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
  1331. var unhandled = this.unhandledRejections[i].promise._value;
  1332. var msg = 'Unhandled rejection: ' + unhandled;
  1333. if (unhandled.stack) {
  1334. msg += '\n' + unhandled.stack;
  1335. }
  1336. warn(msg);
  1337. this.unhandledRejections.splice(i);
  1338. i--;
  1339. }
  1340. }
  1341. if (this.unhandledRejections.length) {
  1342. this.scheduleRejectionCheck();
  1343. }
  1344. }.bind(this), REJECTION_TIMEOUT);
  1345. }
  1346. };
  1347. var Promise = function Promise(resolver) {
  1348. this._status = STATUS_PENDING;
  1349. this._handlers = [];
  1350. try {
  1351. resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
  1352. } catch (e) {
  1353. this._reject(e);
  1354. }
  1355. };
  1356. Promise.all = function Promise_all(promises) {
  1357. var resolveAll, rejectAll;
  1358. var deferred = new Promise(function (resolve, reject) {
  1359. resolveAll = resolve;
  1360. rejectAll = reject;
  1361. });
  1362. var unresolved = promises.length;
  1363. var results = [];
  1364. if (unresolved === 0) {
  1365. resolveAll(results);
  1366. return deferred;
  1367. }
  1368. function reject(reason) {
  1369. if (deferred._status === STATUS_REJECTED) {
  1370. return;
  1371. }
  1372. results = [];
  1373. rejectAll(reason);
  1374. }
  1375. for (var i = 0, ii = promises.length; i < ii; ++i) {
  1376. var promise = promises[i];
  1377. var resolve = function (i) {
  1378. return function (value) {
  1379. if (deferred._status === STATUS_REJECTED) {
  1380. return;
  1381. }
  1382. results[i] = value;
  1383. unresolved--;
  1384. if (unresolved === 0) {
  1385. resolveAll(results);
  1386. }
  1387. };
  1388. }(i);
  1389. if (Promise.isPromise(promise)) {
  1390. promise.then(resolve, reject);
  1391. } else {
  1392. resolve(promise);
  1393. }
  1394. }
  1395. return deferred;
  1396. };
  1397. Promise.isPromise = function Promise_isPromise(value) {
  1398. return value && typeof value.then === 'function';
  1399. };
  1400. Promise.resolve = function Promise_resolve(value) {
  1401. return new Promise(function (resolve) {
  1402. resolve(value);
  1403. });
  1404. };
  1405. Promise.reject = function Promise_reject(reason) {
  1406. return new Promise(function (resolve, reject) {
  1407. reject(reason);
  1408. });
  1409. };
  1410. Promise.prototype = {
  1411. _status: null,
  1412. _value: null,
  1413. _handlers: null,
  1414. _unhandledRejection: null,
  1415. _updateStatus: function Promise__updateStatus(status, value) {
  1416. if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) {
  1417. return;
  1418. }
  1419. if (status === STATUS_RESOLVED && Promise.isPromise(value)) {
  1420. value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED));
  1421. return;
  1422. }
  1423. this._status = status;
  1424. this._value = value;
  1425. if (status === STATUS_REJECTED && this._handlers.length === 0) {
  1426. this._unhandledRejection = true;
  1427. HandlerManager.addUnhandledRejection(this);
  1428. }
  1429. HandlerManager.scheduleHandlers(this);
  1430. },
  1431. _resolve: function Promise_resolve(value) {
  1432. this._updateStatus(STATUS_RESOLVED, value);
  1433. },
  1434. _reject: function Promise_reject(reason) {
  1435. this._updateStatus(STATUS_REJECTED, reason);
  1436. },
  1437. then: function Promise_then(onResolve, onReject) {
  1438. var nextPromise = new Promise(function (resolve, reject) {
  1439. this.resolve = resolve;
  1440. this.reject = reject;
  1441. });
  1442. this._handlers.push({
  1443. thisPromise: this,
  1444. onResolve: onResolve,
  1445. onReject: onReject,
  1446. nextPromise: nextPromise
  1447. });
  1448. HandlerManager.scheduleHandlers(this);
  1449. return nextPromise;
  1450. },
  1451. catch: function Promise_catch(onReject) {
  1452. return this.then(undefined, onReject);
  1453. }
  1454. };
  1455. globalScope.Promise = Promise;
  1456. }());
  1457. (function WeakMapClosure() {
  1458. if (globalScope.WeakMap) {
  1459. return;
  1460. }
  1461. var id = 0;
  1462. function WeakMap() {
  1463. this.id = '$weakmap' + id++;
  1464. }
  1465. WeakMap.prototype = {
  1466. has: function (obj) {
  1467. return !!Object.getOwnPropertyDescriptor(obj, this.id);
  1468. },
  1469. get: function (obj, defaultValue) {
  1470. return this.has(obj) ? obj[this.id] : defaultValue;
  1471. },
  1472. set: function (obj, value) {
  1473. Object.defineProperty(obj, this.id, {
  1474. value: value,
  1475. enumerable: false,
  1476. configurable: true
  1477. });
  1478. },
  1479. delete: function (obj) {
  1480. delete obj[this.id];
  1481. }
  1482. };
  1483. globalScope.WeakMap = WeakMap;
  1484. }());
  1485. var StatTimer = function StatTimerClosure() {
  1486. function rpad(str, pad, length) {
  1487. while (str.length < length) {
  1488. str += pad;
  1489. }
  1490. return str;
  1491. }
  1492. function StatTimer() {
  1493. this.started = Object.create(null);
  1494. this.times = [];
  1495. this.enabled = true;
  1496. }
  1497. StatTimer.prototype = {
  1498. time: function StatTimer_time(name) {
  1499. if (!this.enabled) {
  1500. return;
  1501. }
  1502. if (name in this.started) {
  1503. warn('Timer is already running for ' + name);
  1504. }
  1505. this.started[name] = Date.now();
  1506. },
  1507. timeEnd: function StatTimer_timeEnd(name) {
  1508. if (!this.enabled) {
  1509. return;
  1510. }
  1511. if (!(name in this.started)) {
  1512. warn('Timer has not been started for ' + name);
  1513. }
  1514. this.times.push({
  1515. 'name': name,
  1516. 'start': this.started[name],
  1517. 'end': Date.now()
  1518. });
  1519. delete this.started[name];
  1520. },
  1521. toString: function StatTimer_toString() {
  1522. var i, ii;
  1523. var times = this.times;
  1524. var out = '';
  1525. var longest = 0;
  1526. for (i = 0, ii = times.length; i < ii; ++i) {
  1527. var name = times[i]['name'];
  1528. if (name.length > longest) {
  1529. longest = name.length;
  1530. }
  1531. }
  1532. for (i = 0, ii = times.length; i < ii; ++i) {
  1533. var span = times[i];
  1534. var duration = span.end - span.start;
  1535. out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
  1536. }
  1537. return out;
  1538. }
  1539. };
  1540. return StatTimer;
  1541. }();
  1542. var createBlob = function createBlob(data, contentType) {
  1543. if (typeof Blob !== 'undefined') {
  1544. return new Blob([data], { type: contentType });
  1545. }
  1546. warn('The "Blob" constructor is not supported.');
  1547. };
  1548. var createObjectURL = function createObjectURLClosure() {
  1549. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  1550. return function createObjectURL(data, contentType, forceDataSchema) {
  1551. if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
  1552. var blob = createBlob(data, contentType);
  1553. return URL.createObjectURL(blob);
  1554. }
  1555. var buffer = 'data:' + contentType + ';base64,';
  1556. for (var i = 0, ii = data.length; i < ii; i += 3) {
  1557. var b1 = data[i] & 0xFF;
  1558. var b2 = data[i + 1] & 0xFF;
  1559. var b3 = data[i + 2] & 0xFF;
  1560. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  1561. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  1562. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  1563. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  1564. }
  1565. return buffer;
  1566. };
  1567. }();
  1568. function MessageHandler(sourceName, targetName, comObj) {
  1569. this.sourceName = sourceName;
  1570. this.targetName = targetName;
  1571. this.comObj = comObj;
  1572. this.callbackIndex = 1;
  1573. this.postMessageTransfers = true;
  1574. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  1575. var ah = this.actionHandler = Object.create(null);
  1576. this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
  1577. var data = event.data;
  1578. if (data.targetName !== this.sourceName) {
  1579. return;
  1580. }
  1581. if (data.isReply) {
  1582. var callbackId = data.callbackId;
  1583. if (data.callbackId in callbacksCapabilities) {
  1584. var callback = callbacksCapabilities[callbackId];
  1585. delete callbacksCapabilities[callbackId];
  1586. if ('error' in data) {
  1587. callback.reject(data.error);
  1588. } else {
  1589. callback.resolve(data.data);
  1590. }
  1591. } else {
  1592. error('Cannot resolve callback ' + callbackId);
  1593. }
  1594. } else if (data.action in ah) {
  1595. var action = ah[data.action];
  1596. if (data.callbackId) {
  1597. var sourceName = this.sourceName;
  1598. var targetName = data.sourceName;
  1599. Promise.resolve().then(function () {
  1600. return action[0].call(action[1], data.data);
  1601. }).then(function (result) {
  1602. comObj.postMessage({
  1603. sourceName: sourceName,
  1604. targetName: targetName,
  1605. isReply: true,
  1606. callbackId: data.callbackId,
  1607. data: result
  1608. });
  1609. }, function (reason) {
  1610. if (reason instanceof Error) {
  1611. reason = reason + '';
  1612. }
  1613. comObj.postMessage({
  1614. sourceName: sourceName,
  1615. targetName: targetName,
  1616. isReply: true,
  1617. callbackId: data.callbackId,
  1618. error: reason
  1619. });
  1620. });
  1621. } else {
  1622. action[0].call(action[1], data.data);
  1623. }
  1624. } else {
  1625. error('Unknown action from worker: ' + data.action);
  1626. }
  1627. }.bind(this);
  1628. comObj.addEventListener('message', this._onComObjOnMessage);
  1629. }
  1630. MessageHandler.prototype = {
  1631. on: function messageHandlerOn(actionName, handler, scope) {
  1632. var ah = this.actionHandler;
  1633. if (ah[actionName]) {
  1634. error('There is already an actionName called "' + actionName + '"');
  1635. }
  1636. ah[actionName] = [
  1637. handler,
  1638. scope
  1639. ];
  1640. },
  1641. send: function messageHandlerSend(actionName, data, transfers) {
  1642. var message = {
  1643. sourceName: this.sourceName,
  1644. targetName: this.targetName,
  1645. action: actionName,
  1646. data: data
  1647. };
  1648. this.postMessage(message, transfers);
  1649. },
  1650. sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
  1651. var callbackId = this.callbackIndex++;
  1652. var message = {
  1653. sourceName: this.sourceName,
  1654. targetName: this.targetName,
  1655. action: actionName,
  1656. data: data,
  1657. callbackId: callbackId
  1658. };
  1659. var capability = createPromiseCapability();
  1660. this.callbacksCapabilities[callbackId] = capability;
  1661. try {
  1662. this.postMessage(message, transfers);
  1663. } catch (e) {
  1664. capability.reject(e);
  1665. }
  1666. return capability.promise;
  1667. },
  1668. postMessage: function (message, transfers) {
  1669. if (transfers && this.postMessageTransfers) {
  1670. this.comObj.postMessage(message, transfers);
  1671. } else {
  1672. this.comObj.postMessage(message);
  1673. }
  1674. },
  1675. destroy: function () {
  1676. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  1677. }
  1678. };
  1679. function loadJpegStream(id, imageUrl, objs) {
  1680. var img = new Image();
  1681. img.onload = function loadJpegStream_onloadClosure() {
  1682. objs.resolve(id, img);
  1683. };
  1684. img.onerror = function loadJpegStream_onerrorClosure() {
  1685. objs.resolve(id, null);
  1686. warn('Error during JPEG image loading');
  1687. };
  1688. img.src = imageUrl;
  1689. }
  1690. (function checkURLConstructor(scope) {
  1691. var hasWorkingUrl = false;
  1692. try {
  1693. if (typeof URL === 'function' && typeof URL.prototype === 'object' && 'origin' in URL.prototype) {
  1694. var u = new URL('b', 'http://a');
  1695. u.pathname = 'c%20d';
  1696. hasWorkingUrl = u.href === 'http://a/c%20d';
  1697. }
  1698. } catch (e) {
  1699. }
  1700. if (hasWorkingUrl) {
  1701. return;
  1702. }
  1703. var relative = Object.create(null);
  1704. relative['ftp'] = 21;
  1705. relative['file'] = 0;
  1706. relative['gopher'] = 70;
  1707. relative['http'] = 80;
  1708. relative['https'] = 443;
  1709. relative['ws'] = 80;
  1710. relative['wss'] = 443;
  1711. var relativePathDotMapping = Object.create(null);
  1712. relativePathDotMapping['%2e'] = '.';
  1713. relativePathDotMapping['.%2e'] = '..';
  1714. relativePathDotMapping['%2e.'] = '..';
  1715. relativePathDotMapping['%2e%2e'] = '..';
  1716. function isRelativeScheme(scheme) {
  1717. return relative[scheme] !== undefined;
  1718. }
  1719. function invalid() {
  1720. clear.call(this);
  1721. this._isInvalid = true;
  1722. }
  1723. function IDNAToASCII(h) {
  1724. if (h === '') {
  1725. invalid.call(this);
  1726. }
  1727. return h.toLowerCase();
  1728. }
  1729. function percentEscape(c) {
  1730. var unicode = c.charCodeAt(0);
  1731. if (unicode > 0x20 && unicode < 0x7F && [
  1732. 0x22,
  1733. 0x23,
  1734. 0x3C,
  1735. 0x3E,
  1736. 0x3F,
  1737. 0x60
  1738. ].indexOf(unicode) === -1) {
  1739. return c;
  1740. }
  1741. return encodeURIComponent(c);
  1742. }
  1743. function percentEscapeQuery(c) {
  1744. var unicode = c.charCodeAt(0);
  1745. if (unicode > 0x20 && unicode < 0x7F && [
  1746. 0x22,
  1747. 0x23,
  1748. 0x3C,
  1749. 0x3E,
  1750. 0x60
  1751. ].indexOf(unicode) === -1) {
  1752. return c;
  1753. }
  1754. return encodeURIComponent(c);
  1755. }
  1756. var EOF, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  1757. function parse(input, stateOverride, base) {
  1758. function err(message) {
  1759. errors.push(message);
  1760. }
  1761. var state = stateOverride || 'scheme start', cursor = 0, buffer = '', seenAt = false, seenBracket = false, errors = [];
  1762. loop:
  1763. while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  1764. var c = input[cursor];
  1765. switch (state) {
  1766. case 'scheme start':
  1767. if (c && ALPHA.test(c)) {
  1768. buffer += c.toLowerCase();
  1769. state = 'scheme';
  1770. } else if (!stateOverride) {
  1771. buffer = '';
  1772. state = 'no scheme';
  1773. continue;
  1774. } else {
  1775. err('Invalid scheme.');
  1776. break loop;
  1777. }
  1778. break;
  1779. case 'scheme':
  1780. if (c && ALPHANUMERIC.test(c)) {
  1781. buffer += c.toLowerCase();
  1782. } else if (c === ':') {
  1783. this._scheme = buffer;
  1784. buffer = '';
  1785. if (stateOverride) {
  1786. break loop;
  1787. }
  1788. if (isRelativeScheme(this._scheme)) {
  1789. this._isRelative = true;
  1790. }
  1791. if (this._scheme === 'file') {
  1792. state = 'relative';
  1793. } else if (this._isRelative && base && base._scheme === this._scheme) {
  1794. state = 'relative or authority';
  1795. } else if (this._isRelative) {
  1796. state = 'authority first slash';
  1797. } else {
  1798. state = 'scheme data';
  1799. }
  1800. } else if (!stateOverride) {
  1801. buffer = '';
  1802. cursor = 0;
  1803. state = 'no scheme';
  1804. continue;
  1805. } else if (EOF === c) {
  1806. break loop;
  1807. } else {
  1808. err('Code point not allowed in scheme: ' + c);
  1809. break loop;
  1810. }
  1811. break;
  1812. case 'scheme data':
  1813. if (c === '?') {
  1814. this._query = '?';
  1815. state = 'query';
  1816. } else if (c === '#') {
  1817. this._fragment = '#';
  1818. state = 'fragment';
  1819. } else {
  1820. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  1821. this._schemeData += percentEscape(c);
  1822. }
  1823. }
  1824. break;
  1825. case 'no scheme':
  1826. if (!base || !isRelativeScheme(base._scheme)) {
  1827. err('Missing scheme.');
  1828. invalid.call(this);
  1829. } else {
  1830. state = 'relative';
  1831. continue;
  1832. }
  1833. break;
  1834. case 'relative or authority':
  1835. if (c === '/' && input[cursor + 1] === '/') {
  1836. state = 'authority ignore slashes';
  1837. } else {
  1838. err('Expected /, got: ' + c);
  1839. state = 'relative';
  1840. continue;
  1841. }
  1842. break;
  1843. case 'relative':
  1844. this._isRelative = true;
  1845. if ('file' !== this._scheme) {
  1846. this._scheme = base._scheme;
  1847. }
  1848. if (EOF === c) {
  1849. this._host = base._host;
  1850. this._port = base._port;
  1851. this._path = base._path.slice();
  1852. this._query = base._query;
  1853. this._username = base._username;
  1854. this._password = base._password;
  1855. break loop;
  1856. } else if (c === '/' || c === '\\') {
  1857. if (c === '\\') {
  1858. err('\\ is an invalid code point.');
  1859. }
  1860. state = 'relative slash';
  1861. } else if (c === '?') {
  1862. this._host = base._host;
  1863. this._port = base._port;
  1864. this._path = base._path.slice();
  1865. this._query = '?';
  1866. this._username = base._username;
  1867. this._password = base._password;
  1868. state = 'query';
  1869. } else if (c === '#') {
  1870. this._host = base._host;
  1871. this._port = base._port;
  1872. this._path = base._path.slice();
  1873. this._query = base._query;
  1874. this._fragment = '#';
  1875. this._username = base._username;
  1876. this._password = base._password;
  1877. state = 'fragment';
  1878. } else {
  1879. var nextC = input[cursor + 1];
  1880. var nextNextC = input[cursor + 2];
  1881. if ('file' !== this._scheme || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || EOF !== nextNextC && '/' !== nextNextC && '\\' !== nextNextC && '?' !== nextNextC && '#' !== nextNextC) {
  1882. this._host = base._host;
  1883. this._port = base._port;
  1884. this._username = base._username;
  1885. this._password = base._password;
  1886. this._path = base._path.slice();
  1887. this._path.pop();
  1888. }
  1889. state = 'relative path';
  1890. continue;
  1891. }
  1892. break;
  1893. case 'relative slash':
  1894. if (c === '/' || c === '\\') {
  1895. if (c === '\\') {
  1896. err('\\ is an invalid code point.');
  1897. }
  1898. if (this._scheme === 'file') {
  1899. state = 'file host';
  1900. } else {
  1901. state = 'authority ignore slashes';
  1902. }
  1903. } else {
  1904. if ('file' !== this._scheme) {
  1905. this._host = base._host;
  1906. this._port = base._port;
  1907. this._username = base._username;
  1908. this._password = base._password;
  1909. }
  1910. state = 'relative path';
  1911. continue;
  1912. }
  1913. break;
  1914. case 'authority first slash':
  1915. if (c === '/') {
  1916. state = 'authority second slash';
  1917. } else {
  1918. err('Expected \'/\', got: ' + c);
  1919. state = 'authority ignore slashes';
  1920. continue;
  1921. }
  1922. break;
  1923. case 'authority second slash':
  1924. state = 'authority ignore slashes';
  1925. if ('/' !== c) {
  1926. err('Expected \'/\', got: ' + c);
  1927. continue;
  1928. }
  1929. break;
  1930. case 'authority ignore slashes':
  1931. if ('/' !== c && '\\' !== c) {
  1932. state = 'authority';
  1933. continue;
  1934. } else {
  1935. err('Expected authority, got: ' + c);
  1936. }
  1937. break;
  1938. case 'authority':
  1939. if (c === '@') {
  1940. if (seenAt) {
  1941. err('@ already seen.');
  1942. buffer += '%40';
  1943. }
  1944. seenAt = true;
  1945. for (var i = 0; i < buffer.length; i++) {
  1946. var cp = buffer[i];
  1947. if (cp === '\t' || cp === '\n' || cp === '\r') {
  1948. err('Invalid whitespace in authority.');
  1949. continue;
  1950. }
  1951. if (cp === ':' && this._password === null) {
  1952. this._password = '';
  1953. continue;
  1954. }
  1955. var tempC = percentEscape(cp);
  1956. if (null !== this._password) {
  1957. this._password += tempC;
  1958. } else {
  1959. this._username += tempC;
  1960. }
  1961. }
  1962. buffer = '';
  1963. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  1964. cursor -= buffer.length;
  1965. buffer = '';
  1966. state = 'host';
  1967. continue;
  1968. } else {
  1969. buffer += c;
  1970. }
  1971. break;
  1972. case 'file host':
  1973. if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  1974. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  1975. state = 'relative path';
  1976. } else if (buffer.length === 0) {
  1977. state = 'relative path start';
  1978. } else {
  1979. this._host = IDNAToASCII.call(this, buffer);
  1980. buffer = '';
  1981. state = 'relative path start';
  1982. }
  1983. continue;
  1984. } else if (c === '\t' || c === '\n' || c === '\r') {
  1985. err('Invalid whitespace in file host.');
  1986. } else {
  1987. buffer += c;
  1988. }
  1989. break;
  1990. case 'host':
  1991. case 'hostname':
  1992. if (c === ':' && !seenBracket) {
  1993. this._host = IDNAToASCII.call(this, buffer);
  1994. buffer = '';
  1995. state = 'port';
  1996. if (stateOverride === 'hostname') {
  1997. break loop;
  1998. }
  1999. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  2000. this._host = IDNAToASCII.call(this, buffer);
  2001. buffer = '';
  2002. state = 'relative path start';
  2003. if (stateOverride) {
  2004. break loop;
  2005. }
  2006. continue;
  2007. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  2008. if (c === '[') {
  2009. seenBracket = true;
  2010. } else if (c === ']') {
  2011. seenBracket = false;
  2012. }
  2013. buffer += c;
  2014. } else {
  2015. err('Invalid code point in host/hostname: ' + c);
  2016. }
  2017. break;
  2018. case 'port':
  2019. if (/[0-9]/.test(c)) {
  2020. buffer += c;
  2021. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) {
  2022. if ('' !== buffer) {
  2023. var temp = parseInt(buffer, 10);
  2024. if (temp !== relative[this._scheme]) {
  2025. this._port = temp + '';
  2026. }
  2027. buffer = '';
  2028. }
  2029. if (stateOverride) {
  2030. break loop;
  2031. }
  2032. state = 'relative path start';
  2033. continue;
  2034. } else if (c === '\t' || c === '\n' || c === '\r') {
  2035. err('Invalid code point in port: ' + c);
  2036. } else {
  2037. invalid.call(this);
  2038. }
  2039. break;
  2040. case 'relative path start':
  2041. if (c === '\\') {
  2042. err('\'\\\' not allowed in path.');
  2043. }
  2044. state = 'relative path';
  2045. if ('/' !== c && '\\' !== c) {
  2046. continue;
  2047. }
  2048. break;
  2049. case 'relative path':
  2050. if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) {
  2051. if (c === '\\') {
  2052. err('\\ not allowed in relative path.');
  2053. }
  2054. var tmp;
  2055. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  2056. buffer = tmp;
  2057. }
  2058. if (buffer === '..') {
  2059. this._path.pop();
  2060. if ('/' !== c && '\\' !== c) {
  2061. this._path.push('');
  2062. }
  2063. } else if (buffer === '.' && '/' !== c && '\\' !== c) {
  2064. this._path.push('');
  2065. } else if ('.' !== buffer) {
  2066. if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  2067. buffer = buffer[0] + ':';
  2068. }
  2069. this._path.push(buffer);
  2070. }
  2071. buffer = '';
  2072. if (c === '?') {
  2073. this._query = '?';
  2074. state = 'query';
  2075. } else if (c === '#') {
  2076. this._fragment = '#';
  2077. state = 'fragment';
  2078. }
  2079. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  2080. buffer += percentEscape(c);
  2081. }
  2082. break;
  2083. case 'query':
  2084. if (!stateOverride && c === '#') {
  2085. this._fragment = '#';
  2086. state = 'fragment';
  2087. } else if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  2088. this._query += percentEscapeQuery(c);
  2089. }
  2090. break;
  2091. case 'fragment':
  2092. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  2093. this._fragment += c;
  2094. }
  2095. break;
  2096. }
  2097. cursor++;
  2098. }
  2099. }
  2100. function clear() {
  2101. this._scheme = '';
  2102. this._schemeData = '';
  2103. this._username = '';
  2104. this._password = null;
  2105. this._host = '';
  2106. this._port = '';
  2107. this._path = [];
  2108. this._query = '';
  2109. this._fragment = '';
  2110. this._isInvalid = false;
  2111. this._isRelative = false;
  2112. }
  2113. function JURL(url, base) {
  2114. if (base !== undefined && !(base instanceof JURL)) {
  2115. base = new JURL(String(base));
  2116. }
  2117. this._url = url;
  2118. clear.call(this);
  2119. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  2120. parse.call(this, input, null, base);
  2121. }
  2122. JURL.prototype = {
  2123. toString: function () {
  2124. return this.href;
  2125. },
  2126. get href() {
  2127. if (this._isInvalid) {
  2128. return this._url;
  2129. }
  2130. var authority = '';
  2131. if ('' !== this._username || null !== this._password) {
  2132. authority = this._username + (null !== this._password ? ':' + this._password : '') + '@';
  2133. }
  2134. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  2135. },
  2136. set href(href) {
  2137. clear.call(this);
  2138. parse.call(this, href);
  2139. },
  2140. get protocol() {
  2141. return this._scheme + ':';
  2142. },
  2143. set protocol(protocol) {
  2144. if (this._isInvalid) {
  2145. return;
  2146. }
  2147. parse.call(this, protocol + ':', 'scheme start');
  2148. },
  2149. get host() {
  2150. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  2151. },
  2152. set host(host) {
  2153. if (this._isInvalid || !this._isRelative) {
  2154. return;
  2155. }
  2156. parse.call(this, host, 'host');
  2157. },
  2158. get hostname() {
  2159. return this._host;
  2160. },
  2161. set hostname(hostname) {
  2162. if (this._isInvalid || !this._isRelative) {
  2163. return;
  2164. }
  2165. parse.call(this, hostname, 'hostname');
  2166. },
  2167. get port() {
  2168. return this._port;
  2169. },
  2170. set port(port) {
  2171. if (this._isInvalid || !this._isRelative) {
  2172. return;
  2173. }
  2174. parse.call(this, port, 'port');
  2175. },
  2176. get pathname() {
  2177. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  2178. },
  2179. set pathname(pathname) {
  2180. if (this._isInvalid || !this._isRelative) {
  2181. return;
  2182. }
  2183. this._path = [];
  2184. parse.call(this, pathname, 'relative path start');
  2185. },
  2186. get search() {
  2187. return this._isInvalid || !this._query || this._query === '?' ? '' : this._query;
  2188. },
  2189. set search(search) {
  2190. if (this._isInvalid || !this._isRelative) {
  2191. return;
  2192. }
  2193. this._query = '?';
  2194. if (search[0] === '?') {
  2195. search = search.slice(1);
  2196. }
  2197. parse.call(this, search, 'query');
  2198. },
  2199. get hash() {
  2200. return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment;
  2201. },
  2202. set hash(hash) {
  2203. if (this._isInvalid) {
  2204. return;
  2205. }
  2206. this._fragment = '#';
  2207. if (hash[0] === '#') {
  2208. hash = hash.slice(1);
  2209. }
  2210. parse.call(this, hash, 'fragment');
  2211. },
  2212. get origin() {
  2213. var host;
  2214. if (this._isInvalid || !this._scheme) {
  2215. return '';
  2216. }
  2217. switch (this._scheme) {
  2218. case 'data':
  2219. case 'file':
  2220. case 'javascript':
  2221. case 'mailto':
  2222. return 'null';
  2223. }
  2224. host = this.host;
  2225. if (!host) {
  2226. return '';
  2227. }
  2228. return this._scheme + '://' + host;
  2229. }
  2230. };
  2231. var OriginalURL = scope.URL;
  2232. if (OriginalURL) {
  2233. JURL.createObjectURL = function (blob) {
  2234. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  2235. };
  2236. JURL.revokeObjectURL = function (url) {
  2237. OriginalURL.revokeObjectURL(url);
  2238. };
  2239. }
  2240. scope.URL = JURL;
  2241. }(globalScope));
  2242. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  2243. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  2244. exports.OPS = OPS;
  2245. exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
  2246. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  2247. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  2248. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  2249. exports.AnnotationFlag = AnnotationFlag;
  2250. exports.AnnotationType = AnnotationType;
  2251. exports.FontType = FontType;
  2252. exports.ImageKind = ImageKind;
  2253. exports.CMapCompressionType = CMapCompressionType;
  2254. exports.InvalidPDFException = InvalidPDFException;
  2255. exports.MessageHandler = MessageHandler;
  2256. exports.MissingDataException = MissingDataException;
  2257. exports.MissingPDFException = MissingPDFException;
  2258. exports.NotImplementedException = NotImplementedException;
  2259. exports.PageViewport = PageViewport;
  2260. exports.PasswordException = PasswordException;
  2261. exports.PasswordResponses = PasswordResponses;
  2262. exports.StatTimer = StatTimer;
  2263. exports.StreamType = StreamType;
  2264. exports.TextRenderingMode = TextRenderingMode;
  2265. exports.UnexpectedResponseException = UnexpectedResponseException;
  2266. exports.UnknownErrorException = UnknownErrorException;
  2267. exports.Util = Util;
  2268. exports.XRefParseException = XRefParseException;
  2269. exports.arrayByteLength = arrayByteLength;
  2270. exports.arraysToBytes = arraysToBytes;
  2271. exports.assert = assert;
  2272. exports.bytesToString = bytesToString;
  2273. exports.createBlob = createBlob;
  2274. exports.createPromiseCapability = createPromiseCapability;
  2275. exports.createObjectURL = createObjectURL;
  2276. exports.deprecated = deprecated;
  2277. exports.error = error;
  2278. exports.getLookupTableFactory = getLookupTableFactory;
  2279. exports.getVerbosityLevel = getVerbosityLevel;
  2280. exports.globalScope = globalScope;
  2281. exports.info = info;
  2282. exports.isArray = isArray;
  2283. exports.isArrayBuffer = isArrayBuffer;
  2284. exports.isBool = isBool;
  2285. exports.isEmptyObj = isEmptyObj;
  2286. exports.isInt = isInt;
  2287. exports.isNum = isNum;
  2288. exports.isString = isString;
  2289. exports.isSpace = isSpace;
  2290. exports.isNodeJS = isNodeJS;
  2291. exports.isSameOrigin = isSameOrigin;
  2292. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  2293. exports.isLittleEndian = isLittleEndian;
  2294. exports.isEvalSupported = isEvalSupported;
  2295. exports.loadJpegStream = loadJpegStream;
  2296. exports.log2 = log2;
  2297. exports.readInt8 = readInt8;
  2298. exports.readUint16 = readUint16;
  2299. exports.readUint32 = readUint32;
  2300. exports.removeNullCharacters = removeNullCharacters;
  2301. exports.setVerbosityLevel = setVerbosityLevel;
  2302. exports.shadow = shadow;
  2303. exports.string32 = string32;
  2304. exports.stringToBytes = stringToBytes;
  2305. exports.stringToPDFString = stringToPDFString;
  2306. exports.stringToUTF8String = stringToUTF8String;
  2307. exports.utf8StringToString = utf8StringToString;
  2308. exports.warn = warn;
  2309. /* WEBPACK VAR INJECTION */}.call(exports, __w_pdfjs_require__(26)))
  2310. /***/ }),
  2311. /* 1 */
  2312. /***/ (function(module, exports, __w_pdfjs_require__) {
  2313. "use strict";
  2314. var sharedUtil = __w_pdfjs_require__(0);
  2315. var isArray = sharedUtil.isArray;
  2316. var EOF = {};
  2317. var Name = function NameClosure() {
  2318. function Name(name) {
  2319. this.name = name;
  2320. }
  2321. Name.prototype = {};
  2322. var nameCache = Object.create(null);
  2323. Name.get = function Name_get(name) {
  2324. var nameValue = nameCache[name];
  2325. return nameValue ? nameValue : nameCache[name] = new Name(name);
  2326. };
  2327. return Name;
  2328. }();
  2329. var Cmd = function CmdClosure() {
  2330. function Cmd(cmd) {
  2331. this.cmd = cmd;
  2332. }
  2333. Cmd.prototype = {};
  2334. var cmdCache = Object.create(null);
  2335. Cmd.get = function Cmd_get(cmd) {
  2336. var cmdValue = cmdCache[cmd];
  2337. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  2338. };
  2339. return Cmd;
  2340. }();
  2341. var Dict = function DictClosure() {
  2342. var nonSerializable = function nonSerializableClosure() {
  2343. return nonSerializable;
  2344. };
  2345. function Dict(xref) {
  2346. this.map = Object.create(null);
  2347. this.xref = xref;
  2348. this.objId = null;
  2349. this.suppressEncryption = false;
  2350. this.__nonSerializable__ = nonSerializable;
  2351. }
  2352. Dict.prototype = {
  2353. assignXref: function Dict_assignXref(newXref) {
  2354. this.xref = newXref;
  2355. },
  2356. get: function Dict_get(key1, key2, key3) {
  2357. var value;
  2358. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  2359. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  2360. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  2361. }
  2362. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  2363. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  2364. }
  2365. value = this.map[key3] || null;
  2366. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  2367. },
  2368. getAsync: function Dict_getAsync(key1, key2, key3) {
  2369. var value;
  2370. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  2371. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  2372. if (xref) {
  2373. return xref.fetchIfRefAsync(value, suppressEncryption);
  2374. }
  2375. return Promise.resolve(value);
  2376. }
  2377. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  2378. if (xref) {
  2379. return xref.fetchIfRefAsync(value, suppressEncryption);
  2380. }
  2381. return Promise.resolve(value);
  2382. }
  2383. value = this.map[key3] || null;
  2384. if (xref) {
  2385. return xref.fetchIfRefAsync(value, suppressEncryption);
  2386. }
  2387. return Promise.resolve(value);
  2388. },
  2389. getArray: function Dict_getArray(key1, key2, key3) {
  2390. var value = this.get(key1, key2, key3);
  2391. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  2392. if (!isArray(value) || !xref) {
  2393. return value;
  2394. }
  2395. value = value.slice();
  2396. for (var i = 0, ii = value.length; i < ii; i++) {
  2397. if (!isRef(value[i])) {
  2398. continue;
  2399. }
  2400. value[i] = xref.fetch(value[i], suppressEncryption);
  2401. }
  2402. return value;
  2403. },
  2404. getRaw: function Dict_getRaw(key) {
  2405. return this.map[key];
  2406. },
  2407. getKeys: function Dict_getKeys() {
  2408. return Object.keys(this.map);
  2409. },
  2410. set: function Dict_set(key, value) {
  2411. this.map[key] = value;
  2412. },
  2413. has: function Dict_has(key) {
  2414. return key in this.map;
  2415. },
  2416. forEach: function Dict_forEach(callback) {
  2417. for (var key in this.map) {
  2418. callback(key, this.get(key));
  2419. }
  2420. }
  2421. };
  2422. Dict.empty = new Dict(null);
  2423. Dict.merge = function Dict_merge(xref, dictArray) {
  2424. var mergedDict = new Dict(xref);
  2425. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  2426. var dict = dictArray[i];
  2427. if (!isDict(dict)) {
  2428. continue;
  2429. }
  2430. for (var keyName in dict.map) {
  2431. if (mergedDict.map[keyName]) {
  2432. continue;
  2433. }
  2434. mergedDict.map[keyName] = dict.map[keyName];
  2435. }
  2436. }
  2437. return mergedDict;
  2438. };
  2439. return Dict;
  2440. }();
  2441. var Ref = function RefClosure() {
  2442. function Ref(num, gen) {
  2443. this.num = num;
  2444. this.gen = gen;
  2445. }
  2446. Ref.prototype = {
  2447. toString: function Ref_toString() {
  2448. var str = this.num + 'R';
  2449. if (this.gen !== 0) {
  2450. str += this.gen;
  2451. }
  2452. return str;
  2453. }
  2454. };
  2455. return Ref;
  2456. }();
  2457. var RefSet = function RefSetClosure() {
  2458. function RefSet() {
  2459. this.dict = Object.create(null);
  2460. }
  2461. RefSet.prototype = {
  2462. has: function RefSet_has(ref) {
  2463. return ref.toString() in this.dict;
  2464. },
  2465. put: function RefSet_put(ref) {
  2466. this.dict[ref.toString()] = true;
  2467. },
  2468. remove: function RefSet_remove(ref) {
  2469. delete this.dict[ref.toString()];
  2470. }
  2471. };
  2472. return RefSet;
  2473. }();
  2474. var RefSetCache = function RefSetCacheClosure() {
  2475. function RefSetCache() {
  2476. this.dict = Object.create(null);
  2477. }
  2478. RefSetCache.prototype = {
  2479. get: function RefSetCache_get(ref) {
  2480. return this.dict[ref.toString()];
  2481. },
  2482. has: function RefSetCache_has(ref) {
  2483. return ref.toString() in this.dict;
  2484. },
  2485. put: function RefSetCache_put(ref, obj) {
  2486. this.dict[ref.toString()] = obj;
  2487. },
  2488. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  2489. this.dict[ref.toString()] = this.get(aliasRef);
  2490. },
  2491. forEach: function RefSetCache_forEach(fn, thisArg) {
  2492. for (var i in this.dict) {
  2493. fn.call(thisArg, this.dict[i]);
  2494. }
  2495. },
  2496. clear: function RefSetCache_clear() {
  2497. this.dict = Object.create(null);
  2498. }
  2499. };
  2500. return RefSetCache;
  2501. }();
  2502. function isEOF(v) {
  2503. return v === EOF;
  2504. }
  2505. function isName(v, name) {
  2506. return v instanceof Name && (name === undefined || v.name === name);
  2507. }
  2508. function isCmd(v, cmd) {
  2509. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  2510. }
  2511. function isDict(v, type) {
  2512. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  2513. }
  2514. function isRef(v) {
  2515. return v instanceof Ref;
  2516. }
  2517. function isRefsEqual(v1, v2) {
  2518. return v1.num === v2.num && v1.gen === v2.gen;
  2519. }
  2520. function isStream(v) {
  2521. return typeof v === 'object' && v !== null && v.getBytes !== undefined;
  2522. }
  2523. exports.EOF = EOF;
  2524. exports.Cmd = Cmd;
  2525. exports.Dict = Dict;
  2526. exports.Name = Name;
  2527. exports.Ref = Ref;
  2528. exports.RefSet = RefSet;
  2529. exports.RefSetCache = RefSetCache;
  2530. exports.isEOF = isEOF;
  2531. exports.isCmd = isCmd;
  2532. exports.isDict = isDict;
  2533. exports.isName = isName;
  2534. exports.isRef = isRef;
  2535. exports.isRefsEqual = isRefsEqual;
  2536. exports.isStream = isStream;
  2537. /***/ }),
  2538. /* 2 */
  2539. /***/ (function(module, exports, __w_pdfjs_require__) {
  2540. "use strict";
  2541. var sharedUtil = __w_pdfjs_require__(0);
  2542. var corePrimitives = __w_pdfjs_require__(1);
  2543. var coreJbig2 = __w_pdfjs_require__(35);
  2544. var coreJpg = __w_pdfjs_require__(36);
  2545. var coreJpx = __w_pdfjs_require__(18);
  2546. var Util = sharedUtil.Util;
  2547. var error = sharedUtil.error;
  2548. var info = sharedUtil.info;
  2549. var isInt = sharedUtil.isInt;
  2550. var isArray = sharedUtil.isArray;
  2551. var createObjectURL = sharedUtil.createObjectURL;
  2552. var shadow = sharedUtil.shadow;
  2553. var isSpace = sharedUtil.isSpace;
  2554. var Dict = corePrimitives.Dict;
  2555. var isDict = corePrimitives.isDict;
  2556. var isStream = corePrimitives.isStream;
  2557. var Jbig2Image = coreJbig2.Jbig2Image;
  2558. var JpegImage = coreJpg.JpegImage;
  2559. var JpxImage = coreJpx.JpxImage;
  2560. var Stream = function StreamClosure() {
  2561. function Stream(arrayBuffer, start, length, dict) {
  2562. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  2563. this.start = start || 0;
  2564. this.pos = this.start;
  2565. this.end = start + length || this.bytes.length;
  2566. this.dict = dict;
  2567. }
  2568. Stream.prototype = {
  2569. get length() {
  2570. return this.end - this.start;
  2571. },
  2572. get isEmpty() {
  2573. return this.length === 0;
  2574. },
  2575. getByte: function Stream_getByte() {
  2576. if (this.pos >= this.end) {
  2577. return -1;
  2578. }
  2579. return this.bytes[this.pos++];
  2580. },
  2581. getUint16: function Stream_getUint16() {
  2582. var b0 = this.getByte();
  2583. var b1 = this.getByte();
  2584. if (b0 === -1 || b1 === -1) {
  2585. return -1;
  2586. }
  2587. return (b0 << 8) + b1;
  2588. },
  2589. getInt32: function Stream_getInt32() {
  2590. var b0 = this.getByte();
  2591. var b1 = this.getByte();
  2592. var b2 = this.getByte();
  2593. var b3 = this.getByte();
  2594. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  2595. },
  2596. getBytes: function Stream_getBytes(length) {
  2597. var bytes = this.bytes;
  2598. var pos = this.pos;
  2599. var strEnd = this.end;
  2600. if (!length) {
  2601. return bytes.subarray(pos, strEnd);
  2602. }
  2603. var end = pos + length;
  2604. if (end > strEnd) {
  2605. end = strEnd;
  2606. }
  2607. this.pos = end;
  2608. return bytes.subarray(pos, end);
  2609. },
  2610. peekByte: function Stream_peekByte() {
  2611. var peekedByte = this.getByte();
  2612. this.pos--;
  2613. return peekedByte;
  2614. },
  2615. peekBytes: function Stream_peekBytes(length) {
  2616. var bytes = this.getBytes(length);
  2617. this.pos -= bytes.length;
  2618. return bytes;
  2619. },
  2620. skip: function Stream_skip(n) {
  2621. if (!n) {
  2622. n = 1;
  2623. }
  2624. this.pos += n;
  2625. },
  2626. reset: function Stream_reset() {
  2627. this.pos = this.start;
  2628. },
  2629. moveStart: function Stream_moveStart() {
  2630. this.start = this.pos;
  2631. },
  2632. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  2633. return new Stream(this.bytes.buffer, start, length, dict);
  2634. }
  2635. };
  2636. return Stream;
  2637. }();
  2638. var StringStream = function StringStreamClosure() {
  2639. function StringStream(str) {
  2640. var length = str.length;
  2641. var bytes = new Uint8Array(length);
  2642. for (var n = 0; n < length; ++n) {
  2643. bytes[n] = str.charCodeAt(n);
  2644. }
  2645. Stream.call(this, bytes);
  2646. }
  2647. StringStream.prototype = Stream.prototype;
  2648. return StringStream;
  2649. }();
  2650. var DecodeStream = function DecodeStreamClosure() {
  2651. var emptyBuffer = new Uint8Array(0);
  2652. function DecodeStream(maybeMinBufferLength) {
  2653. this.pos = 0;
  2654. this.bufferLength = 0;
  2655. this.eof = false;
  2656. this.buffer = emptyBuffer;
  2657. this.minBufferLength = 512;
  2658. if (maybeMinBufferLength) {
  2659. while (this.minBufferLength < maybeMinBufferLength) {
  2660. this.minBufferLength *= 2;
  2661. }
  2662. }
  2663. }
  2664. DecodeStream.prototype = {
  2665. get isEmpty() {
  2666. while (!this.eof && this.bufferLength === 0) {
  2667. this.readBlock();
  2668. }
  2669. return this.bufferLength === 0;
  2670. },
  2671. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  2672. var buffer = this.buffer;
  2673. if (requested <= buffer.byteLength) {
  2674. return buffer;
  2675. }
  2676. var size = this.minBufferLength;
  2677. while (size < requested) {
  2678. size *= 2;
  2679. }
  2680. var buffer2 = new Uint8Array(size);
  2681. buffer2.set(buffer);
  2682. return this.buffer = buffer2;
  2683. },
  2684. getByte: function DecodeStream_getByte() {
  2685. var pos = this.pos;
  2686. while (this.bufferLength <= pos) {
  2687. if (this.eof) {
  2688. return -1;
  2689. }
  2690. this.readBlock();
  2691. }
  2692. return this.buffer[this.pos++];
  2693. },
  2694. getUint16: function DecodeStream_getUint16() {
  2695. var b0 = this.getByte();
  2696. var b1 = this.getByte();
  2697. if (b0 === -1 || b1 === -1) {
  2698. return -1;
  2699. }
  2700. return (b0 << 8) + b1;
  2701. },
  2702. getInt32: function DecodeStream_getInt32() {
  2703. var b0 = this.getByte();
  2704. var b1 = this.getByte();
  2705. var b2 = this.getByte();
  2706. var b3 = this.getByte();
  2707. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  2708. },
  2709. getBytes: function DecodeStream_getBytes(length) {
  2710. var end, pos = this.pos;
  2711. if (length) {
  2712. this.ensureBuffer(pos + length);
  2713. end = pos + length;
  2714. while (!this.eof && this.bufferLength < end) {
  2715. this.readBlock();
  2716. }
  2717. var bufEnd = this.bufferLength;
  2718. if (end > bufEnd) {
  2719. end = bufEnd;
  2720. }
  2721. } else {
  2722. while (!this.eof) {
  2723. this.readBlock();
  2724. }
  2725. end = this.bufferLength;
  2726. }
  2727. this.pos = end;
  2728. return this.buffer.subarray(pos, end);
  2729. },
  2730. peekByte: function DecodeStream_peekByte() {
  2731. var peekedByte = this.getByte();
  2732. this.pos--;
  2733. return peekedByte;
  2734. },
  2735. peekBytes: function DecodeStream_peekBytes(length) {
  2736. var bytes = this.getBytes(length);
  2737. this.pos -= bytes.length;
  2738. return bytes;
  2739. },
  2740. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  2741. var end = start + length;
  2742. while (this.bufferLength <= end && !this.eof) {
  2743. this.readBlock();
  2744. }
  2745. return new Stream(this.buffer, start, length, dict);
  2746. },
  2747. skip: function DecodeStream_skip(n) {
  2748. if (!n) {
  2749. n = 1;
  2750. }
  2751. this.pos += n;
  2752. },
  2753. reset: function DecodeStream_reset() {
  2754. this.pos = 0;
  2755. },
  2756. getBaseStreams: function DecodeStream_getBaseStreams() {
  2757. if (this.str && this.str.getBaseStreams) {
  2758. return this.str.getBaseStreams();
  2759. }
  2760. return [];
  2761. }
  2762. };
  2763. return DecodeStream;
  2764. }();
  2765. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  2766. function StreamsSequenceStream(streams) {
  2767. this.streams = streams;
  2768. DecodeStream.call(this, null);
  2769. }
  2770. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  2771. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  2772. var streams = this.streams;
  2773. if (streams.length === 0) {
  2774. this.eof = true;
  2775. return;
  2776. }
  2777. var stream = streams.shift();
  2778. var chunk = stream.getBytes();
  2779. var bufferLength = this.bufferLength;
  2780. var newLength = bufferLength + chunk.length;
  2781. var buffer = this.ensureBuffer(newLength);
  2782. buffer.set(chunk, bufferLength);
  2783. this.bufferLength = newLength;
  2784. };
  2785. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  2786. var baseStreams = [];
  2787. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  2788. var stream = this.streams[i];
  2789. if (stream.getBaseStreams) {
  2790. Util.appendToArray(baseStreams, stream.getBaseStreams());
  2791. }
  2792. }
  2793. return baseStreams;
  2794. };
  2795. return StreamsSequenceStream;
  2796. }();
  2797. var FlateStream = function FlateStreamClosure() {
  2798. var codeLenCodeMap = new Int32Array([
  2799. 16,
  2800. 17,
  2801. 18,
  2802. 0,
  2803. 8,
  2804. 7,
  2805. 9,
  2806. 6,
  2807. 10,
  2808. 5,
  2809. 11,
  2810. 4,
  2811. 12,
  2812. 3,
  2813. 13,
  2814. 2,
  2815. 14,
  2816. 1,
  2817. 15
  2818. ]);
  2819. var lengthDecode = new Int32Array([
  2820. 0x00003,
  2821. 0x00004,
  2822. 0x00005,
  2823. 0x00006,
  2824. 0x00007,
  2825. 0x00008,
  2826. 0x00009,
  2827. 0x0000a,
  2828. 0x1000b,
  2829. 0x1000d,
  2830. 0x1000f,
  2831. 0x10011,
  2832. 0x20013,
  2833. 0x20017,
  2834. 0x2001b,
  2835. 0x2001f,
  2836. 0x30023,
  2837. 0x3002b,
  2838. 0x30033,
  2839. 0x3003b,
  2840. 0x40043,
  2841. 0x40053,
  2842. 0x40063,
  2843. 0x40073,
  2844. 0x50083,
  2845. 0x500a3,
  2846. 0x500c3,
  2847. 0x500e3,
  2848. 0x00102,
  2849. 0x00102,
  2850. 0x00102
  2851. ]);
  2852. var distDecode = new Int32Array([
  2853. 0x00001,
  2854. 0x00002,
  2855. 0x00003,
  2856. 0x00004,
  2857. 0x10005,
  2858. 0x10007,
  2859. 0x20009,
  2860. 0x2000d,
  2861. 0x30011,
  2862. 0x30019,
  2863. 0x40021,
  2864. 0x40031,
  2865. 0x50041,
  2866. 0x50061,
  2867. 0x60081,
  2868. 0x600c1,
  2869. 0x70101,
  2870. 0x70181,
  2871. 0x80201,
  2872. 0x80301,
  2873. 0x90401,
  2874. 0x90601,
  2875. 0xa0801,
  2876. 0xa0c01,
  2877. 0xb1001,
  2878. 0xb1801,
  2879. 0xc2001,
  2880. 0xc3001,
  2881. 0xd4001,
  2882. 0xd6001
  2883. ]);
  2884. var fixedLitCodeTab = [
  2885. new Int32Array([
  2886. 0x70100,
  2887. 0x80050,
  2888. 0x80010,
  2889. 0x80118,
  2890. 0x70110,
  2891. 0x80070,
  2892. 0x80030,
  2893. 0x900c0,
  2894. 0x70108,
  2895. 0x80060,
  2896. 0x80020,
  2897. 0x900a0,
  2898. 0x80000,
  2899. 0x80080,
  2900. 0x80040,
  2901. 0x900e0,
  2902. 0x70104,
  2903. 0x80058,
  2904. 0x80018,
  2905. 0x90090,
  2906. 0x70114,
  2907. 0x80078,
  2908. 0x80038,
  2909. 0x900d0,
  2910. 0x7010c,
  2911. 0x80068,
  2912. 0x80028,
  2913. 0x900b0,
  2914. 0x80008,
  2915. 0x80088,
  2916. 0x80048,
  2917. 0x900f0,
  2918. 0x70102,
  2919. 0x80054,
  2920. 0x80014,
  2921. 0x8011c,
  2922. 0x70112,
  2923. 0x80074,
  2924. 0x80034,
  2925. 0x900c8,
  2926. 0x7010a,
  2927. 0x80064,
  2928. 0x80024,
  2929. 0x900a8,
  2930. 0x80004,
  2931. 0x80084,
  2932. 0x80044,
  2933. 0x900e8,
  2934. 0x70106,
  2935. 0x8005c,
  2936. 0x8001c,
  2937. 0x90098,
  2938. 0x70116,
  2939. 0x8007c,
  2940. 0x8003c,
  2941. 0x900d8,
  2942. 0x7010e,
  2943. 0x8006c,
  2944. 0x8002c,
  2945. 0x900b8,
  2946. 0x8000c,
  2947. 0x8008c,
  2948. 0x8004c,
  2949. 0x900f8,
  2950. 0x70101,
  2951. 0x80052,
  2952. 0x80012,
  2953. 0x8011a,
  2954. 0x70111,
  2955. 0x80072,
  2956. 0x80032,
  2957. 0x900c4,
  2958. 0x70109,
  2959. 0x80062,
  2960. 0x80022,
  2961. 0x900a4,
  2962. 0x80002,
  2963. 0x80082,
  2964. 0x80042,
  2965. 0x900e4,
  2966. 0x70105,
  2967. 0x8005a,
  2968. 0x8001a,
  2969. 0x90094,
  2970. 0x70115,
  2971. 0x8007a,
  2972. 0x8003a,
  2973. 0x900d4,
  2974. 0x7010d,
  2975. 0x8006a,
  2976. 0x8002a,
  2977. 0x900b4,
  2978. 0x8000a,
  2979. 0x8008a,
  2980. 0x8004a,
  2981. 0x900f4,
  2982. 0x70103,
  2983. 0x80056,
  2984. 0x80016,
  2985. 0x8011e,
  2986. 0x70113,
  2987. 0x80076,
  2988. 0x80036,
  2989. 0x900cc,
  2990. 0x7010b,
  2991. 0x80066,
  2992. 0x80026,
  2993. 0x900ac,
  2994. 0x80006,
  2995. 0x80086,
  2996. 0x80046,
  2997. 0x900ec,
  2998. 0x70107,
  2999. 0x8005e,
  3000. 0x8001e,
  3001. 0x9009c,
  3002. 0x70117,
  3003. 0x8007e,
  3004. 0x8003e,
  3005. 0x900dc,
  3006. 0x7010f,
  3007. 0x8006e,
  3008. 0x8002e,
  3009. 0x900bc,
  3010. 0x8000e,
  3011. 0x8008e,
  3012. 0x8004e,
  3013. 0x900fc,
  3014. 0x70100,
  3015. 0x80051,
  3016. 0x80011,
  3017. 0x80119,
  3018. 0x70110,
  3019. 0x80071,
  3020. 0x80031,
  3021. 0x900c2,
  3022. 0x70108,
  3023. 0x80061,
  3024. 0x80021,
  3025. 0x900a2,
  3026. 0x80001,
  3027. 0x80081,
  3028. 0x80041,
  3029. 0x900e2,
  3030. 0x70104,
  3031. 0x80059,
  3032. 0x80019,
  3033. 0x90092,
  3034. 0x70114,
  3035. 0x80079,
  3036. 0x80039,
  3037. 0x900d2,
  3038. 0x7010c,
  3039. 0x80069,
  3040. 0x80029,
  3041. 0x900b2,
  3042. 0x80009,
  3043. 0x80089,
  3044. 0x80049,
  3045. 0x900f2,
  3046. 0x70102,
  3047. 0x80055,
  3048. 0x80015,
  3049. 0x8011d,
  3050. 0x70112,
  3051. 0x80075,
  3052. 0x80035,
  3053. 0x900ca,
  3054. 0x7010a,
  3055. 0x80065,
  3056. 0x80025,
  3057. 0x900aa,
  3058. 0x80005,
  3059. 0x80085,
  3060. 0x80045,
  3061. 0x900ea,
  3062. 0x70106,
  3063. 0x8005d,
  3064. 0x8001d,
  3065. 0x9009a,
  3066. 0x70116,
  3067. 0x8007d,
  3068. 0x8003d,
  3069. 0x900da,
  3070. 0x7010e,
  3071. 0x8006d,
  3072. 0x8002d,
  3073. 0x900ba,
  3074. 0x8000d,
  3075. 0x8008d,
  3076. 0x8004d,
  3077. 0x900fa,
  3078. 0x70101,
  3079. 0x80053,
  3080. 0x80013,
  3081. 0x8011b,
  3082. 0x70111,
  3083. 0x80073,
  3084. 0x80033,
  3085. 0x900c6,
  3086. 0x70109,
  3087. 0x80063,
  3088. 0x80023,
  3089. 0x900a6,
  3090. 0x80003,
  3091. 0x80083,
  3092. 0x80043,
  3093. 0x900e6,
  3094. 0x70105,
  3095. 0x8005b,
  3096. 0x8001b,
  3097. 0x90096,
  3098. 0x70115,
  3099. 0x8007b,
  3100. 0x8003b,
  3101. 0x900d6,
  3102. 0x7010d,
  3103. 0x8006b,
  3104. 0x8002b,
  3105. 0x900b6,
  3106. 0x8000b,
  3107. 0x8008b,
  3108. 0x8004b,
  3109. 0x900f6,
  3110. 0x70103,
  3111. 0x80057,
  3112. 0x80017,
  3113. 0x8011f,
  3114. 0x70113,
  3115. 0x80077,
  3116. 0x80037,
  3117. 0x900ce,
  3118. 0x7010b,
  3119. 0x80067,
  3120. 0x80027,
  3121. 0x900ae,
  3122. 0x80007,
  3123. 0x80087,
  3124. 0x80047,
  3125. 0x900ee,
  3126. 0x70107,
  3127. 0x8005f,
  3128. 0x8001f,
  3129. 0x9009e,
  3130. 0x70117,
  3131. 0x8007f,
  3132. 0x8003f,
  3133. 0x900de,
  3134. 0x7010f,
  3135. 0x8006f,
  3136. 0x8002f,
  3137. 0x900be,
  3138. 0x8000f,
  3139. 0x8008f,
  3140. 0x8004f,
  3141. 0x900fe,
  3142. 0x70100,
  3143. 0x80050,
  3144. 0x80010,
  3145. 0x80118,
  3146. 0x70110,
  3147. 0x80070,
  3148. 0x80030,
  3149. 0x900c1,
  3150. 0x70108,
  3151. 0x80060,
  3152. 0x80020,
  3153. 0x900a1,
  3154. 0x80000,
  3155. 0x80080,
  3156. 0x80040,
  3157. 0x900e1,
  3158. 0x70104,
  3159. 0x80058,
  3160. 0x80018,
  3161. 0x90091,
  3162. 0x70114,
  3163. 0x80078,
  3164. 0x80038,
  3165. 0x900d1,
  3166. 0x7010c,
  3167. 0x80068,
  3168. 0x80028,
  3169. 0x900b1,
  3170. 0x80008,
  3171. 0x80088,
  3172. 0x80048,
  3173. 0x900f1,
  3174. 0x70102,
  3175. 0x80054,
  3176. 0x80014,
  3177. 0x8011c,
  3178. 0x70112,
  3179. 0x80074,
  3180. 0x80034,
  3181. 0x900c9,
  3182. 0x7010a,
  3183. 0x80064,
  3184. 0x80024,
  3185. 0x900a9,
  3186. 0x80004,
  3187. 0x80084,
  3188. 0x80044,
  3189. 0x900e9,
  3190. 0x70106,
  3191. 0x8005c,
  3192. 0x8001c,
  3193. 0x90099,
  3194. 0x70116,
  3195. 0x8007c,
  3196. 0x8003c,
  3197. 0x900d9,
  3198. 0x7010e,
  3199. 0x8006c,
  3200. 0x8002c,
  3201. 0x900b9,
  3202. 0x8000c,
  3203. 0x8008c,
  3204. 0x8004c,
  3205. 0x900f9,
  3206. 0x70101,
  3207. 0x80052,
  3208. 0x80012,
  3209. 0x8011a,
  3210. 0x70111,
  3211. 0x80072,
  3212. 0x80032,
  3213. 0x900c5,
  3214. 0x70109,
  3215. 0x80062,
  3216. 0x80022,
  3217. 0x900a5,
  3218. 0x80002,
  3219. 0x80082,
  3220. 0x80042,
  3221. 0x900e5,
  3222. 0x70105,
  3223. 0x8005a,
  3224. 0x8001a,
  3225. 0x90095,
  3226. 0x70115,
  3227. 0x8007a,
  3228. 0x8003a,
  3229. 0x900d5,
  3230. 0x7010d,
  3231. 0x8006a,
  3232. 0x8002a,
  3233. 0x900b5,
  3234. 0x8000a,
  3235. 0x8008a,
  3236. 0x8004a,
  3237. 0x900f5,
  3238. 0x70103,
  3239. 0x80056,
  3240. 0x80016,
  3241. 0x8011e,
  3242. 0x70113,
  3243. 0x80076,
  3244. 0x80036,
  3245. 0x900cd,
  3246. 0x7010b,
  3247. 0x80066,
  3248. 0x80026,
  3249. 0x900ad,
  3250. 0x80006,
  3251. 0x80086,
  3252. 0x80046,
  3253. 0x900ed,
  3254. 0x70107,
  3255. 0x8005e,
  3256. 0x8001e,
  3257. 0x9009d,
  3258. 0x70117,
  3259. 0x8007e,
  3260. 0x8003e,
  3261. 0x900dd,
  3262. 0x7010f,
  3263. 0x8006e,
  3264. 0x8002e,
  3265. 0x900bd,
  3266. 0x8000e,
  3267. 0x8008e,
  3268. 0x8004e,
  3269. 0x900fd,
  3270. 0x70100,
  3271. 0x80051,
  3272. 0x80011,
  3273. 0x80119,
  3274. 0x70110,
  3275. 0x80071,
  3276. 0x80031,
  3277. 0x900c3,
  3278. 0x70108,
  3279. 0x80061,
  3280. 0x80021,
  3281. 0x900a3,
  3282. 0x80001,
  3283. 0x80081,
  3284. 0x80041,
  3285. 0x900e3,
  3286. 0x70104,
  3287. 0x80059,
  3288. 0x80019,
  3289. 0x90093,
  3290. 0x70114,
  3291. 0x80079,
  3292. 0x80039,
  3293. 0x900d3,
  3294. 0x7010c,
  3295. 0x80069,
  3296. 0x80029,
  3297. 0x900b3,
  3298. 0x80009,
  3299. 0x80089,
  3300. 0x80049,
  3301. 0x900f3,
  3302. 0x70102,
  3303. 0x80055,
  3304. 0x80015,
  3305. 0x8011d,
  3306. 0x70112,
  3307. 0x80075,
  3308. 0x80035,
  3309. 0x900cb,
  3310. 0x7010a,
  3311. 0x80065,
  3312. 0x80025,
  3313. 0x900ab,
  3314. 0x80005,
  3315. 0x80085,
  3316. 0x80045,
  3317. 0x900eb,
  3318. 0x70106,
  3319. 0x8005d,
  3320. 0x8001d,
  3321. 0x9009b,
  3322. 0x70116,
  3323. 0x8007d,
  3324. 0x8003d,
  3325. 0x900db,
  3326. 0x7010e,
  3327. 0x8006d,
  3328. 0x8002d,
  3329. 0x900bb,
  3330. 0x8000d,
  3331. 0x8008d,
  3332. 0x8004d,
  3333. 0x900fb,
  3334. 0x70101,
  3335. 0x80053,
  3336. 0x80013,
  3337. 0x8011b,
  3338. 0x70111,
  3339. 0x80073,
  3340. 0x80033,
  3341. 0x900c7,
  3342. 0x70109,
  3343. 0x80063,
  3344. 0x80023,
  3345. 0x900a7,
  3346. 0x80003,
  3347. 0x80083,
  3348. 0x80043,
  3349. 0x900e7,
  3350. 0x70105,
  3351. 0x8005b,
  3352. 0x8001b,
  3353. 0x90097,
  3354. 0x70115,
  3355. 0x8007b,
  3356. 0x8003b,
  3357. 0x900d7,
  3358. 0x7010d,
  3359. 0x8006b,
  3360. 0x8002b,
  3361. 0x900b7,
  3362. 0x8000b,
  3363. 0x8008b,
  3364. 0x8004b,
  3365. 0x900f7,
  3366. 0x70103,
  3367. 0x80057,
  3368. 0x80017,
  3369. 0x8011f,
  3370. 0x70113,
  3371. 0x80077,
  3372. 0x80037,
  3373. 0x900cf,
  3374. 0x7010b,
  3375. 0x80067,
  3376. 0x80027,
  3377. 0x900af,
  3378. 0x80007,
  3379. 0x80087,
  3380. 0x80047,
  3381. 0x900ef,
  3382. 0x70107,
  3383. 0x8005f,
  3384. 0x8001f,
  3385. 0x9009f,
  3386. 0x70117,
  3387. 0x8007f,
  3388. 0x8003f,
  3389. 0x900df,
  3390. 0x7010f,
  3391. 0x8006f,
  3392. 0x8002f,
  3393. 0x900bf,
  3394. 0x8000f,
  3395. 0x8008f,
  3396. 0x8004f,
  3397. 0x900ff
  3398. ]),
  3399. 9
  3400. ];
  3401. var fixedDistCodeTab = [
  3402. new Int32Array([
  3403. 0x50000,
  3404. 0x50010,
  3405. 0x50008,
  3406. 0x50018,
  3407. 0x50004,
  3408. 0x50014,
  3409. 0x5000c,
  3410. 0x5001c,
  3411. 0x50002,
  3412. 0x50012,
  3413. 0x5000a,
  3414. 0x5001a,
  3415. 0x50006,
  3416. 0x50016,
  3417. 0x5000e,
  3418. 0x00000,
  3419. 0x50001,
  3420. 0x50011,
  3421. 0x50009,
  3422. 0x50019,
  3423. 0x50005,
  3424. 0x50015,
  3425. 0x5000d,
  3426. 0x5001d,
  3427. 0x50003,
  3428. 0x50013,
  3429. 0x5000b,
  3430. 0x5001b,
  3431. 0x50007,
  3432. 0x50017,
  3433. 0x5000f,
  3434. 0x00000
  3435. ]),
  3436. 5
  3437. ];
  3438. function FlateStream(str, maybeLength) {
  3439. this.str = str;
  3440. this.dict = str.dict;
  3441. var cmf = str.getByte();
  3442. var flg = str.getByte();
  3443. if (cmf === -1 || flg === -1) {
  3444. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  3445. }
  3446. if ((cmf & 0x0f) !== 0x08) {
  3447. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  3448. }
  3449. if (((cmf << 8) + flg) % 31 !== 0) {
  3450. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  3451. }
  3452. if (flg & 0x20) {
  3453. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  3454. }
  3455. this.codeSize = 0;
  3456. this.codeBuf = 0;
  3457. DecodeStream.call(this, maybeLength);
  3458. }
  3459. FlateStream.prototype = Object.create(DecodeStream.prototype);
  3460. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  3461. var str = this.str;
  3462. var codeSize = this.codeSize;
  3463. var codeBuf = this.codeBuf;
  3464. var b;
  3465. while (codeSize < bits) {
  3466. if ((b = str.getByte()) === -1) {
  3467. error('Bad encoding in flate stream');
  3468. }
  3469. codeBuf |= b << codeSize;
  3470. codeSize += 8;
  3471. }
  3472. b = codeBuf & (1 << bits) - 1;
  3473. this.codeBuf = codeBuf >> bits;
  3474. this.codeSize = codeSize -= bits;
  3475. return b;
  3476. };
  3477. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  3478. var str = this.str;
  3479. var codes = table[0];
  3480. var maxLen = table[1];
  3481. var codeSize = this.codeSize;
  3482. var codeBuf = this.codeBuf;
  3483. var b;
  3484. while (codeSize < maxLen) {
  3485. if ((b = str.getByte()) === -1) {
  3486. break;
  3487. }
  3488. codeBuf |= b << codeSize;
  3489. codeSize += 8;
  3490. }
  3491. var code = codes[codeBuf & (1 << maxLen) - 1];
  3492. var codeLen = code >> 16;
  3493. var codeVal = code & 0xffff;
  3494. if (codeLen < 1 || codeSize < codeLen) {
  3495. error('Bad encoding in flate stream');
  3496. }
  3497. this.codeBuf = codeBuf >> codeLen;
  3498. this.codeSize = codeSize - codeLen;
  3499. return codeVal;
  3500. };
  3501. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  3502. var n = lengths.length;
  3503. var maxLen = 0;
  3504. var i;
  3505. for (i = 0; i < n; ++i) {
  3506. if (lengths[i] > maxLen) {
  3507. maxLen = lengths[i];
  3508. }
  3509. }
  3510. var size = 1 << maxLen;
  3511. var codes = new Int32Array(size);
  3512. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  3513. for (var val = 0; val < n; ++val) {
  3514. if (lengths[val] === len) {
  3515. var code2 = 0;
  3516. var t = code;
  3517. for (i = 0; i < len; ++i) {
  3518. code2 = code2 << 1 | t & 1;
  3519. t >>= 1;
  3520. }
  3521. for (i = code2; i < size; i += skip) {
  3522. codes[i] = len << 16 | val;
  3523. }
  3524. ++code;
  3525. }
  3526. }
  3527. }
  3528. return [
  3529. codes,
  3530. maxLen
  3531. ];
  3532. };
  3533. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  3534. var buffer, len;
  3535. var str = this.str;
  3536. var hdr = this.getBits(3);
  3537. if (hdr & 1) {
  3538. this.eof = true;
  3539. }
  3540. hdr >>= 1;
  3541. if (hdr === 0) {
  3542. var b;
  3543. if ((b = str.getByte()) === -1) {
  3544. error('Bad block header in flate stream');
  3545. }
  3546. var blockLen = b;
  3547. if ((b = str.getByte()) === -1) {
  3548. error('Bad block header in flate stream');
  3549. }
  3550. blockLen |= b << 8;
  3551. if ((b = str.getByte()) === -1) {
  3552. error('Bad block header in flate stream');
  3553. }
  3554. var check = b;
  3555. if ((b = str.getByte()) === -1) {
  3556. error('Bad block header in flate stream');
  3557. }
  3558. check |= b << 8;
  3559. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  3560. error('Bad uncompressed block length in flate stream');
  3561. }
  3562. this.codeBuf = 0;
  3563. this.codeSize = 0;
  3564. var bufferLength = this.bufferLength;
  3565. buffer = this.ensureBuffer(bufferLength + blockLen);
  3566. var end = bufferLength + blockLen;
  3567. this.bufferLength = end;
  3568. if (blockLen === 0) {
  3569. if (str.peekByte() === -1) {
  3570. this.eof = true;
  3571. }
  3572. } else {
  3573. for (var n = bufferLength; n < end; ++n) {
  3574. if ((b = str.getByte()) === -1) {
  3575. this.eof = true;
  3576. break;
  3577. }
  3578. buffer[n] = b;
  3579. }
  3580. }
  3581. return;
  3582. }
  3583. var litCodeTable;
  3584. var distCodeTable;
  3585. if (hdr === 1) {
  3586. litCodeTable = fixedLitCodeTab;
  3587. distCodeTable = fixedDistCodeTab;
  3588. } else if (hdr === 2) {
  3589. var numLitCodes = this.getBits(5) + 257;
  3590. var numDistCodes = this.getBits(5) + 1;
  3591. var numCodeLenCodes = this.getBits(4) + 4;
  3592. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  3593. var i;
  3594. for (i = 0; i < numCodeLenCodes; ++i) {
  3595. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  3596. }
  3597. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  3598. len = 0;
  3599. i = 0;
  3600. var codes = numLitCodes + numDistCodes;
  3601. var codeLengths = new Uint8Array(codes);
  3602. var bitsLength, bitsOffset, what;
  3603. while (i < codes) {
  3604. var code = this.getCode(codeLenCodeTab);
  3605. if (code === 16) {
  3606. bitsLength = 2;
  3607. bitsOffset = 3;
  3608. what = len;
  3609. } else if (code === 17) {
  3610. bitsLength = 3;
  3611. bitsOffset = 3;
  3612. what = len = 0;
  3613. } else if (code === 18) {
  3614. bitsLength = 7;
  3615. bitsOffset = 11;
  3616. what = len = 0;
  3617. } else {
  3618. codeLengths[i++] = len = code;
  3619. continue;
  3620. }
  3621. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  3622. while (repeatLength-- > 0) {
  3623. codeLengths[i++] = what;
  3624. }
  3625. }
  3626. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  3627. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  3628. } else {
  3629. error('Unknown block type in flate stream');
  3630. }
  3631. buffer = this.buffer;
  3632. var limit = buffer ? buffer.length : 0;
  3633. var pos = this.bufferLength;
  3634. while (true) {
  3635. var code1 = this.getCode(litCodeTable);
  3636. if (code1 < 256) {
  3637. if (pos + 1 >= limit) {
  3638. buffer = this.ensureBuffer(pos + 1);
  3639. limit = buffer.length;
  3640. }
  3641. buffer[pos++] = code1;
  3642. continue;
  3643. }
  3644. if (code1 === 256) {
  3645. this.bufferLength = pos;
  3646. return;
  3647. }
  3648. code1 -= 257;
  3649. code1 = lengthDecode[code1];
  3650. var code2 = code1 >> 16;
  3651. if (code2 > 0) {
  3652. code2 = this.getBits(code2);
  3653. }
  3654. len = (code1 & 0xffff) + code2;
  3655. code1 = this.getCode(distCodeTable);
  3656. code1 = distDecode[code1];
  3657. code2 = code1 >> 16;
  3658. if (code2 > 0) {
  3659. code2 = this.getBits(code2);
  3660. }
  3661. var dist = (code1 & 0xffff) + code2;
  3662. if (pos + len >= limit) {
  3663. buffer = this.ensureBuffer(pos + len);
  3664. limit = buffer.length;
  3665. }
  3666. for (var k = 0; k < len; ++k, ++pos) {
  3667. buffer[pos] = buffer[pos - dist];
  3668. }
  3669. }
  3670. };
  3671. return FlateStream;
  3672. }();
  3673. var PredictorStream = function PredictorStreamClosure() {
  3674. function PredictorStream(str, maybeLength, params) {
  3675. if (!isDict(params)) {
  3676. return str;
  3677. }
  3678. var predictor = this.predictor = params.get('Predictor') || 1;
  3679. if (predictor <= 1) {
  3680. return str;
  3681. }
  3682. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  3683. error('Unsupported predictor: ' + predictor);
  3684. }
  3685. if (predictor === 2) {
  3686. this.readBlock = this.readBlockTiff;
  3687. } else {
  3688. this.readBlock = this.readBlockPng;
  3689. }
  3690. this.str = str;
  3691. this.dict = str.dict;
  3692. var colors = this.colors = params.get('Colors') || 1;
  3693. var bits = this.bits = params.get('BitsPerComponent') || 8;
  3694. var columns = this.columns = params.get('Columns') || 1;
  3695. this.pixBytes = colors * bits + 7 >> 3;
  3696. this.rowBytes = columns * colors * bits + 7 >> 3;
  3697. DecodeStream.call(this, maybeLength);
  3698. return this;
  3699. }
  3700. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  3701. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  3702. var rowBytes = this.rowBytes;
  3703. var bufferLength = this.bufferLength;
  3704. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  3705. var bits = this.bits;
  3706. var colors = this.colors;
  3707. var rawBytes = this.str.getBytes(rowBytes);
  3708. this.eof = !rawBytes.length;
  3709. if (this.eof) {
  3710. return;
  3711. }
  3712. var inbuf = 0, outbuf = 0;
  3713. var inbits = 0, outbits = 0;
  3714. var pos = bufferLength;
  3715. var i;
  3716. if (bits === 1 && colors === 1) {
  3717. for (i = 0; i < rowBytes; ++i) {
  3718. var c = rawBytes[i] ^ inbuf;
  3719. c ^= c >> 1;
  3720. c ^= c >> 2;
  3721. c ^= c >> 4;
  3722. inbuf = (c & 1) << 7;
  3723. buffer[pos++] = c;
  3724. }
  3725. } else if (bits === 8) {
  3726. for (i = 0; i < colors; ++i) {
  3727. buffer[pos++] = rawBytes[i];
  3728. }
  3729. for (; i < rowBytes; ++i) {
  3730. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  3731. pos++;
  3732. }
  3733. } else {
  3734. var compArray = new Uint8Array(colors + 1);
  3735. var bitMask = (1 << bits) - 1;
  3736. var j = 0, k = bufferLength;
  3737. var columns = this.columns;
  3738. for (i = 0; i < columns; ++i) {
  3739. for (var kk = 0; kk < colors; ++kk) {
  3740. if (inbits < bits) {
  3741. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  3742. inbits += 8;
  3743. }
  3744. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  3745. inbits -= bits;
  3746. outbuf = outbuf << bits | compArray[kk];
  3747. outbits += bits;
  3748. if (outbits >= 8) {
  3749. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  3750. outbits -= 8;
  3751. }
  3752. }
  3753. }
  3754. if (outbits > 0) {
  3755. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  3756. }
  3757. }
  3758. this.bufferLength += rowBytes;
  3759. };
  3760. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  3761. var rowBytes = this.rowBytes;
  3762. var pixBytes = this.pixBytes;
  3763. var predictor = this.str.getByte();
  3764. var rawBytes = this.str.getBytes(rowBytes);
  3765. this.eof = !rawBytes.length;
  3766. if (this.eof) {
  3767. return;
  3768. }
  3769. var bufferLength = this.bufferLength;
  3770. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  3771. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  3772. if (prevRow.length === 0) {
  3773. prevRow = new Uint8Array(rowBytes);
  3774. }
  3775. var i, j = bufferLength, up, c;
  3776. switch (predictor) {
  3777. case 0:
  3778. for (i = 0; i < rowBytes; ++i) {
  3779. buffer[j++] = rawBytes[i];
  3780. }
  3781. break;
  3782. case 1:
  3783. for (i = 0; i < pixBytes; ++i) {
  3784. buffer[j++] = rawBytes[i];
  3785. }
  3786. for (; i < rowBytes; ++i) {
  3787. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  3788. j++;
  3789. }
  3790. break;
  3791. case 2:
  3792. for (i = 0; i < rowBytes; ++i) {
  3793. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  3794. }
  3795. break;
  3796. case 3:
  3797. for (i = 0; i < pixBytes; ++i) {
  3798. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  3799. }
  3800. for (; i < rowBytes; ++i) {
  3801. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  3802. j++;
  3803. }
  3804. break;
  3805. case 4:
  3806. for (i = 0; i < pixBytes; ++i) {
  3807. up = prevRow[i];
  3808. c = rawBytes[i];
  3809. buffer[j++] = up + c;
  3810. }
  3811. for (; i < rowBytes; ++i) {
  3812. up = prevRow[i];
  3813. var upLeft = prevRow[i - pixBytes];
  3814. var left = buffer[j - pixBytes];
  3815. var p = left + up - upLeft;
  3816. var pa = p - left;
  3817. if (pa < 0) {
  3818. pa = -pa;
  3819. }
  3820. var pb = p - up;
  3821. if (pb < 0) {
  3822. pb = -pb;
  3823. }
  3824. var pc = p - upLeft;
  3825. if (pc < 0) {
  3826. pc = -pc;
  3827. }
  3828. c = rawBytes[i];
  3829. if (pa <= pb && pa <= pc) {
  3830. buffer[j++] = left + c;
  3831. } else if (pb <= pc) {
  3832. buffer[j++] = up + c;
  3833. } else {
  3834. buffer[j++] = upLeft + c;
  3835. }
  3836. }
  3837. break;
  3838. default:
  3839. error('Unsupported predictor: ' + predictor);
  3840. }
  3841. this.bufferLength += rowBytes;
  3842. };
  3843. return PredictorStream;
  3844. }();
  3845. var JpegStream = function JpegStreamClosure() {
  3846. function JpegStream(stream, maybeLength, dict, params) {
  3847. var ch;
  3848. while ((ch = stream.getByte()) !== -1) {
  3849. if (ch === 0xFF) {
  3850. stream.skip(-1);
  3851. break;
  3852. }
  3853. }
  3854. this.stream = stream;
  3855. this.maybeLength = maybeLength;
  3856. this.dict = dict;
  3857. this.params = params;
  3858. DecodeStream.call(this, maybeLength);
  3859. }
  3860. JpegStream.prototype = Object.create(DecodeStream.prototype);
  3861. Object.defineProperty(JpegStream.prototype, 'bytes', {
  3862. get: function JpegStream_bytes() {
  3863. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3864. },
  3865. configurable: true
  3866. });
  3867. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  3868. if (this.bufferLength) {
  3869. return;
  3870. }
  3871. var jpegImage = new JpegImage();
  3872. var decodeArr = this.dict.getArray('Decode', 'D');
  3873. if (this.forceRGB && isArray(decodeArr)) {
  3874. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  3875. var decodeArrLength = decodeArr.length;
  3876. var transform = new Int32Array(decodeArrLength);
  3877. var transformNeeded = false;
  3878. var maxValue = (1 << bitsPerComponent) - 1;
  3879. for (var i = 0; i < decodeArrLength; i += 2) {
  3880. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  3881. transform[i + 1] = decodeArr[i] * maxValue | 0;
  3882. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  3883. transformNeeded = true;
  3884. }
  3885. }
  3886. if (transformNeeded) {
  3887. jpegImage.decodeTransform = transform;
  3888. }
  3889. }
  3890. if (isDict(this.params)) {
  3891. var colorTransform = this.params.get('ColorTransform');
  3892. if (isInt(colorTransform)) {
  3893. jpegImage.colorTransform = colorTransform;
  3894. }
  3895. }
  3896. jpegImage.parse(this.bytes);
  3897. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  3898. this.buffer = data;
  3899. this.bufferLength = data.length;
  3900. this.eof = true;
  3901. };
  3902. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  3903. this.ensureBuffer();
  3904. return this.buffer;
  3905. };
  3906. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  3907. return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
  3908. };
  3909. return JpegStream;
  3910. }();
  3911. var JpxStream = function JpxStreamClosure() {
  3912. function JpxStream(stream, maybeLength, dict, params) {
  3913. this.stream = stream;
  3914. this.maybeLength = maybeLength;
  3915. this.dict = dict;
  3916. this.params = params;
  3917. DecodeStream.call(this, maybeLength);
  3918. }
  3919. JpxStream.prototype = Object.create(DecodeStream.prototype);
  3920. Object.defineProperty(JpxStream.prototype, 'bytes', {
  3921. get: function JpxStream_bytes() {
  3922. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3923. },
  3924. configurable: true
  3925. });
  3926. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  3927. if (this.bufferLength) {
  3928. return;
  3929. }
  3930. var jpxImage = new JpxImage();
  3931. jpxImage.parse(this.bytes);
  3932. var width = jpxImage.width;
  3933. var height = jpxImage.height;
  3934. var componentsCount = jpxImage.componentsCount;
  3935. var tileCount = jpxImage.tiles.length;
  3936. if (tileCount === 1) {
  3937. this.buffer = jpxImage.tiles[0].items;
  3938. } else {
  3939. var data = new Uint8Array(width * height * componentsCount);
  3940. for (var k = 0; k < tileCount; k++) {
  3941. var tileComponents = jpxImage.tiles[k];
  3942. var tileWidth = tileComponents.width;
  3943. var tileHeight = tileComponents.height;
  3944. var tileLeft = tileComponents.left;
  3945. var tileTop = tileComponents.top;
  3946. var src = tileComponents.items;
  3947. var srcPosition = 0;
  3948. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  3949. var imgRowSize = width * componentsCount;
  3950. var tileRowSize = tileWidth * componentsCount;
  3951. for (var j = 0; j < tileHeight; j++) {
  3952. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  3953. data.set(rowBytes, dataPosition);
  3954. srcPosition += tileRowSize;
  3955. dataPosition += imgRowSize;
  3956. }
  3957. }
  3958. this.buffer = data;
  3959. }
  3960. this.bufferLength = this.buffer.length;
  3961. this.eof = true;
  3962. };
  3963. return JpxStream;
  3964. }();
  3965. var Jbig2Stream = function Jbig2StreamClosure() {
  3966. function Jbig2Stream(stream, maybeLength, dict, params) {
  3967. this.stream = stream;
  3968. this.maybeLength = maybeLength;
  3969. this.dict = dict;
  3970. this.params = params;
  3971. DecodeStream.call(this, maybeLength);
  3972. }
  3973. Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
  3974. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  3975. get: function Jbig2Stream_bytes() {
  3976. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  3977. },
  3978. configurable: true
  3979. });
  3980. Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
  3981. if (this.bufferLength) {
  3982. return;
  3983. }
  3984. var jbig2Image = new Jbig2Image();
  3985. var chunks = [];
  3986. if (isDict(this.params)) {
  3987. var globalsStream = this.params.get('JBIG2Globals');
  3988. if (isStream(globalsStream)) {
  3989. var globals = globalsStream.getBytes();
  3990. chunks.push({
  3991. data: globals,
  3992. start: 0,
  3993. end: globals.length
  3994. });
  3995. }
  3996. }
  3997. chunks.push({
  3998. data: this.bytes,
  3999. start: 0,
  4000. end: this.bytes.length
  4001. });
  4002. var data = jbig2Image.parseChunks(chunks);
  4003. var dataLength = data.length;
  4004. for (var i = 0; i < dataLength; i++) {
  4005. data[i] ^= 0xFF;
  4006. }
  4007. this.buffer = data;
  4008. this.bufferLength = dataLength;
  4009. this.eof = true;
  4010. };
  4011. return Jbig2Stream;
  4012. }();
  4013. var DecryptStream = function DecryptStreamClosure() {
  4014. function DecryptStream(str, maybeLength, decrypt) {
  4015. this.str = str;
  4016. this.dict = str.dict;
  4017. this.decrypt = decrypt;
  4018. this.nextChunk = null;
  4019. this.initialized = false;
  4020. DecodeStream.call(this, maybeLength);
  4021. }
  4022. var chunkSize = 512;
  4023. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  4024. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  4025. var chunk;
  4026. if (this.initialized) {
  4027. chunk = this.nextChunk;
  4028. } else {
  4029. chunk = this.str.getBytes(chunkSize);
  4030. this.initialized = true;
  4031. }
  4032. if (!chunk || chunk.length === 0) {
  4033. this.eof = true;
  4034. return;
  4035. }
  4036. this.nextChunk = this.str.getBytes(chunkSize);
  4037. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  4038. var decrypt = this.decrypt;
  4039. chunk = decrypt(chunk, !hasMoreData);
  4040. var bufferLength = this.bufferLength;
  4041. var i, n = chunk.length;
  4042. var buffer = this.ensureBuffer(bufferLength + n);
  4043. for (i = 0; i < n; i++) {
  4044. buffer[bufferLength++] = chunk[i];
  4045. }
  4046. this.bufferLength = bufferLength;
  4047. };
  4048. return DecryptStream;
  4049. }();
  4050. var Ascii85Stream = function Ascii85StreamClosure() {
  4051. function Ascii85Stream(str, maybeLength) {
  4052. this.str = str;
  4053. this.dict = str.dict;
  4054. this.input = new Uint8Array(5);
  4055. if (maybeLength) {
  4056. maybeLength = 0.8 * maybeLength;
  4057. }
  4058. DecodeStream.call(this, maybeLength);
  4059. }
  4060. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  4061. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  4062. var TILDA_CHAR = 0x7E;
  4063. var Z_LOWER_CHAR = 0x7A;
  4064. var EOF = -1;
  4065. var str = this.str;
  4066. var c = str.getByte();
  4067. while (isSpace(c)) {
  4068. c = str.getByte();
  4069. }
  4070. if (c === EOF || c === TILDA_CHAR) {
  4071. this.eof = true;
  4072. return;
  4073. }
  4074. var bufferLength = this.bufferLength, buffer;
  4075. var i;
  4076. if (c === Z_LOWER_CHAR) {
  4077. buffer = this.ensureBuffer(bufferLength + 4);
  4078. for (i = 0; i < 4; ++i) {
  4079. buffer[bufferLength + i] = 0;
  4080. }
  4081. this.bufferLength += 4;
  4082. } else {
  4083. var input = this.input;
  4084. input[0] = c;
  4085. for (i = 1; i < 5; ++i) {
  4086. c = str.getByte();
  4087. while (isSpace(c)) {
  4088. c = str.getByte();
  4089. }
  4090. input[i] = c;
  4091. if (c === EOF || c === TILDA_CHAR) {
  4092. break;
  4093. }
  4094. }
  4095. buffer = this.ensureBuffer(bufferLength + i - 1);
  4096. this.bufferLength += i - 1;
  4097. if (i < 5) {
  4098. for (; i < 5; ++i) {
  4099. input[i] = 0x21 + 84;
  4100. }
  4101. this.eof = true;
  4102. }
  4103. var t = 0;
  4104. for (i = 0; i < 5; ++i) {
  4105. t = t * 85 + (input[i] - 0x21);
  4106. }
  4107. for (i = 3; i >= 0; --i) {
  4108. buffer[bufferLength + i] = t & 0xFF;
  4109. t >>= 8;
  4110. }
  4111. }
  4112. };
  4113. return Ascii85Stream;
  4114. }();
  4115. var AsciiHexStream = function AsciiHexStreamClosure() {
  4116. function AsciiHexStream(str, maybeLength) {
  4117. this.str = str;
  4118. this.dict = str.dict;
  4119. this.firstDigit = -1;
  4120. if (maybeLength) {
  4121. maybeLength = 0.5 * maybeLength;
  4122. }
  4123. DecodeStream.call(this, maybeLength);
  4124. }
  4125. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  4126. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  4127. var UPSTREAM_BLOCK_SIZE = 8000;
  4128. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  4129. if (!bytes.length) {
  4130. this.eof = true;
  4131. return;
  4132. }
  4133. var maxDecodeLength = bytes.length + 1 >> 1;
  4134. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  4135. var bufferLength = this.bufferLength;
  4136. var firstDigit = this.firstDigit;
  4137. for (var i = 0, ii = bytes.length; i < ii; i++) {
  4138. var ch = bytes[i], digit;
  4139. if (ch >= 0x30 && ch <= 0x39) {
  4140. digit = ch & 0x0F;
  4141. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  4142. digit = (ch & 0x0F) + 9;
  4143. } else if (ch === 0x3E) {
  4144. this.eof = true;
  4145. break;
  4146. } else {
  4147. continue;
  4148. }
  4149. if (firstDigit < 0) {
  4150. firstDigit = digit;
  4151. } else {
  4152. buffer[bufferLength++] = firstDigit << 4 | digit;
  4153. firstDigit = -1;
  4154. }
  4155. }
  4156. if (firstDigit >= 0 && this.eof) {
  4157. buffer[bufferLength++] = firstDigit << 4;
  4158. firstDigit = -1;
  4159. }
  4160. this.firstDigit = firstDigit;
  4161. this.bufferLength = bufferLength;
  4162. };
  4163. return AsciiHexStream;
  4164. }();
  4165. var RunLengthStream = function RunLengthStreamClosure() {
  4166. function RunLengthStream(str, maybeLength) {
  4167. this.str = str;
  4168. this.dict = str.dict;
  4169. DecodeStream.call(this, maybeLength);
  4170. }
  4171. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  4172. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  4173. var repeatHeader = this.str.getBytes(2);
  4174. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  4175. this.eof = true;
  4176. return;
  4177. }
  4178. var buffer;
  4179. var bufferLength = this.bufferLength;
  4180. var n = repeatHeader[0];
  4181. if (n < 128) {
  4182. buffer = this.ensureBuffer(bufferLength + n + 1);
  4183. buffer[bufferLength++] = repeatHeader[1];
  4184. if (n > 0) {
  4185. var source = this.str.getBytes(n);
  4186. buffer.set(source, bufferLength);
  4187. bufferLength += n;
  4188. }
  4189. } else {
  4190. n = 257 - n;
  4191. var b = repeatHeader[1];
  4192. buffer = this.ensureBuffer(bufferLength + n + 1);
  4193. for (var i = 0; i < n; i++) {
  4194. buffer[bufferLength++] = b;
  4195. }
  4196. }
  4197. this.bufferLength = bufferLength;
  4198. };
  4199. return RunLengthStream;
  4200. }();
  4201. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  4202. var ccittEOL = -2;
  4203. var ccittEOF = -1;
  4204. var twoDimPass = 0;
  4205. var twoDimHoriz = 1;
  4206. var twoDimVert0 = 2;
  4207. var twoDimVertR1 = 3;
  4208. var twoDimVertL1 = 4;
  4209. var twoDimVertR2 = 5;
  4210. var twoDimVertL2 = 6;
  4211. var twoDimVertR3 = 7;
  4212. var twoDimVertL3 = 8;
  4213. var twoDimTable = [
  4214. [
  4215. -1,
  4216. -1
  4217. ],
  4218. [
  4219. -1,
  4220. -1
  4221. ],
  4222. [
  4223. 7,
  4224. twoDimVertL3
  4225. ],
  4226. [
  4227. 7,
  4228. twoDimVertR3
  4229. ],
  4230. [
  4231. 6,
  4232. twoDimVertL2
  4233. ],
  4234. [
  4235. 6,
  4236. twoDimVertL2
  4237. ],
  4238. [
  4239. 6,
  4240. twoDimVertR2
  4241. ],
  4242. [
  4243. 6,
  4244. twoDimVertR2
  4245. ],
  4246. [
  4247. 4,
  4248. twoDimPass
  4249. ],
  4250. [
  4251. 4,
  4252. twoDimPass
  4253. ],
  4254. [
  4255. 4,
  4256. twoDimPass
  4257. ],
  4258. [
  4259. 4,
  4260. twoDimPass
  4261. ],
  4262. [
  4263. 4,
  4264. twoDimPass
  4265. ],
  4266. [
  4267. 4,
  4268. twoDimPass
  4269. ],
  4270. [
  4271. 4,
  4272. twoDimPass
  4273. ],
  4274. [
  4275. 4,
  4276. twoDimPass
  4277. ],
  4278. [
  4279. 3,
  4280. twoDimHoriz
  4281. ],
  4282. [
  4283. 3,
  4284. twoDimHoriz
  4285. ],
  4286. [
  4287. 3,
  4288. twoDimHoriz
  4289. ],
  4290. [
  4291. 3,
  4292. twoDimHoriz
  4293. ],
  4294. [
  4295. 3,
  4296. twoDimHoriz
  4297. ],
  4298. [
  4299. 3,
  4300. twoDimHoriz
  4301. ],
  4302. [
  4303. 3,
  4304. twoDimHoriz
  4305. ],
  4306. [
  4307. 3,
  4308. twoDimHoriz
  4309. ],
  4310. [
  4311. 3,
  4312. twoDimHoriz
  4313. ],
  4314. [
  4315. 3,
  4316. twoDimHoriz
  4317. ],
  4318. [
  4319. 3,
  4320. twoDimHoriz
  4321. ],
  4322. [
  4323. 3,
  4324. twoDimHoriz
  4325. ],
  4326. [
  4327. 3,
  4328. twoDimHoriz
  4329. ],
  4330. [
  4331. 3,
  4332. twoDimHoriz
  4333. ],
  4334. [
  4335. 3,
  4336. twoDimHoriz
  4337. ],
  4338. [
  4339. 3,
  4340. twoDimHoriz
  4341. ],
  4342. [
  4343. 3,
  4344. twoDimVertL1
  4345. ],
  4346. [
  4347. 3,
  4348. twoDimVertL1
  4349. ],
  4350. [
  4351. 3,
  4352. twoDimVertL1
  4353. ],
  4354. [
  4355. 3,
  4356. twoDimVertL1
  4357. ],
  4358. [
  4359. 3,
  4360. twoDimVertL1
  4361. ],
  4362. [
  4363. 3,
  4364. twoDimVertL1
  4365. ],
  4366. [
  4367. 3,
  4368. twoDimVertL1
  4369. ],
  4370. [
  4371. 3,
  4372. twoDimVertL1
  4373. ],
  4374. [
  4375. 3,
  4376. twoDimVertL1
  4377. ],
  4378. [
  4379. 3,
  4380. twoDimVertL1
  4381. ],
  4382. [
  4383. 3,
  4384. twoDimVertL1
  4385. ],
  4386. [
  4387. 3,
  4388. twoDimVertL1
  4389. ],
  4390. [
  4391. 3,
  4392. twoDimVertL1
  4393. ],
  4394. [
  4395. 3,
  4396. twoDimVertL1
  4397. ],
  4398. [
  4399. 3,
  4400. twoDimVertL1
  4401. ],
  4402. [
  4403. 3,
  4404. twoDimVertL1
  4405. ],
  4406. [
  4407. 3,
  4408. twoDimVertR1
  4409. ],
  4410. [
  4411. 3,
  4412. twoDimVertR1
  4413. ],
  4414. [
  4415. 3,
  4416. twoDimVertR1
  4417. ],
  4418. [
  4419. 3,
  4420. twoDimVertR1
  4421. ],
  4422. [
  4423. 3,
  4424. twoDimVertR1
  4425. ],
  4426. [
  4427. 3,
  4428. twoDimVertR1
  4429. ],
  4430. [
  4431. 3,
  4432. twoDimVertR1
  4433. ],
  4434. [
  4435. 3,
  4436. twoDimVertR1
  4437. ],
  4438. [
  4439. 3,
  4440. twoDimVertR1
  4441. ],
  4442. [
  4443. 3,
  4444. twoDimVertR1
  4445. ],
  4446. [
  4447. 3,
  4448. twoDimVertR1
  4449. ],
  4450. [
  4451. 3,
  4452. twoDimVertR1
  4453. ],
  4454. [
  4455. 3,
  4456. twoDimVertR1
  4457. ],
  4458. [
  4459. 3,
  4460. twoDimVertR1
  4461. ],
  4462. [
  4463. 3,
  4464. twoDimVertR1
  4465. ],
  4466. [
  4467. 3,
  4468. twoDimVertR1
  4469. ],
  4470. [
  4471. 1,
  4472. twoDimVert0
  4473. ],
  4474. [
  4475. 1,
  4476. twoDimVert0
  4477. ],
  4478. [
  4479. 1,
  4480. twoDimVert0
  4481. ],
  4482. [
  4483. 1,
  4484. twoDimVert0
  4485. ],
  4486. [
  4487. 1,
  4488. twoDimVert0
  4489. ],
  4490. [
  4491. 1,
  4492. twoDimVert0
  4493. ],
  4494. [
  4495. 1,
  4496. twoDimVert0
  4497. ],
  4498. [
  4499. 1,
  4500. twoDimVert0
  4501. ],
  4502. [
  4503. 1,
  4504. twoDimVert0
  4505. ],
  4506. [
  4507. 1,
  4508. twoDimVert0
  4509. ],
  4510. [
  4511. 1,
  4512. twoDimVert0
  4513. ],
  4514. [
  4515. 1,
  4516. twoDimVert0
  4517. ],
  4518. [
  4519. 1,
  4520. twoDimVert0
  4521. ],
  4522. [
  4523. 1,
  4524. twoDimVert0
  4525. ],
  4526. [
  4527. 1,
  4528. twoDimVert0
  4529. ],
  4530. [
  4531. 1,
  4532. twoDimVert0
  4533. ],
  4534. [
  4535. 1,
  4536. twoDimVert0
  4537. ],
  4538. [
  4539. 1,
  4540. twoDimVert0
  4541. ],
  4542. [
  4543. 1,
  4544. twoDimVert0
  4545. ],
  4546. [
  4547. 1,
  4548. twoDimVert0
  4549. ],
  4550. [
  4551. 1,
  4552. twoDimVert0
  4553. ],
  4554. [
  4555. 1,
  4556. twoDimVert0
  4557. ],
  4558. [
  4559. 1,
  4560. twoDimVert0
  4561. ],
  4562. [
  4563. 1,
  4564. twoDimVert0
  4565. ],
  4566. [
  4567. 1,
  4568. twoDimVert0
  4569. ],
  4570. [
  4571. 1,
  4572. twoDimVert0
  4573. ],
  4574. [
  4575. 1,
  4576. twoDimVert0
  4577. ],
  4578. [
  4579. 1,
  4580. twoDimVert0
  4581. ],
  4582. [
  4583. 1,
  4584. twoDimVert0
  4585. ],
  4586. [
  4587. 1,
  4588. twoDimVert0
  4589. ],
  4590. [
  4591. 1,
  4592. twoDimVert0
  4593. ],
  4594. [
  4595. 1,
  4596. twoDimVert0
  4597. ],
  4598. [
  4599. 1,
  4600. twoDimVert0
  4601. ],
  4602. [
  4603. 1,
  4604. twoDimVert0
  4605. ],
  4606. [
  4607. 1,
  4608. twoDimVert0
  4609. ],
  4610. [
  4611. 1,
  4612. twoDimVert0
  4613. ],
  4614. [
  4615. 1,
  4616. twoDimVert0
  4617. ],
  4618. [
  4619. 1,
  4620. twoDimVert0
  4621. ],
  4622. [
  4623. 1,
  4624. twoDimVert0
  4625. ],
  4626. [
  4627. 1,
  4628. twoDimVert0
  4629. ],
  4630. [
  4631. 1,
  4632. twoDimVert0
  4633. ],
  4634. [
  4635. 1,
  4636. twoDimVert0
  4637. ],
  4638. [
  4639. 1,
  4640. twoDimVert0
  4641. ],
  4642. [
  4643. 1,
  4644. twoDimVert0
  4645. ],
  4646. [
  4647. 1,
  4648. twoDimVert0
  4649. ],
  4650. [
  4651. 1,
  4652. twoDimVert0
  4653. ],
  4654. [
  4655. 1,
  4656. twoDimVert0
  4657. ],
  4658. [
  4659. 1,
  4660. twoDimVert0
  4661. ],
  4662. [
  4663. 1,
  4664. twoDimVert0
  4665. ],
  4666. [
  4667. 1,
  4668. twoDimVert0
  4669. ],
  4670. [
  4671. 1,
  4672. twoDimVert0
  4673. ],
  4674. [
  4675. 1,
  4676. twoDimVert0
  4677. ],
  4678. [
  4679. 1,
  4680. twoDimVert0
  4681. ],
  4682. [
  4683. 1,
  4684. twoDimVert0
  4685. ],
  4686. [
  4687. 1,
  4688. twoDimVert0
  4689. ],
  4690. [
  4691. 1,
  4692. twoDimVert0
  4693. ],
  4694. [
  4695. 1,
  4696. twoDimVert0
  4697. ],
  4698. [
  4699. 1,
  4700. twoDimVert0
  4701. ],
  4702. [
  4703. 1,
  4704. twoDimVert0
  4705. ],
  4706. [
  4707. 1,
  4708. twoDimVert0
  4709. ],
  4710. [
  4711. 1,
  4712. twoDimVert0
  4713. ],
  4714. [
  4715. 1,
  4716. twoDimVert0
  4717. ],
  4718. [
  4719. 1,
  4720. twoDimVert0
  4721. ],
  4722. [
  4723. 1,
  4724. twoDimVert0
  4725. ]
  4726. ];
  4727. var whiteTable1 = [
  4728. [
  4729. -1,
  4730. -1
  4731. ],
  4732. [
  4733. 12,
  4734. ccittEOL
  4735. ],
  4736. [
  4737. -1,
  4738. -1
  4739. ],
  4740. [
  4741. -1,
  4742. -1
  4743. ],
  4744. [
  4745. -1,
  4746. -1
  4747. ],
  4748. [
  4749. -1,
  4750. -1
  4751. ],
  4752. [
  4753. -1,
  4754. -1
  4755. ],
  4756. [
  4757. -1,
  4758. -1
  4759. ],
  4760. [
  4761. -1,
  4762. -1
  4763. ],
  4764. [
  4765. -1,
  4766. -1
  4767. ],
  4768. [
  4769. -1,
  4770. -1
  4771. ],
  4772. [
  4773. -1,
  4774. -1
  4775. ],
  4776. [
  4777. -1,
  4778. -1
  4779. ],
  4780. [
  4781. -1,
  4782. -1
  4783. ],
  4784. [
  4785. -1,
  4786. -1
  4787. ],
  4788. [
  4789. -1,
  4790. -1
  4791. ],
  4792. [
  4793. 11,
  4794. 1792
  4795. ],
  4796. [
  4797. 11,
  4798. 1792
  4799. ],
  4800. [
  4801. 12,
  4802. 1984
  4803. ],
  4804. [
  4805. 12,
  4806. 2048
  4807. ],
  4808. [
  4809. 12,
  4810. 2112
  4811. ],
  4812. [
  4813. 12,
  4814. 2176
  4815. ],
  4816. [
  4817. 12,
  4818. 2240
  4819. ],
  4820. [
  4821. 12,
  4822. 2304
  4823. ],
  4824. [
  4825. 11,
  4826. 1856
  4827. ],
  4828. [
  4829. 11,
  4830. 1856
  4831. ],
  4832. [
  4833. 11,
  4834. 1920
  4835. ],
  4836. [
  4837. 11,
  4838. 1920
  4839. ],
  4840. [
  4841. 12,
  4842. 2368
  4843. ],
  4844. [
  4845. 12,
  4846. 2432
  4847. ],
  4848. [
  4849. 12,
  4850. 2496
  4851. ],
  4852. [
  4853. 12,
  4854. 2560
  4855. ]
  4856. ];
  4857. var whiteTable2 = [
  4858. [
  4859. -1,
  4860. -1
  4861. ],
  4862. [
  4863. -1,
  4864. -1
  4865. ],
  4866. [
  4867. -1,
  4868. -1
  4869. ],
  4870. [
  4871. -1,
  4872. -1
  4873. ],
  4874. [
  4875. 8,
  4876. 29
  4877. ],
  4878. [
  4879. 8,
  4880. 29
  4881. ],
  4882. [
  4883. 8,
  4884. 30
  4885. ],
  4886. [
  4887. 8,
  4888. 30
  4889. ],
  4890. [
  4891. 8,
  4892. 45
  4893. ],
  4894. [
  4895. 8,
  4896. 45
  4897. ],
  4898. [
  4899. 8,
  4900. 46
  4901. ],
  4902. [
  4903. 8,
  4904. 46
  4905. ],
  4906. [
  4907. 7,
  4908. 22
  4909. ],
  4910. [
  4911. 7,
  4912. 22
  4913. ],
  4914. [
  4915. 7,
  4916. 22
  4917. ],
  4918. [
  4919. 7,
  4920. 22
  4921. ],
  4922. [
  4923. 7,
  4924. 23
  4925. ],
  4926. [
  4927. 7,
  4928. 23
  4929. ],
  4930. [
  4931. 7,
  4932. 23
  4933. ],
  4934. [
  4935. 7,
  4936. 23
  4937. ],
  4938. [
  4939. 8,
  4940. 47
  4941. ],
  4942. [
  4943. 8,
  4944. 47
  4945. ],
  4946. [
  4947. 8,
  4948. 48
  4949. ],
  4950. [
  4951. 8,
  4952. 48
  4953. ],
  4954. [
  4955. 6,
  4956. 13
  4957. ],
  4958. [
  4959. 6,
  4960. 13
  4961. ],
  4962. [
  4963. 6,
  4964. 13
  4965. ],
  4966. [
  4967. 6,
  4968. 13
  4969. ],
  4970. [
  4971. 6,
  4972. 13
  4973. ],
  4974. [
  4975. 6,
  4976. 13
  4977. ],
  4978. [
  4979. 6,
  4980. 13
  4981. ],
  4982. [
  4983. 6,
  4984. 13
  4985. ],
  4986. [
  4987. 7,
  4988. 20
  4989. ],
  4990. [
  4991. 7,
  4992. 20
  4993. ],
  4994. [
  4995. 7,
  4996. 20
  4997. ],
  4998. [
  4999. 7,
  5000. 20
  5001. ],
  5002. [
  5003. 8,
  5004. 33
  5005. ],
  5006. [
  5007. 8,
  5008. 33
  5009. ],
  5010. [
  5011. 8,
  5012. 34
  5013. ],
  5014. [
  5015. 8,
  5016. 34
  5017. ],
  5018. [
  5019. 8,
  5020. 35
  5021. ],
  5022. [
  5023. 8,
  5024. 35
  5025. ],
  5026. [
  5027. 8,
  5028. 36
  5029. ],
  5030. [
  5031. 8,
  5032. 36
  5033. ],
  5034. [
  5035. 8,
  5036. 37
  5037. ],
  5038. [
  5039. 8,
  5040. 37
  5041. ],
  5042. [
  5043. 8,
  5044. 38
  5045. ],
  5046. [
  5047. 8,
  5048. 38
  5049. ],
  5050. [
  5051. 7,
  5052. 19
  5053. ],
  5054. [
  5055. 7,
  5056. 19
  5057. ],
  5058. [
  5059. 7,
  5060. 19
  5061. ],
  5062. [
  5063. 7,
  5064. 19
  5065. ],
  5066. [
  5067. 8,
  5068. 31
  5069. ],
  5070. [
  5071. 8,
  5072. 31
  5073. ],
  5074. [
  5075. 8,
  5076. 32
  5077. ],
  5078. [
  5079. 8,
  5080. 32
  5081. ],
  5082. [
  5083. 6,
  5084. 1
  5085. ],
  5086. [
  5087. 6,
  5088. 1
  5089. ],
  5090. [
  5091. 6,
  5092. 1
  5093. ],
  5094. [
  5095. 6,
  5096. 1
  5097. ],
  5098. [
  5099. 6,
  5100. 1
  5101. ],
  5102. [
  5103. 6,
  5104. 1
  5105. ],
  5106. [
  5107. 6,
  5108. 1
  5109. ],
  5110. [
  5111. 6,
  5112. 1
  5113. ],
  5114. [
  5115. 6,
  5116. 12
  5117. ],
  5118. [
  5119. 6,
  5120. 12
  5121. ],
  5122. [
  5123. 6,
  5124. 12
  5125. ],
  5126. [
  5127. 6,
  5128. 12
  5129. ],
  5130. [
  5131. 6,
  5132. 12
  5133. ],
  5134. [
  5135. 6,
  5136. 12
  5137. ],
  5138. [
  5139. 6,
  5140. 12
  5141. ],
  5142. [
  5143. 6,
  5144. 12
  5145. ],
  5146. [
  5147. 8,
  5148. 53
  5149. ],
  5150. [
  5151. 8,
  5152. 53
  5153. ],
  5154. [
  5155. 8,
  5156. 54
  5157. ],
  5158. [
  5159. 8,
  5160. 54
  5161. ],
  5162. [
  5163. 7,
  5164. 26
  5165. ],
  5166. [
  5167. 7,
  5168. 26
  5169. ],
  5170. [
  5171. 7,
  5172. 26
  5173. ],
  5174. [
  5175. 7,
  5176. 26
  5177. ],
  5178. [
  5179. 8,
  5180. 39
  5181. ],
  5182. [
  5183. 8,
  5184. 39
  5185. ],
  5186. [
  5187. 8,
  5188. 40
  5189. ],
  5190. [
  5191. 8,
  5192. 40
  5193. ],
  5194. [
  5195. 8,
  5196. 41
  5197. ],
  5198. [
  5199. 8,
  5200. 41
  5201. ],
  5202. [
  5203. 8,
  5204. 42
  5205. ],
  5206. [
  5207. 8,
  5208. 42
  5209. ],
  5210. [
  5211. 8,
  5212. 43
  5213. ],
  5214. [
  5215. 8,
  5216. 43
  5217. ],
  5218. [
  5219. 8,
  5220. 44
  5221. ],
  5222. [
  5223. 8,
  5224. 44
  5225. ],
  5226. [
  5227. 7,
  5228. 21
  5229. ],
  5230. [
  5231. 7,
  5232. 21
  5233. ],
  5234. [
  5235. 7,
  5236. 21
  5237. ],
  5238. [
  5239. 7,
  5240. 21
  5241. ],
  5242. [
  5243. 7,
  5244. 28
  5245. ],
  5246. [
  5247. 7,
  5248. 28
  5249. ],
  5250. [
  5251. 7,
  5252. 28
  5253. ],
  5254. [
  5255. 7,
  5256. 28
  5257. ],
  5258. [
  5259. 8,
  5260. 61
  5261. ],
  5262. [
  5263. 8,
  5264. 61
  5265. ],
  5266. [
  5267. 8,
  5268. 62
  5269. ],
  5270. [
  5271. 8,
  5272. 62
  5273. ],
  5274. [
  5275. 8,
  5276. 63
  5277. ],
  5278. [
  5279. 8,
  5280. 63
  5281. ],
  5282. [
  5283. 8,
  5284. 0
  5285. ],
  5286. [
  5287. 8,
  5288. 0
  5289. ],
  5290. [
  5291. 8,
  5292. 320
  5293. ],
  5294. [
  5295. 8,
  5296. 320
  5297. ],
  5298. [
  5299. 8,
  5300. 384
  5301. ],
  5302. [
  5303. 8,
  5304. 384
  5305. ],
  5306. [
  5307. 5,
  5308. 10
  5309. ],
  5310. [
  5311. 5,
  5312. 10
  5313. ],
  5314. [
  5315. 5,
  5316. 10
  5317. ],
  5318. [
  5319. 5,
  5320. 10
  5321. ],
  5322. [
  5323. 5,
  5324. 10
  5325. ],
  5326. [
  5327. 5,
  5328. 10
  5329. ],
  5330. [
  5331. 5,
  5332. 10
  5333. ],
  5334. [
  5335. 5,
  5336. 10
  5337. ],
  5338. [
  5339. 5,
  5340. 10
  5341. ],
  5342. [
  5343. 5,
  5344. 10
  5345. ],
  5346. [
  5347. 5,
  5348. 10
  5349. ],
  5350. [
  5351. 5,
  5352. 10
  5353. ],
  5354. [
  5355. 5,
  5356. 10
  5357. ],
  5358. [
  5359. 5,
  5360. 10
  5361. ],
  5362. [
  5363. 5,
  5364. 10
  5365. ],
  5366. [
  5367. 5,
  5368. 10
  5369. ],
  5370. [
  5371. 5,
  5372. 11
  5373. ],
  5374. [
  5375. 5,
  5376. 11
  5377. ],
  5378. [
  5379. 5,
  5380. 11
  5381. ],
  5382. [
  5383. 5,
  5384. 11
  5385. ],
  5386. [
  5387. 5,
  5388. 11
  5389. ],
  5390. [
  5391. 5,
  5392. 11
  5393. ],
  5394. [
  5395. 5,
  5396. 11
  5397. ],
  5398. [
  5399. 5,
  5400. 11
  5401. ],
  5402. [
  5403. 5,
  5404. 11
  5405. ],
  5406. [
  5407. 5,
  5408. 11
  5409. ],
  5410. [
  5411. 5,
  5412. 11
  5413. ],
  5414. [
  5415. 5,
  5416. 11
  5417. ],
  5418. [
  5419. 5,
  5420. 11
  5421. ],
  5422. [
  5423. 5,
  5424. 11
  5425. ],
  5426. [
  5427. 5,
  5428. 11
  5429. ],
  5430. [
  5431. 5,
  5432. 11
  5433. ],
  5434. [
  5435. 7,
  5436. 27
  5437. ],
  5438. [
  5439. 7,
  5440. 27
  5441. ],
  5442. [
  5443. 7,
  5444. 27
  5445. ],
  5446. [
  5447. 7,
  5448. 27
  5449. ],
  5450. [
  5451. 8,
  5452. 59
  5453. ],
  5454. [
  5455. 8,
  5456. 59
  5457. ],
  5458. [
  5459. 8,
  5460. 60
  5461. ],
  5462. [
  5463. 8,
  5464. 60
  5465. ],
  5466. [
  5467. 9,
  5468. 1472
  5469. ],
  5470. [
  5471. 9,
  5472. 1536
  5473. ],
  5474. [
  5475. 9,
  5476. 1600
  5477. ],
  5478. [
  5479. 9,
  5480. 1728
  5481. ],
  5482. [
  5483. 7,
  5484. 18
  5485. ],
  5486. [
  5487. 7,
  5488. 18
  5489. ],
  5490. [
  5491. 7,
  5492. 18
  5493. ],
  5494. [
  5495. 7,
  5496. 18
  5497. ],
  5498. [
  5499. 7,
  5500. 24
  5501. ],
  5502. [
  5503. 7,
  5504. 24
  5505. ],
  5506. [
  5507. 7,
  5508. 24
  5509. ],
  5510. [
  5511. 7,
  5512. 24
  5513. ],
  5514. [
  5515. 8,
  5516. 49
  5517. ],
  5518. [
  5519. 8,
  5520. 49
  5521. ],
  5522. [
  5523. 8,
  5524. 50
  5525. ],
  5526. [
  5527. 8,
  5528. 50
  5529. ],
  5530. [
  5531. 8,
  5532. 51
  5533. ],
  5534. [
  5535. 8,
  5536. 51
  5537. ],
  5538. [
  5539. 8,
  5540. 52
  5541. ],
  5542. [
  5543. 8,
  5544. 52
  5545. ],
  5546. [
  5547. 7,
  5548. 25
  5549. ],
  5550. [
  5551. 7,
  5552. 25
  5553. ],
  5554. [
  5555. 7,
  5556. 25
  5557. ],
  5558. [
  5559. 7,
  5560. 25
  5561. ],
  5562. [
  5563. 8,
  5564. 55
  5565. ],
  5566. [
  5567. 8,
  5568. 55
  5569. ],
  5570. [
  5571. 8,
  5572. 56
  5573. ],
  5574. [
  5575. 8,
  5576. 56
  5577. ],
  5578. [
  5579. 8,
  5580. 57
  5581. ],
  5582. [
  5583. 8,
  5584. 57
  5585. ],
  5586. [
  5587. 8,
  5588. 58
  5589. ],
  5590. [
  5591. 8,
  5592. 58
  5593. ],
  5594. [
  5595. 6,
  5596. 192
  5597. ],
  5598. [
  5599. 6,
  5600. 192
  5601. ],
  5602. [
  5603. 6,
  5604. 192
  5605. ],
  5606. [
  5607. 6,
  5608. 192
  5609. ],
  5610. [
  5611. 6,
  5612. 192
  5613. ],
  5614. [
  5615. 6,
  5616. 192
  5617. ],
  5618. [
  5619. 6,
  5620. 192
  5621. ],
  5622. [
  5623. 6,
  5624. 192
  5625. ],
  5626. [
  5627. 6,
  5628. 1664
  5629. ],
  5630. [
  5631. 6,
  5632. 1664
  5633. ],
  5634. [
  5635. 6,
  5636. 1664
  5637. ],
  5638. [
  5639. 6,
  5640. 1664
  5641. ],
  5642. [
  5643. 6,
  5644. 1664
  5645. ],
  5646. [
  5647. 6,
  5648. 1664
  5649. ],
  5650. [
  5651. 6,
  5652. 1664
  5653. ],
  5654. [
  5655. 6,
  5656. 1664
  5657. ],
  5658. [
  5659. 8,
  5660. 448
  5661. ],
  5662. [
  5663. 8,
  5664. 448
  5665. ],
  5666. [
  5667. 8,
  5668. 512
  5669. ],
  5670. [
  5671. 8,
  5672. 512
  5673. ],
  5674. [
  5675. 9,
  5676. 704
  5677. ],
  5678. [
  5679. 9,
  5680. 768
  5681. ],
  5682. [
  5683. 8,
  5684. 640
  5685. ],
  5686. [
  5687. 8,
  5688. 640
  5689. ],
  5690. [
  5691. 8,
  5692. 576
  5693. ],
  5694. [
  5695. 8,
  5696. 576
  5697. ],
  5698. [
  5699. 9,
  5700. 832
  5701. ],
  5702. [
  5703. 9,
  5704. 896
  5705. ],
  5706. [
  5707. 9,
  5708. 960
  5709. ],
  5710. [
  5711. 9,
  5712. 1024
  5713. ],
  5714. [
  5715. 9,
  5716. 1088
  5717. ],
  5718. [
  5719. 9,
  5720. 1152
  5721. ],
  5722. [
  5723. 9,
  5724. 1216
  5725. ],
  5726. [
  5727. 9,
  5728. 1280
  5729. ],
  5730. [
  5731. 9,
  5732. 1344
  5733. ],
  5734. [
  5735. 9,
  5736. 1408
  5737. ],
  5738. [
  5739. 7,
  5740. 256
  5741. ],
  5742. [
  5743. 7,
  5744. 256
  5745. ],
  5746. [
  5747. 7,
  5748. 256
  5749. ],
  5750. [
  5751. 7,
  5752. 256
  5753. ],
  5754. [
  5755. 4,
  5756. 2
  5757. ],
  5758. [
  5759. 4,
  5760. 2
  5761. ],
  5762. [
  5763. 4,
  5764. 2
  5765. ],
  5766. [
  5767. 4,
  5768. 2
  5769. ],
  5770. [
  5771. 4,
  5772. 2
  5773. ],
  5774. [
  5775. 4,
  5776. 2
  5777. ],
  5778. [
  5779. 4,
  5780. 2
  5781. ],
  5782. [
  5783. 4,
  5784. 2
  5785. ],
  5786. [
  5787. 4,
  5788. 2
  5789. ],
  5790. [
  5791. 4,
  5792. 2
  5793. ],
  5794. [
  5795. 4,
  5796. 2
  5797. ],
  5798. [
  5799. 4,
  5800. 2
  5801. ],
  5802. [
  5803. 4,
  5804. 2
  5805. ],
  5806. [
  5807. 4,
  5808. 2
  5809. ],
  5810. [
  5811. 4,
  5812. 2
  5813. ],
  5814. [
  5815. 4,
  5816. 2
  5817. ],
  5818. [
  5819. 4,
  5820. 2
  5821. ],
  5822. [
  5823. 4,
  5824. 2
  5825. ],
  5826. [
  5827. 4,
  5828. 2
  5829. ],
  5830. [
  5831. 4,
  5832. 2
  5833. ],
  5834. [
  5835. 4,
  5836. 2
  5837. ],
  5838. [
  5839. 4,
  5840. 2
  5841. ],
  5842. [
  5843. 4,
  5844. 2
  5845. ],
  5846. [
  5847. 4,
  5848. 2
  5849. ],
  5850. [
  5851. 4,
  5852. 2
  5853. ],
  5854. [
  5855. 4,
  5856. 2
  5857. ],
  5858. [
  5859. 4,
  5860. 2
  5861. ],
  5862. [
  5863. 4,
  5864. 2
  5865. ],
  5866. [
  5867. 4,
  5868. 2
  5869. ],
  5870. [
  5871. 4,
  5872. 2
  5873. ],
  5874. [
  5875. 4,
  5876. 2
  5877. ],
  5878. [
  5879. 4,
  5880. 2
  5881. ],
  5882. [
  5883. 4,
  5884. 3
  5885. ],
  5886. [
  5887. 4,
  5888. 3
  5889. ],
  5890. [
  5891. 4,
  5892. 3
  5893. ],
  5894. [
  5895. 4,
  5896. 3
  5897. ],
  5898. [
  5899. 4,
  5900. 3
  5901. ],
  5902. [
  5903. 4,
  5904. 3
  5905. ],
  5906. [
  5907. 4,
  5908. 3
  5909. ],
  5910. [
  5911. 4,
  5912. 3
  5913. ],
  5914. [
  5915. 4,
  5916. 3
  5917. ],
  5918. [
  5919. 4,
  5920. 3
  5921. ],
  5922. [
  5923. 4,
  5924. 3
  5925. ],
  5926. [
  5927. 4,
  5928. 3
  5929. ],
  5930. [
  5931. 4,
  5932. 3
  5933. ],
  5934. [
  5935. 4,
  5936. 3
  5937. ],
  5938. [
  5939. 4,
  5940. 3
  5941. ],
  5942. [
  5943. 4,
  5944. 3
  5945. ],
  5946. [
  5947. 4,
  5948. 3
  5949. ],
  5950. [
  5951. 4,
  5952. 3
  5953. ],
  5954. [
  5955. 4,
  5956. 3
  5957. ],
  5958. [
  5959. 4,
  5960. 3
  5961. ],
  5962. [
  5963. 4,
  5964. 3
  5965. ],
  5966. [
  5967. 4,
  5968. 3
  5969. ],
  5970. [
  5971. 4,
  5972. 3
  5973. ],
  5974. [
  5975. 4,
  5976. 3
  5977. ],
  5978. [
  5979. 4,
  5980. 3
  5981. ],
  5982. [
  5983. 4,
  5984. 3
  5985. ],
  5986. [
  5987. 4,
  5988. 3
  5989. ],
  5990. [
  5991. 4,
  5992. 3
  5993. ],
  5994. [
  5995. 4,
  5996. 3
  5997. ],
  5998. [
  5999. 4,
  6000. 3
  6001. ],
  6002. [
  6003. 4,
  6004. 3
  6005. ],
  6006. [
  6007. 4,
  6008. 3
  6009. ],
  6010. [
  6011. 5,
  6012. 128
  6013. ],
  6014. [
  6015. 5,
  6016. 128
  6017. ],
  6018. [
  6019. 5,
  6020. 128
  6021. ],
  6022. [
  6023. 5,
  6024. 128
  6025. ],
  6026. [
  6027. 5,
  6028. 128
  6029. ],
  6030. [
  6031. 5,
  6032. 128
  6033. ],
  6034. [
  6035. 5,
  6036. 128
  6037. ],
  6038. [
  6039. 5,
  6040. 128
  6041. ],
  6042. [
  6043. 5,
  6044. 128
  6045. ],
  6046. [
  6047. 5,
  6048. 128
  6049. ],
  6050. [
  6051. 5,
  6052. 128
  6053. ],
  6054. [
  6055. 5,
  6056. 128
  6057. ],
  6058. [
  6059. 5,
  6060. 128
  6061. ],
  6062. [
  6063. 5,
  6064. 128
  6065. ],
  6066. [
  6067. 5,
  6068. 128
  6069. ],
  6070. [
  6071. 5,
  6072. 128
  6073. ],
  6074. [
  6075. 5,
  6076. 8
  6077. ],
  6078. [
  6079. 5,
  6080. 8
  6081. ],
  6082. [
  6083. 5,
  6084. 8
  6085. ],
  6086. [
  6087. 5,
  6088. 8
  6089. ],
  6090. [
  6091. 5,
  6092. 8
  6093. ],
  6094. [
  6095. 5,
  6096. 8
  6097. ],
  6098. [
  6099. 5,
  6100. 8
  6101. ],
  6102. [
  6103. 5,
  6104. 8
  6105. ],
  6106. [
  6107. 5,
  6108. 8
  6109. ],
  6110. [
  6111. 5,
  6112. 8
  6113. ],
  6114. [
  6115. 5,
  6116. 8
  6117. ],
  6118. [
  6119. 5,
  6120. 8
  6121. ],
  6122. [
  6123. 5,
  6124. 8
  6125. ],
  6126. [
  6127. 5,
  6128. 8
  6129. ],
  6130. [
  6131. 5,
  6132. 8
  6133. ],
  6134. [
  6135. 5,
  6136. 8
  6137. ],
  6138. [
  6139. 5,
  6140. 9
  6141. ],
  6142. [
  6143. 5,
  6144. 9
  6145. ],
  6146. [
  6147. 5,
  6148. 9
  6149. ],
  6150. [
  6151. 5,
  6152. 9
  6153. ],
  6154. [
  6155. 5,
  6156. 9
  6157. ],
  6158. [
  6159. 5,
  6160. 9
  6161. ],
  6162. [
  6163. 5,
  6164. 9
  6165. ],
  6166. [
  6167. 5,
  6168. 9
  6169. ],
  6170. [
  6171. 5,
  6172. 9
  6173. ],
  6174. [
  6175. 5,
  6176. 9
  6177. ],
  6178. [
  6179. 5,
  6180. 9
  6181. ],
  6182. [
  6183. 5,
  6184. 9
  6185. ],
  6186. [
  6187. 5,
  6188. 9
  6189. ],
  6190. [
  6191. 5,
  6192. 9
  6193. ],
  6194. [
  6195. 5,
  6196. 9
  6197. ],
  6198. [
  6199. 5,
  6200. 9
  6201. ],
  6202. [
  6203. 6,
  6204. 16
  6205. ],
  6206. [
  6207. 6,
  6208. 16
  6209. ],
  6210. [
  6211. 6,
  6212. 16
  6213. ],
  6214. [
  6215. 6,
  6216. 16
  6217. ],
  6218. [
  6219. 6,
  6220. 16
  6221. ],
  6222. [
  6223. 6,
  6224. 16
  6225. ],
  6226. [
  6227. 6,
  6228. 16
  6229. ],
  6230. [
  6231. 6,
  6232. 16
  6233. ],
  6234. [
  6235. 6,
  6236. 17
  6237. ],
  6238. [
  6239. 6,
  6240. 17
  6241. ],
  6242. [
  6243. 6,
  6244. 17
  6245. ],
  6246. [
  6247. 6,
  6248. 17
  6249. ],
  6250. [
  6251. 6,
  6252. 17
  6253. ],
  6254. [
  6255. 6,
  6256. 17
  6257. ],
  6258. [
  6259. 6,
  6260. 17
  6261. ],
  6262. [
  6263. 6,
  6264. 17
  6265. ],
  6266. [
  6267. 4,
  6268. 4
  6269. ],
  6270. [
  6271. 4,
  6272. 4
  6273. ],
  6274. [
  6275. 4,
  6276. 4
  6277. ],
  6278. [
  6279. 4,
  6280. 4
  6281. ],
  6282. [
  6283. 4,
  6284. 4
  6285. ],
  6286. [
  6287. 4,
  6288. 4
  6289. ],
  6290. [
  6291. 4,
  6292. 4
  6293. ],
  6294. [
  6295. 4,
  6296. 4
  6297. ],
  6298. [
  6299. 4,
  6300. 4
  6301. ],
  6302. [
  6303. 4,
  6304. 4
  6305. ],
  6306. [
  6307. 4,
  6308. 4
  6309. ],
  6310. [
  6311. 4,
  6312. 4
  6313. ],
  6314. [
  6315. 4,
  6316. 4
  6317. ],
  6318. [
  6319. 4,
  6320. 4
  6321. ],
  6322. [
  6323. 4,
  6324. 4
  6325. ],
  6326. [
  6327. 4,
  6328. 4
  6329. ],
  6330. [
  6331. 4,
  6332. 4
  6333. ],
  6334. [
  6335. 4,
  6336. 4
  6337. ],
  6338. [
  6339. 4,
  6340. 4
  6341. ],
  6342. [
  6343. 4,
  6344. 4
  6345. ],
  6346. [
  6347. 4,
  6348. 4
  6349. ],
  6350. [
  6351. 4,
  6352. 4
  6353. ],
  6354. [
  6355. 4,
  6356. 4
  6357. ],
  6358. [
  6359. 4,
  6360. 4
  6361. ],
  6362. [
  6363. 4,
  6364. 4
  6365. ],
  6366. [
  6367. 4,
  6368. 4
  6369. ],
  6370. [
  6371. 4,
  6372. 4
  6373. ],
  6374. [
  6375. 4,
  6376. 4
  6377. ],
  6378. [
  6379. 4,
  6380. 4
  6381. ],
  6382. [
  6383. 4,
  6384. 4
  6385. ],
  6386. [
  6387. 4,
  6388. 4
  6389. ],
  6390. [
  6391. 4,
  6392. 4
  6393. ],
  6394. [
  6395. 4,
  6396. 5
  6397. ],
  6398. [
  6399. 4,
  6400. 5
  6401. ],
  6402. [
  6403. 4,
  6404. 5
  6405. ],
  6406. [
  6407. 4,
  6408. 5
  6409. ],
  6410. [
  6411. 4,
  6412. 5
  6413. ],
  6414. [
  6415. 4,
  6416. 5
  6417. ],
  6418. [
  6419. 4,
  6420. 5
  6421. ],
  6422. [
  6423. 4,
  6424. 5
  6425. ],
  6426. [
  6427. 4,
  6428. 5
  6429. ],
  6430. [
  6431. 4,
  6432. 5
  6433. ],
  6434. [
  6435. 4,
  6436. 5
  6437. ],
  6438. [
  6439. 4,
  6440. 5
  6441. ],
  6442. [
  6443. 4,
  6444. 5
  6445. ],
  6446. [
  6447. 4,
  6448. 5
  6449. ],
  6450. [
  6451. 4,
  6452. 5
  6453. ],
  6454. [
  6455. 4,
  6456. 5
  6457. ],
  6458. [
  6459. 4,
  6460. 5
  6461. ],
  6462. [
  6463. 4,
  6464. 5
  6465. ],
  6466. [
  6467. 4,
  6468. 5
  6469. ],
  6470. [
  6471. 4,
  6472. 5
  6473. ],
  6474. [
  6475. 4,
  6476. 5
  6477. ],
  6478. [
  6479. 4,
  6480. 5
  6481. ],
  6482. [
  6483. 4,
  6484. 5
  6485. ],
  6486. [
  6487. 4,
  6488. 5
  6489. ],
  6490. [
  6491. 4,
  6492. 5
  6493. ],
  6494. [
  6495. 4,
  6496. 5
  6497. ],
  6498. [
  6499. 4,
  6500. 5
  6501. ],
  6502. [
  6503. 4,
  6504. 5
  6505. ],
  6506. [
  6507. 4,
  6508. 5
  6509. ],
  6510. [
  6511. 4,
  6512. 5
  6513. ],
  6514. [
  6515. 4,
  6516. 5
  6517. ],
  6518. [
  6519. 4,
  6520. 5
  6521. ],
  6522. [
  6523. 6,
  6524. 14
  6525. ],
  6526. [
  6527. 6,
  6528. 14
  6529. ],
  6530. [
  6531. 6,
  6532. 14
  6533. ],
  6534. [
  6535. 6,
  6536. 14
  6537. ],
  6538. [
  6539. 6,
  6540. 14
  6541. ],
  6542. [
  6543. 6,
  6544. 14
  6545. ],
  6546. [
  6547. 6,
  6548. 14
  6549. ],
  6550. [
  6551. 6,
  6552. 14
  6553. ],
  6554. [
  6555. 6,
  6556. 15
  6557. ],
  6558. [
  6559. 6,
  6560. 15
  6561. ],
  6562. [
  6563. 6,
  6564. 15
  6565. ],
  6566. [
  6567. 6,
  6568. 15
  6569. ],
  6570. [
  6571. 6,
  6572. 15
  6573. ],
  6574. [
  6575. 6,
  6576. 15
  6577. ],
  6578. [
  6579. 6,
  6580. 15
  6581. ],
  6582. [
  6583. 6,
  6584. 15
  6585. ],
  6586. [
  6587. 5,
  6588. 64
  6589. ],
  6590. [
  6591. 5,
  6592. 64
  6593. ],
  6594. [
  6595. 5,
  6596. 64
  6597. ],
  6598. [
  6599. 5,
  6600. 64
  6601. ],
  6602. [
  6603. 5,
  6604. 64
  6605. ],
  6606. [
  6607. 5,
  6608. 64
  6609. ],
  6610. [
  6611. 5,
  6612. 64
  6613. ],
  6614. [
  6615. 5,
  6616. 64
  6617. ],
  6618. [
  6619. 5,
  6620. 64
  6621. ],
  6622. [
  6623. 5,
  6624. 64
  6625. ],
  6626. [
  6627. 5,
  6628. 64
  6629. ],
  6630. [
  6631. 5,
  6632. 64
  6633. ],
  6634. [
  6635. 5,
  6636. 64
  6637. ],
  6638. [
  6639. 5,
  6640. 64
  6641. ],
  6642. [
  6643. 5,
  6644. 64
  6645. ],
  6646. [
  6647. 5,
  6648. 64
  6649. ],
  6650. [
  6651. 4,
  6652. 6
  6653. ],
  6654. [
  6655. 4,
  6656. 6
  6657. ],
  6658. [
  6659. 4,
  6660. 6
  6661. ],
  6662. [
  6663. 4,
  6664. 6
  6665. ],
  6666. [
  6667. 4,
  6668. 6
  6669. ],
  6670. [
  6671. 4,
  6672. 6
  6673. ],
  6674. [
  6675. 4,
  6676. 6
  6677. ],
  6678. [
  6679. 4,
  6680. 6
  6681. ],
  6682. [
  6683. 4,
  6684. 6
  6685. ],
  6686. [
  6687. 4,
  6688. 6
  6689. ],
  6690. [
  6691. 4,
  6692. 6
  6693. ],
  6694. [
  6695. 4,
  6696. 6
  6697. ],
  6698. [
  6699. 4,
  6700. 6
  6701. ],
  6702. [
  6703. 4,
  6704. 6
  6705. ],
  6706. [
  6707. 4,
  6708. 6
  6709. ],
  6710. [
  6711. 4,
  6712. 6
  6713. ],
  6714. [
  6715. 4,
  6716. 6
  6717. ],
  6718. [
  6719. 4,
  6720. 6
  6721. ],
  6722. [
  6723. 4,
  6724. 6
  6725. ],
  6726. [
  6727. 4,
  6728. 6
  6729. ],
  6730. [
  6731. 4,
  6732. 6
  6733. ],
  6734. [
  6735. 4,
  6736. 6
  6737. ],
  6738. [
  6739. 4,
  6740. 6
  6741. ],
  6742. [
  6743. 4,
  6744. 6
  6745. ],
  6746. [
  6747. 4,
  6748. 6
  6749. ],
  6750. [
  6751. 4,
  6752. 6
  6753. ],
  6754. [
  6755. 4,
  6756. 6
  6757. ],
  6758. [
  6759. 4,
  6760. 6
  6761. ],
  6762. [
  6763. 4,
  6764. 6
  6765. ],
  6766. [
  6767. 4,
  6768. 6
  6769. ],
  6770. [
  6771. 4,
  6772. 6
  6773. ],
  6774. [
  6775. 4,
  6776. 6
  6777. ],
  6778. [
  6779. 4,
  6780. 7
  6781. ],
  6782. [
  6783. 4,
  6784. 7
  6785. ],
  6786. [
  6787. 4,
  6788. 7
  6789. ],
  6790. [
  6791. 4,
  6792. 7
  6793. ],
  6794. [
  6795. 4,
  6796. 7
  6797. ],
  6798. [
  6799. 4,
  6800. 7
  6801. ],
  6802. [
  6803. 4,
  6804. 7
  6805. ],
  6806. [
  6807. 4,
  6808. 7
  6809. ],
  6810. [
  6811. 4,
  6812. 7
  6813. ],
  6814. [
  6815. 4,
  6816. 7
  6817. ],
  6818. [
  6819. 4,
  6820. 7
  6821. ],
  6822. [
  6823. 4,
  6824. 7
  6825. ],
  6826. [
  6827. 4,
  6828. 7
  6829. ],
  6830. [
  6831. 4,
  6832. 7
  6833. ],
  6834. [
  6835. 4,
  6836. 7
  6837. ],
  6838. [
  6839. 4,
  6840. 7
  6841. ],
  6842. [
  6843. 4,
  6844. 7
  6845. ],
  6846. [
  6847. 4,
  6848. 7
  6849. ],
  6850. [
  6851. 4,
  6852. 7
  6853. ],
  6854. [
  6855. 4,
  6856. 7
  6857. ],
  6858. [
  6859. 4,
  6860. 7
  6861. ],
  6862. [
  6863. 4,
  6864. 7
  6865. ],
  6866. [
  6867. 4,
  6868. 7
  6869. ],
  6870. [
  6871. 4,
  6872. 7
  6873. ],
  6874. [
  6875. 4,
  6876. 7
  6877. ],
  6878. [
  6879. 4,
  6880. 7
  6881. ],
  6882. [
  6883. 4,
  6884. 7
  6885. ],
  6886. [
  6887. 4,
  6888. 7
  6889. ],
  6890. [
  6891. 4,
  6892. 7
  6893. ],
  6894. [
  6895. 4,
  6896. 7
  6897. ],
  6898. [
  6899. 4,
  6900. 7
  6901. ],
  6902. [
  6903. 4,
  6904. 7
  6905. ]
  6906. ];
  6907. var blackTable1 = [
  6908. [
  6909. -1,
  6910. -1
  6911. ],
  6912. [
  6913. -1,
  6914. -1
  6915. ],
  6916. [
  6917. 12,
  6918. ccittEOL
  6919. ],
  6920. [
  6921. 12,
  6922. ccittEOL
  6923. ],
  6924. [
  6925. -1,
  6926. -1
  6927. ],
  6928. [
  6929. -1,
  6930. -1
  6931. ],
  6932. [
  6933. -1,
  6934. -1
  6935. ],
  6936. [
  6937. -1,
  6938. -1
  6939. ],
  6940. [
  6941. -1,
  6942. -1
  6943. ],
  6944. [
  6945. -1,
  6946. -1
  6947. ],
  6948. [
  6949. -1,
  6950. -1
  6951. ],
  6952. [
  6953. -1,
  6954. -1
  6955. ],
  6956. [
  6957. -1,
  6958. -1
  6959. ],
  6960. [
  6961. -1,
  6962. -1
  6963. ],
  6964. [
  6965. -1,
  6966. -1
  6967. ],
  6968. [
  6969. -1,
  6970. -1
  6971. ],
  6972. [
  6973. -1,
  6974. -1
  6975. ],
  6976. [
  6977. -1,
  6978. -1
  6979. ],
  6980. [
  6981. -1,
  6982. -1
  6983. ],
  6984. [
  6985. -1,
  6986. -1
  6987. ],
  6988. [
  6989. -1,
  6990. -1
  6991. ],
  6992. [
  6993. -1,
  6994. -1
  6995. ],
  6996. [
  6997. -1,
  6998. -1
  6999. ],
  7000. [
  7001. -1,
  7002. -1
  7003. ],
  7004. [
  7005. -1,
  7006. -1
  7007. ],
  7008. [
  7009. -1,
  7010. -1
  7011. ],
  7012. [
  7013. -1,
  7014. -1
  7015. ],
  7016. [
  7017. -1,
  7018. -1
  7019. ],
  7020. [
  7021. -1,
  7022. -1
  7023. ],
  7024. [
  7025. -1,
  7026. -1
  7027. ],
  7028. [
  7029. -1,
  7030. -1
  7031. ],
  7032. [
  7033. -1,
  7034. -1
  7035. ],
  7036. [
  7037. 11,
  7038. 1792
  7039. ],
  7040. [
  7041. 11,
  7042. 1792
  7043. ],
  7044. [
  7045. 11,
  7046. 1792
  7047. ],
  7048. [
  7049. 11,
  7050. 1792
  7051. ],
  7052. [
  7053. 12,
  7054. 1984
  7055. ],
  7056. [
  7057. 12,
  7058. 1984
  7059. ],
  7060. [
  7061. 12,
  7062. 2048
  7063. ],
  7064. [
  7065. 12,
  7066. 2048
  7067. ],
  7068. [
  7069. 12,
  7070. 2112
  7071. ],
  7072. [
  7073. 12,
  7074. 2112
  7075. ],
  7076. [
  7077. 12,
  7078. 2176
  7079. ],
  7080. [
  7081. 12,
  7082. 2176
  7083. ],
  7084. [
  7085. 12,
  7086. 2240
  7087. ],
  7088. [
  7089. 12,
  7090. 2240
  7091. ],
  7092. [
  7093. 12,
  7094. 2304
  7095. ],
  7096. [
  7097. 12,
  7098. 2304
  7099. ],
  7100. [
  7101. 11,
  7102. 1856
  7103. ],
  7104. [
  7105. 11,
  7106. 1856
  7107. ],
  7108. [
  7109. 11,
  7110. 1856
  7111. ],
  7112. [
  7113. 11,
  7114. 1856
  7115. ],
  7116. [
  7117. 11,
  7118. 1920
  7119. ],
  7120. [
  7121. 11,
  7122. 1920
  7123. ],
  7124. [
  7125. 11,
  7126. 1920
  7127. ],
  7128. [
  7129. 11,
  7130. 1920
  7131. ],
  7132. [
  7133. 12,
  7134. 2368
  7135. ],
  7136. [
  7137. 12,
  7138. 2368
  7139. ],
  7140. [
  7141. 12,
  7142. 2432
  7143. ],
  7144. [
  7145. 12,
  7146. 2432
  7147. ],
  7148. [
  7149. 12,
  7150. 2496
  7151. ],
  7152. [
  7153. 12,
  7154. 2496
  7155. ],
  7156. [
  7157. 12,
  7158. 2560
  7159. ],
  7160. [
  7161. 12,
  7162. 2560
  7163. ],
  7164. [
  7165. 10,
  7166. 18
  7167. ],
  7168. [
  7169. 10,
  7170. 18
  7171. ],
  7172. [
  7173. 10,
  7174. 18
  7175. ],
  7176. [
  7177. 10,
  7178. 18
  7179. ],
  7180. [
  7181. 10,
  7182. 18
  7183. ],
  7184. [
  7185. 10,
  7186. 18
  7187. ],
  7188. [
  7189. 10,
  7190. 18
  7191. ],
  7192. [
  7193. 10,
  7194. 18
  7195. ],
  7196. [
  7197. 12,
  7198. 52
  7199. ],
  7200. [
  7201. 12,
  7202. 52
  7203. ],
  7204. [
  7205. 13,
  7206. 640
  7207. ],
  7208. [
  7209. 13,
  7210. 704
  7211. ],
  7212. [
  7213. 13,
  7214. 768
  7215. ],
  7216. [
  7217. 13,
  7218. 832
  7219. ],
  7220. [
  7221. 12,
  7222. 55
  7223. ],
  7224. [
  7225. 12,
  7226. 55
  7227. ],
  7228. [
  7229. 12,
  7230. 56
  7231. ],
  7232. [
  7233. 12,
  7234. 56
  7235. ],
  7236. [
  7237. 13,
  7238. 1280
  7239. ],
  7240. [
  7241. 13,
  7242. 1344
  7243. ],
  7244. [
  7245. 13,
  7246. 1408
  7247. ],
  7248. [
  7249. 13,
  7250. 1472
  7251. ],
  7252. [
  7253. 12,
  7254. 59
  7255. ],
  7256. [
  7257. 12,
  7258. 59
  7259. ],
  7260. [
  7261. 12,
  7262. 60
  7263. ],
  7264. [
  7265. 12,
  7266. 60
  7267. ],
  7268. [
  7269. 13,
  7270. 1536
  7271. ],
  7272. [
  7273. 13,
  7274. 1600
  7275. ],
  7276. [
  7277. 11,
  7278. 24
  7279. ],
  7280. [
  7281. 11,
  7282. 24
  7283. ],
  7284. [
  7285. 11,
  7286. 24
  7287. ],
  7288. [
  7289. 11,
  7290. 24
  7291. ],
  7292. [
  7293. 11,
  7294. 25
  7295. ],
  7296. [
  7297. 11,
  7298. 25
  7299. ],
  7300. [
  7301. 11,
  7302. 25
  7303. ],
  7304. [
  7305. 11,
  7306. 25
  7307. ],
  7308. [
  7309. 13,
  7310. 1664
  7311. ],
  7312. [
  7313. 13,
  7314. 1728
  7315. ],
  7316. [
  7317. 12,
  7318. 320
  7319. ],
  7320. [
  7321. 12,
  7322. 320
  7323. ],
  7324. [
  7325. 12,
  7326. 384
  7327. ],
  7328. [
  7329. 12,
  7330. 384
  7331. ],
  7332. [
  7333. 12,
  7334. 448
  7335. ],
  7336. [
  7337. 12,
  7338. 448
  7339. ],
  7340. [
  7341. 13,
  7342. 512
  7343. ],
  7344. [
  7345. 13,
  7346. 576
  7347. ],
  7348. [
  7349. 12,
  7350. 53
  7351. ],
  7352. [
  7353. 12,
  7354. 53
  7355. ],
  7356. [
  7357. 12,
  7358. 54
  7359. ],
  7360. [
  7361. 12,
  7362. 54
  7363. ],
  7364. [
  7365. 13,
  7366. 896
  7367. ],
  7368. [
  7369. 13,
  7370. 960
  7371. ],
  7372. [
  7373. 13,
  7374. 1024
  7375. ],
  7376. [
  7377. 13,
  7378. 1088
  7379. ],
  7380. [
  7381. 13,
  7382. 1152
  7383. ],
  7384. [
  7385. 13,
  7386. 1216
  7387. ],
  7388. [
  7389. 10,
  7390. 64
  7391. ],
  7392. [
  7393. 10,
  7394. 64
  7395. ],
  7396. [
  7397. 10,
  7398. 64
  7399. ],
  7400. [
  7401. 10,
  7402. 64
  7403. ],
  7404. [
  7405. 10,
  7406. 64
  7407. ],
  7408. [
  7409. 10,
  7410. 64
  7411. ],
  7412. [
  7413. 10,
  7414. 64
  7415. ],
  7416. [
  7417. 10,
  7418. 64
  7419. ]
  7420. ];
  7421. var blackTable2 = [
  7422. [
  7423. 8,
  7424. 13
  7425. ],
  7426. [
  7427. 8,
  7428. 13
  7429. ],
  7430. [
  7431. 8,
  7432. 13
  7433. ],
  7434. [
  7435. 8,
  7436. 13
  7437. ],
  7438. [
  7439. 8,
  7440. 13
  7441. ],
  7442. [
  7443. 8,
  7444. 13
  7445. ],
  7446. [
  7447. 8,
  7448. 13
  7449. ],
  7450. [
  7451. 8,
  7452. 13
  7453. ],
  7454. [
  7455. 8,
  7456. 13
  7457. ],
  7458. [
  7459. 8,
  7460. 13
  7461. ],
  7462. [
  7463. 8,
  7464. 13
  7465. ],
  7466. [
  7467. 8,
  7468. 13
  7469. ],
  7470. [
  7471. 8,
  7472. 13
  7473. ],
  7474. [
  7475. 8,
  7476. 13
  7477. ],
  7478. [
  7479. 8,
  7480. 13
  7481. ],
  7482. [
  7483. 8,
  7484. 13
  7485. ],
  7486. [
  7487. 11,
  7488. 23
  7489. ],
  7490. [
  7491. 11,
  7492. 23
  7493. ],
  7494. [
  7495. 12,
  7496. 50
  7497. ],
  7498. [
  7499. 12,
  7500. 51
  7501. ],
  7502. [
  7503. 12,
  7504. 44
  7505. ],
  7506. [
  7507. 12,
  7508. 45
  7509. ],
  7510. [
  7511. 12,
  7512. 46
  7513. ],
  7514. [
  7515. 12,
  7516. 47
  7517. ],
  7518. [
  7519. 12,
  7520. 57
  7521. ],
  7522. [
  7523. 12,
  7524. 58
  7525. ],
  7526. [
  7527. 12,
  7528. 61
  7529. ],
  7530. [
  7531. 12,
  7532. 256
  7533. ],
  7534. [
  7535. 10,
  7536. 16
  7537. ],
  7538. [
  7539. 10,
  7540. 16
  7541. ],
  7542. [
  7543. 10,
  7544. 16
  7545. ],
  7546. [
  7547. 10,
  7548. 16
  7549. ],
  7550. [
  7551. 10,
  7552. 17
  7553. ],
  7554. [
  7555. 10,
  7556. 17
  7557. ],
  7558. [
  7559. 10,
  7560. 17
  7561. ],
  7562. [
  7563. 10,
  7564. 17
  7565. ],
  7566. [
  7567. 12,
  7568. 48
  7569. ],
  7570. [
  7571. 12,
  7572. 49
  7573. ],
  7574. [
  7575. 12,
  7576. 62
  7577. ],
  7578. [
  7579. 12,
  7580. 63
  7581. ],
  7582. [
  7583. 12,
  7584. 30
  7585. ],
  7586. [
  7587. 12,
  7588. 31
  7589. ],
  7590. [
  7591. 12,
  7592. 32
  7593. ],
  7594. [
  7595. 12,
  7596. 33
  7597. ],
  7598. [
  7599. 12,
  7600. 40
  7601. ],
  7602. [
  7603. 12,
  7604. 41
  7605. ],
  7606. [
  7607. 11,
  7608. 22
  7609. ],
  7610. [
  7611. 11,
  7612. 22
  7613. ],
  7614. [
  7615. 8,
  7616. 14
  7617. ],
  7618. [
  7619. 8,
  7620. 14
  7621. ],
  7622. [
  7623. 8,
  7624. 14
  7625. ],
  7626. [
  7627. 8,
  7628. 14
  7629. ],
  7630. [
  7631. 8,
  7632. 14
  7633. ],
  7634. [
  7635. 8,
  7636. 14
  7637. ],
  7638. [
  7639. 8,
  7640. 14
  7641. ],
  7642. [
  7643. 8,
  7644. 14
  7645. ],
  7646. [
  7647. 8,
  7648. 14
  7649. ],
  7650. [
  7651. 8,
  7652. 14
  7653. ],
  7654. [
  7655. 8,
  7656. 14
  7657. ],
  7658. [
  7659. 8,
  7660. 14
  7661. ],
  7662. [
  7663. 8,
  7664. 14
  7665. ],
  7666. [
  7667. 8,
  7668. 14
  7669. ],
  7670. [
  7671. 8,
  7672. 14
  7673. ],
  7674. [
  7675. 8,
  7676. 14
  7677. ],
  7678. [
  7679. 7,
  7680. 10
  7681. ],
  7682. [
  7683. 7,
  7684. 10
  7685. ],
  7686. [
  7687. 7,
  7688. 10
  7689. ],
  7690. [
  7691. 7,
  7692. 10
  7693. ],
  7694. [
  7695. 7,
  7696. 10
  7697. ],
  7698. [
  7699. 7,
  7700. 10
  7701. ],
  7702. [
  7703. 7,
  7704. 10
  7705. ],
  7706. [
  7707. 7,
  7708. 10
  7709. ],
  7710. [
  7711. 7,
  7712. 10
  7713. ],
  7714. [
  7715. 7,
  7716. 10
  7717. ],
  7718. [
  7719. 7,
  7720. 10
  7721. ],
  7722. [
  7723. 7,
  7724. 10
  7725. ],
  7726. [
  7727. 7,
  7728. 10
  7729. ],
  7730. [
  7731. 7,
  7732. 10
  7733. ],
  7734. [
  7735. 7,
  7736. 10
  7737. ],
  7738. [
  7739. 7,
  7740. 10
  7741. ],
  7742. [
  7743. 7,
  7744. 10
  7745. ],
  7746. [
  7747. 7,
  7748. 10
  7749. ],
  7750. [
  7751. 7,
  7752. 10
  7753. ],
  7754. [
  7755. 7,
  7756. 10
  7757. ],
  7758. [
  7759. 7,
  7760. 10
  7761. ],
  7762. [
  7763. 7,
  7764. 10
  7765. ],
  7766. [
  7767. 7,
  7768. 10
  7769. ],
  7770. [
  7771. 7,
  7772. 10
  7773. ],
  7774. [
  7775. 7,
  7776. 10
  7777. ],
  7778. [
  7779. 7,
  7780. 10
  7781. ],
  7782. [
  7783. 7,
  7784. 10
  7785. ],
  7786. [
  7787. 7,
  7788. 10
  7789. ],
  7790. [
  7791. 7,
  7792. 10
  7793. ],
  7794. [
  7795. 7,
  7796. 10
  7797. ],
  7798. [
  7799. 7,
  7800. 10
  7801. ],
  7802. [
  7803. 7,
  7804. 10
  7805. ],
  7806. [
  7807. 7,
  7808. 11
  7809. ],
  7810. [
  7811. 7,
  7812. 11
  7813. ],
  7814. [
  7815. 7,
  7816. 11
  7817. ],
  7818. [
  7819. 7,
  7820. 11
  7821. ],
  7822. [
  7823. 7,
  7824. 11
  7825. ],
  7826. [
  7827. 7,
  7828. 11
  7829. ],
  7830. [
  7831. 7,
  7832. 11
  7833. ],
  7834. [
  7835. 7,
  7836. 11
  7837. ],
  7838. [
  7839. 7,
  7840. 11
  7841. ],
  7842. [
  7843. 7,
  7844. 11
  7845. ],
  7846. [
  7847. 7,
  7848. 11
  7849. ],
  7850. [
  7851. 7,
  7852. 11
  7853. ],
  7854. [
  7855. 7,
  7856. 11
  7857. ],
  7858. [
  7859. 7,
  7860. 11
  7861. ],
  7862. [
  7863. 7,
  7864. 11
  7865. ],
  7866. [
  7867. 7,
  7868. 11
  7869. ],
  7870. [
  7871. 7,
  7872. 11
  7873. ],
  7874. [
  7875. 7,
  7876. 11
  7877. ],
  7878. [
  7879. 7,
  7880. 11
  7881. ],
  7882. [
  7883. 7,
  7884. 11
  7885. ],
  7886. [
  7887. 7,
  7888. 11
  7889. ],
  7890. [
  7891. 7,
  7892. 11
  7893. ],
  7894. [
  7895. 7,
  7896. 11
  7897. ],
  7898. [
  7899. 7,
  7900. 11
  7901. ],
  7902. [
  7903. 7,
  7904. 11
  7905. ],
  7906. [
  7907. 7,
  7908. 11
  7909. ],
  7910. [
  7911. 7,
  7912. 11
  7913. ],
  7914. [
  7915. 7,
  7916. 11
  7917. ],
  7918. [
  7919. 7,
  7920. 11
  7921. ],
  7922. [
  7923. 7,
  7924. 11
  7925. ],
  7926. [
  7927. 7,
  7928. 11
  7929. ],
  7930. [
  7931. 7,
  7932. 11
  7933. ],
  7934. [
  7935. 9,
  7936. 15
  7937. ],
  7938. [
  7939. 9,
  7940. 15
  7941. ],
  7942. [
  7943. 9,
  7944. 15
  7945. ],
  7946. [
  7947. 9,
  7948. 15
  7949. ],
  7950. [
  7951. 9,
  7952. 15
  7953. ],
  7954. [
  7955. 9,
  7956. 15
  7957. ],
  7958. [
  7959. 9,
  7960. 15
  7961. ],
  7962. [
  7963. 9,
  7964. 15
  7965. ],
  7966. [
  7967. 12,
  7968. 128
  7969. ],
  7970. [
  7971. 12,
  7972. 192
  7973. ],
  7974. [
  7975. 12,
  7976. 26
  7977. ],
  7978. [
  7979. 12,
  7980. 27
  7981. ],
  7982. [
  7983. 12,
  7984. 28
  7985. ],
  7986. [
  7987. 12,
  7988. 29
  7989. ],
  7990. [
  7991. 11,
  7992. 19
  7993. ],
  7994. [
  7995. 11,
  7996. 19
  7997. ],
  7998. [
  7999. 11,
  8000. 20
  8001. ],
  8002. [
  8003. 11,
  8004. 20
  8005. ],
  8006. [
  8007. 12,
  8008. 34
  8009. ],
  8010. [
  8011. 12,
  8012. 35
  8013. ],
  8014. [
  8015. 12,
  8016. 36
  8017. ],
  8018. [
  8019. 12,
  8020. 37
  8021. ],
  8022. [
  8023. 12,
  8024. 38
  8025. ],
  8026. [
  8027. 12,
  8028. 39
  8029. ],
  8030. [
  8031. 11,
  8032. 21
  8033. ],
  8034. [
  8035. 11,
  8036. 21
  8037. ],
  8038. [
  8039. 12,
  8040. 42
  8041. ],
  8042. [
  8043. 12,
  8044. 43
  8045. ],
  8046. [
  8047. 10,
  8048. 0
  8049. ],
  8050. [
  8051. 10,
  8052. 0
  8053. ],
  8054. [
  8055. 10,
  8056. 0
  8057. ],
  8058. [
  8059. 10,
  8060. 0
  8061. ],
  8062. [
  8063. 7,
  8064. 12
  8065. ],
  8066. [
  8067. 7,
  8068. 12
  8069. ],
  8070. [
  8071. 7,
  8072. 12
  8073. ],
  8074. [
  8075. 7,
  8076. 12
  8077. ],
  8078. [
  8079. 7,
  8080. 12
  8081. ],
  8082. [
  8083. 7,
  8084. 12
  8085. ],
  8086. [
  8087. 7,
  8088. 12
  8089. ],
  8090. [
  8091. 7,
  8092. 12
  8093. ],
  8094. [
  8095. 7,
  8096. 12
  8097. ],
  8098. [
  8099. 7,
  8100. 12
  8101. ],
  8102. [
  8103. 7,
  8104. 12
  8105. ],
  8106. [
  8107. 7,
  8108. 12
  8109. ],
  8110. [
  8111. 7,
  8112. 12
  8113. ],
  8114. [
  8115. 7,
  8116. 12
  8117. ],
  8118. [
  8119. 7,
  8120. 12
  8121. ],
  8122. [
  8123. 7,
  8124. 12
  8125. ],
  8126. [
  8127. 7,
  8128. 12
  8129. ],
  8130. [
  8131. 7,
  8132. 12
  8133. ],
  8134. [
  8135. 7,
  8136. 12
  8137. ],
  8138. [
  8139. 7,
  8140. 12
  8141. ],
  8142. [
  8143. 7,
  8144. 12
  8145. ],
  8146. [
  8147. 7,
  8148. 12
  8149. ],
  8150. [
  8151. 7,
  8152. 12
  8153. ],
  8154. [
  8155. 7,
  8156. 12
  8157. ],
  8158. [
  8159. 7,
  8160. 12
  8161. ],
  8162. [
  8163. 7,
  8164. 12
  8165. ],
  8166. [
  8167. 7,
  8168. 12
  8169. ],
  8170. [
  8171. 7,
  8172. 12
  8173. ],
  8174. [
  8175. 7,
  8176. 12
  8177. ],
  8178. [
  8179. 7,
  8180. 12
  8181. ],
  8182. [
  8183. 7,
  8184. 12
  8185. ],
  8186. [
  8187. 7,
  8188. 12
  8189. ]
  8190. ];
  8191. var blackTable3 = [
  8192. [
  8193. -1,
  8194. -1
  8195. ],
  8196. [
  8197. -1,
  8198. -1
  8199. ],
  8200. [
  8201. -1,
  8202. -1
  8203. ],
  8204. [
  8205. -1,
  8206. -1
  8207. ],
  8208. [
  8209. 6,
  8210. 9
  8211. ],
  8212. [
  8213. 6,
  8214. 8
  8215. ],
  8216. [
  8217. 5,
  8218. 7
  8219. ],
  8220. [
  8221. 5,
  8222. 7
  8223. ],
  8224. [
  8225. 4,
  8226. 6
  8227. ],
  8228. [
  8229. 4,
  8230. 6
  8231. ],
  8232. [
  8233. 4,
  8234. 6
  8235. ],
  8236. [
  8237. 4,
  8238. 6
  8239. ],
  8240. [
  8241. 4,
  8242. 5
  8243. ],
  8244. [
  8245. 4,
  8246. 5
  8247. ],
  8248. [
  8249. 4,
  8250. 5
  8251. ],
  8252. [
  8253. 4,
  8254. 5
  8255. ],
  8256. [
  8257. 3,
  8258. 1
  8259. ],
  8260. [
  8261. 3,
  8262. 1
  8263. ],
  8264. [
  8265. 3,
  8266. 1
  8267. ],
  8268. [
  8269. 3,
  8270. 1
  8271. ],
  8272. [
  8273. 3,
  8274. 1
  8275. ],
  8276. [
  8277. 3,
  8278. 1
  8279. ],
  8280. [
  8281. 3,
  8282. 1
  8283. ],
  8284. [
  8285. 3,
  8286. 1
  8287. ],
  8288. [
  8289. 3,
  8290. 4
  8291. ],
  8292. [
  8293. 3,
  8294. 4
  8295. ],
  8296. [
  8297. 3,
  8298. 4
  8299. ],
  8300. [
  8301. 3,
  8302. 4
  8303. ],
  8304. [
  8305. 3,
  8306. 4
  8307. ],
  8308. [
  8309. 3,
  8310. 4
  8311. ],
  8312. [
  8313. 3,
  8314. 4
  8315. ],
  8316. [
  8317. 3,
  8318. 4
  8319. ],
  8320. [
  8321. 2,
  8322. 3
  8323. ],
  8324. [
  8325. 2,
  8326. 3
  8327. ],
  8328. [
  8329. 2,
  8330. 3
  8331. ],
  8332. [
  8333. 2,
  8334. 3
  8335. ],
  8336. [
  8337. 2,
  8338. 3
  8339. ],
  8340. [
  8341. 2,
  8342. 3
  8343. ],
  8344. [
  8345. 2,
  8346. 3
  8347. ],
  8348. [
  8349. 2,
  8350. 3
  8351. ],
  8352. [
  8353. 2,
  8354. 3
  8355. ],
  8356. [
  8357. 2,
  8358. 3
  8359. ],
  8360. [
  8361. 2,
  8362. 3
  8363. ],
  8364. [
  8365. 2,
  8366. 3
  8367. ],
  8368. [
  8369. 2,
  8370. 3
  8371. ],
  8372. [
  8373. 2,
  8374. 3
  8375. ],
  8376. [
  8377. 2,
  8378. 3
  8379. ],
  8380. [
  8381. 2,
  8382. 3
  8383. ],
  8384. [
  8385. 2,
  8386. 2
  8387. ],
  8388. [
  8389. 2,
  8390. 2
  8391. ],
  8392. [
  8393. 2,
  8394. 2
  8395. ],
  8396. [
  8397. 2,
  8398. 2
  8399. ],
  8400. [
  8401. 2,
  8402. 2
  8403. ],
  8404. [
  8405. 2,
  8406. 2
  8407. ],
  8408. [
  8409. 2,
  8410. 2
  8411. ],
  8412. [
  8413. 2,
  8414. 2
  8415. ],
  8416. [
  8417. 2,
  8418. 2
  8419. ],
  8420. [
  8421. 2,
  8422. 2
  8423. ],
  8424. [
  8425. 2,
  8426. 2
  8427. ],
  8428. [
  8429. 2,
  8430. 2
  8431. ],
  8432. [
  8433. 2,
  8434. 2
  8435. ],
  8436. [
  8437. 2,
  8438. 2
  8439. ],
  8440. [
  8441. 2,
  8442. 2
  8443. ],
  8444. [
  8445. 2,
  8446. 2
  8447. ]
  8448. ];
  8449. function CCITTFaxStream(str, maybeLength, params) {
  8450. this.str = str;
  8451. this.dict = str.dict;
  8452. params = params || Dict.empty;
  8453. this.encoding = params.get('K') || 0;
  8454. this.eoline = params.get('EndOfLine') || false;
  8455. this.byteAlign = params.get('EncodedByteAlign') || false;
  8456. this.columns = params.get('Columns') || 1728;
  8457. this.rows = params.get('Rows') || 0;
  8458. var eoblock = params.get('EndOfBlock');
  8459. if (eoblock === null || eoblock === undefined) {
  8460. eoblock = true;
  8461. }
  8462. this.eoblock = eoblock;
  8463. this.black = params.get('BlackIs1') || false;
  8464. this.codingLine = new Uint32Array(this.columns + 1);
  8465. this.refLine = new Uint32Array(this.columns + 2);
  8466. this.codingLine[0] = this.columns;
  8467. this.codingPos = 0;
  8468. this.row = 0;
  8469. this.nextLine2D = this.encoding < 0;
  8470. this.inputBits = 0;
  8471. this.inputBuf = 0;
  8472. this.outputBits = 0;
  8473. var code1;
  8474. while ((code1 = this.lookBits(12)) === 0) {
  8475. this.eatBits(1);
  8476. }
  8477. if (code1 === 1) {
  8478. this.eatBits(12);
  8479. }
  8480. if (this.encoding > 0) {
  8481. this.nextLine2D = !this.lookBits(1);
  8482. this.eatBits(1);
  8483. }
  8484. DecodeStream.call(this, maybeLength);
  8485. }
  8486. CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
  8487. CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
  8488. while (!this.eof) {
  8489. var c = this.lookChar();
  8490. this.ensureBuffer(this.bufferLength + 1);
  8491. this.buffer[this.bufferLength++] = c;
  8492. }
  8493. };
  8494. CCITTFaxStream.prototype.addPixels = function ccittFaxStreamAddPixels(a1, blackPixels) {
  8495. var codingLine = this.codingLine;
  8496. var codingPos = this.codingPos;
  8497. if (a1 > codingLine[codingPos]) {
  8498. if (a1 > this.columns) {
  8499. info('row is wrong length');
  8500. this.err = true;
  8501. a1 = this.columns;
  8502. }
  8503. if (codingPos & 1 ^ blackPixels) {
  8504. ++codingPos;
  8505. }
  8506. codingLine[codingPos] = a1;
  8507. }
  8508. this.codingPos = codingPos;
  8509. };
  8510. CCITTFaxStream.prototype.addPixelsNeg = function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
  8511. var codingLine = this.codingLine;
  8512. var codingPos = this.codingPos;
  8513. if (a1 > codingLine[codingPos]) {
  8514. if (a1 > this.columns) {
  8515. info('row is wrong length');
  8516. this.err = true;
  8517. a1 = this.columns;
  8518. }
  8519. if (codingPos & 1 ^ blackPixels) {
  8520. ++codingPos;
  8521. }
  8522. codingLine[codingPos] = a1;
  8523. } else if (a1 < codingLine[codingPos]) {
  8524. if (a1 < 0) {
  8525. info('invalid code');
  8526. this.err = true;
  8527. a1 = 0;
  8528. }
  8529. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  8530. --codingPos;
  8531. }
  8532. codingLine[codingPos] = a1;
  8533. }
  8534. this.codingPos = codingPos;
  8535. };
  8536. CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
  8537. var refLine = this.refLine;
  8538. var codingLine = this.codingLine;
  8539. var columns = this.columns;
  8540. var refPos, blackPixels, bits, i;
  8541. if (this.outputBits === 0) {
  8542. if (this.eof) {
  8543. return null;
  8544. }
  8545. this.err = false;
  8546. var code1, code2, code3;
  8547. if (this.nextLine2D) {
  8548. for (i = 0; codingLine[i] < columns; ++i) {
  8549. refLine[i] = codingLine[i];
  8550. }
  8551. refLine[i++] = columns;
  8552. refLine[i] = columns;
  8553. codingLine[0] = 0;
  8554. this.codingPos = 0;
  8555. refPos = 0;
  8556. blackPixels = 0;
  8557. while (codingLine[this.codingPos] < columns) {
  8558. code1 = this.getTwoDimCode();
  8559. switch (code1) {
  8560. case twoDimPass:
  8561. this.addPixels(refLine[refPos + 1], blackPixels);
  8562. if (refLine[refPos + 1] < columns) {
  8563. refPos += 2;
  8564. }
  8565. break;
  8566. case twoDimHoriz:
  8567. code1 = code2 = 0;
  8568. if (blackPixels) {
  8569. do {
  8570. code1 += code3 = this.getBlackCode();
  8571. } while (code3 >= 64);
  8572. do {
  8573. code2 += code3 = this.getWhiteCode();
  8574. } while (code3 >= 64);
  8575. } else {
  8576. do {
  8577. code1 += code3 = this.getWhiteCode();
  8578. } while (code3 >= 64);
  8579. do {
  8580. code2 += code3 = this.getBlackCode();
  8581. } while (code3 >= 64);
  8582. }
  8583. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  8584. if (codingLine[this.codingPos] < columns) {
  8585. this.addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  8586. }
  8587. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8588. refPos += 2;
  8589. }
  8590. break;
  8591. case twoDimVertR3:
  8592. this.addPixels(refLine[refPos] + 3, blackPixels);
  8593. blackPixels ^= 1;
  8594. if (codingLine[this.codingPos] < columns) {
  8595. ++refPos;
  8596. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8597. refPos += 2;
  8598. }
  8599. }
  8600. break;
  8601. case twoDimVertR2:
  8602. this.addPixels(refLine[refPos] + 2, blackPixels);
  8603. blackPixels ^= 1;
  8604. if (codingLine[this.codingPos] < columns) {
  8605. ++refPos;
  8606. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8607. refPos += 2;
  8608. }
  8609. }
  8610. break;
  8611. case twoDimVertR1:
  8612. this.addPixels(refLine[refPos] + 1, blackPixels);
  8613. blackPixels ^= 1;
  8614. if (codingLine[this.codingPos] < columns) {
  8615. ++refPos;
  8616. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8617. refPos += 2;
  8618. }
  8619. }
  8620. break;
  8621. case twoDimVert0:
  8622. this.addPixels(refLine[refPos], blackPixels);
  8623. blackPixels ^= 1;
  8624. if (codingLine[this.codingPos] < columns) {
  8625. ++refPos;
  8626. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8627. refPos += 2;
  8628. }
  8629. }
  8630. break;
  8631. case twoDimVertL3:
  8632. this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
  8633. blackPixels ^= 1;
  8634. if (codingLine[this.codingPos] < columns) {
  8635. if (refPos > 0) {
  8636. --refPos;
  8637. } else {
  8638. ++refPos;
  8639. }
  8640. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8641. refPos += 2;
  8642. }
  8643. }
  8644. break;
  8645. case twoDimVertL2:
  8646. this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
  8647. blackPixels ^= 1;
  8648. if (codingLine[this.codingPos] < columns) {
  8649. if (refPos > 0) {
  8650. --refPos;
  8651. } else {
  8652. ++refPos;
  8653. }
  8654. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8655. refPos += 2;
  8656. }
  8657. }
  8658. break;
  8659. case twoDimVertL1:
  8660. this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
  8661. blackPixels ^= 1;
  8662. if (codingLine[this.codingPos] < columns) {
  8663. if (refPos > 0) {
  8664. --refPos;
  8665. } else {
  8666. ++refPos;
  8667. }
  8668. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  8669. refPos += 2;
  8670. }
  8671. }
  8672. break;
  8673. case ccittEOF:
  8674. this.addPixels(columns, 0);
  8675. this.eof = true;
  8676. break;
  8677. default:
  8678. info('bad 2d code');
  8679. this.addPixels(columns, 0);
  8680. this.err = true;
  8681. }
  8682. }
  8683. } else {
  8684. codingLine[0] = 0;
  8685. this.codingPos = 0;
  8686. blackPixels = 0;
  8687. while (codingLine[this.codingPos] < columns) {
  8688. code1 = 0;
  8689. if (blackPixels) {
  8690. do {
  8691. code1 += code3 = this.getBlackCode();
  8692. } while (code3 >= 64);
  8693. } else {
  8694. do {
  8695. code1 += code3 = this.getWhiteCode();
  8696. } while (code3 >= 64);
  8697. }
  8698. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  8699. blackPixels ^= 1;
  8700. }
  8701. }
  8702. var gotEOL = false;
  8703. if (this.byteAlign) {
  8704. this.inputBits &= ~7;
  8705. }
  8706. if (!this.eoblock && this.row === this.rows - 1) {
  8707. this.eof = true;
  8708. } else {
  8709. code1 = this.lookBits(12);
  8710. if (this.eoline) {
  8711. while (code1 !== ccittEOF && code1 !== 1) {
  8712. this.eatBits(1);
  8713. code1 = this.lookBits(12);
  8714. }
  8715. } else {
  8716. while (code1 === 0) {
  8717. this.eatBits(1);
  8718. code1 = this.lookBits(12);
  8719. }
  8720. }
  8721. if (code1 === 1) {
  8722. this.eatBits(12);
  8723. gotEOL = true;
  8724. } else if (code1 === ccittEOF) {
  8725. this.eof = true;
  8726. }
  8727. }
  8728. if (!this.eof && this.encoding > 0) {
  8729. this.nextLine2D = !this.lookBits(1);
  8730. this.eatBits(1);
  8731. }
  8732. if (this.eoblock && gotEOL && this.byteAlign) {
  8733. code1 = this.lookBits(12);
  8734. if (code1 === 1) {
  8735. this.eatBits(12);
  8736. if (this.encoding > 0) {
  8737. this.lookBits(1);
  8738. this.eatBits(1);
  8739. }
  8740. if (this.encoding >= 0) {
  8741. for (i = 0; i < 4; ++i) {
  8742. code1 = this.lookBits(12);
  8743. if (code1 !== 1) {
  8744. info('bad rtc code: ' + code1);
  8745. }
  8746. this.eatBits(12);
  8747. if (this.encoding > 0) {
  8748. this.lookBits(1);
  8749. this.eatBits(1);
  8750. }
  8751. }
  8752. }
  8753. this.eof = true;
  8754. }
  8755. } else if (this.err && this.eoline) {
  8756. while (true) {
  8757. code1 = this.lookBits(13);
  8758. if (code1 === ccittEOF) {
  8759. this.eof = true;
  8760. return null;
  8761. }
  8762. if (code1 >> 1 === 1) {
  8763. break;
  8764. }
  8765. this.eatBits(1);
  8766. }
  8767. this.eatBits(12);
  8768. if (this.encoding > 0) {
  8769. this.eatBits(1);
  8770. this.nextLine2D = !(code1 & 1);
  8771. }
  8772. }
  8773. if (codingLine[0] > 0) {
  8774. this.outputBits = codingLine[this.codingPos = 0];
  8775. } else {
  8776. this.outputBits = codingLine[this.codingPos = 1];
  8777. }
  8778. this.row++;
  8779. }
  8780. var c;
  8781. if (this.outputBits >= 8) {
  8782. c = this.codingPos & 1 ? 0 : 0xFF;
  8783. this.outputBits -= 8;
  8784. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  8785. this.codingPos++;
  8786. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  8787. }
  8788. } else {
  8789. bits = 8;
  8790. c = 0;
  8791. do {
  8792. if (this.outputBits > bits) {
  8793. c <<= bits;
  8794. if (!(this.codingPos & 1)) {
  8795. c |= 0xFF >> 8 - bits;
  8796. }
  8797. this.outputBits -= bits;
  8798. bits = 0;
  8799. } else {
  8800. c <<= this.outputBits;
  8801. if (!(this.codingPos & 1)) {
  8802. c |= 0xFF >> 8 - this.outputBits;
  8803. }
  8804. bits -= this.outputBits;
  8805. this.outputBits = 0;
  8806. if (codingLine[this.codingPos] < columns) {
  8807. this.codingPos++;
  8808. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  8809. } else if (bits > 0) {
  8810. c <<= bits;
  8811. bits = 0;
  8812. }
  8813. }
  8814. } while (bits);
  8815. }
  8816. if (this.black) {
  8817. c ^= 0xFF;
  8818. }
  8819. return c;
  8820. };
  8821. CCITTFaxStream.prototype.findTableCode = function ccittFaxStreamFindTableCode(start, end, table, limit) {
  8822. var limitValue = limit || 0;
  8823. for (var i = start; i <= end; ++i) {
  8824. var code = this.lookBits(i);
  8825. if (code === ccittEOF) {
  8826. return [
  8827. true,
  8828. 1,
  8829. false
  8830. ];
  8831. }
  8832. if (i < end) {
  8833. code <<= end - i;
  8834. }
  8835. if (!limitValue || code >= limitValue) {
  8836. var p = table[code - limitValue];
  8837. if (p[0] === i) {
  8838. this.eatBits(i);
  8839. return [
  8840. true,
  8841. p[1],
  8842. true
  8843. ];
  8844. }
  8845. }
  8846. }
  8847. return [
  8848. false,
  8849. 0,
  8850. false
  8851. ];
  8852. };
  8853. CCITTFaxStream.prototype.getTwoDimCode = function ccittFaxStreamGetTwoDimCode() {
  8854. var code = 0;
  8855. var p;
  8856. if (this.eoblock) {
  8857. code = this.lookBits(7);
  8858. p = twoDimTable[code];
  8859. if (p && p[0] > 0) {
  8860. this.eatBits(p[0]);
  8861. return p[1];
  8862. }
  8863. } else {
  8864. var result = this.findTableCode(1, 7, twoDimTable);
  8865. if (result[0] && result[2]) {
  8866. return result[1];
  8867. }
  8868. }
  8869. info('Bad two dim code');
  8870. return ccittEOF;
  8871. };
  8872. CCITTFaxStream.prototype.getWhiteCode = function ccittFaxStreamGetWhiteCode() {
  8873. var code = 0;
  8874. var p;
  8875. if (this.eoblock) {
  8876. code = this.lookBits(12);
  8877. if (code === ccittEOF) {
  8878. return 1;
  8879. }
  8880. if (code >> 5 === 0) {
  8881. p = whiteTable1[code];
  8882. } else {
  8883. p = whiteTable2[code >> 3];
  8884. }
  8885. if (p[0] > 0) {
  8886. this.eatBits(p[0]);
  8887. return p[1];
  8888. }
  8889. } else {
  8890. var result = this.findTableCode(1, 9, whiteTable2);
  8891. if (result[0]) {
  8892. return result[1];
  8893. }
  8894. result = this.findTableCode(11, 12, whiteTable1);
  8895. if (result[0]) {
  8896. return result[1];
  8897. }
  8898. }
  8899. info('bad white code');
  8900. this.eatBits(1);
  8901. return 1;
  8902. };
  8903. CCITTFaxStream.prototype.getBlackCode = function ccittFaxStreamGetBlackCode() {
  8904. var code, p;
  8905. if (this.eoblock) {
  8906. code = this.lookBits(13);
  8907. if (code === ccittEOF) {
  8908. return 1;
  8909. }
  8910. if (code >> 7 === 0) {
  8911. p = blackTable1[code];
  8912. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  8913. p = blackTable2[(code >> 1) - 64];
  8914. } else {
  8915. p = blackTable3[code >> 7];
  8916. }
  8917. if (p[0] > 0) {
  8918. this.eatBits(p[0]);
  8919. return p[1];
  8920. }
  8921. } else {
  8922. var result = this.findTableCode(2, 6, blackTable3);
  8923. if (result[0]) {
  8924. return result[1];
  8925. }
  8926. result = this.findTableCode(7, 12, blackTable2, 64);
  8927. if (result[0]) {
  8928. return result[1];
  8929. }
  8930. result = this.findTableCode(10, 13, blackTable1);
  8931. if (result[0]) {
  8932. return result[1];
  8933. }
  8934. }
  8935. info('bad black code');
  8936. this.eatBits(1);
  8937. return 1;
  8938. };
  8939. CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
  8940. var c;
  8941. while (this.inputBits < n) {
  8942. if ((c = this.str.getByte()) === -1) {
  8943. if (this.inputBits === 0) {
  8944. return ccittEOF;
  8945. }
  8946. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  8947. }
  8948. this.inputBuf = this.inputBuf << 8 | c;
  8949. this.inputBits += 8;
  8950. }
  8951. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  8952. };
  8953. CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
  8954. if ((this.inputBits -= n) < 0) {
  8955. this.inputBits = 0;
  8956. }
  8957. };
  8958. return CCITTFaxStream;
  8959. }();
  8960. var LZWStream = function LZWStreamClosure() {
  8961. function LZWStream(str, maybeLength, earlyChange) {
  8962. this.str = str;
  8963. this.dict = str.dict;
  8964. this.cachedData = 0;
  8965. this.bitsCached = 0;
  8966. var maxLzwDictionarySize = 4096;
  8967. var lzwState = {
  8968. earlyChange: earlyChange,
  8969. codeLength: 9,
  8970. nextCode: 258,
  8971. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  8972. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  8973. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  8974. currentSequence: new Uint8Array(maxLzwDictionarySize),
  8975. currentSequenceLength: 0
  8976. };
  8977. for (var i = 0; i < 256; ++i) {
  8978. lzwState.dictionaryValues[i] = i;
  8979. lzwState.dictionaryLengths[i] = 1;
  8980. }
  8981. this.lzwState = lzwState;
  8982. DecodeStream.call(this, maybeLength);
  8983. }
  8984. LZWStream.prototype = Object.create(DecodeStream.prototype);
  8985. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  8986. var bitsCached = this.bitsCached;
  8987. var cachedData = this.cachedData;
  8988. while (bitsCached < n) {
  8989. var c = this.str.getByte();
  8990. if (c === -1) {
  8991. this.eof = true;
  8992. return null;
  8993. }
  8994. cachedData = cachedData << 8 | c;
  8995. bitsCached += 8;
  8996. }
  8997. this.bitsCached = bitsCached -= n;
  8998. this.cachedData = cachedData;
  8999. this.lastCode = null;
  9000. return cachedData >>> bitsCached & (1 << n) - 1;
  9001. };
  9002. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  9003. var blockSize = 512;
  9004. var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
  9005. var i, j, q;
  9006. var lzwState = this.lzwState;
  9007. if (!lzwState) {
  9008. return;
  9009. }
  9010. var earlyChange = lzwState.earlyChange;
  9011. var nextCode = lzwState.nextCode;
  9012. var dictionaryValues = lzwState.dictionaryValues;
  9013. var dictionaryLengths = lzwState.dictionaryLengths;
  9014. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  9015. var codeLength = lzwState.codeLength;
  9016. var prevCode = lzwState.prevCode;
  9017. var currentSequence = lzwState.currentSequence;
  9018. var currentSequenceLength = lzwState.currentSequenceLength;
  9019. var decodedLength = 0;
  9020. var currentBufferLength = this.bufferLength;
  9021. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  9022. for (i = 0; i < blockSize; i++) {
  9023. var code = this.readBits(codeLength);
  9024. var hasPrev = currentSequenceLength > 0;
  9025. if (code < 256) {
  9026. currentSequence[0] = code;
  9027. currentSequenceLength = 1;
  9028. } else if (code >= 258) {
  9029. if (code < nextCode) {
  9030. currentSequenceLength = dictionaryLengths[code];
  9031. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  9032. currentSequence[j] = dictionaryValues[q];
  9033. q = dictionaryPrevCodes[q];
  9034. }
  9035. } else {
  9036. currentSequence[currentSequenceLength++] = currentSequence[0];
  9037. }
  9038. } else if (code === 256) {
  9039. codeLength = 9;
  9040. nextCode = 258;
  9041. currentSequenceLength = 0;
  9042. continue;
  9043. } else {
  9044. this.eof = true;
  9045. delete this.lzwState;
  9046. break;
  9047. }
  9048. if (hasPrev) {
  9049. dictionaryPrevCodes[nextCode] = prevCode;
  9050. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  9051. dictionaryValues[nextCode] = currentSequence[0];
  9052. nextCode++;
  9053. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  9054. }
  9055. prevCode = code;
  9056. decodedLength += currentSequenceLength;
  9057. if (estimatedDecodedSize < decodedLength) {
  9058. do {
  9059. estimatedDecodedSize += decodedSizeDelta;
  9060. } while (estimatedDecodedSize < decodedLength);
  9061. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  9062. }
  9063. for (j = 0; j < currentSequenceLength; j++) {
  9064. buffer[currentBufferLength++] = currentSequence[j];
  9065. }
  9066. }
  9067. lzwState.nextCode = nextCode;
  9068. lzwState.codeLength = codeLength;
  9069. lzwState.prevCode = prevCode;
  9070. lzwState.currentSequenceLength = currentSequenceLength;
  9071. this.bufferLength = currentBufferLength;
  9072. };
  9073. return LZWStream;
  9074. }();
  9075. var NullStream = function NullStreamClosure() {
  9076. function NullStream() {
  9077. Stream.call(this, new Uint8Array(0));
  9078. }
  9079. NullStream.prototype = Stream.prototype;
  9080. return NullStream;
  9081. }();
  9082. exports.Ascii85Stream = Ascii85Stream;
  9083. exports.AsciiHexStream = AsciiHexStream;
  9084. exports.CCITTFaxStream = CCITTFaxStream;
  9085. exports.DecryptStream = DecryptStream;
  9086. exports.DecodeStream = DecodeStream;
  9087. exports.FlateStream = FlateStream;
  9088. exports.Jbig2Stream = Jbig2Stream;
  9089. exports.JpegStream = JpegStream;
  9090. exports.JpxStream = JpxStream;
  9091. exports.NullStream = NullStream;
  9092. exports.PredictorStream = PredictorStream;
  9093. exports.RunLengthStream = RunLengthStream;
  9094. exports.Stream = Stream;
  9095. exports.StreamsSequenceStream = StreamsSequenceStream;
  9096. exports.StringStream = StringStream;
  9097. exports.LZWStream = LZWStream;
  9098. /***/ }),
  9099. /* 3 */
  9100. /***/ (function(module, exports, __w_pdfjs_require__) {
  9101. "use strict";
  9102. var sharedUtil = __w_pdfjs_require__(0);
  9103. var assert = sharedUtil.assert;
  9104. var removeNullCharacters = sharedUtil.removeNullCharacters;
  9105. var warn = sharedUtil.warn;
  9106. var deprecated = sharedUtil.deprecated;
  9107. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  9108. var stringToBytes = sharedUtil.stringToBytes;
  9109. var CMapCompressionType = sharedUtil.CMapCompressionType;
  9110. var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
  9111. function DOMCanvasFactory() {
  9112. }
  9113. DOMCanvasFactory.prototype = {
  9114. create: function DOMCanvasFactory_create(width, height) {
  9115. assert(width > 0 && height > 0, 'invalid canvas size');
  9116. var canvas = document.createElement('canvas');
  9117. var context = canvas.getContext('2d');
  9118. canvas.width = width;
  9119. canvas.height = height;
  9120. return {
  9121. canvas: canvas,
  9122. context: context
  9123. };
  9124. },
  9125. reset: function DOMCanvasFactory_reset(canvasAndContextPair, width, height) {
  9126. assert(canvasAndContextPair.canvas, 'canvas is not specified');
  9127. assert(width > 0 && height > 0, 'invalid canvas size');
  9128. canvasAndContextPair.canvas.width = width;
  9129. canvasAndContextPair.canvas.height = height;
  9130. },
  9131. destroy: function DOMCanvasFactory_destroy(canvasAndContextPair) {
  9132. assert(canvasAndContextPair.canvas, 'canvas is not specified');
  9133. canvasAndContextPair.canvas.width = 0;
  9134. canvasAndContextPair.canvas.height = 0;
  9135. canvasAndContextPair.canvas = null;
  9136. canvasAndContextPair.context = null;
  9137. }
  9138. };
  9139. var DOMCMapReaderFactory = function DOMCMapReaderFactoryClosure() {
  9140. function DOMCMapReaderFactory(params) {
  9141. this.baseUrl = params.baseUrl || null;
  9142. this.isCompressed = params.isCompressed || false;
  9143. }
  9144. DOMCMapReaderFactory.prototype = {
  9145. fetch: function (params) {
  9146. if (!params.name) {
  9147. return Promise.reject(new Error('CMap name must be specified.'));
  9148. }
  9149. return new Promise(function (resolve, reject) {
  9150. var url = this.baseUrl + params.name;
  9151. var request = new XMLHttpRequest();
  9152. if (this.isCompressed) {
  9153. url += '.bcmap';
  9154. request.responseType = 'arraybuffer';
  9155. }
  9156. request.onreadystatechange = function () {
  9157. if (request.readyState === XMLHttpRequest.DONE && (request.status === 200 || request.status === 0)) {
  9158. var data;
  9159. if (this.isCompressed && request.response) {
  9160. data = new Uint8Array(request.response);
  9161. } else if (!this.isCompressed && request.responseText) {
  9162. data = stringToBytes(request.responseText);
  9163. }
  9164. if (data) {
  9165. resolve({
  9166. cMapData: data,
  9167. compressionType: this.isCompressed ? CMapCompressionType.BINARY : CMapCompressionType.NONE
  9168. });
  9169. return;
  9170. }
  9171. reject(new Error('Unable to load ' + (this.isCompressed ? 'binary' : '') + ' CMap at: ' + url));
  9172. }
  9173. }.bind(this);
  9174. request.open('GET', url, true);
  9175. request.send(null);
  9176. }.bind(this));
  9177. }
  9178. };
  9179. return DOMCMapReaderFactory;
  9180. }();
  9181. var CustomStyle = function CustomStyleClosure() {
  9182. var prefixes = [
  9183. 'ms',
  9184. 'Moz',
  9185. 'Webkit',
  9186. 'O'
  9187. ];
  9188. var _cache = Object.create(null);
  9189. function CustomStyle() {
  9190. }
  9191. CustomStyle.getProp = function get(propName, element) {
  9192. if (arguments.length === 1 && typeof _cache[propName] === 'string') {
  9193. return _cache[propName];
  9194. }
  9195. element = element || document.documentElement;
  9196. var style = element.style, prefixed, uPropName;
  9197. if (typeof style[propName] === 'string') {
  9198. return _cache[propName] = propName;
  9199. }
  9200. uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
  9201. for (var i = 0, l = prefixes.length; i < l; i++) {
  9202. prefixed = prefixes[i] + uPropName;
  9203. if (typeof style[prefixed] === 'string') {
  9204. return _cache[propName] = prefixed;
  9205. }
  9206. }
  9207. return _cache[propName] = 'undefined';
  9208. };
  9209. CustomStyle.setProp = function set(propName, element, str) {
  9210. var prop = this.getProp(propName);
  9211. if (prop !== 'undefined') {
  9212. element.style[prop] = str;
  9213. }
  9214. };
  9215. return CustomStyle;
  9216. }();
  9217. var hasCanvasTypedArrays;
  9218. hasCanvasTypedArrays = function hasCanvasTypedArrays() {
  9219. var canvas = document.createElement('canvas');
  9220. canvas.width = canvas.height = 1;
  9221. var ctx = canvas.getContext('2d');
  9222. var imageData = ctx.createImageData(1, 1);
  9223. return typeof imageData.data.buffer !== 'undefined';
  9224. };
  9225. var LinkTarget = {
  9226. NONE: 0,
  9227. SELF: 1,
  9228. BLANK: 2,
  9229. PARENT: 3,
  9230. TOP: 4
  9231. };
  9232. var LinkTargetStringMap = [
  9233. '',
  9234. '_self',
  9235. '_blank',
  9236. '_parent',
  9237. '_top'
  9238. ];
  9239. function addLinkAttributes(link, params) {
  9240. var url = params && params.url;
  9241. link.href = link.title = url ? removeNullCharacters(url) : '';
  9242. if (url) {
  9243. var target = params.target;
  9244. if (typeof target === 'undefined') {
  9245. target = getDefaultSetting('externalLinkTarget');
  9246. }
  9247. link.target = LinkTargetStringMap[target];
  9248. var rel = params.rel;
  9249. if (typeof rel === 'undefined') {
  9250. rel = getDefaultSetting('externalLinkRel');
  9251. }
  9252. link.rel = rel;
  9253. }
  9254. }
  9255. function getFilenameFromUrl(url) {
  9256. var anchor = url.indexOf('#');
  9257. var query = url.indexOf('?');
  9258. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  9259. return url.substring(url.lastIndexOf('/', end) + 1, end);
  9260. }
  9261. function getDefaultSetting(id) {
  9262. var globalSettings = sharedUtil.globalScope.PDFJS;
  9263. switch (id) {
  9264. case 'pdfBug':
  9265. return globalSettings ? globalSettings.pdfBug : false;
  9266. case 'disableAutoFetch':
  9267. return globalSettings ? globalSettings.disableAutoFetch : false;
  9268. case 'disableStream':
  9269. return globalSettings ? globalSettings.disableStream : false;
  9270. case 'disableRange':
  9271. return globalSettings ? globalSettings.disableRange : false;
  9272. case 'disableFontFace':
  9273. return globalSettings ? globalSettings.disableFontFace : false;
  9274. case 'disableCreateObjectURL':
  9275. return globalSettings ? globalSettings.disableCreateObjectURL : false;
  9276. case 'disableWebGL':
  9277. return globalSettings ? globalSettings.disableWebGL : true;
  9278. case 'cMapUrl':
  9279. return globalSettings ? globalSettings.cMapUrl : null;
  9280. case 'cMapPacked':
  9281. return globalSettings ? globalSettings.cMapPacked : false;
  9282. case 'postMessageTransfers':
  9283. return globalSettings ? globalSettings.postMessageTransfers : true;
  9284. case 'workerSrc':
  9285. return globalSettings ? globalSettings.workerSrc : null;
  9286. case 'disableWorker':
  9287. return globalSettings ? globalSettings.disableWorker : false;
  9288. case 'maxImageSize':
  9289. return globalSettings ? globalSettings.maxImageSize : -1;
  9290. case 'imageResourcesPath':
  9291. return globalSettings ? globalSettings.imageResourcesPath : '';
  9292. case 'isEvalSupported':
  9293. return globalSettings ? globalSettings.isEvalSupported : true;
  9294. case 'externalLinkTarget':
  9295. if (!globalSettings) {
  9296. return LinkTarget.NONE;
  9297. }
  9298. switch (globalSettings.externalLinkTarget) {
  9299. case LinkTarget.NONE:
  9300. case LinkTarget.SELF:
  9301. case LinkTarget.BLANK:
  9302. case LinkTarget.PARENT:
  9303. case LinkTarget.TOP:
  9304. return globalSettings.externalLinkTarget;
  9305. }
  9306. warn('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
  9307. globalSettings.externalLinkTarget = LinkTarget.NONE;
  9308. return LinkTarget.NONE;
  9309. case 'externalLinkRel':
  9310. return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL;
  9311. case 'enableStats':
  9312. return !!(globalSettings && globalSettings.enableStats);
  9313. default:
  9314. throw new Error('Unknown default setting: ' + id);
  9315. }
  9316. }
  9317. function isExternalLinkTargetSet() {
  9318. var externalLinkTarget = getDefaultSetting('externalLinkTarget');
  9319. switch (externalLinkTarget) {
  9320. case LinkTarget.NONE:
  9321. return false;
  9322. case LinkTarget.SELF:
  9323. case LinkTarget.BLANK:
  9324. case LinkTarget.PARENT:
  9325. case LinkTarget.TOP:
  9326. return true;
  9327. }
  9328. }
  9329. function isValidUrl(url, allowRelative) {
  9330. deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.');
  9331. var baseUrl = allowRelative ? 'http://example.com' : null;
  9332. return createValidAbsoluteUrl(url, baseUrl) !== null;
  9333. }
  9334. exports.CustomStyle = CustomStyle;
  9335. exports.addLinkAttributes = addLinkAttributes;
  9336. exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
  9337. exports.isValidUrl = isValidUrl;
  9338. exports.getFilenameFromUrl = getFilenameFromUrl;
  9339. exports.LinkTarget = LinkTarget;
  9340. exports.hasCanvasTypedArrays = hasCanvasTypedArrays;
  9341. exports.getDefaultSetting = getDefaultSetting;
  9342. exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
  9343. exports.DOMCanvasFactory = DOMCanvasFactory;
  9344. exports.DOMCMapReaderFactory = DOMCMapReaderFactory;
  9345. /***/ }),
  9346. /* 4 */
  9347. /***/ (function(module, exports, __w_pdfjs_require__) {
  9348. "use strict";
  9349. var sharedUtil = __w_pdfjs_require__(0);
  9350. var corePrimitives = __w_pdfjs_require__(1);
  9351. var coreFunction = __w_pdfjs_require__(7);
  9352. var error = sharedUtil.error;
  9353. var info = sharedUtil.info;
  9354. var isArray = sharedUtil.isArray;
  9355. var isString = sharedUtil.isString;
  9356. var shadow = sharedUtil.shadow;
  9357. var warn = sharedUtil.warn;
  9358. var isDict = corePrimitives.isDict;
  9359. var isName = corePrimitives.isName;
  9360. var isStream = corePrimitives.isStream;
  9361. var PDFFunction = coreFunction.PDFFunction;
  9362. var ColorSpace = function ColorSpaceClosure() {
  9363. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  9364. var COMPONENTS = 3;
  9365. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  9366. var xRatio = w1 / w2;
  9367. var yRatio = h1 / h2;
  9368. var i, j, py, newIndex = 0, oldIndex;
  9369. var xScaled = new Uint16Array(w2);
  9370. var w1Scanline = w1 * COMPONENTS;
  9371. for (i = 0; i < w2; i++) {
  9372. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  9373. }
  9374. for (i = 0; i < h2; i++) {
  9375. py = Math.floor(i * yRatio) * w1Scanline;
  9376. for (j = 0; j < w2; j++) {
  9377. oldIndex = py + xScaled[j];
  9378. dest[newIndex++] = src[oldIndex++];
  9379. dest[newIndex++] = src[oldIndex++];
  9380. dest[newIndex++] = src[oldIndex++];
  9381. newIndex += alpha01;
  9382. }
  9383. }
  9384. }
  9385. function ColorSpace() {
  9386. error('should not call ColorSpace constructor');
  9387. }
  9388. ColorSpace.prototype = {
  9389. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  9390. var rgb = new Uint8Array(3);
  9391. this.getRgbItem(src, srcOffset, rgb, 0);
  9392. return rgb;
  9393. },
  9394. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  9395. error('Should not call ColorSpace.getRgbItem');
  9396. },
  9397. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9398. error('Should not call ColorSpace.getRgbBuffer');
  9399. },
  9400. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  9401. error('Should not call ColorSpace.getOutputLength');
  9402. },
  9403. isPassthrough: function ColorSpace_isPassthrough(bits) {
  9404. return false;
  9405. },
  9406. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  9407. var count = originalWidth * originalHeight;
  9408. var rgbBuf = null;
  9409. var numComponentColors = 1 << bpc;
  9410. var needsResizing = originalHeight !== height || originalWidth !== width;
  9411. var i, ii;
  9412. if (this.isPassthrough(bpc)) {
  9413. rgbBuf = comps;
  9414. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  9415. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  9416. var key;
  9417. for (i = 0; i < numComponentColors; i++) {
  9418. allColors[i] = i;
  9419. }
  9420. var colorMap = new Uint8Array(numComponentColors * 3);
  9421. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  9422. var destPos, rgbPos;
  9423. if (!needsResizing) {
  9424. destPos = 0;
  9425. for (i = 0; i < count; ++i) {
  9426. key = comps[i] * 3;
  9427. dest[destPos++] = colorMap[key];
  9428. dest[destPos++] = colorMap[key + 1];
  9429. dest[destPos++] = colorMap[key + 2];
  9430. destPos += alpha01;
  9431. }
  9432. } else {
  9433. rgbBuf = new Uint8Array(count * 3);
  9434. rgbPos = 0;
  9435. for (i = 0; i < count; ++i) {
  9436. key = comps[i] * 3;
  9437. rgbBuf[rgbPos++] = colorMap[key];
  9438. rgbBuf[rgbPos++] = colorMap[key + 1];
  9439. rgbBuf[rgbPos++] = colorMap[key + 2];
  9440. }
  9441. }
  9442. } else {
  9443. if (!needsResizing) {
  9444. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  9445. } else {
  9446. rgbBuf = new Uint8Array(count * 3);
  9447. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  9448. }
  9449. }
  9450. if (rgbBuf) {
  9451. if (needsResizing) {
  9452. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  9453. } else {
  9454. rgbPos = 0;
  9455. destPos = 0;
  9456. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  9457. dest[destPos++] = rgbBuf[rgbPos++];
  9458. dest[destPos++] = rgbBuf[rgbPos++];
  9459. dest[destPos++] = rgbBuf[rgbPos++];
  9460. destPos += alpha01;
  9461. }
  9462. }
  9463. }
  9464. },
  9465. usesZeroToOneRange: true
  9466. };
  9467. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  9468. var IR = ColorSpace.parseToIR(cs, xref, res);
  9469. if (IR instanceof AlternateCS) {
  9470. return IR;
  9471. }
  9472. return ColorSpace.fromIR(IR);
  9473. };
  9474. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  9475. var name = isArray(IR) ? IR[0] : IR;
  9476. var whitePoint, blackPoint, gamma;
  9477. switch (name) {
  9478. case 'DeviceGrayCS':
  9479. return this.singletons.gray;
  9480. case 'DeviceRgbCS':
  9481. return this.singletons.rgb;
  9482. case 'DeviceCmykCS':
  9483. return this.singletons.cmyk;
  9484. case 'CalGrayCS':
  9485. whitePoint = IR[1];
  9486. blackPoint = IR[2];
  9487. gamma = IR[3];
  9488. return new CalGrayCS(whitePoint, blackPoint, gamma);
  9489. case 'CalRGBCS':
  9490. whitePoint = IR[1];
  9491. blackPoint = IR[2];
  9492. gamma = IR[3];
  9493. var matrix = IR[4];
  9494. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  9495. case 'PatternCS':
  9496. var basePatternCS = IR[1];
  9497. if (basePatternCS) {
  9498. basePatternCS = ColorSpace.fromIR(basePatternCS);
  9499. }
  9500. return new PatternCS(basePatternCS);
  9501. case 'IndexedCS':
  9502. var baseIndexedCS = IR[1];
  9503. var hiVal = IR[2];
  9504. var lookup = IR[3];
  9505. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  9506. case 'AlternateCS':
  9507. var numComps = IR[1];
  9508. var alt = IR[2];
  9509. var tintFnIR = IR[3];
  9510. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  9511. case 'LabCS':
  9512. whitePoint = IR[1];
  9513. blackPoint = IR[2];
  9514. var range = IR[3];
  9515. return new LabCS(whitePoint, blackPoint, range);
  9516. default:
  9517. error('Unknown name ' + name);
  9518. }
  9519. return null;
  9520. };
  9521. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  9522. if (isName(cs)) {
  9523. var colorSpaces = res.get('ColorSpace');
  9524. if (isDict(colorSpaces)) {
  9525. var refcs = colorSpaces.get(cs.name);
  9526. if (refcs) {
  9527. cs = refcs;
  9528. }
  9529. }
  9530. }
  9531. cs = xref.fetchIfRef(cs);
  9532. if (isName(cs)) {
  9533. switch (cs.name) {
  9534. case 'DeviceGray':
  9535. case 'G':
  9536. return 'DeviceGrayCS';
  9537. case 'DeviceRGB':
  9538. case 'RGB':
  9539. return 'DeviceRgbCS';
  9540. case 'DeviceCMYK':
  9541. case 'CMYK':
  9542. return 'DeviceCmykCS';
  9543. case 'Pattern':
  9544. return [
  9545. 'PatternCS',
  9546. null
  9547. ];
  9548. default:
  9549. error('unrecognized colorspace ' + cs.name);
  9550. }
  9551. } else if (isArray(cs)) {
  9552. var mode = xref.fetchIfRef(cs[0]).name;
  9553. var numComps, params, alt, whitePoint, blackPoint, gamma;
  9554. switch (mode) {
  9555. case 'DeviceGray':
  9556. case 'G':
  9557. return 'DeviceGrayCS';
  9558. case 'DeviceRGB':
  9559. case 'RGB':
  9560. return 'DeviceRgbCS';
  9561. case 'DeviceCMYK':
  9562. case 'CMYK':
  9563. return 'DeviceCmykCS';
  9564. case 'CalGray':
  9565. params = xref.fetchIfRef(cs[1]);
  9566. whitePoint = params.getArray('WhitePoint');
  9567. blackPoint = params.getArray('BlackPoint');
  9568. gamma = params.get('Gamma');
  9569. return [
  9570. 'CalGrayCS',
  9571. whitePoint,
  9572. blackPoint,
  9573. gamma
  9574. ];
  9575. case 'CalRGB':
  9576. params = xref.fetchIfRef(cs[1]);
  9577. whitePoint = params.getArray('WhitePoint');
  9578. blackPoint = params.getArray('BlackPoint');
  9579. gamma = params.getArray('Gamma');
  9580. var matrix = params.getArray('Matrix');
  9581. return [
  9582. 'CalRGBCS',
  9583. whitePoint,
  9584. blackPoint,
  9585. gamma,
  9586. matrix
  9587. ];
  9588. case 'ICCBased':
  9589. var stream = xref.fetchIfRef(cs[1]);
  9590. var dict = stream.dict;
  9591. numComps = dict.get('N');
  9592. alt = dict.get('Alternate');
  9593. if (alt) {
  9594. var altIR = ColorSpace.parseToIR(alt, xref, res);
  9595. var altCS = ColorSpace.fromIR(altIR);
  9596. if (altCS.numComps === numComps) {
  9597. return altIR;
  9598. }
  9599. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  9600. }
  9601. if (numComps === 1) {
  9602. return 'DeviceGrayCS';
  9603. } else if (numComps === 3) {
  9604. return 'DeviceRgbCS';
  9605. } else if (numComps === 4) {
  9606. return 'DeviceCmykCS';
  9607. }
  9608. break;
  9609. case 'Pattern':
  9610. var basePatternCS = cs[1] || null;
  9611. if (basePatternCS) {
  9612. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  9613. }
  9614. return [
  9615. 'PatternCS',
  9616. basePatternCS
  9617. ];
  9618. case 'Indexed':
  9619. case 'I':
  9620. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  9621. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  9622. var lookup = xref.fetchIfRef(cs[3]);
  9623. if (isStream(lookup)) {
  9624. lookup = lookup.getBytes();
  9625. }
  9626. return [
  9627. 'IndexedCS',
  9628. baseIndexedCS,
  9629. hiVal,
  9630. lookup
  9631. ];
  9632. case 'Separation':
  9633. case 'DeviceN':
  9634. var name = xref.fetchIfRef(cs[1]);
  9635. numComps = isArray(name) ? name.length : 1;
  9636. alt = ColorSpace.parseToIR(cs[2], xref, res);
  9637. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  9638. return [
  9639. 'AlternateCS',
  9640. numComps,
  9641. alt,
  9642. tintFnIR
  9643. ];
  9644. case 'Lab':
  9645. params = xref.fetchIfRef(cs[1]);
  9646. whitePoint = params.getArray('WhitePoint');
  9647. blackPoint = params.getArray('BlackPoint');
  9648. var range = params.getArray('Range');
  9649. return [
  9650. 'LabCS',
  9651. whitePoint,
  9652. blackPoint,
  9653. range
  9654. ];
  9655. default:
  9656. error('unimplemented color space object "' + mode + '"');
  9657. }
  9658. } else {
  9659. error('unrecognized color space object: "' + cs + '"');
  9660. }
  9661. return null;
  9662. };
  9663. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  9664. if (!isArray(decode)) {
  9665. return true;
  9666. }
  9667. if (n * 2 !== decode.length) {
  9668. warn('The decode map is not the correct length');
  9669. return true;
  9670. }
  9671. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  9672. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  9673. return false;
  9674. }
  9675. }
  9676. return true;
  9677. };
  9678. ColorSpace.singletons = {
  9679. get gray() {
  9680. return shadow(this, 'gray', new DeviceGrayCS());
  9681. },
  9682. get rgb() {
  9683. return shadow(this, 'rgb', new DeviceRgbCS());
  9684. },
  9685. get cmyk() {
  9686. return shadow(this, 'cmyk', new DeviceCmykCS());
  9687. }
  9688. };
  9689. return ColorSpace;
  9690. }();
  9691. var AlternateCS = function AlternateCSClosure() {
  9692. function AlternateCS(numComps, base, tintFn) {
  9693. this.name = 'Alternate';
  9694. this.numComps = numComps;
  9695. this.defaultColor = new Float32Array(numComps);
  9696. for (var i = 0; i < numComps; ++i) {
  9697. this.defaultColor[i] = 1;
  9698. }
  9699. this.base = base;
  9700. this.tintFn = tintFn;
  9701. this.tmpBuf = new Float32Array(base.numComps);
  9702. }
  9703. AlternateCS.prototype = {
  9704. getRgb: ColorSpace.prototype.getRgb,
  9705. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9706. var tmpBuf = this.tmpBuf;
  9707. this.tintFn(src, srcOffset, tmpBuf, 0);
  9708. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  9709. },
  9710. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9711. var tintFn = this.tintFn;
  9712. var base = this.base;
  9713. var scale = 1 / ((1 << bits) - 1);
  9714. var baseNumComps = base.numComps;
  9715. var usesZeroToOneRange = base.usesZeroToOneRange;
  9716. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  9717. var pos = isPassthrough ? destOffset : 0;
  9718. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  9719. var numComps = this.numComps;
  9720. var scaled = new Float32Array(numComps);
  9721. var tinted = new Float32Array(baseNumComps);
  9722. var i, j;
  9723. for (i = 0; i < count; i++) {
  9724. for (j = 0; j < numComps; j++) {
  9725. scaled[j] = src[srcOffset++] * scale;
  9726. }
  9727. tintFn(scaled, 0, tinted, 0);
  9728. if (usesZeroToOneRange) {
  9729. for (j = 0; j < baseNumComps; j++) {
  9730. baseBuf[pos++] = tinted[j] * 255;
  9731. }
  9732. } else {
  9733. base.getRgbItem(tinted, 0, baseBuf, pos);
  9734. pos += baseNumComps;
  9735. }
  9736. }
  9737. if (!isPassthrough) {
  9738. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  9739. }
  9740. },
  9741. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  9742. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  9743. },
  9744. isPassthrough: ColorSpace.prototype.isPassthrough,
  9745. fillRgb: ColorSpace.prototype.fillRgb,
  9746. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  9747. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9748. },
  9749. usesZeroToOneRange: true
  9750. };
  9751. return AlternateCS;
  9752. }();
  9753. var PatternCS = function PatternCSClosure() {
  9754. function PatternCS(baseCS) {
  9755. this.name = 'Pattern';
  9756. this.base = baseCS;
  9757. }
  9758. PatternCS.prototype = {};
  9759. return PatternCS;
  9760. }();
  9761. var IndexedCS = function IndexedCSClosure() {
  9762. function IndexedCS(base, highVal, lookup) {
  9763. this.name = 'Indexed';
  9764. this.numComps = 1;
  9765. this.defaultColor = new Uint8Array(this.numComps);
  9766. this.base = base;
  9767. this.highVal = highVal;
  9768. var baseNumComps = base.numComps;
  9769. var length = baseNumComps * highVal;
  9770. if (isStream(lookup)) {
  9771. this.lookup = new Uint8Array(length);
  9772. var bytes = lookup.getBytes(length);
  9773. this.lookup.set(bytes);
  9774. } else if (isString(lookup)) {
  9775. this.lookup = new Uint8Array(length);
  9776. for (var i = 0; i < length; ++i) {
  9777. this.lookup[i] = lookup.charCodeAt(i);
  9778. }
  9779. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  9780. this.lookup = lookup;
  9781. } else {
  9782. error('Unrecognized lookup table: ' + lookup);
  9783. }
  9784. }
  9785. IndexedCS.prototype = {
  9786. getRgb: ColorSpace.prototype.getRgb,
  9787. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9788. var numComps = this.base.numComps;
  9789. var start = src[srcOffset] * numComps;
  9790. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  9791. },
  9792. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9793. var base = this.base;
  9794. var numComps = base.numComps;
  9795. var outputDelta = base.getOutputLength(numComps, alpha01);
  9796. var lookup = this.lookup;
  9797. for (var i = 0; i < count; ++i) {
  9798. var lookupPos = src[srcOffset++] * numComps;
  9799. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  9800. destOffset += outputDelta;
  9801. }
  9802. },
  9803. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  9804. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  9805. },
  9806. isPassthrough: ColorSpace.prototype.isPassthrough,
  9807. fillRgb: ColorSpace.prototype.fillRgb,
  9808. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  9809. return true;
  9810. },
  9811. usesZeroToOneRange: true
  9812. };
  9813. return IndexedCS;
  9814. }();
  9815. var DeviceGrayCS = function DeviceGrayCSClosure() {
  9816. function DeviceGrayCS() {
  9817. this.name = 'DeviceGray';
  9818. this.numComps = 1;
  9819. this.defaultColor = new Float32Array(this.numComps);
  9820. }
  9821. DeviceGrayCS.prototype = {
  9822. getRgb: ColorSpace.prototype.getRgb,
  9823. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9824. var c = src[srcOffset] * 255 | 0;
  9825. c = c < 0 ? 0 : c > 255 ? 255 : c;
  9826. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  9827. },
  9828. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9829. var scale = 255 / ((1 << bits) - 1);
  9830. var j = srcOffset, q = destOffset;
  9831. for (var i = 0; i < count; ++i) {
  9832. var c = scale * src[j++] | 0;
  9833. dest[q++] = c;
  9834. dest[q++] = c;
  9835. dest[q++] = c;
  9836. q += alpha01;
  9837. }
  9838. },
  9839. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  9840. return inputLength * (3 + alpha01);
  9841. },
  9842. isPassthrough: ColorSpace.prototype.isPassthrough,
  9843. fillRgb: ColorSpace.prototype.fillRgb,
  9844. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  9845. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9846. },
  9847. usesZeroToOneRange: true
  9848. };
  9849. return DeviceGrayCS;
  9850. }();
  9851. var DeviceRgbCS = function DeviceRgbCSClosure() {
  9852. function DeviceRgbCS() {
  9853. this.name = 'DeviceRGB';
  9854. this.numComps = 3;
  9855. this.defaultColor = new Float32Array(this.numComps);
  9856. }
  9857. DeviceRgbCS.prototype = {
  9858. getRgb: ColorSpace.prototype.getRgb,
  9859. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9860. var r = src[srcOffset] * 255 | 0;
  9861. var g = src[srcOffset + 1] * 255 | 0;
  9862. var b = src[srcOffset + 2] * 255 | 0;
  9863. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  9864. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  9865. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  9866. },
  9867. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9868. if (bits === 8 && alpha01 === 0) {
  9869. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  9870. return;
  9871. }
  9872. var scale = 255 / ((1 << bits) - 1);
  9873. var j = srcOffset, q = destOffset;
  9874. for (var i = 0; i < count; ++i) {
  9875. dest[q++] = scale * src[j++] | 0;
  9876. dest[q++] = scale * src[j++] | 0;
  9877. dest[q++] = scale * src[j++] | 0;
  9878. q += alpha01;
  9879. }
  9880. },
  9881. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  9882. return inputLength * (3 + alpha01) / 3 | 0;
  9883. },
  9884. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  9885. return bits === 8;
  9886. },
  9887. fillRgb: ColorSpace.prototype.fillRgb,
  9888. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  9889. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9890. },
  9891. usesZeroToOneRange: true
  9892. };
  9893. return DeviceRgbCS;
  9894. }();
  9895. var DeviceCmykCS = function DeviceCmykCSClosure() {
  9896. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  9897. var c = src[srcOffset + 0] * srcScale;
  9898. var m = src[srcOffset + 1] * srcScale;
  9899. var y = src[srcOffset + 2] * srcScale;
  9900. var k = src[srcOffset + 3] * srcScale;
  9901. var r = 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) + 255 | 0;
  9902. var g = 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) + 255 | 0;
  9903. var b = 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) + 255 | 0;
  9904. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  9905. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  9906. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  9907. }
  9908. function DeviceCmykCS() {
  9909. this.name = 'DeviceCMYK';
  9910. this.numComps = 4;
  9911. this.defaultColor = new Float32Array(this.numComps);
  9912. this.defaultColor[3] = 1;
  9913. }
  9914. DeviceCmykCS.prototype = {
  9915. getRgb: ColorSpace.prototype.getRgb,
  9916. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9917. convertToRgb(src, srcOffset, 1, dest, destOffset);
  9918. },
  9919. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9920. var scale = 1 / ((1 << bits) - 1);
  9921. for (var i = 0; i < count; i++) {
  9922. convertToRgb(src, srcOffset, scale, dest, destOffset);
  9923. srcOffset += 4;
  9924. destOffset += 3 + alpha01;
  9925. }
  9926. },
  9927. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  9928. return inputLength / 4 * (3 + alpha01) | 0;
  9929. },
  9930. isPassthrough: ColorSpace.prototype.isPassthrough,
  9931. fillRgb: ColorSpace.prototype.fillRgb,
  9932. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  9933. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  9934. },
  9935. usesZeroToOneRange: true
  9936. };
  9937. return DeviceCmykCS;
  9938. }();
  9939. var CalGrayCS = function CalGrayCSClosure() {
  9940. function CalGrayCS(whitePoint, blackPoint, gamma) {
  9941. this.name = 'CalGray';
  9942. this.numComps = 1;
  9943. this.defaultColor = new Float32Array(this.numComps);
  9944. if (!whitePoint) {
  9945. error('WhitePoint missing - required for color space CalGray');
  9946. }
  9947. blackPoint = blackPoint || [
  9948. 0,
  9949. 0,
  9950. 0
  9951. ];
  9952. gamma = gamma || 1;
  9953. this.XW = whitePoint[0];
  9954. this.YW = whitePoint[1];
  9955. this.ZW = whitePoint[2];
  9956. this.XB = blackPoint[0];
  9957. this.YB = blackPoint[1];
  9958. this.ZB = blackPoint[2];
  9959. this.G = gamma;
  9960. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  9961. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  9962. }
  9963. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  9964. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  9965. this.XB = this.YB = this.ZB = 0;
  9966. }
  9967. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  9968. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  9969. }
  9970. if (this.G < 1) {
  9971. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  9972. this.G = 1;
  9973. }
  9974. }
  9975. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  9976. var A = src[srcOffset] * scale;
  9977. var AG = Math.pow(A, cs.G);
  9978. var L = cs.YW * AG;
  9979. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  9980. dest[destOffset] = val;
  9981. dest[destOffset + 1] = val;
  9982. dest[destOffset + 2] = val;
  9983. }
  9984. CalGrayCS.prototype = {
  9985. getRgb: ColorSpace.prototype.getRgb,
  9986. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  9987. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  9988. },
  9989. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  9990. var scale = 1 / ((1 << bits) - 1);
  9991. for (var i = 0; i < count; ++i) {
  9992. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  9993. srcOffset += 1;
  9994. destOffset += 3 + alpha01;
  9995. }
  9996. },
  9997. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  9998. return inputLength * (3 + alpha01);
  9999. },
  10000. isPassthrough: ColorSpace.prototype.isPassthrough,
  10001. fillRgb: ColorSpace.prototype.fillRgb,
  10002. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  10003. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  10004. },
  10005. usesZeroToOneRange: true
  10006. };
  10007. return CalGrayCS;
  10008. }();
  10009. var CalRGBCS = function CalRGBCSClosure() {
  10010. var BRADFORD_SCALE_MATRIX = new Float32Array([
  10011. 0.8951,
  10012. 0.2664,
  10013. -0.1614,
  10014. -0.7502,
  10015. 1.7135,
  10016. 0.0367,
  10017. 0.0389,
  10018. -0.0685,
  10019. 1.0296
  10020. ]);
  10021. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  10022. 0.9869929,
  10023. -0.1470543,
  10024. 0.1599627,
  10025. 0.4323053,
  10026. 0.5183603,
  10027. 0.0492912,
  10028. -0.0085287,
  10029. 0.0400428,
  10030. 0.9684867
  10031. ]);
  10032. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  10033. 3.2404542,
  10034. -1.5371385,
  10035. -0.4985314,
  10036. -0.9692660,
  10037. 1.8760108,
  10038. 0.0415560,
  10039. 0.0556434,
  10040. -0.2040259,
  10041. 1.0572252
  10042. ]);
  10043. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  10044. 1,
  10045. 1,
  10046. 1
  10047. ]);
  10048. var tempNormalizeMatrix = new Float32Array(3);
  10049. var tempConvertMatrix1 = new Float32Array(3);
  10050. var tempConvertMatrix2 = new Float32Array(3);
  10051. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  10052. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  10053. this.name = 'CalRGB';
  10054. this.numComps = 3;
  10055. this.defaultColor = new Float32Array(this.numComps);
  10056. if (!whitePoint) {
  10057. error('WhitePoint missing - required for color space CalRGB');
  10058. }
  10059. blackPoint = blackPoint || new Float32Array(3);
  10060. gamma = gamma || new Float32Array([
  10061. 1,
  10062. 1,
  10063. 1
  10064. ]);
  10065. matrix = matrix || new Float32Array([
  10066. 1,
  10067. 0,
  10068. 0,
  10069. 0,
  10070. 1,
  10071. 0,
  10072. 0,
  10073. 0,
  10074. 1
  10075. ]);
  10076. var XW = whitePoint[0];
  10077. var YW = whitePoint[1];
  10078. var ZW = whitePoint[2];
  10079. this.whitePoint = whitePoint;
  10080. var XB = blackPoint[0];
  10081. var YB = blackPoint[1];
  10082. var ZB = blackPoint[2];
  10083. this.blackPoint = blackPoint;
  10084. this.GR = gamma[0];
  10085. this.GG = gamma[1];
  10086. this.GB = gamma[2];
  10087. this.MXA = matrix[0];
  10088. this.MYA = matrix[1];
  10089. this.MZA = matrix[2];
  10090. this.MXB = matrix[3];
  10091. this.MYB = matrix[4];
  10092. this.MZB = matrix[5];
  10093. this.MXC = matrix[6];
  10094. this.MYC = matrix[7];
  10095. this.MZC = matrix[8];
  10096. if (XW < 0 || ZW < 0 || YW !== 1) {
  10097. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  10098. }
  10099. if (XB < 0 || YB < 0 || ZB < 0) {
  10100. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  10101. this.blackPoint = new Float32Array(3);
  10102. }
  10103. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  10104. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  10105. this.GR = this.GG = this.GB = 1;
  10106. }
  10107. if (this.MXA < 0 || this.MYA < 0 || this.MZA < 0 || this.MXB < 0 || this.MYB < 0 || this.MZB < 0 || this.MXC < 0 || this.MYC < 0 || this.MZC < 0) {
  10108. info('Invalid Matrix for ' + this.name + ' [' + this.MXA + ', ' + this.MYA + ', ' + this.MZA + this.MXB + ', ' + this.MYB + ', ' + this.MZB + this.MXC + ', ' + this.MYC + ', ' + this.MZC + '], falling back to default');
  10109. this.MXA = this.MYB = this.MZC = 1;
  10110. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  10111. }
  10112. }
  10113. function matrixProduct(a, b, result) {
  10114. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  10115. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  10116. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  10117. }
  10118. function convertToFlat(sourceWhitePoint, LMS, result) {
  10119. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  10120. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  10121. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  10122. }
  10123. function convertToD65(sourceWhitePoint, LMS, result) {
  10124. var D65X = 0.95047;
  10125. var D65Y = 1;
  10126. var D65Z = 1.08883;
  10127. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  10128. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  10129. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  10130. }
  10131. function sRGBTransferFunction(color) {
  10132. if (color <= 0.0031308) {
  10133. return adjustToRange(0, 1, 12.92 * color);
  10134. }
  10135. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  10136. }
  10137. function adjustToRange(min, max, value) {
  10138. return Math.max(min, Math.min(max, value));
  10139. }
  10140. function decodeL(L) {
  10141. if (L < 0) {
  10142. return -decodeL(-L);
  10143. }
  10144. if (L > 8.0) {
  10145. return Math.pow((L + 16) / 116, 3);
  10146. }
  10147. return L * DECODE_L_CONSTANT;
  10148. }
  10149. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  10150. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  10151. result[0] = XYZ_Flat[0];
  10152. result[1] = XYZ_Flat[1];
  10153. result[2] = XYZ_Flat[2];
  10154. return;
  10155. }
  10156. var zeroDecodeL = decodeL(0);
  10157. var X_DST = zeroDecodeL;
  10158. var X_SRC = decodeL(sourceBlackPoint[0]);
  10159. var Y_DST = zeroDecodeL;
  10160. var Y_SRC = decodeL(sourceBlackPoint[1]);
  10161. var Z_DST = zeroDecodeL;
  10162. var Z_SRC = decodeL(sourceBlackPoint[2]);
  10163. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  10164. var X_Offset = 1 - X_Scale;
  10165. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  10166. var Y_Offset = 1 - Y_Scale;
  10167. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  10168. var Z_Offset = 1 - Z_Scale;
  10169. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  10170. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  10171. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  10172. }
  10173. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  10174. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  10175. result[0] = XYZ_In[0];
  10176. result[1] = XYZ_In[1];
  10177. result[2] = XYZ_In[2];
  10178. return;
  10179. }
  10180. var LMS = result;
  10181. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  10182. var LMS_Flat = tempNormalizeMatrix;
  10183. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  10184. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  10185. }
  10186. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  10187. var LMS = result;
  10188. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  10189. var LMS_D65 = tempNormalizeMatrix;
  10190. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  10191. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  10192. }
  10193. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  10194. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  10195. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  10196. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  10197. var AGR = Math.pow(A, cs.GR);
  10198. var BGG = Math.pow(B, cs.GG);
  10199. var CGB = Math.pow(C, cs.GB);
  10200. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  10201. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  10202. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  10203. var XYZ = tempConvertMatrix1;
  10204. XYZ[0] = X;
  10205. XYZ[1] = Y;
  10206. XYZ[2] = Z;
  10207. var XYZ_Flat = tempConvertMatrix2;
  10208. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  10209. var XYZ_Black = tempConvertMatrix1;
  10210. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  10211. var XYZ_D65 = tempConvertMatrix2;
  10212. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  10213. var SRGB = tempConvertMatrix1;
  10214. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  10215. var sR = sRGBTransferFunction(SRGB[0]);
  10216. var sG = sRGBTransferFunction(SRGB[1]);
  10217. var sB = sRGBTransferFunction(SRGB[2]);
  10218. dest[destOffset] = Math.round(sR * 255);
  10219. dest[destOffset + 1] = Math.round(sG * 255);
  10220. dest[destOffset + 2] = Math.round(sB * 255);
  10221. }
  10222. CalRGBCS.prototype = {
  10223. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  10224. var rgb = new Uint8Array(3);
  10225. this.getRgbItem(src, srcOffset, rgb, 0);
  10226. return rgb;
  10227. },
  10228. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  10229. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  10230. },
  10231. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  10232. var scale = 1 / ((1 << bits) - 1);
  10233. for (var i = 0; i < count; ++i) {
  10234. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  10235. srcOffset += 3;
  10236. destOffset += 3 + alpha01;
  10237. }
  10238. },
  10239. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  10240. return inputLength * (3 + alpha01) / 3 | 0;
  10241. },
  10242. isPassthrough: ColorSpace.prototype.isPassthrough,
  10243. fillRgb: ColorSpace.prototype.fillRgb,
  10244. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  10245. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  10246. },
  10247. usesZeroToOneRange: true
  10248. };
  10249. return CalRGBCS;
  10250. }();
  10251. var LabCS = function LabCSClosure() {
  10252. function LabCS(whitePoint, blackPoint, range) {
  10253. this.name = 'Lab';
  10254. this.numComps = 3;
  10255. this.defaultColor = new Float32Array(this.numComps);
  10256. if (!whitePoint) {
  10257. error('WhitePoint missing - required for color space Lab');
  10258. }
  10259. blackPoint = blackPoint || [
  10260. 0,
  10261. 0,
  10262. 0
  10263. ];
  10264. range = range || [
  10265. -100,
  10266. 100,
  10267. -100,
  10268. 100
  10269. ];
  10270. this.XW = whitePoint[0];
  10271. this.YW = whitePoint[1];
  10272. this.ZW = whitePoint[2];
  10273. this.amin = range[0];
  10274. this.amax = range[1];
  10275. this.bmin = range[2];
  10276. this.bmax = range[3];
  10277. this.XB = blackPoint[0];
  10278. this.YB = blackPoint[1];
  10279. this.ZB = blackPoint[2];
  10280. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  10281. error('Invalid WhitePoint components, no fallback available');
  10282. }
  10283. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  10284. info('Invalid BlackPoint, falling back to default');
  10285. this.XB = this.YB = this.ZB = 0;
  10286. }
  10287. if (this.amin > this.amax || this.bmin > this.bmax) {
  10288. info('Invalid Range, falling back to defaults');
  10289. this.amin = -100;
  10290. this.amax = 100;
  10291. this.bmin = -100;
  10292. this.bmax = 100;
  10293. }
  10294. }
  10295. function fn_g(x) {
  10296. var result;
  10297. if (x >= 6 / 29) {
  10298. result = x * x * x;
  10299. } else {
  10300. result = 108 / 841 * (x - 4 / 29);
  10301. }
  10302. return result;
  10303. }
  10304. function decode(value, high1, low2, high2) {
  10305. return low2 + value * (high2 - low2) / high1;
  10306. }
  10307. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  10308. var Ls = src[srcOffset];
  10309. var as = src[srcOffset + 1];
  10310. var bs = src[srcOffset + 2];
  10311. if (maxVal !== false) {
  10312. Ls = decode(Ls, maxVal, 0, 100);
  10313. as = decode(as, maxVal, cs.amin, cs.amax);
  10314. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  10315. }
  10316. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  10317. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  10318. var M = (Ls + 16) / 116;
  10319. var L = M + as / 500;
  10320. var N = M - bs / 200;
  10321. var X = cs.XW * fn_g(L);
  10322. var Y = cs.YW * fn_g(M);
  10323. var Z = cs.ZW * fn_g(N);
  10324. var r, g, b;
  10325. if (cs.ZW < 1) {
  10326. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  10327. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  10328. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  10329. } else {
  10330. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  10331. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  10332. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  10333. }
  10334. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  10335. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  10336. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  10337. }
  10338. LabCS.prototype = {
  10339. getRgb: ColorSpace.prototype.getRgb,
  10340. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  10341. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  10342. },
  10343. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  10344. var maxVal = (1 << bits) - 1;
  10345. for (var i = 0; i < count; i++) {
  10346. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  10347. srcOffset += 3;
  10348. destOffset += 3 + alpha01;
  10349. }
  10350. },
  10351. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  10352. return inputLength * (3 + alpha01) / 3 | 0;
  10353. },
  10354. isPassthrough: ColorSpace.prototype.isPassthrough,
  10355. fillRgb: ColorSpace.prototype.fillRgb,
  10356. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  10357. return true;
  10358. },
  10359. usesZeroToOneRange: false
  10360. };
  10361. return LabCS;
  10362. }();
  10363. exports.ColorSpace = ColorSpace;
  10364. /***/ }),
  10365. /* 5 */
  10366. /***/ (function(module, exports, __w_pdfjs_require__) {
  10367. "use strict";
  10368. var ExpertEncoding = [
  10369. '',
  10370. '',
  10371. '',
  10372. '',
  10373. '',
  10374. '',
  10375. '',
  10376. '',
  10377. '',
  10378. '',
  10379. '',
  10380. '',
  10381. '',
  10382. '',
  10383. '',
  10384. '',
  10385. '',
  10386. '',
  10387. '',
  10388. '',
  10389. '',
  10390. '',
  10391. '',
  10392. '',
  10393. '',
  10394. '',
  10395. '',
  10396. '',
  10397. '',
  10398. '',
  10399. '',
  10400. '',
  10401. 'space',
  10402. 'exclamsmall',
  10403. 'Hungarumlautsmall',
  10404. '',
  10405. 'dollaroldstyle',
  10406. 'dollarsuperior',
  10407. 'ampersandsmall',
  10408. 'Acutesmall',
  10409. 'parenleftsuperior',
  10410. 'parenrightsuperior',
  10411. 'twodotenleader',
  10412. 'onedotenleader',
  10413. 'comma',
  10414. 'hyphen',
  10415. 'period',
  10416. 'fraction',
  10417. 'zerooldstyle',
  10418. 'oneoldstyle',
  10419. 'twooldstyle',
  10420. 'threeoldstyle',
  10421. 'fouroldstyle',
  10422. 'fiveoldstyle',
  10423. 'sixoldstyle',
  10424. 'sevenoldstyle',
  10425. 'eightoldstyle',
  10426. 'nineoldstyle',
  10427. 'colon',
  10428. 'semicolon',
  10429. 'commasuperior',
  10430. 'threequartersemdash',
  10431. 'periodsuperior',
  10432. 'questionsmall',
  10433. '',
  10434. 'asuperior',
  10435. 'bsuperior',
  10436. 'centsuperior',
  10437. 'dsuperior',
  10438. 'esuperior',
  10439. '',
  10440. '',
  10441. 'isuperior',
  10442. '',
  10443. '',
  10444. 'lsuperior',
  10445. 'msuperior',
  10446. 'nsuperior',
  10447. 'osuperior',
  10448. '',
  10449. '',
  10450. 'rsuperior',
  10451. 'ssuperior',
  10452. 'tsuperior',
  10453. '',
  10454. 'ff',
  10455. 'fi',
  10456. 'fl',
  10457. 'ffi',
  10458. 'ffl',
  10459. 'parenleftinferior',
  10460. '',
  10461. 'parenrightinferior',
  10462. 'Circumflexsmall',
  10463. 'hyphensuperior',
  10464. 'Gravesmall',
  10465. 'Asmall',
  10466. 'Bsmall',
  10467. 'Csmall',
  10468. 'Dsmall',
  10469. 'Esmall',
  10470. 'Fsmall',
  10471. 'Gsmall',
  10472. 'Hsmall',
  10473. 'Ismall',
  10474. 'Jsmall',
  10475. 'Ksmall',
  10476. 'Lsmall',
  10477. 'Msmall',
  10478. 'Nsmall',
  10479. 'Osmall',
  10480. 'Psmall',
  10481. 'Qsmall',
  10482. 'Rsmall',
  10483. 'Ssmall',
  10484. 'Tsmall',
  10485. 'Usmall',
  10486. 'Vsmall',
  10487. 'Wsmall',
  10488. 'Xsmall',
  10489. 'Ysmall',
  10490. 'Zsmall',
  10491. 'colonmonetary',
  10492. 'onefitted',
  10493. 'rupiah',
  10494. 'Tildesmall',
  10495. '',
  10496. '',
  10497. '',
  10498. '',
  10499. '',
  10500. '',
  10501. '',
  10502. '',
  10503. '',
  10504. '',
  10505. '',
  10506. '',
  10507. '',
  10508. '',
  10509. '',
  10510. '',
  10511. '',
  10512. '',
  10513. '',
  10514. '',
  10515. '',
  10516. '',
  10517. '',
  10518. '',
  10519. '',
  10520. '',
  10521. '',
  10522. '',
  10523. '',
  10524. '',
  10525. '',
  10526. '',
  10527. '',
  10528. '',
  10529. 'exclamdownsmall',
  10530. 'centoldstyle',
  10531. 'Lslashsmall',
  10532. '',
  10533. '',
  10534. 'Scaronsmall',
  10535. 'Zcaronsmall',
  10536. 'Dieresissmall',
  10537. 'Brevesmall',
  10538. 'Caronsmall',
  10539. '',
  10540. 'Dotaccentsmall',
  10541. '',
  10542. '',
  10543. 'Macronsmall',
  10544. '',
  10545. '',
  10546. 'figuredash',
  10547. 'hypheninferior',
  10548. '',
  10549. '',
  10550. 'Ogoneksmall',
  10551. 'Ringsmall',
  10552. 'Cedillasmall',
  10553. '',
  10554. '',
  10555. '',
  10556. 'onequarter',
  10557. 'onehalf',
  10558. 'threequarters',
  10559. 'questiondownsmall',
  10560. 'oneeighth',
  10561. 'threeeighths',
  10562. 'fiveeighths',
  10563. 'seveneighths',
  10564. 'onethird',
  10565. 'twothirds',
  10566. '',
  10567. '',
  10568. 'zerosuperior',
  10569. 'onesuperior',
  10570. 'twosuperior',
  10571. 'threesuperior',
  10572. 'foursuperior',
  10573. 'fivesuperior',
  10574. 'sixsuperior',
  10575. 'sevensuperior',
  10576. 'eightsuperior',
  10577. 'ninesuperior',
  10578. 'zeroinferior',
  10579. 'oneinferior',
  10580. 'twoinferior',
  10581. 'threeinferior',
  10582. 'fourinferior',
  10583. 'fiveinferior',
  10584. 'sixinferior',
  10585. 'seveninferior',
  10586. 'eightinferior',
  10587. 'nineinferior',
  10588. 'centinferior',
  10589. 'dollarinferior',
  10590. 'periodinferior',
  10591. 'commainferior',
  10592. 'Agravesmall',
  10593. 'Aacutesmall',
  10594. 'Acircumflexsmall',
  10595. 'Atildesmall',
  10596. 'Adieresissmall',
  10597. 'Aringsmall',
  10598. 'AEsmall',
  10599. 'Ccedillasmall',
  10600. 'Egravesmall',
  10601. 'Eacutesmall',
  10602. 'Ecircumflexsmall',
  10603. 'Edieresissmall',
  10604. 'Igravesmall',
  10605. 'Iacutesmall',
  10606. 'Icircumflexsmall',
  10607. 'Idieresissmall',
  10608. 'Ethsmall',
  10609. 'Ntildesmall',
  10610. 'Ogravesmall',
  10611. 'Oacutesmall',
  10612. 'Ocircumflexsmall',
  10613. 'Otildesmall',
  10614. 'Odieresissmall',
  10615. 'OEsmall',
  10616. 'Oslashsmall',
  10617. 'Ugravesmall',
  10618. 'Uacutesmall',
  10619. 'Ucircumflexsmall',
  10620. 'Udieresissmall',
  10621. 'Yacutesmall',
  10622. 'Thornsmall',
  10623. 'Ydieresissmall'
  10624. ];
  10625. var MacExpertEncoding = [
  10626. '',
  10627. '',
  10628. '',
  10629. '',
  10630. '',
  10631. '',
  10632. '',
  10633. '',
  10634. '',
  10635. '',
  10636. '',
  10637. '',
  10638. '',
  10639. '',
  10640. '',
  10641. '',
  10642. '',
  10643. '',
  10644. '',
  10645. '',
  10646. '',
  10647. '',
  10648. '',
  10649. '',
  10650. '',
  10651. '',
  10652. '',
  10653. '',
  10654. '',
  10655. '',
  10656. '',
  10657. '',
  10658. 'space',
  10659. 'exclamsmall',
  10660. 'Hungarumlautsmall',
  10661. 'centoldstyle',
  10662. 'dollaroldstyle',
  10663. 'dollarsuperior',
  10664. 'ampersandsmall',
  10665. 'Acutesmall',
  10666. 'parenleftsuperior',
  10667. 'parenrightsuperior',
  10668. 'twodotenleader',
  10669. 'onedotenleader',
  10670. 'comma',
  10671. 'hyphen',
  10672. 'period',
  10673. 'fraction',
  10674. 'zerooldstyle',
  10675. 'oneoldstyle',
  10676. 'twooldstyle',
  10677. 'threeoldstyle',
  10678. 'fouroldstyle',
  10679. 'fiveoldstyle',
  10680. 'sixoldstyle',
  10681. 'sevenoldstyle',
  10682. 'eightoldstyle',
  10683. 'nineoldstyle',
  10684. 'colon',
  10685. 'semicolon',
  10686. '',
  10687. 'threequartersemdash',
  10688. '',
  10689. 'questionsmall',
  10690. '',
  10691. '',
  10692. '',
  10693. '',
  10694. 'Ethsmall',
  10695. '',
  10696. '',
  10697. 'onequarter',
  10698. 'onehalf',
  10699. 'threequarters',
  10700. 'oneeighth',
  10701. 'threeeighths',
  10702. 'fiveeighths',
  10703. 'seveneighths',
  10704. 'onethird',
  10705. 'twothirds',
  10706. '',
  10707. '',
  10708. '',
  10709. '',
  10710. '',
  10711. '',
  10712. 'ff',
  10713. 'fi',
  10714. 'fl',
  10715. 'ffi',
  10716. 'ffl',
  10717. 'parenleftinferior',
  10718. '',
  10719. 'parenrightinferior',
  10720. 'Circumflexsmall',
  10721. 'hypheninferior',
  10722. 'Gravesmall',
  10723. 'Asmall',
  10724. 'Bsmall',
  10725. 'Csmall',
  10726. 'Dsmall',
  10727. 'Esmall',
  10728. 'Fsmall',
  10729. 'Gsmall',
  10730. 'Hsmall',
  10731. 'Ismall',
  10732. 'Jsmall',
  10733. 'Ksmall',
  10734. 'Lsmall',
  10735. 'Msmall',
  10736. 'Nsmall',
  10737. 'Osmall',
  10738. 'Psmall',
  10739. 'Qsmall',
  10740. 'Rsmall',
  10741. 'Ssmall',
  10742. 'Tsmall',
  10743. 'Usmall',
  10744. 'Vsmall',
  10745. 'Wsmall',
  10746. 'Xsmall',
  10747. 'Ysmall',
  10748. 'Zsmall',
  10749. 'colonmonetary',
  10750. 'onefitted',
  10751. 'rupiah',
  10752. 'Tildesmall',
  10753. '',
  10754. '',
  10755. 'asuperior',
  10756. 'centsuperior',
  10757. '',
  10758. '',
  10759. '',
  10760. '',
  10761. 'Aacutesmall',
  10762. 'Agravesmall',
  10763. 'Acircumflexsmall',
  10764. 'Adieresissmall',
  10765. 'Atildesmall',
  10766. 'Aringsmall',
  10767. 'Ccedillasmall',
  10768. 'Eacutesmall',
  10769. 'Egravesmall',
  10770. 'Ecircumflexsmall',
  10771. 'Edieresissmall',
  10772. 'Iacutesmall',
  10773. 'Igravesmall',
  10774. 'Icircumflexsmall',
  10775. 'Idieresissmall',
  10776. 'Ntildesmall',
  10777. 'Oacutesmall',
  10778. 'Ogravesmall',
  10779. 'Ocircumflexsmall',
  10780. 'Odieresissmall',
  10781. 'Otildesmall',
  10782. 'Uacutesmall',
  10783. 'Ugravesmall',
  10784. 'Ucircumflexsmall',
  10785. 'Udieresissmall',
  10786. '',
  10787. 'eightsuperior',
  10788. 'fourinferior',
  10789. 'threeinferior',
  10790. 'sixinferior',
  10791. 'eightinferior',
  10792. 'seveninferior',
  10793. 'Scaronsmall',
  10794. '',
  10795. 'centinferior',
  10796. 'twoinferior',
  10797. '',
  10798. 'Dieresissmall',
  10799. '',
  10800. 'Caronsmall',
  10801. 'osuperior',
  10802. 'fiveinferior',
  10803. '',
  10804. 'commainferior',
  10805. 'periodinferior',
  10806. 'Yacutesmall',
  10807. '',
  10808. 'dollarinferior',
  10809. '',
  10810. 'Thornsmall',
  10811. '',
  10812. 'nineinferior',
  10813. 'zeroinferior',
  10814. 'Zcaronsmall',
  10815. 'AEsmall',
  10816. 'Oslashsmall',
  10817. 'questiondownsmall',
  10818. 'oneinferior',
  10819. 'Lslashsmall',
  10820. '',
  10821. '',
  10822. '',
  10823. '',
  10824. '',
  10825. '',
  10826. 'Cedillasmall',
  10827. '',
  10828. '',
  10829. '',
  10830. '',
  10831. '',
  10832. 'OEsmall',
  10833. 'figuredash',
  10834. 'hyphensuperior',
  10835. '',
  10836. '',
  10837. '',
  10838. '',
  10839. 'exclamdownsmall',
  10840. '',
  10841. 'Ydieresissmall',
  10842. '',
  10843. 'onesuperior',
  10844. 'twosuperior',
  10845. 'threesuperior',
  10846. 'foursuperior',
  10847. 'fivesuperior',
  10848. 'sixsuperior',
  10849. 'sevensuperior',
  10850. 'ninesuperior',
  10851. 'zerosuperior',
  10852. '',
  10853. 'esuperior',
  10854. 'rsuperior',
  10855. 'tsuperior',
  10856. '',
  10857. '',
  10858. 'isuperior',
  10859. 'ssuperior',
  10860. 'dsuperior',
  10861. '',
  10862. '',
  10863. '',
  10864. '',
  10865. '',
  10866. 'lsuperior',
  10867. 'Ogoneksmall',
  10868. 'Brevesmall',
  10869. 'Macronsmall',
  10870. 'bsuperior',
  10871. 'nsuperior',
  10872. 'msuperior',
  10873. 'commasuperior',
  10874. 'periodsuperior',
  10875. 'Dotaccentsmall',
  10876. 'Ringsmall'
  10877. ];
  10878. var MacRomanEncoding = [
  10879. '',
  10880. '',
  10881. '',
  10882. '',
  10883. '',
  10884. '',
  10885. '',
  10886. '',
  10887. '',
  10888. '',
  10889. '',
  10890. '',
  10891. '',
  10892. '',
  10893. '',
  10894. '',
  10895. '',
  10896. '',
  10897. '',
  10898. '',
  10899. '',
  10900. '',
  10901. '',
  10902. '',
  10903. '',
  10904. '',
  10905. '',
  10906. '',
  10907. '',
  10908. '',
  10909. '',
  10910. '',
  10911. 'space',
  10912. 'exclam',
  10913. 'quotedbl',
  10914. 'numbersign',
  10915. 'dollar',
  10916. 'percent',
  10917. 'ampersand',
  10918. 'quotesingle',
  10919. 'parenleft',
  10920. 'parenright',
  10921. 'asterisk',
  10922. 'plus',
  10923. 'comma',
  10924. 'hyphen',
  10925. 'period',
  10926. 'slash',
  10927. 'zero',
  10928. 'one',
  10929. 'two',
  10930. 'three',
  10931. 'four',
  10932. 'five',
  10933. 'six',
  10934. 'seven',
  10935. 'eight',
  10936. 'nine',
  10937. 'colon',
  10938. 'semicolon',
  10939. 'less',
  10940. 'equal',
  10941. 'greater',
  10942. 'question',
  10943. 'at',
  10944. 'A',
  10945. 'B',
  10946. 'C',
  10947. 'D',
  10948. 'E',
  10949. 'F',
  10950. 'G',
  10951. 'H',
  10952. 'I',
  10953. 'J',
  10954. 'K',
  10955. 'L',
  10956. 'M',
  10957. 'N',
  10958. 'O',
  10959. 'P',
  10960. 'Q',
  10961. 'R',
  10962. 'S',
  10963. 'T',
  10964. 'U',
  10965. 'V',
  10966. 'W',
  10967. 'X',
  10968. 'Y',
  10969. 'Z',
  10970. 'bracketleft',
  10971. 'backslash',
  10972. 'bracketright',
  10973. 'asciicircum',
  10974. 'underscore',
  10975. 'grave',
  10976. 'a',
  10977. 'b',
  10978. 'c',
  10979. 'd',
  10980. 'e',
  10981. 'f',
  10982. 'g',
  10983. 'h',
  10984. 'i',
  10985. 'j',
  10986. 'k',
  10987. 'l',
  10988. 'm',
  10989. 'n',
  10990. 'o',
  10991. 'p',
  10992. 'q',
  10993. 'r',
  10994. 's',
  10995. 't',
  10996. 'u',
  10997. 'v',
  10998. 'w',
  10999. 'x',
  11000. 'y',
  11001. 'z',
  11002. 'braceleft',
  11003. 'bar',
  11004. 'braceright',
  11005. 'asciitilde',
  11006. '',
  11007. 'Adieresis',
  11008. 'Aring',
  11009. 'Ccedilla',
  11010. 'Eacute',
  11011. 'Ntilde',
  11012. 'Odieresis',
  11013. 'Udieresis',
  11014. 'aacute',
  11015. 'agrave',
  11016. 'acircumflex',
  11017. 'adieresis',
  11018. 'atilde',
  11019. 'aring',
  11020. 'ccedilla',
  11021. 'eacute',
  11022. 'egrave',
  11023. 'ecircumflex',
  11024. 'edieresis',
  11025. 'iacute',
  11026. 'igrave',
  11027. 'icircumflex',
  11028. 'idieresis',
  11029. 'ntilde',
  11030. 'oacute',
  11031. 'ograve',
  11032. 'ocircumflex',
  11033. 'odieresis',
  11034. 'otilde',
  11035. 'uacute',
  11036. 'ugrave',
  11037. 'ucircumflex',
  11038. 'udieresis',
  11039. 'dagger',
  11040. 'degree',
  11041. 'cent',
  11042. 'sterling',
  11043. 'section',
  11044. 'bullet',
  11045. 'paragraph',
  11046. 'germandbls',
  11047. 'registered',
  11048. 'copyright',
  11049. 'trademark',
  11050. 'acute',
  11051. 'dieresis',
  11052. 'notequal',
  11053. 'AE',
  11054. 'Oslash',
  11055. 'infinity',
  11056. 'plusminus',
  11057. 'lessequal',
  11058. 'greaterequal',
  11059. 'yen',
  11060. 'mu',
  11061. 'partialdiff',
  11062. 'summation',
  11063. 'product',
  11064. 'pi',
  11065. 'integral',
  11066. 'ordfeminine',
  11067. 'ordmasculine',
  11068. 'Omega',
  11069. 'ae',
  11070. 'oslash',
  11071. 'questiondown',
  11072. 'exclamdown',
  11073. 'logicalnot',
  11074. 'radical',
  11075. 'florin',
  11076. 'approxequal',
  11077. 'Delta',
  11078. 'guillemotleft',
  11079. 'guillemotright',
  11080. 'ellipsis',
  11081. 'space',
  11082. 'Agrave',
  11083. 'Atilde',
  11084. 'Otilde',
  11085. 'OE',
  11086. 'oe',
  11087. 'endash',
  11088. 'emdash',
  11089. 'quotedblleft',
  11090. 'quotedblright',
  11091. 'quoteleft',
  11092. 'quoteright',
  11093. 'divide',
  11094. 'lozenge',
  11095. 'ydieresis',
  11096. 'Ydieresis',
  11097. 'fraction',
  11098. 'currency',
  11099. 'guilsinglleft',
  11100. 'guilsinglright',
  11101. 'fi',
  11102. 'fl',
  11103. 'daggerdbl',
  11104. 'periodcentered',
  11105. 'quotesinglbase',
  11106. 'quotedblbase',
  11107. 'perthousand',
  11108. 'Acircumflex',
  11109. 'Ecircumflex',
  11110. 'Aacute',
  11111. 'Edieresis',
  11112. 'Egrave',
  11113. 'Iacute',
  11114. 'Icircumflex',
  11115. 'Idieresis',
  11116. 'Igrave',
  11117. 'Oacute',
  11118. 'Ocircumflex',
  11119. 'apple',
  11120. 'Ograve',
  11121. 'Uacute',
  11122. 'Ucircumflex',
  11123. 'Ugrave',
  11124. 'dotlessi',
  11125. 'circumflex',
  11126. 'tilde',
  11127. 'macron',
  11128. 'breve',
  11129. 'dotaccent',
  11130. 'ring',
  11131. 'cedilla',
  11132. 'hungarumlaut',
  11133. 'ogonek',
  11134. 'caron'
  11135. ];
  11136. var StandardEncoding = [
  11137. '',
  11138. '',
  11139. '',
  11140. '',
  11141. '',
  11142. '',
  11143. '',
  11144. '',
  11145. '',
  11146. '',
  11147. '',
  11148. '',
  11149. '',
  11150. '',
  11151. '',
  11152. '',
  11153. '',
  11154. '',
  11155. '',
  11156. '',
  11157. '',
  11158. '',
  11159. '',
  11160. '',
  11161. '',
  11162. '',
  11163. '',
  11164. '',
  11165. '',
  11166. '',
  11167. '',
  11168. '',
  11169. 'space',
  11170. 'exclam',
  11171. 'quotedbl',
  11172. 'numbersign',
  11173. 'dollar',
  11174. 'percent',
  11175. 'ampersand',
  11176. 'quoteright',
  11177. 'parenleft',
  11178. 'parenright',
  11179. 'asterisk',
  11180. 'plus',
  11181. 'comma',
  11182. 'hyphen',
  11183. 'period',
  11184. 'slash',
  11185. 'zero',
  11186. 'one',
  11187. 'two',
  11188. 'three',
  11189. 'four',
  11190. 'five',
  11191. 'six',
  11192. 'seven',
  11193. 'eight',
  11194. 'nine',
  11195. 'colon',
  11196. 'semicolon',
  11197. 'less',
  11198. 'equal',
  11199. 'greater',
  11200. 'question',
  11201. 'at',
  11202. 'A',
  11203. 'B',
  11204. 'C',
  11205. 'D',
  11206. 'E',
  11207. 'F',
  11208. 'G',
  11209. 'H',
  11210. 'I',
  11211. 'J',
  11212. 'K',
  11213. 'L',
  11214. 'M',
  11215. 'N',
  11216. 'O',
  11217. 'P',
  11218. 'Q',
  11219. 'R',
  11220. 'S',
  11221. 'T',
  11222. 'U',
  11223. 'V',
  11224. 'W',
  11225. 'X',
  11226. 'Y',
  11227. 'Z',
  11228. 'bracketleft',
  11229. 'backslash',
  11230. 'bracketright',
  11231. 'asciicircum',
  11232. 'underscore',
  11233. 'quoteleft',
  11234. 'a',
  11235. 'b',
  11236. 'c',
  11237. 'd',
  11238. 'e',
  11239. 'f',
  11240. 'g',
  11241. 'h',
  11242. 'i',
  11243. 'j',
  11244. 'k',
  11245. 'l',
  11246. 'm',
  11247. 'n',
  11248. 'o',
  11249. 'p',
  11250. 'q',
  11251. 'r',
  11252. 's',
  11253. 't',
  11254. 'u',
  11255. 'v',
  11256. 'w',
  11257. 'x',
  11258. 'y',
  11259. 'z',
  11260. 'braceleft',
  11261. 'bar',
  11262. 'braceright',
  11263. 'asciitilde',
  11264. '',
  11265. '',
  11266. '',
  11267. '',
  11268. '',
  11269. '',
  11270. '',
  11271. '',
  11272. '',
  11273. '',
  11274. '',
  11275. '',
  11276. '',
  11277. '',
  11278. '',
  11279. '',
  11280. '',
  11281. '',
  11282. '',
  11283. '',
  11284. '',
  11285. '',
  11286. '',
  11287. '',
  11288. '',
  11289. '',
  11290. '',
  11291. '',
  11292. '',
  11293. '',
  11294. '',
  11295. '',
  11296. '',
  11297. '',
  11298. 'exclamdown',
  11299. 'cent',
  11300. 'sterling',
  11301. 'fraction',
  11302. 'yen',
  11303. 'florin',
  11304. 'section',
  11305. 'currency',
  11306. 'quotesingle',
  11307. 'quotedblleft',
  11308. 'guillemotleft',
  11309. 'guilsinglleft',
  11310. 'guilsinglright',
  11311. 'fi',
  11312. 'fl',
  11313. '',
  11314. 'endash',
  11315. 'dagger',
  11316. 'daggerdbl',
  11317. 'periodcentered',
  11318. '',
  11319. 'paragraph',
  11320. 'bullet',
  11321. 'quotesinglbase',
  11322. 'quotedblbase',
  11323. 'quotedblright',
  11324. 'guillemotright',
  11325. 'ellipsis',
  11326. 'perthousand',
  11327. '',
  11328. 'questiondown',
  11329. '',
  11330. 'grave',
  11331. 'acute',
  11332. 'circumflex',
  11333. 'tilde',
  11334. 'macron',
  11335. 'breve',
  11336. 'dotaccent',
  11337. 'dieresis',
  11338. '',
  11339. 'ring',
  11340. 'cedilla',
  11341. '',
  11342. 'hungarumlaut',
  11343. 'ogonek',
  11344. 'caron',
  11345. 'emdash',
  11346. '',
  11347. '',
  11348. '',
  11349. '',
  11350. '',
  11351. '',
  11352. '',
  11353. '',
  11354. '',
  11355. '',
  11356. '',
  11357. '',
  11358. '',
  11359. '',
  11360. '',
  11361. '',
  11362. 'AE',
  11363. '',
  11364. 'ordfeminine',
  11365. '',
  11366. '',
  11367. '',
  11368. '',
  11369. 'Lslash',
  11370. 'Oslash',
  11371. 'OE',
  11372. 'ordmasculine',
  11373. '',
  11374. '',
  11375. '',
  11376. '',
  11377. '',
  11378. 'ae',
  11379. '',
  11380. '',
  11381. '',
  11382. 'dotlessi',
  11383. '',
  11384. '',
  11385. 'lslash',
  11386. 'oslash',
  11387. 'oe',
  11388. 'germandbls'
  11389. ];
  11390. var WinAnsiEncoding = [
  11391. '',
  11392. '',
  11393. '',
  11394. '',
  11395. '',
  11396. '',
  11397. '',
  11398. '',
  11399. '',
  11400. '',
  11401. '',
  11402. '',
  11403. '',
  11404. '',
  11405. '',
  11406. '',
  11407. '',
  11408. '',
  11409. '',
  11410. '',
  11411. '',
  11412. '',
  11413. '',
  11414. '',
  11415. '',
  11416. '',
  11417. '',
  11418. '',
  11419. '',
  11420. '',
  11421. '',
  11422. '',
  11423. 'space',
  11424. 'exclam',
  11425. 'quotedbl',
  11426. 'numbersign',
  11427. 'dollar',
  11428. 'percent',
  11429. 'ampersand',
  11430. 'quotesingle',
  11431. 'parenleft',
  11432. 'parenright',
  11433. 'asterisk',
  11434. 'plus',
  11435. 'comma',
  11436. 'hyphen',
  11437. 'period',
  11438. 'slash',
  11439. 'zero',
  11440. 'one',
  11441. 'two',
  11442. 'three',
  11443. 'four',
  11444. 'five',
  11445. 'six',
  11446. 'seven',
  11447. 'eight',
  11448. 'nine',
  11449. 'colon',
  11450. 'semicolon',
  11451. 'less',
  11452. 'equal',
  11453. 'greater',
  11454. 'question',
  11455. 'at',
  11456. 'A',
  11457. 'B',
  11458. 'C',
  11459. 'D',
  11460. 'E',
  11461. 'F',
  11462. 'G',
  11463. 'H',
  11464. 'I',
  11465. 'J',
  11466. 'K',
  11467. 'L',
  11468. 'M',
  11469. 'N',
  11470. 'O',
  11471. 'P',
  11472. 'Q',
  11473. 'R',
  11474. 'S',
  11475. 'T',
  11476. 'U',
  11477. 'V',
  11478. 'W',
  11479. 'X',
  11480. 'Y',
  11481. 'Z',
  11482. 'bracketleft',
  11483. 'backslash',
  11484. 'bracketright',
  11485. 'asciicircum',
  11486. 'underscore',
  11487. 'grave',
  11488. 'a',
  11489. 'b',
  11490. 'c',
  11491. 'd',
  11492. 'e',
  11493. 'f',
  11494. 'g',
  11495. 'h',
  11496. 'i',
  11497. 'j',
  11498. 'k',
  11499. 'l',
  11500. 'm',
  11501. 'n',
  11502. 'o',
  11503. 'p',
  11504. 'q',
  11505. 'r',
  11506. 's',
  11507. 't',
  11508. 'u',
  11509. 'v',
  11510. 'w',
  11511. 'x',
  11512. 'y',
  11513. 'z',
  11514. 'braceleft',
  11515. 'bar',
  11516. 'braceright',
  11517. 'asciitilde',
  11518. 'bullet',
  11519. 'Euro',
  11520. 'bullet',
  11521. 'quotesinglbase',
  11522. 'florin',
  11523. 'quotedblbase',
  11524. 'ellipsis',
  11525. 'dagger',
  11526. 'daggerdbl',
  11527. 'circumflex',
  11528. 'perthousand',
  11529. 'Scaron',
  11530. 'guilsinglleft',
  11531. 'OE',
  11532. 'bullet',
  11533. 'Zcaron',
  11534. 'bullet',
  11535. 'bullet',
  11536. 'quoteleft',
  11537. 'quoteright',
  11538. 'quotedblleft',
  11539. 'quotedblright',
  11540. 'bullet',
  11541. 'endash',
  11542. 'emdash',
  11543. 'tilde',
  11544. 'trademark',
  11545. 'scaron',
  11546. 'guilsinglright',
  11547. 'oe',
  11548. 'bullet',
  11549. 'zcaron',
  11550. 'Ydieresis',
  11551. 'space',
  11552. 'exclamdown',
  11553. 'cent',
  11554. 'sterling',
  11555. 'currency',
  11556. 'yen',
  11557. 'brokenbar',
  11558. 'section',
  11559. 'dieresis',
  11560. 'copyright',
  11561. 'ordfeminine',
  11562. 'guillemotleft',
  11563. 'logicalnot',
  11564. 'hyphen',
  11565. 'registered',
  11566. 'macron',
  11567. 'degree',
  11568. 'plusminus',
  11569. 'twosuperior',
  11570. 'threesuperior',
  11571. 'acute',
  11572. 'mu',
  11573. 'paragraph',
  11574. 'periodcentered',
  11575. 'cedilla',
  11576. 'onesuperior',
  11577. 'ordmasculine',
  11578. 'guillemotright',
  11579. 'onequarter',
  11580. 'onehalf',
  11581. 'threequarters',
  11582. 'questiondown',
  11583. 'Agrave',
  11584. 'Aacute',
  11585. 'Acircumflex',
  11586. 'Atilde',
  11587. 'Adieresis',
  11588. 'Aring',
  11589. 'AE',
  11590. 'Ccedilla',
  11591. 'Egrave',
  11592. 'Eacute',
  11593. 'Ecircumflex',
  11594. 'Edieresis',
  11595. 'Igrave',
  11596. 'Iacute',
  11597. 'Icircumflex',
  11598. 'Idieresis',
  11599. 'Eth',
  11600. 'Ntilde',
  11601. 'Ograve',
  11602. 'Oacute',
  11603. 'Ocircumflex',
  11604. 'Otilde',
  11605. 'Odieresis',
  11606. 'multiply',
  11607. 'Oslash',
  11608. 'Ugrave',
  11609. 'Uacute',
  11610. 'Ucircumflex',
  11611. 'Udieresis',
  11612. 'Yacute',
  11613. 'Thorn',
  11614. 'germandbls',
  11615. 'agrave',
  11616. 'aacute',
  11617. 'acircumflex',
  11618. 'atilde',
  11619. 'adieresis',
  11620. 'aring',
  11621. 'ae',
  11622. 'ccedilla',
  11623. 'egrave',
  11624. 'eacute',
  11625. 'ecircumflex',
  11626. 'edieresis',
  11627. 'igrave',
  11628. 'iacute',
  11629. 'icircumflex',
  11630. 'idieresis',
  11631. 'eth',
  11632. 'ntilde',
  11633. 'ograve',
  11634. 'oacute',
  11635. 'ocircumflex',
  11636. 'otilde',
  11637. 'odieresis',
  11638. 'divide',
  11639. 'oslash',
  11640. 'ugrave',
  11641. 'uacute',
  11642. 'ucircumflex',
  11643. 'udieresis',
  11644. 'yacute',
  11645. 'thorn',
  11646. 'ydieresis'
  11647. ];
  11648. var SymbolSetEncoding = [
  11649. '',
  11650. '',
  11651. '',
  11652. '',
  11653. '',
  11654. '',
  11655. '',
  11656. '',
  11657. '',
  11658. '',
  11659. '',
  11660. '',
  11661. '',
  11662. '',
  11663. '',
  11664. '',
  11665. '',
  11666. '',
  11667. '',
  11668. '',
  11669. '',
  11670. '',
  11671. '',
  11672. '',
  11673. '',
  11674. '',
  11675. '',
  11676. '',
  11677. '',
  11678. '',
  11679. '',
  11680. '',
  11681. 'space',
  11682. 'exclam',
  11683. 'universal',
  11684. 'numbersign',
  11685. 'existential',
  11686. 'percent',
  11687. 'ampersand',
  11688. 'suchthat',
  11689. 'parenleft',
  11690. 'parenright',
  11691. 'asteriskmath',
  11692. 'plus',
  11693. 'comma',
  11694. 'minus',
  11695. 'period',
  11696. 'slash',
  11697. 'zero',
  11698. 'one',
  11699. 'two',
  11700. 'three',
  11701. 'four',
  11702. 'five',
  11703. 'six',
  11704. 'seven',
  11705. 'eight',
  11706. 'nine',
  11707. 'colon',
  11708. 'semicolon',
  11709. 'less',
  11710. 'equal',
  11711. 'greater',
  11712. 'question',
  11713. 'congruent',
  11714. 'Alpha',
  11715. 'Beta',
  11716. 'Chi',
  11717. 'Delta',
  11718. 'Epsilon',
  11719. 'Phi',
  11720. 'Gamma',
  11721. 'Eta',
  11722. 'Iota',
  11723. 'theta1',
  11724. 'Kappa',
  11725. 'Lambda',
  11726. 'Mu',
  11727. 'Nu',
  11728. 'Omicron',
  11729. 'Pi',
  11730. 'Theta',
  11731. 'Rho',
  11732. 'Sigma',
  11733. 'Tau',
  11734. 'Upsilon',
  11735. 'sigma1',
  11736. 'Omega',
  11737. 'Xi',
  11738. 'Psi',
  11739. 'Zeta',
  11740. 'bracketleft',
  11741. 'therefore',
  11742. 'bracketright',
  11743. 'perpendicular',
  11744. 'underscore',
  11745. 'radicalex',
  11746. 'alpha',
  11747. 'beta',
  11748. 'chi',
  11749. 'delta',
  11750. 'epsilon',
  11751. 'phi',
  11752. 'gamma',
  11753. 'eta',
  11754. 'iota',
  11755. 'phi1',
  11756. 'kappa',
  11757. 'lambda',
  11758. 'mu',
  11759. 'nu',
  11760. 'omicron',
  11761. 'pi',
  11762. 'theta',
  11763. 'rho',
  11764. 'sigma',
  11765. 'tau',
  11766. 'upsilon',
  11767. 'omega1',
  11768. 'omega',
  11769. 'xi',
  11770. 'psi',
  11771. 'zeta',
  11772. 'braceleft',
  11773. 'bar',
  11774. 'braceright',
  11775. 'similar',
  11776. '',
  11777. '',
  11778. '',
  11779. '',
  11780. '',
  11781. '',
  11782. '',
  11783. '',
  11784. '',
  11785. '',
  11786. '',
  11787. '',
  11788. '',
  11789. '',
  11790. '',
  11791. '',
  11792. '',
  11793. '',
  11794. '',
  11795. '',
  11796. '',
  11797. '',
  11798. '',
  11799. '',
  11800. '',
  11801. '',
  11802. '',
  11803. '',
  11804. '',
  11805. '',
  11806. '',
  11807. '',
  11808. '',
  11809. 'Euro',
  11810. 'Upsilon1',
  11811. 'minute',
  11812. 'lessequal',
  11813. 'fraction',
  11814. 'infinity',
  11815. 'florin',
  11816. 'club',
  11817. 'diamond',
  11818. 'heart',
  11819. 'spade',
  11820. 'arrowboth',
  11821. 'arrowleft',
  11822. 'arrowup',
  11823. 'arrowright',
  11824. 'arrowdown',
  11825. 'degree',
  11826. 'plusminus',
  11827. 'second',
  11828. 'greaterequal',
  11829. 'multiply',
  11830. 'proportional',
  11831. 'partialdiff',
  11832. 'bullet',
  11833. 'divide',
  11834. 'notequal',
  11835. 'equivalence',
  11836. 'approxequal',
  11837. 'ellipsis',
  11838. 'arrowvertex',
  11839. 'arrowhorizex',
  11840. 'carriagereturn',
  11841. 'aleph',
  11842. 'Ifraktur',
  11843. 'Rfraktur',
  11844. 'weierstrass',
  11845. 'circlemultiply',
  11846. 'circleplus',
  11847. 'emptyset',
  11848. 'intersection',
  11849. 'union',
  11850. 'propersuperset',
  11851. 'reflexsuperset',
  11852. 'notsubset',
  11853. 'propersubset',
  11854. 'reflexsubset',
  11855. 'element',
  11856. 'notelement',
  11857. 'angle',
  11858. 'gradient',
  11859. 'registerserif',
  11860. 'copyrightserif',
  11861. 'trademarkserif',
  11862. 'product',
  11863. 'radical',
  11864. 'dotmath',
  11865. 'logicalnot',
  11866. 'logicaland',
  11867. 'logicalor',
  11868. 'arrowdblboth',
  11869. 'arrowdblleft',
  11870. 'arrowdblup',
  11871. 'arrowdblright',
  11872. 'arrowdbldown',
  11873. 'lozenge',
  11874. 'angleleft',
  11875. 'registersans',
  11876. 'copyrightsans',
  11877. 'trademarksans',
  11878. 'summation',
  11879. 'parenlefttp',
  11880. 'parenleftex',
  11881. 'parenleftbt',
  11882. 'bracketlefttp',
  11883. 'bracketleftex',
  11884. 'bracketleftbt',
  11885. 'bracelefttp',
  11886. 'braceleftmid',
  11887. 'braceleftbt',
  11888. 'braceex',
  11889. '',
  11890. 'angleright',
  11891. 'integral',
  11892. 'integraltp',
  11893. 'integralex',
  11894. 'integralbt',
  11895. 'parenrighttp',
  11896. 'parenrightex',
  11897. 'parenrightbt',
  11898. 'bracketrighttp',
  11899. 'bracketrightex',
  11900. 'bracketrightbt',
  11901. 'bracerighttp',
  11902. 'bracerightmid',
  11903. 'bracerightbt'
  11904. ];
  11905. var ZapfDingbatsEncoding = [
  11906. '',
  11907. '',
  11908. '',
  11909. '',
  11910. '',
  11911. '',
  11912. '',
  11913. '',
  11914. '',
  11915. '',
  11916. '',
  11917. '',
  11918. '',
  11919. '',
  11920. '',
  11921. '',
  11922. '',
  11923. '',
  11924. '',
  11925. '',
  11926. '',
  11927. '',
  11928. '',
  11929. '',
  11930. '',
  11931. '',
  11932. '',
  11933. '',
  11934. '',
  11935. '',
  11936. '',
  11937. '',
  11938. 'space',
  11939. 'a1',
  11940. 'a2',
  11941. 'a202',
  11942. 'a3',
  11943. 'a4',
  11944. 'a5',
  11945. 'a119',
  11946. 'a118',
  11947. 'a117',
  11948. 'a11',
  11949. 'a12',
  11950. 'a13',
  11951. 'a14',
  11952. 'a15',
  11953. 'a16',
  11954. 'a105',
  11955. 'a17',
  11956. 'a18',
  11957. 'a19',
  11958. 'a20',
  11959. 'a21',
  11960. 'a22',
  11961. 'a23',
  11962. 'a24',
  11963. 'a25',
  11964. 'a26',
  11965. 'a27',
  11966. 'a28',
  11967. 'a6',
  11968. 'a7',
  11969. 'a8',
  11970. 'a9',
  11971. 'a10',
  11972. 'a29',
  11973. 'a30',
  11974. 'a31',
  11975. 'a32',
  11976. 'a33',
  11977. 'a34',
  11978. 'a35',
  11979. 'a36',
  11980. 'a37',
  11981. 'a38',
  11982. 'a39',
  11983. 'a40',
  11984. 'a41',
  11985. 'a42',
  11986. 'a43',
  11987. 'a44',
  11988. 'a45',
  11989. 'a46',
  11990. 'a47',
  11991. 'a48',
  11992. 'a49',
  11993. 'a50',
  11994. 'a51',
  11995. 'a52',
  11996. 'a53',
  11997. 'a54',
  11998. 'a55',
  11999. 'a56',
  12000. 'a57',
  12001. 'a58',
  12002. 'a59',
  12003. 'a60',
  12004. 'a61',
  12005. 'a62',
  12006. 'a63',
  12007. 'a64',
  12008. 'a65',
  12009. 'a66',
  12010. 'a67',
  12011. 'a68',
  12012. 'a69',
  12013. 'a70',
  12014. 'a71',
  12015. 'a72',
  12016. 'a73',
  12017. 'a74',
  12018. 'a203',
  12019. 'a75',
  12020. 'a204',
  12021. 'a76',
  12022. 'a77',
  12023. 'a78',
  12024. 'a79',
  12025. 'a81',
  12026. 'a82',
  12027. 'a83',
  12028. 'a84',
  12029. 'a97',
  12030. 'a98',
  12031. 'a99',
  12032. 'a100',
  12033. '',
  12034. 'a89',
  12035. 'a90',
  12036. 'a93',
  12037. 'a94',
  12038. 'a91',
  12039. 'a92',
  12040. 'a205',
  12041. 'a85',
  12042. 'a206',
  12043. 'a86',
  12044. 'a87',
  12045. 'a88',
  12046. 'a95',
  12047. 'a96',
  12048. '',
  12049. '',
  12050. '',
  12051. '',
  12052. '',
  12053. '',
  12054. '',
  12055. '',
  12056. '',
  12057. '',
  12058. '',
  12059. '',
  12060. '',
  12061. '',
  12062. '',
  12063. '',
  12064. '',
  12065. '',
  12066. '',
  12067. 'a101',
  12068. 'a102',
  12069. 'a103',
  12070. 'a104',
  12071. 'a106',
  12072. 'a107',
  12073. 'a108',
  12074. 'a112',
  12075. 'a111',
  12076. 'a110',
  12077. 'a109',
  12078. 'a120',
  12079. 'a121',
  12080. 'a122',
  12081. 'a123',
  12082. 'a124',
  12083. 'a125',
  12084. 'a126',
  12085. 'a127',
  12086. 'a128',
  12087. 'a129',
  12088. 'a130',
  12089. 'a131',
  12090. 'a132',
  12091. 'a133',
  12092. 'a134',
  12093. 'a135',
  12094. 'a136',
  12095. 'a137',
  12096. 'a138',
  12097. 'a139',
  12098. 'a140',
  12099. 'a141',
  12100. 'a142',
  12101. 'a143',
  12102. 'a144',
  12103. 'a145',
  12104. 'a146',
  12105. 'a147',
  12106. 'a148',
  12107. 'a149',
  12108. 'a150',
  12109. 'a151',
  12110. 'a152',
  12111. 'a153',
  12112. 'a154',
  12113. 'a155',
  12114. 'a156',
  12115. 'a157',
  12116. 'a158',
  12117. 'a159',
  12118. 'a160',
  12119. 'a161',
  12120. 'a163',
  12121. 'a164',
  12122. 'a196',
  12123. 'a165',
  12124. 'a192',
  12125. 'a166',
  12126. 'a167',
  12127. 'a168',
  12128. 'a169',
  12129. 'a170',
  12130. 'a171',
  12131. 'a172',
  12132. 'a173',
  12133. 'a162',
  12134. 'a174',
  12135. 'a175',
  12136. 'a176',
  12137. 'a177',
  12138. 'a178',
  12139. 'a179',
  12140. 'a193',
  12141. 'a180',
  12142. 'a199',
  12143. 'a181',
  12144. 'a200',
  12145. 'a182',
  12146. '',
  12147. 'a201',
  12148. 'a183',
  12149. 'a184',
  12150. 'a197',
  12151. 'a185',
  12152. 'a194',
  12153. 'a198',
  12154. 'a186',
  12155. 'a195',
  12156. 'a187',
  12157. 'a188',
  12158. 'a189',
  12159. 'a190',
  12160. 'a191'
  12161. ];
  12162. function getEncoding(encodingName) {
  12163. switch (encodingName) {
  12164. case 'WinAnsiEncoding':
  12165. return WinAnsiEncoding;
  12166. case 'StandardEncoding':
  12167. return StandardEncoding;
  12168. case 'MacRomanEncoding':
  12169. return MacRomanEncoding;
  12170. case 'SymbolSetEncoding':
  12171. return SymbolSetEncoding;
  12172. case 'ZapfDingbatsEncoding':
  12173. return ZapfDingbatsEncoding;
  12174. case 'ExpertEncoding':
  12175. return ExpertEncoding;
  12176. case 'MacExpertEncoding':
  12177. return MacExpertEncoding;
  12178. default:
  12179. return null;
  12180. }
  12181. }
  12182. exports.WinAnsiEncoding = WinAnsiEncoding;
  12183. exports.StandardEncoding = StandardEncoding;
  12184. exports.MacRomanEncoding = MacRomanEncoding;
  12185. exports.SymbolSetEncoding = SymbolSetEncoding;
  12186. exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
  12187. exports.ExpertEncoding = ExpertEncoding;
  12188. exports.getEncoding = getEncoding;
  12189. /***/ }),
  12190. /* 6 */
  12191. /***/ (function(module, exports, __w_pdfjs_require__) {
  12192. "use strict";
  12193. var sharedUtil = __w_pdfjs_require__(0);
  12194. var corePrimitives = __w_pdfjs_require__(1);
  12195. var coreStream = __w_pdfjs_require__(2);
  12196. var MissingDataException = sharedUtil.MissingDataException;
  12197. var StreamType = sharedUtil.StreamType;
  12198. var assert = sharedUtil.assert;
  12199. var error = sharedUtil.error;
  12200. var info = sharedUtil.info;
  12201. var isArray = sharedUtil.isArray;
  12202. var isInt = sharedUtil.isInt;
  12203. var isNum = sharedUtil.isNum;
  12204. var isString = sharedUtil.isString;
  12205. var warn = sharedUtil.warn;
  12206. var EOF = corePrimitives.EOF;
  12207. var Cmd = corePrimitives.Cmd;
  12208. var Dict = corePrimitives.Dict;
  12209. var Name = corePrimitives.Name;
  12210. var Ref = corePrimitives.Ref;
  12211. var isEOF = corePrimitives.isEOF;
  12212. var isCmd = corePrimitives.isCmd;
  12213. var isDict = corePrimitives.isDict;
  12214. var isName = corePrimitives.isName;
  12215. var Ascii85Stream = coreStream.Ascii85Stream;
  12216. var AsciiHexStream = coreStream.AsciiHexStream;
  12217. var CCITTFaxStream = coreStream.CCITTFaxStream;
  12218. var FlateStream = coreStream.FlateStream;
  12219. var Jbig2Stream = coreStream.Jbig2Stream;
  12220. var JpegStream = coreStream.JpegStream;
  12221. var JpxStream = coreStream.JpxStream;
  12222. var LZWStream = coreStream.LZWStream;
  12223. var NullStream = coreStream.NullStream;
  12224. var PredictorStream = coreStream.PredictorStream;
  12225. var RunLengthStream = coreStream.RunLengthStream;
  12226. var MAX_LENGTH_TO_CACHE = 1000;
  12227. var Parser = function ParserClosure() {
  12228. function Parser(lexer, allowStreams, xref, recoveryMode) {
  12229. this.lexer = lexer;
  12230. this.allowStreams = allowStreams;
  12231. this.xref = xref;
  12232. this.recoveryMode = recoveryMode || false;
  12233. this.imageCache = Object.create(null);
  12234. this.refill();
  12235. }
  12236. Parser.prototype = {
  12237. refill: function Parser_refill() {
  12238. this.buf1 = this.lexer.getObj();
  12239. this.buf2 = this.lexer.getObj();
  12240. },
  12241. shift: function Parser_shift() {
  12242. if (isCmd(this.buf2, 'ID')) {
  12243. this.buf1 = this.buf2;
  12244. this.buf2 = null;
  12245. } else {
  12246. this.buf1 = this.buf2;
  12247. this.buf2 = this.lexer.getObj();
  12248. }
  12249. },
  12250. tryShift: function Parser_tryShift() {
  12251. try {
  12252. this.shift();
  12253. return true;
  12254. } catch (e) {
  12255. if (e instanceof MissingDataException) {
  12256. throw e;
  12257. }
  12258. return false;
  12259. }
  12260. },
  12261. getObj: function Parser_getObj(cipherTransform) {
  12262. var buf1 = this.buf1;
  12263. this.shift();
  12264. if (buf1 instanceof Cmd) {
  12265. switch (buf1.cmd) {
  12266. case 'BI':
  12267. return this.makeInlineImage(cipherTransform);
  12268. case '[':
  12269. var array = [];
  12270. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  12271. array.push(this.getObj(cipherTransform));
  12272. }
  12273. if (isEOF(this.buf1)) {
  12274. if (!this.recoveryMode) {
  12275. error('End of file inside array');
  12276. }
  12277. return array;
  12278. }
  12279. this.shift();
  12280. return array;
  12281. case '<<':
  12282. var dict = new Dict(this.xref);
  12283. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  12284. if (!isName(this.buf1)) {
  12285. info('Malformed dictionary: key must be a name object');
  12286. this.shift();
  12287. continue;
  12288. }
  12289. var key = this.buf1.name;
  12290. this.shift();
  12291. if (isEOF(this.buf1)) {
  12292. break;
  12293. }
  12294. dict.set(key, this.getObj(cipherTransform));
  12295. }
  12296. if (isEOF(this.buf1)) {
  12297. if (!this.recoveryMode) {
  12298. error('End of file inside dictionary');
  12299. }
  12300. return dict;
  12301. }
  12302. if (isCmd(this.buf2, 'stream')) {
  12303. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  12304. }
  12305. this.shift();
  12306. return dict;
  12307. default:
  12308. return buf1;
  12309. }
  12310. }
  12311. if (isInt(buf1)) {
  12312. var num = buf1;
  12313. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  12314. var ref = new Ref(num, this.buf1);
  12315. this.shift();
  12316. this.shift();
  12317. return ref;
  12318. }
  12319. return num;
  12320. }
  12321. if (isString(buf1)) {
  12322. var str = buf1;
  12323. if (cipherTransform) {
  12324. str = cipherTransform.decryptString(str);
  12325. }
  12326. return str;
  12327. }
  12328. return buf1;
  12329. },
  12330. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  12331. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  12332. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  12333. while ((ch = stream.getByte()) !== -1) {
  12334. if (state === 0) {
  12335. state = ch === E ? 1 : 0;
  12336. } else if (state === 1) {
  12337. state = ch === I ? 2 : 0;
  12338. } else {
  12339. assert(state === 2);
  12340. if (ch === SPACE || ch === LF || ch === CR) {
  12341. n = 5;
  12342. followingBytes = stream.peekBytes(n);
  12343. for (i = 0; i < n; i++) {
  12344. ch = followingBytes[i];
  12345. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  12346. state = 0;
  12347. break;
  12348. }
  12349. }
  12350. if (state === 2) {
  12351. break;
  12352. }
  12353. } else {
  12354. state = 0;
  12355. }
  12356. }
  12357. }
  12358. return stream.pos - 4 - startPos;
  12359. },
  12360. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  12361. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  12362. while ((b = stream.getByte()) !== -1) {
  12363. if (b !== 0xFF) {
  12364. continue;
  12365. }
  12366. switch (stream.getByte()) {
  12367. case 0x00:
  12368. break;
  12369. case 0xFF:
  12370. stream.skip(-1);
  12371. break;
  12372. case 0xD9:
  12373. foundEOI = true;
  12374. break;
  12375. case 0xC0:
  12376. case 0xC1:
  12377. case 0xC2:
  12378. case 0xC3:
  12379. case 0xC5:
  12380. case 0xC6:
  12381. case 0xC7:
  12382. case 0xC9:
  12383. case 0xCA:
  12384. case 0xCB:
  12385. case 0xCD:
  12386. case 0xCE:
  12387. case 0xCF:
  12388. case 0xC4:
  12389. case 0xCC:
  12390. case 0xDA:
  12391. case 0xDB:
  12392. case 0xDC:
  12393. case 0xDD:
  12394. case 0xDE:
  12395. case 0xDF:
  12396. case 0xE0:
  12397. case 0xE1:
  12398. case 0xE2:
  12399. case 0xE3:
  12400. case 0xE4:
  12401. case 0xE5:
  12402. case 0xE6:
  12403. case 0xE7:
  12404. case 0xE8:
  12405. case 0xE9:
  12406. case 0xEA:
  12407. case 0xEB:
  12408. case 0xEC:
  12409. case 0xED:
  12410. case 0xEE:
  12411. case 0xEF:
  12412. case 0xFE:
  12413. markerLength = stream.getUint16();
  12414. if (markerLength > 2) {
  12415. stream.skip(markerLength - 2);
  12416. } else {
  12417. stream.skip(-2);
  12418. }
  12419. break;
  12420. }
  12421. if (foundEOI) {
  12422. break;
  12423. }
  12424. }
  12425. length = stream.pos - startPos;
  12426. if (b === -1) {
  12427. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  12428. stream.skip(-length);
  12429. return this.findDefaultInlineStreamEnd(stream);
  12430. }
  12431. this.inlineStreamSkipEI(stream);
  12432. return length;
  12433. },
  12434. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  12435. var TILDE = 0x7E, GT = 0x3E;
  12436. var startPos = stream.pos, ch, length;
  12437. while ((ch = stream.getByte()) !== -1) {
  12438. if (ch === TILDE && stream.peekByte() === GT) {
  12439. stream.skip();
  12440. break;
  12441. }
  12442. }
  12443. length = stream.pos - startPos;
  12444. if (ch === -1) {
  12445. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  12446. stream.skip(-length);
  12447. return this.findDefaultInlineStreamEnd(stream);
  12448. }
  12449. this.inlineStreamSkipEI(stream);
  12450. return length;
  12451. },
  12452. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  12453. var GT = 0x3E;
  12454. var startPos = stream.pos, ch, length;
  12455. while ((ch = stream.getByte()) !== -1) {
  12456. if (ch === GT) {
  12457. break;
  12458. }
  12459. }
  12460. length = stream.pos - startPos;
  12461. if (ch === -1) {
  12462. warn('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  12463. stream.skip(-length);
  12464. return this.findDefaultInlineStreamEnd(stream);
  12465. }
  12466. this.inlineStreamSkipEI(stream);
  12467. return length;
  12468. },
  12469. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  12470. var E = 0x45, I = 0x49;
  12471. var state = 0, ch;
  12472. while ((ch = stream.getByte()) !== -1) {
  12473. if (state === 0) {
  12474. state = ch === E ? 1 : 0;
  12475. } else if (state === 1) {
  12476. state = ch === I ? 2 : 0;
  12477. } else if (state === 2) {
  12478. break;
  12479. }
  12480. }
  12481. },
  12482. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  12483. var lexer = this.lexer;
  12484. var stream = lexer.stream;
  12485. var dict = new Dict(this.xref);
  12486. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  12487. if (!isName(this.buf1)) {
  12488. error('Dictionary key must be a name object');
  12489. }
  12490. var key = this.buf1.name;
  12491. this.shift();
  12492. if (isEOF(this.buf1)) {
  12493. break;
  12494. }
  12495. dict.set(key, this.getObj(cipherTransform));
  12496. }
  12497. var filter = dict.get('Filter', 'F'), filterName;
  12498. if (isName(filter)) {
  12499. filterName = filter.name;
  12500. } else if (isArray(filter)) {
  12501. var filterZero = this.xref.fetchIfRef(filter[0]);
  12502. if (isName(filterZero)) {
  12503. filterName = filterZero.name;
  12504. }
  12505. }
  12506. var startPos = stream.pos, length, i, ii;
  12507. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  12508. length = this.findDCTDecodeInlineStreamEnd(stream);
  12509. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  12510. length = this.findASCII85DecodeInlineStreamEnd(stream);
  12511. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  12512. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  12513. } else {
  12514. length = this.findDefaultInlineStreamEnd(stream);
  12515. }
  12516. var imageStream = stream.makeSubStream(startPos, length, dict);
  12517. var adler32;
  12518. if (length < MAX_LENGTH_TO_CACHE) {
  12519. var imageBytes = imageStream.getBytes();
  12520. imageStream.reset();
  12521. var a = 1;
  12522. var b = 0;
  12523. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  12524. a += imageBytes[i] & 0xff;
  12525. b += a;
  12526. }
  12527. adler32 = b % 65521 << 16 | a % 65521;
  12528. if (this.imageCache.adler32 === adler32) {
  12529. this.buf2 = Cmd.get('EI');
  12530. this.shift();
  12531. this.imageCache[adler32].reset();
  12532. return this.imageCache[adler32];
  12533. }
  12534. }
  12535. if (cipherTransform) {
  12536. imageStream = cipherTransform.createStream(imageStream, length);
  12537. }
  12538. imageStream = this.filter(imageStream, dict, length);
  12539. imageStream.dict = dict;
  12540. if (adler32 !== undefined) {
  12541. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  12542. this.imageCache[adler32] = imageStream;
  12543. }
  12544. this.buf2 = Cmd.get('EI');
  12545. this.shift();
  12546. return imageStream;
  12547. },
  12548. makeStream: function Parser_makeStream(dict, cipherTransform) {
  12549. var lexer = this.lexer;
  12550. var stream = lexer.stream;
  12551. lexer.skipToNextLine();
  12552. var pos = stream.pos - 1;
  12553. var length = dict.get('Length');
  12554. if (!isInt(length)) {
  12555. info('Bad ' + length + ' attribute in stream');
  12556. length = 0;
  12557. }
  12558. stream.pos = pos + length;
  12559. lexer.nextChar();
  12560. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  12561. this.shift();
  12562. } else {
  12563. stream.pos = pos;
  12564. var SCAN_BLOCK_SIZE = 2048;
  12565. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  12566. var ENDSTREAM_SIGNATURE = [
  12567. 0x65,
  12568. 0x6E,
  12569. 0x64,
  12570. 0x73,
  12571. 0x74,
  12572. 0x72,
  12573. 0x65,
  12574. 0x61,
  12575. 0x6D
  12576. ];
  12577. var skipped = 0, found = false, i, j;
  12578. while (stream.pos < stream.end) {
  12579. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  12580. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  12581. if (scanLength <= 0) {
  12582. break;
  12583. }
  12584. found = false;
  12585. i = 0;
  12586. while (i < scanLength) {
  12587. j = 0;
  12588. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  12589. j++;
  12590. }
  12591. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  12592. found = true;
  12593. break;
  12594. }
  12595. i++;
  12596. }
  12597. if (found) {
  12598. skipped += i;
  12599. stream.pos += i;
  12600. break;
  12601. }
  12602. skipped += scanLength;
  12603. stream.pos += scanLength;
  12604. }
  12605. if (!found) {
  12606. error('Missing endstream');
  12607. }
  12608. length = skipped;
  12609. lexer.nextChar();
  12610. this.shift();
  12611. this.shift();
  12612. }
  12613. this.shift();
  12614. stream = stream.makeSubStream(pos, length, dict);
  12615. if (cipherTransform) {
  12616. stream = cipherTransform.createStream(stream, length);
  12617. }
  12618. stream = this.filter(stream, dict, length);
  12619. stream.dict = dict;
  12620. return stream;
  12621. },
  12622. filter: function Parser_filter(stream, dict, length) {
  12623. var filter = dict.get('Filter', 'F');
  12624. var params = dict.get('DecodeParms', 'DP');
  12625. if (isName(filter)) {
  12626. if (isArray(params)) {
  12627. params = this.xref.fetchIfRef(params[0]);
  12628. }
  12629. return this.makeFilter(stream, filter.name, length, params);
  12630. }
  12631. var maybeLength = length;
  12632. if (isArray(filter)) {
  12633. var filterArray = filter;
  12634. var paramsArray = params;
  12635. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  12636. filter = this.xref.fetchIfRef(filterArray[i]);
  12637. if (!isName(filter)) {
  12638. error('Bad filter name: ' + filter);
  12639. }
  12640. params = null;
  12641. if (isArray(paramsArray) && i in paramsArray) {
  12642. params = this.xref.fetchIfRef(paramsArray[i]);
  12643. }
  12644. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  12645. maybeLength = null;
  12646. }
  12647. }
  12648. return stream;
  12649. },
  12650. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  12651. if (maybeLength === 0) {
  12652. warn('Empty "' + name + '" stream.');
  12653. return new NullStream(stream);
  12654. }
  12655. try {
  12656. var xrefStreamStats = this.xref.stats.streamTypes;
  12657. if (name === 'FlateDecode' || name === 'Fl') {
  12658. xrefStreamStats[StreamType.FLATE] = true;
  12659. if (params) {
  12660. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  12661. }
  12662. return new FlateStream(stream, maybeLength);
  12663. }
  12664. if (name === 'LZWDecode' || name === 'LZW') {
  12665. xrefStreamStats[StreamType.LZW] = true;
  12666. var earlyChange = 1;
  12667. if (params) {
  12668. if (params.has('EarlyChange')) {
  12669. earlyChange = params.get('EarlyChange');
  12670. }
  12671. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  12672. }
  12673. return new LZWStream(stream, maybeLength, earlyChange);
  12674. }
  12675. if (name === 'DCTDecode' || name === 'DCT') {
  12676. xrefStreamStats[StreamType.DCT] = true;
  12677. return new JpegStream(stream, maybeLength, stream.dict, params);
  12678. }
  12679. if (name === 'JPXDecode' || name === 'JPX') {
  12680. xrefStreamStats[StreamType.JPX] = true;
  12681. return new JpxStream(stream, maybeLength, stream.dict, params);
  12682. }
  12683. if (name === 'ASCII85Decode' || name === 'A85') {
  12684. xrefStreamStats[StreamType.A85] = true;
  12685. return new Ascii85Stream(stream, maybeLength);
  12686. }
  12687. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  12688. xrefStreamStats[StreamType.AHX] = true;
  12689. return new AsciiHexStream(stream, maybeLength);
  12690. }
  12691. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  12692. xrefStreamStats[StreamType.CCF] = true;
  12693. return new CCITTFaxStream(stream, maybeLength, params);
  12694. }
  12695. if (name === 'RunLengthDecode' || name === 'RL') {
  12696. xrefStreamStats[StreamType.RL] = true;
  12697. return new RunLengthStream(stream, maybeLength);
  12698. }
  12699. if (name === 'JBIG2Decode') {
  12700. xrefStreamStats[StreamType.JBIG] = true;
  12701. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  12702. }
  12703. warn('filter "' + name + '" not supported yet');
  12704. return stream;
  12705. } catch (ex) {
  12706. if (ex instanceof MissingDataException) {
  12707. throw ex;
  12708. }
  12709. warn('Invalid stream: \"' + ex + '\"');
  12710. return new NullStream(stream);
  12711. }
  12712. }
  12713. };
  12714. return Parser;
  12715. }();
  12716. var Lexer = function LexerClosure() {
  12717. function Lexer(stream, knownCommands) {
  12718. this.stream = stream;
  12719. this.nextChar();
  12720. this.strBuf = [];
  12721. this.knownCommands = knownCommands;
  12722. }
  12723. var specialChars = [
  12724. 1,
  12725. 0,
  12726. 0,
  12727. 0,
  12728. 0,
  12729. 0,
  12730. 0,
  12731. 0,
  12732. 0,
  12733. 1,
  12734. 1,
  12735. 0,
  12736. 1,
  12737. 1,
  12738. 0,
  12739. 0,
  12740. 0,
  12741. 0,
  12742. 0,
  12743. 0,
  12744. 0,
  12745. 0,
  12746. 0,
  12747. 0,
  12748. 0,
  12749. 0,
  12750. 0,
  12751. 0,
  12752. 0,
  12753. 0,
  12754. 0,
  12755. 0,
  12756. 1,
  12757. 0,
  12758. 0,
  12759. 0,
  12760. 0,
  12761. 2,
  12762. 0,
  12763. 0,
  12764. 2,
  12765. 2,
  12766. 0,
  12767. 0,
  12768. 0,
  12769. 0,
  12770. 0,
  12771. 2,
  12772. 0,
  12773. 0,
  12774. 0,
  12775. 0,
  12776. 0,
  12777. 0,
  12778. 0,
  12779. 0,
  12780. 0,
  12781. 0,
  12782. 0,
  12783. 0,
  12784. 2,
  12785. 0,
  12786. 2,
  12787. 0,
  12788. 0,
  12789. 0,
  12790. 0,
  12791. 0,
  12792. 0,
  12793. 0,
  12794. 0,
  12795. 0,
  12796. 0,
  12797. 0,
  12798. 0,
  12799. 0,
  12800. 0,
  12801. 0,
  12802. 0,
  12803. 0,
  12804. 0,
  12805. 0,
  12806. 0,
  12807. 0,
  12808. 0,
  12809. 0,
  12810. 0,
  12811. 0,
  12812. 0,
  12813. 0,
  12814. 0,
  12815. 2,
  12816. 0,
  12817. 2,
  12818. 0,
  12819. 0,
  12820. 0,
  12821. 0,
  12822. 0,
  12823. 0,
  12824. 0,
  12825. 0,
  12826. 0,
  12827. 0,
  12828. 0,
  12829. 0,
  12830. 0,
  12831. 0,
  12832. 0,
  12833. 0,
  12834. 0,
  12835. 0,
  12836. 0,
  12837. 0,
  12838. 0,
  12839. 0,
  12840. 0,
  12841. 0,
  12842. 0,
  12843. 0,
  12844. 0,
  12845. 0,
  12846. 0,
  12847. 2,
  12848. 0,
  12849. 2,
  12850. 0,
  12851. 0,
  12852. 0,
  12853. 0,
  12854. 0,
  12855. 0,
  12856. 0,
  12857. 0,
  12858. 0,
  12859. 0,
  12860. 0,
  12861. 0,
  12862. 0,
  12863. 0,
  12864. 0,
  12865. 0,
  12866. 0,
  12867. 0,
  12868. 0,
  12869. 0,
  12870. 0,
  12871. 0,
  12872. 0,
  12873. 0,
  12874. 0,
  12875. 0,
  12876. 0,
  12877. 0,
  12878. 0,
  12879. 0,
  12880. 0,
  12881. 0,
  12882. 0,
  12883. 0,
  12884. 0,
  12885. 0,
  12886. 0,
  12887. 0,
  12888. 0,
  12889. 0,
  12890. 0,
  12891. 0,
  12892. 0,
  12893. 0,
  12894. 0,
  12895. 0,
  12896. 0,
  12897. 0,
  12898. 0,
  12899. 0,
  12900. 0,
  12901. 0,
  12902. 0,
  12903. 0,
  12904. 0,
  12905. 0,
  12906. 0,
  12907. 0,
  12908. 0,
  12909. 0,
  12910. 0,
  12911. 0,
  12912. 0,
  12913. 0,
  12914. 0,
  12915. 0,
  12916. 0,
  12917. 0,
  12918. 0,
  12919. 0,
  12920. 0,
  12921. 0,
  12922. 0,
  12923. 0,
  12924. 0,
  12925. 0,
  12926. 0,
  12927. 0,
  12928. 0,
  12929. 0,
  12930. 0,
  12931. 0,
  12932. 0,
  12933. 0,
  12934. 0,
  12935. 0,
  12936. 0,
  12937. 0,
  12938. 0,
  12939. 0,
  12940. 0,
  12941. 0,
  12942. 0,
  12943. 0,
  12944. 0,
  12945. 0,
  12946. 0,
  12947. 0,
  12948. 0,
  12949. 0,
  12950. 0,
  12951. 0,
  12952. 0,
  12953. 0,
  12954. 0,
  12955. 0,
  12956. 0,
  12957. 0,
  12958. 0,
  12959. 0,
  12960. 0,
  12961. 0,
  12962. 0,
  12963. 0,
  12964. 0,
  12965. 0,
  12966. 0,
  12967. 0,
  12968. 0,
  12969. 0,
  12970. 0,
  12971. 0,
  12972. 0,
  12973. 0,
  12974. 0,
  12975. 0,
  12976. 0,
  12977. 0,
  12978. 0,
  12979. 0
  12980. ];
  12981. function toHexDigit(ch) {
  12982. if (ch >= 0x30 && ch <= 0x39) {
  12983. return ch & 0x0F;
  12984. }
  12985. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  12986. return (ch & 0x0F) + 9;
  12987. }
  12988. return -1;
  12989. }
  12990. Lexer.prototype = {
  12991. nextChar: function Lexer_nextChar() {
  12992. return this.currentChar = this.stream.getByte();
  12993. },
  12994. peekChar: function Lexer_peekChar() {
  12995. return this.stream.peekByte();
  12996. },
  12997. getNumber: function Lexer_getNumber() {
  12998. var ch = this.currentChar;
  12999. var eNotation = false;
  13000. var divideBy = 0;
  13001. var sign = 1;
  13002. if (ch === 0x2D) {
  13003. sign = -1;
  13004. ch = this.nextChar();
  13005. if (ch === 0x2D) {
  13006. ch = this.nextChar();
  13007. }
  13008. } else if (ch === 0x2B) {
  13009. ch = this.nextChar();
  13010. }
  13011. if (ch === 0x2E) {
  13012. divideBy = 10;
  13013. ch = this.nextChar();
  13014. }
  13015. if (ch < 0x30 || ch > 0x39) {
  13016. error('Invalid number: ' + String.fromCharCode(ch));
  13017. return 0;
  13018. }
  13019. var baseValue = ch - 0x30;
  13020. var powerValue = 0;
  13021. var powerValueSign = 1;
  13022. while ((ch = this.nextChar()) >= 0) {
  13023. if (0x30 <= ch && ch <= 0x39) {
  13024. var currentDigit = ch - 0x30;
  13025. if (eNotation) {
  13026. powerValue = powerValue * 10 + currentDigit;
  13027. } else {
  13028. if (divideBy !== 0) {
  13029. divideBy *= 10;
  13030. }
  13031. baseValue = baseValue * 10 + currentDigit;
  13032. }
  13033. } else if (ch === 0x2E) {
  13034. if (divideBy === 0) {
  13035. divideBy = 1;
  13036. } else {
  13037. break;
  13038. }
  13039. } else if (ch === 0x2D) {
  13040. warn('Badly formatted number');
  13041. } else if (ch === 0x45 || ch === 0x65) {
  13042. ch = this.peekChar();
  13043. if (ch === 0x2B || ch === 0x2D) {
  13044. powerValueSign = ch === 0x2D ? -1 : 1;
  13045. this.nextChar();
  13046. } else if (ch < 0x30 || ch > 0x39) {
  13047. break;
  13048. }
  13049. eNotation = true;
  13050. } else {
  13051. break;
  13052. }
  13053. }
  13054. if (divideBy !== 0) {
  13055. baseValue /= divideBy;
  13056. }
  13057. if (eNotation) {
  13058. baseValue *= Math.pow(10, powerValueSign * powerValue);
  13059. }
  13060. return sign * baseValue;
  13061. },
  13062. getString: function Lexer_getString() {
  13063. var numParen = 1;
  13064. var done = false;
  13065. var strBuf = this.strBuf;
  13066. strBuf.length = 0;
  13067. var ch = this.nextChar();
  13068. while (true) {
  13069. var charBuffered = false;
  13070. switch (ch | 0) {
  13071. case -1:
  13072. warn('Unterminated string');
  13073. done = true;
  13074. break;
  13075. case 0x28:
  13076. ++numParen;
  13077. strBuf.push('(');
  13078. break;
  13079. case 0x29:
  13080. if (--numParen === 0) {
  13081. this.nextChar();
  13082. done = true;
  13083. } else {
  13084. strBuf.push(')');
  13085. }
  13086. break;
  13087. case 0x5C:
  13088. ch = this.nextChar();
  13089. switch (ch) {
  13090. case -1:
  13091. warn('Unterminated string');
  13092. done = true;
  13093. break;
  13094. case 0x6E:
  13095. strBuf.push('\n');
  13096. break;
  13097. case 0x72:
  13098. strBuf.push('\r');
  13099. break;
  13100. case 0x74:
  13101. strBuf.push('\t');
  13102. break;
  13103. case 0x62:
  13104. strBuf.push('\b');
  13105. break;
  13106. case 0x66:
  13107. strBuf.push('\f');
  13108. break;
  13109. case 0x5C:
  13110. case 0x28:
  13111. case 0x29:
  13112. strBuf.push(String.fromCharCode(ch));
  13113. break;
  13114. case 0x30:
  13115. case 0x31:
  13116. case 0x32:
  13117. case 0x33:
  13118. case 0x34:
  13119. case 0x35:
  13120. case 0x36:
  13121. case 0x37:
  13122. var x = ch & 0x0F;
  13123. ch = this.nextChar();
  13124. charBuffered = true;
  13125. if (ch >= 0x30 && ch <= 0x37) {
  13126. x = (x << 3) + (ch & 0x0F);
  13127. ch = this.nextChar();
  13128. if (ch >= 0x30 && ch <= 0x37) {
  13129. charBuffered = false;
  13130. x = (x << 3) + (ch & 0x0F);
  13131. }
  13132. }
  13133. strBuf.push(String.fromCharCode(x));
  13134. break;
  13135. case 0x0D:
  13136. if (this.peekChar() === 0x0A) {
  13137. this.nextChar();
  13138. }
  13139. break;
  13140. case 0x0A:
  13141. break;
  13142. default:
  13143. strBuf.push(String.fromCharCode(ch));
  13144. break;
  13145. }
  13146. break;
  13147. default:
  13148. strBuf.push(String.fromCharCode(ch));
  13149. break;
  13150. }
  13151. if (done) {
  13152. break;
  13153. }
  13154. if (!charBuffered) {
  13155. ch = this.nextChar();
  13156. }
  13157. }
  13158. return strBuf.join('');
  13159. },
  13160. getName: function Lexer_getName() {
  13161. var ch, previousCh;
  13162. var strBuf = this.strBuf;
  13163. strBuf.length = 0;
  13164. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  13165. if (ch === 0x23) {
  13166. ch = this.nextChar();
  13167. if (specialChars[ch]) {
  13168. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  13169. strBuf.push('#');
  13170. break;
  13171. }
  13172. var x = toHexDigit(ch);
  13173. if (x !== -1) {
  13174. previousCh = ch;
  13175. ch = this.nextChar();
  13176. var x2 = toHexDigit(ch);
  13177. if (x2 === -1) {
  13178. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  13179. strBuf.push('#', String.fromCharCode(previousCh));
  13180. if (specialChars[ch]) {
  13181. break;
  13182. }
  13183. strBuf.push(String.fromCharCode(ch));
  13184. continue;
  13185. }
  13186. strBuf.push(String.fromCharCode(x << 4 | x2));
  13187. } else {
  13188. strBuf.push('#', String.fromCharCode(ch));
  13189. }
  13190. } else {
  13191. strBuf.push(String.fromCharCode(ch));
  13192. }
  13193. }
  13194. if (strBuf.length > 127) {
  13195. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  13196. }
  13197. return Name.get(strBuf.join(''));
  13198. },
  13199. getHexString: function Lexer_getHexString() {
  13200. var strBuf = this.strBuf;
  13201. strBuf.length = 0;
  13202. var ch = this.currentChar;
  13203. var isFirstHex = true;
  13204. var firstDigit;
  13205. var secondDigit;
  13206. while (true) {
  13207. if (ch < 0) {
  13208. warn('Unterminated hex string');
  13209. break;
  13210. } else if (ch === 0x3E) {
  13211. this.nextChar();
  13212. break;
  13213. } else if (specialChars[ch] === 1) {
  13214. ch = this.nextChar();
  13215. continue;
  13216. } else {
  13217. if (isFirstHex) {
  13218. firstDigit = toHexDigit(ch);
  13219. if (firstDigit === -1) {
  13220. warn('Ignoring invalid character "' + ch + '" in hex string');
  13221. ch = this.nextChar();
  13222. continue;
  13223. }
  13224. } else {
  13225. secondDigit = toHexDigit(ch);
  13226. if (secondDigit === -1) {
  13227. warn('Ignoring invalid character "' + ch + '" in hex string');
  13228. ch = this.nextChar();
  13229. continue;
  13230. }
  13231. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  13232. }
  13233. isFirstHex = !isFirstHex;
  13234. ch = this.nextChar();
  13235. }
  13236. }
  13237. return strBuf.join('');
  13238. },
  13239. getObj: function Lexer_getObj() {
  13240. var comment = false;
  13241. var ch = this.currentChar;
  13242. while (true) {
  13243. if (ch < 0) {
  13244. return EOF;
  13245. }
  13246. if (comment) {
  13247. if (ch === 0x0A || ch === 0x0D) {
  13248. comment = false;
  13249. }
  13250. } else if (ch === 0x25) {
  13251. comment = true;
  13252. } else if (specialChars[ch] !== 1) {
  13253. break;
  13254. }
  13255. ch = this.nextChar();
  13256. }
  13257. switch (ch | 0) {
  13258. case 0x30:
  13259. case 0x31:
  13260. case 0x32:
  13261. case 0x33:
  13262. case 0x34:
  13263. case 0x35:
  13264. case 0x36:
  13265. case 0x37:
  13266. case 0x38:
  13267. case 0x39:
  13268. case 0x2B:
  13269. case 0x2D:
  13270. case 0x2E:
  13271. return this.getNumber();
  13272. case 0x28:
  13273. return this.getString();
  13274. case 0x2F:
  13275. return this.getName();
  13276. case 0x5B:
  13277. this.nextChar();
  13278. return Cmd.get('[');
  13279. case 0x5D:
  13280. this.nextChar();
  13281. return Cmd.get(']');
  13282. case 0x3C:
  13283. ch = this.nextChar();
  13284. if (ch === 0x3C) {
  13285. this.nextChar();
  13286. return Cmd.get('<<');
  13287. }
  13288. return this.getHexString();
  13289. case 0x3E:
  13290. ch = this.nextChar();
  13291. if (ch === 0x3E) {
  13292. this.nextChar();
  13293. return Cmd.get('>>');
  13294. }
  13295. return Cmd.get('>');
  13296. case 0x7B:
  13297. this.nextChar();
  13298. return Cmd.get('{');
  13299. case 0x7D:
  13300. this.nextChar();
  13301. return Cmd.get('}');
  13302. case 0x29:
  13303. this.nextChar();
  13304. error('Illegal character: ' + ch);
  13305. break;
  13306. }
  13307. var str = String.fromCharCode(ch);
  13308. var knownCommands = this.knownCommands;
  13309. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  13310. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  13311. var possibleCommand = str + String.fromCharCode(ch);
  13312. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  13313. break;
  13314. }
  13315. if (str.length === 128) {
  13316. error('Command token too long: ' + str.length);
  13317. }
  13318. str = possibleCommand;
  13319. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  13320. }
  13321. if (str === 'true') {
  13322. return true;
  13323. }
  13324. if (str === 'false') {
  13325. return false;
  13326. }
  13327. if (str === 'null') {
  13328. return null;
  13329. }
  13330. return Cmd.get(str);
  13331. },
  13332. skipToNextLine: function Lexer_skipToNextLine() {
  13333. var ch = this.currentChar;
  13334. while (ch >= 0) {
  13335. if (ch === 0x0D) {
  13336. ch = this.nextChar();
  13337. if (ch === 0x0A) {
  13338. this.nextChar();
  13339. }
  13340. break;
  13341. } else if (ch === 0x0A) {
  13342. this.nextChar();
  13343. break;
  13344. }
  13345. ch = this.nextChar();
  13346. }
  13347. }
  13348. };
  13349. return Lexer;
  13350. }();
  13351. var Linearization = {
  13352. create: function LinearizationCreate(stream) {
  13353. function getInt(name, allowZeroValue) {
  13354. var obj = linDict.get(name);
  13355. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  13356. return obj;
  13357. }
  13358. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  13359. }
  13360. function getHints() {
  13361. var hints = linDict.get('H'), hintsLength, item;
  13362. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  13363. for (var index = 0; index < hintsLength; index++) {
  13364. if (!(isInt(item = hints[index]) && item > 0)) {
  13365. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  13366. }
  13367. }
  13368. return hints;
  13369. }
  13370. throw new Error('Hint array in the linearization dictionary is invalid.');
  13371. }
  13372. var parser = new Parser(new Lexer(stream), false, null);
  13373. var obj1 = parser.getObj();
  13374. var obj2 = parser.getObj();
  13375. var obj3 = parser.getObj();
  13376. var linDict = parser.getObj();
  13377. var obj, length;
  13378. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  13379. return null;
  13380. } else if ((length = getInt('L')) !== stream.length) {
  13381. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  13382. }
  13383. return {
  13384. length: length,
  13385. hints: getHints(),
  13386. objectNumberFirst: getInt('O'),
  13387. endFirst: getInt('E'),
  13388. numPages: getInt('N'),
  13389. mainXRefEntriesOffset: getInt('T'),
  13390. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  13391. };
  13392. }
  13393. };
  13394. exports.Lexer = Lexer;
  13395. exports.Linearization = Linearization;
  13396. exports.Parser = Parser;
  13397. /***/ }),
  13398. /* 7 */
  13399. /***/ (function(module, exports, __w_pdfjs_require__) {
  13400. "use strict";
  13401. var sharedUtil = __w_pdfjs_require__(0);
  13402. var corePrimitives = __w_pdfjs_require__(1);
  13403. var corePsParser = __w_pdfjs_require__(42);
  13404. var error = sharedUtil.error;
  13405. var info = sharedUtil.info;
  13406. var isArray = sharedUtil.isArray;
  13407. var isBool = sharedUtil.isBool;
  13408. var isDict = corePrimitives.isDict;
  13409. var isStream = corePrimitives.isStream;
  13410. var PostScriptLexer = corePsParser.PostScriptLexer;
  13411. var PostScriptParser = corePsParser.PostScriptParser;
  13412. var PDFFunction = function PDFFunctionClosure() {
  13413. var CONSTRUCT_SAMPLED = 0;
  13414. var CONSTRUCT_INTERPOLATED = 2;
  13415. var CONSTRUCT_STICHED = 3;
  13416. var CONSTRUCT_POSTSCRIPT = 4;
  13417. return {
  13418. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  13419. var i, ii;
  13420. var length = 1;
  13421. for (i = 0, ii = size.length; i < ii; i++) {
  13422. length *= size[i];
  13423. }
  13424. length *= outputSize;
  13425. var array = new Array(length);
  13426. var codeSize = 0;
  13427. var codeBuf = 0;
  13428. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  13429. var strBytes = str.getBytes((length * bps + 7) / 8);
  13430. var strIdx = 0;
  13431. for (i = 0; i < length; i++) {
  13432. while (codeSize < bps) {
  13433. codeBuf <<= 8;
  13434. codeBuf |= strBytes[strIdx++];
  13435. codeSize += 8;
  13436. }
  13437. codeSize -= bps;
  13438. array[i] = (codeBuf >> codeSize) * sampleMul;
  13439. codeBuf &= (1 << codeSize) - 1;
  13440. }
  13441. return array;
  13442. },
  13443. getIR: function PDFFunction_getIR(xref, fn) {
  13444. var dict = fn.dict;
  13445. if (!dict) {
  13446. dict = fn;
  13447. }
  13448. var types = [
  13449. this.constructSampled,
  13450. null,
  13451. this.constructInterpolated,
  13452. this.constructStiched,
  13453. this.constructPostScript
  13454. ];
  13455. var typeNum = dict.get('FunctionType');
  13456. var typeFn = types[typeNum];
  13457. if (!typeFn) {
  13458. error('Unknown type of function');
  13459. }
  13460. return typeFn.call(this, fn, dict, xref);
  13461. },
  13462. fromIR: function PDFFunction_fromIR(IR) {
  13463. var type = IR[0];
  13464. switch (type) {
  13465. case CONSTRUCT_SAMPLED:
  13466. return this.constructSampledFromIR(IR);
  13467. case CONSTRUCT_INTERPOLATED:
  13468. return this.constructInterpolatedFromIR(IR);
  13469. case CONSTRUCT_STICHED:
  13470. return this.constructStichedFromIR(IR);
  13471. default:
  13472. return this.constructPostScriptFromIR(IR);
  13473. }
  13474. },
  13475. parse: function PDFFunction_parse(xref, fn) {
  13476. var IR = this.getIR(xref, fn);
  13477. return this.fromIR(IR);
  13478. },
  13479. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  13480. if (!isArray(fnObj)) {
  13481. return this.parse(xref, fnObj);
  13482. }
  13483. var fnArray = [];
  13484. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  13485. var obj = xref.fetchIfRef(fnObj[j]);
  13486. fnArray.push(PDFFunction.parse(xref, obj));
  13487. }
  13488. return function (src, srcOffset, dest, destOffset) {
  13489. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  13490. fnArray[i](src, srcOffset, dest, destOffset + i);
  13491. }
  13492. };
  13493. },
  13494. constructSampled: function PDFFunction_constructSampled(str, dict) {
  13495. function toMultiArray(arr) {
  13496. var inputLength = arr.length;
  13497. var out = [];
  13498. var index = 0;
  13499. for (var i = 0; i < inputLength; i += 2) {
  13500. out[index] = [
  13501. arr[i],
  13502. arr[i + 1]
  13503. ];
  13504. ++index;
  13505. }
  13506. return out;
  13507. }
  13508. var domain = dict.getArray('Domain');
  13509. var range = dict.getArray('Range');
  13510. if (!domain || !range) {
  13511. error('No domain or range');
  13512. }
  13513. var inputSize = domain.length / 2;
  13514. var outputSize = range.length / 2;
  13515. domain = toMultiArray(domain);
  13516. range = toMultiArray(range);
  13517. var size = dict.get('Size');
  13518. var bps = dict.get('BitsPerSample');
  13519. var order = dict.get('Order') || 1;
  13520. if (order !== 1) {
  13521. info('No support for cubic spline interpolation: ' + order);
  13522. }
  13523. var encode = dict.getArray('Encode');
  13524. if (!encode) {
  13525. encode = [];
  13526. for (var i = 0; i < inputSize; ++i) {
  13527. encode.push(0);
  13528. encode.push(size[i] - 1);
  13529. }
  13530. }
  13531. encode = toMultiArray(encode);
  13532. var decode = dict.getArray('Decode');
  13533. if (!decode) {
  13534. decode = range;
  13535. } else {
  13536. decode = toMultiArray(decode);
  13537. }
  13538. var samples = this.getSampleArray(size, outputSize, bps, str);
  13539. return [
  13540. CONSTRUCT_SAMPLED,
  13541. inputSize,
  13542. domain,
  13543. encode,
  13544. decode,
  13545. samples,
  13546. size,
  13547. outputSize,
  13548. Math.pow(2, bps) - 1,
  13549. range
  13550. ];
  13551. },
  13552. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  13553. function interpolate(x, xmin, xmax, ymin, ymax) {
  13554. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  13555. }
  13556. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  13557. var m = IR[1];
  13558. var domain = IR[2];
  13559. var encode = IR[3];
  13560. var decode = IR[4];
  13561. var samples = IR[5];
  13562. var size = IR[6];
  13563. var n = IR[7];
  13564. var range = IR[9];
  13565. var cubeVertices = 1 << m;
  13566. var cubeN = new Float64Array(cubeVertices);
  13567. var cubeVertex = new Uint32Array(cubeVertices);
  13568. var i, j;
  13569. for (j = 0; j < cubeVertices; j++) {
  13570. cubeN[j] = 1;
  13571. }
  13572. var k = n, pos = 1;
  13573. for (i = 0; i < m; ++i) {
  13574. var domain_2i = domain[i][0];
  13575. var domain_2i_1 = domain[i][1];
  13576. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  13577. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  13578. var size_i = size[i];
  13579. e = Math.min(Math.max(e, 0), size_i - 1);
  13580. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  13581. var n0 = e0 + 1 - e;
  13582. var n1 = e - e0;
  13583. var offset0 = e0 * k;
  13584. var offset1 = offset0 + k;
  13585. for (j = 0; j < cubeVertices; j++) {
  13586. if (j & pos) {
  13587. cubeN[j] *= n1;
  13588. cubeVertex[j] += offset1;
  13589. } else {
  13590. cubeN[j] *= n0;
  13591. cubeVertex[j] += offset0;
  13592. }
  13593. }
  13594. k *= size_i;
  13595. pos <<= 1;
  13596. }
  13597. for (j = 0; j < n; ++j) {
  13598. var rj = 0;
  13599. for (i = 0; i < cubeVertices; i++) {
  13600. rj += samples[cubeVertex[i] + j] * cubeN[i];
  13601. }
  13602. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  13603. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  13604. }
  13605. };
  13606. },
  13607. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  13608. var c0 = dict.getArray('C0') || [0];
  13609. var c1 = dict.getArray('C1') || [1];
  13610. var n = dict.get('N');
  13611. if (!isArray(c0) || !isArray(c1)) {
  13612. error('Illegal dictionary for interpolated function');
  13613. }
  13614. var length = c0.length;
  13615. var diff = [];
  13616. for (var i = 0; i < length; ++i) {
  13617. diff.push(c1[i] - c0[i]);
  13618. }
  13619. return [
  13620. CONSTRUCT_INTERPOLATED,
  13621. c0,
  13622. diff,
  13623. n
  13624. ];
  13625. },
  13626. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  13627. var c0 = IR[1];
  13628. var diff = IR[2];
  13629. var n = IR[3];
  13630. var length = diff.length;
  13631. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  13632. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  13633. for (var j = 0; j < length; ++j) {
  13634. dest[destOffset + j] = c0[j] + x * diff[j];
  13635. }
  13636. };
  13637. },
  13638. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  13639. var domain = dict.getArray('Domain');
  13640. if (!domain) {
  13641. error('No domain');
  13642. }
  13643. var inputSize = domain.length / 2;
  13644. if (inputSize !== 1) {
  13645. error('Bad domain for stiched function');
  13646. }
  13647. var fnRefs = dict.get('Functions');
  13648. var fns = [];
  13649. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  13650. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  13651. }
  13652. var bounds = dict.getArray('Bounds');
  13653. var encode = dict.getArray('Encode');
  13654. return [
  13655. CONSTRUCT_STICHED,
  13656. domain,
  13657. bounds,
  13658. encode,
  13659. fns
  13660. ];
  13661. },
  13662. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  13663. var domain = IR[1];
  13664. var bounds = IR[2];
  13665. var encode = IR[3];
  13666. var fnsIR = IR[4];
  13667. var fns = [];
  13668. var tmpBuf = new Float32Array(1);
  13669. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  13670. fns.push(PDFFunction.fromIR(fnsIR[i]));
  13671. }
  13672. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  13673. var clip = function constructStichedFromIRClip(v, min, max) {
  13674. if (v > max) {
  13675. v = max;
  13676. } else if (v < min) {
  13677. v = min;
  13678. }
  13679. return v;
  13680. };
  13681. var v = clip(src[srcOffset], domain[0], domain[1]);
  13682. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  13683. if (v < bounds[i]) {
  13684. break;
  13685. }
  13686. }
  13687. var dmin = domain[0];
  13688. if (i > 0) {
  13689. dmin = bounds[i - 1];
  13690. }
  13691. var dmax = domain[1];
  13692. if (i < bounds.length) {
  13693. dmax = bounds[i];
  13694. }
  13695. var rmin = encode[2 * i];
  13696. var rmax = encode[2 * i + 1];
  13697. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  13698. fns[i](tmpBuf, 0, dest, destOffset);
  13699. };
  13700. },
  13701. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  13702. var domain = dict.getArray('Domain');
  13703. var range = dict.getArray('Range');
  13704. if (!domain) {
  13705. error('No domain.');
  13706. }
  13707. if (!range) {
  13708. error('No range.');
  13709. }
  13710. var lexer = new PostScriptLexer(fn);
  13711. var parser = new PostScriptParser(lexer);
  13712. var code = parser.parse();
  13713. return [
  13714. CONSTRUCT_POSTSCRIPT,
  13715. domain,
  13716. range,
  13717. code
  13718. ];
  13719. },
  13720. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  13721. var domain = IR[1];
  13722. var range = IR[2];
  13723. var code = IR[3];
  13724. var compiled = new PostScriptCompiler().compile(code, domain, range);
  13725. if (compiled) {
  13726. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  13727. }
  13728. info('Unable to compile PS function');
  13729. var numOutputs = range.length >> 1;
  13730. var numInputs = domain.length >> 1;
  13731. var evaluator = new PostScriptEvaluator(code);
  13732. var cache = Object.create(null);
  13733. var MAX_CACHE_SIZE = 2048 * 4;
  13734. var cache_available = MAX_CACHE_SIZE;
  13735. var tmpBuf = new Float32Array(numInputs);
  13736. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  13737. var i, value;
  13738. var key = '';
  13739. var input = tmpBuf;
  13740. for (i = 0; i < numInputs; i++) {
  13741. value = src[srcOffset + i];
  13742. input[i] = value;
  13743. key += value + '_';
  13744. }
  13745. var cachedValue = cache[key];
  13746. if (cachedValue !== undefined) {
  13747. dest.set(cachedValue, destOffset);
  13748. return;
  13749. }
  13750. var output = new Float32Array(numOutputs);
  13751. var stack = evaluator.execute(input);
  13752. var stackIndex = stack.length - numOutputs;
  13753. for (i = 0; i < numOutputs; i++) {
  13754. value = stack[stackIndex + i];
  13755. var bound = range[i * 2];
  13756. if (value < bound) {
  13757. value = bound;
  13758. } else {
  13759. bound = range[i * 2 + 1];
  13760. if (value > bound) {
  13761. value = bound;
  13762. }
  13763. }
  13764. output[i] = value;
  13765. }
  13766. if (cache_available > 0) {
  13767. cache_available--;
  13768. cache[key] = output;
  13769. }
  13770. dest.set(output, destOffset);
  13771. };
  13772. }
  13773. };
  13774. }();
  13775. function isPDFFunction(v) {
  13776. var fnDict;
  13777. if (typeof v !== 'object') {
  13778. return false;
  13779. } else if (isDict(v)) {
  13780. fnDict = v;
  13781. } else if (isStream(v)) {
  13782. fnDict = v.dict;
  13783. } else {
  13784. return false;
  13785. }
  13786. return fnDict.has('FunctionType');
  13787. }
  13788. var PostScriptStack = function PostScriptStackClosure() {
  13789. var MAX_STACK_SIZE = 100;
  13790. function PostScriptStack(initialStack) {
  13791. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  13792. }
  13793. PostScriptStack.prototype = {
  13794. push: function PostScriptStack_push(value) {
  13795. if (this.stack.length >= MAX_STACK_SIZE) {
  13796. error('PostScript function stack overflow.');
  13797. }
  13798. this.stack.push(value);
  13799. },
  13800. pop: function PostScriptStack_pop() {
  13801. if (this.stack.length <= 0) {
  13802. error('PostScript function stack underflow.');
  13803. }
  13804. return this.stack.pop();
  13805. },
  13806. copy: function PostScriptStack_copy(n) {
  13807. if (this.stack.length + n >= MAX_STACK_SIZE) {
  13808. error('PostScript function stack overflow.');
  13809. }
  13810. var stack = this.stack;
  13811. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  13812. stack.push(stack[i]);
  13813. }
  13814. },
  13815. index: function PostScriptStack_index(n) {
  13816. this.push(this.stack[this.stack.length - n - 1]);
  13817. },
  13818. roll: function PostScriptStack_roll(n, p) {
  13819. var stack = this.stack;
  13820. var l = stack.length - n;
  13821. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  13822. for (i = l, j = r; i < j; i++, j--) {
  13823. t = stack[i];
  13824. stack[i] = stack[j];
  13825. stack[j] = t;
  13826. }
  13827. for (i = l, j = c - 1; i < j; i++, j--) {
  13828. t = stack[i];
  13829. stack[i] = stack[j];
  13830. stack[j] = t;
  13831. }
  13832. for (i = c, j = r; i < j; i++, j--) {
  13833. t = stack[i];
  13834. stack[i] = stack[j];
  13835. stack[j] = t;
  13836. }
  13837. }
  13838. };
  13839. return PostScriptStack;
  13840. }();
  13841. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  13842. function PostScriptEvaluator(operators) {
  13843. this.operators = operators;
  13844. }
  13845. PostScriptEvaluator.prototype = {
  13846. execute: function PostScriptEvaluator_execute(initialStack) {
  13847. var stack = new PostScriptStack(initialStack);
  13848. var counter = 0;
  13849. var operators = this.operators;
  13850. var length = operators.length;
  13851. var operator, a, b;
  13852. while (counter < length) {
  13853. operator = operators[counter++];
  13854. if (typeof operator === 'number') {
  13855. stack.push(operator);
  13856. continue;
  13857. }
  13858. switch (operator) {
  13859. case 'jz':
  13860. b = stack.pop();
  13861. a = stack.pop();
  13862. if (!a) {
  13863. counter = b;
  13864. }
  13865. break;
  13866. case 'j':
  13867. a = stack.pop();
  13868. counter = a;
  13869. break;
  13870. case 'abs':
  13871. a = stack.pop();
  13872. stack.push(Math.abs(a));
  13873. break;
  13874. case 'add':
  13875. b = stack.pop();
  13876. a = stack.pop();
  13877. stack.push(a + b);
  13878. break;
  13879. case 'and':
  13880. b = stack.pop();
  13881. a = stack.pop();
  13882. if (isBool(a) && isBool(b)) {
  13883. stack.push(a && b);
  13884. } else {
  13885. stack.push(a & b);
  13886. }
  13887. break;
  13888. case 'atan':
  13889. a = stack.pop();
  13890. stack.push(Math.atan(a));
  13891. break;
  13892. case 'bitshift':
  13893. b = stack.pop();
  13894. a = stack.pop();
  13895. if (a > 0) {
  13896. stack.push(a << b);
  13897. } else {
  13898. stack.push(a >> b);
  13899. }
  13900. break;
  13901. case 'ceiling':
  13902. a = stack.pop();
  13903. stack.push(Math.ceil(a));
  13904. break;
  13905. case 'copy':
  13906. a = stack.pop();
  13907. stack.copy(a);
  13908. break;
  13909. case 'cos':
  13910. a = stack.pop();
  13911. stack.push(Math.cos(a));
  13912. break;
  13913. case 'cvi':
  13914. a = stack.pop() | 0;
  13915. stack.push(a);
  13916. break;
  13917. case 'cvr':
  13918. break;
  13919. case 'div':
  13920. b = stack.pop();
  13921. a = stack.pop();
  13922. stack.push(a / b);
  13923. break;
  13924. case 'dup':
  13925. stack.copy(1);
  13926. break;
  13927. case 'eq':
  13928. b = stack.pop();
  13929. a = stack.pop();
  13930. stack.push(a === b);
  13931. break;
  13932. case 'exch':
  13933. stack.roll(2, 1);
  13934. break;
  13935. case 'exp':
  13936. b = stack.pop();
  13937. a = stack.pop();
  13938. stack.push(Math.pow(a, b));
  13939. break;
  13940. case 'false':
  13941. stack.push(false);
  13942. break;
  13943. case 'floor':
  13944. a = stack.pop();
  13945. stack.push(Math.floor(a));
  13946. break;
  13947. case 'ge':
  13948. b = stack.pop();
  13949. a = stack.pop();
  13950. stack.push(a >= b);
  13951. break;
  13952. case 'gt':
  13953. b = stack.pop();
  13954. a = stack.pop();
  13955. stack.push(a > b);
  13956. break;
  13957. case 'idiv':
  13958. b = stack.pop();
  13959. a = stack.pop();
  13960. stack.push(a / b | 0);
  13961. break;
  13962. case 'index':
  13963. a = stack.pop();
  13964. stack.index(a);
  13965. break;
  13966. case 'le':
  13967. b = stack.pop();
  13968. a = stack.pop();
  13969. stack.push(a <= b);
  13970. break;
  13971. case 'ln':
  13972. a = stack.pop();
  13973. stack.push(Math.log(a));
  13974. break;
  13975. case 'log':
  13976. a = stack.pop();
  13977. stack.push(Math.log(a) / Math.LN10);
  13978. break;
  13979. case 'lt':
  13980. b = stack.pop();
  13981. a = stack.pop();
  13982. stack.push(a < b);
  13983. break;
  13984. case 'mod':
  13985. b = stack.pop();
  13986. a = stack.pop();
  13987. stack.push(a % b);
  13988. break;
  13989. case 'mul':
  13990. b = stack.pop();
  13991. a = stack.pop();
  13992. stack.push(a * b);
  13993. break;
  13994. case 'ne':
  13995. b = stack.pop();
  13996. a = stack.pop();
  13997. stack.push(a !== b);
  13998. break;
  13999. case 'neg':
  14000. a = stack.pop();
  14001. stack.push(-a);
  14002. break;
  14003. case 'not':
  14004. a = stack.pop();
  14005. if (isBool(a)) {
  14006. stack.push(!a);
  14007. } else {
  14008. stack.push(~a);
  14009. }
  14010. break;
  14011. case 'or':
  14012. b = stack.pop();
  14013. a = stack.pop();
  14014. if (isBool(a) && isBool(b)) {
  14015. stack.push(a || b);
  14016. } else {
  14017. stack.push(a | b);
  14018. }
  14019. break;
  14020. case 'pop':
  14021. stack.pop();
  14022. break;
  14023. case 'roll':
  14024. b = stack.pop();
  14025. a = stack.pop();
  14026. stack.roll(a, b);
  14027. break;
  14028. case 'round':
  14029. a = stack.pop();
  14030. stack.push(Math.round(a));
  14031. break;
  14032. case 'sin':
  14033. a = stack.pop();
  14034. stack.push(Math.sin(a));
  14035. break;
  14036. case 'sqrt':
  14037. a = stack.pop();
  14038. stack.push(Math.sqrt(a));
  14039. break;
  14040. case 'sub':
  14041. b = stack.pop();
  14042. a = stack.pop();
  14043. stack.push(a - b);
  14044. break;
  14045. case 'true':
  14046. stack.push(true);
  14047. break;
  14048. case 'truncate':
  14049. a = stack.pop();
  14050. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  14051. stack.push(a);
  14052. break;
  14053. case 'xor':
  14054. b = stack.pop();
  14055. a = stack.pop();
  14056. if (isBool(a) && isBool(b)) {
  14057. stack.push(a !== b);
  14058. } else {
  14059. stack.push(a ^ b);
  14060. }
  14061. break;
  14062. default:
  14063. error('Unknown operator ' + operator);
  14064. break;
  14065. }
  14066. }
  14067. return stack.stack;
  14068. }
  14069. };
  14070. return PostScriptEvaluator;
  14071. }();
  14072. var PostScriptCompiler = function PostScriptCompilerClosure() {
  14073. function AstNode(type) {
  14074. this.type = type;
  14075. }
  14076. AstNode.prototype.visit = function (visitor) {
  14077. throw new Error('abstract method');
  14078. };
  14079. function AstArgument(index, min, max) {
  14080. AstNode.call(this, 'args');
  14081. this.index = index;
  14082. this.min = min;
  14083. this.max = max;
  14084. }
  14085. AstArgument.prototype = Object.create(AstNode.prototype);
  14086. AstArgument.prototype.visit = function (visitor) {
  14087. visitor.visitArgument(this);
  14088. };
  14089. function AstLiteral(number) {
  14090. AstNode.call(this, 'literal');
  14091. this.number = number;
  14092. this.min = number;
  14093. this.max = number;
  14094. }
  14095. AstLiteral.prototype = Object.create(AstNode.prototype);
  14096. AstLiteral.prototype.visit = function (visitor) {
  14097. visitor.visitLiteral(this);
  14098. };
  14099. function AstBinaryOperation(op, arg1, arg2, min, max) {
  14100. AstNode.call(this, 'binary');
  14101. this.op = op;
  14102. this.arg1 = arg1;
  14103. this.arg2 = arg2;
  14104. this.min = min;
  14105. this.max = max;
  14106. }
  14107. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  14108. AstBinaryOperation.prototype.visit = function (visitor) {
  14109. visitor.visitBinaryOperation(this);
  14110. };
  14111. function AstMin(arg, max) {
  14112. AstNode.call(this, 'max');
  14113. this.arg = arg;
  14114. this.min = arg.min;
  14115. this.max = max;
  14116. }
  14117. AstMin.prototype = Object.create(AstNode.prototype);
  14118. AstMin.prototype.visit = function (visitor) {
  14119. visitor.visitMin(this);
  14120. };
  14121. function AstVariable(index, min, max) {
  14122. AstNode.call(this, 'var');
  14123. this.index = index;
  14124. this.min = min;
  14125. this.max = max;
  14126. }
  14127. AstVariable.prototype = Object.create(AstNode.prototype);
  14128. AstVariable.prototype.visit = function (visitor) {
  14129. visitor.visitVariable(this);
  14130. };
  14131. function AstVariableDefinition(variable, arg) {
  14132. AstNode.call(this, 'definition');
  14133. this.variable = variable;
  14134. this.arg = arg;
  14135. }
  14136. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  14137. AstVariableDefinition.prototype.visit = function (visitor) {
  14138. visitor.visitVariableDefinition(this);
  14139. };
  14140. function ExpressionBuilderVisitor() {
  14141. this.parts = [];
  14142. }
  14143. ExpressionBuilderVisitor.prototype = {
  14144. visitArgument: function (arg) {
  14145. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  14146. },
  14147. visitVariable: function (variable) {
  14148. this.parts.push('v', variable.index);
  14149. },
  14150. visitLiteral: function (literal) {
  14151. this.parts.push(literal.number);
  14152. },
  14153. visitBinaryOperation: function (operation) {
  14154. this.parts.push('(');
  14155. operation.arg1.visit(this);
  14156. this.parts.push(' ', operation.op, ' ');
  14157. operation.arg2.visit(this);
  14158. this.parts.push(')');
  14159. },
  14160. visitVariableDefinition: function (definition) {
  14161. this.parts.push('var ');
  14162. definition.variable.visit(this);
  14163. this.parts.push(' = ');
  14164. definition.arg.visit(this);
  14165. this.parts.push(';');
  14166. },
  14167. visitMin: function (max) {
  14168. this.parts.push('Math.min(');
  14169. max.arg.visit(this);
  14170. this.parts.push(', ', max.max, ')');
  14171. },
  14172. toString: function () {
  14173. return this.parts.join('');
  14174. }
  14175. };
  14176. function buildAddOperation(num1, num2) {
  14177. if (num2.type === 'literal' && num2.number === 0) {
  14178. return num1;
  14179. }
  14180. if (num1.type === 'literal' && num1.number === 0) {
  14181. return num2;
  14182. }
  14183. if (num2.type === 'literal' && num1.type === 'literal') {
  14184. return new AstLiteral(num1.number + num2.number);
  14185. }
  14186. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  14187. }
  14188. function buildMulOperation(num1, num2) {
  14189. if (num2.type === 'literal') {
  14190. if (num2.number === 0) {
  14191. return new AstLiteral(0);
  14192. } else if (num2.number === 1) {
  14193. return num1;
  14194. } else if (num1.type === 'literal') {
  14195. return new AstLiteral(num1.number * num2.number);
  14196. }
  14197. }
  14198. if (num1.type === 'literal') {
  14199. if (num1.number === 0) {
  14200. return new AstLiteral(0);
  14201. } else if (num1.number === 1) {
  14202. return num2;
  14203. }
  14204. }
  14205. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  14206. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  14207. return new AstBinaryOperation('*', num1, num2, min, max);
  14208. }
  14209. function buildSubOperation(num1, num2) {
  14210. if (num2.type === 'literal') {
  14211. if (num2.number === 0) {
  14212. return num1;
  14213. } else if (num1.type === 'literal') {
  14214. return new AstLiteral(num1.number - num2.number);
  14215. }
  14216. }
  14217. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  14218. return num2.arg2;
  14219. }
  14220. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  14221. }
  14222. function buildMinOperation(num1, max) {
  14223. if (num1.min >= max) {
  14224. return new AstLiteral(max);
  14225. } else if (num1.max <= max) {
  14226. return num1;
  14227. }
  14228. return new AstMin(num1, max);
  14229. }
  14230. function PostScriptCompiler() {
  14231. }
  14232. PostScriptCompiler.prototype = {
  14233. compile: function PostScriptCompiler_compile(code, domain, range) {
  14234. var stack = [];
  14235. var i, ii;
  14236. var instructions = [];
  14237. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  14238. var lastRegister = 0;
  14239. var n, j;
  14240. var num1, num2, ast1, ast2, tmpVar, item;
  14241. for (i = 0; i < inputSize; i++) {
  14242. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  14243. }
  14244. for (i = 0, ii = code.length; i < ii; i++) {
  14245. item = code[i];
  14246. if (typeof item === 'number') {
  14247. stack.push(new AstLiteral(item));
  14248. continue;
  14249. }
  14250. switch (item) {
  14251. case 'add':
  14252. if (stack.length < 2) {
  14253. return null;
  14254. }
  14255. num2 = stack.pop();
  14256. num1 = stack.pop();
  14257. stack.push(buildAddOperation(num1, num2));
  14258. break;
  14259. case 'cvr':
  14260. if (stack.length < 1) {
  14261. return null;
  14262. }
  14263. break;
  14264. case 'mul':
  14265. if (stack.length < 2) {
  14266. return null;
  14267. }
  14268. num2 = stack.pop();
  14269. num1 = stack.pop();
  14270. stack.push(buildMulOperation(num1, num2));
  14271. break;
  14272. case 'sub':
  14273. if (stack.length < 2) {
  14274. return null;
  14275. }
  14276. num2 = stack.pop();
  14277. num1 = stack.pop();
  14278. stack.push(buildSubOperation(num1, num2));
  14279. break;
  14280. case 'exch':
  14281. if (stack.length < 2) {
  14282. return null;
  14283. }
  14284. ast1 = stack.pop();
  14285. ast2 = stack.pop();
  14286. stack.push(ast1, ast2);
  14287. break;
  14288. case 'pop':
  14289. if (stack.length < 1) {
  14290. return null;
  14291. }
  14292. stack.pop();
  14293. break;
  14294. case 'index':
  14295. if (stack.length < 1) {
  14296. return null;
  14297. }
  14298. num1 = stack.pop();
  14299. if (num1.type !== 'literal') {
  14300. return null;
  14301. }
  14302. n = num1.number;
  14303. if (n < 0 || (n | 0) !== n || stack.length < n) {
  14304. return null;
  14305. }
  14306. ast1 = stack[stack.length - n - 1];
  14307. if (ast1.type === 'literal' || ast1.type === 'var') {
  14308. stack.push(ast1);
  14309. break;
  14310. }
  14311. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  14312. stack[stack.length - n - 1] = tmpVar;
  14313. stack.push(tmpVar);
  14314. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  14315. break;
  14316. case 'dup':
  14317. if (stack.length < 1) {
  14318. return null;
  14319. }
  14320. 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]) {
  14321. num1 = stack.pop();
  14322. stack.push(buildMinOperation(num1, code[i + 1]));
  14323. i += 6;
  14324. break;
  14325. }
  14326. ast1 = stack[stack.length - 1];
  14327. if (ast1.type === 'literal' || ast1.type === 'var') {
  14328. stack.push(ast1);
  14329. break;
  14330. }
  14331. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  14332. stack[stack.length - 1] = tmpVar;
  14333. stack.push(tmpVar);
  14334. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  14335. break;
  14336. case 'roll':
  14337. if (stack.length < 2) {
  14338. return null;
  14339. }
  14340. num2 = stack.pop();
  14341. num1 = stack.pop();
  14342. if (num2.type !== 'literal' || num1.type !== 'literal') {
  14343. return null;
  14344. }
  14345. j = num2.number;
  14346. n = num1.number;
  14347. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  14348. return null;
  14349. }
  14350. j = (j % n + n) % n;
  14351. if (j === 0) {
  14352. break;
  14353. }
  14354. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  14355. break;
  14356. default:
  14357. return null;
  14358. }
  14359. }
  14360. if (stack.length !== outputSize) {
  14361. return null;
  14362. }
  14363. var result = [];
  14364. instructions.forEach(function (instruction) {
  14365. var statementBuilder = new ExpressionBuilderVisitor();
  14366. instruction.visit(statementBuilder);
  14367. result.push(statementBuilder.toString());
  14368. });
  14369. stack.forEach(function (expr, i) {
  14370. var statementBuilder = new ExpressionBuilderVisitor();
  14371. expr.visit(statementBuilder);
  14372. var min = range[i * 2], max = range[i * 2 + 1];
  14373. var out = [statementBuilder.toString()];
  14374. if (min > expr.min) {
  14375. out.unshift('Math.max(', min, ', ');
  14376. out.push(')');
  14377. }
  14378. if (max < expr.max) {
  14379. out.unshift('Math.min(', max, ', ');
  14380. out.push(')');
  14381. }
  14382. out.unshift('dest[destOffset + ', i, '] = ');
  14383. out.push(';');
  14384. result.push(out.join(''));
  14385. });
  14386. return result.join('\n');
  14387. }
  14388. };
  14389. return PostScriptCompiler;
  14390. }();
  14391. exports.isPDFFunction = isPDFFunction;
  14392. exports.PDFFunction = PDFFunction;
  14393. exports.PostScriptEvaluator = PostScriptEvaluator;
  14394. exports.PostScriptCompiler = PostScriptCompiler;
  14395. /***/ }),
  14396. /* 8 */
  14397. /***/ (function(module, exports, __w_pdfjs_require__) {
  14398. "use strict";
  14399. var sharedUtil = __w_pdfjs_require__(0);
  14400. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  14401. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  14402. t['A'] = 0x0041;
  14403. t['AE'] = 0x00C6;
  14404. t['AEacute'] = 0x01FC;
  14405. t['AEmacron'] = 0x01E2;
  14406. t['AEsmall'] = 0xF7E6;
  14407. t['Aacute'] = 0x00C1;
  14408. t['Aacutesmall'] = 0xF7E1;
  14409. t['Abreve'] = 0x0102;
  14410. t['Abreveacute'] = 0x1EAE;
  14411. t['Abrevecyrillic'] = 0x04D0;
  14412. t['Abrevedotbelow'] = 0x1EB6;
  14413. t['Abrevegrave'] = 0x1EB0;
  14414. t['Abrevehookabove'] = 0x1EB2;
  14415. t['Abrevetilde'] = 0x1EB4;
  14416. t['Acaron'] = 0x01CD;
  14417. t['Acircle'] = 0x24B6;
  14418. t['Acircumflex'] = 0x00C2;
  14419. t['Acircumflexacute'] = 0x1EA4;
  14420. t['Acircumflexdotbelow'] = 0x1EAC;
  14421. t['Acircumflexgrave'] = 0x1EA6;
  14422. t['Acircumflexhookabove'] = 0x1EA8;
  14423. t['Acircumflexsmall'] = 0xF7E2;
  14424. t['Acircumflextilde'] = 0x1EAA;
  14425. t['Acute'] = 0xF6C9;
  14426. t['Acutesmall'] = 0xF7B4;
  14427. t['Acyrillic'] = 0x0410;
  14428. t['Adblgrave'] = 0x0200;
  14429. t['Adieresis'] = 0x00C4;
  14430. t['Adieresiscyrillic'] = 0x04D2;
  14431. t['Adieresismacron'] = 0x01DE;
  14432. t['Adieresissmall'] = 0xF7E4;
  14433. t['Adotbelow'] = 0x1EA0;
  14434. t['Adotmacron'] = 0x01E0;
  14435. t['Agrave'] = 0x00C0;
  14436. t['Agravesmall'] = 0xF7E0;
  14437. t['Ahookabove'] = 0x1EA2;
  14438. t['Aiecyrillic'] = 0x04D4;
  14439. t['Ainvertedbreve'] = 0x0202;
  14440. t['Alpha'] = 0x0391;
  14441. t['Alphatonos'] = 0x0386;
  14442. t['Amacron'] = 0x0100;
  14443. t['Amonospace'] = 0xFF21;
  14444. t['Aogonek'] = 0x0104;
  14445. t['Aring'] = 0x00C5;
  14446. t['Aringacute'] = 0x01FA;
  14447. t['Aringbelow'] = 0x1E00;
  14448. t['Aringsmall'] = 0xF7E5;
  14449. t['Asmall'] = 0xF761;
  14450. t['Atilde'] = 0x00C3;
  14451. t['Atildesmall'] = 0xF7E3;
  14452. t['Aybarmenian'] = 0x0531;
  14453. t['B'] = 0x0042;
  14454. t['Bcircle'] = 0x24B7;
  14455. t['Bdotaccent'] = 0x1E02;
  14456. t['Bdotbelow'] = 0x1E04;
  14457. t['Becyrillic'] = 0x0411;
  14458. t['Benarmenian'] = 0x0532;
  14459. t['Beta'] = 0x0392;
  14460. t['Bhook'] = 0x0181;
  14461. t['Blinebelow'] = 0x1E06;
  14462. t['Bmonospace'] = 0xFF22;
  14463. t['Brevesmall'] = 0xF6F4;
  14464. t['Bsmall'] = 0xF762;
  14465. t['Btopbar'] = 0x0182;
  14466. t['C'] = 0x0043;
  14467. t['Caarmenian'] = 0x053E;
  14468. t['Cacute'] = 0x0106;
  14469. t['Caron'] = 0xF6CA;
  14470. t['Caronsmall'] = 0xF6F5;
  14471. t['Ccaron'] = 0x010C;
  14472. t['Ccedilla'] = 0x00C7;
  14473. t['Ccedillaacute'] = 0x1E08;
  14474. t['Ccedillasmall'] = 0xF7E7;
  14475. t['Ccircle'] = 0x24B8;
  14476. t['Ccircumflex'] = 0x0108;
  14477. t['Cdot'] = 0x010A;
  14478. t['Cdotaccent'] = 0x010A;
  14479. t['Cedillasmall'] = 0xF7B8;
  14480. t['Chaarmenian'] = 0x0549;
  14481. t['Cheabkhasiancyrillic'] = 0x04BC;
  14482. t['Checyrillic'] = 0x0427;
  14483. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  14484. t['Chedescendercyrillic'] = 0x04B6;
  14485. t['Chedieresiscyrillic'] = 0x04F4;
  14486. t['Cheharmenian'] = 0x0543;
  14487. t['Chekhakassiancyrillic'] = 0x04CB;
  14488. t['Cheverticalstrokecyrillic'] = 0x04B8;
  14489. t['Chi'] = 0x03A7;
  14490. t['Chook'] = 0x0187;
  14491. t['Circumflexsmall'] = 0xF6F6;
  14492. t['Cmonospace'] = 0xFF23;
  14493. t['Coarmenian'] = 0x0551;
  14494. t['Csmall'] = 0xF763;
  14495. t['D'] = 0x0044;
  14496. t['DZ'] = 0x01F1;
  14497. t['DZcaron'] = 0x01C4;
  14498. t['Daarmenian'] = 0x0534;
  14499. t['Dafrican'] = 0x0189;
  14500. t['Dcaron'] = 0x010E;
  14501. t['Dcedilla'] = 0x1E10;
  14502. t['Dcircle'] = 0x24B9;
  14503. t['Dcircumflexbelow'] = 0x1E12;
  14504. t['Dcroat'] = 0x0110;
  14505. t['Ddotaccent'] = 0x1E0A;
  14506. t['Ddotbelow'] = 0x1E0C;
  14507. t['Decyrillic'] = 0x0414;
  14508. t['Deicoptic'] = 0x03EE;
  14509. t['Delta'] = 0x2206;
  14510. t['Deltagreek'] = 0x0394;
  14511. t['Dhook'] = 0x018A;
  14512. t['Dieresis'] = 0xF6CB;
  14513. t['DieresisAcute'] = 0xF6CC;
  14514. t['DieresisGrave'] = 0xF6CD;
  14515. t['Dieresissmall'] = 0xF7A8;
  14516. t['Digammagreek'] = 0x03DC;
  14517. t['Djecyrillic'] = 0x0402;
  14518. t['Dlinebelow'] = 0x1E0E;
  14519. t['Dmonospace'] = 0xFF24;
  14520. t['Dotaccentsmall'] = 0xF6F7;
  14521. t['Dslash'] = 0x0110;
  14522. t['Dsmall'] = 0xF764;
  14523. t['Dtopbar'] = 0x018B;
  14524. t['Dz'] = 0x01F2;
  14525. t['Dzcaron'] = 0x01C5;
  14526. t['Dzeabkhasiancyrillic'] = 0x04E0;
  14527. t['Dzecyrillic'] = 0x0405;
  14528. t['Dzhecyrillic'] = 0x040F;
  14529. t['E'] = 0x0045;
  14530. t['Eacute'] = 0x00C9;
  14531. t['Eacutesmall'] = 0xF7E9;
  14532. t['Ebreve'] = 0x0114;
  14533. t['Ecaron'] = 0x011A;
  14534. t['Ecedillabreve'] = 0x1E1C;
  14535. t['Echarmenian'] = 0x0535;
  14536. t['Ecircle'] = 0x24BA;
  14537. t['Ecircumflex'] = 0x00CA;
  14538. t['Ecircumflexacute'] = 0x1EBE;
  14539. t['Ecircumflexbelow'] = 0x1E18;
  14540. t['Ecircumflexdotbelow'] = 0x1EC6;
  14541. t['Ecircumflexgrave'] = 0x1EC0;
  14542. t['Ecircumflexhookabove'] = 0x1EC2;
  14543. t['Ecircumflexsmall'] = 0xF7EA;
  14544. t['Ecircumflextilde'] = 0x1EC4;
  14545. t['Ecyrillic'] = 0x0404;
  14546. t['Edblgrave'] = 0x0204;
  14547. t['Edieresis'] = 0x00CB;
  14548. t['Edieresissmall'] = 0xF7EB;
  14549. t['Edot'] = 0x0116;
  14550. t['Edotaccent'] = 0x0116;
  14551. t['Edotbelow'] = 0x1EB8;
  14552. t['Efcyrillic'] = 0x0424;
  14553. t['Egrave'] = 0x00C8;
  14554. t['Egravesmall'] = 0xF7E8;
  14555. t['Eharmenian'] = 0x0537;
  14556. t['Ehookabove'] = 0x1EBA;
  14557. t['Eightroman'] = 0x2167;
  14558. t['Einvertedbreve'] = 0x0206;
  14559. t['Eiotifiedcyrillic'] = 0x0464;
  14560. t['Elcyrillic'] = 0x041B;
  14561. t['Elevenroman'] = 0x216A;
  14562. t['Emacron'] = 0x0112;
  14563. t['Emacronacute'] = 0x1E16;
  14564. t['Emacrongrave'] = 0x1E14;
  14565. t['Emcyrillic'] = 0x041C;
  14566. t['Emonospace'] = 0xFF25;
  14567. t['Encyrillic'] = 0x041D;
  14568. t['Endescendercyrillic'] = 0x04A2;
  14569. t['Eng'] = 0x014A;
  14570. t['Enghecyrillic'] = 0x04A4;
  14571. t['Enhookcyrillic'] = 0x04C7;
  14572. t['Eogonek'] = 0x0118;
  14573. t['Eopen'] = 0x0190;
  14574. t['Epsilon'] = 0x0395;
  14575. t['Epsilontonos'] = 0x0388;
  14576. t['Ercyrillic'] = 0x0420;
  14577. t['Ereversed'] = 0x018E;
  14578. t['Ereversedcyrillic'] = 0x042D;
  14579. t['Escyrillic'] = 0x0421;
  14580. t['Esdescendercyrillic'] = 0x04AA;
  14581. t['Esh'] = 0x01A9;
  14582. t['Esmall'] = 0xF765;
  14583. t['Eta'] = 0x0397;
  14584. t['Etarmenian'] = 0x0538;
  14585. t['Etatonos'] = 0x0389;
  14586. t['Eth'] = 0x00D0;
  14587. t['Ethsmall'] = 0xF7F0;
  14588. t['Etilde'] = 0x1EBC;
  14589. t['Etildebelow'] = 0x1E1A;
  14590. t['Euro'] = 0x20AC;
  14591. t['Ezh'] = 0x01B7;
  14592. t['Ezhcaron'] = 0x01EE;
  14593. t['Ezhreversed'] = 0x01B8;
  14594. t['F'] = 0x0046;
  14595. t['Fcircle'] = 0x24BB;
  14596. t['Fdotaccent'] = 0x1E1E;
  14597. t['Feharmenian'] = 0x0556;
  14598. t['Feicoptic'] = 0x03E4;
  14599. t['Fhook'] = 0x0191;
  14600. t['Fitacyrillic'] = 0x0472;
  14601. t['Fiveroman'] = 0x2164;
  14602. t['Fmonospace'] = 0xFF26;
  14603. t['Fourroman'] = 0x2163;
  14604. t['Fsmall'] = 0xF766;
  14605. t['G'] = 0x0047;
  14606. t['GBsquare'] = 0x3387;
  14607. t['Gacute'] = 0x01F4;
  14608. t['Gamma'] = 0x0393;
  14609. t['Gammaafrican'] = 0x0194;
  14610. t['Gangiacoptic'] = 0x03EA;
  14611. t['Gbreve'] = 0x011E;
  14612. t['Gcaron'] = 0x01E6;
  14613. t['Gcedilla'] = 0x0122;
  14614. t['Gcircle'] = 0x24BC;
  14615. t['Gcircumflex'] = 0x011C;
  14616. t['Gcommaaccent'] = 0x0122;
  14617. t['Gdot'] = 0x0120;
  14618. t['Gdotaccent'] = 0x0120;
  14619. t['Gecyrillic'] = 0x0413;
  14620. t['Ghadarmenian'] = 0x0542;
  14621. t['Ghemiddlehookcyrillic'] = 0x0494;
  14622. t['Ghestrokecyrillic'] = 0x0492;
  14623. t['Gheupturncyrillic'] = 0x0490;
  14624. t['Ghook'] = 0x0193;
  14625. t['Gimarmenian'] = 0x0533;
  14626. t['Gjecyrillic'] = 0x0403;
  14627. t['Gmacron'] = 0x1E20;
  14628. t['Gmonospace'] = 0xFF27;
  14629. t['Grave'] = 0xF6CE;
  14630. t['Gravesmall'] = 0xF760;
  14631. t['Gsmall'] = 0xF767;
  14632. t['Gsmallhook'] = 0x029B;
  14633. t['Gstroke'] = 0x01E4;
  14634. t['H'] = 0x0048;
  14635. t['H18533'] = 0x25CF;
  14636. t['H18543'] = 0x25AA;
  14637. t['H18551'] = 0x25AB;
  14638. t['H22073'] = 0x25A1;
  14639. t['HPsquare'] = 0x33CB;
  14640. t['Haabkhasiancyrillic'] = 0x04A8;
  14641. t['Hadescendercyrillic'] = 0x04B2;
  14642. t['Hardsigncyrillic'] = 0x042A;
  14643. t['Hbar'] = 0x0126;
  14644. t['Hbrevebelow'] = 0x1E2A;
  14645. t['Hcedilla'] = 0x1E28;
  14646. t['Hcircle'] = 0x24BD;
  14647. t['Hcircumflex'] = 0x0124;
  14648. t['Hdieresis'] = 0x1E26;
  14649. t['Hdotaccent'] = 0x1E22;
  14650. t['Hdotbelow'] = 0x1E24;
  14651. t['Hmonospace'] = 0xFF28;
  14652. t['Hoarmenian'] = 0x0540;
  14653. t['Horicoptic'] = 0x03E8;
  14654. t['Hsmall'] = 0xF768;
  14655. t['Hungarumlaut'] = 0xF6CF;
  14656. t['Hungarumlautsmall'] = 0xF6F8;
  14657. t['Hzsquare'] = 0x3390;
  14658. t['I'] = 0x0049;
  14659. t['IAcyrillic'] = 0x042F;
  14660. t['IJ'] = 0x0132;
  14661. t['IUcyrillic'] = 0x042E;
  14662. t['Iacute'] = 0x00CD;
  14663. t['Iacutesmall'] = 0xF7ED;
  14664. t['Ibreve'] = 0x012C;
  14665. t['Icaron'] = 0x01CF;
  14666. t['Icircle'] = 0x24BE;
  14667. t['Icircumflex'] = 0x00CE;
  14668. t['Icircumflexsmall'] = 0xF7EE;
  14669. t['Icyrillic'] = 0x0406;
  14670. t['Idblgrave'] = 0x0208;
  14671. t['Idieresis'] = 0x00CF;
  14672. t['Idieresisacute'] = 0x1E2E;
  14673. t['Idieresiscyrillic'] = 0x04E4;
  14674. t['Idieresissmall'] = 0xF7EF;
  14675. t['Idot'] = 0x0130;
  14676. t['Idotaccent'] = 0x0130;
  14677. t['Idotbelow'] = 0x1ECA;
  14678. t['Iebrevecyrillic'] = 0x04D6;
  14679. t['Iecyrillic'] = 0x0415;
  14680. t['Ifraktur'] = 0x2111;
  14681. t['Igrave'] = 0x00CC;
  14682. t['Igravesmall'] = 0xF7EC;
  14683. t['Ihookabove'] = 0x1EC8;
  14684. t['Iicyrillic'] = 0x0418;
  14685. t['Iinvertedbreve'] = 0x020A;
  14686. t['Iishortcyrillic'] = 0x0419;
  14687. t['Imacron'] = 0x012A;
  14688. t['Imacroncyrillic'] = 0x04E2;
  14689. t['Imonospace'] = 0xFF29;
  14690. t['Iniarmenian'] = 0x053B;
  14691. t['Iocyrillic'] = 0x0401;
  14692. t['Iogonek'] = 0x012E;
  14693. t['Iota'] = 0x0399;
  14694. t['Iotaafrican'] = 0x0196;
  14695. t['Iotadieresis'] = 0x03AA;
  14696. t['Iotatonos'] = 0x038A;
  14697. t['Ismall'] = 0xF769;
  14698. t['Istroke'] = 0x0197;
  14699. t['Itilde'] = 0x0128;
  14700. t['Itildebelow'] = 0x1E2C;
  14701. t['Izhitsacyrillic'] = 0x0474;
  14702. t['Izhitsadblgravecyrillic'] = 0x0476;
  14703. t['J'] = 0x004A;
  14704. t['Jaarmenian'] = 0x0541;
  14705. t['Jcircle'] = 0x24BF;
  14706. t['Jcircumflex'] = 0x0134;
  14707. t['Jecyrillic'] = 0x0408;
  14708. t['Jheharmenian'] = 0x054B;
  14709. t['Jmonospace'] = 0xFF2A;
  14710. t['Jsmall'] = 0xF76A;
  14711. t['K'] = 0x004B;
  14712. t['KBsquare'] = 0x3385;
  14713. t['KKsquare'] = 0x33CD;
  14714. t['Kabashkircyrillic'] = 0x04A0;
  14715. t['Kacute'] = 0x1E30;
  14716. t['Kacyrillic'] = 0x041A;
  14717. t['Kadescendercyrillic'] = 0x049A;
  14718. t['Kahookcyrillic'] = 0x04C3;
  14719. t['Kappa'] = 0x039A;
  14720. t['Kastrokecyrillic'] = 0x049E;
  14721. t['Kaverticalstrokecyrillic'] = 0x049C;
  14722. t['Kcaron'] = 0x01E8;
  14723. t['Kcedilla'] = 0x0136;
  14724. t['Kcircle'] = 0x24C0;
  14725. t['Kcommaaccent'] = 0x0136;
  14726. t['Kdotbelow'] = 0x1E32;
  14727. t['Keharmenian'] = 0x0554;
  14728. t['Kenarmenian'] = 0x053F;
  14729. t['Khacyrillic'] = 0x0425;
  14730. t['Kheicoptic'] = 0x03E6;
  14731. t['Khook'] = 0x0198;
  14732. t['Kjecyrillic'] = 0x040C;
  14733. t['Klinebelow'] = 0x1E34;
  14734. t['Kmonospace'] = 0xFF2B;
  14735. t['Koppacyrillic'] = 0x0480;
  14736. t['Koppagreek'] = 0x03DE;
  14737. t['Ksicyrillic'] = 0x046E;
  14738. t['Ksmall'] = 0xF76B;
  14739. t['L'] = 0x004C;
  14740. t['LJ'] = 0x01C7;
  14741. t['LL'] = 0xF6BF;
  14742. t['Lacute'] = 0x0139;
  14743. t['Lambda'] = 0x039B;
  14744. t['Lcaron'] = 0x013D;
  14745. t['Lcedilla'] = 0x013B;
  14746. t['Lcircle'] = 0x24C1;
  14747. t['Lcircumflexbelow'] = 0x1E3C;
  14748. t['Lcommaaccent'] = 0x013B;
  14749. t['Ldot'] = 0x013F;
  14750. t['Ldotaccent'] = 0x013F;
  14751. t['Ldotbelow'] = 0x1E36;
  14752. t['Ldotbelowmacron'] = 0x1E38;
  14753. t['Liwnarmenian'] = 0x053C;
  14754. t['Lj'] = 0x01C8;
  14755. t['Ljecyrillic'] = 0x0409;
  14756. t['Llinebelow'] = 0x1E3A;
  14757. t['Lmonospace'] = 0xFF2C;
  14758. t['Lslash'] = 0x0141;
  14759. t['Lslashsmall'] = 0xF6F9;
  14760. t['Lsmall'] = 0xF76C;
  14761. t['M'] = 0x004D;
  14762. t['MBsquare'] = 0x3386;
  14763. t['Macron'] = 0xF6D0;
  14764. t['Macronsmall'] = 0xF7AF;
  14765. t['Macute'] = 0x1E3E;
  14766. t['Mcircle'] = 0x24C2;
  14767. t['Mdotaccent'] = 0x1E40;
  14768. t['Mdotbelow'] = 0x1E42;
  14769. t['Menarmenian'] = 0x0544;
  14770. t['Mmonospace'] = 0xFF2D;
  14771. t['Msmall'] = 0xF76D;
  14772. t['Mturned'] = 0x019C;
  14773. t['Mu'] = 0x039C;
  14774. t['N'] = 0x004E;
  14775. t['NJ'] = 0x01CA;
  14776. t['Nacute'] = 0x0143;
  14777. t['Ncaron'] = 0x0147;
  14778. t['Ncedilla'] = 0x0145;
  14779. t['Ncircle'] = 0x24C3;
  14780. t['Ncircumflexbelow'] = 0x1E4A;
  14781. t['Ncommaaccent'] = 0x0145;
  14782. t['Ndotaccent'] = 0x1E44;
  14783. t['Ndotbelow'] = 0x1E46;
  14784. t['Nhookleft'] = 0x019D;
  14785. t['Nineroman'] = 0x2168;
  14786. t['Nj'] = 0x01CB;
  14787. t['Njecyrillic'] = 0x040A;
  14788. t['Nlinebelow'] = 0x1E48;
  14789. t['Nmonospace'] = 0xFF2E;
  14790. t['Nowarmenian'] = 0x0546;
  14791. t['Nsmall'] = 0xF76E;
  14792. t['Ntilde'] = 0x00D1;
  14793. t['Ntildesmall'] = 0xF7F1;
  14794. t['Nu'] = 0x039D;
  14795. t['O'] = 0x004F;
  14796. t['OE'] = 0x0152;
  14797. t['OEsmall'] = 0xF6FA;
  14798. t['Oacute'] = 0x00D3;
  14799. t['Oacutesmall'] = 0xF7F3;
  14800. t['Obarredcyrillic'] = 0x04E8;
  14801. t['Obarreddieresiscyrillic'] = 0x04EA;
  14802. t['Obreve'] = 0x014E;
  14803. t['Ocaron'] = 0x01D1;
  14804. t['Ocenteredtilde'] = 0x019F;
  14805. t['Ocircle'] = 0x24C4;
  14806. t['Ocircumflex'] = 0x00D4;
  14807. t['Ocircumflexacute'] = 0x1ED0;
  14808. t['Ocircumflexdotbelow'] = 0x1ED8;
  14809. t['Ocircumflexgrave'] = 0x1ED2;
  14810. t['Ocircumflexhookabove'] = 0x1ED4;
  14811. t['Ocircumflexsmall'] = 0xF7F4;
  14812. t['Ocircumflextilde'] = 0x1ED6;
  14813. t['Ocyrillic'] = 0x041E;
  14814. t['Odblacute'] = 0x0150;
  14815. t['Odblgrave'] = 0x020C;
  14816. t['Odieresis'] = 0x00D6;
  14817. t['Odieresiscyrillic'] = 0x04E6;
  14818. t['Odieresissmall'] = 0xF7F6;
  14819. t['Odotbelow'] = 0x1ECC;
  14820. t['Ogoneksmall'] = 0xF6FB;
  14821. t['Ograve'] = 0x00D2;
  14822. t['Ogravesmall'] = 0xF7F2;
  14823. t['Oharmenian'] = 0x0555;
  14824. t['Ohm'] = 0x2126;
  14825. t['Ohookabove'] = 0x1ECE;
  14826. t['Ohorn'] = 0x01A0;
  14827. t['Ohornacute'] = 0x1EDA;
  14828. t['Ohorndotbelow'] = 0x1EE2;
  14829. t['Ohorngrave'] = 0x1EDC;
  14830. t['Ohornhookabove'] = 0x1EDE;
  14831. t['Ohorntilde'] = 0x1EE0;
  14832. t['Ohungarumlaut'] = 0x0150;
  14833. t['Oi'] = 0x01A2;
  14834. t['Oinvertedbreve'] = 0x020E;
  14835. t['Omacron'] = 0x014C;
  14836. t['Omacronacute'] = 0x1E52;
  14837. t['Omacrongrave'] = 0x1E50;
  14838. t['Omega'] = 0x2126;
  14839. t['Omegacyrillic'] = 0x0460;
  14840. t['Omegagreek'] = 0x03A9;
  14841. t['Omegaroundcyrillic'] = 0x047A;
  14842. t['Omegatitlocyrillic'] = 0x047C;
  14843. t['Omegatonos'] = 0x038F;
  14844. t['Omicron'] = 0x039F;
  14845. t['Omicrontonos'] = 0x038C;
  14846. t['Omonospace'] = 0xFF2F;
  14847. t['Oneroman'] = 0x2160;
  14848. t['Oogonek'] = 0x01EA;
  14849. t['Oogonekmacron'] = 0x01EC;
  14850. t['Oopen'] = 0x0186;
  14851. t['Oslash'] = 0x00D8;
  14852. t['Oslashacute'] = 0x01FE;
  14853. t['Oslashsmall'] = 0xF7F8;
  14854. t['Osmall'] = 0xF76F;
  14855. t['Ostrokeacute'] = 0x01FE;
  14856. t['Otcyrillic'] = 0x047E;
  14857. t['Otilde'] = 0x00D5;
  14858. t['Otildeacute'] = 0x1E4C;
  14859. t['Otildedieresis'] = 0x1E4E;
  14860. t['Otildesmall'] = 0xF7F5;
  14861. t['P'] = 0x0050;
  14862. t['Pacute'] = 0x1E54;
  14863. t['Pcircle'] = 0x24C5;
  14864. t['Pdotaccent'] = 0x1E56;
  14865. t['Pecyrillic'] = 0x041F;
  14866. t['Peharmenian'] = 0x054A;
  14867. t['Pemiddlehookcyrillic'] = 0x04A6;
  14868. t['Phi'] = 0x03A6;
  14869. t['Phook'] = 0x01A4;
  14870. t['Pi'] = 0x03A0;
  14871. t['Piwrarmenian'] = 0x0553;
  14872. t['Pmonospace'] = 0xFF30;
  14873. t['Psi'] = 0x03A8;
  14874. t['Psicyrillic'] = 0x0470;
  14875. t['Psmall'] = 0xF770;
  14876. t['Q'] = 0x0051;
  14877. t['Qcircle'] = 0x24C6;
  14878. t['Qmonospace'] = 0xFF31;
  14879. t['Qsmall'] = 0xF771;
  14880. t['R'] = 0x0052;
  14881. t['Raarmenian'] = 0x054C;
  14882. t['Racute'] = 0x0154;
  14883. t['Rcaron'] = 0x0158;
  14884. t['Rcedilla'] = 0x0156;
  14885. t['Rcircle'] = 0x24C7;
  14886. t['Rcommaaccent'] = 0x0156;
  14887. t['Rdblgrave'] = 0x0210;
  14888. t['Rdotaccent'] = 0x1E58;
  14889. t['Rdotbelow'] = 0x1E5A;
  14890. t['Rdotbelowmacron'] = 0x1E5C;
  14891. t['Reharmenian'] = 0x0550;
  14892. t['Rfraktur'] = 0x211C;
  14893. t['Rho'] = 0x03A1;
  14894. t['Ringsmall'] = 0xF6FC;
  14895. t['Rinvertedbreve'] = 0x0212;
  14896. t['Rlinebelow'] = 0x1E5E;
  14897. t['Rmonospace'] = 0xFF32;
  14898. t['Rsmall'] = 0xF772;
  14899. t['Rsmallinverted'] = 0x0281;
  14900. t['Rsmallinvertedsuperior'] = 0x02B6;
  14901. t['S'] = 0x0053;
  14902. t['SF010000'] = 0x250C;
  14903. t['SF020000'] = 0x2514;
  14904. t['SF030000'] = 0x2510;
  14905. t['SF040000'] = 0x2518;
  14906. t['SF050000'] = 0x253C;
  14907. t['SF060000'] = 0x252C;
  14908. t['SF070000'] = 0x2534;
  14909. t['SF080000'] = 0x251C;
  14910. t['SF090000'] = 0x2524;
  14911. t['SF100000'] = 0x2500;
  14912. t['SF110000'] = 0x2502;
  14913. t['SF190000'] = 0x2561;
  14914. t['SF200000'] = 0x2562;
  14915. t['SF210000'] = 0x2556;
  14916. t['SF220000'] = 0x2555;
  14917. t['SF230000'] = 0x2563;
  14918. t['SF240000'] = 0x2551;
  14919. t['SF250000'] = 0x2557;
  14920. t['SF260000'] = 0x255D;
  14921. t['SF270000'] = 0x255C;
  14922. t['SF280000'] = 0x255B;
  14923. t['SF360000'] = 0x255E;
  14924. t['SF370000'] = 0x255F;
  14925. t['SF380000'] = 0x255A;
  14926. t['SF390000'] = 0x2554;
  14927. t['SF400000'] = 0x2569;
  14928. t['SF410000'] = 0x2566;
  14929. t['SF420000'] = 0x2560;
  14930. t['SF430000'] = 0x2550;
  14931. t['SF440000'] = 0x256C;
  14932. t['SF450000'] = 0x2567;
  14933. t['SF460000'] = 0x2568;
  14934. t['SF470000'] = 0x2564;
  14935. t['SF480000'] = 0x2565;
  14936. t['SF490000'] = 0x2559;
  14937. t['SF500000'] = 0x2558;
  14938. t['SF510000'] = 0x2552;
  14939. t['SF520000'] = 0x2553;
  14940. t['SF530000'] = 0x256B;
  14941. t['SF540000'] = 0x256A;
  14942. t['Sacute'] = 0x015A;
  14943. t['Sacutedotaccent'] = 0x1E64;
  14944. t['Sampigreek'] = 0x03E0;
  14945. t['Scaron'] = 0x0160;
  14946. t['Scarondotaccent'] = 0x1E66;
  14947. t['Scaronsmall'] = 0xF6FD;
  14948. t['Scedilla'] = 0x015E;
  14949. t['Schwa'] = 0x018F;
  14950. t['Schwacyrillic'] = 0x04D8;
  14951. t['Schwadieresiscyrillic'] = 0x04DA;
  14952. t['Scircle'] = 0x24C8;
  14953. t['Scircumflex'] = 0x015C;
  14954. t['Scommaaccent'] = 0x0218;
  14955. t['Sdotaccent'] = 0x1E60;
  14956. t['Sdotbelow'] = 0x1E62;
  14957. t['Sdotbelowdotaccent'] = 0x1E68;
  14958. t['Seharmenian'] = 0x054D;
  14959. t['Sevenroman'] = 0x2166;
  14960. t['Shaarmenian'] = 0x0547;
  14961. t['Shacyrillic'] = 0x0428;
  14962. t['Shchacyrillic'] = 0x0429;
  14963. t['Sheicoptic'] = 0x03E2;
  14964. t['Shhacyrillic'] = 0x04BA;
  14965. t['Shimacoptic'] = 0x03EC;
  14966. t['Sigma'] = 0x03A3;
  14967. t['Sixroman'] = 0x2165;
  14968. t['Smonospace'] = 0xFF33;
  14969. t['Softsigncyrillic'] = 0x042C;
  14970. t['Ssmall'] = 0xF773;
  14971. t['Stigmagreek'] = 0x03DA;
  14972. t['T'] = 0x0054;
  14973. t['Tau'] = 0x03A4;
  14974. t['Tbar'] = 0x0166;
  14975. t['Tcaron'] = 0x0164;
  14976. t['Tcedilla'] = 0x0162;
  14977. t['Tcircle'] = 0x24C9;
  14978. t['Tcircumflexbelow'] = 0x1E70;
  14979. t['Tcommaaccent'] = 0x0162;
  14980. t['Tdotaccent'] = 0x1E6A;
  14981. t['Tdotbelow'] = 0x1E6C;
  14982. t['Tecyrillic'] = 0x0422;
  14983. t['Tedescendercyrillic'] = 0x04AC;
  14984. t['Tenroman'] = 0x2169;
  14985. t['Tetsecyrillic'] = 0x04B4;
  14986. t['Theta'] = 0x0398;
  14987. t['Thook'] = 0x01AC;
  14988. t['Thorn'] = 0x00DE;
  14989. t['Thornsmall'] = 0xF7FE;
  14990. t['Threeroman'] = 0x2162;
  14991. t['Tildesmall'] = 0xF6FE;
  14992. t['Tiwnarmenian'] = 0x054F;
  14993. t['Tlinebelow'] = 0x1E6E;
  14994. t['Tmonospace'] = 0xFF34;
  14995. t['Toarmenian'] = 0x0539;
  14996. t['Tonefive'] = 0x01BC;
  14997. t['Tonesix'] = 0x0184;
  14998. t['Tonetwo'] = 0x01A7;
  14999. t['Tretroflexhook'] = 0x01AE;
  15000. t['Tsecyrillic'] = 0x0426;
  15001. t['Tshecyrillic'] = 0x040B;
  15002. t['Tsmall'] = 0xF774;
  15003. t['Twelveroman'] = 0x216B;
  15004. t['Tworoman'] = 0x2161;
  15005. t['U'] = 0x0055;
  15006. t['Uacute'] = 0x00DA;
  15007. t['Uacutesmall'] = 0xF7FA;
  15008. t['Ubreve'] = 0x016C;
  15009. t['Ucaron'] = 0x01D3;
  15010. t['Ucircle'] = 0x24CA;
  15011. t['Ucircumflex'] = 0x00DB;
  15012. t['Ucircumflexbelow'] = 0x1E76;
  15013. t['Ucircumflexsmall'] = 0xF7FB;
  15014. t['Ucyrillic'] = 0x0423;
  15015. t['Udblacute'] = 0x0170;
  15016. t['Udblgrave'] = 0x0214;
  15017. t['Udieresis'] = 0x00DC;
  15018. t['Udieresisacute'] = 0x01D7;
  15019. t['Udieresisbelow'] = 0x1E72;
  15020. t['Udieresiscaron'] = 0x01D9;
  15021. t['Udieresiscyrillic'] = 0x04F0;
  15022. t['Udieresisgrave'] = 0x01DB;
  15023. t['Udieresismacron'] = 0x01D5;
  15024. t['Udieresissmall'] = 0xF7FC;
  15025. t['Udotbelow'] = 0x1EE4;
  15026. t['Ugrave'] = 0x00D9;
  15027. t['Ugravesmall'] = 0xF7F9;
  15028. t['Uhookabove'] = 0x1EE6;
  15029. t['Uhorn'] = 0x01AF;
  15030. t['Uhornacute'] = 0x1EE8;
  15031. t['Uhorndotbelow'] = 0x1EF0;
  15032. t['Uhorngrave'] = 0x1EEA;
  15033. t['Uhornhookabove'] = 0x1EEC;
  15034. t['Uhorntilde'] = 0x1EEE;
  15035. t['Uhungarumlaut'] = 0x0170;
  15036. t['Uhungarumlautcyrillic'] = 0x04F2;
  15037. t['Uinvertedbreve'] = 0x0216;
  15038. t['Ukcyrillic'] = 0x0478;
  15039. t['Umacron'] = 0x016A;
  15040. t['Umacroncyrillic'] = 0x04EE;
  15041. t['Umacrondieresis'] = 0x1E7A;
  15042. t['Umonospace'] = 0xFF35;
  15043. t['Uogonek'] = 0x0172;
  15044. t['Upsilon'] = 0x03A5;
  15045. t['Upsilon1'] = 0x03D2;
  15046. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  15047. t['Upsilonafrican'] = 0x01B1;
  15048. t['Upsilondieresis'] = 0x03AB;
  15049. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  15050. t['Upsilonhooksymbol'] = 0x03D2;
  15051. t['Upsilontonos'] = 0x038E;
  15052. t['Uring'] = 0x016E;
  15053. t['Ushortcyrillic'] = 0x040E;
  15054. t['Usmall'] = 0xF775;
  15055. t['Ustraightcyrillic'] = 0x04AE;
  15056. t['Ustraightstrokecyrillic'] = 0x04B0;
  15057. t['Utilde'] = 0x0168;
  15058. t['Utildeacute'] = 0x1E78;
  15059. t['Utildebelow'] = 0x1E74;
  15060. t['V'] = 0x0056;
  15061. t['Vcircle'] = 0x24CB;
  15062. t['Vdotbelow'] = 0x1E7E;
  15063. t['Vecyrillic'] = 0x0412;
  15064. t['Vewarmenian'] = 0x054E;
  15065. t['Vhook'] = 0x01B2;
  15066. t['Vmonospace'] = 0xFF36;
  15067. t['Voarmenian'] = 0x0548;
  15068. t['Vsmall'] = 0xF776;
  15069. t['Vtilde'] = 0x1E7C;
  15070. t['W'] = 0x0057;
  15071. t['Wacute'] = 0x1E82;
  15072. t['Wcircle'] = 0x24CC;
  15073. t['Wcircumflex'] = 0x0174;
  15074. t['Wdieresis'] = 0x1E84;
  15075. t['Wdotaccent'] = 0x1E86;
  15076. t['Wdotbelow'] = 0x1E88;
  15077. t['Wgrave'] = 0x1E80;
  15078. t['Wmonospace'] = 0xFF37;
  15079. t['Wsmall'] = 0xF777;
  15080. t['X'] = 0x0058;
  15081. t['Xcircle'] = 0x24CD;
  15082. t['Xdieresis'] = 0x1E8C;
  15083. t['Xdotaccent'] = 0x1E8A;
  15084. t['Xeharmenian'] = 0x053D;
  15085. t['Xi'] = 0x039E;
  15086. t['Xmonospace'] = 0xFF38;
  15087. t['Xsmall'] = 0xF778;
  15088. t['Y'] = 0x0059;
  15089. t['Yacute'] = 0x00DD;
  15090. t['Yacutesmall'] = 0xF7FD;
  15091. t['Yatcyrillic'] = 0x0462;
  15092. t['Ycircle'] = 0x24CE;
  15093. t['Ycircumflex'] = 0x0176;
  15094. t['Ydieresis'] = 0x0178;
  15095. t['Ydieresissmall'] = 0xF7FF;
  15096. t['Ydotaccent'] = 0x1E8E;
  15097. t['Ydotbelow'] = 0x1EF4;
  15098. t['Yericyrillic'] = 0x042B;
  15099. t['Yerudieresiscyrillic'] = 0x04F8;
  15100. t['Ygrave'] = 0x1EF2;
  15101. t['Yhook'] = 0x01B3;
  15102. t['Yhookabove'] = 0x1EF6;
  15103. t['Yiarmenian'] = 0x0545;
  15104. t['Yicyrillic'] = 0x0407;
  15105. t['Yiwnarmenian'] = 0x0552;
  15106. t['Ymonospace'] = 0xFF39;
  15107. t['Ysmall'] = 0xF779;
  15108. t['Ytilde'] = 0x1EF8;
  15109. t['Yusbigcyrillic'] = 0x046A;
  15110. t['Yusbigiotifiedcyrillic'] = 0x046C;
  15111. t['Yuslittlecyrillic'] = 0x0466;
  15112. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  15113. t['Z'] = 0x005A;
  15114. t['Zaarmenian'] = 0x0536;
  15115. t['Zacute'] = 0x0179;
  15116. t['Zcaron'] = 0x017D;
  15117. t['Zcaronsmall'] = 0xF6FF;
  15118. t['Zcircle'] = 0x24CF;
  15119. t['Zcircumflex'] = 0x1E90;
  15120. t['Zdot'] = 0x017B;
  15121. t['Zdotaccent'] = 0x017B;
  15122. t['Zdotbelow'] = 0x1E92;
  15123. t['Zecyrillic'] = 0x0417;
  15124. t['Zedescendercyrillic'] = 0x0498;
  15125. t['Zedieresiscyrillic'] = 0x04DE;
  15126. t['Zeta'] = 0x0396;
  15127. t['Zhearmenian'] = 0x053A;
  15128. t['Zhebrevecyrillic'] = 0x04C1;
  15129. t['Zhecyrillic'] = 0x0416;
  15130. t['Zhedescendercyrillic'] = 0x0496;
  15131. t['Zhedieresiscyrillic'] = 0x04DC;
  15132. t['Zlinebelow'] = 0x1E94;
  15133. t['Zmonospace'] = 0xFF3A;
  15134. t['Zsmall'] = 0xF77A;
  15135. t['Zstroke'] = 0x01B5;
  15136. t['a'] = 0x0061;
  15137. t['aabengali'] = 0x0986;
  15138. t['aacute'] = 0x00E1;
  15139. t['aadeva'] = 0x0906;
  15140. t['aagujarati'] = 0x0A86;
  15141. t['aagurmukhi'] = 0x0A06;
  15142. t['aamatragurmukhi'] = 0x0A3E;
  15143. t['aarusquare'] = 0x3303;
  15144. t['aavowelsignbengali'] = 0x09BE;
  15145. t['aavowelsigndeva'] = 0x093E;
  15146. t['aavowelsigngujarati'] = 0x0ABE;
  15147. t['abbreviationmarkarmenian'] = 0x055F;
  15148. t['abbreviationsigndeva'] = 0x0970;
  15149. t['abengali'] = 0x0985;
  15150. t['abopomofo'] = 0x311A;
  15151. t['abreve'] = 0x0103;
  15152. t['abreveacute'] = 0x1EAF;
  15153. t['abrevecyrillic'] = 0x04D1;
  15154. t['abrevedotbelow'] = 0x1EB7;
  15155. t['abrevegrave'] = 0x1EB1;
  15156. t['abrevehookabove'] = 0x1EB3;
  15157. t['abrevetilde'] = 0x1EB5;
  15158. t['acaron'] = 0x01CE;
  15159. t['acircle'] = 0x24D0;
  15160. t['acircumflex'] = 0x00E2;
  15161. t['acircumflexacute'] = 0x1EA5;
  15162. t['acircumflexdotbelow'] = 0x1EAD;
  15163. t['acircumflexgrave'] = 0x1EA7;
  15164. t['acircumflexhookabove'] = 0x1EA9;
  15165. t['acircumflextilde'] = 0x1EAB;
  15166. t['acute'] = 0x00B4;
  15167. t['acutebelowcmb'] = 0x0317;
  15168. t['acutecmb'] = 0x0301;
  15169. t['acutecomb'] = 0x0301;
  15170. t['acutedeva'] = 0x0954;
  15171. t['acutelowmod'] = 0x02CF;
  15172. t['acutetonecmb'] = 0x0341;
  15173. t['acyrillic'] = 0x0430;
  15174. t['adblgrave'] = 0x0201;
  15175. t['addakgurmukhi'] = 0x0A71;
  15176. t['adeva'] = 0x0905;
  15177. t['adieresis'] = 0x00E4;
  15178. t['adieresiscyrillic'] = 0x04D3;
  15179. t['adieresismacron'] = 0x01DF;
  15180. t['adotbelow'] = 0x1EA1;
  15181. t['adotmacron'] = 0x01E1;
  15182. t['ae'] = 0x00E6;
  15183. t['aeacute'] = 0x01FD;
  15184. t['aekorean'] = 0x3150;
  15185. t['aemacron'] = 0x01E3;
  15186. t['afii00208'] = 0x2015;
  15187. t['afii08941'] = 0x20A4;
  15188. t['afii10017'] = 0x0410;
  15189. t['afii10018'] = 0x0411;
  15190. t['afii10019'] = 0x0412;
  15191. t['afii10020'] = 0x0413;
  15192. t['afii10021'] = 0x0414;
  15193. t['afii10022'] = 0x0415;
  15194. t['afii10023'] = 0x0401;
  15195. t['afii10024'] = 0x0416;
  15196. t['afii10025'] = 0x0417;
  15197. t['afii10026'] = 0x0418;
  15198. t['afii10027'] = 0x0419;
  15199. t['afii10028'] = 0x041A;
  15200. t['afii10029'] = 0x041B;
  15201. t['afii10030'] = 0x041C;
  15202. t['afii10031'] = 0x041D;
  15203. t['afii10032'] = 0x041E;
  15204. t['afii10033'] = 0x041F;
  15205. t['afii10034'] = 0x0420;
  15206. t['afii10035'] = 0x0421;
  15207. t['afii10036'] = 0x0422;
  15208. t['afii10037'] = 0x0423;
  15209. t['afii10038'] = 0x0424;
  15210. t['afii10039'] = 0x0425;
  15211. t['afii10040'] = 0x0426;
  15212. t['afii10041'] = 0x0427;
  15213. t['afii10042'] = 0x0428;
  15214. t['afii10043'] = 0x0429;
  15215. t['afii10044'] = 0x042A;
  15216. t['afii10045'] = 0x042B;
  15217. t['afii10046'] = 0x042C;
  15218. t['afii10047'] = 0x042D;
  15219. t['afii10048'] = 0x042E;
  15220. t['afii10049'] = 0x042F;
  15221. t['afii10050'] = 0x0490;
  15222. t['afii10051'] = 0x0402;
  15223. t['afii10052'] = 0x0403;
  15224. t['afii10053'] = 0x0404;
  15225. t['afii10054'] = 0x0405;
  15226. t['afii10055'] = 0x0406;
  15227. t['afii10056'] = 0x0407;
  15228. t['afii10057'] = 0x0408;
  15229. t['afii10058'] = 0x0409;
  15230. t['afii10059'] = 0x040A;
  15231. t['afii10060'] = 0x040B;
  15232. t['afii10061'] = 0x040C;
  15233. t['afii10062'] = 0x040E;
  15234. t['afii10063'] = 0xF6C4;
  15235. t['afii10064'] = 0xF6C5;
  15236. t['afii10065'] = 0x0430;
  15237. t['afii10066'] = 0x0431;
  15238. t['afii10067'] = 0x0432;
  15239. t['afii10068'] = 0x0433;
  15240. t['afii10069'] = 0x0434;
  15241. t['afii10070'] = 0x0435;
  15242. t['afii10071'] = 0x0451;
  15243. t['afii10072'] = 0x0436;
  15244. t['afii10073'] = 0x0437;
  15245. t['afii10074'] = 0x0438;
  15246. t['afii10075'] = 0x0439;
  15247. t['afii10076'] = 0x043A;
  15248. t['afii10077'] = 0x043B;
  15249. t['afii10078'] = 0x043C;
  15250. t['afii10079'] = 0x043D;
  15251. t['afii10080'] = 0x043E;
  15252. t['afii10081'] = 0x043F;
  15253. t['afii10082'] = 0x0440;
  15254. t['afii10083'] = 0x0441;
  15255. t['afii10084'] = 0x0442;
  15256. t['afii10085'] = 0x0443;
  15257. t['afii10086'] = 0x0444;
  15258. t['afii10087'] = 0x0445;
  15259. t['afii10088'] = 0x0446;
  15260. t['afii10089'] = 0x0447;
  15261. t['afii10090'] = 0x0448;
  15262. t['afii10091'] = 0x0449;
  15263. t['afii10092'] = 0x044A;
  15264. t['afii10093'] = 0x044B;
  15265. t['afii10094'] = 0x044C;
  15266. t['afii10095'] = 0x044D;
  15267. t['afii10096'] = 0x044E;
  15268. t['afii10097'] = 0x044F;
  15269. t['afii10098'] = 0x0491;
  15270. t['afii10099'] = 0x0452;
  15271. t['afii10100'] = 0x0453;
  15272. t['afii10101'] = 0x0454;
  15273. t['afii10102'] = 0x0455;
  15274. t['afii10103'] = 0x0456;
  15275. t['afii10104'] = 0x0457;
  15276. t['afii10105'] = 0x0458;
  15277. t['afii10106'] = 0x0459;
  15278. t['afii10107'] = 0x045A;
  15279. t['afii10108'] = 0x045B;
  15280. t['afii10109'] = 0x045C;
  15281. t['afii10110'] = 0x045E;
  15282. t['afii10145'] = 0x040F;
  15283. t['afii10146'] = 0x0462;
  15284. t['afii10147'] = 0x0472;
  15285. t['afii10148'] = 0x0474;
  15286. t['afii10192'] = 0xF6C6;
  15287. t['afii10193'] = 0x045F;
  15288. t['afii10194'] = 0x0463;
  15289. t['afii10195'] = 0x0473;
  15290. t['afii10196'] = 0x0475;
  15291. t['afii10831'] = 0xF6C7;
  15292. t['afii10832'] = 0xF6C8;
  15293. t['afii10846'] = 0x04D9;
  15294. t['afii299'] = 0x200E;
  15295. t['afii300'] = 0x200F;
  15296. t['afii301'] = 0x200D;
  15297. t['afii57381'] = 0x066A;
  15298. t['afii57388'] = 0x060C;
  15299. t['afii57392'] = 0x0660;
  15300. t['afii57393'] = 0x0661;
  15301. t['afii57394'] = 0x0662;
  15302. t['afii57395'] = 0x0663;
  15303. t['afii57396'] = 0x0664;
  15304. t['afii57397'] = 0x0665;
  15305. t['afii57398'] = 0x0666;
  15306. t['afii57399'] = 0x0667;
  15307. t['afii57400'] = 0x0668;
  15308. t['afii57401'] = 0x0669;
  15309. t['afii57403'] = 0x061B;
  15310. t['afii57407'] = 0x061F;
  15311. t['afii57409'] = 0x0621;
  15312. t['afii57410'] = 0x0622;
  15313. t['afii57411'] = 0x0623;
  15314. t['afii57412'] = 0x0624;
  15315. t['afii57413'] = 0x0625;
  15316. t['afii57414'] = 0x0626;
  15317. t['afii57415'] = 0x0627;
  15318. t['afii57416'] = 0x0628;
  15319. t['afii57417'] = 0x0629;
  15320. t['afii57418'] = 0x062A;
  15321. t['afii57419'] = 0x062B;
  15322. t['afii57420'] = 0x062C;
  15323. t['afii57421'] = 0x062D;
  15324. t['afii57422'] = 0x062E;
  15325. t['afii57423'] = 0x062F;
  15326. t['afii57424'] = 0x0630;
  15327. t['afii57425'] = 0x0631;
  15328. t['afii57426'] = 0x0632;
  15329. t['afii57427'] = 0x0633;
  15330. t['afii57428'] = 0x0634;
  15331. t['afii57429'] = 0x0635;
  15332. t['afii57430'] = 0x0636;
  15333. t['afii57431'] = 0x0637;
  15334. t['afii57432'] = 0x0638;
  15335. t['afii57433'] = 0x0639;
  15336. t['afii57434'] = 0x063A;
  15337. t['afii57440'] = 0x0640;
  15338. t['afii57441'] = 0x0641;
  15339. t['afii57442'] = 0x0642;
  15340. t['afii57443'] = 0x0643;
  15341. t['afii57444'] = 0x0644;
  15342. t['afii57445'] = 0x0645;
  15343. t['afii57446'] = 0x0646;
  15344. t['afii57448'] = 0x0648;
  15345. t['afii57449'] = 0x0649;
  15346. t['afii57450'] = 0x064A;
  15347. t['afii57451'] = 0x064B;
  15348. t['afii57452'] = 0x064C;
  15349. t['afii57453'] = 0x064D;
  15350. t['afii57454'] = 0x064E;
  15351. t['afii57455'] = 0x064F;
  15352. t['afii57456'] = 0x0650;
  15353. t['afii57457'] = 0x0651;
  15354. t['afii57458'] = 0x0652;
  15355. t['afii57470'] = 0x0647;
  15356. t['afii57505'] = 0x06A4;
  15357. t['afii57506'] = 0x067E;
  15358. t['afii57507'] = 0x0686;
  15359. t['afii57508'] = 0x0698;
  15360. t['afii57509'] = 0x06AF;
  15361. t['afii57511'] = 0x0679;
  15362. t['afii57512'] = 0x0688;
  15363. t['afii57513'] = 0x0691;
  15364. t['afii57514'] = 0x06BA;
  15365. t['afii57519'] = 0x06D2;
  15366. t['afii57534'] = 0x06D5;
  15367. t['afii57636'] = 0x20AA;
  15368. t['afii57645'] = 0x05BE;
  15369. t['afii57658'] = 0x05C3;
  15370. t['afii57664'] = 0x05D0;
  15371. t['afii57665'] = 0x05D1;
  15372. t['afii57666'] = 0x05D2;
  15373. t['afii57667'] = 0x05D3;
  15374. t['afii57668'] = 0x05D4;
  15375. t['afii57669'] = 0x05D5;
  15376. t['afii57670'] = 0x05D6;
  15377. t['afii57671'] = 0x05D7;
  15378. t['afii57672'] = 0x05D8;
  15379. t['afii57673'] = 0x05D9;
  15380. t['afii57674'] = 0x05DA;
  15381. t['afii57675'] = 0x05DB;
  15382. t['afii57676'] = 0x05DC;
  15383. t['afii57677'] = 0x05DD;
  15384. t['afii57678'] = 0x05DE;
  15385. t['afii57679'] = 0x05DF;
  15386. t['afii57680'] = 0x05E0;
  15387. t['afii57681'] = 0x05E1;
  15388. t['afii57682'] = 0x05E2;
  15389. t['afii57683'] = 0x05E3;
  15390. t['afii57684'] = 0x05E4;
  15391. t['afii57685'] = 0x05E5;
  15392. t['afii57686'] = 0x05E6;
  15393. t['afii57687'] = 0x05E7;
  15394. t['afii57688'] = 0x05E8;
  15395. t['afii57689'] = 0x05E9;
  15396. t['afii57690'] = 0x05EA;
  15397. t['afii57694'] = 0xFB2A;
  15398. t['afii57695'] = 0xFB2B;
  15399. t['afii57700'] = 0xFB4B;
  15400. t['afii57705'] = 0xFB1F;
  15401. t['afii57716'] = 0x05F0;
  15402. t['afii57717'] = 0x05F1;
  15403. t['afii57718'] = 0x05F2;
  15404. t['afii57723'] = 0xFB35;
  15405. t['afii57793'] = 0x05B4;
  15406. t['afii57794'] = 0x05B5;
  15407. t['afii57795'] = 0x05B6;
  15408. t['afii57796'] = 0x05BB;
  15409. t['afii57797'] = 0x05B8;
  15410. t['afii57798'] = 0x05B7;
  15411. t['afii57799'] = 0x05B0;
  15412. t['afii57800'] = 0x05B2;
  15413. t['afii57801'] = 0x05B1;
  15414. t['afii57802'] = 0x05B3;
  15415. t['afii57803'] = 0x05C2;
  15416. t['afii57804'] = 0x05C1;
  15417. t['afii57806'] = 0x05B9;
  15418. t['afii57807'] = 0x05BC;
  15419. t['afii57839'] = 0x05BD;
  15420. t['afii57841'] = 0x05BF;
  15421. t['afii57842'] = 0x05C0;
  15422. t['afii57929'] = 0x02BC;
  15423. t['afii61248'] = 0x2105;
  15424. t['afii61289'] = 0x2113;
  15425. t['afii61352'] = 0x2116;
  15426. t['afii61573'] = 0x202C;
  15427. t['afii61574'] = 0x202D;
  15428. t['afii61575'] = 0x202E;
  15429. t['afii61664'] = 0x200C;
  15430. t['afii63167'] = 0x066D;
  15431. t['afii64937'] = 0x02BD;
  15432. t['agrave'] = 0x00E0;
  15433. t['agujarati'] = 0x0A85;
  15434. t['agurmukhi'] = 0x0A05;
  15435. t['ahiragana'] = 0x3042;
  15436. t['ahookabove'] = 0x1EA3;
  15437. t['aibengali'] = 0x0990;
  15438. t['aibopomofo'] = 0x311E;
  15439. t['aideva'] = 0x0910;
  15440. t['aiecyrillic'] = 0x04D5;
  15441. t['aigujarati'] = 0x0A90;
  15442. t['aigurmukhi'] = 0x0A10;
  15443. t['aimatragurmukhi'] = 0x0A48;
  15444. t['ainarabic'] = 0x0639;
  15445. t['ainfinalarabic'] = 0xFECA;
  15446. t['aininitialarabic'] = 0xFECB;
  15447. t['ainmedialarabic'] = 0xFECC;
  15448. t['ainvertedbreve'] = 0x0203;
  15449. t['aivowelsignbengali'] = 0x09C8;
  15450. t['aivowelsigndeva'] = 0x0948;
  15451. t['aivowelsigngujarati'] = 0x0AC8;
  15452. t['akatakana'] = 0x30A2;
  15453. t['akatakanahalfwidth'] = 0xFF71;
  15454. t['akorean'] = 0x314F;
  15455. t['alef'] = 0x05D0;
  15456. t['alefarabic'] = 0x0627;
  15457. t['alefdageshhebrew'] = 0xFB30;
  15458. t['aleffinalarabic'] = 0xFE8E;
  15459. t['alefhamzaabovearabic'] = 0x0623;
  15460. t['alefhamzaabovefinalarabic'] = 0xFE84;
  15461. t['alefhamzabelowarabic'] = 0x0625;
  15462. t['alefhamzabelowfinalarabic'] = 0xFE88;
  15463. t['alefhebrew'] = 0x05D0;
  15464. t['aleflamedhebrew'] = 0xFB4F;
  15465. t['alefmaddaabovearabic'] = 0x0622;
  15466. t['alefmaddaabovefinalarabic'] = 0xFE82;
  15467. t['alefmaksuraarabic'] = 0x0649;
  15468. t['alefmaksurafinalarabic'] = 0xFEF0;
  15469. t['alefmaksurainitialarabic'] = 0xFEF3;
  15470. t['alefmaksuramedialarabic'] = 0xFEF4;
  15471. t['alefpatahhebrew'] = 0xFB2E;
  15472. t['alefqamatshebrew'] = 0xFB2F;
  15473. t['aleph'] = 0x2135;
  15474. t['allequal'] = 0x224C;
  15475. t['alpha'] = 0x03B1;
  15476. t['alphatonos'] = 0x03AC;
  15477. t['amacron'] = 0x0101;
  15478. t['amonospace'] = 0xFF41;
  15479. t['ampersand'] = 0x0026;
  15480. t['ampersandmonospace'] = 0xFF06;
  15481. t['ampersandsmall'] = 0xF726;
  15482. t['amsquare'] = 0x33C2;
  15483. t['anbopomofo'] = 0x3122;
  15484. t['angbopomofo'] = 0x3124;
  15485. t['angbracketleft'] = 0x3008;
  15486. t['angbracketright'] = 0x3009;
  15487. t['angkhankhuthai'] = 0x0E5A;
  15488. t['angle'] = 0x2220;
  15489. t['anglebracketleft'] = 0x3008;
  15490. t['anglebracketleftvertical'] = 0xFE3F;
  15491. t['anglebracketright'] = 0x3009;
  15492. t['anglebracketrightvertical'] = 0xFE40;
  15493. t['angleleft'] = 0x2329;
  15494. t['angleright'] = 0x232A;
  15495. t['angstrom'] = 0x212B;
  15496. t['anoteleia'] = 0x0387;
  15497. t['anudattadeva'] = 0x0952;
  15498. t['anusvarabengali'] = 0x0982;
  15499. t['anusvaradeva'] = 0x0902;
  15500. t['anusvaragujarati'] = 0x0A82;
  15501. t['aogonek'] = 0x0105;
  15502. t['apaatosquare'] = 0x3300;
  15503. t['aparen'] = 0x249C;
  15504. t['apostrophearmenian'] = 0x055A;
  15505. t['apostrophemod'] = 0x02BC;
  15506. t['apple'] = 0xF8FF;
  15507. t['approaches'] = 0x2250;
  15508. t['approxequal'] = 0x2248;
  15509. t['approxequalorimage'] = 0x2252;
  15510. t['approximatelyequal'] = 0x2245;
  15511. t['araeaekorean'] = 0x318E;
  15512. t['araeakorean'] = 0x318D;
  15513. t['arc'] = 0x2312;
  15514. t['arighthalfring'] = 0x1E9A;
  15515. t['aring'] = 0x00E5;
  15516. t['aringacute'] = 0x01FB;
  15517. t['aringbelow'] = 0x1E01;
  15518. t['arrowboth'] = 0x2194;
  15519. t['arrowdashdown'] = 0x21E3;
  15520. t['arrowdashleft'] = 0x21E0;
  15521. t['arrowdashright'] = 0x21E2;
  15522. t['arrowdashup'] = 0x21E1;
  15523. t['arrowdblboth'] = 0x21D4;
  15524. t['arrowdbldown'] = 0x21D3;
  15525. t['arrowdblleft'] = 0x21D0;
  15526. t['arrowdblright'] = 0x21D2;
  15527. t['arrowdblup'] = 0x21D1;
  15528. t['arrowdown'] = 0x2193;
  15529. t['arrowdownleft'] = 0x2199;
  15530. t['arrowdownright'] = 0x2198;
  15531. t['arrowdownwhite'] = 0x21E9;
  15532. t['arrowheaddownmod'] = 0x02C5;
  15533. t['arrowheadleftmod'] = 0x02C2;
  15534. t['arrowheadrightmod'] = 0x02C3;
  15535. t['arrowheadupmod'] = 0x02C4;
  15536. t['arrowhorizex'] = 0xF8E7;
  15537. t['arrowleft'] = 0x2190;
  15538. t['arrowleftdbl'] = 0x21D0;
  15539. t['arrowleftdblstroke'] = 0x21CD;
  15540. t['arrowleftoverright'] = 0x21C6;
  15541. t['arrowleftwhite'] = 0x21E6;
  15542. t['arrowright'] = 0x2192;
  15543. t['arrowrightdblstroke'] = 0x21CF;
  15544. t['arrowrightheavy'] = 0x279E;
  15545. t['arrowrightoverleft'] = 0x21C4;
  15546. t['arrowrightwhite'] = 0x21E8;
  15547. t['arrowtableft'] = 0x21E4;
  15548. t['arrowtabright'] = 0x21E5;
  15549. t['arrowup'] = 0x2191;
  15550. t['arrowupdn'] = 0x2195;
  15551. t['arrowupdnbse'] = 0x21A8;
  15552. t['arrowupdownbase'] = 0x21A8;
  15553. t['arrowupleft'] = 0x2196;
  15554. t['arrowupleftofdown'] = 0x21C5;
  15555. t['arrowupright'] = 0x2197;
  15556. t['arrowupwhite'] = 0x21E7;
  15557. t['arrowvertex'] = 0xF8E6;
  15558. t['asciicircum'] = 0x005E;
  15559. t['asciicircummonospace'] = 0xFF3E;
  15560. t['asciitilde'] = 0x007E;
  15561. t['asciitildemonospace'] = 0xFF5E;
  15562. t['ascript'] = 0x0251;
  15563. t['ascriptturned'] = 0x0252;
  15564. t['asmallhiragana'] = 0x3041;
  15565. t['asmallkatakana'] = 0x30A1;
  15566. t['asmallkatakanahalfwidth'] = 0xFF67;
  15567. t['asterisk'] = 0x002A;
  15568. t['asteriskaltonearabic'] = 0x066D;
  15569. t['asteriskarabic'] = 0x066D;
  15570. t['asteriskmath'] = 0x2217;
  15571. t['asteriskmonospace'] = 0xFF0A;
  15572. t['asterisksmall'] = 0xFE61;
  15573. t['asterism'] = 0x2042;
  15574. t['asuperior'] = 0xF6E9;
  15575. t['asymptoticallyequal'] = 0x2243;
  15576. t['at'] = 0x0040;
  15577. t['atilde'] = 0x00E3;
  15578. t['atmonospace'] = 0xFF20;
  15579. t['atsmall'] = 0xFE6B;
  15580. t['aturned'] = 0x0250;
  15581. t['aubengali'] = 0x0994;
  15582. t['aubopomofo'] = 0x3120;
  15583. t['audeva'] = 0x0914;
  15584. t['augujarati'] = 0x0A94;
  15585. t['augurmukhi'] = 0x0A14;
  15586. t['aulengthmarkbengali'] = 0x09D7;
  15587. t['aumatragurmukhi'] = 0x0A4C;
  15588. t['auvowelsignbengali'] = 0x09CC;
  15589. t['auvowelsigndeva'] = 0x094C;
  15590. t['auvowelsigngujarati'] = 0x0ACC;
  15591. t['avagrahadeva'] = 0x093D;
  15592. t['aybarmenian'] = 0x0561;
  15593. t['ayin'] = 0x05E2;
  15594. t['ayinaltonehebrew'] = 0xFB20;
  15595. t['ayinhebrew'] = 0x05E2;
  15596. t['b'] = 0x0062;
  15597. t['babengali'] = 0x09AC;
  15598. t['backslash'] = 0x005C;
  15599. t['backslashmonospace'] = 0xFF3C;
  15600. t['badeva'] = 0x092C;
  15601. t['bagujarati'] = 0x0AAC;
  15602. t['bagurmukhi'] = 0x0A2C;
  15603. t['bahiragana'] = 0x3070;
  15604. t['bahtthai'] = 0x0E3F;
  15605. t['bakatakana'] = 0x30D0;
  15606. t['bar'] = 0x007C;
  15607. t['barmonospace'] = 0xFF5C;
  15608. t['bbopomofo'] = 0x3105;
  15609. t['bcircle'] = 0x24D1;
  15610. t['bdotaccent'] = 0x1E03;
  15611. t['bdotbelow'] = 0x1E05;
  15612. t['beamedsixteenthnotes'] = 0x266C;
  15613. t['because'] = 0x2235;
  15614. t['becyrillic'] = 0x0431;
  15615. t['beharabic'] = 0x0628;
  15616. t['behfinalarabic'] = 0xFE90;
  15617. t['behinitialarabic'] = 0xFE91;
  15618. t['behiragana'] = 0x3079;
  15619. t['behmedialarabic'] = 0xFE92;
  15620. t['behmeeminitialarabic'] = 0xFC9F;
  15621. t['behmeemisolatedarabic'] = 0xFC08;
  15622. t['behnoonfinalarabic'] = 0xFC6D;
  15623. t['bekatakana'] = 0x30D9;
  15624. t['benarmenian'] = 0x0562;
  15625. t['bet'] = 0x05D1;
  15626. t['beta'] = 0x03B2;
  15627. t['betasymbolgreek'] = 0x03D0;
  15628. t['betdagesh'] = 0xFB31;
  15629. t['betdageshhebrew'] = 0xFB31;
  15630. t['bethebrew'] = 0x05D1;
  15631. t['betrafehebrew'] = 0xFB4C;
  15632. t['bhabengali'] = 0x09AD;
  15633. t['bhadeva'] = 0x092D;
  15634. t['bhagujarati'] = 0x0AAD;
  15635. t['bhagurmukhi'] = 0x0A2D;
  15636. t['bhook'] = 0x0253;
  15637. t['bihiragana'] = 0x3073;
  15638. t['bikatakana'] = 0x30D3;
  15639. t['bilabialclick'] = 0x0298;
  15640. t['bindigurmukhi'] = 0x0A02;
  15641. t['birusquare'] = 0x3331;
  15642. t['blackcircle'] = 0x25CF;
  15643. t['blackdiamond'] = 0x25C6;
  15644. t['blackdownpointingtriangle'] = 0x25BC;
  15645. t['blackleftpointingpointer'] = 0x25C4;
  15646. t['blackleftpointingtriangle'] = 0x25C0;
  15647. t['blacklenticularbracketleft'] = 0x3010;
  15648. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  15649. t['blacklenticularbracketright'] = 0x3011;
  15650. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  15651. t['blacklowerlefttriangle'] = 0x25E3;
  15652. t['blacklowerrighttriangle'] = 0x25E2;
  15653. t['blackrectangle'] = 0x25AC;
  15654. t['blackrightpointingpointer'] = 0x25BA;
  15655. t['blackrightpointingtriangle'] = 0x25B6;
  15656. t['blacksmallsquare'] = 0x25AA;
  15657. t['blacksmilingface'] = 0x263B;
  15658. t['blacksquare'] = 0x25A0;
  15659. t['blackstar'] = 0x2605;
  15660. t['blackupperlefttriangle'] = 0x25E4;
  15661. t['blackupperrighttriangle'] = 0x25E5;
  15662. t['blackuppointingsmalltriangle'] = 0x25B4;
  15663. t['blackuppointingtriangle'] = 0x25B2;
  15664. t['blank'] = 0x2423;
  15665. t['blinebelow'] = 0x1E07;
  15666. t['block'] = 0x2588;
  15667. t['bmonospace'] = 0xFF42;
  15668. t['bobaimaithai'] = 0x0E1A;
  15669. t['bohiragana'] = 0x307C;
  15670. t['bokatakana'] = 0x30DC;
  15671. t['bparen'] = 0x249D;
  15672. t['bqsquare'] = 0x33C3;
  15673. t['braceex'] = 0xF8F4;
  15674. t['braceleft'] = 0x007B;
  15675. t['braceleftbt'] = 0xF8F3;
  15676. t['braceleftmid'] = 0xF8F2;
  15677. t['braceleftmonospace'] = 0xFF5B;
  15678. t['braceleftsmall'] = 0xFE5B;
  15679. t['bracelefttp'] = 0xF8F1;
  15680. t['braceleftvertical'] = 0xFE37;
  15681. t['braceright'] = 0x007D;
  15682. t['bracerightbt'] = 0xF8FE;
  15683. t['bracerightmid'] = 0xF8FD;
  15684. t['bracerightmonospace'] = 0xFF5D;
  15685. t['bracerightsmall'] = 0xFE5C;
  15686. t['bracerighttp'] = 0xF8FC;
  15687. t['bracerightvertical'] = 0xFE38;
  15688. t['bracketleft'] = 0x005B;
  15689. t['bracketleftbt'] = 0xF8F0;
  15690. t['bracketleftex'] = 0xF8EF;
  15691. t['bracketleftmonospace'] = 0xFF3B;
  15692. t['bracketlefttp'] = 0xF8EE;
  15693. t['bracketright'] = 0x005D;
  15694. t['bracketrightbt'] = 0xF8FB;
  15695. t['bracketrightex'] = 0xF8FA;
  15696. t['bracketrightmonospace'] = 0xFF3D;
  15697. t['bracketrighttp'] = 0xF8F9;
  15698. t['breve'] = 0x02D8;
  15699. t['brevebelowcmb'] = 0x032E;
  15700. t['brevecmb'] = 0x0306;
  15701. t['breveinvertedbelowcmb'] = 0x032F;
  15702. t['breveinvertedcmb'] = 0x0311;
  15703. t['breveinverteddoublecmb'] = 0x0361;
  15704. t['bridgebelowcmb'] = 0x032A;
  15705. t['bridgeinvertedbelowcmb'] = 0x033A;
  15706. t['brokenbar'] = 0x00A6;
  15707. t['bstroke'] = 0x0180;
  15708. t['bsuperior'] = 0xF6EA;
  15709. t['btopbar'] = 0x0183;
  15710. t['buhiragana'] = 0x3076;
  15711. t['bukatakana'] = 0x30D6;
  15712. t['bullet'] = 0x2022;
  15713. t['bulletinverse'] = 0x25D8;
  15714. t['bulletoperator'] = 0x2219;
  15715. t['bullseye'] = 0x25CE;
  15716. t['c'] = 0x0063;
  15717. t['caarmenian'] = 0x056E;
  15718. t['cabengali'] = 0x099A;
  15719. t['cacute'] = 0x0107;
  15720. t['cadeva'] = 0x091A;
  15721. t['cagujarati'] = 0x0A9A;
  15722. t['cagurmukhi'] = 0x0A1A;
  15723. t['calsquare'] = 0x3388;
  15724. t['candrabindubengali'] = 0x0981;
  15725. t['candrabinducmb'] = 0x0310;
  15726. t['candrabindudeva'] = 0x0901;
  15727. t['candrabindugujarati'] = 0x0A81;
  15728. t['capslock'] = 0x21EA;
  15729. t['careof'] = 0x2105;
  15730. t['caron'] = 0x02C7;
  15731. t['caronbelowcmb'] = 0x032C;
  15732. t['caroncmb'] = 0x030C;
  15733. t['carriagereturn'] = 0x21B5;
  15734. t['cbopomofo'] = 0x3118;
  15735. t['ccaron'] = 0x010D;
  15736. t['ccedilla'] = 0x00E7;
  15737. t['ccedillaacute'] = 0x1E09;
  15738. t['ccircle'] = 0x24D2;
  15739. t['ccircumflex'] = 0x0109;
  15740. t['ccurl'] = 0x0255;
  15741. t['cdot'] = 0x010B;
  15742. t['cdotaccent'] = 0x010B;
  15743. t['cdsquare'] = 0x33C5;
  15744. t['cedilla'] = 0x00B8;
  15745. t['cedillacmb'] = 0x0327;
  15746. t['cent'] = 0x00A2;
  15747. t['centigrade'] = 0x2103;
  15748. t['centinferior'] = 0xF6DF;
  15749. t['centmonospace'] = 0xFFE0;
  15750. t['centoldstyle'] = 0xF7A2;
  15751. t['centsuperior'] = 0xF6E0;
  15752. t['chaarmenian'] = 0x0579;
  15753. t['chabengali'] = 0x099B;
  15754. t['chadeva'] = 0x091B;
  15755. t['chagujarati'] = 0x0A9B;
  15756. t['chagurmukhi'] = 0x0A1B;
  15757. t['chbopomofo'] = 0x3114;
  15758. t['cheabkhasiancyrillic'] = 0x04BD;
  15759. t['checkmark'] = 0x2713;
  15760. t['checyrillic'] = 0x0447;
  15761. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  15762. t['chedescendercyrillic'] = 0x04B7;
  15763. t['chedieresiscyrillic'] = 0x04F5;
  15764. t['cheharmenian'] = 0x0573;
  15765. t['chekhakassiancyrillic'] = 0x04CC;
  15766. t['cheverticalstrokecyrillic'] = 0x04B9;
  15767. t['chi'] = 0x03C7;
  15768. t['chieuchacirclekorean'] = 0x3277;
  15769. t['chieuchaparenkorean'] = 0x3217;
  15770. t['chieuchcirclekorean'] = 0x3269;
  15771. t['chieuchkorean'] = 0x314A;
  15772. t['chieuchparenkorean'] = 0x3209;
  15773. t['chochangthai'] = 0x0E0A;
  15774. t['chochanthai'] = 0x0E08;
  15775. t['chochingthai'] = 0x0E09;
  15776. t['chochoethai'] = 0x0E0C;
  15777. t['chook'] = 0x0188;
  15778. t['cieucacirclekorean'] = 0x3276;
  15779. t['cieucaparenkorean'] = 0x3216;
  15780. t['cieuccirclekorean'] = 0x3268;
  15781. t['cieuckorean'] = 0x3148;
  15782. t['cieucparenkorean'] = 0x3208;
  15783. t['cieucuparenkorean'] = 0x321C;
  15784. t['circle'] = 0x25CB;
  15785. t['circlecopyrt'] = 0x00A9;
  15786. t['circlemultiply'] = 0x2297;
  15787. t['circleot'] = 0x2299;
  15788. t['circleplus'] = 0x2295;
  15789. t['circlepostalmark'] = 0x3036;
  15790. t['circlewithlefthalfblack'] = 0x25D0;
  15791. t['circlewithrighthalfblack'] = 0x25D1;
  15792. t['circumflex'] = 0x02C6;
  15793. t['circumflexbelowcmb'] = 0x032D;
  15794. t['circumflexcmb'] = 0x0302;
  15795. t['clear'] = 0x2327;
  15796. t['clickalveolar'] = 0x01C2;
  15797. t['clickdental'] = 0x01C0;
  15798. t['clicklateral'] = 0x01C1;
  15799. t['clickretroflex'] = 0x01C3;
  15800. t['club'] = 0x2663;
  15801. t['clubsuitblack'] = 0x2663;
  15802. t['clubsuitwhite'] = 0x2667;
  15803. t['cmcubedsquare'] = 0x33A4;
  15804. t['cmonospace'] = 0xFF43;
  15805. t['cmsquaredsquare'] = 0x33A0;
  15806. t['coarmenian'] = 0x0581;
  15807. t['colon'] = 0x003A;
  15808. t['colonmonetary'] = 0x20A1;
  15809. t['colonmonospace'] = 0xFF1A;
  15810. t['colonsign'] = 0x20A1;
  15811. t['colonsmall'] = 0xFE55;
  15812. t['colontriangularhalfmod'] = 0x02D1;
  15813. t['colontriangularmod'] = 0x02D0;
  15814. t['comma'] = 0x002C;
  15815. t['commaabovecmb'] = 0x0313;
  15816. t['commaaboverightcmb'] = 0x0315;
  15817. t['commaaccent'] = 0xF6C3;
  15818. t['commaarabic'] = 0x060C;
  15819. t['commaarmenian'] = 0x055D;
  15820. t['commainferior'] = 0xF6E1;
  15821. t['commamonospace'] = 0xFF0C;
  15822. t['commareversedabovecmb'] = 0x0314;
  15823. t['commareversedmod'] = 0x02BD;
  15824. t['commasmall'] = 0xFE50;
  15825. t['commasuperior'] = 0xF6E2;
  15826. t['commaturnedabovecmb'] = 0x0312;
  15827. t['commaturnedmod'] = 0x02BB;
  15828. t['compass'] = 0x263C;
  15829. t['congruent'] = 0x2245;
  15830. t['contourintegral'] = 0x222E;
  15831. t['control'] = 0x2303;
  15832. t['controlACK'] = 0x0006;
  15833. t['controlBEL'] = 0x0007;
  15834. t['controlBS'] = 0x0008;
  15835. t['controlCAN'] = 0x0018;
  15836. t['controlCR'] = 0x000D;
  15837. t['controlDC1'] = 0x0011;
  15838. t['controlDC2'] = 0x0012;
  15839. t['controlDC3'] = 0x0013;
  15840. t['controlDC4'] = 0x0014;
  15841. t['controlDEL'] = 0x007F;
  15842. t['controlDLE'] = 0x0010;
  15843. t['controlEM'] = 0x0019;
  15844. t['controlENQ'] = 0x0005;
  15845. t['controlEOT'] = 0x0004;
  15846. t['controlESC'] = 0x001B;
  15847. t['controlETB'] = 0x0017;
  15848. t['controlETX'] = 0x0003;
  15849. t['controlFF'] = 0x000C;
  15850. t['controlFS'] = 0x001C;
  15851. t['controlGS'] = 0x001D;
  15852. t['controlHT'] = 0x0009;
  15853. t['controlLF'] = 0x000A;
  15854. t['controlNAK'] = 0x0015;
  15855. t['controlNULL'] = 0x0000;
  15856. t['controlRS'] = 0x001E;
  15857. t['controlSI'] = 0x000F;
  15858. t['controlSO'] = 0x000E;
  15859. t['controlSOT'] = 0x0002;
  15860. t['controlSTX'] = 0x0001;
  15861. t['controlSUB'] = 0x001A;
  15862. t['controlSYN'] = 0x0016;
  15863. t['controlUS'] = 0x001F;
  15864. t['controlVT'] = 0x000B;
  15865. t['copyright'] = 0x00A9;
  15866. t['copyrightsans'] = 0xF8E9;
  15867. t['copyrightserif'] = 0xF6D9;
  15868. t['cornerbracketleft'] = 0x300C;
  15869. t['cornerbracketlefthalfwidth'] = 0xFF62;
  15870. t['cornerbracketleftvertical'] = 0xFE41;
  15871. t['cornerbracketright'] = 0x300D;
  15872. t['cornerbracketrighthalfwidth'] = 0xFF63;
  15873. t['cornerbracketrightvertical'] = 0xFE42;
  15874. t['corporationsquare'] = 0x337F;
  15875. t['cosquare'] = 0x33C7;
  15876. t['coverkgsquare'] = 0x33C6;
  15877. t['cparen'] = 0x249E;
  15878. t['cruzeiro'] = 0x20A2;
  15879. t['cstretched'] = 0x0297;
  15880. t['curlyand'] = 0x22CF;
  15881. t['curlyor'] = 0x22CE;
  15882. t['currency'] = 0x00A4;
  15883. t['cyrBreve'] = 0xF6D1;
  15884. t['cyrFlex'] = 0xF6D2;
  15885. t['cyrbreve'] = 0xF6D4;
  15886. t['cyrflex'] = 0xF6D5;
  15887. t['d'] = 0x0064;
  15888. t['daarmenian'] = 0x0564;
  15889. t['dabengali'] = 0x09A6;
  15890. t['dadarabic'] = 0x0636;
  15891. t['dadeva'] = 0x0926;
  15892. t['dadfinalarabic'] = 0xFEBE;
  15893. t['dadinitialarabic'] = 0xFEBF;
  15894. t['dadmedialarabic'] = 0xFEC0;
  15895. t['dagesh'] = 0x05BC;
  15896. t['dageshhebrew'] = 0x05BC;
  15897. t['dagger'] = 0x2020;
  15898. t['daggerdbl'] = 0x2021;
  15899. t['dagujarati'] = 0x0AA6;
  15900. t['dagurmukhi'] = 0x0A26;
  15901. t['dahiragana'] = 0x3060;
  15902. t['dakatakana'] = 0x30C0;
  15903. t['dalarabic'] = 0x062F;
  15904. t['dalet'] = 0x05D3;
  15905. t['daletdagesh'] = 0xFB33;
  15906. t['daletdageshhebrew'] = 0xFB33;
  15907. t['dalethebrew'] = 0x05D3;
  15908. t['dalfinalarabic'] = 0xFEAA;
  15909. t['dammaarabic'] = 0x064F;
  15910. t['dammalowarabic'] = 0x064F;
  15911. t['dammatanaltonearabic'] = 0x064C;
  15912. t['dammatanarabic'] = 0x064C;
  15913. t['danda'] = 0x0964;
  15914. t['dargahebrew'] = 0x05A7;
  15915. t['dargalefthebrew'] = 0x05A7;
  15916. t['dasiapneumatacyrilliccmb'] = 0x0485;
  15917. t['dblGrave'] = 0xF6D3;
  15918. t['dblanglebracketleft'] = 0x300A;
  15919. t['dblanglebracketleftvertical'] = 0xFE3D;
  15920. t['dblanglebracketright'] = 0x300B;
  15921. t['dblanglebracketrightvertical'] = 0xFE3E;
  15922. t['dblarchinvertedbelowcmb'] = 0x032B;
  15923. t['dblarrowleft'] = 0x21D4;
  15924. t['dblarrowright'] = 0x21D2;
  15925. t['dbldanda'] = 0x0965;
  15926. t['dblgrave'] = 0xF6D6;
  15927. t['dblgravecmb'] = 0x030F;
  15928. t['dblintegral'] = 0x222C;
  15929. t['dbllowline'] = 0x2017;
  15930. t['dbllowlinecmb'] = 0x0333;
  15931. t['dbloverlinecmb'] = 0x033F;
  15932. t['dblprimemod'] = 0x02BA;
  15933. t['dblverticalbar'] = 0x2016;
  15934. t['dblverticallineabovecmb'] = 0x030E;
  15935. t['dbopomofo'] = 0x3109;
  15936. t['dbsquare'] = 0x33C8;
  15937. t['dcaron'] = 0x010F;
  15938. t['dcedilla'] = 0x1E11;
  15939. t['dcircle'] = 0x24D3;
  15940. t['dcircumflexbelow'] = 0x1E13;
  15941. t['dcroat'] = 0x0111;
  15942. t['ddabengali'] = 0x09A1;
  15943. t['ddadeva'] = 0x0921;
  15944. t['ddagujarati'] = 0x0AA1;
  15945. t['ddagurmukhi'] = 0x0A21;
  15946. t['ddalarabic'] = 0x0688;
  15947. t['ddalfinalarabic'] = 0xFB89;
  15948. t['dddhadeva'] = 0x095C;
  15949. t['ddhabengali'] = 0x09A2;
  15950. t['ddhadeva'] = 0x0922;
  15951. t['ddhagujarati'] = 0x0AA2;
  15952. t['ddhagurmukhi'] = 0x0A22;
  15953. t['ddotaccent'] = 0x1E0B;
  15954. t['ddotbelow'] = 0x1E0D;
  15955. t['decimalseparatorarabic'] = 0x066B;
  15956. t['decimalseparatorpersian'] = 0x066B;
  15957. t['decyrillic'] = 0x0434;
  15958. t['degree'] = 0x00B0;
  15959. t['dehihebrew'] = 0x05AD;
  15960. t['dehiragana'] = 0x3067;
  15961. t['deicoptic'] = 0x03EF;
  15962. t['dekatakana'] = 0x30C7;
  15963. t['deleteleft'] = 0x232B;
  15964. t['deleteright'] = 0x2326;
  15965. t['delta'] = 0x03B4;
  15966. t['deltaturned'] = 0x018D;
  15967. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  15968. t['dezh'] = 0x02A4;
  15969. t['dhabengali'] = 0x09A7;
  15970. t['dhadeva'] = 0x0927;
  15971. t['dhagujarati'] = 0x0AA7;
  15972. t['dhagurmukhi'] = 0x0A27;
  15973. t['dhook'] = 0x0257;
  15974. t['dialytikatonos'] = 0x0385;
  15975. t['dialytikatonoscmb'] = 0x0344;
  15976. t['diamond'] = 0x2666;
  15977. t['diamondsuitwhite'] = 0x2662;
  15978. t['dieresis'] = 0x00A8;
  15979. t['dieresisacute'] = 0xF6D7;
  15980. t['dieresisbelowcmb'] = 0x0324;
  15981. t['dieresiscmb'] = 0x0308;
  15982. t['dieresisgrave'] = 0xF6D8;
  15983. t['dieresistonos'] = 0x0385;
  15984. t['dihiragana'] = 0x3062;
  15985. t['dikatakana'] = 0x30C2;
  15986. t['dittomark'] = 0x3003;
  15987. t['divide'] = 0x00F7;
  15988. t['divides'] = 0x2223;
  15989. t['divisionslash'] = 0x2215;
  15990. t['djecyrillic'] = 0x0452;
  15991. t['dkshade'] = 0x2593;
  15992. t['dlinebelow'] = 0x1E0F;
  15993. t['dlsquare'] = 0x3397;
  15994. t['dmacron'] = 0x0111;
  15995. t['dmonospace'] = 0xFF44;
  15996. t['dnblock'] = 0x2584;
  15997. t['dochadathai'] = 0x0E0E;
  15998. t['dodekthai'] = 0x0E14;
  15999. t['dohiragana'] = 0x3069;
  16000. t['dokatakana'] = 0x30C9;
  16001. t['dollar'] = 0x0024;
  16002. t['dollarinferior'] = 0xF6E3;
  16003. t['dollarmonospace'] = 0xFF04;
  16004. t['dollaroldstyle'] = 0xF724;
  16005. t['dollarsmall'] = 0xFE69;
  16006. t['dollarsuperior'] = 0xF6E4;
  16007. t['dong'] = 0x20AB;
  16008. t['dorusquare'] = 0x3326;
  16009. t['dotaccent'] = 0x02D9;
  16010. t['dotaccentcmb'] = 0x0307;
  16011. t['dotbelowcmb'] = 0x0323;
  16012. t['dotbelowcomb'] = 0x0323;
  16013. t['dotkatakana'] = 0x30FB;
  16014. t['dotlessi'] = 0x0131;
  16015. t['dotlessj'] = 0xF6BE;
  16016. t['dotlessjstrokehook'] = 0x0284;
  16017. t['dotmath'] = 0x22C5;
  16018. t['dottedcircle'] = 0x25CC;
  16019. t['doubleyodpatah'] = 0xFB1F;
  16020. t['doubleyodpatahhebrew'] = 0xFB1F;
  16021. t['downtackbelowcmb'] = 0x031E;
  16022. t['downtackmod'] = 0x02D5;
  16023. t['dparen'] = 0x249F;
  16024. t['dsuperior'] = 0xF6EB;
  16025. t['dtail'] = 0x0256;
  16026. t['dtopbar'] = 0x018C;
  16027. t['duhiragana'] = 0x3065;
  16028. t['dukatakana'] = 0x30C5;
  16029. t['dz'] = 0x01F3;
  16030. t['dzaltone'] = 0x02A3;
  16031. t['dzcaron'] = 0x01C6;
  16032. t['dzcurl'] = 0x02A5;
  16033. t['dzeabkhasiancyrillic'] = 0x04E1;
  16034. t['dzecyrillic'] = 0x0455;
  16035. t['dzhecyrillic'] = 0x045F;
  16036. t['e'] = 0x0065;
  16037. t['eacute'] = 0x00E9;
  16038. t['earth'] = 0x2641;
  16039. t['ebengali'] = 0x098F;
  16040. t['ebopomofo'] = 0x311C;
  16041. t['ebreve'] = 0x0115;
  16042. t['ecandradeva'] = 0x090D;
  16043. t['ecandragujarati'] = 0x0A8D;
  16044. t['ecandravowelsigndeva'] = 0x0945;
  16045. t['ecandravowelsigngujarati'] = 0x0AC5;
  16046. t['ecaron'] = 0x011B;
  16047. t['ecedillabreve'] = 0x1E1D;
  16048. t['echarmenian'] = 0x0565;
  16049. t['echyiwnarmenian'] = 0x0587;
  16050. t['ecircle'] = 0x24D4;
  16051. t['ecircumflex'] = 0x00EA;
  16052. t['ecircumflexacute'] = 0x1EBF;
  16053. t['ecircumflexbelow'] = 0x1E19;
  16054. t['ecircumflexdotbelow'] = 0x1EC7;
  16055. t['ecircumflexgrave'] = 0x1EC1;
  16056. t['ecircumflexhookabove'] = 0x1EC3;
  16057. t['ecircumflextilde'] = 0x1EC5;
  16058. t['ecyrillic'] = 0x0454;
  16059. t['edblgrave'] = 0x0205;
  16060. t['edeva'] = 0x090F;
  16061. t['edieresis'] = 0x00EB;
  16062. t['edot'] = 0x0117;
  16063. t['edotaccent'] = 0x0117;
  16064. t['edotbelow'] = 0x1EB9;
  16065. t['eegurmukhi'] = 0x0A0F;
  16066. t['eematragurmukhi'] = 0x0A47;
  16067. t['efcyrillic'] = 0x0444;
  16068. t['egrave'] = 0x00E8;
  16069. t['egujarati'] = 0x0A8F;
  16070. t['eharmenian'] = 0x0567;
  16071. t['ehbopomofo'] = 0x311D;
  16072. t['ehiragana'] = 0x3048;
  16073. t['ehookabove'] = 0x1EBB;
  16074. t['eibopomofo'] = 0x311F;
  16075. t['eight'] = 0x0038;
  16076. t['eightarabic'] = 0x0668;
  16077. t['eightbengali'] = 0x09EE;
  16078. t['eightcircle'] = 0x2467;
  16079. t['eightcircleinversesansserif'] = 0x2791;
  16080. t['eightdeva'] = 0x096E;
  16081. t['eighteencircle'] = 0x2471;
  16082. t['eighteenparen'] = 0x2485;
  16083. t['eighteenperiod'] = 0x2499;
  16084. t['eightgujarati'] = 0x0AEE;
  16085. t['eightgurmukhi'] = 0x0A6E;
  16086. t['eighthackarabic'] = 0x0668;
  16087. t['eighthangzhou'] = 0x3028;
  16088. t['eighthnotebeamed'] = 0x266B;
  16089. t['eightideographicparen'] = 0x3227;
  16090. t['eightinferior'] = 0x2088;
  16091. t['eightmonospace'] = 0xFF18;
  16092. t['eightoldstyle'] = 0xF738;
  16093. t['eightparen'] = 0x247B;
  16094. t['eightperiod'] = 0x248F;
  16095. t['eightpersian'] = 0x06F8;
  16096. t['eightroman'] = 0x2177;
  16097. t['eightsuperior'] = 0x2078;
  16098. t['eightthai'] = 0x0E58;
  16099. t['einvertedbreve'] = 0x0207;
  16100. t['eiotifiedcyrillic'] = 0x0465;
  16101. t['ekatakana'] = 0x30A8;
  16102. t['ekatakanahalfwidth'] = 0xFF74;
  16103. t['ekonkargurmukhi'] = 0x0A74;
  16104. t['ekorean'] = 0x3154;
  16105. t['elcyrillic'] = 0x043B;
  16106. t['element'] = 0x2208;
  16107. t['elevencircle'] = 0x246A;
  16108. t['elevenparen'] = 0x247E;
  16109. t['elevenperiod'] = 0x2492;
  16110. t['elevenroman'] = 0x217A;
  16111. t['ellipsis'] = 0x2026;
  16112. t['ellipsisvertical'] = 0x22EE;
  16113. t['emacron'] = 0x0113;
  16114. t['emacronacute'] = 0x1E17;
  16115. t['emacrongrave'] = 0x1E15;
  16116. t['emcyrillic'] = 0x043C;
  16117. t['emdash'] = 0x2014;
  16118. t['emdashvertical'] = 0xFE31;
  16119. t['emonospace'] = 0xFF45;
  16120. t['emphasismarkarmenian'] = 0x055B;
  16121. t['emptyset'] = 0x2205;
  16122. t['enbopomofo'] = 0x3123;
  16123. t['encyrillic'] = 0x043D;
  16124. t['endash'] = 0x2013;
  16125. t['endashvertical'] = 0xFE32;
  16126. t['endescendercyrillic'] = 0x04A3;
  16127. t['eng'] = 0x014B;
  16128. t['engbopomofo'] = 0x3125;
  16129. t['enghecyrillic'] = 0x04A5;
  16130. t['enhookcyrillic'] = 0x04C8;
  16131. t['enspace'] = 0x2002;
  16132. t['eogonek'] = 0x0119;
  16133. t['eokorean'] = 0x3153;
  16134. t['eopen'] = 0x025B;
  16135. t['eopenclosed'] = 0x029A;
  16136. t['eopenreversed'] = 0x025C;
  16137. t['eopenreversedclosed'] = 0x025E;
  16138. t['eopenreversedhook'] = 0x025D;
  16139. t['eparen'] = 0x24A0;
  16140. t['epsilon'] = 0x03B5;
  16141. t['epsilontonos'] = 0x03AD;
  16142. t['equal'] = 0x003D;
  16143. t['equalmonospace'] = 0xFF1D;
  16144. t['equalsmall'] = 0xFE66;
  16145. t['equalsuperior'] = 0x207C;
  16146. t['equivalence'] = 0x2261;
  16147. t['erbopomofo'] = 0x3126;
  16148. t['ercyrillic'] = 0x0440;
  16149. t['ereversed'] = 0x0258;
  16150. t['ereversedcyrillic'] = 0x044D;
  16151. t['escyrillic'] = 0x0441;
  16152. t['esdescendercyrillic'] = 0x04AB;
  16153. t['esh'] = 0x0283;
  16154. t['eshcurl'] = 0x0286;
  16155. t['eshortdeva'] = 0x090E;
  16156. t['eshortvowelsigndeva'] = 0x0946;
  16157. t['eshreversedloop'] = 0x01AA;
  16158. t['eshsquatreversed'] = 0x0285;
  16159. t['esmallhiragana'] = 0x3047;
  16160. t['esmallkatakana'] = 0x30A7;
  16161. t['esmallkatakanahalfwidth'] = 0xFF6A;
  16162. t['estimated'] = 0x212E;
  16163. t['esuperior'] = 0xF6EC;
  16164. t['eta'] = 0x03B7;
  16165. t['etarmenian'] = 0x0568;
  16166. t['etatonos'] = 0x03AE;
  16167. t['eth'] = 0x00F0;
  16168. t['etilde'] = 0x1EBD;
  16169. t['etildebelow'] = 0x1E1B;
  16170. t['etnahtafoukhhebrew'] = 0x0591;
  16171. t['etnahtafoukhlefthebrew'] = 0x0591;
  16172. t['etnahtahebrew'] = 0x0591;
  16173. t['etnahtalefthebrew'] = 0x0591;
  16174. t['eturned'] = 0x01DD;
  16175. t['eukorean'] = 0x3161;
  16176. t['euro'] = 0x20AC;
  16177. t['evowelsignbengali'] = 0x09C7;
  16178. t['evowelsigndeva'] = 0x0947;
  16179. t['evowelsigngujarati'] = 0x0AC7;
  16180. t['exclam'] = 0x0021;
  16181. t['exclamarmenian'] = 0x055C;
  16182. t['exclamdbl'] = 0x203C;
  16183. t['exclamdown'] = 0x00A1;
  16184. t['exclamdownsmall'] = 0xF7A1;
  16185. t['exclammonospace'] = 0xFF01;
  16186. t['exclamsmall'] = 0xF721;
  16187. t['existential'] = 0x2203;
  16188. t['ezh'] = 0x0292;
  16189. t['ezhcaron'] = 0x01EF;
  16190. t['ezhcurl'] = 0x0293;
  16191. t['ezhreversed'] = 0x01B9;
  16192. t['ezhtail'] = 0x01BA;
  16193. t['f'] = 0x0066;
  16194. t['fadeva'] = 0x095E;
  16195. t['fagurmukhi'] = 0x0A5E;
  16196. t['fahrenheit'] = 0x2109;
  16197. t['fathaarabic'] = 0x064E;
  16198. t['fathalowarabic'] = 0x064E;
  16199. t['fathatanarabic'] = 0x064B;
  16200. t['fbopomofo'] = 0x3108;
  16201. t['fcircle'] = 0x24D5;
  16202. t['fdotaccent'] = 0x1E1F;
  16203. t['feharabic'] = 0x0641;
  16204. t['feharmenian'] = 0x0586;
  16205. t['fehfinalarabic'] = 0xFED2;
  16206. t['fehinitialarabic'] = 0xFED3;
  16207. t['fehmedialarabic'] = 0xFED4;
  16208. t['feicoptic'] = 0x03E5;
  16209. t['female'] = 0x2640;
  16210. t['ff'] = 0xFB00;
  16211. t['ffi'] = 0xFB03;
  16212. t['ffl'] = 0xFB04;
  16213. t['fi'] = 0xFB01;
  16214. t['fifteencircle'] = 0x246E;
  16215. t['fifteenparen'] = 0x2482;
  16216. t['fifteenperiod'] = 0x2496;
  16217. t['figuredash'] = 0x2012;
  16218. t['filledbox'] = 0x25A0;
  16219. t['filledrect'] = 0x25AC;
  16220. t['finalkaf'] = 0x05DA;
  16221. t['finalkafdagesh'] = 0xFB3A;
  16222. t['finalkafdageshhebrew'] = 0xFB3A;
  16223. t['finalkafhebrew'] = 0x05DA;
  16224. t['finalmem'] = 0x05DD;
  16225. t['finalmemhebrew'] = 0x05DD;
  16226. t['finalnun'] = 0x05DF;
  16227. t['finalnunhebrew'] = 0x05DF;
  16228. t['finalpe'] = 0x05E3;
  16229. t['finalpehebrew'] = 0x05E3;
  16230. t['finaltsadi'] = 0x05E5;
  16231. t['finaltsadihebrew'] = 0x05E5;
  16232. t['firsttonechinese'] = 0x02C9;
  16233. t['fisheye'] = 0x25C9;
  16234. t['fitacyrillic'] = 0x0473;
  16235. t['five'] = 0x0035;
  16236. t['fivearabic'] = 0x0665;
  16237. t['fivebengali'] = 0x09EB;
  16238. t['fivecircle'] = 0x2464;
  16239. t['fivecircleinversesansserif'] = 0x278E;
  16240. t['fivedeva'] = 0x096B;
  16241. t['fiveeighths'] = 0x215D;
  16242. t['fivegujarati'] = 0x0AEB;
  16243. t['fivegurmukhi'] = 0x0A6B;
  16244. t['fivehackarabic'] = 0x0665;
  16245. t['fivehangzhou'] = 0x3025;
  16246. t['fiveideographicparen'] = 0x3224;
  16247. t['fiveinferior'] = 0x2085;
  16248. t['fivemonospace'] = 0xFF15;
  16249. t['fiveoldstyle'] = 0xF735;
  16250. t['fiveparen'] = 0x2478;
  16251. t['fiveperiod'] = 0x248C;
  16252. t['fivepersian'] = 0x06F5;
  16253. t['fiveroman'] = 0x2174;
  16254. t['fivesuperior'] = 0x2075;
  16255. t['fivethai'] = 0x0E55;
  16256. t['fl'] = 0xFB02;
  16257. t['florin'] = 0x0192;
  16258. t['fmonospace'] = 0xFF46;
  16259. t['fmsquare'] = 0x3399;
  16260. t['fofanthai'] = 0x0E1F;
  16261. t['fofathai'] = 0x0E1D;
  16262. t['fongmanthai'] = 0x0E4F;
  16263. t['forall'] = 0x2200;
  16264. t['four'] = 0x0034;
  16265. t['fourarabic'] = 0x0664;
  16266. t['fourbengali'] = 0x09EA;
  16267. t['fourcircle'] = 0x2463;
  16268. t['fourcircleinversesansserif'] = 0x278D;
  16269. t['fourdeva'] = 0x096A;
  16270. t['fourgujarati'] = 0x0AEA;
  16271. t['fourgurmukhi'] = 0x0A6A;
  16272. t['fourhackarabic'] = 0x0664;
  16273. t['fourhangzhou'] = 0x3024;
  16274. t['fourideographicparen'] = 0x3223;
  16275. t['fourinferior'] = 0x2084;
  16276. t['fourmonospace'] = 0xFF14;
  16277. t['fournumeratorbengali'] = 0x09F7;
  16278. t['fouroldstyle'] = 0xF734;
  16279. t['fourparen'] = 0x2477;
  16280. t['fourperiod'] = 0x248B;
  16281. t['fourpersian'] = 0x06F4;
  16282. t['fourroman'] = 0x2173;
  16283. t['foursuperior'] = 0x2074;
  16284. t['fourteencircle'] = 0x246D;
  16285. t['fourteenparen'] = 0x2481;
  16286. t['fourteenperiod'] = 0x2495;
  16287. t['fourthai'] = 0x0E54;
  16288. t['fourthtonechinese'] = 0x02CB;
  16289. t['fparen'] = 0x24A1;
  16290. t['fraction'] = 0x2044;
  16291. t['franc'] = 0x20A3;
  16292. t['g'] = 0x0067;
  16293. t['gabengali'] = 0x0997;
  16294. t['gacute'] = 0x01F5;
  16295. t['gadeva'] = 0x0917;
  16296. t['gafarabic'] = 0x06AF;
  16297. t['gaffinalarabic'] = 0xFB93;
  16298. t['gafinitialarabic'] = 0xFB94;
  16299. t['gafmedialarabic'] = 0xFB95;
  16300. t['gagujarati'] = 0x0A97;
  16301. t['gagurmukhi'] = 0x0A17;
  16302. t['gahiragana'] = 0x304C;
  16303. t['gakatakana'] = 0x30AC;
  16304. t['gamma'] = 0x03B3;
  16305. t['gammalatinsmall'] = 0x0263;
  16306. t['gammasuperior'] = 0x02E0;
  16307. t['gangiacoptic'] = 0x03EB;
  16308. t['gbopomofo'] = 0x310D;
  16309. t['gbreve'] = 0x011F;
  16310. t['gcaron'] = 0x01E7;
  16311. t['gcedilla'] = 0x0123;
  16312. t['gcircle'] = 0x24D6;
  16313. t['gcircumflex'] = 0x011D;
  16314. t['gcommaaccent'] = 0x0123;
  16315. t['gdot'] = 0x0121;
  16316. t['gdotaccent'] = 0x0121;
  16317. t['gecyrillic'] = 0x0433;
  16318. t['gehiragana'] = 0x3052;
  16319. t['gekatakana'] = 0x30B2;
  16320. t['geometricallyequal'] = 0x2251;
  16321. t['gereshaccenthebrew'] = 0x059C;
  16322. t['gereshhebrew'] = 0x05F3;
  16323. t['gereshmuqdamhebrew'] = 0x059D;
  16324. t['germandbls'] = 0x00DF;
  16325. t['gershayimaccenthebrew'] = 0x059E;
  16326. t['gershayimhebrew'] = 0x05F4;
  16327. t['getamark'] = 0x3013;
  16328. t['ghabengali'] = 0x0998;
  16329. t['ghadarmenian'] = 0x0572;
  16330. t['ghadeva'] = 0x0918;
  16331. t['ghagujarati'] = 0x0A98;
  16332. t['ghagurmukhi'] = 0x0A18;
  16333. t['ghainarabic'] = 0x063A;
  16334. t['ghainfinalarabic'] = 0xFECE;
  16335. t['ghaininitialarabic'] = 0xFECF;
  16336. t['ghainmedialarabic'] = 0xFED0;
  16337. t['ghemiddlehookcyrillic'] = 0x0495;
  16338. t['ghestrokecyrillic'] = 0x0493;
  16339. t['gheupturncyrillic'] = 0x0491;
  16340. t['ghhadeva'] = 0x095A;
  16341. t['ghhagurmukhi'] = 0x0A5A;
  16342. t['ghook'] = 0x0260;
  16343. t['ghzsquare'] = 0x3393;
  16344. t['gihiragana'] = 0x304E;
  16345. t['gikatakana'] = 0x30AE;
  16346. t['gimarmenian'] = 0x0563;
  16347. t['gimel'] = 0x05D2;
  16348. t['gimeldagesh'] = 0xFB32;
  16349. t['gimeldageshhebrew'] = 0xFB32;
  16350. t['gimelhebrew'] = 0x05D2;
  16351. t['gjecyrillic'] = 0x0453;
  16352. t['glottalinvertedstroke'] = 0x01BE;
  16353. t['glottalstop'] = 0x0294;
  16354. t['glottalstopinverted'] = 0x0296;
  16355. t['glottalstopmod'] = 0x02C0;
  16356. t['glottalstopreversed'] = 0x0295;
  16357. t['glottalstopreversedmod'] = 0x02C1;
  16358. t['glottalstopreversedsuperior'] = 0x02E4;
  16359. t['glottalstopstroke'] = 0x02A1;
  16360. t['glottalstopstrokereversed'] = 0x02A2;
  16361. t['gmacron'] = 0x1E21;
  16362. t['gmonospace'] = 0xFF47;
  16363. t['gohiragana'] = 0x3054;
  16364. t['gokatakana'] = 0x30B4;
  16365. t['gparen'] = 0x24A2;
  16366. t['gpasquare'] = 0x33AC;
  16367. t['gradient'] = 0x2207;
  16368. t['grave'] = 0x0060;
  16369. t['gravebelowcmb'] = 0x0316;
  16370. t['gravecmb'] = 0x0300;
  16371. t['gravecomb'] = 0x0300;
  16372. t['gravedeva'] = 0x0953;
  16373. t['gravelowmod'] = 0x02CE;
  16374. t['gravemonospace'] = 0xFF40;
  16375. t['gravetonecmb'] = 0x0340;
  16376. t['greater'] = 0x003E;
  16377. t['greaterequal'] = 0x2265;
  16378. t['greaterequalorless'] = 0x22DB;
  16379. t['greatermonospace'] = 0xFF1E;
  16380. t['greaterorequivalent'] = 0x2273;
  16381. t['greaterorless'] = 0x2277;
  16382. t['greateroverequal'] = 0x2267;
  16383. t['greatersmall'] = 0xFE65;
  16384. t['gscript'] = 0x0261;
  16385. t['gstroke'] = 0x01E5;
  16386. t['guhiragana'] = 0x3050;
  16387. t['guillemotleft'] = 0x00AB;
  16388. t['guillemotright'] = 0x00BB;
  16389. t['guilsinglleft'] = 0x2039;
  16390. t['guilsinglright'] = 0x203A;
  16391. t['gukatakana'] = 0x30B0;
  16392. t['guramusquare'] = 0x3318;
  16393. t['gysquare'] = 0x33C9;
  16394. t['h'] = 0x0068;
  16395. t['haabkhasiancyrillic'] = 0x04A9;
  16396. t['haaltonearabic'] = 0x06C1;
  16397. t['habengali'] = 0x09B9;
  16398. t['hadescendercyrillic'] = 0x04B3;
  16399. t['hadeva'] = 0x0939;
  16400. t['hagujarati'] = 0x0AB9;
  16401. t['hagurmukhi'] = 0x0A39;
  16402. t['haharabic'] = 0x062D;
  16403. t['hahfinalarabic'] = 0xFEA2;
  16404. t['hahinitialarabic'] = 0xFEA3;
  16405. t['hahiragana'] = 0x306F;
  16406. t['hahmedialarabic'] = 0xFEA4;
  16407. t['haitusquare'] = 0x332A;
  16408. t['hakatakana'] = 0x30CF;
  16409. t['hakatakanahalfwidth'] = 0xFF8A;
  16410. t['halantgurmukhi'] = 0x0A4D;
  16411. t['hamzaarabic'] = 0x0621;
  16412. t['hamzalowarabic'] = 0x0621;
  16413. t['hangulfiller'] = 0x3164;
  16414. t['hardsigncyrillic'] = 0x044A;
  16415. t['harpoonleftbarbup'] = 0x21BC;
  16416. t['harpoonrightbarbup'] = 0x21C0;
  16417. t['hasquare'] = 0x33CA;
  16418. t['hatafpatah'] = 0x05B2;
  16419. t['hatafpatah16'] = 0x05B2;
  16420. t['hatafpatah23'] = 0x05B2;
  16421. t['hatafpatah2f'] = 0x05B2;
  16422. t['hatafpatahhebrew'] = 0x05B2;
  16423. t['hatafpatahnarrowhebrew'] = 0x05B2;
  16424. t['hatafpatahquarterhebrew'] = 0x05B2;
  16425. t['hatafpatahwidehebrew'] = 0x05B2;
  16426. t['hatafqamats'] = 0x05B3;
  16427. t['hatafqamats1b'] = 0x05B3;
  16428. t['hatafqamats28'] = 0x05B3;
  16429. t['hatafqamats34'] = 0x05B3;
  16430. t['hatafqamatshebrew'] = 0x05B3;
  16431. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  16432. t['hatafqamatsquarterhebrew'] = 0x05B3;
  16433. t['hatafqamatswidehebrew'] = 0x05B3;
  16434. t['hatafsegol'] = 0x05B1;
  16435. t['hatafsegol17'] = 0x05B1;
  16436. t['hatafsegol24'] = 0x05B1;
  16437. t['hatafsegol30'] = 0x05B1;
  16438. t['hatafsegolhebrew'] = 0x05B1;
  16439. t['hatafsegolnarrowhebrew'] = 0x05B1;
  16440. t['hatafsegolquarterhebrew'] = 0x05B1;
  16441. t['hatafsegolwidehebrew'] = 0x05B1;
  16442. t['hbar'] = 0x0127;
  16443. t['hbopomofo'] = 0x310F;
  16444. t['hbrevebelow'] = 0x1E2B;
  16445. t['hcedilla'] = 0x1E29;
  16446. t['hcircle'] = 0x24D7;
  16447. t['hcircumflex'] = 0x0125;
  16448. t['hdieresis'] = 0x1E27;
  16449. t['hdotaccent'] = 0x1E23;
  16450. t['hdotbelow'] = 0x1E25;
  16451. t['he'] = 0x05D4;
  16452. t['heart'] = 0x2665;
  16453. t['heartsuitblack'] = 0x2665;
  16454. t['heartsuitwhite'] = 0x2661;
  16455. t['hedagesh'] = 0xFB34;
  16456. t['hedageshhebrew'] = 0xFB34;
  16457. t['hehaltonearabic'] = 0x06C1;
  16458. t['heharabic'] = 0x0647;
  16459. t['hehebrew'] = 0x05D4;
  16460. t['hehfinalaltonearabic'] = 0xFBA7;
  16461. t['hehfinalalttwoarabic'] = 0xFEEA;
  16462. t['hehfinalarabic'] = 0xFEEA;
  16463. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  16464. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  16465. t['hehinitialaltonearabic'] = 0xFBA8;
  16466. t['hehinitialarabic'] = 0xFEEB;
  16467. t['hehiragana'] = 0x3078;
  16468. t['hehmedialaltonearabic'] = 0xFBA9;
  16469. t['hehmedialarabic'] = 0xFEEC;
  16470. t['heiseierasquare'] = 0x337B;
  16471. t['hekatakana'] = 0x30D8;
  16472. t['hekatakanahalfwidth'] = 0xFF8D;
  16473. t['hekutaarusquare'] = 0x3336;
  16474. t['henghook'] = 0x0267;
  16475. t['herutusquare'] = 0x3339;
  16476. t['het'] = 0x05D7;
  16477. t['hethebrew'] = 0x05D7;
  16478. t['hhook'] = 0x0266;
  16479. t['hhooksuperior'] = 0x02B1;
  16480. t['hieuhacirclekorean'] = 0x327B;
  16481. t['hieuhaparenkorean'] = 0x321B;
  16482. t['hieuhcirclekorean'] = 0x326D;
  16483. t['hieuhkorean'] = 0x314E;
  16484. t['hieuhparenkorean'] = 0x320D;
  16485. t['hihiragana'] = 0x3072;
  16486. t['hikatakana'] = 0x30D2;
  16487. t['hikatakanahalfwidth'] = 0xFF8B;
  16488. t['hiriq'] = 0x05B4;
  16489. t['hiriq14'] = 0x05B4;
  16490. t['hiriq21'] = 0x05B4;
  16491. t['hiriq2d'] = 0x05B4;
  16492. t['hiriqhebrew'] = 0x05B4;
  16493. t['hiriqnarrowhebrew'] = 0x05B4;
  16494. t['hiriqquarterhebrew'] = 0x05B4;
  16495. t['hiriqwidehebrew'] = 0x05B4;
  16496. t['hlinebelow'] = 0x1E96;
  16497. t['hmonospace'] = 0xFF48;
  16498. t['hoarmenian'] = 0x0570;
  16499. t['hohipthai'] = 0x0E2B;
  16500. t['hohiragana'] = 0x307B;
  16501. t['hokatakana'] = 0x30DB;
  16502. t['hokatakanahalfwidth'] = 0xFF8E;
  16503. t['holam'] = 0x05B9;
  16504. t['holam19'] = 0x05B9;
  16505. t['holam26'] = 0x05B9;
  16506. t['holam32'] = 0x05B9;
  16507. t['holamhebrew'] = 0x05B9;
  16508. t['holamnarrowhebrew'] = 0x05B9;
  16509. t['holamquarterhebrew'] = 0x05B9;
  16510. t['holamwidehebrew'] = 0x05B9;
  16511. t['honokhukthai'] = 0x0E2E;
  16512. t['hookabovecomb'] = 0x0309;
  16513. t['hookcmb'] = 0x0309;
  16514. t['hookpalatalizedbelowcmb'] = 0x0321;
  16515. t['hookretroflexbelowcmb'] = 0x0322;
  16516. t['hoonsquare'] = 0x3342;
  16517. t['horicoptic'] = 0x03E9;
  16518. t['horizontalbar'] = 0x2015;
  16519. t['horncmb'] = 0x031B;
  16520. t['hotsprings'] = 0x2668;
  16521. t['house'] = 0x2302;
  16522. t['hparen'] = 0x24A3;
  16523. t['hsuperior'] = 0x02B0;
  16524. t['hturned'] = 0x0265;
  16525. t['huhiragana'] = 0x3075;
  16526. t['huiitosquare'] = 0x3333;
  16527. t['hukatakana'] = 0x30D5;
  16528. t['hukatakanahalfwidth'] = 0xFF8C;
  16529. t['hungarumlaut'] = 0x02DD;
  16530. t['hungarumlautcmb'] = 0x030B;
  16531. t['hv'] = 0x0195;
  16532. t['hyphen'] = 0x002D;
  16533. t['hypheninferior'] = 0xF6E5;
  16534. t['hyphenmonospace'] = 0xFF0D;
  16535. t['hyphensmall'] = 0xFE63;
  16536. t['hyphensuperior'] = 0xF6E6;
  16537. t['hyphentwo'] = 0x2010;
  16538. t['i'] = 0x0069;
  16539. t['iacute'] = 0x00ED;
  16540. t['iacyrillic'] = 0x044F;
  16541. t['ibengali'] = 0x0987;
  16542. t['ibopomofo'] = 0x3127;
  16543. t['ibreve'] = 0x012D;
  16544. t['icaron'] = 0x01D0;
  16545. t['icircle'] = 0x24D8;
  16546. t['icircumflex'] = 0x00EE;
  16547. t['icyrillic'] = 0x0456;
  16548. t['idblgrave'] = 0x0209;
  16549. t['ideographearthcircle'] = 0x328F;
  16550. t['ideographfirecircle'] = 0x328B;
  16551. t['ideographicallianceparen'] = 0x323F;
  16552. t['ideographiccallparen'] = 0x323A;
  16553. t['ideographiccentrecircle'] = 0x32A5;
  16554. t['ideographicclose'] = 0x3006;
  16555. t['ideographiccomma'] = 0x3001;
  16556. t['ideographiccommaleft'] = 0xFF64;
  16557. t['ideographiccongratulationparen'] = 0x3237;
  16558. t['ideographiccorrectcircle'] = 0x32A3;
  16559. t['ideographicearthparen'] = 0x322F;
  16560. t['ideographicenterpriseparen'] = 0x323D;
  16561. t['ideographicexcellentcircle'] = 0x329D;
  16562. t['ideographicfestivalparen'] = 0x3240;
  16563. t['ideographicfinancialcircle'] = 0x3296;
  16564. t['ideographicfinancialparen'] = 0x3236;
  16565. t['ideographicfireparen'] = 0x322B;
  16566. t['ideographichaveparen'] = 0x3232;
  16567. t['ideographichighcircle'] = 0x32A4;
  16568. t['ideographiciterationmark'] = 0x3005;
  16569. t['ideographiclaborcircle'] = 0x3298;
  16570. t['ideographiclaborparen'] = 0x3238;
  16571. t['ideographicleftcircle'] = 0x32A7;
  16572. t['ideographiclowcircle'] = 0x32A6;
  16573. t['ideographicmedicinecircle'] = 0x32A9;
  16574. t['ideographicmetalparen'] = 0x322E;
  16575. t['ideographicmoonparen'] = 0x322A;
  16576. t['ideographicnameparen'] = 0x3234;
  16577. t['ideographicperiod'] = 0x3002;
  16578. t['ideographicprintcircle'] = 0x329E;
  16579. t['ideographicreachparen'] = 0x3243;
  16580. t['ideographicrepresentparen'] = 0x3239;
  16581. t['ideographicresourceparen'] = 0x323E;
  16582. t['ideographicrightcircle'] = 0x32A8;
  16583. t['ideographicsecretcircle'] = 0x3299;
  16584. t['ideographicselfparen'] = 0x3242;
  16585. t['ideographicsocietyparen'] = 0x3233;
  16586. t['ideographicspace'] = 0x3000;
  16587. t['ideographicspecialparen'] = 0x3235;
  16588. t['ideographicstockparen'] = 0x3231;
  16589. t['ideographicstudyparen'] = 0x323B;
  16590. t['ideographicsunparen'] = 0x3230;
  16591. t['ideographicsuperviseparen'] = 0x323C;
  16592. t['ideographicwaterparen'] = 0x322C;
  16593. t['ideographicwoodparen'] = 0x322D;
  16594. t['ideographiczero'] = 0x3007;
  16595. t['ideographmetalcircle'] = 0x328E;
  16596. t['ideographmooncircle'] = 0x328A;
  16597. t['ideographnamecircle'] = 0x3294;
  16598. t['ideographsuncircle'] = 0x3290;
  16599. t['ideographwatercircle'] = 0x328C;
  16600. t['ideographwoodcircle'] = 0x328D;
  16601. t['ideva'] = 0x0907;
  16602. t['idieresis'] = 0x00EF;
  16603. t['idieresisacute'] = 0x1E2F;
  16604. t['idieresiscyrillic'] = 0x04E5;
  16605. t['idotbelow'] = 0x1ECB;
  16606. t['iebrevecyrillic'] = 0x04D7;
  16607. t['iecyrillic'] = 0x0435;
  16608. t['ieungacirclekorean'] = 0x3275;
  16609. t['ieungaparenkorean'] = 0x3215;
  16610. t['ieungcirclekorean'] = 0x3267;
  16611. t['ieungkorean'] = 0x3147;
  16612. t['ieungparenkorean'] = 0x3207;
  16613. t['igrave'] = 0x00EC;
  16614. t['igujarati'] = 0x0A87;
  16615. t['igurmukhi'] = 0x0A07;
  16616. t['ihiragana'] = 0x3044;
  16617. t['ihookabove'] = 0x1EC9;
  16618. t['iibengali'] = 0x0988;
  16619. t['iicyrillic'] = 0x0438;
  16620. t['iideva'] = 0x0908;
  16621. t['iigujarati'] = 0x0A88;
  16622. t['iigurmukhi'] = 0x0A08;
  16623. t['iimatragurmukhi'] = 0x0A40;
  16624. t['iinvertedbreve'] = 0x020B;
  16625. t['iishortcyrillic'] = 0x0439;
  16626. t['iivowelsignbengali'] = 0x09C0;
  16627. t['iivowelsigndeva'] = 0x0940;
  16628. t['iivowelsigngujarati'] = 0x0AC0;
  16629. t['ij'] = 0x0133;
  16630. t['ikatakana'] = 0x30A4;
  16631. t['ikatakanahalfwidth'] = 0xFF72;
  16632. t['ikorean'] = 0x3163;
  16633. t['ilde'] = 0x02DC;
  16634. t['iluyhebrew'] = 0x05AC;
  16635. t['imacron'] = 0x012B;
  16636. t['imacroncyrillic'] = 0x04E3;
  16637. t['imageorapproximatelyequal'] = 0x2253;
  16638. t['imatragurmukhi'] = 0x0A3F;
  16639. t['imonospace'] = 0xFF49;
  16640. t['increment'] = 0x2206;
  16641. t['infinity'] = 0x221E;
  16642. t['iniarmenian'] = 0x056B;
  16643. t['integral'] = 0x222B;
  16644. t['integralbottom'] = 0x2321;
  16645. t['integralbt'] = 0x2321;
  16646. t['integralex'] = 0xF8F5;
  16647. t['integraltop'] = 0x2320;
  16648. t['integraltp'] = 0x2320;
  16649. t['intersection'] = 0x2229;
  16650. t['intisquare'] = 0x3305;
  16651. t['invbullet'] = 0x25D8;
  16652. t['invcircle'] = 0x25D9;
  16653. t['invsmileface'] = 0x263B;
  16654. t['iocyrillic'] = 0x0451;
  16655. t['iogonek'] = 0x012F;
  16656. t['iota'] = 0x03B9;
  16657. t['iotadieresis'] = 0x03CA;
  16658. t['iotadieresistonos'] = 0x0390;
  16659. t['iotalatin'] = 0x0269;
  16660. t['iotatonos'] = 0x03AF;
  16661. t['iparen'] = 0x24A4;
  16662. t['irigurmukhi'] = 0x0A72;
  16663. t['ismallhiragana'] = 0x3043;
  16664. t['ismallkatakana'] = 0x30A3;
  16665. t['ismallkatakanahalfwidth'] = 0xFF68;
  16666. t['issharbengali'] = 0x09FA;
  16667. t['istroke'] = 0x0268;
  16668. t['isuperior'] = 0xF6ED;
  16669. t['iterationhiragana'] = 0x309D;
  16670. t['iterationkatakana'] = 0x30FD;
  16671. t['itilde'] = 0x0129;
  16672. t['itildebelow'] = 0x1E2D;
  16673. t['iubopomofo'] = 0x3129;
  16674. t['iucyrillic'] = 0x044E;
  16675. t['ivowelsignbengali'] = 0x09BF;
  16676. t['ivowelsigndeva'] = 0x093F;
  16677. t['ivowelsigngujarati'] = 0x0ABF;
  16678. t['izhitsacyrillic'] = 0x0475;
  16679. t['izhitsadblgravecyrillic'] = 0x0477;
  16680. t['j'] = 0x006A;
  16681. t['jaarmenian'] = 0x0571;
  16682. t['jabengali'] = 0x099C;
  16683. t['jadeva'] = 0x091C;
  16684. t['jagujarati'] = 0x0A9C;
  16685. t['jagurmukhi'] = 0x0A1C;
  16686. t['jbopomofo'] = 0x3110;
  16687. t['jcaron'] = 0x01F0;
  16688. t['jcircle'] = 0x24D9;
  16689. t['jcircumflex'] = 0x0135;
  16690. t['jcrossedtail'] = 0x029D;
  16691. t['jdotlessstroke'] = 0x025F;
  16692. t['jecyrillic'] = 0x0458;
  16693. t['jeemarabic'] = 0x062C;
  16694. t['jeemfinalarabic'] = 0xFE9E;
  16695. t['jeeminitialarabic'] = 0xFE9F;
  16696. t['jeemmedialarabic'] = 0xFEA0;
  16697. t['jeharabic'] = 0x0698;
  16698. t['jehfinalarabic'] = 0xFB8B;
  16699. t['jhabengali'] = 0x099D;
  16700. t['jhadeva'] = 0x091D;
  16701. t['jhagujarati'] = 0x0A9D;
  16702. t['jhagurmukhi'] = 0x0A1D;
  16703. t['jheharmenian'] = 0x057B;
  16704. t['jis'] = 0x3004;
  16705. t['jmonospace'] = 0xFF4A;
  16706. t['jparen'] = 0x24A5;
  16707. t['jsuperior'] = 0x02B2;
  16708. t['k'] = 0x006B;
  16709. t['kabashkircyrillic'] = 0x04A1;
  16710. t['kabengali'] = 0x0995;
  16711. t['kacute'] = 0x1E31;
  16712. t['kacyrillic'] = 0x043A;
  16713. t['kadescendercyrillic'] = 0x049B;
  16714. t['kadeva'] = 0x0915;
  16715. t['kaf'] = 0x05DB;
  16716. t['kafarabic'] = 0x0643;
  16717. t['kafdagesh'] = 0xFB3B;
  16718. t['kafdageshhebrew'] = 0xFB3B;
  16719. t['kaffinalarabic'] = 0xFEDA;
  16720. t['kafhebrew'] = 0x05DB;
  16721. t['kafinitialarabic'] = 0xFEDB;
  16722. t['kafmedialarabic'] = 0xFEDC;
  16723. t['kafrafehebrew'] = 0xFB4D;
  16724. t['kagujarati'] = 0x0A95;
  16725. t['kagurmukhi'] = 0x0A15;
  16726. t['kahiragana'] = 0x304B;
  16727. t['kahookcyrillic'] = 0x04C4;
  16728. t['kakatakana'] = 0x30AB;
  16729. t['kakatakanahalfwidth'] = 0xFF76;
  16730. t['kappa'] = 0x03BA;
  16731. t['kappasymbolgreek'] = 0x03F0;
  16732. t['kapyeounmieumkorean'] = 0x3171;
  16733. t['kapyeounphieuphkorean'] = 0x3184;
  16734. t['kapyeounpieupkorean'] = 0x3178;
  16735. t['kapyeounssangpieupkorean'] = 0x3179;
  16736. t['karoriisquare'] = 0x330D;
  16737. t['kashidaautoarabic'] = 0x0640;
  16738. t['kashidaautonosidebearingarabic'] = 0x0640;
  16739. t['kasmallkatakana'] = 0x30F5;
  16740. t['kasquare'] = 0x3384;
  16741. t['kasraarabic'] = 0x0650;
  16742. t['kasratanarabic'] = 0x064D;
  16743. t['kastrokecyrillic'] = 0x049F;
  16744. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  16745. t['kaverticalstrokecyrillic'] = 0x049D;
  16746. t['kbopomofo'] = 0x310E;
  16747. t['kcalsquare'] = 0x3389;
  16748. t['kcaron'] = 0x01E9;
  16749. t['kcedilla'] = 0x0137;
  16750. t['kcircle'] = 0x24DA;
  16751. t['kcommaaccent'] = 0x0137;
  16752. t['kdotbelow'] = 0x1E33;
  16753. t['keharmenian'] = 0x0584;
  16754. t['kehiragana'] = 0x3051;
  16755. t['kekatakana'] = 0x30B1;
  16756. t['kekatakanahalfwidth'] = 0xFF79;
  16757. t['kenarmenian'] = 0x056F;
  16758. t['kesmallkatakana'] = 0x30F6;
  16759. t['kgreenlandic'] = 0x0138;
  16760. t['khabengali'] = 0x0996;
  16761. t['khacyrillic'] = 0x0445;
  16762. t['khadeva'] = 0x0916;
  16763. t['khagujarati'] = 0x0A96;
  16764. t['khagurmukhi'] = 0x0A16;
  16765. t['khaharabic'] = 0x062E;
  16766. t['khahfinalarabic'] = 0xFEA6;
  16767. t['khahinitialarabic'] = 0xFEA7;
  16768. t['khahmedialarabic'] = 0xFEA8;
  16769. t['kheicoptic'] = 0x03E7;
  16770. t['khhadeva'] = 0x0959;
  16771. t['khhagurmukhi'] = 0x0A59;
  16772. t['khieukhacirclekorean'] = 0x3278;
  16773. t['khieukhaparenkorean'] = 0x3218;
  16774. t['khieukhcirclekorean'] = 0x326A;
  16775. t['khieukhkorean'] = 0x314B;
  16776. t['khieukhparenkorean'] = 0x320A;
  16777. t['khokhaithai'] = 0x0E02;
  16778. t['khokhonthai'] = 0x0E05;
  16779. t['khokhuatthai'] = 0x0E03;
  16780. t['khokhwaithai'] = 0x0E04;
  16781. t['khomutthai'] = 0x0E5B;
  16782. t['khook'] = 0x0199;
  16783. t['khorakhangthai'] = 0x0E06;
  16784. t['khzsquare'] = 0x3391;
  16785. t['kihiragana'] = 0x304D;
  16786. t['kikatakana'] = 0x30AD;
  16787. t['kikatakanahalfwidth'] = 0xFF77;
  16788. t['kiroguramusquare'] = 0x3315;
  16789. t['kiromeetorusquare'] = 0x3316;
  16790. t['kirosquare'] = 0x3314;
  16791. t['kiyeokacirclekorean'] = 0x326E;
  16792. t['kiyeokaparenkorean'] = 0x320E;
  16793. t['kiyeokcirclekorean'] = 0x3260;
  16794. t['kiyeokkorean'] = 0x3131;
  16795. t['kiyeokparenkorean'] = 0x3200;
  16796. t['kiyeoksioskorean'] = 0x3133;
  16797. t['kjecyrillic'] = 0x045C;
  16798. t['klinebelow'] = 0x1E35;
  16799. t['klsquare'] = 0x3398;
  16800. t['kmcubedsquare'] = 0x33A6;
  16801. t['kmonospace'] = 0xFF4B;
  16802. t['kmsquaredsquare'] = 0x33A2;
  16803. t['kohiragana'] = 0x3053;
  16804. t['kohmsquare'] = 0x33C0;
  16805. t['kokaithai'] = 0x0E01;
  16806. t['kokatakana'] = 0x30B3;
  16807. t['kokatakanahalfwidth'] = 0xFF7A;
  16808. t['kooposquare'] = 0x331E;
  16809. t['koppacyrillic'] = 0x0481;
  16810. t['koreanstandardsymbol'] = 0x327F;
  16811. t['koroniscmb'] = 0x0343;
  16812. t['kparen'] = 0x24A6;
  16813. t['kpasquare'] = 0x33AA;
  16814. t['ksicyrillic'] = 0x046F;
  16815. t['ktsquare'] = 0x33CF;
  16816. t['kturned'] = 0x029E;
  16817. t['kuhiragana'] = 0x304F;
  16818. t['kukatakana'] = 0x30AF;
  16819. t['kukatakanahalfwidth'] = 0xFF78;
  16820. t['kvsquare'] = 0x33B8;
  16821. t['kwsquare'] = 0x33BE;
  16822. t['l'] = 0x006C;
  16823. t['labengali'] = 0x09B2;
  16824. t['lacute'] = 0x013A;
  16825. t['ladeva'] = 0x0932;
  16826. t['lagujarati'] = 0x0AB2;
  16827. t['lagurmukhi'] = 0x0A32;
  16828. t['lakkhangyaothai'] = 0x0E45;
  16829. t['lamaleffinalarabic'] = 0xFEFC;
  16830. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  16831. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  16832. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  16833. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  16834. t['lamalefisolatedarabic'] = 0xFEFB;
  16835. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  16836. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  16837. t['lamarabic'] = 0x0644;
  16838. t['lambda'] = 0x03BB;
  16839. t['lambdastroke'] = 0x019B;
  16840. t['lamed'] = 0x05DC;
  16841. t['lameddagesh'] = 0xFB3C;
  16842. t['lameddageshhebrew'] = 0xFB3C;
  16843. t['lamedhebrew'] = 0x05DC;
  16844. t['lamfinalarabic'] = 0xFEDE;
  16845. t['lamhahinitialarabic'] = 0xFCCA;
  16846. t['laminitialarabic'] = 0xFEDF;
  16847. t['lamjeeminitialarabic'] = 0xFCC9;
  16848. t['lamkhahinitialarabic'] = 0xFCCB;
  16849. t['lamlamhehisolatedarabic'] = 0xFDF2;
  16850. t['lammedialarabic'] = 0xFEE0;
  16851. t['lammeemhahinitialarabic'] = 0xFD88;
  16852. t['lammeeminitialarabic'] = 0xFCCC;
  16853. t['largecircle'] = 0x25EF;
  16854. t['lbar'] = 0x019A;
  16855. t['lbelt'] = 0x026C;
  16856. t['lbopomofo'] = 0x310C;
  16857. t['lcaron'] = 0x013E;
  16858. t['lcedilla'] = 0x013C;
  16859. t['lcircle'] = 0x24DB;
  16860. t['lcircumflexbelow'] = 0x1E3D;
  16861. t['lcommaaccent'] = 0x013C;
  16862. t['ldot'] = 0x0140;
  16863. t['ldotaccent'] = 0x0140;
  16864. t['ldotbelow'] = 0x1E37;
  16865. t['ldotbelowmacron'] = 0x1E39;
  16866. t['leftangleabovecmb'] = 0x031A;
  16867. t['lefttackbelowcmb'] = 0x0318;
  16868. t['less'] = 0x003C;
  16869. t['lessequal'] = 0x2264;
  16870. t['lessequalorgreater'] = 0x22DA;
  16871. t['lessmonospace'] = 0xFF1C;
  16872. t['lessorequivalent'] = 0x2272;
  16873. t['lessorgreater'] = 0x2276;
  16874. t['lessoverequal'] = 0x2266;
  16875. t['lesssmall'] = 0xFE64;
  16876. t['lezh'] = 0x026E;
  16877. t['lfblock'] = 0x258C;
  16878. t['lhookretroflex'] = 0x026D;
  16879. t['lira'] = 0x20A4;
  16880. t['liwnarmenian'] = 0x056C;
  16881. t['lj'] = 0x01C9;
  16882. t['ljecyrillic'] = 0x0459;
  16883. t['ll'] = 0xF6C0;
  16884. t['lladeva'] = 0x0933;
  16885. t['llagujarati'] = 0x0AB3;
  16886. t['llinebelow'] = 0x1E3B;
  16887. t['llladeva'] = 0x0934;
  16888. t['llvocalicbengali'] = 0x09E1;
  16889. t['llvocalicdeva'] = 0x0961;
  16890. t['llvocalicvowelsignbengali'] = 0x09E3;
  16891. t['llvocalicvowelsigndeva'] = 0x0963;
  16892. t['lmiddletilde'] = 0x026B;
  16893. t['lmonospace'] = 0xFF4C;
  16894. t['lmsquare'] = 0x33D0;
  16895. t['lochulathai'] = 0x0E2C;
  16896. t['logicaland'] = 0x2227;
  16897. t['logicalnot'] = 0x00AC;
  16898. t['logicalnotreversed'] = 0x2310;
  16899. t['logicalor'] = 0x2228;
  16900. t['lolingthai'] = 0x0E25;
  16901. t['longs'] = 0x017F;
  16902. t['lowlinecenterline'] = 0xFE4E;
  16903. t['lowlinecmb'] = 0x0332;
  16904. t['lowlinedashed'] = 0xFE4D;
  16905. t['lozenge'] = 0x25CA;
  16906. t['lparen'] = 0x24A7;
  16907. t['lslash'] = 0x0142;
  16908. t['lsquare'] = 0x2113;
  16909. t['lsuperior'] = 0xF6EE;
  16910. t['ltshade'] = 0x2591;
  16911. t['luthai'] = 0x0E26;
  16912. t['lvocalicbengali'] = 0x098C;
  16913. t['lvocalicdeva'] = 0x090C;
  16914. t['lvocalicvowelsignbengali'] = 0x09E2;
  16915. t['lvocalicvowelsigndeva'] = 0x0962;
  16916. t['lxsquare'] = 0x33D3;
  16917. t['m'] = 0x006D;
  16918. t['mabengali'] = 0x09AE;
  16919. t['macron'] = 0x00AF;
  16920. t['macronbelowcmb'] = 0x0331;
  16921. t['macroncmb'] = 0x0304;
  16922. t['macronlowmod'] = 0x02CD;
  16923. t['macronmonospace'] = 0xFFE3;
  16924. t['macute'] = 0x1E3F;
  16925. t['madeva'] = 0x092E;
  16926. t['magujarati'] = 0x0AAE;
  16927. t['magurmukhi'] = 0x0A2E;
  16928. t['mahapakhhebrew'] = 0x05A4;
  16929. t['mahapakhlefthebrew'] = 0x05A4;
  16930. t['mahiragana'] = 0x307E;
  16931. t['maichattawalowleftthai'] = 0xF895;
  16932. t['maichattawalowrightthai'] = 0xF894;
  16933. t['maichattawathai'] = 0x0E4B;
  16934. t['maichattawaupperleftthai'] = 0xF893;
  16935. t['maieklowleftthai'] = 0xF88C;
  16936. t['maieklowrightthai'] = 0xF88B;
  16937. t['maiekthai'] = 0x0E48;
  16938. t['maiekupperleftthai'] = 0xF88A;
  16939. t['maihanakatleftthai'] = 0xF884;
  16940. t['maihanakatthai'] = 0x0E31;
  16941. t['maitaikhuleftthai'] = 0xF889;
  16942. t['maitaikhuthai'] = 0x0E47;
  16943. t['maitholowleftthai'] = 0xF88F;
  16944. t['maitholowrightthai'] = 0xF88E;
  16945. t['maithothai'] = 0x0E49;
  16946. t['maithoupperleftthai'] = 0xF88D;
  16947. t['maitrilowleftthai'] = 0xF892;
  16948. t['maitrilowrightthai'] = 0xF891;
  16949. t['maitrithai'] = 0x0E4A;
  16950. t['maitriupperleftthai'] = 0xF890;
  16951. t['maiyamokthai'] = 0x0E46;
  16952. t['makatakana'] = 0x30DE;
  16953. t['makatakanahalfwidth'] = 0xFF8F;
  16954. t['male'] = 0x2642;
  16955. t['mansyonsquare'] = 0x3347;
  16956. t['maqafhebrew'] = 0x05BE;
  16957. t['mars'] = 0x2642;
  16958. t['masoracirclehebrew'] = 0x05AF;
  16959. t['masquare'] = 0x3383;
  16960. t['mbopomofo'] = 0x3107;
  16961. t['mbsquare'] = 0x33D4;
  16962. t['mcircle'] = 0x24DC;
  16963. t['mcubedsquare'] = 0x33A5;
  16964. t['mdotaccent'] = 0x1E41;
  16965. t['mdotbelow'] = 0x1E43;
  16966. t['meemarabic'] = 0x0645;
  16967. t['meemfinalarabic'] = 0xFEE2;
  16968. t['meeminitialarabic'] = 0xFEE3;
  16969. t['meemmedialarabic'] = 0xFEE4;
  16970. t['meemmeeminitialarabic'] = 0xFCD1;
  16971. t['meemmeemisolatedarabic'] = 0xFC48;
  16972. t['meetorusquare'] = 0x334D;
  16973. t['mehiragana'] = 0x3081;
  16974. t['meizierasquare'] = 0x337E;
  16975. t['mekatakana'] = 0x30E1;
  16976. t['mekatakanahalfwidth'] = 0xFF92;
  16977. t['mem'] = 0x05DE;
  16978. t['memdagesh'] = 0xFB3E;
  16979. t['memdageshhebrew'] = 0xFB3E;
  16980. t['memhebrew'] = 0x05DE;
  16981. t['menarmenian'] = 0x0574;
  16982. t['merkhahebrew'] = 0x05A5;
  16983. t['merkhakefulahebrew'] = 0x05A6;
  16984. t['merkhakefulalefthebrew'] = 0x05A6;
  16985. t['merkhalefthebrew'] = 0x05A5;
  16986. t['mhook'] = 0x0271;
  16987. t['mhzsquare'] = 0x3392;
  16988. t['middledotkatakanahalfwidth'] = 0xFF65;
  16989. t['middot'] = 0x00B7;
  16990. t['mieumacirclekorean'] = 0x3272;
  16991. t['mieumaparenkorean'] = 0x3212;
  16992. t['mieumcirclekorean'] = 0x3264;
  16993. t['mieumkorean'] = 0x3141;
  16994. t['mieumpansioskorean'] = 0x3170;
  16995. t['mieumparenkorean'] = 0x3204;
  16996. t['mieumpieupkorean'] = 0x316E;
  16997. t['mieumsioskorean'] = 0x316F;
  16998. t['mihiragana'] = 0x307F;
  16999. t['mikatakana'] = 0x30DF;
  17000. t['mikatakanahalfwidth'] = 0xFF90;
  17001. t['minus'] = 0x2212;
  17002. t['minusbelowcmb'] = 0x0320;
  17003. t['minuscircle'] = 0x2296;
  17004. t['minusmod'] = 0x02D7;
  17005. t['minusplus'] = 0x2213;
  17006. t['minute'] = 0x2032;
  17007. t['miribaarusquare'] = 0x334A;
  17008. t['mirisquare'] = 0x3349;
  17009. t['mlonglegturned'] = 0x0270;
  17010. t['mlsquare'] = 0x3396;
  17011. t['mmcubedsquare'] = 0x33A3;
  17012. t['mmonospace'] = 0xFF4D;
  17013. t['mmsquaredsquare'] = 0x339F;
  17014. t['mohiragana'] = 0x3082;
  17015. t['mohmsquare'] = 0x33C1;
  17016. t['mokatakana'] = 0x30E2;
  17017. t['mokatakanahalfwidth'] = 0xFF93;
  17018. t['molsquare'] = 0x33D6;
  17019. t['momathai'] = 0x0E21;
  17020. t['moverssquare'] = 0x33A7;
  17021. t['moverssquaredsquare'] = 0x33A8;
  17022. t['mparen'] = 0x24A8;
  17023. t['mpasquare'] = 0x33AB;
  17024. t['mssquare'] = 0x33B3;
  17025. t['msuperior'] = 0xF6EF;
  17026. t['mturned'] = 0x026F;
  17027. t['mu'] = 0x00B5;
  17028. t['mu1'] = 0x00B5;
  17029. t['muasquare'] = 0x3382;
  17030. t['muchgreater'] = 0x226B;
  17031. t['muchless'] = 0x226A;
  17032. t['mufsquare'] = 0x338C;
  17033. t['mugreek'] = 0x03BC;
  17034. t['mugsquare'] = 0x338D;
  17035. t['muhiragana'] = 0x3080;
  17036. t['mukatakana'] = 0x30E0;
  17037. t['mukatakanahalfwidth'] = 0xFF91;
  17038. t['mulsquare'] = 0x3395;
  17039. t['multiply'] = 0x00D7;
  17040. t['mumsquare'] = 0x339B;
  17041. t['munahhebrew'] = 0x05A3;
  17042. t['munahlefthebrew'] = 0x05A3;
  17043. t['musicalnote'] = 0x266A;
  17044. t['musicalnotedbl'] = 0x266B;
  17045. t['musicflatsign'] = 0x266D;
  17046. t['musicsharpsign'] = 0x266F;
  17047. t['mussquare'] = 0x33B2;
  17048. t['muvsquare'] = 0x33B6;
  17049. t['muwsquare'] = 0x33BC;
  17050. t['mvmegasquare'] = 0x33B9;
  17051. t['mvsquare'] = 0x33B7;
  17052. t['mwmegasquare'] = 0x33BF;
  17053. t['mwsquare'] = 0x33BD;
  17054. t['n'] = 0x006E;
  17055. t['nabengali'] = 0x09A8;
  17056. t['nabla'] = 0x2207;
  17057. t['nacute'] = 0x0144;
  17058. t['nadeva'] = 0x0928;
  17059. t['nagujarati'] = 0x0AA8;
  17060. t['nagurmukhi'] = 0x0A28;
  17061. t['nahiragana'] = 0x306A;
  17062. t['nakatakana'] = 0x30CA;
  17063. t['nakatakanahalfwidth'] = 0xFF85;
  17064. t['napostrophe'] = 0x0149;
  17065. t['nasquare'] = 0x3381;
  17066. t['nbopomofo'] = 0x310B;
  17067. t['nbspace'] = 0x00A0;
  17068. t['ncaron'] = 0x0148;
  17069. t['ncedilla'] = 0x0146;
  17070. t['ncircle'] = 0x24DD;
  17071. t['ncircumflexbelow'] = 0x1E4B;
  17072. t['ncommaaccent'] = 0x0146;
  17073. t['ndotaccent'] = 0x1E45;
  17074. t['ndotbelow'] = 0x1E47;
  17075. t['nehiragana'] = 0x306D;
  17076. t['nekatakana'] = 0x30CD;
  17077. t['nekatakanahalfwidth'] = 0xFF88;
  17078. t['newsheqelsign'] = 0x20AA;
  17079. t['nfsquare'] = 0x338B;
  17080. t['ngabengali'] = 0x0999;
  17081. t['ngadeva'] = 0x0919;
  17082. t['ngagujarati'] = 0x0A99;
  17083. t['ngagurmukhi'] = 0x0A19;
  17084. t['ngonguthai'] = 0x0E07;
  17085. t['nhiragana'] = 0x3093;
  17086. t['nhookleft'] = 0x0272;
  17087. t['nhookretroflex'] = 0x0273;
  17088. t['nieunacirclekorean'] = 0x326F;
  17089. t['nieunaparenkorean'] = 0x320F;
  17090. t['nieuncieuckorean'] = 0x3135;
  17091. t['nieuncirclekorean'] = 0x3261;
  17092. t['nieunhieuhkorean'] = 0x3136;
  17093. t['nieunkorean'] = 0x3134;
  17094. t['nieunpansioskorean'] = 0x3168;
  17095. t['nieunparenkorean'] = 0x3201;
  17096. t['nieunsioskorean'] = 0x3167;
  17097. t['nieuntikeutkorean'] = 0x3166;
  17098. t['nihiragana'] = 0x306B;
  17099. t['nikatakana'] = 0x30CB;
  17100. t['nikatakanahalfwidth'] = 0xFF86;
  17101. t['nikhahitleftthai'] = 0xF899;
  17102. t['nikhahitthai'] = 0x0E4D;
  17103. t['nine'] = 0x0039;
  17104. t['ninearabic'] = 0x0669;
  17105. t['ninebengali'] = 0x09EF;
  17106. t['ninecircle'] = 0x2468;
  17107. t['ninecircleinversesansserif'] = 0x2792;
  17108. t['ninedeva'] = 0x096F;
  17109. t['ninegujarati'] = 0x0AEF;
  17110. t['ninegurmukhi'] = 0x0A6F;
  17111. t['ninehackarabic'] = 0x0669;
  17112. t['ninehangzhou'] = 0x3029;
  17113. t['nineideographicparen'] = 0x3228;
  17114. t['nineinferior'] = 0x2089;
  17115. t['ninemonospace'] = 0xFF19;
  17116. t['nineoldstyle'] = 0xF739;
  17117. t['nineparen'] = 0x247C;
  17118. t['nineperiod'] = 0x2490;
  17119. t['ninepersian'] = 0x06F9;
  17120. t['nineroman'] = 0x2178;
  17121. t['ninesuperior'] = 0x2079;
  17122. t['nineteencircle'] = 0x2472;
  17123. t['nineteenparen'] = 0x2486;
  17124. t['nineteenperiod'] = 0x249A;
  17125. t['ninethai'] = 0x0E59;
  17126. t['nj'] = 0x01CC;
  17127. t['njecyrillic'] = 0x045A;
  17128. t['nkatakana'] = 0x30F3;
  17129. t['nkatakanahalfwidth'] = 0xFF9D;
  17130. t['nlegrightlong'] = 0x019E;
  17131. t['nlinebelow'] = 0x1E49;
  17132. t['nmonospace'] = 0xFF4E;
  17133. t['nmsquare'] = 0x339A;
  17134. t['nnabengali'] = 0x09A3;
  17135. t['nnadeva'] = 0x0923;
  17136. t['nnagujarati'] = 0x0AA3;
  17137. t['nnagurmukhi'] = 0x0A23;
  17138. t['nnnadeva'] = 0x0929;
  17139. t['nohiragana'] = 0x306E;
  17140. t['nokatakana'] = 0x30CE;
  17141. t['nokatakanahalfwidth'] = 0xFF89;
  17142. t['nonbreakingspace'] = 0x00A0;
  17143. t['nonenthai'] = 0x0E13;
  17144. t['nonuthai'] = 0x0E19;
  17145. t['noonarabic'] = 0x0646;
  17146. t['noonfinalarabic'] = 0xFEE6;
  17147. t['noonghunnaarabic'] = 0x06BA;
  17148. t['noonghunnafinalarabic'] = 0xFB9F;
  17149. t['nooninitialarabic'] = 0xFEE7;
  17150. t['noonjeeminitialarabic'] = 0xFCD2;
  17151. t['noonjeemisolatedarabic'] = 0xFC4B;
  17152. t['noonmedialarabic'] = 0xFEE8;
  17153. t['noonmeeminitialarabic'] = 0xFCD5;
  17154. t['noonmeemisolatedarabic'] = 0xFC4E;
  17155. t['noonnoonfinalarabic'] = 0xFC8D;
  17156. t['notcontains'] = 0x220C;
  17157. t['notelement'] = 0x2209;
  17158. t['notelementof'] = 0x2209;
  17159. t['notequal'] = 0x2260;
  17160. t['notgreater'] = 0x226F;
  17161. t['notgreaternorequal'] = 0x2271;
  17162. t['notgreaternorless'] = 0x2279;
  17163. t['notidentical'] = 0x2262;
  17164. t['notless'] = 0x226E;
  17165. t['notlessnorequal'] = 0x2270;
  17166. t['notparallel'] = 0x2226;
  17167. t['notprecedes'] = 0x2280;
  17168. t['notsubset'] = 0x2284;
  17169. t['notsucceeds'] = 0x2281;
  17170. t['notsuperset'] = 0x2285;
  17171. t['nowarmenian'] = 0x0576;
  17172. t['nparen'] = 0x24A9;
  17173. t['nssquare'] = 0x33B1;
  17174. t['nsuperior'] = 0x207F;
  17175. t['ntilde'] = 0x00F1;
  17176. t['nu'] = 0x03BD;
  17177. t['nuhiragana'] = 0x306C;
  17178. t['nukatakana'] = 0x30CC;
  17179. t['nukatakanahalfwidth'] = 0xFF87;
  17180. t['nuktabengali'] = 0x09BC;
  17181. t['nuktadeva'] = 0x093C;
  17182. t['nuktagujarati'] = 0x0ABC;
  17183. t['nuktagurmukhi'] = 0x0A3C;
  17184. t['numbersign'] = 0x0023;
  17185. t['numbersignmonospace'] = 0xFF03;
  17186. t['numbersignsmall'] = 0xFE5F;
  17187. t['numeralsigngreek'] = 0x0374;
  17188. t['numeralsignlowergreek'] = 0x0375;
  17189. t['numero'] = 0x2116;
  17190. t['nun'] = 0x05E0;
  17191. t['nundagesh'] = 0xFB40;
  17192. t['nundageshhebrew'] = 0xFB40;
  17193. t['nunhebrew'] = 0x05E0;
  17194. t['nvsquare'] = 0x33B5;
  17195. t['nwsquare'] = 0x33BB;
  17196. t['nyabengali'] = 0x099E;
  17197. t['nyadeva'] = 0x091E;
  17198. t['nyagujarati'] = 0x0A9E;
  17199. t['nyagurmukhi'] = 0x0A1E;
  17200. t['o'] = 0x006F;
  17201. t['oacute'] = 0x00F3;
  17202. t['oangthai'] = 0x0E2D;
  17203. t['obarred'] = 0x0275;
  17204. t['obarredcyrillic'] = 0x04E9;
  17205. t['obarreddieresiscyrillic'] = 0x04EB;
  17206. t['obengali'] = 0x0993;
  17207. t['obopomofo'] = 0x311B;
  17208. t['obreve'] = 0x014F;
  17209. t['ocandradeva'] = 0x0911;
  17210. t['ocandragujarati'] = 0x0A91;
  17211. t['ocandravowelsigndeva'] = 0x0949;
  17212. t['ocandravowelsigngujarati'] = 0x0AC9;
  17213. t['ocaron'] = 0x01D2;
  17214. t['ocircle'] = 0x24DE;
  17215. t['ocircumflex'] = 0x00F4;
  17216. t['ocircumflexacute'] = 0x1ED1;
  17217. t['ocircumflexdotbelow'] = 0x1ED9;
  17218. t['ocircumflexgrave'] = 0x1ED3;
  17219. t['ocircumflexhookabove'] = 0x1ED5;
  17220. t['ocircumflextilde'] = 0x1ED7;
  17221. t['ocyrillic'] = 0x043E;
  17222. t['odblacute'] = 0x0151;
  17223. t['odblgrave'] = 0x020D;
  17224. t['odeva'] = 0x0913;
  17225. t['odieresis'] = 0x00F6;
  17226. t['odieresiscyrillic'] = 0x04E7;
  17227. t['odotbelow'] = 0x1ECD;
  17228. t['oe'] = 0x0153;
  17229. t['oekorean'] = 0x315A;
  17230. t['ogonek'] = 0x02DB;
  17231. t['ogonekcmb'] = 0x0328;
  17232. t['ograve'] = 0x00F2;
  17233. t['ogujarati'] = 0x0A93;
  17234. t['oharmenian'] = 0x0585;
  17235. t['ohiragana'] = 0x304A;
  17236. t['ohookabove'] = 0x1ECF;
  17237. t['ohorn'] = 0x01A1;
  17238. t['ohornacute'] = 0x1EDB;
  17239. t['ohorndotbelow'] = 0x1EE3;
  17240. t['ohorngrave'] = 0x1EDD;
  17241. t['ohornhookabove'] = 0x1EDF;
  17242. t['ohorntilde'] = 0x1EE1;
  17243. t['ohungarumlaut'] = 0x0151;
  17244. t['oi'] = 0x01A3;
  17245. t['oinvertedbreve'] = 0x020F;
  17246. t['okatakana'] = 0x30AA;
  17247. t['okatakanahalfwidth'] = 0xFF75;
  17248. t['okorean'] = 0x3157;
  17249. t['olehebrew'] = 0x05AB;
  17250. t['omacron'] = 0x014D;
  17251. t['omacronacute'] = 0x1E53;
  17252. t['omacrongrave'] = 0x1E51;
  17253. t['omdeva'] = 0x0950;
  17254. t['omega'] = 0x03C9;
  17255. t['omega1'] = 0x03D6;
  17256. t['omegacyrillic'] = 0x0461;
  17257. t['omegalatinclosed'] = 0x0277;
  17258. t['omegaroundcyrillic'] = 0x047B;
  17259. t['omegatitlocyrillic'] = 0x047D;
  17260. t['omegatonos'] = 0x03CE;
  17261. t['omgujarati'] = 0x0AD0;
  17262. t['omicron'] = 0x03BF;
  17263. t['omicrontonos'] = 0x03CC;
  17264. t['omonospace'] = 0xFF4F;
  17265. t['one'] = 0x0031;
  17266. t['onearabic'] = 0x0661;
  17267. t['onebengali'] = 0x09E7;
  17268. t['onecircle'] = 0x2460;
  17269. t['onecircleinversesansserif'] = 0x278A;
  17270. t['onedeva'] = 0x0967;
  17271. t['onedotenleader'] = 0x2024;
  17272. t['oneeighth'] = 0x215B;
  17273. t['onefitted'] = 0xF6DC;
  17274. t['onegujarati'] = 0x0AE7;
  17275. t['onegurmukhi'] = 0x0A67;
  17276. t['onehackarabic'] = 0x0661;
  17277. t['onehalf'] = 0x00BD;
  17278. t['onehangzhou'] = 0x3021;
  17279. t['oneideographicparen'] = 0x3220;
  17280. t['oneinferior'] = 0x2081;
  17281. t['onemonospace'] = 0xFF11;
  17282. t['onenumeratorbengali'] = 0x09F4;
  17283. t['oneoldstyle'] = 0xF731;
  17284. t['oneparen'] = 0x2474;
  17285. t['oneperiod'] = 0x2488;
  17286. t['onepersian'] = 0x06F1;
  17287. t['onequarter'] = 0x00BC;
  17288. t['oneroman'] = 0x2170;
  17289. t['onesuperior'] = 0x00B9;
  17290. t['onethai'] = 0x0E51;
  17291. t['onethird'] = 0x2153;
  17292. t['oogonek'] = 0x01EB;
  17293. t['oogonekmacron'] = 0x01ED;
  17294. t['oogurmukhi'] = 0x0A13;
  17295. t['oomatragurmukhi'] = 0x0A4B;
  17296. t['oopen'] = 0x0254;
  17297. t['oparen'] = 0x24AA;
  17298. t['openbullet'] = 0x25E6;
  17299. t['option'] = 0x2325;
  17300. t['ordfeminine'] = 0x00AA;
  17301. t['ordmasculine'] = 0x00BA;
  17302. t['orthogonal'] = 0x221F;
  17303. t['oshortdeva'] = 0x0912;
  17304. t['oshortvowelsigndeva'] = 0x094A;
  17305. t['oslash'] = 0x00F8;
  17306. t['oslashacute'] = 0x01FF;
  17307. t['osmallhiragana'] = 0x3049;
  17308. t['osmallkatakana'] = 0x30A9;
  17309. t['osmallkatakanahalfwidth'] = 0xFF6B;
  17310. t['ostrokeacute'] = 0x01FF;
  17311. t['osuperior'] = 0xF6F0;
  17312. t['otcyrillic'] = 0x047F;
  17313. t['otilde'] = 0x00F5;
  17314. t['otildeacute'] = 0x1E4D;
  17315. t['otildedieresis'] = 0x1E4F;
  17316. t['oubopomofo'] = 0x3121;
  17317. t['overline'] = 0x203E;
  17318. t['overlinecenterline'] = 0xFE4A;
  17319. t['overlinecmb'] = 0x0305;
  17320. t['overlinedashed'] = 0xFE49;
  17321. t['overlinedblwavy'] = 0xFE4C;
  17322. t['overlinewavy'] = 0xFE4B;
  17323. t['overscore'] = 0x00AF;
  17324. t['ovowelsignbengali'] = 0x09CB;
  17325. t['ovowelsigndeva'] = 0x094B;
  17326. t['ovowelsigngujarati'] = 0x0ACB;
  17327. t['p'] = 0x0070;
  17328. t['paampssquare'] = 0x3380;
  17329. t['paasentosquare'] = 0x332B;
  17330. t['pabengali'] = 0x09AA;
  17331. t['pacute'] = 0x1E55;
  17332. t['padeva'] = 0x092A;
  17333. t['pagedown'] = 0x21DF;
  17334. t['pageup'] = 0x21DE;
  17335. t['pagujarati'] = 0x0AAA;
  17336. t['pagurmukhi'] = 0x0A2A;
  17337. t['pahiragana'] = 0x3071;
  17338. t['paiyannoithai'] = 0x0E2F;
  17339. t['pakatakana'] = 0x30D1;
  17340. t['palatalizationcyrilliccmb'] = 0x0484;
  17341. t['palochkacyrillic'] = 0x04C0;
  17342. t['pansioskorean'] = 0x317F;
  17343. t['paragraph'] = 0x00B6;
  17344. t['parallel'] = 0x2225;
  17345. t['parenleft'] = 0x0028;
  17346. t['parenleftaltonearabic'] = 0xFD3E;
  17347. t['parenleftbt'] = 0xF8ED;
  17348. t['parenleftex'] = 0xF8EC;
  17349. t['parenleftinferior'] = 0x208D;
  17350. t['parenleftmonospace'] = 0xFF08;
  17351. t['parenleftsmall'] = 0xFE59;
  17352. t['parenleftsuperior'] = 0x207D;
  17353. t['parenlefttp'] = 0xF8EB;
  17354. t['parenleftvertical'] = 0xFE35;
  17355. t['parenright'] = 0x0029;
  17356. t['parenrightaltonearabic'] = 0xFD3F;
  17357. t['parenrightbt'] = 0xF8F8;
  17358. t['parenrightex'] = 0xF8F7;
  17359. t['parenrightinferior'] = 0x208E;
  17360. t['parenrightmonospace'] = 0xFF09;
  17361. t['parenrightsmall'] = 0xFE5A;
  17362. t['parenrightsuperior'] = 0x207E;
  17363. t['parenrighttp'] = 0xF8F6;
  17364. t['parenrightvertical'] = 0xFE36;
  17365. t['partialdiff'] = 0x2202;
  17366. t['paseqhebrew'] = 0x05C0;
  17367. t['pashtahebrew'] = 0x0599;
  17368. t['pasquare'] = 0x33A9;
  17369. t['patah'] = 0x05B7;
  17370. t['patah11'] = 0x05B7;
  17371. t['patah1d'] = 0x05B7;
  17372. t['patah2a'] = 0x05B7;
  17373. t['patahhebrew'] = 0x05B7;
  17374. t['patahnarrowhebrew'] = 0x05B7;
  17375. t['patahquarterhebrew'] = 0x05B7;
  17376. t['patahwidehebrew'] = 0x05B7;
  17377. t['pazerhebrew'] = 0x05A1;
  17378. t['pbopomofo'] = 0x3106;
  17379. t['pcircle'] = 0x24DF;
  17380. t['pdotaccent'] = 0x1E57;
  17381. t['pe'] = 0x05E4;
  17382. t['pecyrillic'] = 0x043F;
  17383. t['pedagesh'] = 0xFB44;
  17384. t['pedageshhebrew'] = 0xFB44;
  17385. t['peezisquare'] = 0x333B;
  17386. t['pefinaldageshhebrew'] = 0xFB43;
  17387. t['peharabic'] = 0x067E;
  17388. t['peharmenian'] = 0x057A;
  17389. t['pehebrew'] = 0x05E4;
  17390. t['pehfinalarabic'] = 0xFB57;
  17391. t['pehinitialarabic'] = 0xFB58;
  17392. t['pehiragana'] = 0x307A;
  17393. t['pehmedialarabic'] = 0xFB59;
  17394. t['pekatakana'] = 0x30DA;
  17395. t['pemiddlehookcyrillic'] = 0x04A7;
  17396. t['perafehebrew'] = 0xFB4E;
  17397. t['percent'] = 0x0025;
  17398. t['percentarabic'] = 0x066A;
  17399. t['percentmonospace'] = 0xFF05;
  17400. t['percentsmall'] = 0xFE6A;
  17401. t['period'] = 0x002E;
  17402. t['periodarmenian'] = 0x0589;
  17403. t['periodcentered'] = 0x00B7;
  17404. t['periodhalfwidth'] = 0xFF61;
  17405. t['periodinferior'] = 0xF6E7;
  17406. t['periodmonospace'] = 0xFF0E;
  17407. t['periodsmall'] = 0xFE52;
  17408. t['periodsuperior'] = 0xF6E8;
  17409. t['perispomenigreekcmb'] = 0x0342;
  17410. t['perpendicular'] = 0x22A5;
  17411. t['perthousand'] = 0x2030;
  17412. t['peseta'] = 0x20A7;
  17413. t['pfsquare'] = 0x338A;
  17414. t['phabengali'] = 0x09AB;
  17415. t['phadeva'] = 0x092B;
  17416. t['phagujarati'] = 0x0AAB;
  17417. t['phagurmukhi'] = 0x0A2B;
  17418. t['phi'] = 0x03C6;
  17419. t['phi1'] = 0x03D5;
  17420. t['phieuphacirclekorean'] = 0x327A;
  17421. t['phieuphaparenkorean'] = 0x321A;
  17422. t['phieuphcirclekorean'] = 0x326C;
  17423. t['phieuphkorean'] = 0x314D;
  17424. t['phieuphparenkorean'] = 0x320C;
  17425. t['philatin'] = 0x0278;
  17426. t['phinthuthai'] = 0x0E3A;
  17427. t['phisymbolgreek'] = 0x03D5;
  17428. t['phook'] = 0x01A5;
  17429. t['phophanthai'] = 0x0E1E;
  17430. t['phophungthai'] = 0x0E1C;
  17431. t['phosamphaothai'] = 0x0E20;
  17432. t['pi'] = 0x03C0;
  17433. t['pieupacirclekorean'] = 0x3273;
  17434. t['pieupaparenkorean'] = 0x3213;
  17435. t['pieupcieuckorean'] = 0x3176;
  17436. t['pieupcirclekorean'] = 0x3265;
  17437. t['pieupkiyeokkorean'] = 0x3172;
  17438. t['pieupkorean'] = 0x3142;
  17439. t['pieupparenkorean'] = 0x3205;
  17440. t['pieupsioskiyeokkorean'] = 0x3174;
  17441. t['pieupsioskorean'] = 0x3144;
  17442. t['pieupsiostikeutkorean'] = 0x3175;
  17443. t['pieupthieuthkorean'] = 0x3177;
  17444. t['pieuptikeutkorean'] = 0x3173;
  17445. t['pihiragana'] = 0x3074;
  17446. t['pikatakana'] = 0x30D4;
  17447. t['pisymbolgreek'] = 0x03D6;
  17448. t['piwrarmenian'] = 0x0583;
  17449. t['plus'] = 0x002B;
  17450. t['plusbelowcmb'] = 0x031F;
  17451. t['pluscircle'] = 0x2295;
  17452. t['plusminus'] = 0x00B1;
  17453. t['plusmod'] = 0x02D6;
  17454. t['plusmonospace'] = 0xFF0B;
  17455. t['plussmall'] = 0xFE62;
  17456. t['plussuperior'] = 0x207A;
  17457. t['pmonospace'] = 0xFF50;
  17458. t['pmsquare'] = 0x33D8;
  17459. t['pohiragana'] = 0x307D;
  17460. t['pointingindexdownwhite'] = 0x261F;
  17461. t['pointingindexleftwhite'] = 0x261C;
  17462. t['pointingindexrightwhite'] = 0x261E;
  17463. t['pointingindexupwhite'] = 0x261D;
  17464. t['pokatakana'] = 0x30DD;
  17465. t['poplathai'] = 0x0E1B;
  17466. t['postalmark'] = 0x3012;
  17467. t['postalmarkface'] = 0x3020;
  17468. t['pparen'] = 0x24AB;
  17469. t['precedes'] = 0x227A;
  17470. t['prescription'] = 0x211E;
  17471. t['primemod'] = 0x02B9;
  17472. t['primereversed'] = 0x2035;
  17473. t['product'] = 0x220F;
  17474. t['projective'] = 0x2305;
  17475. t['prolongedkana'] = 0x30FC;
  17476. t['propellor'] = 0x2318;
  17477. t['propersubset'] = 0x2282;
  17478. t['propersuperset'] = 0x2283;
  17479. t['proportion'] = 0x2237;
  17480. t['proportional'] = 0x221D;
  17481. t['psi'] = 0x03C8;
  17482. t['psicyrillic'] = 0x0471;
  17483. t['psilipneumatacyrilliccmb'] = 0x0486;
  17484. t['pssquare'] = 0x33B0;
  17485. t['puhiragana'] = 0x3077;
  17486. t['pukatakana'] = 0x30D7;
  17487. t['pvsquare'] = 0x33B4;
  17488. t['pwsquare'] = 0x33BA;
  17489. t['q'] = 0x0071;
  17490. t['qadeva'] = 0x0958;
  17491. t['qadmahebrew'] = 0x05A8;
  17492. t['qafarabic'] = 0x0642;
  17493. t['qaffinalarabic'] = 0xFED6;
  17494. t['qafinitialarabic'] = 0xFED7;
  17495. t['qafmedialarabic'] = 0xFED8;
  17496. t['qamats'] = 0x05B8;
  17497. t['qamats10'] = 0x05B8;
  17498. t['qamats1a'] = 0x05B8;
  17499. t['qamats1c'] = 0x05B8;
  17500. t['qamats27'] = 0x05B8;
  17501. t['qamats29'] = 0x05B8;
  17502. t['qamats33'] = 0x05B8;
  17503. t['qamatsde'] = 0x05B8;
  17504. t['qamatshebrew'] = 0x05B8;
  17505. t['qamatsnarrowhebrew'] = 0x05B8;
  17506. t['qamatsqatanhebrew'] = 0x05B8;
  17507. t['qamatsqatannarrowhebrew'] = 0x05B8;
  17508. t['qamatsqatanquarterhebrew'] = 0x05B8;
  17509. t['qamatsqatanwidehebrew'] = 0x05B8;
  17510. t['qamatsquarterhebrew'] = 0x05B8;
  17511. t['qamatswidehebrew'] = 0x05B8;
  17512. t['qarneyparahebrew'] = 0x059F;
  17513. t['qbopomofo'] = 0x3111;
  17514. t['qcircle'] = 0x24E0;
  17515. t['qhook'] = 0x02A0;
  17516. t['qmonospace'] = 0xFF51;
  17517. t['qof'] = 0x05E7;
  17518. t['qofdagesh'] = 0xFB47;
  17519. t['qofdageshhebrew'] = 0xFB47;
  17520. t['qofhebrew'] = 0x05E7;
  17521. t['qparen'] = 0x24AC;
  17522. t['quarternote'] = 0x2669;
  17523. t['qubuts'] = 0x05BB;
  17524. t['qubuts18'] = 0x05BB;
  17525. t['qubuts25'] = 0x05BB;
  17526. t['qubuts31'] = 0x05BB;
  17527. t['qubutshebrew'] = 0x05BB;
  17528. t['qubutsnarrowhebrew'] = 0x05BB;
  17529. t['qubutsquarterhebrew'] = 0x05BB;
  17530. t['qubutswidehebrew'] = 0x05BB;
  17531. t['question'] = 0x003F;
  17532. t['questionarabic'] = 0x061F;
  17533. t['questionarmenian'] = 0x055E;
  17534. t['questiondown'] = 0x00BF;
  17535. t['questiondownsmall'] = 0xF7BF;
  17536. t['questiongreek'] = 0x037E;
  17537. t['questionmonospace'] = 0xFF1F;
  17538. t['questionsmall'] = 0xF73F;
  17539. t['quotedbl'] = 0x0022;
  17540. t['quotedblbase'] = 0x201E;
  17541. t['quotedblleft'] = 0x201C;
  17542. t['quotedblmonospace'] = 0xFF02;
  17543. t['quotedblprime'] = 0x301E;
  17544. t['quotedblprimereversed'] = 0x301D;
  17545. t['quotedblright'] = 0x201D;
  17546. t['quoteleft'] = 0x2018;
  17547. t['quoteleftreversed'] = 0x201B;
  17548. t['quotereversed'] = 0x201B;
  17549. t['quoteright'] = 0x2019;
  17550. t['quoterightn'] = 0x0149;
  17551. t['quotesinglbase'] = 0x201A;
  17552. t['quotesingle'] = 0x0027;
  17553. t['quotesinglemonospace'] = 0xFF07;
  17554. t['r'] = 0x0072;
  17555. t['raarmenian'] = 0x057C;
  17556. t['rabengali'] = 0x09B0;
  17557. t['racute'] = 0x0155;
  17558. t['radeva'] = 0x0930;
  17559. t['radical'] = 0x221A;
  17560. t['radicalex'] = 0xF8E5;
  17561. t['radoverssquare'] = 0x33AE;
  17562. t['radoverssquaredsquare'] = 0x33AF;
  17563. t['radsquare'] = 0x33AD;
  17564. t['rafe'] = 0x05BF;
  17565. t['rafehebrew'] = 0x05BF;
  17566. t['ragujarati'] = 0x0AB0;
  17567. t['ragurmukhi'] = 0x0A30;
  17568. t['rahiragana'] = 0x3089;
  17569. t['rakatakana'] = 0x30E9;
  17570. t['rakatakanahalfwidth'] = 0xFF97;
  17571. t['ralowerdiagonalbengali'] = 0x09F1;
  17572. t['ramiddlediagonalbengali'] = 0x09F0;
  17573. t['ramshorn'] = 0x0264;
  17574. t['ratio'] = 0x2236;
  17575. t['rbopomofo'] = 0x3116;
  17576. t['rcaron'] = 0x0159;
  17577. t['rcedilla'] = 0x0157;
  17578. t['rcircle'] = 0x24E1;
  17579. t['rcommaaccent'] = 0x0157;
  17580. t['rdblgrave'] = 0x0211;
  17581. t['rdotaccent'] = 0x1E59;
  17582. t['rdotbelow'] = 0x1E5B;
  17583. t['rdotbelowmacron'] = 0x1E5D;
  17584. t['referencemark'] = 0x203B;
  17585. t['reflexsubset'] = 0x2286;
  17586. t['reflexsuperset'] = 0x2287;
  17587. t['registered'] = 0x00AE;
  17588. t['registersans'] = 0xF8E8;
  17589. t['registerserif'] = 0xF6DA;
  17590. t['reharabic'] = 0x0631;
  17591. t['reharmenian'] = 0x0580;
  17592. t['rehfinalarabic'] = 0xFEAE;
  17593. t['rehiragana'] = 0x308C;
  17594. t['rekatakana'] = 0x30EC;
  17595. t['rekatakanahalfwidth'] = 0xFF9A;
  17596. t['resh'] = 0x05E8;
  17597. t['reshdageshhebrew'] = 0xFB48;
  17598. t['reshhebrew'] = 0x05E8;
  17599. t['reversedtilde'] = 0x223D;
  17600. t['reviahebrew'] = 0x0597;
  17601. t['reviamugrashhebrew'] = 0x0597;
  17602. t['revlogicalnot'] = 0x2310;
  17603. t['rfishhook'] = 0x027E;
  17604. t['rfishhookreversed'] = 0x027F;
  17605. t['rhabengali'] = 0x09DD;
  17606. t['rhadeva'] = 0x095D;
  17607. t['rho'] = 0x03C1;
  17608. t['rhook'] = 0x027D;
  17609. t['rhookturned'] = 0x027B;
  17610. t['rhookturnedsuperior'] = 0x02B5;
  17611. t['rhosymbolgreek'] = 0x03F1;
  17612. t['rhotichookmod'] = 0x02DE;
  17613. t['rieulacirclekorean'] = 0x3271;
  17614. t['rieulaparenkorean'] = 0x3211;
  17615. t['rieulcirclekorean'] = 0x3263;
  17616. t['rieulhieuhkorean'] = 0x3140;
  17617. t['rieulkiyeokkorean'] = 0x313A;
  17618. t['rieulkiyeoksioskorean'] = 0x3169;
  17619. t['rieulkorean'] = 0x3139;
  17620. t['rieulmieumkorean'] = 0x313B;
  17621. t['rieulpansioskorean'] = 0x316C;
  17622. t['rieulparenkorean'] = 0x3203;
  17623. t['rieulphieuphkorean'] = 0x313F;
  17624. t['rieulpieupkorean'] = 0x313C;
  17625. t['rieulpieupsioskorean'] = 0x316B;
  17626. t['rieulsioskorean'] = 0x313D;
  17627. t['rieulthieuthkorean'] = 0x313E;
  17628. t['rieultikeutkorean'] = 0x316A;
  17629. t['rieulyeorinhieuhkorean'] = 0x316D;
  17630. t['rightangle'] = 0x221F;
  17631. t['righttackbelowcmb'] = 0x0319;
  17632. t['righttriangle'] = 0x22BF;
  17633. t['rihiragana'] = 0x308A;
  17634. t['rikatakana'] = 0x30EA;
  17635. t['rikatakanahalfwidth'] = 0xFF98;
  17636. t['ring'] = 0x02DA;
  17637. t['ringbelowcmb'] = 0x0325;
  17638. t['ringcmb'] = 0x030A;
  17639. t['ringhalfleft'] = 0x02BF;
  17640. t['ringhalfleftarmenian'] = 0x0559;
  17641. t['ringhalfleftbelowcmb'] = 0x031C;
  17642. t['ringhalfleftcentered'] = 0x02D3;
  17643. t['ringhalfright'] = 0x02BE;
  17644. t['ringhalfrightbelowcmb'] = 0x0339;
  17645. t['ringhalfrightcentered'] = 0x02D2;
  17646. t['rinvertedbreve'] = 0x0213;
  17647. t['rittorusquare'] = 0x3351;
  17648. t['rlinebelow'] = 0x1E5F;
  17649. t['rlongleg'] = 0x027C;
  17650. t['rlonglegturned'] = 0x027A;
  17651. t['rmonospace'] = 0xFF52;
  17652. t['rohiragana'] = 0x308D;
  17653. t['rokatakana'] = 0x30ED;
  17654. t['rokatakanahalfwidth'] = 0xFF9B;
  17655. t['roruathai'] = 0x0E23;
  17656. t['rparen'] = 0x24AD;
  17657. t['rrabengali'] = 0x09DC;
  17658. t['rradeva'] = 0x0931;
  17659. t['rragurmukhi'] = 0x0A5C;
  17660. t['rreharabic'] = 0x0691;
  17661. t['rrehfinalarabic'] = 0xFB8D;
  17662. t['rrvocalicbengali'] = 0x09E0;
  17663. t['rrvocalicdeva'] = 0x0960;
  17664. t['rrvocalicgujarati'] = 0x0AE0;
  17665. t['rrvocalicvowelsignbengali'] = 0x09C4;
  17666. t['rrvocalicvowelsigndeva'] = 0x0944;
  17667. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  17668. t['rsuperior'] = 0xF6F1;
  17669. t['rtblock'] = 0x2590;
  17670. t['rturned'] = 0x0279;
  17671. t['rturnedsuperior'] = 0x02B4;
  17672. t['ruhiragana'] = 0x308B;
  17673. t['rukatakana'] = 0x30EB;
  17674. t['rukatakanahalfwidth'] = 0xFF99;
  17675. t['rupeemarkbengali'] = 0x09F2;
  17676. t['rupeesignbengali'] = 0x09F3;
  17677. t['rupiah'] = 0xF6DD;
  17678. t['ruthai'] = 0x0E24;
  17679. t['rvocalicbengali'] = 0x098B;
  17680. t['rvocalicdeva'] = 0x090B;
  17681. t['rvocalicgujarati'] = 0x0A8B;
  17682. t['rvocalicvowelsignbengali'] = 0x09C3;
  17683. t['rvocalicvowelsigndeva'] = 0x0943;
  17684. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  17685. t['s'] = 0x0073;
  17686. t['sabengali'] = 0x09B8;
  17687. t['sacute'] = 0x015B;
  17688. t['sacutedotaccent'] = 0x1E65;
  17689. t['sadarabic'] = 0x0635;
  17690. t['sadeva'] = 0x0938;
  17691. t['sadfinalarabic'] = 0xFEBA;
  17692. t['sadinitialarabic'] = 0xFEBB;
  17693. t['sadmedialarabic'] = 0xFEBC;
  17694. t['sagujarati'] = 0x0AB8;
  17695. t['sagurmukhi'] = 0x0A38;
  17696. t['sahiragana'] = 0x3055;
  17697. t['sakatakana'] = 0x30B5;
  17698. t['sakatakanahalfwidth'] = 0xFF7B;
  17699. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  17700. t['samekh'] = 0x05E1;
  17701. t['samekhdagesh'] = 0xFB41;
  17702. t['samekhdageshhebrew'] = 0xFB41;
  17703. t['samekhhebrew'] = 0x05E1;
  17704. t['saraaathai'] = 0x0E32;
  17705. t['saraaethai'] = 0x0E41;
  17706. t['saraaimaimalaithai'] = 0x0E44;
  17707. t['saraaimaimuanthai'] = 0x0E43;
  17708. t['saraamthai'] = 0x0E33;
  17709. t['saraathai'] = 0x0E30;
  17710. t['saraethai'] = 0x0E40;
  17711. t['saraiileftthai'] = 0xF886;
  17712. t['saraiithai'] = 0x0E35;
  17713. t['saraileftthai'] = 0xF885;
  17714. t['saraithai'] = 0x0E34;
  17715. t['saraothai'] = 0x0E42;
  17716. t['saraueeleftthai'] = 0xF888;
  17717. t['saraueethai'] = 0x0E37;
  17718. t['saraueleftthai'] = 0xF887;
  17719. t['sarauethai'] = 0x0E36;
  17720. t['sarauthai'] = 0x0E38;
  17721. t['sarauuthai'] = 0x0E39;
  17722. t['sbopomofo'] = 0x3119;
  17723. t['scaron'] = 0x0161;
  17724. t['scarondotaccent'] = 0x1E67;
  17725. t['scedilla'] = 0x015F;
  17726. t['schwa'] = 0x0259;
  17727. t['schwacyrillic'] = 0x04D9;
  17728. t['schwadieresiscyrillic'] = 0x04DB;
  17729. t['schwahook'] = 0x025A;
  17730. t['scircle'] = 0x24E2;
  17731. t['scircumflex'] = 0x015D;
  17732. t['scommaaccent'] = 0x0219;
  17733. t['sdotaccent'] = 0x1E61;
  17734. t['sdotbelow'] = 0x1E63;
  17735. t['sdotbelowdotaccent'] = 0x1E69;
  17736. t['seagullbelowcmb'] = 0x033C;
  17737. t['second'] = 0x2033;
  17738. t['secondtonechinese'] = 0x02CA;
  17739. t['section'] = 0x00A7;
  17740. t['seenarabic'] = 0x0633;
  17741. t['seenfinalarabic'] = 0xFEB2;
  17742. t['seeninitialarabic'] = 0xFEB3;
  17743. t['seenmedialarabic'] = 0xFEB4;
  17744. t['segol'] = 0x05B6;
  17745. t['segol13'] = 0x05B6;
  17746. t['segol1f'] = 0x05B6;
  17747. t['segol2c'] = 0x05B6;
  17748. t['segolhebrew'] = 0x05B6;
  17749. t['segolnarrowhebrew'] = 0x05B6;
  17750. t['segolquarterhebrew'] = 0x05B6;
  17751. t['segoltahebrew'] = 0x0592;
  17752. t['segolwidehebrew'] = 0x05B6;
  17753. t['seharmenian'] = 0x057D;
  17754. t['sehiragana'] = 0x305B;
  17755. t['sekatakana'] = 0x30BB;
  17756. t['sekatakanahalfwidth'] = 0xFF7E;
  17757. t['semicolon'] = 0x003B;
  17758. t['semicolonarabic'] = 0x061B;
  17759. t['semicolonmonospace'] = 0xFF1B;
  17760. t['semicolonsmall'] = 0xFE54;
  17761. t['semivoicedmarkkana'] = 0x309C;
  17762. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  17763. t['sentisquare'] = 0x3322;
  17764. t['sentosquare'] = 0x3323;
  17765. t['seven'] = 0x0037;
  17766. t['sevenarabic'] = 0x0667;
  17767. t['sevenbengali'] = 0x09ED;
  17768. t['sevencircle'] = 0x2466;
  17769. t['sevencircleinversesansserif'] = 0x2790;
  17770. t['sevendeva'] = 0x096D;
  17771. t['seveneighths'] = 0x215E;
  17772. t['sevengujarati'] = 0x0AED;
  17773. t['sevengurmukhi'] = 0x0A6D;
  17774. t['sevenhackarabic'] = 0x0667;
  17775. t['sevenhangzhou'] = 0x3027;
  17776. t['sevenideographicparen'] = 0x3226;
  17777. t['seveninferior'] = 0x2087;
  17778. t['sevenmonospace'] = 0xFF17;
  17779. t['sevenoldstyle'] = 0xF737;
  17780. t['sevenparen'] = 0x247A;
  17781. t['sevenperiod'] = 0x248E;
  17782. t['sevenpersian'] = 0x06F7;
  17783. t['sevenroman'] = 0x2176;
  17784. t['sevensuperior'] = 0x2077;
  17785. t['seventeencircle'] = 0x2470;
  17786. t['seventeenparen'] = 0x2484;
  17787. t['seventeenperiod'] = 0x2498;
  17788. t['seventhai'] = 0x0E57;
  17789. t['sfthyphen'] = 0x00AD;
  17790. t['shaarmenian'] = 0x0577;
  17791. t['shabengali'] = 0x09B6;
  17792. t['shacyrillic'] = 0x0448;
  17793. t['shaddaarabic'] = 0x0651;
  17794. t['shaddadammaarabic'] = 0xFC61;
  17795. t['shaddadammatanarabic'] = 0xFC5E;
  17796. t['shaddafathaarabic'] = 0xFC60;
  17797. t['shaddakasraarabic'] = 0xFC62;
  17798. t['shaddakasratanarabic'] = 0xFC5F;
  17799. t['shade'] = 0x2592;
  17800. t['shadedark'] = 0x2593;
  17801. t['shadelight'] = 0x2591;
  17802. t['shademedium'] = 0x2592;
  17803. t['shadeva'] = 0x0936;
  17804. t['shagujarati'] = 0x0AB6;
  17805. t['shagurmukhi'] = 0x0A36;
  17806. t['shalshelethebrew'] = 0x0593;
  17807. t['shbopomofo'] = 0x3115;
  17808. t['shchacyrillic'] = 0x0449;
  17809. t['sheenarabic'] = 0x0634;
  17810. t['sheenfinalarabic'] = 0xFEB6;
  17811. t['sheeninitialarabic'] = 0xFEB7;
  17812. t['sheenmedialarabic'] = 0xFEB8;
  17813. t['sheicoptic'] = 0x03E3;
  17814. t['sheqel'] = 0x20AA;
  17815. t['sheqelhebrew'] = 0x20AA;
  17816. t['sheva'] = 0x05B0;
  17817. t['sheva115'] = 0x05B0;
  17818. t['sheva15'] = 0x05B0;
  17819. t['sheva22'] = 0x05B0;
  17820. t['sheva2e'] = 0x05B0;
  17821. t['shevahebrew'] = 0x05B0;
  17822. t['shevanarrowhebrew'] = 0x05B0;
  17823. t['shevaquarterhebrew'] = 0x05B0;
  17824. t['shevawidehebrew'] = 0x05B0;
  17825. t['shhacyrillic'] = 0x04BB;
  17826. t['shimacoptic'] = 0x03ED;
  17827. t['shin'] = 0x05E9;
  17828. t['shindagesh'] = 0xFB49;
  17829. t['shindageshhebrew'] = 0xFB49;
  17830. t['shindageshshindot'] = 0xFB2C;
  17831. t['shindageshshindothebrew'] = 0xFB2C;
  17832. t['shindageshsindot'] = 0xFB2D;
  17833. t['shindageshsindothebrew'] = 0xFB2D;
  17834. t['shindothebrew'] = 0x05C1;
  17835. t['shinhebrew'] = 0x05E9;
  17836. t['shinshindot'] = 0xFB2A;
  17837. t['shinshindothebrew'] = 0xFB2A;
  17838. t['shinsindot'] = 0xFB2B;
  17839. t['shinsindothebrew'] = 0xFB2B;
  17840. t['shook'] = 0x0282;
  17841. t['sigma'] = 0x03C3;
  17842. t['sigma1'] = 0x03C2;
  17843. t['sigmafinal'] = 0x03C2;
  17844. t['sigmalunatesymbolgreek'] = 0x03F2;
  17845. t['sihiragana'] = 0x3057;
  17846. t['sikatakana'] = 0x30B7;
  17847. t['sikatakanahalfwidth'] = 0xFF7C;
  17848. t['siluqhebrew'] = 0x05BD;
  17849. t['siluqlefthebrew'] = 0x05BD;
  17850. t['similar'] = 0x223C;
  17851. t['sindothebrew'] = 0x05C2;
  17852. t['siosacirclekorean'] = 0x3274;
  17853. t['siosaparenkorean'] = 0x3214;
  17854. t['sioscieuckorean'] = 0x317E;
  17855. t['sioscirclekorean'] = 0x3266;
  17856. t['sioskiyeokkorean'] = 0x317A;
  17857. t['sioskorean'] = 0x3145;
  17858. t['siosnieunkorean'] = 0x317B;
  17859. t['siosparenkorean'] = 0x3206;
  17860. t['siospieupkorean'] = 0x317D;
  17861. t['siostikeutkorean'] = 0x317C;
  17862. t['six'] = 0x0036;
  17863. t['sixarabic'] = 0x0666;
  17864. t['sixbengali'] = 0x09EC;
  17865. t['sixcircle'] = 0x2465;
  17866. t['sixcircleinversesansserif'] = 0x278F;
  17867. t['sixdeva'] = 0x096C;
  17868. t['sixgujarati'] = 0x0AEC;
  17869. t['sixgurmukhi'] = 0x0A6C;
  17870. t['sixhackarabic'] = 0x0666;
  17871. t['sixhangzhou'] = 0x3026;
  17872. t['sixideographicparen'] = 0x3225;
  17873. t['sixinferior'] = 0x2086;
  17874. t['sixmonospace'] = 0xFF16;
  17875. t['sixoldstyle'] = 0xF736;
  17876. t['sixparen'] = 0x2479;
  17877. t['sixperiod'] = 0x248D;
  17878. t['sixpersian'] = 0x06F6;
  17879. t['sixroman'] = 0x2175;
  17880. t['sixsuperior'] = 0x2076;
  17881. t['sixteencircle'] = 0x246F;
  17882. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  17883. t['sixteenparen'] = 0x2483;
  17884. t['sixteenperiod'] = 0x2497;
  17885. t['sixthai'] = 0x0E56;
  17886. t['slash'] = 0x002F;
  17887. t['slashmonospace'] = 0xFF0F;
  17888. t['slong'] = 0x017F;
  17889. t['slongdotaccent'] = 0x1E9B;
  17890. t['smileface'] = 0x263A;
  17891. t['smonospace'] = 0xFF53;
  17892. t['sofpasuqhebrew'] = 0x05C3;
  17893. t['softhyphen'] = 0x00AD;
  17894. t['softsigncyrillic'] = 0x044C;
  17895. t['sohiragana'] = 0x305D;
  17896. t['sokatakana'] = 0x30BD;
  17897. t['sokatakanahalfwidth'] = 0xFF7F;
  17898. t['soliduslongoverlaycmb'] = 0x0338;
  17899. t['solidusshortoverlaycmb'] = 0x0337;
  17900. t['sorusithai'] = 0x0E29;
  17901. t['sosalathai'] = 0x0E28;
  17902. t['sosothai'] = 0x0E0B;
  17903. t['sosuathai'] = 0x0E2A;
  17904. t['space'] = 0x0020;
  17905. t['spacehackarabic'] = 0x0020;
  17906. t['spade'] = 0x2660;
  17907. t['spadesuitblack'] = 0x2660;
  17908. t['spadesuitwhite'] = 0x2664;
  17909. t['sparen'] = 0x24AE;
  17910. t['squarebelowcmb'] = 0x033B;
  17911. t['squarecc'] = 0x33C4;
  17912. t['squarecm'] = 0x339D;
  17913. t['squarediagonalcrosshatchfill'] = 0x25A9;
  17914. t['squarehorizontalfill'] = 0x25A4;
  17915. t['squarekg'] = 0x338F;
  17916. t['squarekm'] = 0x339E;
  17917. t['squarekmcapital'] = 0x33CE;
  17918. t['squareln'] = 0x33D1;
  17919. t['squarelog'] = 0x33D2;
  17920. t['squaremg'] = 0x338E;
  17921. t['squaremil'] = 0x33D5;
  17922. t['squaremm'] = 0x339C;
  17923. t['squaremsquared'] = 0x33A1;
  17924. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  17925. t['squareupperlefttolowerrightfill'] = 0x25A7;
  17926. t['squareupperrighttolowerleftfill'] = 0x25A8;
  17927. t['squareverticalfill'] = 0x25A5;
  17928. t['squarewhitewithsmallblack'] = 0x25A3;
  17929. t['srsquare'] = 0x33DB;
  17930. t['ssabengali'] = 0x09B7;
  17931. t['ssadeva'] = 0x0937;
  17932. t['ssagujarati'] = 0x0AB7;
  17933. t['ssangcieuckorean'] = 0x3149;
  17934. t['ssanghieuhkorean'] = 0x3185;
  17935. t['ssangieungkorean'] = 0x3180;
  17936. t['ssangkiyeokkorean'] = 0x3132;
  17937. t['ssangnieunkorean'] = 0x3165;
  17938. t['ssangpieupkorean'] = 0x3143;
  17939. t['ssangsioskorean'] = 0x3146;
  17940. t['ssangtikeutkorean'] = 0x3138;
  17941. t['ssuperior'] = 0xF6F2;
  17942. t['sterling'] = 0x00A3;
  17943. t['sterlingmonospace'] = 0xFFE1;
  17944. t['strokelongoverlaycmb'] = 0x0336;
  17945. t['strokeshortoverlaycmb'] = 0x0335;
  17946. t['subset'] = 0x2282;
  17947. t['subsetnotequal'] = 0x228A;
  17948. t['subsetorequal'] = 0x2286;
  17949. t['succeeds'] = 0x227B;
  17950. t['suchthat'] = 0x220B;
  17951. t['suhiragana'] = 0x3059;
  17952. t['sukatakana'] = 0x30B9;
  17953. t['sukatakanahalfwidth'] = 0xFF7D;
  17954. t['sukunarabic'] = 0x0652;
  17955. t['summation'] = 0x2211;
  17956. t['sun'] = 0x263C;
  17957. t['superset'] = 0x2283;
  17958. t['supersetnotequal'] = 0x228B;
  17959. t['supersetorequal'] = 0x2287;
  17960. t['svsquare'] = 0x33DC;
  17961. t['syouwaerasquare'] = 0x337C;
  17962. t['t'] = 0x0074;
  17963. t['tabengali'] = 0x09A4;
  17964. t['tackdown'] = 0x22A4;
  17965. t['tackleft'] = 0x22A3;
  17966. t['tadeva'] = 0x0924;
  17967. t['tagujarati'] = 0x0AA4;
  17968. t['tagurmukhi'] = 0x0A24;
  17969. t['taharabic'] = 0x0637;
  17970. t['tahfinalarabic'] = 0xFEC2;
  17971. t['tahinitialarabic'] = 0xFEC3;
  17972. t['tahiragana'] = 0x305F;
  17973. t['tahmedialarabic'] = 0xFEC4;
  17974. t['taisyouerasquare'] = 0x337D;
  17975. t['takatakana'] = 0x30BF;
  17976. t['takatakanahalfwidth'] = 0xFF80;
  17977. t['tatweelarabic'] = 0x0640;
  17978. t['tau'] = 0x03C4;
  17979. t['tav'] = 0x05EA;
  17980. t['tavdages'] = 0xFB4A;
  17981. t['tavdagesh'] = 0xFB4A;
  17982. t['tavdageshhebrew'] = 0xFB4A;
  17983. t['tavhebrew'] = 0x05EA;
  17984. t['tbar'] = 0x0167;
  17985. t['tbopomofo'] = 0x310A;
  17986. t['tcaron'] = 0x0165;
  17987. t['tccurl'] = 0x02A8;
  17988. t['tcedilla'] = 0x0163;
  17989. t['tcheharabic'] = 0x0686;
  17990. t['tchehfinalarabic'] = 0xFB7B;
  17991. t['tchehinitialarabic'] = 0xFB7C;
  17992. t['tchehmedialarabic'] = 0xFB7D;
  17993. t['tcircle'] = 0x24E3;
  17994. t['tcircumflexbelow'] = 0x1E71;
  17995. t['tcommaaccent'] = 0x0163;
  17996. t['tdieresis'] = 0x1E97;
  17997. t['tdotaccent'] = 0x1E6B;
  17998. t['tdotbelow'] = 0x1E6D;
  17999. t['tecyrillic'] = 0x0442;
  18000. t['tedescendercyrillic'] = 0x04AD;
  18001. t['teharabic'] = 0x062A;
  18002. t['tehfinalarabic'] = 0xFE96;
  18003. t['tehhahinitialarabic'] = 0xFCA2;
  18004. t['tehhahisolatedarabic'] = 0xFC0C;
  18005. t['tehinitialarabic'] = 0xFE97;
  18006. t['tehiragana'] = 0x3066;
  18007. t['tehjeeminitialarabic'] = 0xFCA1;
  18008. t['tehjeemisolatedarabic'] = 0xFC0B;
  18009. t['tehmarbutaarabic'] = 0x0629;
  18010. t['tehmarbutafinalarabic'] = 0xFE94;
  18011. t['tehmedialarabic'] = 0xFE98;
  18012. t['tehmeeminitialarabic'] = 0xFCA4;
  18013. t['tehmeemisolatedarabic'] = 0xFC0E;
  18014. t['tehnoonfinalarabic'] = 0xFC73;
  18015. t['tekatakana'] = 0x30C6;
  18016. t['tekatakanahalfwidth'] = 0xFF83;
  18017. t['telephone'] = 0x2121;
  18018. t['telephoneblack'] = 0x260E;
  18019. t['telishagedolahebrew'] = 0x05A0;
  18020. t['telishaqetanahebrew'] = 0x05A9;
  18021. t['tencircle'] = 0x2469;
  18022. t['tenideographicparen'] = 0x3229;
  18023. t['tenparen'] = 0x247D;
  18024. t['tenperiod'] = 0x2491;
  18025. t['tenroman'] = 0x2179;
  18026. t['tesh'] = 0x02A7;
  18027. t['tet'] = 0x05D8;
  18028. t['tetdagesh'] = 0xFB38;
  18029. t['tetdageshhebrew'] = 0xFB38;
  18030. t['tethebrew'] = 0x05D8;
  18031. t['tetsecyrillic'] = 0x04B5;
  18032. t['tevirhebrew'] = 0x059B;
  18033. t['tevirlefthebrew'] = 0x059B;
  18034. t['thabengali'] = 0x09A5;
  18035. t['thadeva'] = 0x0925;
  18036. t['thagujarati'] = 0x0AA5;
  18037. t['thagurmukhi'] = 0x0A25;
  18038. t['thalarabic'] = 0x0630;
  18039. t['thalfinalarabic'] = 0xFEAC;
  18040. t['thanthakhatlowleftthai'] = 0xF898;
  18041. t['thanthakhatlowrightthai'] = 0xF897;
  18042. t['thanthakhatthai'] = 0x0E4C;
  18043. t['thanthakhatupperleftthai'] = 0xF896;
  18044. t['theharabic'] = 0x062B;
  18045. t['thehfinalarabic'] = 0xFE9A;
  18046. t['thehinitialarabic'] = 0xFE9B;
  18047. t['thehmedialarabic'] = 0xFE9C;
  18048. t['thereexists'] = 0x2203;
  18049. t['therefore'] = 0x2234;
  18050. t['theta'] = 0x03B8;
  18051. t['theta1'] = 0x03D1;
  18052. t['thetasymbolgreek'] = 0x03D1;
  18053. t['thieuthacirclekorean'] = 0x3279;
  18054. t['thieuthaparenkorean'] = 0x3219;
  18055. t['thieuthcirclekorean'] = 0x326B;
  18056. t['thieuthkorean'] = 0x314C;
  18057. t['thieuthparenkorean'] = 0x320B;
  18058. t['thirteencircle'] = 0x246C;
  18059. t['thirteenparen'] = 0x2480;
  18060. t['thirteenperiod'] = 0x2494;
  18061. t['thonangmonthothai'] = 0x0E11;
  18062. t['thook'] = 0x01AD;
  18063. t['thophuthaothai'] = 0x0E12;
  18064. t['thorn'] = 0x00FE;
  18065. t['thothahanthai'] = 0x0E17;
  18066. t['thothanthai'] = 0x0E10;
  18067. t['thothongthai'] = 0x0E18;
  18068. t['thothungthai'] = 0x0E16;
  18069. t['thousandcyrillic'] = 0x0482;
  18070. t['thousandsseparatorarabic'] = 0x066C;
  18071. t['thousandsseparatorpersian'] = 0x066C;
  18072. t['three'] = 0x0033;
  18073. t['threearabic'] = 0x0663;
  18074. t['threebengali'] = 0x09E9;
  18075. t['threecircle'] = 0x2462;
  18076. t['threecircleinversesansserif'] = 0x278C;
  18077. t['threedeva'] = 0x0969;
  18078. t['threeeighths'] = 0x215C;
  18079. t['threegujarati'] = 0x0AE9;
  18080. t['threegurmukhi'] = 0x0A69;
  18081. t['threehackarabic'] = 0x0663;
  18082. t['threehangzhou'] = 0x3023;
  18083. t['threeideographicparen'] = 0x3222;
  18084. t['threeinferior'] = 0x2083;
  18085. t['threemonospace'] = 0xFF13;
  18086. t['threenumeratorbengali'] = 0x09F6;
  18087. t['threeoldstyle'] = 0xF733;
  18088. t['threeparen'] = 0x2476;
  18089. t['threeperiod'] = 0x248A;
  18090. t['threepersian'] = 0x06F3;
  18091. t['threequarters'] = 0x00BE;
  18092. t['threequartersemdash'] = 0xF6DE;
  18093. t['threeroman'] = 0x2172;
  18094. t['threesuperior'] = 0x00B3;
  18095. t['threethai'] = 0x0E53;
  18096. t['thzsquare'] = 0x3394;
  18097. t['tihiragana'] = 0x3061;
  18098. t['tikatakana'] = 0x30C1;
  18099. t['tikatakanahalfwidth'] = 0xFF81;
  18100. t['tikeutacirclekorean'] = 0x3270;
  18101. t['tikeutaparenkorean'] = 0x3210;
  18102. t['tikeutcirclekorean'] = 0x3262;
  18103. t['tikeutkorean'] = 0x3137;
  18104. t['tikeutparenkorean'] = 0x3202;
  18105. t['tilde'] = 0x02DC;
  18106. t['tildebelowcmb'] = 0x0330;
  18107. t['tildecmb'] = 0x0303;
  18108. t['tildecomb'] = 0x0303;
  18109. t['tildedoublecmb'] = 0x0360;
  18110. t['tildeoperator'] = 0x223C;
  18111. t['tildeoverlaycmb'] = 0x0334;
  18112. t['tildeverticalcmb'] = 0x033E;
  18113. t['timescircle'] = 0x2297;
  18114. t['tipehahebrew'] = 0x0596;
  18115. t['tipehalefthebrew'] = 0x0596;
  18116. t['tippigurmukhi'] = 0x0A70;
  18117. t['titlocyrilliccmb'] = 0x0483;
  18118. t['tiwnarmenian'] = 0x057F;
  18119. t['tlinebelow'] = 0x1E6F;
  18120. t['tmonospace'] = 0xFF54;
  18121. t['toarmenian'] = 0x0569;
  18122. t['tohiragana'] = 0x3068;
  18123. t['tokatakana'] = 0x30C8;
  18124. t['tokatakanahalfwidth'] = 0xFF84;
  18125. t['tonebarextrahighmod'] = 0x02E5;
  18126. t['tonebarextralowmod'] = 0x02E9;
  18127. t['tonebarhighmod'] = 0x02E6;
  18128. t['tonebarlowmod'] = 0x02E8;
  18129. t['tonebarmidmod'] = 0x02E7;
  18130. t['tonefive'] = 0x01BD;
  18131. t['tonesix'] = 0x0185;
  18132. t['tonetwo'] = 0x01A8;
  18133. t['tonos'] = 0x0384;
  18134. t['tonsquare'] = 0x3327;
  18135. t['topatakthai'] = 0x0E0F;
  18136. t['tortoiseshellbracketleft'] = 0x3014;
  18137. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  18138. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  18139. t['tortoiseshellbracketright'] = 0x3015;
  18140. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  18141. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  18142. t['totaothai'] = 0x0E15;
  18143. t['tpalatalhook'] = 0x01AB;
  18144. t['tparen'] = 0x24AF;
  18145. t['trademark'] = 0x2122;
  18146. t['trademarksans'] = 0xF8EA;
  18147. t['trademarkserif'] = 0xF6DB;
  18148. t['tretroflexhook'] = 0x0288;
  18149. t['triagdn'] = 0x25BC;
  18150. t['triaglf'] = 0x25C4;
  18151. t['triagrt'] = 0x25BA;
  18152. t['triagup'] = 0x25B2;
  18153. t['ts'] = 0x02A6;
  18154. t['tsadi'] = 0x05E6;
  18155. t['tsadidagesh'] = 0xFB46;
  18156. t['tsadidageshhebrew'] = 0xFB46;
  18157. t['tsadihebrew'] = 0x05E6;
  18158. t['tsecyrillic'] = 0x0446;
  18159. t['tsere'] = 0x05B5;
  18160. t['tsere12'] = 0x05B5;
  18161. t['tsere1e'] = 0x05B5;
  18162. t['tsere2b'] = 0x05B5;
  18163. t['tserehebrew'] = 0x05B5;
  18164. t['tserenarrowhebrew'] = 0x05B5;
  18165. t['tserequarterhebrew'] = 0x05B5;
  18166. t['tserewidehebrew'] = 0x05B5;
  18167. t['tshecyrillic'] = 0x045B;
  18168. t['tsuperior'] = 0xF6F3;
  18169. t['ttabengali'] = 0x099F;
  18170. t['ttadeva'] = 0x091F;
  18171. t['ttagujarati'] = 0x0A9F;
  18172. t['ttagurmukhi'] = 0x0A1F;
  18173. t['tteharabic'] = 0x0679;
  18174. t['ttehfinalarabic'] = 0xFB67;
  18175. t['ttehinitialarabic'] = 0xFB68;
  18176. t['ttehmedialarabic'] = 0xFB69;
  18177. t['tthabengali'] = 0x09A0;
  18178. t['tthadeva'] = 0x0920;
  18179. t['tthagujarati'] = 0x0AA0;
  18180. t['tthagurmukhi'] = 0x0A20;
  18181. t['tturned'] = 0x0287;
  18182. t['tuhiragana'] = 0x3064;
  18183. t['tukatakana'] = 0x30C4;
  18184. t['tukatakanahalfwidth'] = 0xFF82;
  18185. t['tusmallhiragana'] = 0x3063;
  18186. t['tusmallkatakana'] = 0x30C3;
  18187. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  18188. t['twelvecircle'] = 0x246B;
  18189. t['twelveparen'] = 0x247F;
  18190. t['twelveperiod'] = 0x2493;
  18191. t['twelveroman'] = 0x217B;
  18192. t['twentycircle'] = 0x2473;
  18193. t['twentyhangzhou'] = 0x5344;
  18194. t['twentyparen'] = 0x2487;
  18195. t['twentyperiod'] = 0x249B;
  18196. t['two'] = 0x0032;
  18197. t['twoarabic'] = 0x0662;
  18198. t['twobengali'] = 0x09E8;
  18199. t['twocircle'] = 0x2461;
  18200. t['twocircleinversesansserif'] = 0x278B;
  18201. t['twodeva'] = 0x0968;
  18202. t['twodotenleader'] = 0x2025;
  18203. t['twodotleader'] = 0x2025;
  18204. t['twodotleadervertical'] = 0xFE30;
  18205. t['twogujarati'] = 0x0AE8;
  18206. t['twogurmukhi'] = 0x0A68;
  18207. t['twohackarabic'] = 0x0662;
  18208. t['twohangzhou'] = 0x3022;
  18209. t['twoideographicparen'] = 0x3221;
  18210. t['twoinferior'] = 0x2082;
  18211. t['twomonospace'] = 0xFF12;
  18212. t['twonumeratorbengali'] = 0x09F5;
  18213. t['twooldstyle'] = 0xF732;
  18214. t['twoparen'] = 0x2475;
  18215. t['twoperiod'] = 0x2489;
  18216. t['twopersian'] = 0x06F2;
  18217. t['tworoman'] = 0x2171;
  18218. t['twostroke'] = 0x01BB;
  18219. t['twosuperior'] = 0x00B2;
  18220. t['twothai'] = 0x0E52;
  18221. t['twothirds'] = 0x2154;
  18222. t['u'] = 0x0075;
  18223. t['uacute'] = 0x00FA;
  18224. t['ubar'] = 0x0289;
  18225. t['ubengali'] = 0x0989;
  18226. t['ubopomofo'] = 0x3128;
  18227. t['ubreve'] = 0x016D;
  18228. t['ucaron'] = 0x01D4;
  18229. t['ucircle'] = 0x24E4;
  18230. t['ucircumflex'] = 0x00FB;
  18231. t['ucircumflexbelow'] = 0x1E77;
  18232. t['ucyrillic'] = 0x0443;
  18233. t['udattadeva'] = 0x0951;
  18234. t['udblacute'] = 0x0171;
  18235. t['udblgrave'] = 0x0215;
  18236. t['udeva'] = 0x0909;
  18237. t['udieresis'] = 0x00FC;
  18238. t['udieresisacute'] = 0x01D8;
  18239. t['udieresisbelow'] = 0x1E73;
  18240. t['udieresiscaron'] = 0x01DA;
  18241. t['udieresiscyrillic'] = 0x04F1;
  18242. t['udieresisgrave'] = 0x01DC;
  18243. t['udieresismacron'] = 0x01D6;
  18244. t['udotbelow'] = 0x1EE5;
  18245. t['ugrave'] = 0x00F9;
  18246. t['ugujarati'] = 0x0A89;
  18247. t['ugurmukhi'] = 0x0A09;
  18248. t['uhiragana'] = 0x3046;
  18249. t['uhookabove'] = 0x1EE7;
  18250. t['uhorn'] = 0x01B0;
  18251. t['uhornacute'] = 0x1EE9;
  18252. t['uhorndotbelow'] = 0x1EF1;
  18253. t['uhorngrave'] = 0x1EEB;
  18254. t['uhornhookabove'] = 0x1EED;
  18255. t['uhorntilde'] = 0x1EEF;
  18256. t['uhungarumlaut'] = 0x0171;
  18257. t['uhungarumlautcyrillic'] = 0x04F3;
  18258. t['uinvertedbreve'] = 0x0217;
  18259. t['ukatakana'] = 0x30A6;
  18260. t['ukatakanahalfwidth'] = 0xFF73;
  18261. t['ukcyrillic'] = 0x0479;
  18262. t['ukorean'] = 0x315C;
  18263. t['umacron'] = 0x016B;
  18264. t['umacroncyrillic'] = 0x04EF;
  18265. t['umacrondieresis'] = 0x1E7B;
  18266. t['umatragurmukhi'] = 0x0A41;
  18267. t['umonospace'] = 0xFF55;
  18268. t['underscore'] = 0x005F;
  18269. t['underscoredbl'] = 0x2017;
  18270. t['underscoremonospace'] = 0xFF3F;
  18271. t['underscorevertical'] = 0xFE33;
  18272. t['underscorewavy'] = 0xFE4F;
  18273. t['union'] = 0x222A;
  18274. t['universal'] = 0x2200;
  18275. t['uogonek'] = 0x0173;
  18276. t['uparen'] = 0x24B0;
  18277. t['upblock'] = 0x2580;
  18278. t['upperdothebrew'] = 0x05C4;
  18279. t['upsilon'] = 0x03C5;
  18280. t['upsilondieresis'] = 0x03CB;
  18281. t['upsilondieresistonos'] = 0x03B0;
  18282. t['upsilonlatin'] = 0x028A;
  18283. t['upsilontonos'] = 0x03CD;
  18284. t['uptackbelowcmb'] = 0x031D;
  18285. t['uptackmod'] = 0x02D4;
  18286. t['uragurmukhi'] = 0x0A73;
  18287. t['uring'] = 0x016F;
  18288. t['ushortcyrillic'] = 0x045E;
  18289. t['usmallhiragana'] = 0x3045;
  18290. t['usmallkatakana'] = 0x30A5;
  18291. t['usmallkatakanahalfwidth'] = 0xFF69;
  18292. t['ustraightcyrillic'] = 0x04AF;
  18293. t['ustraightstrokecyrillic'] = 0x04B1;
  18294. t['utilde'] = 0x0169;
  18295. t['utildeacute'] = 0x1E79;
  18296. t['utildebelow'] = 0x1E75;
  18297. t['uubengali'] = 0x098A;
  18298. t['uudeva'] = 0x090A;
  18299. t['uugujarati'] = 0x0A8A;
  18300. t['uugurmukhi'] = 0x0A0A;
  18301. t['uumatragurmukhi'] = 0x0A42;
  18302. t['uuvowelsignbengali'] = 0x09C2;
  18303. t['uuvowelsigndeva'] = 0x0942;
  18304. t['uuvowelsigngujarati'] = 0x0AC2;
  18305. t['uvowelsignbengali'] = 0x09C1;
  18306. t['uvowelsigndeva'] = 0x0941;
  18307. t['uvowelsigngujarati'] = 0x0AC1;
  18308. t['v'] = 0x0076;
  18309. t['vadeva'] = 0x0935;
  18310. t['vagujarati'] = 0x0AB5;
  18311. t['vagurmukhi'] = 0x0A35;
  18312. t['vakatakana'] = 0x30F7;
  18313. t['vav'] = 0x05D5;
  18314. t['vavdagesh'] = 0xFB35;
  18315. t['vavdagesh65'] = 0xFB35;
  18316. t['vavdageshhebrew'] = 0xFB35;
  18317. t['vavhebrew'] = 0x05D5;
  18318. t['vavholam'] = 0xFB4B;
  18319. t['vavholamhebrew'] = 0xFB4B;
  18320. t['vavvavhebrew'] = 0x05F0;
  18321. t['vavyodhebrew'] = 0x05F1;
  18322. t['vcircle'] = 0x24E5;
  18323. t['vdotbelow'] = 0x1E7F;
  18324. t['vecyrillic'] = 0x0432;
  18325. t['veharabic'] = 0x06A4;
  18326. t['vehfinalarabic'] = 0xFB6B;
  18327. t['vehinitialarabic'] = 0xFB6C;
  18328. t['vehmedialarabic'] = 0xFB6D;
  18329. t['vekatakana'] = 0x30F9;
  18330. t['venus'] = 0x2640;
  18331. t['verticalbar'] = 0x007C;
  18332. t['verticallineabovecmb'] = 0x030D;
  18333. t['verticallinebelowcmb'] = 0x0329;
  18334. t['verticallinelowmod'] = 0x02CC;
  18335. t['verticallinemod'] = 0x02C8;
  18336. t['vewarmenian'] = 0x057E;
  18337. t['vhook'] = 0x028B;
  18338. t['vikatakana'] = 0x30F8;
  18339. t['viramabengali'] = 0x09CD;
  18340. t['viramadeva'] = 0x094D;
  18341. t['viramagujarati'] = 0x0ACD;
  18342. t['visargabengali'] = 0x0983;
  18343. t['visargadeva'] = 0x0903;
  18344. t['visargagujarati'] = 0x0A83;
  18345. t['vmonospace'] = 0xFF56;
  18346. t['voarmenian'] = 0x0578;
  18347. t['voicediterationhiragana'] = 0x309E;
  18348. t['voicediterationkatakana'] = 0x30FE;
  18349. t['voicedmarkkana'] = 0x309B;
  18350. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  18351. t['vokatakana'] = 0x30FA;
  18352. t['vparen'] = 0x24B1;
  18353. t['vtilde'] = 0x1E7D;
  18354. t['vturned'] = 0x028C;
  18355. t['vuhiragana'] = 0x3094;
  18356. t['vukatakana'] = 0x30F4;
  18357. t['w'] = 0x0077;
  18358. t['wacute'] = 0x1E83;
  18359. t['waekorean'] = 0x3159;
  18360. t['wahiragana'] = 0x308F;
  18361. t['wakatakana'] = 0x30EF;
  18362. t['wakatakanahalfwidth'] = 0xFF9C;
  18363. t['wakorean'] = 0x3158;
  18364. t['wasmallhiragana'] = 0x308E;
  18365. t['wasmallkatakana'] = 0x30EE;
  18366. t['wattosquare'] = 0x3357;
  18367. t['wavedash'] = 0x301C;
  18368. t['wavyunderscorevertical'] = 0xFE34;
  18369. t['wawarabic'] = 0x0648;
  18370. t['wawfinalarabic'] = 0xFEEE;
  18371. t['wawhamzaabovearabic'] = 0x0624;
  18372. t['wawhamzaabovefinalarabic'] = 0xFE86;
  18373. t['wbsquare'] = 0x33DD;
  18374. t['wcircle'] = 0x24E6;
  18375. t['wcircumflex'] = 0x0175;
  18376. t['wdieresis'] = 0x1E85;
  18377. t['wdotaccent'] = 0x1E87;
  18378. t['wdotbelow'] = 0x1E89;
  18379. t['wehiragana'] = 0x3091;
  18380. t['weierstrass'] = 0x2118;
  18381. t['wekatakana'] = 0x30F1;
  18382. t['wekorean'] = 0x315E;
  18383. t['weokorean'] = 0x315D;
  18384. t['wgrave'] = 0x1E81;
  18385. t['whitebullet'] = 0x25E6;
  18386. t['whitecircle'] = 0x25CB;
  18387. t['whitecircleinverse'] = 0x25D9;
  18388. t['whitecornerbracketleft'] = 0x300E;
  18389. t['whitecornerbracketleftvertical'] = 0xFE43;
  18390. t['whitecornerbracketright'] = 0x300F;
  18391. t['whitecornerbracketrightvertical'] = 0xFE44;
  18392. t['whitediamond'] = 0x25C7;
  18393. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  18394. t['whitedownpointingsmalltriangle'] = 0x25BF;
  18395. t['whitedownpointingtriangle'] = 0x25BD;
  18396. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  18397. t['whiteleftpointingtriangle'] = 0x25C1;
  18398. t['whitelenticularbracketleft'] = 0x3016;
  18399. t['whitelenticularbracketright'] = 0x3017;
  18400. t['whiterightpointingsmalltriangle'] = 0x25B9;
  18401. t['whiterightpointingtriangle'] = 0x25B7;
  18402. t['whitesmallsquare'] = 0x25AB;
  18403. t['whitesmilingface'] = 0x263A;
  18404. t['whitesquare'] = 0x25A1;
  18405. t['whitestar'] = 0x2606;
  18406. t['whitetelephone'] = 0x260F;
  18407. t['whitetortoiseshellbracketleft'] = 0x3018;
  18408. t['whitetortoiseshellbracketright'] = 0x3019;
  18409. t['whiteuppointingsmalltriangle'] = 0x25B5;
  18410. t['whiteuppointingtriangle'] = 0x25B3;
  18411. t['wihiragana'] = 0x3090;
  18412. t['wikatakana'] = 0x30F0;
  18413. t['wikorean'] = 0x315F;
  18414. t['wmonospace'] = 0xFF57;
  18415. t['wohiragana'] = 0x3092;
  18416. t['wokatakana'] = 0x30F2;
  18417. t['wokatakanahalfwidth'] = 0xFF66;
  18418. t['won'] = 0x20A9;
  18419. t['wonmonospace'] = 0xFFE6;
  18420. t['wowaenthai'] = 0x0E27;
  18421. t['wparen'] = 0x24B2;
  18422. t['wring'] = 0x1E98;
  18423. t['wsuperior'] = 0x02B7;
  18424. t['wturned'] = 0x028D;
  18425. t['wynn'] = 0x01BF;
  18426. t['x'] = 0x0078;
  18427. t['xabovecmb'] = 0x033D;
  18428. t['xbopomofo'] = 0x3112;
  18429. t['xcircle'] = 0x24E7;
  18430. t['xdieresis'] = 0x1E8D;
  18431. t['xdotaccent'] = 0x1E8B;
  18432. t['xeharmenian'] = 0x056D;
  18433. t['xi'] = 0x03BE;
  18434. t['xmonospace'] = 0xFF58;
  18435. t['xparen'] = 0x24B3;
  18436. t['xsuperior'] = 0x02E3;
  18437. t['y'] = 0x0079;
  18438. t['yaadosquare'] = 0x334E;
  18439. t['yabengali'] = 0x09AF;
  18440. t['yacute'] = 0x00FD;
  18441. t['yadeva'] = 0x092F;
  18442. t['yaekorean'] = 0x3152;
  18443. t['yagujarati'] = 0x0AAF;
  18444. t['yagurmukhi'] = 0x0A2F;
  18445. t['yahiragana'] = 0x3084;
  18446. t['yakatakana'] = 0x30E4;
  18447. t['yakatakanahalfwidth'] = 0xFF94;
  18448. t['yakorean'] = 0x3151;
  18449. t['yamakkanthai'] = 0x0E4E;
  18450. t['yasmallhiragana'] = 0x3083;
  18451. t['yasmallkatakana'] = 0x30E3;
  18452. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  18453. t['yatcyrillic'] = 0x0463;
  18454. t['ycircle'] = 0x24E8;
  18455. t['ycircumflex'] = 0x0177;
  18456. t['ydieresis'] = 0x00FF;
  18457. t['ydotaccent'] = 0x1E8F;
  18458. t['ydotbelow'] = 0x1EF5;
  18459. t['yeharabic'] = 0x064A;
  18460. t['yehbarreearabic'] = 0x06D2;
  18461. t['yehbarreefinalarabic'] = 0xFBAF;
  18462. t['yehfinalarabic'] = 0xFEF2;
  18463. t['yehhamzaabovearabic'] = 0x0626;
  18464. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  18465. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  18466. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  18467. t['yehinitialarabic'] = 0xFEF3;
  18468. t['yehmedialarabic'] = 0xFEF4;
  18469. t['yehmeeminitialarabic'] = 0xFCDD;
  18470. t['yehmeemisolatedarabic'] = 0xFC58;
  18471. t['yehnoonfinalarabic'] = 0xFC94;
  18472. t['yehthreedotsbelowarabic'] = 0x06D1;
  18473. t['yekorean'] = 0x3156;
  18474. t['yen'] = 0x00A5;
  18475. t['yenmonospace'] = 0xFFE5;
  18476. t['yeokorean'] = 0x3155;
  18477. t['yeorinhieuhkorean'] = 0x3186;
  18478. t['yerahbenyomohebrew'] = 0x05AA;
  18479. t['yerahbenyomolefthebrew'] = 0x05AA;
  18480. t['yericyrillic'] = 0x044B;
  18481. t['yerudieresiscyrillic'] = 0x04F9;
  18482. t['yesieungkorean'] = 0x3181;
  18483. t['yesieungpansioskorean'] = 0x3183;
  18484. t['yesieungsioskorean'] = 0x3182;
  18485. t['yetivhebrew'] = 0x059A;
  18486. t['ygrave'] = 0x1EF3;
  18487. t['yhook'] = 0x01B4;
  18488. t['yhookabove'] = 0x1EF7;
  18489. t['yiarmenian'] = 0x0575;
  18490. t['yicyrillic'] = 0x0457;
  18491. t['yikorean'] = 0x3162;
  18492. t['yinyang'] = 0x262F;
  18493. t['yiwnarmenian'] = 0x0582;
  18494. t['ymonospace'] = 0xFF59;
  18495. t['yod'] = 0x05D9;
  18496. t['yoddagesh'] = 0xFB39;
  18497. t['yoddageshhebrew'] = 0xFB39;
  18498. t['yodhebrew'] = 0x05D9;
  18499. t['yodyodhebrew'] = 0x05F2;
  18500. t['yodyodpatahhebrew'] = 0xFB1F;
  18501. t['yohiragana'] = 0x3088;
  18502. t['yoikorean'] = 0x3189;
  18503. t['yokatakana'] = 0x30E8;
  18504. t['yokatakanahalfwidth'] = 0xFF96;
  18505. t['yokorean'] = 0x315B;
  18506. t['yosmallhiragana'] = 0x3087;
  18507. t['yosmallkatakana'] = 0x30E7;
  18508. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  18509. t['yotgreek'] = 0x03F3;
  18510. t['yoyaekorean'] = 0x3188;
  18511. t['yoyakorean'] = 0x3187;
  18512. t['yoyakthai'] = 0x0E22;
  18513. t['yoyingthai'] = 0x0E0D;
  18514. t['yparen'] = 0x24B4;
  18515. t['ypogegrammeni'] = 0x037A;
  18516. t['ypogegrammenigreekcmb'] = 0x0345;
  18517. t['yr'] = 0x01A6;
  18518. t['yring'] = 0x1E99;
  18519. t['ysuperior'] = 0x02B8;
  18520. t['ytilde'] = 0x1EF9;
  18521. t['yturned'] = 0x028E;
  18522. t['yuhiragana'] = 0x3086;
  18523. t['yuikorean'] = 0x318C;
  18524. t['yukatakana'] = 0x30E6;
  18525. t['yukatakanahalfwidth'] = 0xFF95;
  18526. t['yukorean'] = 0x3160;
  18527. t['yusbigcyrillic'] = 0x046B;
  18528. t['yusbigiotifiedcyrillic'] = 0x046D;
  18529. t['yuslittlecyrillic'] = 0x0467;
  18530. t['yuslittleiotifiedcyrillic'] = 0x0469;
  18531. t['yusmallhiragana'] = 0x3085;
  18532. t['yusmallkatakana'] = 0x30E5;
  18533. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  18534. t['yuyekorean'] = 0x318B;
  18535. t['yuyeokorean'] = 0x318A;
  18536. t['yyabengali'] = 0x09DF;
  18537. t['yyadeva'] = 0x095F;
  18538. t['z'] = 0x007A;
  18539. t['zaarmenian'] = 0x0566;
  18540. t['zacute'] = 0x017A;
  18541. t['zadeva'] = 0x095B;
  18542. t['zagurmukhi'] = 0x0A5B;
  18543. t['zaharabic'] = 0x0638;
  18544. t['zahfinalarabic'] = 0xFEC6;
  18545. t['zahinitialarabic'] = 0xFEC7;
  18546. t['zahiragana'] = 0x3056;
  18547. t['zahmedialarabic'] = 0xFEC8;
  18548. t['zainarabic'] = 0x0632;
  18549. t['zainfinalarabic'] = 0xFEB0;
  18550. t['zakatakana'] = 0x30B6;
  18551. t['zaqefgadolhebrew'] = 0x0595;
  18552. t['zaqefqatanhebrew'] = 0x0594;
  18553. t['zarqahebrew'] = 0x0598;
  18554. t['zayin'] = 0x05D6;
  18555. t['zayindagesh'] = 0xFB36;
  18556. t['zayindageshhebrew'] = 0xFB36;
  18557. t['zayinhebrew'] = 0x05D6;
  18558. t['zbopomofo'] = 0x3117;
  18559. t['zcaron'] = 0x017E;
  18560. t['zcircle'] = 0x24E9;
  18561. t['zcircumflex'] = 0x1E91;
  18562. t['zcurl'] = 0x0291;
  18563. t['zdot'] = 0x017C;
  18564. t['zdotaccent'] = 0x017C;
  18565. t['zdotbelow'] = 0x1E93;
  18566. t['zecyrillic'] = 0x0437;
  18567. t['zedescendercyrillic'] = 0x0499;
  18568. t['zedieresiscyrillic'] = 0x04DF;
  18569. t['zehiragana'] = 0x305C;
  18570. t['zekatakana'] = 0x30BC;
  18571. t['zero'] = 0x0030;
  18572. t['zeroarabic'] = 0x0660;
  18573. t['zerobengali'] = 0x09E6;
  18574. t['zerodeva'] = 0x0966;
  18575. t['zerogujarati'] = 0x0AE6;
  18576. t['zerogurmukhi'] = 0x0A66;
  18577. t['zerohackarabic'] = 0x0660;
  18578. t['zeroinferior'] = 0x2080;
  18579. t['zeromonospace'] = 0xFF10;
  18580. t['zerooldstyle'] = 0xF730;
  18581. t['zeropersian'] = 0x06F0;
  18582. t['zerosuperior'] = 0x2070;
  18583. t['zerothai'] = 0x0E50;
  18584. t['zerowidthjoiner'] = 0xFEFF;
  18585. t['zerowidthnonjoiner'] = 0x200C;
  18586. t['zerowidthspace'] = 0x200B;
  18587. t['zeta'] = 0x03B6;
  18588. t['zhbopomofo'] = 0x3113;
  18589. t['zhearmenian'] = 0x056A;
  18590. t['zhebrevecyrillic'] = 0x04C2;
  18591. t['zhecyrillic'] = 0x0436;
  18592. t['zhedescendercyrillic'] = 0x0497;
  18593. t['zhedieresiscyrillic'] = 0x04DD;
  18594. t['zihiragana'] = 0x3058;
  18595. t['zikatakana'] = 0x30B8;
  18596. t['zinorhebrew'] = 0x05AE;
  18597. t['zlinebelow'] = 0x1E95;
  18598. t['zmonospace'] = 0xFF5A;
  18599. t['zohiragana'] = 0x305E;
  18600. t['zokatakana'] = 0x30BE;
  18601. t['zparen'] = 0x24B5;
  18602. t['zretroflexhook'] = 0x0290;
  18603. t['zstroke'] = 0x01B6;
  18604. t['zuhiragana'] = 0x305A;
  18605. t['zukatakana'] = 0x30BA;
  18606. t['.notdef'] = 0x0000;
  18607. t['angbracketleftbig'] = 0x2329;
  18608. t['angbracketleftBig'] = 0x2329;
  18609. t['angbracketleftbigg'] = 0x2329;
  18610. t['angbracketleftBigg'] = 0x2329;
  18611. t['angbracketrightBig'] = 0x232A;
  18612. t['angbracketrightbig'] = 0x232A;
  18613. t['angbracketrightBigg'] = 0x232A;
  18614. t['angbracketrightbigg'] = 0x232A;
  18615. t['arrowhookleft'] = 0x21AA;
  18616. t['arrowhookright'] = 0x21A9;
  18617. t['arrowlefttophalf'] = 0x21BC;
  18618. t['arrowleftbothalf'] = 0x21BD;
  18619. t['arrownortheast'] = 0x2197;
  18620. t['arrownorthwest'] = 0x2196;
  18621. t['arrowrighttophalf'] = 0x21C0;
  18622. t['arrowrightbothalf'] = 0x21C1;
  18623. t['arrowsoutheast'] = 0x2198;
  18624. t['arrowsouthwest'] = 0x2199;
  18625. t['backslashbig'] = 0x2216;
  18626. t['backslashBig'] = 0x2216;
  18627. t['backslashBigg'] = 0x2216;
  18628. t['backslashbigg'] = 0x2216;
  18629. t['bardbl'] = 0x2016;
  18630. t['bracehtipdownleft'] = 0xFE37;
  18631. t['bracehtipdownright'] = 0xFE37;
  18632. t['bracehtipupleft'] = 0xFE38;
  18633. t['bracehtipupright'] = 0xFE38;
  18634. t['braceleftBig'] = 0x007B;
  18635. t['braceleftbig'] = 0x007B;
  18636. t['braceleftbigg'] = 0x007B;
  18637. t['braceleftBigg'] = 0x007B;
  18638. t['bracerightBig'] = 0x007D;
  18639. t['bracerightbig'] = 0x007D;
  18640. t['bracerightbigg'] = 0x007D;
  18641. t['bracerightBigg'] = 0x007D;
  18642. t['bracketleftbig'] = 0x005B;
  18643. t['bracketleftBig'] = 0x005B;
  18644. t['bracketleftbigg'] = 0x005B;
  18645. t['bracketleftBigg'] = 0x005B;
  18646. t['bracketrightBig'] = 0x005D;
  18647. t['bracketrightbig'] = 0x005D;
  18648. t['bracketrightbigg'] = 0x005D;
  18649. t['bracketrightBigg'] = 0x005D;
  18650. t['ceilingleftbig'] = 0x2308;
  18651. t['ceilingleftBig'] = 0x2308;
  18652. t['ceilingleftBigg'] = 0x2308;
  18653. t['ceilingleftbigg'] = 0x2308;
  18654. t['ceilingrightbig'] = 0x2309;
  18655. t['ceilingrightBig'] = 0x2309;
  18656. t['ceilingrightbigg'] = 0x2309;
  18657. t['ceilingrightBigg'] = 0x2309;
  18658. t['circledotdisplay'] = 0x2299;
  18659. t['circledottext'] = 0x2299;
  18660. t['circlemultiplydisplay'] = 0x2297;
  18661. t['circlemultiplytext'] = 0x2297;
  18662. t['circleplusdisplay'] = 0x2295;
  18663. t['circleplustext'] = 0x2295;
  18664. t['contintegraldisplay'] = 0x222E;
  18665. t['contintegraltext'] = 0x222E;
  18666. t['coproductdisplay'] = 0x2210;
  18667. t['coproducttext'] = 0x2210;
  18668. t['floorleftBig'] = 0x230A;
  18669. t['floorleftbig'] = 0x230A;
  18670. t['floorleftbigg'] = 0x230A;
  18671. t['floorleftBigg'] = 0x230A;
  18672. t['floorrightbig'] = 0x230B;
  18673. t['floorrightBig'] = 0x230B;
  18674. t['floorrightBigg'] = 0x230B;
  18675. t['floorrightbigg'] = 0x230B;
  18676. t['hatwide'] = 0x0302;
  18677. t['hatwider'] = 0x0302;
  18678. t['hatwidest'] = 0x0302;
  18679. t['intercal'] = 0x1D40;
  18680. t['integraldisplay'] = 0x222B;
  18681. t['integraltext'] = 0x222B;
  18682. t['intersectiondisplay'] = 0x22C2;
  18683. t['intersectiontext'] = 0x22C2;
  18684. t['logicalanddisplay'] = 0x2227;
  18685. t['logicalandtext'] = 0x2227;
  18686. t['logicalordisplay'] = 0x2228;
  18687. t['logicalortext'] = 0x2228;
  18688. t['parenleftBig'] = 0x0028;
  18689. t['parenleftbig'] = 0x0028;
  18690. t['parenleftBigg'] = 0x0028;
  18691. t['parenleftbigg'] = 0x0028;
  18692. t['parenrightBig'] = 0x0029;
  18693. t['parenrightbig'] = 0x0029;
  18694. t['parenrightBigg'] = 0x0029;
  18695. t['parenrightbigg'] = 0x0029;
  18696. t['prime'] = 0x2032;
  18697. t['productdisplay'] = 0x220F;
  18698. t['producttext'] = 0x220F;
  18699. t['radicalbig'] = 0x221A;
  18700. t['radicalBig'] = 0x221A;
  18701. t['radicalBigg'] = 0x221A;
  18702. t['radicalbigg'] = 0x221A;
  18703. t['radicalbt'] = 0x221A;
  18704. t['radicaltp'] = 0x221A;
  18705. t['radicalvertex'] = 0x221A;
  18706. t['slashbig'] = 0x002F;
  18707. t['slashBig'] = 0x002F;
  18708. t['slashBigg'] = 0x002F;
  18709. t['slashbigg'] = 0x002F;
  18710. t['summationdisplay'] = 0x2211;
  18711. t['summationtext'] = 0x2211;
  18712. t['tildewide'] = 0x02DC;
  18713. t['tildewider'] = 0x02DC;
  18714. t['tildewidest'] = 0x02DC;
  18715. t['uniondisplay'] = 0x22C3;
  18716. t['unionmultidisplay'] = 0x228E;
  18717. t['unionmultitext'] = 0x228E;
  18718. t['unionsqdisplay'] = 0x2294;
  18719. t['unionsqtext'] = 0x2294;
  18720. t['uniontext'] = 0x22C3;
  18721. t['vextenddouble'] = 0x2225;
  18722. t['vextendsingle'] = 0x2223;
  18723. });
  18724. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  18725. t['space'] = 0x0020;
  18726. t['a1'] = 0x2701;
  18727. t['a2'] = 0x2702;
  18728. t['a202'] = 0x2703;
  18729. t['a3'] = 0x2704;
  18730. t['a4'] = 0x260E;
  18731. t['a5'] = 0x2706;
  18732. t['a119'] = 0x2707;
  18733. t['a118'] = 0x2708;
  18734. t['a117'] = 0x2709;
  18735. t['a11'] = 0x261B;
  18736. t['a12'] = 0x261E;
  18737. t['a13'] = 0x270C;
  18738. t['a14'] = 0x270D;
  18739. t['a15'] = 0x270E;
  18740. t['a16'] = 0x270F;
  18741. t['a105'] = 0x2710;
  18742. t['a17'] = 0x2711;
  18743. t['a18'] = 0x2712;
  18744. t['a19'] = 0x2713;
  18745. t['a20'] = 0x2714;
  18746. t['a21'] = 0x2715;
  18747. t['a22'] = 0x2716;
  18748. t['a23'] = 0x2717;
  18749. t['a24'] = 0x2718;
  18750. t['a25'] = 0x2719;
  18751. t['a26'] = 0x271A;
  18752. t['a27'] = 0x271B;
  18753. t['a28'] = 0x271C;
  18754. t['a6'] = 0x271D;
  18755. t['a7'] = 0x271E;
  18756. t['a8'] = 0x271F;
  18757. t['a9'] = 0x2720;
  18758. t['a10'] = 0x2721;
  18759. t['a29'] = 0x2722;
  18760. t['a30'] = 0x2723;
  18761. t['a31'] = 0x2724;
  18762. t['a32'] = 0x2725;
  18763. t['a33'] = 0x2726;
  18764. t['a34'] = 0x2727;
  18765. t['a35'] = 0x2605;
  18766. t['a36'] = 0x2729;
  18767. t['a37'] = 0x272A;
  18768. t['a38'] = 0x272B;
  18769. t['a39'] = 0x272C;
  18770. t['a40'] = 0x272D;
  18771. t['a41'] = 0x272E;
  18772. t['a42'] = 0x272F;
  18773. t['a43'] = 0x2730;
  18774. t['a44'] = 0x2731;
  18775. t['a45'] = 0x2732;
  18776. t['a46'] = 0x2733;
  18777. t['a47'] = 0x2734;
  18778. t['a48'] = 0x2735;
  18779. t['a49'] = 0x2736;
  18780. t['a50'] = 0x2737;
  18781. t['a51'] = 0x2738;
  18782. t['a52'] = 0x2739;
  18783. t['a53'] = 0x273A;
  18784. t['a54'] = 0x273B;
  18785. t['a55'] = 0x273C;
  18786. t['a56'] = 0x273D;
  18787. t['a57'] = 0x273E;
  18788. t['a58'] = 0x273F;
  18789. t['a59'] = 0x2740;
  18790. t['a60'] = 0x2741;
  18791. t['a61'] = 0x2742;
  18792. t['a62'] = 0x2743;
  18793. t['a63'] = 0x2744;
  18794. t['a64'] = 0x2745;
  18795. t['a65'] = 0x2746;
  18796. t['a66'] = 0x2747;
  18797. t['a67'] = 0x2748;
  18798. t['a68'] = 0x2749;
  18799. t['a69'] = 0x274A;
  18800. t['a70'] = 0x274B;
  18801. t['a71'] = 0x25CF;
  18802. t['a72'] = 0x274D;
  18803. t['a73'] = 0x25A0;
  18804. t['a74'] = 0x274F;
  18805. t['a203'] = 0x2750;
  18806. t['a75'] = 0x2751;
  18807. t['a204'] = 0x2752;
  18808. t['a76'] = 0x25B2;
  18809. t['a77'] = 0x25BC;
  18810. t['a78'] = 0x25C6;
  18811. t['a79'] = 0x2756;
  18812. t['a81'] = 0x25D7;
  18813. t['a82'] = 0x2758;
  18814. t['a83'] = 0x2759;
  18815. t['a84'] = 0x275A;
  18816. t['a97'] = 0x275B;
  18817. t['a98'] = 0x275C;
  18818. t['a99'] = 0x275D;
  18819. t['a100'] = 0x275E;
  18820. t['a101'] = 0x2761;
  18821. t['a102'] = 0x2762;
  18822. t['a103'] = 0x2763;
  18823. t['a104'] = 0x2764;
  18824. t['a106'] = 0x2765;
  18825. t['a107'] = 0x2766;
  18826. t['a108'] = 0x2767;
  18827. t['a112'] = 0x2663;
  18828. t['a111'] = 0x2666;
  18829. t['a110'] = 0x2665;
  18830. t['a109'] = 0x2660;
  18831. t['a120'] = 0x2460;
  18832. t['a121'] = 0x2461;
  18833. t['a122'] = 0x2462;
  18834. t['a123'] = 0x2463;
  18835. t['a124'] = 0x2464;
  18836. t['a125'] = 0x2465;
  18837. t['a126'] = 0x2466;
  18838. t['a127'] = 0x2467;
  18839. t['a128'] = 0x2468;
  18840. t['a129'] = 0x2469;
  18841. t['a130'] = 0x2776;
  18842. t['a131'] = 0x2777;
  18843. t['a132'] = 0x2778;
  18844. t['a133'] = 0x2779;
  18845. t['a134'] = 0x277A;
  18846. t['a135'] = 0x277B;
  18847. t['a136'] = 0x277C;
  18848. t['a137'] = 0x277D;
  18849. t['a138'] = 0x277E;
  18850. t['a139'] = 0x277F;
  18851. t['a140'] = 0x2780;
  18852. t['a141'] = 0x2781;
  18853. t['a142'] = 0x2782;
  18854. t['a143'] = 0x2783;
  18855. t['a144'] = 0x2784;
  18856. t['a145'] = 0x2785;
  18857. t['a146'] = 0x2786;
  18858. t['a147'] = 0x2787;
  18859. t['a148'] = 0x2788;
  18860. t['a149'] = 0x2789;
  18861. t['a150'] = 0x278A;
  18862. t['a151'] = 0x278B;
  18863. t['a152'] = 0x278C;
  18864. t['a153'] = 0x278D;
  18865. t['a154'] = 0x278E;
  18866. t['a155'] = 0x278F;
  18867. t['a156'] = 0x2790;
  18868. t['a157'] = 0x2791;
  18869. t['a158'] = 0x2792;
  18870. t['a159'] = 0x2793;
  18871. t['a160'] = 0x2794;
  18872. t['a161'] = 0x2192;
  18873. t['a163'] = 0x2194;
  18874. t['a164'] = 0x2195;
  18875. t['a196'] = 0x2798;
  18876. t['a165'] = 0x2799;
  18877. t['a192'] = 0x279A;
  18878. t['a166'] = 0x279B;
  18879. t['a167'] = 0x279C;
  18880. t['a168'] = 0x279D;
  18881. t['a169'] = 0x279E;
  18882. t['a170'] = 0x279F;
  18883. t['a171'] = 0x27A0;
  18884. t['a172'] = 0x27A1;
  18885. t['a173'] = 0x27A2;
  18886. t['a162'] = 0x27A3;
  18887. t['a174'] = 0x27A4;
  18888. t['a175'] = 0x27A5;
  18889. t['a176'] = 0x27A6;
  18890. t['a177'] = 0x27A7;
  18891. t['a178'] = 0x27A8;
  18892. t['a179'] = 0x27A9;
  18893. t['a193'] = 0x27AA;
  18894. t['a180'] = 0x27AB;
  18895. t['a199'] = 0x27AC;
  18896. t['a181'] = 0x27AD;
  18897. t['a200'] = 0x27AE;
  18898. t['a182'] = 0x27AF;
  18899. t['a201'] = 0x27B1;
  18900. t['a183'] = 0x27B2;
  18901. t['a184'] = 0x27B3;
  18902. t['a197'] = 0x27B4;
  18903. t['a185'] = 0x27B5;
  18904. t['a194'] = 0x27B6;
  18905. t['a198'] = 0x27B7;
  18906. t['a186'] = 0x27B8;
  18907. t['a195'] = 0x27B9;
  18908. t['a187'] = 0x27BA;
  18909. t['a188'] = 0x27BB;
  18910. t['a189'] = 0x27BC;
  18911. t['a190'] = 0x27BD;
  18912. t['a191'] = 0x27BE;
  18913. t['a89'] = 0x2768;
  18914. t['a90'] = 0x2769;
  18915. t['a93'] = 0x276A;
  18916. t['a94'] = 0x276B;
  18917. t['a91'] = 0x276C;
  18918. t['a92'] = 0x276D;
  18919. t['a205'] = 0x276E;
  18920. t['a85'] = 0x276F;
  18921. t['a206'] = 0x2770;
  18922. t['a86'] = 0x2771;
  18923. t['a87'] = 0x2772;
  18924. t['a88'] = 0x2773;
  18925. t['a95'] = 0x2774;
  18926. t['a96'] = 0x2775;
  18927. t['.notdef'] = 0x0000;
  18928. });
  18929. exports.getGlyphsUnicode = getGlyphsUnicode;
  18930. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  18931. /***/ }),
  18932. /* 9 */
  18933. /***/ (function(module, exports, __w_pdfjs_require__) {
  18934. "use strict";
  18935. var sharedUtil = __w_pdfjs_require__(0);
  18936. var displayDOMUtils = __w_pdfjs_require__(3);
  18937. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  18938. var AnnotationType = sharedUtil.AnnotationType;
  18939. var stringToPDFString = sharedUtil.stringToPDFString;
  18940. var Util = sharedUtil.Util;
  18941. var addLinkAttributes = displayDOMUtils.addLinkAttributes;
  18942. var LinkTarget = displayDOMUtils.LinkTarget;
  18943. var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  18944. var warn = sharedUtil.warn;
  18945. var CustomStyle = displayDOMUtils.CustomStyle;
  18946. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  18947. function AnnotationElementFactory() {
  18948. }
  18949. AnnotationElementFactory.prototype = {
  18950. create: function AnnotationElementFactory_create(parameters) {
  18951. var subtype = parameters.data.annotationType;
  18952. switch (subtype) {
  18953. case AnnotationType.LINK:
  18954. return new LinkAnnotationElement(parameters);
  18955. case AnnotationType.TEXT:
  18956. return new TextAnnotationElement(parameters);
  18957. case AnnotationType.WIDGET:
  18958. var fieldType = parameters.data.fieldType;
  18959. switch (fieldType) {
  18960. case 'Tx':
  18961. return new TextWidgetAnnotationElement(parameters);
  18962. case 'Btn':
  18963. if (parameters.data.radioButton) {
  18964. return new RadioButtonWidgetAnnotationElement(parameters);
  18965. } else if (parameters.data.checkBox) {
  18966. return new CheckboxWidgetAnnotationElement(parameters);
  18967. }
  18968. warn('Unimplemented button widget annotation: pushbutton');
  18969. break;
  18970. case 'Ch':
  18971. return new ChoiceWidgetAnnotationElement(parameters);
  18972. }
  18973. return new WidgetAnnotationElement(parameters);
  18974. case AnnotationType.POPUP:
  18975. return new PopupAnnotationElement(parameters);
  18976. case AnnotationType.HIGHLIGHT:
  18977. return new HighlightAnnotationElement(parameters);
  18978. case AnnotationType.UNDERLINE:
  18979. return new UnderlineAnnotationElement(parameters);
  18980. case AnnotationType.SQUIGGLY:
  18981. return new SquigglyAnnotationElement(parameters);
  18982. case AnnotationType.STRIKEOUT:
  18983. return new StrikeOutAnnotationElement(parameters);
  18984. case AnnotationType.FILEATTACHMENT:
  18985. return new FileAttachmentAnnotationElement(parameters);
  18986. default:
  18987. return new AnnotationElement(parameters);
  18988. }
  18989. }
  18990. };
  18991. var AnnotationElement = function AnnotationElementClosure() {
  18992. function AnnotationElement(parameters, isRenderable) {
  18993. this.isRenderable = isRenderable || false;
  18994. this.data = parameters.data;
  18995. this.layer = parameters.layer;
  18996. this.page = parameters.page;
  18997. this.viewport = parameters.viewport;
  18998. this.linkService = parameters.linkService;
  18999. this.downloadManager = parameters.downloadManager;
  19000. this.imageResourcesPath = parameters.imageResourcesPath;
  19001. this.renderInteractiveForms = parameters.renderInteractiveForms;
  19002. if (isRenderable) {
  19003. this.container = this._createContainer();
  19004. }
  19005. }
  19006. AnnotationElement.prototype = {
  19007. _createContainer: function AnnotationElement_createContainer() {
  19008. var data = this.data, page = this.page, viewport = this.viewport;
  19009. var container = document.createElement('section');
  19010. var width = data.rect[2] - data.rect[0];
  19011. var height = data.rect[3] - data.rect[1];
  19012. container.setAttribute('data-annotation-id', data.id);
  19013. var rect = Util.normalizeRect([
  19014. data.rect[0],
  19015. page.view[3] - data.rect[1] + page.view[1],
  19016. data.rect[2],
  19017. page.view[3] - data.rect[3] + page.view[1]
  19018. ]);
  19019. CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  19020. CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  19021. if (data.borderStyle.width > 0) {
  19022. container.style.borderWidth = data.borderStyle.width + 'px';
  19023. if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
  19024. width = width - 2 * data.borderStyle.width;
  19025. height = height - 2 * data.borderStyle.width;
  19026. }
  19027. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  19028. var verticalRadius = data.borderStyle.verticalCornerRadius;
  19029. if (horizontalRadius > 0 || verticalRadius > 0) {
  19030. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  19031. CustomStyle.setProp('borderRadius', container, radius);
  19032. }
  19033. switch (data.borderStyle.style) {
  19034. case AnnotationBorderStyleType.SOLID:
  19035. container.style.borderStyle = 'solid';
  19036. break;
  19037. case AnnotationBorderStyleType.DASHED:
  19038. container.style.borderStyle = 'dashed';
  19039. break;
  19040. case AnnotationBorderStyleType.BEVELED:
  19041. warn('Unimplemented border style: beveled');
  19042. break;
  19043. case AnnotationBorderStyleType.INSET:
  19044. warn('Unimplemented border style: inset');
  19045. break;
  19046. case AnnotationBorderStyleType.UNDERLINE:
  19047. container.style.borderBottomStyle = 'solid';
  19048. break;
  19049. default:
  19050. break;
  19051. }
  19052. if (data.color) {
  19053. container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  19054. } else {
  19055. container.style.borderWidth = 0;
  19056. }
  19057. }
  19058. container.style.left = rect[0] + 'px';
  19059. container.style.top = rect[1] + 'px';
  19060. container.style.width = width + 'px';
  19061. container.style.height = height + 'px';
  19062. return container;
  19063. },
  19064. _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
  19065. if (!trigger) {
  19066. trigger = document.createElement('div');
  19067. trigger.style.height = container.style.height;
  19068. trigger.style.width = container.style.width;
  19069. container.appendChild(trigger);
  19070. }
  19071. var popupElement = new PopupElement({
  19072. container: container,
  19073. trigger: trigger,
  19074. color: data.color,
  19075. title: data.title,
  19076. contents: data.contents,
  19077. hideWrapper: true
  19078. });
  19079. var popup = popupElement.render();
  19080. popup.style.left = container.style.width;
  19081. container.appendChild(popup);
  19082. },
  19083. render: function AnnotationElement_render() {
  19084. throw new Error('Abstract method AnnotationElement.render called');
  19085. }
  19086. };
  19087. return AnnotationElement;
  19088. }();
  19089. var LinkAnnotationElement = function LinkAnnotationElementClosure() {
  19090. function LinkAnnotationElement(parameters) {
  19091. AnnotationElement.call(this, parameters, true);
  19092. }
  19093. Util.inherit(LinkAnnotationElement, AnnotationElement, {
  19094. render: function LinkAnnotationElement_render() {
  19095. this.container.className = 'linkAnnotation';
  19096. var link = document.createElement('a');
  19097. addLinkAttributes(link, {
  19098. url: this.data.url,
  19099. target: this.data.newWindow ? LinkTarget.BLANK : undefined
  19100. });
  19101. if (!this.data.url) {
  19102. if (this.data.action) {
  19103. this._bindNamedAction(link, this.data.action);
  19104. } else {
  19105. this._bindLink(link, this.data.dest);
  19106. }
  19107. }
  19108. this.container.appendChild(link);
  19109. return this.container;
  19110. },
  19111. _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
  19112. var self = this;
  19113. link.href = this.linkService.getDestinationHash(destination);
  19114. link.onclick = function () {
  19115. if (destination) {
  19116. self.linkService.navigateTo(destination);
  19117. }
  19118. return false;
  19119. };
  19120. if (destination) {
  19121. link.className = 'internalLink';
  19122. }
  19123. },
  19124. _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) {
  19125. var self = this;
  19126. link.href = this.linkService.getAnchorUrl('');
  19127. link.onclick = function () {
  19128. self.linkService.executeNamedAction(action);
  19129. return false;
  19130. };
  19131. link.className = 'internalLink';
  19132. }
  19133. });
  19134. return LinkAnnotationElement;
  19135. }();
  19136. var TextAnnotationElement = function TextAnnotationElementClosure() {
  19137. function TextAnnotationElement(parameters) {
  19138. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19139. AnnotationElement.call(this, parameters, isRenderable);
  19140. }
  19141. Util.inherit(TextAnnotationElement, AnnotationElement, {
  19142. render: function TextAnnotationElement_render() {
  19143. this.container.className = 'textAnnotation';
  19144. var image = document.createElement('img');
  19145. image.style.height = this.container.style.height;
  19146. image.style.width = this.container.style.width;
  19147. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  19148. image.alt = '[{{type}} Annotation]';
  19149. image.dataset.l10nId = 'text_annotation_type';
  19150. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  19151. if (!this.data.hasPopup) {
  19152. this._createPopup(this.container, image, this.data);
  19153. }
  19154. this.container.appendChild(image);
  19155. return this.container;
  19156. }
  19157. });
  19158. return TextAnnotationElement;
  19159. }();
  19160. var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
  19161. function WidgetAnnotationElement(parameters, isRenderable) {
  19162. AnnotationElement.call(this, parameters, isRenderable);
  19163. }
  19164. Util.inherit(WidgetAnnotationElement, AnnotationElement, {
  19165. render: function WidgetAnnotationElement_render() {
  19166. return this.container;
  19167. }
  19168. });
  19169. return WidgetAnnotationElement;
  19170. }();
  19171. var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
  19172. var TEXT_ALIGNMENT = [
  19173. 'left',
  19174. 'center',
  19175. 'right'
  19176. ];
  19177. function TextWidgetAnnotationElement(parameters) {
  19178. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  19179. WidgetAnnotationElement.call(this, parameters, isRenderable);
  19180. }
  19181. Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
  19182. render: function TextWidgetAnnotationElement_render() {
  19183. this.container.className = 'textWidgetAnnotation';
  19184. var element = null;
  19185. if (this.renderInteractiveForms) {
  19186. if (this.data.multiLine) {
  19187. element = document.createElement('textarea');
  19188. element.textContent = this.data.fieldValue;
  19189. } else {
  19190. element = document.createElement('input');
  19191. element.type = 'text';
  19192. element.setAttribute('value', this.data.fieldValue);
  19193. }
  19194. element.disabled = this.data.readOnly;
  19195. if (this.data.maxLen !== null) {
  19196. element.maxLength = this.data.maxLen;
  19197. }
  19198. if (this.data.comb) {
  19199. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  19200. var combWidth = fieldWidth / this.data.maxLen;
  19201. element.classList.add('comb');
  19202. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  19203. }
  19204. } else {
  19205. element = document.createElement('div');
  19206. element.textContent = this.data.fieldValue;
  19207. element.style.verticalAlign = 'middle';
  19208. element.style.display = 'table-cell';
  19209. var font = null;
  19210. if (this.data.fontRefName) {
  19211. font = this.page.commonObjs.getData(this.data.fontRefName);
  19212. }
  19213. this._setTextStyle(element, font);
  19214. }
  19215. if (this.data.textAlignment !== null) {
  19216. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  19217. }
  19218. this.container.appendChild(element);
  19219. return this.container;
  19220. },
  19221. _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
  19222. var style = element.style;
  19223. style.fontSize = this.data.fontSize + 'px';
  19224. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  19225. if (!font) {
  19226. return;
  19227. }
  19228. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  19229. style.fontStyle = font.italic ? 'italic' : 'normal';
  19230. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  19231. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  19232. style.fontFamily = fontFamily + fallbackName;
  19233. }
  19234. });
  19235. return TextWidgetAnnotationElement;
  19236. }();
  19237. var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementClosure() {
  19238. function CheckboxWidgetAnnotationElement(parameters) {
  19239. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  19240. }
  19241. Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, {
  19242. render: function CheckboxWidgetAnnotationElement_render() {
  19243. this.container.className = 'buttonWidgetAnnotation checkBox';
  19244. var element = document.createElement('input');
  19245. element.disabled = this.data.readOnly;
  19246. element.type = 'checkbox';
  19247. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  19248. element.setAttribute('checked', true);
  19249. }
  19250. this.container.appendChild(element);
  19251. return this.container;
  19252. }
  19253. });
  19254. return CheckboxWidgetAnnotationElement;
  19255. }();
  19256. var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationElementClosure() {
  19257. function RadioButtonWidgetAnnotationElement(parameters) {
  19258. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  19259. }
  19260. Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, {
  19261. render: function RadioButtonWidgetAnnotationElement_render() {
  19262. this.container.className = 'buttonWidgetAnnotation radioButton';
  19263. var element = document.createElement('input');
  19264. element.disabled = this.data.readOnly;
  19265. element.type = 'radio';
  19266. element.name = this.data.fieldName;
  19267. if (this.data.fieldValue === this.data.buttonValue) {
  19268. element.setAttribute('checked', true);
  19269. }
  19270. this.container.appendChild(element);
  19271. return this.container;
  19272. }
  19273. });
  19274. return RadioButtonWidgetAnnotationElement;
  19275. }();
  19276. var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
  19277. function ChoiceWidgetAnnotationElement(parameters) {
  19278. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  19279. }
  19280. Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
  19281. render: function ChoiceWidgetAnnotationElement_render() {
  19282. this.container.className = 'choiceWidgetAnnotation';
  19283. var selectElement = document.createElement('select');
  19284. selectElement.disabled = this.data.readOnly;
  19285. if (!this.data.combo) {
  19286. selectElement.size = this.data.options.length;
  19287. if (this.data.multiSelect) {
  19288. selectElement.multiple = true;
  19289. }
  19290. }
  19291. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  19292. var option = this.data.options[i];
  19293. var optionElement = document.createElement('option');
  19294. optionElement.textContent = option.displayValue;
  19295. optionElement.value = option.exportValue;
  19296. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  19297. optionElement.setAttribute('selected', true);
  19298. }
  19299. selectElement.appendChild(optionElement);
  19300. }
  19301. this.container.appendChild(selectElement);
  19302. return this.container;
  19303. }
  19304. });
  19305. return ChoiceWidgetAnnotationElement;
  19306. }();
  19307. var PopupAnnotationElement = function PopupAnnotationElementClosure() {
  19308. function PopupAnnotationElement(parameters) {
  19309. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  19310. AnnotationElement.call(this, parameters, isRenderable);
  19311. }
  19312. Util.inherit(PopupAnnotationElement, AnnotationElement, {
  19313. render: function PopupAnnotationElement_render() {
  19314. this.container.className = 'popupAnnotation';
  19315. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  19316. var parentElement = this.layer.querySelector(selector);
  19317. if (!parentElement) {
  19318. return this.container;
  19319. }
  19320. var popup = new PopupElement({
  19321. container: this.container,
  19322. trigger: parentElement,
  19323. color: this.data.color,
  19324. title: this.data.title,
  19325. contents: this.data.contents
  19326. });
  19327. var parentLeft = parseFloat(parentElement.style.left);
  19328. var parentWidth = parseFloat(parentElement.style.width);
  19329. CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  19330. this.container.style.left = parentLeft + parentWidth + 'px';
  19331. this.container.appendChild(popup.render());
  19332. return this.container;
  19333. }
  19334. });
  19335. return PopupAnnotationElement;
  19336. }();
  19337. var PopupElement = function PopupElementClosure() {
  19338. var BACKGROUND_ENLIGHT = 0.7;
  19339. function PopupElement(parameters) {
  19340. this.container = parameters.container;
  19341. this.trigger = parameters.trigger;
  19342. this.color = parameters.color;
  19343. this.title = parameters.title;
  19344. this.contents = parameters.contents;
  19345. this.hideWrapper = parameters.hideWrapper || false;
  19346. this.pinned = false;
  19347. }
  19348. PopupElement.prototype = {
  19349. render: function PopupElement_render() {
  19350. var wrapper = document.createElement('div');
  19351. wrapper.className = 'popupWrapper';
  19352. this.hideElement = this.hideWrapper ? wrapper : this.container;
  19353. this.hideElement.setAttribute('hidden', true);
  19354. var popup = document.createElement('div');
  19355. popup.className = 'popup';
  19356. var color = this.color;
  19357. if (color) {
  19358. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  19359. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  19360. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  19361. popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
  19362. }
  19363. var contents = this._formatContents(this.contents);
  19364. var title = document.createElement('h1');
  19365. title.textContent = this.title;
  19366. this.trigger.addEventListener('click', this._toggle.bind(this));
  19367. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  19368. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  19369. popup.addEventListener('click', this._hide.bind(this, true));
  19370. popup.appendChild(title);
  19371. popup.appendChild(contents);
  19372. wrapper.appendChild(popup);
  19373. return wrapper;
  19374. },
  19375. _formatContents: function PopupElement_formatContents(contents) {
  19376. var p = document.createElement('p');
  19377. var lines = contents.split(/(?:\r\n?|\n)/);
  19378. for (var i = 0, ii = lines.length; i < ii; ++i) {
  19379. var line = lines[i];
  19380. p.appendChild(document.createTextNode(line));
  19381. if (i < ii - 1) {
  19382. p.appendChild(document.createElement('br'));
  19383. }
  19384. }
  19385. return p;
  19386. },
  19387. _toggle: function PopupElement_toggle() {
  19388. if (this.pinned) {
  19389. this._hide(true);
  19390. } else {
  19391. this._show(true);
  19392. }
  19393. },
  19394. _show: function PopupElement_show(pin) {
  19395. if (pin) {
  19396. this.pinned = true;
  19397. }
  19398. if (this.hideElement.hasAttribute('hidden')) {
  19399. this.hideElement.removeAttribute('hidden');
  19400. this.container.style.zIndex += 1;
  19401. }
  19402. },
  19403. _hide: function PopupElement_hide(unpin) {
  19404. if (unpin) {
  19405. this.pinned = false;
  19406. }
  19407. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  19408. this.hideElement.setAttribute('hidden', true);
  19409. this.container.style.zIndex -= 1;
  19410. }
  19411. }
  19412. };
  19413. return PopupElement;
  19414. }();
  19415. var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
  19416. function HighlightAnnotationElement(parameters) {
  19417. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19418. AnnotationElement.call(this, parameters, isRenderable);
  19419. }
  19420. Util.inherit(HighlightAnnotationElement, AnnotationElement, {
  19421. render: function HighlightAnnotationElement_render() {
  19422. this.container.className = 'highlightAnnotation';
  19423. if (!this.data.hasPopup) {
  19424. this._createPopup(this.container, null, this.data);
  19425. }
  19426. return this.container;
  19427. }
  19428. });
  19429. return HighlightAnnotationElement;
  19430. }();
  19431. var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
  19432. function UnderlineAnnotationElement(parameters) {
  19433. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19434. AnnotationElement.call(this, parameters, isRenderable);
  19435. }
  19436. Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
  19437. render: function UnderlineAnnotationElement_render() {
  19438. this.container.className = 'underlineAnnotation';
  19439. if (!this.data.hasPopup) {
  19440. this._createPopup(this.container, null, this.data);
  19441. }
  19442. return this.container;
  19443. }
  19444. });
  19445. return UnderlineAnnotationElement;
  19446. }();
  19447. var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
  19448. function SquigglyAnnotationElement(parameters) {
  19449. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19450. AnnotationElement.call(this, parameters, isRenderable);
  19451. }
  19452. Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
  19453. render: function SquigglyAnnotationElement_render() {
  19454. this.container.className = 'squigglyAnnotation';
  19455. if (!this.data.hasPopup) {
  19456. this._createPopup(this.container, null, this.data);
  19457. }
  19458. return this.container;
  19459. }
  19460. });
  19461. return SquigglyAnnotationElement;
  19462. }();
  19463. var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
  19464. function StrikeOutAnnotationElement(parameters) {
  19465. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  19466. AnnotationElement.call(this, parameters, isRenderable);
  19467. }
  19468. Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
  19469. render: function StrikeOutAnnotationElement_render() {
  19470. this.container.className = 'strikeoutAnnotation';
  19471. if (!this.data.hasPopup) {
  19472. this._createPopup(this.container, null, this.data);
  19473. }
  19474. return this.container;
  19475. }
  19476. });
  19477. return StrikeOutAnnotationElement;
  19478. }();
  19479. var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
  19480. function FileAttachmentAnnotationElement(parameters) {
  19481. AnnotationElement.call(this, parameters, true);
  19482. var file = this.data.file;
  19483. this.filename = getFilenameFromUrl(file.filename);
  19484. this.content = file.content;
  19485. this.linkService.onFileAttachmentAnnotation({
  19486. id: stringToPDFString(file.filename),
  19487. filename: file.filename,
  19488. content: file.content
  19489. });
  19490. }
  19491. Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
  19492. render: function FileAttachmentAnnotationElement_render() {
  19493. this.container.className = 'fileAttachmentAnnotation';
  19494. var trigger = document.createElement('div');
  19495. trigger.style.height = this.container.style.height;
  19496. trigger.style.width = this.container.style.width;
  19497. trigger.addEventListener('dblclick', this._download.bind(this));
  19498. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  19499. this._createPopup(this.container, trigger, this.data);
  19500. }
  19501. this.container.appendChild(trigger);
  19502. return this.container;
  19503. },
  19504. _download: function FileAttachmentAnnotationElement_download() {
  19505. if (!this.downloadManager) {
  19506. warn('Download cannot be started due to unavailable download manager');
  19507. return;
  19508. }
  19509. this.downloadManager.downloadData(this.content, this.filename, '');
  19510. }
  19511. });
  19512. return FileAttachmentAnnotationElement;
  19513. }();
  19514. var AnnotationLayer = function AnnotationLayerClosure() {
  19515. return {
  19516. render: function AnnotationLayer_render(parameters) {
  19517. var annotationElementFactory = new AnnotationElementFactory();
  19518. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  19519. var data = parameters.annotations[i];
  19520. if (!data) {
  19521. continue;
  19522. }
  19523. var element = annotationElementFactory.create({
  19524. data: data,
  19525. layer: parameters.div,
  19526. page: parameters.page,
  19527. viewport: parameters.viewport,
  19528. linkService: parameters.linkService,
  19529. downloadManager: parameters.downloadManager,
  19530. imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
  19531. renderInteractiveForms: parameters.renderInteractiveForms || false
  19532. });
  19533. if (element.isRenderable) {
  19534. parameters.div.appendChild(element.render());
  19535. }
  19536. }
  19537. },
  19538. update: function AnnotationLayer_update(parameters) {
  19539. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  19540. var data = parameters.annotations[i];
  19541. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  19542. if (element) {
  19543. CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  19544. }
  19545. }
  19546. parameters.div.removeAttribute('hidden');
  19547. }
  19548. };
  19549. }();
  19550. exports.AnnotationLayer = AnnotationLayer;
  19551. /***/ }),
  19552. /* 10 */
  19553. /***/ (function(module, exports, __w_pdfjs_require__) {
  19554. "use strict";
  19555. var sharedUtil = __w_pdfjs_require__(0);
  19556. var displayFontLoader = __w_pdfjs_require__(45);
  19557. var displayCanvas = __w_pdfjs_require__(44);
  19558. var displayMetadata = __w_pdfjs_require__(23);
  19559. var displayDOMUtils = __w_pdfjs_require__(3);
  19560. var amdRequire;
  19561. var InvalidPDFException = sharedUtil.InvalidPDFException;
  19562. var MessageHandler = sharedUtil.MessageHandler;
  19563. var MissingPDFException = sharedUtil.MissingPDFException;
  19564. var PageViewport = sharedUtil.PageViewport;
  19565. var PasswordException = sharedUtil.PasswordException;
  19566. var StatTimer = sharedUtil.StatTimer;
  19567. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  19568. var UnknownErrorException = sharedUtil.UnknownErrorException;
  19569. var Util = sharedUtil.Util;
  19570. var createPromiseCapability = sharedUtil.createPromiseCapability;
  19571. var error = sharedUtil.error;
  19572. var deprecated = sharedUtil.deprecated;
  19573. var getVerbosityLevel = sharedUtil.getVerbosityLevel;
  19574. var info = sharedUtil.info;
  19575. var isInt = sharedUtil.isInt;
  19576. var isArray = sharedUtil.isArray;
  19577. var isArrayBuffer = sharedUtil.isArrayBuffer;
  19578. var isSameOrigin = sharedUtil.isSameOrigin;
  19579. var loadJpegStream = sharedUtil.loadJpegStream;
  19580. var stringToBytes = sharedUtil.stringToBytes;
  19581. var globalScope = sharedUtil.globalScope;
  19582. var warn = sharedUtil.warn;
  19583. var FontFaceObject = displayFontLoader.FontFaceObject;
  19584. var FontLoader = displayFontLoader.FontLoader;
  19585. var CanvasGraphics = displayCanvas.CanvasGraphics;
  19586. var Metadata = displayMetadata.Metadata;
  19587. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  19588. var DOMCanvasFactory = displayDOMUtils.DOMCanvasFactory;
  19589. var DOMCMapReaderFactory = displayDOMUtils.DOMCMapReaderFactory;
  19590. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  19591. var isWorkerDisabled = false;
  19592. var workerSrc;
  19593. var isPostMessageTransfersDisabled = false;
  19594. var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  19595. var fakeWorkerFilesLoader = null;
  19596. var useRequireEnsure = false;
  19597. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  19598. var task = new PDFDocumentLoadingTask();
  19599. if (arguments.length > 1) {
  19600. deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  19601. }
  19602. if (pdfDataRangeTransport) {
  19603. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  19604. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  19605. pdfDataRangeTransport.length = src.length;
  19606. pdfDataRangeTransport.initialData = src.initialData;
  19607. if (!pdfDataRangeTransport.abort) {
  19608. pdfDataRangeTransport.abort = function () {
  19609. };
  19610. }
  19611. }
  19612. src = Object.create(src);
  19613. src.range = pdfDataRangeTransport;
  19614. }
  19615. task.onPassword = passwordCallback || null;
  19616. task.onProgress = progressCallback || null;
  19617. var source;
  19618. if (typeof src === 'string') {
  19619. source = { url: src };
  19620. } else if (isArrayBuffer(src)) {
  19621. source = { data: src };
  19622. } else if (src instanceof PDFDataRangeTransport) {
  19623. source = { range: src };
  19624. } else {
  19625. if (typeof src !== 'object') {
  19626. error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
  19627. }
  19628. if (!src.url && !src.data && !src.range) {
  19629. error('Invalid parameter object: need either .data, .range or .url');
  19630. }
  19631. source = src;
  19632. }
  19633. var params = {};
  19634. var rangeTransport = null;
  19635. var worker = null;
  19636. for (var key in source) {
  19637. if (key === 'url' && typeof window !== 'undefined') {
  19638. params[key] = new URL(source[key], window.location).href;
  19639. continue;
  19640. } else if (key === 'range') {
  19641. rangeTransport = source[key];
  19642. continue;
  19643. } else if (key === 'worker') {
  19644. worker = source[key];
  19645. continue;
  19646. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  19647. var pdfBytes = source[key];
  19648. if (typeof pdfBytes === 'string') {
  19649. params[key] = stringToBytes(pdfBytes);
  19650. } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  19651. params[key] = new Uint8Array(pdfBytes);
  19652. } else if (isArrayBuffer(pdfBytes)) {
  19653. params[key] = new Uint8Array(pdfBytes);
  19654. } else {
  19655. error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
  19656. }
  19657. continue;
  19658. }
  19659. params[key] = source[key];
  19660. }
  19661. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  19662. params.disableNativeImageDecoder = params.disableNativeImageDecoder === true;
  19663. var CMapReaderFactory = params.CMapReaderFactory || DOMCMapReaderFactory;
  19664. if (!worker) {
  19665. worker = new PDFWorker();
  19666. task._worker = worker;
  19667. }
  19668. var docId = task.docId;
  19669. worker.promise.then(function () {
  19670. if (task.destroyed) {
  19671. throw new Error('Loading aborted');
  19672. }
  19673. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  19674. if (task.destroyed) {
  19675. throw new Error('Loading aborted');
  19676. }
  19677. var messageHandler = new MessageHandler(docId, workerId, worker.port);
  19678. var transport = new WorkerTransport(messageHandler, task, rangeTransport, CMapReaderFactory);
  19679. task._transport = transport;
  19680. messageHandler.send('Ready', null);
  19681. });
  19682. }).catch(task._capability.reject);
  19683. return task;
  19684. }
  19685. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  19686. if (worker.destroyed) {
  19687. return Promise.reject(new Error('Worker was destroyed'));
  19688. }
  19689. source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
  19690. source.disableStream = getDefaultSetting('disableStream');
  19691. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  19692. if (pdfDataRangeTransport) {
  19693. source.length = pdfDataRangeTransport.length;
  19694. source.initialData = pdfDataRangeTransport.initialData;
  19695. }
  19696. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  19697. docId: docId,
  19698. source: source,
  19699. disableRange: getDefaultSetting('disableRange'),
  19700. maxImageSize: getDefaultSetting('maxImageSize'),
  19701. disableFontFace: getDefaultSetting('disableFontFace'),
  19702. disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
  19703. postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
  19704. docBaseUrl: source.docBaseUrl,
  19705. disableNativeImageDecoder: source.disableNativeImageDecoder
  19706. }).then(function (workerId) {
  19707. if (worker.destroyed) {
  19708. throw new Error('Worker was destroyed');
  19709. }
  19710. return workerId;
  19711. });
  19712. }
  19713. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  19714. var nextDocumentId = 0;
  19715. function PDFDocumentLoadingTask() {
  19716. this._capability = createPromiseCapability();
  19717. this._transport = null;
  19718. this._worker = null;
  19719. this.docId = 'd' + nextDocumentId++;
  19720. this.destroyed = false;
  19721. this.onPassword = null;
  19722. this.onProgress = null;
  19723. this.onUnsupportedFeature = null;
  19724. }
  19725. PDFDocumentLoadingTask.prototype = {
  19726. get promise() {
  19727. return this._capability.promise;
  19728. },
  19729. destroy: function () {
  19730. this.destroyed = true;
  19731. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  19732. return transportDestroyed.then(function () {
  19733. this._transport = null;
  19734. if (this._worker) {
  19735. this._worker.destroy();
  19736. this._worker = null;
  19737. }
  19738. }.bind(this));
  19739. },
  19740. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  19741. return this.promise.then.apply(this.promise, arguments);
  19742. }
  19743. };
  19744. return PDFDocumentLoadingTask;
  19745. }();
  19746. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  19747. function PDFDataRangeTransport(length, initialData) {
  19748. this.length = length;
  19749. this.initialData = initialData;
  19750. this._rangeListeners = [];
  19751. this._progressListeners = [];
  19752. this._progressiveReadListeners = [];
  19753. this._readyCapability = createPromiseCapability();
  19754. }
  19755. PDFDataRangeTransport.prototype = {
  19756. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  19757. this._rangeListeners.push(listener);
  19758. },
  19759. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  19760. this._progressListeners.push(listener);
  19761. },
  19762. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  19763. this._progressiveReadListeners.push(listener);
  19764. },
  19765. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  19766. var listeners = this._rangeListeners;
  19767. for (var i = 0, n = listeners.length; i < n; ++i) {
  19768. listeners[i](begin, chunk);
  19769. }
  19770. },
  19771. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  19772. this._readyCapability.promise.then(function () {
  19773. var listeners = this._progressListeners;
  19774. for (var i = 0, n = listeners.length; i < n; ++i) {
  19775. listeners[i](loaded);
  19776. }
  19777. }.bind(this));
  19778. },
  19779. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  19780. this._readyCapability.promise.then(function () {
  19781. var listeners = this._progressiveReadListeners;
  19782. for (var i = 0, n = listeners.length; i < n; ++i) {
  19783. listeners[i](chunk);
  19784. }
  19785. }.bind(this));
  19786. },
  19787. transportReady: function PDFDataRangeTransport_transportReady() {
  19788. this._readyCapability.resolve();
  19789. },
  19790. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  19791. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  19792. },
  19793. abort: function PDFDataRangeTransport_abort() {
  19794. }
  19795. };
  19796. return PDFDataRangeTransport;
  19797. }();
  19798. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  19799. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  19800. this.pdfInfo = pdfInfo;
  19801. this.transport = transport;
  19802. this.loadingTask = loadingTask;
  19803. }
  19804. PDFDocumentProxy.prototype = {
  19805. get numPages() {
  19806. return this.pdfInfo.numPages;
  19807. },
  19808. get fingerprint() {
  19809. return this.pdfInfo.fingerprint;
  19810. },
  19811. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  19812. return this.transport.getPage(pageNumber);
  19813. },
  19814. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  19815. return this.transport.getPageIndex(ref);
  19816. },
  19817. getDestinations: function PDFDocumentProxy_getDestinations() {
  19818. return this.transport.getDestinations();
  19819. },
  19820. getDestination: function PDFDocumentProxy_getDestination(id) {
  19821. return this.transport.getDestination(id);
  19822. },
  19823. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  19824. return this.transport.getPageLabels();
  19825. },
  19826. getAttachments: function PDFDocumentProxy_getAttachments() {
  19827. return this.transport.getAttachments();
  19828. },
  19829. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  19830. return this.transport.getJavaScript();
  19831. },
  19832. getOutline: function PDFDocumentProxy_getOutline() {
  19833. return this.transport.getOutline();
  19834. },
  19835. getMetadata: function PDFDocumentProxy_getMetadata() {
  19836. return this.transport.getMetadata();
  19837. },
  19838. getData: function PDFDocumentProxy_getData() {
  19839. return this.transport.getData();
  19840. },
  19841. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  19842. return this.transport.downloadInfoCapability.promise;
  19843. },
  19844. getStats: function PDFDocumentProxy_getStats() {
  19845. return this.transport.getStats();
  19846. },
  19847. cleanup: function PDFDocumentProxy_cleanup() {
  19848. this.transport.startCleanup();
  19849. },
  19850. destroy: function PDFDocumentProxy_destroy() {
  19851. return this.loadingTask.destroy();
  19852. }
  19853. };
  19854. return PDFDocumentProxy;
  19855. }();
  19856. var PDFPageProxy = function PDFPageProxyClosure() {
  19857. function PDFPageProxy(pageIndex, pageInfo, transport) {
  19858. this.pageIndex = pageIndex;
  19859. this.pageInfo = pageInfo;
  19860. this.transport = transport;
  19861. this.stats = new StatTimer();
  19862. this.stats.enabled = getDefaultSetting('enableStats');
  19863. this.commonObjs = transport.commonObjs;
  19864. this.objs = new PDFObjects();
  19865. this.cleanupAfterRender = false;
  19866. this.pendingCleanup = false;
  19867. this.intentStates = Object.create(null);
  19868. this.destroyed = false;
  19869. }
  19870. PDFPageProxy.prototype = {
  19871. get pageNumber() {
  19872. return this.pageIndex + 1;
  19873. },
  19874. get rotate() {
  19875. return this.pageInfo.rotate;
  19876. },
  19877. get ref() {
  19878. return this.pageInfo.ref;
  19879. },
  19880. get userUnit() {
  19881. return this.pageInfo.userUnit;
  19882. },
  19883. get view() {
  19884. return this.pageInfo.view;
  19885. },
  19886. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  19887. if (arguments.length < 2) {
  19888. rotate = this.rotate;
  19889. }
  19890. return new PageViewport(this.view, scale, rotate, 0, 0);
  19891. },
  19892. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  19893. var intent = params && params.intent || null;
  19894. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  19895. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  19896. this.annotationsIntent = intent;
  19897. }
  19898. return this.annotationsPromise;
  19899. },
  19900. render: function PDFPageProxy_render(params) {
  19901. var stats = this.stats;
  19902. stats.time('Overall');
  19903. this.pendingCleanup = false;
  19904. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  19905. var renderInteractiveForms = params.renderInteractiveForms === true ? true : false;
  19906. var canvasFactory = params.canvasFactory || new DOMCanvasFactory();
  19907. if (!this.intentStates[renderingIntent]) {
  19908. this.intentStates[renderingIntent] = Object.create(null);
  19909. }
  19910. var intentState = this.intentStates[renderingIntent];
  19911. if (!intentState.displayReadyCapability) {
  19912. intentState.receivingOperatorList = true;
  19913. intentState.displayReadyCapability = createPromiseCapability();
  19914. intentState.operatorList = {
  19915. fnArray: [],
  19916. argsArray: [],
  19917. lastChunk: false
  19918. };
  19919. this.stats.time('Page Request');
  19920. this.transport.messageHandler.send('RenderPageRequest', {
  19921. pageIndex: this.pageNumber - 1,
  19922. intent: renderingIntent,
  19923. renderInteractiveForms: renderInteractiveForms
  19924. });
  19925. }
  19926. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber, canvasFactory);
  19927. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  19928. if (!intentState.renderTasks) {
  19929. intentState.renderTasks = [];
  19930. }
  19931. intentState.renderTasks.push(internalRenderTask);
  19932. var renderTask = internalRenderTask.task;
  19933. if (params.continueCallback) {
  19934. deprecated('render is used with continueCallback parameter');
  19935. renderTask.onContinue = params.continueCallback;
  19936. }
  19937. var self = this;
  19938. intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) {
  19939. if (self.pendingCleanup) {
  19940. complete();
  19941. return;
  19942. }
  19943. stats.time('Rendering');
  19944. internalRenderTask.initializeGraphics(transparency);
  19945. internalRenderTask.operatorListChanged();
  19946. }, function pageDisplayReadPromiseError(reason) {
  19947. complete(reason);
  19948. });
  19949. function complete(error) {
  19950. var i = intentState.renderTasks.indexOf(internalRenderTask);
  19951. if (i >= 0) {
  19952. intentState.renderTasks.splice(i, 1);
  19953. }
  19954. if (self.cleanupAfterRender) {
  19955. self.pendingCleanup = true;
  19956. }
  19957. self._tryCleanup();
  19958. if (error) {
  19959. internalRenderTask.capability.reject(error);
  19960. } else {
  19961. internalRenderTask.capability.resolve();
  19962. }
  19963. stats.timeEnd('Rendering');
  19964. stats.timeEnd('Overall');
  19965. }
  19966. return renderTask;
  19967. },
  19968. getOperatorList: function PDFPageProxy_getOperatorList() {
  19969. function operatorListChanged() {
  19970. if (intentState.operatorList.lastChunk) {
  19971. intentState.opListReadCapability.resolve(intentState.operatorList);
  19972. var i = intentState.renderTasks.indexOf(opListTask);
  19973. if (i >= 0) {
  19974. intentState.renderTasks.splice(i, 1);
  19975. }
  19976. }
  19977. }
  19978. var renderingIntent = 'oplist';
  19979. if (!this.intentStates[renderingIntent]) {
  19980. this.intentStates[renderingIntent] = Object.create(null);
  19981. }
  19982. var intentState = this.intentStates[renderingIntent];
  19983. var opListTask;
  19984. if (!intentState.opListReadCapability) {
  19985. opListTask = {};
  19986. opListTask.operatorListChanged = operatorListChanged;
  19987. intentState.receivingOperatorList = true;
  19988. intentState.opListReadCapability = createPromiseCapability();
  19989. intentState.renderTasks = [];
  19990. intentState.renderTasks.push(opListTask);
  19991. intentState.operatorList = {
  19992. fnArray: [],
  19993. argsArray: [],
  19994. lastChunk: false
  19995. };
  19996. this.transport.messageHandler.send('RenderPageRequest', {
  19997. pageIndex: this.pageIndex,
  19998. intent: renderingIntent
  19999. });
  20000. }
  20001. return intentState.opListReadCapability.promise;
  20002. },
  20003. getTextContent: function PDFPageProxy_getTextContent(params) {
  20004. return this.transport.messageHandler.sendWithPromise('GetTextContent', {
  20005. pageIndex: this.pageNumber - 1,
  20006. normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false,
  20007. combineTextItems: params && params.disableCombineTextItems === true ? false : true
  20008. });
  20009. },
  20010. _destroy: function PDFPageProxy_destroy() {
  20011. this.destroyed = true;
  20012. this.transport.pageCache[this.pageIndex] = null;
  20013. var waitOn = [];
  20014. Object.keys(this.intentStates).forEach(function (intent) {
  20015. if (intent === 'oplist') {
  20016. return;
  20017. }
  20018. var intentState = this.intentStates[intent];
  20019. intentState.renderTasks.forEach(function (renderTask) {
  20020. var renderCompleted = renderTask.capability.promise.catch(function () {
  20021. });
  20022. waitOn.push(renderCompleted);
  20023. renderTask.cancel();
  20024. });
  20025. }, this);
  20026. this.objs.clear();
  20027. this.annotationsPromise = null;
  20028. this.pendingCleanup = false;
  20029. return Promise.all(waitOn);
  20030. },
  20031. destroy: function () {
  20032. deprecated('page destroy method, use cleanup() instead');
  20033. this.cleanup();
  20034. },
  20035. cleanup: function PDFPageProxy_cleanup() {
  20036. this.pendingCleanup = true;
  20037. this._tryCleanup();
  20038. },
  20039. _tryCleanup: function PDFPageProxy_tryCleanup() {
  20040. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  20041. var intentState = this.intentStates[intent];
  20042. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  20043. }, this)) {
  20044. return;
  20045. }
  20046. Object.keys(this.intentStates).forEach(function (intent) {
  20047. delete this.intentStates[intent];
  20048. }, this);
  20049. this.objs.clear();
  20050. this.annotationsPromise = null;
  20051. this.pendingCleanup = false;
  20052. },
  20053. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  20054. var intentState = this.intentStates[intent];
  20055. if (intentState.displayReadyCapability) {
  20056. intentState.displayReadyCapability.resolve(transparency);
  20057. }
  20058. },
  20059. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  20060. var intentState = this.intentStates[intent];
  20061. var i, ii;
  20062. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  20063. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  20064. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  20065. }
  20066. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  20067. for (i = 0; i < intentState.renderTasks.length; i++) {
  20068. intentState.renderTasks[i].operatorListChanged();
  20069. }
  20070. if (operatorListChunk.lastChunk) {
  20071. intentState.receivingOperatorList = false;
  20072. this._tryCleanup();
  20073. }
  20074. }
  20075. };
  20076. return PDFPageProxy;
  20077. }();
  20078. var PDFWorker = function PDFWorkerClosure() {
  20079. var nextFakeWorkerId = 0;
  20080. function getWorkerSrc() {
  20081. if (typeof workerSrc !== 'undefined') {
  20082. return workerSrc;
  20083. }
  20084. if (getDefaultSetting('workerSrc')) {
  20085. return getDefaultSetting('workerSrc');
  20086. }
  20087. if (pdfjsFilePath) {
  20088. return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
  20089. }
  20090. error('No PDFJS.workerSrc specified');
  20091. }
  20092. var fakeWorkerFilesLoadedCapability;
  20093. function setupFakeWorkerGlobal() {
  20094. var WorkerMessageHandler;
  20095. if (fakeWorkerFilesLoadedCapability) {
  20096. return fakeWorkerFilesLoadedCapability.promise;
  20097. }
  20098. fakeWorkerFilesLoadedCapability = createPromiseCapability();
  20099. var pdfjsCoreWorker = __w_pdfjs_require__(22);
  20100. __w_pdfjs_require__(39);
  20101. WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
  20102. fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
  20103. return fakeWorkerFilesLoadedCapability.promise;
  20104. }
  20105. function FakeWorkerPort(defer) {
  20106. this._listeners = [];
  20107. this._defer = defer;
  20108. this._deferred = Promise.resolve(undefined);
  20109. }
  20110. FakeWorkerPort.prototype = {
  20111. postMessage: function (obj, transfers) {
  20112. function cloneValue(value) {
  20113. if (typeof value !== 'object' || value === null) {
  20114. return value;
  20115. }
  20116. if (cloned.has(value)) {
  20117. return cloned.get(value);
  20118. }
  20119. var result;
  20120. var buffer;
  20121. if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
  20122. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  20123. if (value === buffer) {
  20124. result = value;
  20125. } else if (transferable) {
  20126. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  20127. } else {
  20128. result = new value.constructor(value);
  20129. }
  20130. cloned.set(value, result);
  20131. return result;
  20132. }
  20133. result = isArray(value) ? [] : {};
  20134. cloned.set(value, result);
  20135. for (var i in value) {
  20136. var desc, p = value;
  20137. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  20138. p = Object.getPrototypeOf(p);
  20139. }
  20140. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  20141. continue;
  20142. }
  20143. result[i] = cloneValue(desc.value);
  20144. }
  20145. return result;
  20146. }
  20147. if (!this._defer) {
  20148. this._listeners.forEach(function (listener) {
  20149. listener.call(this, { data: obj });
  20150. }, this);
  20151. return;
  20152. }
  20153. var cloned = new WeakMap();
  20154. var e = { data: cloneValue(obj) };
  20155. this._deferred.then(function () {
  20156. this._listeners.forEach(function (listener) {
  20157. listener.call(this, e);
  20158. }, this);
  20159. }.bind(this));
  20160. },
  20161. addEventListener: function (name, listener) {
  20162. this._listeners.push(listener);
  20163. },
  20164. removeEventListener: function (name, listener) {
  20165. var i = this._listeners.indexOf(listener);
  20166. this._listeners.splice(i, 1);
  20167. },
  20168. terminate: function () {
  20169. this._listeners = [];
  20170. }
  20171. };
  20172. function createCDNWrapper(url) {
  20173. var wrapper = 'importScripts(\'' + url + '\');';
  20174. return URL.createObjectURL(new Blob([wrapper]));
  20175. }
  20176. function PDFWorker(name) {
  20177. this.name = name;
  20178. this.destroyed = false;
  20179. this._readyCapability = createPromiseCapability();
  20180. this._port = null;
  20181. this._webWorker = null;
  20182. this._messageHandler = null;
  20183. this._initialize();
  20184. }
  20185. PDFWorker.prototype = {
  20186. get promise() {
  20187. return this._readyCapability.promise;
  20188. },
  20189. get port() {
  20190. return this._port;
  20191. },
  20192. get messageHandler() {
  20193. return this._messageHandler;
  20194. },
  20195. _initialize: function PDFWorker_initialize() {
  20196. this._setupFakeWorker();
  20197. },
  20198. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  20199. if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
  20200. warn('Setting up fake worker.');
  20201. isWorkerDisabled = true;
  20202. }
  20203. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  20204. if (this.destroyed) {
  20205. this._readyCapability.reject(new Error('Worker was destroyed'));
  20206. return;
  20207. }
  20208. var isTypedArraysPresent = Uint8Array !== Float32Array;
  20209. var port = new FakeWorkerPort(isTypedArraysPresent);
  20210. this._port = port;
  20211. var id = 'fake' + nextFakeWorkerId++;
  20212. var workerHandler = new MessageHandler(id + '_worker', id, port);
  20213. WorkerMessageHandler.setup(workerHandler, port);
  20214. var messageHandler = new MessageHandler(id, id + '_worker', port);
  20215. this._messageHandler = messageHandler;
  20216. this._readyCapability.resolve();
  20217. }.bind(this));
  20218. },
  20219. destroy: function PDFWorker_destroy() {
  20220. this.destroyed = true;
  20221. if (this._webWorker) {
  20222. this._webWorker.terminate();
  20223. this._webWorker = null;
  20224. }
  20225. this._port = null;
  20226. if (this._messageHandler) {
  20227. this._messageHandler.destroy();
  20228. this._messageHandler = null;
  20229. }
  20230. }
  20231. };
  20232. return PDFWorker;
  20233. }();
  20234. var WorkerTransport = function WorkerTransportClosure() {
  20235. function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport, CMapReaderFactory) {
  20236. this.messageHandler = messageHandler;
  20237. this.loadingTask = loadingTask;
  20238. this.pdfDataRangeTransport = pdfDataRangeTransport;
  20239. this.commonObjs = new PDFObjects();
  20240. this.fontLoader = new FontLoader(loadingTask.docId);
  20241. this.CMapReaderFactory = new CMapReaderFactory({
  20242. baseUrl: getDefaultSetting('cMapUrl'),
  20243. isCompressed: getDefaultSetting('cMapPacked')
  20244. });
  20245. this.destroyed = false;
  20246. this.destroyCapability = null;
  20247. this._passwordCapability = null;
  20248. this.pageCache = [];
  20249. this.pagePromises = [];
  20250. this.downloadInfoCapability = createPromiseCapability();
  20251. this.setupMessageHandler();
  20252. }
  20253. WorkerTransport.prototype = {
  20254. destroy: function WorkerTransport_destroy() {
  20255. if (this.destroyCapability) {
  20256. return this.destroyCapability.promise;
  20257. }
  20258. this.destroyed = true;
  20259. this.destroyCapability = createPromiseCapability();
  20260. if (this._passwordCapability) {
  20261. this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
  20262. }
  20263. var waitOn = [];
  20264. this.pageCache.forEach(function (page) {
  20265. if (page) {
  20266. waitOn.push(page._destroy());
  20267. }
  20268. });
  20269. this.pageCache = [];
  20270. this.pagePromises = [];
  20271. var self = this;
  20272. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  20273. waitOn.push(terminated);
  20274. Promise.all(waitOn).then(function () {
  20275. self.fontLoader.clear();
  20276. if (self.pdfDataRangeTransport) {
  20277. self.pdfDataRangeTransport.abort();
  20278. self.pdfDataRangeTransport = null;
  20279. }
  20280. if (self.messageHandler) {
  20281. self.messageHandler.destroy();
  20282. self.messageHandler = null;
  20283. }
  20284. self.destroyCapability.resolve();
  20285. }, this.destroyCapability.reject);
  20286. return this.destroyCapability.promise;
  20287. },
  20288. setupMessageHandler: function WorkerTransport_setupMessageHandler() {
  20289. var messageHandler = this.messageHandler;
  20290. var loadingTask = this.loadingTask;
  20291. var pdfDataRangeTransport = this.pdfDataRangeTransport;
  20292. if (pdfDataRangeTransport) {
  20293. pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  20294. messageHandler.send('OnDataRange', {
  20295. begin: begin,
  20296. chunk: chunk
  20297. });
  20298. });
  20299. pdfDataRangeTransport.addProgressListener(function (loaded) {
  20300. messageHandler.send('OnDataProgress', { loaded: loaded });
  20301. });
  20302. pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  20303. messageHandler.send('OnDataRange', { chunk: chunk });
  20304. });
  20305. messageHandler.on('RequestDataRange', function transportDataRange(data) {
  20306. pdfDataRangeTransport.requestDataRange(data.begin, data.end);
  20307. }, this);
  20308. }
  20309. messageHandler.on('GetDoc', function transportDoc(data) {
  20310. var pdfInfo = data.pdfInfo;
  20311. this.numPages = data.pdfInfo.numPages;
  20312. var loadingTask = this.loadingTask;
  20313. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  20314. this.pdfDocument = pdfDocument;
  20315. loadingTask._capability.resolve(pdfDocument);
  20316. }, this);
  20317. messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
  20318. this._passwordCapability = createPromiseCapability();
  20319. if (loadingTask.onPassword) {
  20320. var updatePassword = function (password) {
  20321. this._passwordCapability.resolve({ password: password });
  20322. }.bind(this);
  20323. loadingTask.onPassword(updatePassword, exception.code);
  20324. } else {
  20325. this._passwordCapability.reject(new PasswordException(exception.message, exception.code));
  20326. }
  20327. return this._passwordCapability.promise;
  20328. }, this);
  20329. messageHandler.on('PasswordException', function transportPasswordException(exception) {
  20330. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  20331. }, this);
  20332. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  20333. this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
  20334. }, this);
  20335. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  20336. this.loadingTask._capability.reject(new MissingPDFException(exception.message));
  20337. }, this);
  20338. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  20339. this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status));
  20340. }, this);
  20341. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  20342. this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
  20343. }, this);
  20344. messageHandler.on('DataLoaded', function transportPage(data) {
  20345. this.downloadInfoCapability.resolve(data);
  20346. }, this);
  20347. messageHandler.on('PDFManagerReady', function transportPage(data) {
  20348. if (this.pdfDataRangeTransport) {
  20349. this.pdfDataRangeTransport.transportReady();
  20350. }
  20351. }, this);
  20352. messageHandler.on('StartRenderPage', function transportRender(data) {
  20353. if (this.destroyed) {
  20354. return;
  20355. }
  20356. var page = this.pageCache[data.pageIndex];
  20357. page.stats.timeEnd('Page Request');
  20358. page._startRenderPage(data.transparency, data.intent);
  20359. }, this);
  20360. messageHandler.on('RenderPageChunk', function transportRender(data) {
  20361. if (this.destroyed) {
  20362. return;
  20363. }
  20364. var page = this.pageCache[data.pageIndex];
  20365. page._renderPageChunk(data.operatorList, data.intent);
  20366. }, this);
  20367. messageHandler.on('commonobj', function transportObj(data) {
  20368. if (this.destroyed) {
  20369. return;
  20370. }
  20371. var id = data[0];
  20372. var type = data[1];
  20373. if (this.commonObjs.hasData(id)) {
  20374. return;
  20375. }
  20376. switch (type) {
  20377. case 'Font':
  20378. var exportedData = data[2];
  20379. if ('error' in exportedData) {
  20380. var exportedError = exportedData.error;
  20381. warn('Error during font loading: ' + exportedError);
  20382. this.commonObjs.resolve(id, exportedError);
  20383. break;
  20384. }
  20385. var fontRegistry = null;
  20386. if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
  20387. fontRegistry = {
  20388. registerFont: function (font, url) {
  20389. globalScope['FontInspector'].fontAdded(font, url);
  20390. }
  20391. };
  20392. }
  20393. var font = new FontFaceObject(exportedData, {
  20394. isEvalSuported: getDefaultSetting('isEvalSupported'),
  20395. disableFontFace: getDefaultSetting('disableFontFace'),
  20396. fontRegistry: fontRegistry
  20397. });
  20398. this.fontLoader.bind([font], function fontReady(fontObjs) {
  20399. this.commonObjs.resolve(id, font);
  20400. }.bind(this));
  20401. break;
  20402. case 'FontPath':
  20403. this.commonObjs.resolve(id, data[2]);
  20404. break;
  20405. default:
  20406. error('Got unknown common object type ' + type);
  20407. }
  20408. }, this);
  20409. messageHandler.on('obj', function transportObj(data) {
  20410. if (this.destroyed) {
  20411. return;
  20412. }
  20413. var id = data[0];
  20414. var pageIndex = data[1];
  20415. var type = data[2];
  20416. var pageProxy = this.pageCache[pageIndex];
  20417. var imageData;
  20418. if (pageProxy.objs.hasData(id)) {
  20419. return;
  20420. }
  20421. switch (type) {
  20422. case 'JpegStream':
  20423. imageData = data[3];
  20424. loadJpegStream(id, imageData, pageProxy.objs);
  20425. break;
  20426. case 'Image':
  20427. imageData = data[3];
  20428. pageProxy.objs.resolve(id, imageData);
  20429. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  20430. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  20431. pageProxy.cleanupAfterRender = true;
  20432. }
  20433. break;
  20434. default:
  20435. error('Got unknown object type ' + type);
  20436. }
  20437. }, this);
  20438. messageHandler.on('DocProgress', function transportDocProgress(data) {
  20439. if (this.destroyed) {
  20440. return;
  20441. }
  20442. var loadingTask = this.loadingTask;
  20443. if (loadingTask.onProgress) {
  20444. loadingTask.onProgress({
  20445. loaded: data.loaded,
  20446. total: data.total
  20447. });
  20448. }
  20449. }, this);
  20450. messageHandler.on('PageError', function transportError(data) {
  20451. if (this.destroyed) {
  20452. return;
  20453. }
  20454. var page = this.pageCache[data.pageNum - 1];
  20455. var intentState = page.intentStates[data.intent];
  20456. if (intentState.displayReadyCapability) {
  20457. intentState.displayReadyCapability.reject(data.error);
  20458. } else {
  20459. error(data.error);
  20460. }
  20461. if (intentState.operatorList) {
  20462. intentState.operatorList.lastChunk = true;
  20463. for (var i = 0; i < intentState.renderTasks.length; i++) {
  20464. intentState.renderTasks[i].operatorListChanged();
  20465. }
  20466. }
  20467. }, this);
  20468. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  20469. if (this.destroyed) {
  20470. return;
  20471. }
  20472. var featureId = data.featureId;
  20473. var loadingTask = this.loadingTask;
  20474. if (loadingTask.onUnsupportedFeature) {
  20475. loadingTask.onUnsupportedFeature(featureId);
  20476. }
  20477. _UnsupportedManager.notify(featureId);
  20478. }, this);
  20479. messageHandler.on('JpegDecode', function (data) {
  20480. if (this.destroyed) {
  20481. return Promise.reject(new Error('Worker was destroyed'));
  20482. }
  20483. if (typeof document === 'undefined') {
  20484. return Promise.reject(new Error('"document" is not defined.'));
  20485. }
  20486. var imageUrl = data[0];
  20487. var components = data[1];
  20488. if (components !== 3 && components !== 1) {
  20489. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  20490. }
  20491. return new Promise(function (resolve, reject) {
  20492. var img = new Image();
  20493. img.onload = function () {
  20494. var width = img.width;
  20495. var height = img.height;
  20496. var size = width * height;
  20497. var rgbaLength = size * 4;
  20498. var buf = new Uint8Array(size * components);
  20499. var tmpCanvas = document.createElement('canvas');
  20500. tmpCanvas.width = width;
  20501. tmpCanvas.height = height;
  20502. var tmpCtx = tmpCanvas.getContext('2d');
  20503. tmpCtx.drawImage(img, 0, 0);
  20504. var data = tmpCtx.getImageData(0, 0, width, height).data;
  20505. var i, j;
  20506. if (components === 3) {
  20507. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  20508. buf[j] = data[i];
  20509. buf[j + 1] = data[i + 1];
  20510. buf[j + 2] = data[i + 2];
  20511. }
  20512. } else if (components === 1) {
  20513. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  20514. buf[j] = data[i];
  20515. }
  20516. }
  20517. resolve({
  20518. data: buf,
  20519. width: width,
  20520. height: height
  20521. });
  20522. };
  20523. img.onerror = function () {
  20524. reject(new Error('JpegDecode failed to load image'));
  20525. };
  20526. img.src = imageUrl;
  20527. });
  20528. }, this);
  20529. messageHandler.on('FetchBuiltInCMap', function (data) {
  20530. if (this.destroyed) {
  20531. return Promise.reject(new Error('Worker was destroyed'));
  20532. }
  20533. return this.CMapReaderFactory.fetch({ name: data.name });
  20534. }, this);
  20535. },
  20536. getData: function WorkerTransport_getData() {
  20537. return this.messageHandler.sendWithPromise('GetData', null);
  20538. },
  20539. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  20540. if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  20541. return Promise.reject(new Error('Invalid page request'));
  20542. }
  20543. var pageIndex = pageNumber - 1;
  20544. if (pageIndex in this.pagePromises) {
  20545. return this.pagePromises[pageIndex];
  20546. }
  20547. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  20548. if (this.destroyed) {
  20549. throw new Error('Transport destroyed');
  20550. }
  20551. var page = new PDFPageProxy(pageIndex, pageInfo, this);
  20552. this.pageCache[pageIndex] = page;
  20553. return page;
  20554. }.bind(this));
  20555. this.pagePromises[pageIndex] = promise;
  20556. return promise;
  20557. },
  20558. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  20559. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  20560. return Promise.reject(new Error(reason));
  20561. });
  20562. },
  20563. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  20564. return this.messageHandler.sendWithPromise('GetAnnotations', {
  20565. pageIndex: pageIndex,
  20566. intent: intent
  20567. });
  20568. },
  20569. getDestinations: function WorkerTransport_getDestinations() {
  20570. return this.messageHandler.sendWithPromise('GetDestinations', null);
  20571. },
  20572. getDestination: function WorkerTransport_getDestination(id) {
  20573. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  20574. },
  20575. getPageLabels: function WorkerTransport_getPageLabels() {
  20576. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  20577. },
  20578. getAttachments: function WorkerTransport_getAttachments() {
  20579. return this.messageHandler.sendWithPromise('GetAttachments', null);
  20580. },
  20581. getJavaScript: function WorkerTransport_getJavaScript() {
  20582. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  20583. },
  20584. getOutline: function WorkerTransport_getOutline() {
  20585. return this.messageHandler.sendWithPromise('GetOutline', null);
  20586. },
  20587. getMetadata: function WorkerTransport_getMetadata() {
  20588. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  20589. return {
  20590. info: results[0],
  20591. metadata: results[1] ? new Metadata(results[1]) : null
  20592. };
  20593. });
  20594. },
  20595. getStats: function WorkerTransport_getStats() {
  20596. return this.messageHandler.sendWithPromise('GetStats', null);
  20597. },
  20598. startCleanup: function WorkerTransport_startCleanup() {
  20599. this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() {
  20600. for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
  20601. var page = this.pageCache[i];
  20602. if (page) {
  20603. page.cleanup();
  20604. }
  20605. }
  20606. this.commonObjs.clear();
  20607. this.fontLoader.clear();
  20608. }.bind(this));
  20609. }
  20610. };
  20611. return WorkerTransport;
  20612. }();
  20613. var PDFObjects = function PDFObjectsClosure() {
  20614. function PDFObjects() {
  20615. this.objs = Object.create(null);
  20616. }
  20617. PDFObjects.prototype = {
  20618. ensureObj: function PDFObjects_ensureObj(objId) {
  20619. if (this.objs[objId]) {
  20620. return this.objs[objId];
  20621. }
  20622. var obj = {
  20623. capability: createPromiseCapability(),
  20624. data: null,
  20625. resolved: false
  20626. };
  20627. this.objs[objId] = obj;
  20628. return obj;
  20629. },
  20630. get: function PDFObjects_get(objId, callback) {
  20631. if (callback) {
  20632. this.ensureObj(objId).capability.promise.then(callback);
  20633. return null;
  20634. }
  20635. var obj = this.objs[objId];
  20636. if (!obj || !obj.resolved) {
  20637. error('Requesting object that isn\'t resolved yet ' + objId);
  20638. }
  20639. return obj.data;
  20640. },
  20641. resolve: function PDFObjects_resolve(objId, data) {
  20642. var obj = this.ensureObj(objId);
  20643. obj.resolved = true;
  20644. obj.data = data;
  20645. obj.capability.resolve(data);
  20646. },
  20647. isResolved: function PDFObjects_isResolved(objId) {
  20648. var objs = this.objs;
  20649. if (!objs[objId]) {
  20650. return false;
  20651. }
  20652. return objs[objId].resolved;
  20653. },
  20654. hasData: function PDFObjects_hasData(objId) {
  20655. return this.isResolved(objId);
  20656. },
  20657. getData: function PDFObjects_getData(objId) {
  20658. var objs = this.objs;
  20659. if (!objs[objId] || !objs[objId].resolved) {
  20660. return null;
  20661. }
  20662. return objs[objId].data;
  20663. },
  20664. clear: function PDFObjects_clear() {
  20665. this.objs = Object.create(null);
  20666. }
  20667. };
  20668. return PDFObjects;
  20669. }();
  20670. var RenderTask = function RenderTaskClosure() {
  20671. function RenderTask(internalRenderTask) {
  20672. this._internalRenderTask = internalRenderTask;
  20673. this.onContinue = null;
  20674. }
  20675. RenderTask.prototype = {
  20676. get promise() {
  20677. return this._internalRenderTask.capability.promise;
  20678. },
  20679. cancel: function RenderTask_cancel() {
  20680. this._internalRenderTask.cancel();
  20681. },
  20682. then: function RenderTask_then(onFulfilled, onRejected) {
  20683. return this.promise.then.apply(this.promise, arguments);
  20684. }
  20685. };
  20686. return RenderTask;
  20687. }();
  20688. var InternalRenderTask = function InternalRenderTaskClosure() {
  20689. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber, canvasFactory) {
  20690. this.callback = callback;
  20691. this.params = params;
  20692. this.objs = objs;
  20693. this.commonObjs = commonObjs;
  20694. this.operatorListIdx = null;
  20695. this.operatorList = operatorList;
  20696. this.pageNumber = pageNumber;
  20697. this.canvasFactory = canvasFactory;
  20698. this.running = false;
  20699. this.graphicsReadyCallback = null;
  20700. this.graphicsReady = false;
  20701. this.useRequestAnimationFrame = false;
  20702. this.cancelled = false;
  20703. this.capability = createPromiseCapability();
  20704. this.task = new RenderTask(this);
  20705. this._continueBound = this._continue.bind(this);
  20706. this._scheduleNextBound = this._scheduleNext.bind(this);
  20707. this._nextBound = this._next.bind(this);
  20708. }
  20709. InternalRenderTask.prototype = {
  20710. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  20711. if (this.cancelled) {
  20712. return;
  20713. }
  20714. if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
  20715. this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
  20716. this.stepper.init(this.operatorList);
  20717. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  20718. }
  20719. var params = this.params;
  20720. this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, params.imageLayer);
  20721. this.gfx.beginDrawing(params.transform, params.viewport, transparency);
  20722. this.operatorListIdx = 0;
  20723. this.graphicsReady = true;
  20724. if (this.graphicsReadyCallback) {
  20725. this.graphicsReadyCallback();
  20726. }
  20727. },
  20728. cancel: function InternalRenderTask_cancel() {
  20729. this.running = false;
  20730. this.cancelled = true;
  20731. this.callback('cancelled');
  20732. },
  20733. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  20734. if (!this.graphicsReady) {
  20735. if (!this.graphicsReadyCallback) {
  20736. this.graphicsReadyCallback = this._continueBound;
  20737. }
  20738. return;
  20739. }
  20740. if (this.stepper) {
  20741. this.stepper.updateOperatorList(this.operatorList);
  20742. }
  20743. if (this.running) {
  20744. return;
  20745. }
  20746. this._continue();
  20747. },
  20748. _continue: function InternalRenderTask__continue() {
  20749. this.running = true;
  20750. if (this.cancelled) {
  20751. return;
  20752. }
  20753. if (this.task.onContinue) {
  20754. this.task.onContinue(this._scheduleNextBound);
  20755. } else {
  20756. this._scheduleNext();
  20757. }
  20758. },
  20759. _scheduleNext: function InternalRenderTask__scheduleNext() {
  20760. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  20761. window.requestAnimationFrame(this._nextBound);
  20762. } else {
  20763. Promise.resolve(undefined).then(this._nextBound);
  20764. }
  20765. },
  20766. _next: function InternalRenderTask__next() {
  20767. if (this.cancelled) {
  20768. return;
  20769. }
  20770. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  20771. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  20772. this.running = false;
  20773. if (this.operatorList.lastChunk) {
  20774. this.gfx.endDrawing();
  20775. this.callback();
  20776. }
  20777. }
  20778. }
  20779. };
  20780. return InternalRenderTask;
  20781. }();
  20782. var _UnsupportedManager = function UnsupportedManagerClosure() {
  20783. var listeners = [];
  20784. return {
  20785. listen: function (cb) {
  20786. deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  20787. listeners.push(cb);
  20788. },
  20789. notify: function (featureId) {
  20790. for (var i = 0, ii = listeners.length; i < ii; i++) {
  20791. listeners[i](featureId);
  20792. }
  20793. }
  20794. };
  20795. }();
  20796. exports.version = '1.7.314';
  20797. exports.build = '912c952d';
  20798. exports.getDocument = getDocument;
  20799. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  20800. exports.PDFWorker = PDFWorker;
  20801. exports.PDFDocumentProxy = PDFDocumentProxy;
  20802. exports.PDFPageProxy = PDFPageProxy;
  20803. exports._UnsupportedManager = _UnsupportedManager;
  20804. /***/ }),
  20805. /* 11 */
  20806. /***/ (function(module, exports, __w_pdfjs_require__) {
  20807. "use strict";
  20808. var sharedUtil = __w_pdfjs_require__(0);
  20809. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  20810. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  20811. var ImageKind = sharedUtil.ImageKind;
  20812. var OPS = sharedUtil.OPS;
  20813. var Util = sharedUtil.Util;
  20814. var isNum = sharedUtil.isNum;
  20815. var isArray = sharedUtil.isArray;
  20816. var warn = sharedUtil.warn;
  20817. var createObjectURL = sharedUtil.createObjectURL;
  20818. var SVG_DEFAULTS = {
  20819. fontStyle: 'normal',
  20820. fontWeight: 'normal',
  20821. fillColor: '#000000'
  20822. };
  20823. var convertImgDataToPng = function convertImgDataToPngClosure() {
  20824. var PNG_HEADER = new Uint8Array([
  20825. 0x89,
  20826. 0x50,
  20827. 0x4e,
  20828. 0x47,
  20829. 0x0d,
  20830. 0x0a,
  20831. 0x1a,
  20832. 0x0a
  20833. ]);
  20834. var CHUNK_WRAPPER_SIZE = 12;
  20835. var crcTable = new Int32Array(256);
  20836. for (var i = 0; i < 256; i++) {
  20837. var c = i;
  20838. for (var h = 0; h < 8; h++) {
  20839. if (c & 1) {
  20840. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  20841. } else {
  20842. c = c >> 1 & 0x7fffffff;
  20843. }
  20844. }
  20845. crcTable[i] = c;
  20846. }
  20847. function crc32(data, start, end) {
  20848. var crc = -1;
  20849. for (var i = start; i < end; i++) {
  20850. var a = (crc ^ data[i]) & 0xff;
  20851. var b = crcTable[a];
  20852. crc = crc >>> 8 ^ b;
  20853. }
  20854. return crc ^ -1;
  20855. }
  20856. function writePngChunk(type, body, data, offset) {
  20857. var p = offset;
  20858. var len = body.length;
  20859. data[p] = len >> 24 & 0xff;
  20860. data[p + 1] = len >> 16 & 0xff;
  20861. data[p + 2] = len >> 8 & 0xff;
  20862. data[p + 3] = len & 0xff;
  20863. p += 4;
  20864. data[p] = type.charCodeAt(0) & 0xff;
  20865. data[p + 1] = type.charCodeAt(1) & 0xff;
  20866. data[p + 2] = type.charCodeAt(2) & 0xff;
  20867. data[p + 3] = type.charCodeAt(3) & 0xff;
  20868. p += 4;
  20869. data.set(body, p);
  20870. p += body.length;
  20871. var crc = crc32(data, offset + 4, p);
  20872. data[p] = crc >> 24 & 0xff;
  20873. data[p + 1] = crc >> 16 & 0xff;
  20874. data[p + 2] = crc >> 8 & 0xff;
  20875. data[p + 3] = crc & 0xff;
  20876. }
  20877. function adler32(data, start, end) {
  20878. var a = 1;
  20879. var b = 0;
  20880. for (var i = start; i < end; ++i) {
  20881. a = (a + (data[i] & 0xff)) % 65521;
  20882. b = (b + a) % 65521;
  20883. }
  20884. return b << 16 | a;
  20885. }
  20886. function encode(imgData, kind, forceDataSchema) {
  20887. var width = imgData.width;
  20888. var height = imgData.height;
  20889. var bitDepth, colorType, lineSize;
  20890. var bytes = imgData.data;
  20891. switch (kind) {
  20892. case ImageKind.GRAYSCALE_1BPP:
  20893. colorType = 0;
  20894. bitDepth = 1;
  20895. lineSize = width + 7 >> 3;
  20896. break;
  20897. case ImageKind.RGB_24BPP:
  20898. colorType = 2;
  20899. bitDepth = 8;
  20900. lineSize = width * 3;
  20901. break;
  20902. case ImageKind.RGBA_32BPP:
  20903. colorType = 6;
  20904. bitDepth = 8;
  20905. lineSize = width * 4;
  20906. break;
  20907. default:
  20908. throw new Error('invalid format');
  20909. }
  20910. var literals = new Uint8Array((1 + lineSize) * height);
  20911. var offsetLiterals = 0, offsetBytes = 0;
  20912. var y, i;
  20913. for (y = 0; y < height; ++y) {
  20914. literals[offsetLiterals++] = 0;
  20915. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  20916. offsetBytes += lineSize;
  20917. offsetLiterals += lineSize;
  20918. }
  20919. if (kind === ImageKind.GRAYSCALE_1BPP) {
  20920. offsetLiterals = 0;
  20921. for (y = 0; y < height; y++) {
  20922. offsetLiterals++;
  20923. for (i = 0; i < lineSize; i++) {
  20924. literals[offsetLiterals++] ^= 0xFF;
  20925. }
  20926. }
  20927. }
  20928. var ihdr = new Uint8Array([
  20929. width >> 24 & 0xff,
  20930. width >> 16 & 0xff,
  20931. width >> 8 & 0xff,
  20932. width & 0xff,
  20933. height >> 24 & 0xff,
  20934. height >> 16 & 0xff,
  20935. height >> 8 & 0xff,
  20936. height & 0xff,
  20937. bitDepth,
  20938. colorType,
  20939. 0x00,
  20940. 0x00,
  20941. 0x00
  20942. ]);
  20943. var len = literals.length;
  20944. var maxBlockLength = 0xFFFF;
  20945. var deflateBlocks = Math.ceil(len / maxBlockLength);
  20946. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  20947. var pi = 0;
  20948. idat[pi++] = 0x78;
  20949. idat[pi++] = 0x9c;
  20950. var pos = 0;
  20951. while (len > maxBlockLength) {
  20952. idat[pi++] = 0x00;
  20953. idat[pi++] = 0xff;
  20954. idat[pi++] = 0xff;
  20955. idat[pi++] = 0x00;
  20956. idat[pi++] = 0x00;
  20957. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  20958. pi += maxBlockLength;
  20959. pos += maxBlockLength;
  20960. len -= maxBlockLength;
  20961. }
  20962. idat[pi++] = 0x01;
  20963. idat[pi++] = len & 0xff;
  20964. idat[pi++] = len >> 8 & 0xff;
  20965. idat[pi++] = ~len & 0xffff & 0xff;
  20966. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  20967. idat.set(literals.subarray(pos), pi);
  20968. pi += literals.length - pos;
  20969. var adler = adler32(literals, 0, literals.length);
  20970. idat[pi++] = adler >> 24 & 0xff;
  20971. idat[pi++] = adler >> 16 & 0xff;
  20972. idat[pi++] = adler >> 8 & 0xff;
  20973. idat[pi++] = adler & 0xff;
  20974. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  20975. var data = new Uint8Array(pngLength);
  20976. var offset = 0;
  20977. data.set(PNG_HEADER, offset);
  20978. offset += PNG_HEADER.length;
  20979. writePngChunk('IHDR', ihdr, data, offset);
  20980. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  20981. writePngChunk('IDATA', idat, data, offset);
  20982. offset += CHUNK_WRAPPER_SIZE + idat.length;
  20983. writePngChunk('IEND', new Uint8Array(0), data, offset);
  20984. return createObjectURL(data, 'image/png', forceDataSchema);
  20985. }
  20986. return function convertImgDataToPng(imgData, forceDataSchema) {
  20987. var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind;
  20988. return encode(imgData, kind, forceDataSchema);
  20989. };
  20990. }();
  20991. var SVGExtraState = function SVGExtraStateClosure() {
  20992. function SVGExtraState() {
  20993. this.fontSizeScale = 1;
  20994. this.fontWeight = SVG_DEFAULTS.fontWeight;
  20995. this.fontSize = 0;
  20996. this.textMatrix = IDENTITY_MATRIX;
  20997. this.fontMatrix = FONT_IDENTITY_MATRIX;
  20998. this.leading = 0;
  20999. this.x = 0;
  21000. this.y = 0;
  21001. this.lineX = 0;
  21002. this.lineY = 0;
  21003. this.charSpacing = 0;
  21004. this.wordSpacing = 0;
  21005. this.textHScale = 1;
  21006. this.textRise = 0;
  21007. this.fillColor = SVG_DEFAULTS.fillColor;
  21008. this.strokeColor = '#000000';
  21009. this.fillAlpha = 1;
  21010. this.strokeAlpha = 1;
  21011. this.lineWidth = 1;
  21012. this.lineJoin = '';
  21013. this.lineCap = '';
  21014. this.miterLimit = 0;
  21015. this.dashArray = [];
  21016. this.dashPhase = 0;
  21017. this.dependencies = [];
  21018. this.activeClipUrl = null;
  21019. this.clipGroup = null;
  21020. this.maskId = '';
  21021. }
  21022. SVGExtraState.prototype = {
  21023. clone: function SVGExtraState_clone() {
  21024. return Object.create(this);
  21025. },
  21026. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  21027. this.x = x;
  21028. this.y = y;
  21029. }
  21030. };
  21031. return SVGExtraState;
  21032. }();
  21033. var SVGGraphics = function SVGGraphicsClosure() {
  21034. function opListToTree(opList) {
  21035. var opTree = [];
  21036. var tmp = [];
  21037. var opListLen = opList.length;
  21038. for (var x = 0; x < opListLen; x++) {
  21039. if (opList[x].fn === 'save') {
  21040. opTree.push({
  21041. 'fnId': 92,
  21042. 'fn': 'group',
  21043. 'items': []
  21044. });
  21045. tmp.push(opTree);
  21046. opTree = opTree[opTree.length - 1].items;
  21047. continue;
  21048. }
  21049. if (opList[x].fn === 'restore') {
  21050. opTree = tmp.pop();
  21051. } else {
  21052. opTree.push(opList[x]);
  21053. }
  21054. }
  21055. return opTree;
  21056. }
  21057. function pf(value) {
  21058. if (value === (value | 0)) {
  21059. return value.toString();
  21060. }
  21061. var s = value.toFixed(10);
  21062. var i = s.length - 1;
  21063. if (s[i] !== '0') {
  21064. return s;
  21065. }
  21066. do {
  21067. i--;
  21068. } while (s[i] === '0');
  21069. return s.substr(0, s[i] === '.' ? i : i + 1);
  21070. }
  21071. function pm(m) {
  21072. if (m[4] === 0 && m[5] === 0) {
  21073. if (m[1] === 0 && m[2] === 0) {
  21074. if (m[0] === 1 && m[3] === 1) {
  21075. return '';
  21076. }
  21077. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  21078. }
  21079. if (m[0] === m[3] && m[1] === -m[2]) {
  21080. var a = Math.acos(m[0]) * 180 / Math.PI;
  21081. return 'rotate(' + pf(a) + ')';
  21082. }
  21083. } else {
  21084. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  21085. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  21086. }
  21087. }
  21088. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  21089. }
  21090. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  21091. this.current = new SVGExtraState();
  21092. this.transformMatrix = IDENTITY_MATRIX;
  21093. this.transformStack = [];
  21094. this.extraStack = [];
  21095. this.commonObjs = commonObjs;
  21096. this.objs = objs;
  21097. this.pendingEOFill = false;
  21098. this.embedFonts = false;
  21099. this.embeddedFonts = Object.create(null);
  21100. this.cssStyle = null;
  21101. this.forceDataSchema = !!forceDataSchema;
  21102. }
  21103. var NS = 'http://www.w3.org/2000/svg';
  21104. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  21105. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  21106. var LINE_CAP_STYLES = [
  21107. 'butt',
  21108. 'round',
  21109. 'square'
  21110. ];
  21111. var LINE_JOIN_STYLES = [
  21112. 'miter',
  21113. 'round',
  21114. 'bevel'
  21115. ];
  21116. var clipCount = 0;
  21117. var maskCount = 0;
  21118. SVGGraphics.prototype = {
  21119. save: function SVGGraphics_save() {
  21120. this.transformStack.push(this.transformMatrix);
  21121. var old = this.current;
  21122. this.extraStack.push(old);
  21123. this.current = old.clone();
  21124. },
  21125. restore: function SVGGraphics_restore() {
  21126. this.transformMatrix = this.transformStack.pop();
  21127. this.current = this.extraStack.pop();
  21128. this.tgrp = null;
  21129. },
  21130. group: function SVGGraphics_group(items) {
  21131. this.save();
  21132. this.executeOpTree(items);
  21133. this.restore();
  21134. },
  21135. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  21136. var fnArray = operatorList.fnArray;
  21137. var fnArrayLen = fnArray.length;
  21138. var argsArray = operatorList.argsArray;
  21139. var self = this;
  21140. for (var i = 0; i < fnArrayLen; i++) {
  21141. if (OPS.dependency === fnArray[i]) {
  21142. var deps = argsArray[i];
  21143. for (var n = 0, nn = deps.length; n < nn; n++) {
  21144. var obj = deps[n];
  21145. var common = obj.substring(0, 2) === 'g_';
  21146. var promise;
  21147. if (common) {
  21148. promise = new Promise(function (resolve) {
  21149. self.commonObjs.get(obj, resolve);
  21150. });
  21151. } else {
  21152. promise = new Promise(function (resolve) {
  21153. self.objs.get(obj, resolve);
  21154. });
  21155. }
  21156. this.current.dependencies.push(promise);
  21157. }
  21158. }
  21159. }
  21160. return Promise.all(this.current.dependencies);
  21161. },
  21162. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  21163. var transformMatrix = [
  21164. a,
  21165. b,
  21166. c,
  21167. d,
  21168. e,
  21169. f
  21170. ];
  21171. this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix);
  21172. this.tgrp = null;
  21173. },
  21174. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  21175. this.viewport = viewport;
  21176. var svgElement = this._initialize(viewport);
  21177. return this.loadDependencies(operatorList).then(function () {
  21178. this.transformMatrix = IDENTITY_MATRIX;
  21179. var opTree = this.convertOpList(operatorList);
  21180. this.executeOpTree(opTree);
  21181. return svgElement;
  21182. }.bind(this));
  21183. },
  21184. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  21185. var argsArray = operatorList.argsArray;
  21186. var fnArray = operatorList.fnArray;
  21187. var fnArrayLen = fnArray.length;
  21188. var REVOPS = [];
  21189. var opList = [];
  21190. for (var op in OPS) {
  21191. REVOPS[OPS[op]] = op;
  21192. }
  21193. for (var x = 0; x < fnArrayLen; x++) {
  21194. var fnId = fnArray[x];
  21195. opList.push({
  21196. 'fnId': fnId,
  21197. 'fn': REVOPS[fnId],
  21198. 'args': argsArray[x]
  21199. });
  21200. }
  21201. return opListToTree(opList);
  21202. },
  21203. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  21204. var opTreeLen = opTree.length;
  21205. for (var x = 0; x < opTreeLen; x++) {
  21206. var fn = opTree[x].fn;
  21207. var fnId = opTree[x].fnId;
  21208. var args = opTree[x].args;
  21209. switch (fnId | 0) {
  21210. case OPS.beginText:
  21211. this.beginText();
  21212. break;
  21213. case OPS.setLeading:
  21214. this.setLeading(args);
  21215. break;
  21216. case OPS.setLeadingMoveText:
  21217. this.setLeadingMoveText(args[0], args[1]);
  21218. break;
  21219. case OPS.setFont:
  21220. this.setFont(args);
  21221. break;
  21222. case OPS.showText:
  21223. this.showText(args[0]);
  21224. break;
  21225. case OPS.showSpacedText:
  21226. this.showText(args[0]);
  21227. break;
  21228. case OPS.endText:
  21229. this.endText();
  21230. break;
  21231. case OPS.moveText:
  21232. this.moveText(args[0], args[1]);
  21233. break;
  21234. case OPS.setCharSpacing:
  21235. this.setCharSpacing(args[0]);
  21236. break;
  21237. case OPS.setWordSpacing:
  21238. this.setWordSpacing(args[0]);
  21239. break;
  21240. case OPS.setHScale:
  21241. this.setHScale(args[0]);
  21242. break;
  21243. case OPS.setTextMatrix:
  21244. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  21245. break;
  21246. case OPS.setLineWidth:
  21247. this.setLineWidth(args[0]);
  21248. break;
  21249. case OPS.setLineJoin:
  21250. this.setLineJoin(args[0]);
  21251. break;
  21252. case OPS.setLineCap:
  21253. this.setLineCap(args[0]);
  21254. break;
  21255. case OPS.setMiterLimit:
  21256. this.setMiterLimit(args[0]);
  21257. break;
  21258. case OPS.setFillRGBColor:
  21259. this.setFillRGBColor(args[0], args[1], args[2]);
  21260. break;
  21261. case OPS.setStrokeRGBColor:
  21262. this.setStrokeRGBColor(args[0], args[1], args[2]);
  21263. break;
  21264. case OPS.setDash:
  21265. this.setDash(args[0], args[1]);
  21266. break;
  21267. case OPS.setGState:
  21268. this.setGState(args[0]);
  21269. break;
  21270. case OPS.fill:
  21271. this.fill();
  21272. break;
  21273. case OPS.eoFill:
  21274. this.eoFill();
  21275. break;
  21276. case OPS.stroke:
  21277. this.stroke();
  21278. break;
  21279. case OPS.fillStroke:
  21280. this.fillStroke();
  21281. break;
  21282. case OPS.eoFillStroke:
  21283. this.eoFillStroke();
  21284. break;
  21285. case OPS.clip:
  21286. this.clip('nonzero');
  21287. break;
  21288. case OPS.eoClip:
  21289. this.clip('evenodd');
  21290. break;
  21291. case OPS.paintSolidColorImageMask:
  21292. this.paintSolidColorImageMask();
  21293. break;
  21294. case OPS.paintJpegXObject:
  21295. this.paintJpegXObject(args[0], args[1], args[2]);
  21296. break;
  21297. case OPS.paintImageXObject:
  21298. this.paintImageXObject(args[0]);
  21299. break;
  21300. case OPS.paintInlineImageXObject:
  21301. this.paintInlineImageXObject(args[0]);
  21302. break;
  21303. case OPS.paintImageMaskXObject:
  21304. this.paintImageMaskXObject(args[0]);
  21305. break;
  21306. case OPS.paintFormXObjectBegin:
  21307. this.paintFormXObjectBegin(args[0], args[1]);
  21308. break;
  21309. case OPS.paintFormXObjectEnd:
  21310. this.paintFormXObjectEnd();
  21311. break;
  21312. case OPS.closePath:
  21313. this.closePath();
  21314. break;
  21315. case OPS.closeStroke:
  21316. this.closeStroke();
  21317. break;
  21318. case OPS.closeFillStroke:
  21319. this.closeFillStroke();
  21320. break;
  21321. case OPS.nextLine:
  21322. this.nextLine();
  21323. break;
  21324. case OPS.transform:
  21325. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  21326. break;
  21327. case OPS.constructPath:
  21328. this.constructPath(args[0], args[1]);
  21329. break;
  21330. case OPS.endPath:
  21331. this.endPath();
  21332. break;
  21333. case 92:
  21334. this.group(opTree[x].items);
  21335. break;
  21336. default:
  21337. warn('Unimplemented operator ' + fn);
  21338. break;
  21339. }
  21340. }
  21341. },
  21342. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  21343. this.current.wordSpacing = wordSpacing;
  21344. },
  21345. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  21346. this.current.charSpacing = charSpacing;
  21347. },
  21348. nextLine: function SVGGraphics_nextLine() {
  21349. this.moveText(0, this.current.leading);
  21350. },
  21351. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  21352. var current = this.current;
  21353. this.current.textMatrix = this.current.lineMatrix = [
  21354. a,
  21355. b,
  21356. c,
  21357. d,
  21358. e,
  21359. f
  21360. ];
  21361. this.current.x = this.current.lineX = 0;
  21362. this.current.y = this.current.lineY = 0;
  21363. current.xcoords = [];
  21364. current.tspan = document.createElementNS(NS, 'svg:tspan');
  21365. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  21366. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  21367. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21368. current.txtElement = document.createElementNS(NS, 'svg:text');
  21369. current.txtElement.appendChild(current.tspan);
  21370. },
  21371. beginText: function SVGGraphics_beginText() {
  21372. this.current.x = this.current.lineX = 0;
  21373. this.current.y = this.current.lineY = 0;
  21374. this.current.textMatrix = IDENTITY_MATRIX;
  21375. this.current.lineMatrix = IDENTITY_MATRIX;
  21376. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  21377. this.current.txtElement = document.createElementNS(NS, 'svg:text');
  21378. this.current.txtgrp = document.createElementNS(NS, 'svg:g');
  21379. this.current.xcoords = [];
  21380. },
  21381. moveText: function SVGGraphics_moveText(x, y) {
  21382. var current = this.current;
  21383. this.current.x = this.current.lineX += x;
  21384. this.current.y = this.current.lineY += y;
  21385. current.xcoords = [];
  21386. current.tspan = document.createElementNS(NS, 'svg:tspan');
  21387. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  21388. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  21389. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21390. },
  21391. showText: function SVGGraphics_showText(glyphs) {
  21392. var current = this.current;
  21393. var font = current.font;
  21394. var fontSize = current.fontSize;
  21395. if (fontSize === 0) {
  21396. return;
  21397. }
  21398. var charSpacing = current.charSpacing;
  21399. var wordSpacing = current.wordSpacing;
  21400. var fontDirection = current.fontDirection;
  21401. var textHScale = current.textHScale * fontDirection;
  21402. var glyphsLength = glyphs.length;
  21403. var vertical = font.vertical;
  21404. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  21405. var x = 0, i;
  21406. for (i = 0; i < glyphsLength; ++i) {
  21407. var glyph = glyphs[i];
  21408. if (glyph === null) {
  21409. x += fontDirection * wordSpacing;
  21410. continue;
  21411. } else if (isNum(glyph)) {
  21412. x += -glyph * fontSize * 0.001;
  21413. continue;
  21414. }
  21415. current.xcoords.push(current.x + x * textHScale);
  21416. var width = glyph.width;
  21417. var character = glyph.fontChar;
  21418. var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
  21419. x += charWidth;
  21420. current.tspan.textContent += character;
  21421. }
  21422. if (vertical) {
  21423. current.y -= x * textHScale;
  21424. } else {
  21425. current.x += x * textHScale;
  21426. }
  21427. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  21428. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21429. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  21430. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  21431. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  21432. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  21433. }
  21434. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  21435. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  21436. }
  21437. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  21438. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  21439. }
  21440. current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)');
  21441. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  21442. current.txtElement.appendChild(current.tspan);
  21443. current.txtgrp.appendChild(current.txtElement);
  21444. this._ensureTransformGroup().appendChild(current.txtElement);
  21445. },
  21446. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  21447. this.setLeading(-y);
  21448. this.moveText(x, y);
  21449. },
  21450. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  21451. if (!this.cssStyle) {
  21452. this.cssStyle = document.createElementNS(NS, 'svg:style');
  21453. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  21454. this.defs.appendChild(this.cssStyle);
  21455. }
  21456. var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  21457. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  21458. },
  21459. setFont: function SVGGraphics_setFont(details) {
  21460. var current = this.current;
  21461. var fontObj = this.commonObjs.get(details[0]);
  21462. var size = details[1];
  21463. this.current.font = fontObj;
  21464. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  21465. this.addFontStyle(fontObj);
  21466. this.embeddedFonts[fontObj.loadedName] = fontObj;
  21467. }
  21468. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  21469. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  21470. var italic = fontObj.italic ? 'italic' : 'normal';
  21471. if (size < 0) {
  21472. size = -size;
  21473. current.fontDirection = -1;
  21474. } else {
  21475. current.fontDirection = 1;
  21476. }
  21477. current.fontSize = size;
  21478. current.fontFamily = fontObj.loadedName;
  21479. current.fontWeight = bold;
  21480. current.fontStyle = italic;
  21481. current.tspan = document.createElementNS(NS, 'svg:tspan');
  21482. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  21483. current.xcoords = [];
  21484. },
  21485. endText: function SVGGraphics_endText() {
  21486. },
  21487. setLineWidth: function SVGGraphics_setLineWidth(width) {
  21488. this.current.lineWidth = width;
  21489. },
  21490. setLineCap: function SVGGraphics_setLineCap(style) {
  21491. this.current.lineCap = LINE_CAP_STYLES[style];
  21492. },
  21493. setLineJoin: function SVGGraphics_setLineJoin(style) {
  21494. this.current.lineJoin = LINE_JOIN_STYLES[style];
  21495. },
  21496. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  21497. this.current.miterLimit = limit;
  21498. },
  21499. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  21500. var color = Util.makeCssRgb(r, g, b);
  21501. this.current.strokeColor = color;
  21502. },
  21503. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  21504. var color = Util.makeCssRgb(r, g, b);
  21505. this.current.fillColor = color;
  21506. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  21507. this.current.xcoords = [];
  21508. },
  21509. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  21510. this.current.dashArray = dashArray;
  21511. this.current.dashPhase = dashPhase;
  21512. },
  21513. constructPath: function SVGGraphics_constructPath(ops, args) {
  21514. var current = this.current;
  21515. var x = current.x, y = current.y;
  21516. current.path = document.createElementNS(NS, 'svg:path');
  21517. var d = [];
  21518. var opLength = ops.length;
  21519. for (var i = 0, j = 0; i < opLength; i++) {
  21520. switch (ops[i] | 0) {
  21521. case OPS.rectangle:
  21522. x = args[j++];
  21523. y = args[j++];
  21524. var width = args[j++];
  21525. var height = args[j++];
  21526. var xw = x + width;
  21527. var yh = y + height;
  21528. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  21529. break;
  21530. case OPS.moveTo:
  21531. x = args[j++];
  21532. y = args[j++];
  21533. d.push('M', pf(x), pf(y));
  21534. break;
  21535. case OPS.lineTo:
  21536. x = args[j++];
  21537. y = args[j++];
  21538. d.push('L', pf(x), pf(y));
  21539. break;
  21540. case OPS.curveTo:
  21541. x = args[j + 4];
  21542. y = args[j + 5];
  21543. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  21544. j += 6;
  21545. break;
  21546. case OPS.curveTo2:
  21547. x = args[j + 2];
  21548. y = args[j + 3];
  21549. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  21550. j += 4;
  21551. break;
  21552. case OPS.curveTo3:
  21553. x = args[j + 2];
  21554. y = args[j + 3];
  21555. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  21556. j += 4;
  21557. break;
  21558. case OPS.closePath:
  21559. d.push('Z');
  21560. break;
  21561. }
  21562. }
  21563. current.path.setAttributeNS(null, 'd', d.join(' '));
  21564. current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  21565. current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  21566. current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  21567. current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  21568. current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  21569. current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  21570. current.path.setAttributeNS(null, 'fill', 'none');
  21571. this._ensureTransformGroup().appendChild(current.path);
  21572. current.element = current.path;
  21573. current.setCurrentPoint(x, y);
  21574. },
  21575. endPath: function SVGGraphics_endPath() {
  21576. },
  21577. clip: function SVGGraphics_clip(type) {
  21578. var current = this.current;
  21579. var clipId = 'clippath' + clipCount;
  21580. clipCount++;
  21581. var clipPath = document.createElementNS(NS, 'svg:clipPath');
  21582. clipPath.setAttributeNS(null, 'id', clipId);
  21583. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  21584. var clipElement = current.element.cloneNode();
  21585. if (type === 'evenodd') {
  21586. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  21587. } else {
  21588. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  21589. }
  21590. clipPath.appendChild(clipElement);
  21591. this.defs.appendChild(clipPath);
  21592. if (current.activeClipUrl) {
  21593. current.clipGroup = null;
  21594. this.extraStack.forEach(function (prev) {
  21595. prev.clipGroup = null;
  21596. });
  21597. }
  21598. current.activeClipUrl = 'url(#' + clipId + ')';
  21599. this.tgrp = null;
  21600. },
  21601. closePath: function SVGGraphics_closePath() {
  21602. var current = this.current;
  21603. var d = current.path.getAttributeNS(null, 'd');
  21604. d += 'Z';
  21605. current.path.setAttributeNS(null, 'd', d);
  21606. },
  21607. setLeading: function SVGGraphics_setLeading(leading) {
  21608. this.current.leading = -leading;
  21609. },
  21610. setTextRise: function SVGGraphics_setTextRise(textRise) {
  21611. this.current.textRise = textRise;
  21612. },
  21613. setHScale: function SVGGraphics_setHScale(scale) {
  21614. this.current.textHScale = scale / 100;
  21615. },
  21616. setGState: function SVGGraphics_setGState(states) {
  21617. for (var i = 0, ii = states.length; i < ii; i++) {
  21618. var state = states[i];
  21619. var key = state[0];
  21620. var value = state[1];
  21621. switch (key) {
  21622. case 'LW':
  21623. this.setLineWidth(value);
  21624. break;
  21625. case 'LC':
  21626. this.setLineCap(value);
  21627. break;
  21628. case 'LJ':
  21629. this.setLineJoin(value);
  21630. break;
  21631. case 'ML':
  21632. this.setMiterLimit(value);
  21633. break;
  21634. case 'D':
  21635. this.setDash(value[0], value[1]);
  21636. break;
  21637. case 'Font':
  21638. this.setFont(value);
  21639. break;
  21640. default:
  21641. warn('Unimplemented graphic state ' + key);
  21642. break;
  21643. }
  21644. }
  21645. },
  21646. fill: function SVGGraphics_fill() {
  21647. var current = this.current;
  21648. current.element.setAttributeNS(null, 'fill', current.fillColor);
  21649. },
  21650. stroke: function SVGGraphics_stroke() {
  21651. var current = this.current;
  21652. current.element.setAttributeNS(null, 'stroke', current.strokeColor);
  21653. current.element.setAttributeNS(null, 'fill', 'none');
  21654. },
  21655. eoFill: function SVGGraphics_eoFill() {
  21656. var current = this.current;
  21657. current.element.setAttributeNS(null, 'fill', current.fillColor);
  21658. current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  21659. },
  21660. fillStroke: function SVGGraphics_fillStroke() {
  21661. this.stroke();
  21662. this.fill();
  21663. },
  21664. eoFillStroke: function SVGGraphics_eoFillStroke() {
  21665. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  21666. this.fillStroke();
  21667. },
  21668. closeStroke: function SVGGraphics_closeStroke() {
  21669. this.closePath();
  21670. this.stroke();
  21671. },
  21672. closeFillStroke: function SVGGraphics_closeFillStroke() {
  21673. this.closePath();
  21674. this.fillStroke();
  21675. },
  21676. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  21677. var current = this.current;
  21678. var rect = document.createElementNS(NS, 'svg:rect');
  21679. rect.setAttributeNS(null, 'x', '0');
  21680. rect.setAttributeNS(null, 'y', '0');
  21681. rect.setAttributeNS(null, 'width', '1px');
  21682. rect.setAttributeNS(null, 'height', '1px');
  21683. rect.setAttributeNS(null, 'fill', current.fillColor);
  21684. this._ensureTransformGroup().appendChild(rect);
  21685. },
  21686. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  21687. var imgObj = this.objs.get(objId);
  21688. var imgEl = document.createElementNS(NS, 'svg:image');
  21689. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  21690. imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
  21691. imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
  21692. imgEl.setAttributeNS(null, 'x', '0');
  21693. imgEl.setAttributeNS(null, 'y', pf(-h));
  21694. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  21695. this._ensureTransformGroup().appendChild(imgEl);
  21696. },
  21697. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  21698. var imgData = this.objs.get(objId);
  21699. if (!imgData) {
  21700. warn('Dependent image isn\'t ready yet');
  21701. return;
  21702. }
  21703. this.paintInlineImageXObject(imgData);
  21704. },
  21705. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  21706. var width = imgData.width;
  21707. var height = imgData.height;
  21708. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
  21709. var cliprect = document.createElementNS(NS, 'svg:rect');
  21710. cliprect.setAttributeNS(null, 'x', '0');
  21711. cliprect.setAttributeNS(null, 'y', '0');
  21712. cliprect.setAttributeNS(null, 'width', pf(width));
  21713. cliprect.setAttributeNS(null, 'height', pf(height));
  21714. this.current.element = cliprect;
  21715. this.clip('nonzero');
  21716. var imgEl = document.createElementNS(NS, 'svg:image');
  21717. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  21718. imgEl.setAttributeNS(null, 'x', '0');
  21719. imgEl.setAttributeNS(null, 'y', pf(-height));
  21720. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  21721. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  21722. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  21723. if (mask) {
  21724. mask.appendChild(imgEl);
  21725. } else {
  21726. this._ensureTransformGroup().appendChild(imgEl);
  21727. }
  21728. },
  21729. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  21730. var current = this.current;
  21731. var width = imgData.width;
  21732. var height = imgData.height;
  21733. var fillColor = current.fillColor;
  21734. current.maskId = 'mask' + maskCount++;
  21735. var mask = document.createElementNS(NS, 'svg:mask');
  21736. mask.setAttributeNS(null, 'id', current.maskId);
  21737. var rect = document.createElementNS(NS, 'svg:rect');
  21738. rect.setAttributeNS(null, 'x', '0');
  21739. rect.setAttributeNS(null, 'y', '0');
  21740. rect.setAttributeNS(null, 'width', pf(width));
  21741. rect.setAttributeNS(null, 'height', pf(height));
  21742. rect.setAttributeNS(null, 'fill', fillColor);
  21743. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  21744. this.defs.appendChild(mask);
  21745. this._ensureTransformGroup().appendChild(rect);
  21746. this.paintInlineImageXObject(imgData, mask);
  21747. },
  21748. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  21749. if (isArray(matrix) && matrix.length === 6) {
  21750. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  21751. }
  21752. if (isArray(bbox) && bbox.length === 4) {
  21753. var width = bbox[2] - bbox[0];
  21754. var height = bbox[3] - bbox[1];
  21755. var cliprect = document.createElementNS(NS, 'svg:rect');
  21756. cliprect.setAttributeNS(null, 'x', bbox[0]);
  21757. cliprect.setAttributeNS(null, 'y', bbox[1]);
  21758. cliprect.setAttributeNS(null, 'width', pf(width));
  21759. cliprect.setAttributeNS(null, 'height', pf(height));
  21760. this.current.element = cliprect;
  21761. this.clip('nonzero');
  21762. this.endPath();
  21763. }
  21764. },
  21765. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {
  21766. },
  21767. _initialize: function SVGGraphics_initialize(viewport) {
  21768. var svg = document.createElementNS(NS, 'svg:svg');
  21769. svg.setAttributeNS(null, 'version', '1.1');
  21770. svg.setAttributeNS(null, 'width', viewport.width + 'px');
  21771. svg.setAttributeNS(null, 'height', viewport.height + 'px');
  21772. svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
  21773. svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
  21774. var definitions = document.createElementNS(NS, 'svg:defs');
  21775. svg.appendChild(definitions);
  21776. this.defs = definitions;
  21777. var rootGroup = document.createElementNS(NS, 'svg:g');
  21778. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  21779. svg.appendChild(rootGroup);
  21780. this.svg = rootGroup;
  21781. return svg;
  21782. },
  21783. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  21784. if (!this.current.clipGroup) {
  21785. var clipGroup = document.createElementNS(NS, 'svg:g');
  21786. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  21787. this.svg.appendChild(clipGroup);
  21788. this.current.clipGroup = clipGroup;
  21789. }
  21790. return this.current.clipGroup;
  21791. },
  21792. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  21793. if (!this.tgrp) {
  21794. this.tgrp = document.createElementNS(NS, 'svg:g');
  21795. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  21796. if (this.current.activeClipUrl) {
  21797. this._ensureClipGroup().appendChild(this.tgrp);
  21798. } else {
  21799. this.svg.appendChild(this.tgrp);
  21800. }
  21801. }
  21802. return this.tgrp;
  21803. }
  21804. };
  21805. return SVGGraphics;
  21806. }();
  21807. exports.SVGGraphics = SVGGraphics;
  21808. /***/ }),
  21809. /* 12 */
  21810. /***/ (function(module, exports, __w_pdfjs_require__) {
  21811. "use strict";
  21812. var sharedUtil = __w_pdfjs_require__(0);
  21813. var displayDOMUtils = __w_pdfjs_require__(3);
  21814. var Util = sharedUtil.Util;
  21815. var createPromiseCapability = sharedUtil.createPromiseCapability;
  21816. var CustomStyle = displayDOMUtils.CustomStyle;
  21817. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  21818. var renderTextLayer = function renderTextLayerClosure() {
  21819. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  21820. var NonWhitespaceRegexp = /\S/;
  21821. function isAllWhitespace(str) {
  21822. return !NonWhitespaceRegexp.test(str);
  21823. }
  21824. var styleBuf = [
  21825. 'left: ',
  21826. 0,
  21827. 'px; top: ',
  21828. 0,
  21829. 'px; font-size: ',
  21830. 0,
  21831. 'px; font-family: ',
  21832. '',
  21833. ';'
  21834. ];
  21835. function appendText(task, geom, styles) {
  21836. var textDiv = document.createElement('div');
  21837. var textDivProperties = {
  21838. style: null,
  21839. angle: 0,
  21840. canvasWidth: 0,
  21841. isWhitespace: false,
  21842. originalTransform: null,
  21843. paddingBottom: 0,
  21844. paddingLeft: 0,
  21845. paddingRight: 0,
  21846. paddingTop: 0,
  21847. scale: 1
  21848. };
  21849. task._textDivs.push(textDiv);
  21850. if (isAllWhitespace(geom.str)) {
  21851. textDivProperties.isWhitespace = true;
  21852. task._textDivProperties.set(textDiv, textDivProperties);
  21853. return;
  21854. }
  21855. var tx = Util.transform(task._viewport.transform, geom.transform);
  21856. var angle = Math.atan2(tx[1], tx[0]);
  21857. var style = styles[geom.fontName];
  21858. if (style.vertical) {
  21859. angle += Math.PI / 2;
  21860. }
  21861. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  21862. var fontAscent = fontHeight;
  21863. if (style.ascent) {
  21864. fontAscent = style.ascent * fontAscent;
  21865. } else if (style.descent) {
  21866. fontAscent = (1 + style.descent) * fontAscent;
  21867. }
  21868. var left;
  21869. var top;
  21870. if (angle === 0) {
  21871. left = tx[4];
  21872. top = tx[5] - fontAscent;
  21873. } else {
  21874. left = tx[4] + fontAscent * Math.sin(angle);
  21875. top = tx[5] - fontAscent * Math.cos(angle);
  21876. }
  21877. styleBuf[1] = left;
  21878. styleBuf[3] = top;
  21879. styleBuf[5] = fontHeight;
  21880. styleBuf[7] = style.fontFamily;
  21881. textDivProperties.style = styleBuf.join('');
  21882. textDiv.setAttribute('style', textDivProperties.style);
  21883. textDiv.textContent = geom.str;
  21884. if (getDefaultSetting('pdfBug')) {
  21885. textDiv.dataset.fontName = geom.fontName;
  21886. }
  21887. if (angle !== 0) {
  21888. textDivProperties.angle = angle * (180 / Math.PI);
  21889. }
  21890. if (geom.str.length > 1) {
  21891. if (style.vertical) {
  21892. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  21893. } else {
  21894. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  21895. }
  21896. }
  21897. task._textDivProperties.set(textDiv, textDivProperties);
  21898. if (task._enhanceTextSelection) {
  21899. var angleCos = 1, angleSin = 0;
  21900. if (angle !== 0) {
  21901. angleCos = Math.cos(angle);
  21902. angleSin = Math.sin(angle);
  21903. }
  21904. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  21905. var divHeight = fontHeight;
  21906. var m, b;
  21907. if (angle !== 0) {
  21908. m = [
  21909. angleCos,
  21910. angleSin,
  21911. -angleSin,
  21912. angleCos,
  21913. left,
  21914. top
  21915. ];
  21916. b = Util.getAxialAlignedBoundingBox([
  21917. 0,
  21918. 0,
  21919. divWidth,
  21920. divHeight
  21921. ], m);
  21922. } else {
  21923. b = [
  21924. left,
  21925. top,
  21926. left + divWidth,
  21927. top + divHeight
  21928. ];
  21929. }
  21930. task._bounds.push({
  21931. left: b[0],
  21932. top: b[1],
  21933. right: b[2],
  21934. bottom: b[3],
  21935. div: textDiv,
  21936. size: [
  21937. divWidth,
  21938. divHeight
  21939. ],
  21940. m: m
  21941. });
  21942. }
  21943. }
  21944. function render(task) {
  21945. if (task._canceled) {
  21946. return;
  21947. }
  21948. var textLayerFrag = task._container;
  21949. var textDivs = task._textDivs;
  21950. var capability = task._capability;
  21951. var textDivsLength = textDivs.length;
  21952. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  21953. task._renderingDone = true;
  21954. capability.resolve();
  21955. return;
  21956. }
  21957. var canvas = document.createElement('canvas');
  21958. var ctx = canvas.getContext('2d', { alpha: false });
  21959. var lastFontSize;
  21960. var lastFontFamily;
  21961. for (var i = 0; i < textDivsLength; i++) {
  21962. var textDiv = textDivs[i];
  21963. var textDivProperties = task._textDivProperties.get(textDiv);
  21964. if (textDivProperties.isWhitespace) {
  21965. continue;
  21966. }
  21967. var fontSize = textDiv.style.fontSize;
  21968. var fontFamily = textDiv.style.fontFamily;
  21969. if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
  21970. ctx.font = fontSize + ' ' + fontFamily;
  21971. lastFontSize = fontSize;
  21972. lastFontFamily = fontFamily;
  21973. }
  21974. var width = ctx.measureText(textDiv.textContent).width;
  21975. textLayerFrag.appendChild(textDiv);
  21976. var transform = '';
  21977. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  21978. textDivProperties.scale = textDivProperties.canvasWidth / width;
  21979. transform = 'scaleX(' + textDivProperties.scale + ')';
  21980. }
  21981. if (textDivProperties.angle !== 0) {
  21982. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  21983. }
  21984. if (transform !== '') {
  21985. textDivProperties.originalTransform = transform;
  21986. CustomStyle.setProp('transform', textDiv, transform);
  21987. }
  21988. task._textDivProperties.set(textDiv, textDivProperties);
  21989. }
  21990. task._renderingDone = true;
  21991. capability.resolve();
  21992. }
  21993. function expand(task) {
  21994. var bounds = task._bounds;
  21995. var viewport = task._viewport;
  21996. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  21997. for (var i = 0; i < expanded.length; i++) {
  21998. var div = bounds[i].div;
  21999. var divProperties = task._textDivProperties.get(div);
  22000. if (divProperties.angle === 0) {
  22001. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  22002. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  22003. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  22004. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  22005. task._textDivProperties.set(div, divProperties);
  22006. continue;
  22007. }
  22008. var e = expanded[i], b = bounds[i];
  22009. var m = b.m, c = m[0], s = m[1];
  22010. var points = [
  22011. [
  22012. 0,
  22013. 0
  22014. ],
  22015. [
  22016. 0,
  22017. b.size[1]
  22018. ],
  22019. [
  22020. b.size[0],
  22021. 0
  22022. ],
  22023. b.size
  22024. ];
  22025. var ts = new Float64Array(64);
  22026. points.forEach(function (p, i) {
  22027. var t = Util.applyTransform(p, m);
  22028. ts[i + 0] = c && (e.left - t[0]) / c;
  22029. ts[i + 4] = s && (e.top - t[1]) / s;
  22030. ts[i + 8] = c && (e.right - t[0]) / c;
  22031. ts[i + 12] = s && (e.bottom - t[1]) / s;
  22032. ts[i + 16] = s && (e.left - t[0]) / -s;
  22033. ts[i + 20] = c && (e.top - t[1]) / c;
  22034. ts[i + 24] = s && (e.right - t[0]) / -s;
  22035. ts[i + 28] = c && (e.bottom - t[1]) / c;
  22036. ts[i + 32] = c && (e.left - t[0]) / -c;
  22037. ts[i + 36] = s && (e.top - t[1]) / -s;
  22038. ts[i + 40] = c && (e.right - t[0]) / -c;
  22039. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  22040. ts[i + 48] = s && (e.left - t[0]) / s;
  22041. ts[i + 52] = c && (e.top - t[1]) / -c;
  22042. ts[i + 56] = s && (e.right - t[0]) / s;
  22043. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  22044. });
  22045. var findPositiveMin = function (ts, offset, count) {
  22046. var result = 0;
  22047. for (var i = 0; i < count; i++) {
  22048. var t = ts[offset++];
  22049. if (t > 0) {
  22050. result = result ? Math.min(t, result) : t;
  22051. }
  22052. }
  22053. return result;
  22054. };
  22055. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  22056. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  22057. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  22058. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  22059. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  22060. task._textDivProperties.set(div, divProperties);
  22061. }
  22062. }
  22063. function expandBounds(width, height, boxes) {
  22064. var bounds = boxes.map(function (box, i) {
  22065. return {
  22066. x1: box.left,
  22067. y1: box.top,
  22068. x2: box.right,
  22069. y2: box.bottom,
  22070. index: i,
  22071. x1New: undefined,
  22072. x2New: undefined
  22073. };
  22074. });
  22075. expandBoundsLTR(width, bounds);
  22076. var expanded = new Array(boxes.length);
  22077. bounds.forEach(function (b) {
  22078. var i = b.index;
  22079. expanded[i] = {
  22080. left: b.x1New,
  22081. top: 0,
  22082. right: b.x2New,
  22083. bottom: 0
  22084. };
  22085. });
  22086. boxes.map(function (box, i) {
  22087. var e = expanded[i], b = bounds[i];
  22088. b.x1 = box.top;
  22089. b.y1 = width - e.right;
  22090. b.x2 = box.bottom;
  22091. b.y2 = width - e.left;
  22092. b.index = i;
  22093. b.x1New = undefined;
  22094. b.x2New = undefined;
  22095. });
  22096. expandBoundsLTR(height, bounds);
  22097. bounds.forEach(function (b) {
  22098. var i = b.index;
  22099. expanded[i].top = b.x1New;
  22100. expanded[i].bottom = b.x2New;
  22101. });
  22102. return expanded;
  22103. }
  22104. function expandBoundsLTR(width, bounds) {
  22105. bounds.sort(function (a, b) {
  22106. return a.x1 - b.x1 || a.index - b.index;
  22107. });
  22108. var fakeBoundary = {
  22109. x1: -Infinity,
  22110. y1: -Infinity,
  22111. x2: 0,
  22112. y2: Infinity,
  22113. index: -1,
  22114. x1New: 0,
  22115. x2New: 0
  22116. };
  22117. var horizon = [{
  22118. start: -Infinity,
  22119. end: Infinity,
  22120. boundary: fakeBoundary
  22121. }];
  22122. bounds.forEach(function (boundary) {
  22123. var i = 0;
  22124. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  22125. i++;
  22126. }
  22127. var j = horizon.length - 1;
  22128. while (j >= 0 && horizon[j].start >= boundary.y2) {
  22129. j--;
  22130. }
  22131. var horizonPart, affectedBoundary;
  22132. var q, k, maxXNew = -Infinity;
  22133. for (q = i; q <= j; q++) {
  22134. horizonPart = horizon[q];
  22135. affectedBoundary = horizonPart.boundary;
  22136. var xNew;
  22137. if (affectedBoundary.x2 > boundary.x1) {
  22138. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  22139. } else if (affectedBoundary.x2New === undefined) {
  22140. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  22141. } else {
  22142. xNew = affectedBoundary.x2New;
  22143. }
  22144. if (xNew > maxXNew) {
  22145. maxXNew = xNew;
  22146. }
  22147. }
  22148. boundary.x1New = maxXNew;
  22149. for (q = i; q <= j; q++) {
  22150. horizonPart = horizon[q];
  22151. affectedBoundary = horizonPart.boundary;
  22152. if (affectedBoundary.x2New === undefined) {
  22153. if (affectedBoundary.x2 > boundary.x1) {
  22154. if (affectedBoundary.index > boundary.index) {
  22155. affectedBoundary.x2New = affectedBoundary.x2;
  22156. }
  22157. } else {
  22158. affectedBoundary.x2New = maxXNew;
  22159. }
  22160. } else if (affectedBoundary.x2New > maxXNew) {
  22161. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  22162. }
  22163. }
  22164. var changedHorizon = [], lastBoundary = null;
  22165. for (q = i; q <= j; q++) {
  22166. horizonPart = horizon[q];
  22167. affectedBoundary = horizonPart.boundary;
  22168. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  22169. if (lastBoundary === useBoundary) {
  22170. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  22171. } else {
  22172. changedHorizon.push({
  22173. start: horizonPart.start,
  22174. end: horizonPart.end,
  22175. boundary: useBoundary
  22176. });
  22177. lastBoundary = useBoundary;
  22178. }
  22179. }
  22180. if (horizon[i].start < boundary.y1) {
  22181. changedHorizon[0].start = boundary.y1;
  22182. changedHorizon.unshift({
  22183. start: horizon[i].start,
  22184. end: boundary.y1,
  22185. boundary: horizon[i].boundary
  22186. });
  22187. }
  22188. if (boundary.y2 < horizon[j].end) {
  22189. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  22190. changedHorizon.push({
  22191. start: boundary.y2,
  22192. end: horizon[j].end,
  22193. boundary: horizon[j].boundary
  22194. });
  22195. }
  22196. for (q = i; q <= j; q++) {
  22197. horizonPart = horizon[q];
  22198. affectedBoundary = horizonPart.boundary;
  22199. if (affectedBoundary.x2New !== undefined) {
  22200. continue;
  22201. }
  22202. var used = false;
  22203. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  22204. used = horizon[k].boundary === affectedBoundary;
  22205. }
  22206. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  22207. used = horizon[k].boundary === affectedBoundary;
  22208. }
  22209. for (k = 0; !used && k < changedHorizon.length; k++) {
  22210. used = changedHorizon[k].boundary === affectedBoundary;
  22211. }
  22212. if (!used) {
  22213. affectedBoundary.x2New = maxXNew;
  22214. }
  22215. }
  22216. Array.prototype.splice.apply(horizon, [
  22217. i,
  22218. j - i + 1
  22219. ].concat(changedHorizon));
  22220. });
  22221. horizon.forEach(function (horizonPart) {
  22222. var affectedBoundary = horizonPart.boundary;
  22223. if (affectedBoundary.x2New === undefined) {
  22224. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  22225. }
  22226. });
  22227. }
  22228. function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) {
  22229. this._textContent = textContent;
  22230. this._container = container;
  22231. this._viewport = viewport;
  22232. this._textDivs = textDivs || [];
  22233. this._textDivProperties = new WeakMap();
  22234. this._renderingDone = false;
  22235. this._canceled = false;
  22236. this._capability = createPromiseCapability();
  22237. this._renderTimer = null;
  22238. this._bounds = [];
  22239. this._enhanceTextSelection = !!enhanceTextSelection;
  22240. }
  22241. TextLayerRenderTask.prototype = {
  22242. get promise() {
  22243. return this._capability.promise;
  22244. },
  22245. cancel: function TextLayer_cancel() {
  22246. this._canceled = true;
  22247. if (this._renderTimer !== null) {
  22248. clearTimeout(this._renderTimer);
  22249. this._renderTimer = null;
  22250. }
  22251. this._capability.reject('canceled');
  22252. },
  22253. _render: function TextLayer_render(timeout) {
  22254. var textItems = this._textContent.items;
  22255. var textStyles = this._textContent.styles;
  22256. for (var i = 0, len = textItems.length; i < len; i++) {
  22257. appendText(this, textItems[i], textStyles);
  22258. }
  22259. if (!timeout) {
  22260. render(this);
  22261. } else {
  22262. var self = this;
  22263. this._renderTimer = setTimeout(function () {
  22264. render(self);
  22265. self._renderTimer = null;
  22266. }, timeout);
  22267. }
  22268. },
  22269. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  22270. if (!this._enhanceTextSelection || !this._renderingDone) {
  22271. return;
  22272. }
  22273. if (this._bounds !== null) {
  22274. expand(this);
  22275. this._bounds = null;
  22276. }
  22277. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  22278. var div = this._textDivs[i];
  22279. var divProperties = this._textDivProperties.get(div);
  22280. if (divProperties.isWhitespace) {
  22281. continue;
  22282. }
  22283. if (expandDivs) {
  22284. var transform = '', padding = '';
  22285. if (divProperties.scale !== 1) {
  22286. transform = 'scaleX(' + divProperties.scale + ')';
  22287. }
  22288. if (divProperties.angle !== 0) {
  22289. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  22290. }
  22291. if (divProperties.paddingLeft !== 0) {
  22292. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  22293. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  22294. }
  22295. if (divProperties.paddingTop !== 0) {
  22296. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  22297. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  22298. }
  22299. if (divProperties.paddingRight !== 0) {
  22300. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  22301. }
  22302. if (divProperties.paddingBottom !== 0) {
  22303. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  22304. }
  22305. if (padding !== '') {
  22306. div.setAttribute('style', divProperties.style + padding);
  22307. }
  22308. if (transform !== '') {
  22309. CustomStyle.setProp('transform', div, transform);
  22310. }
  22311. } else {
  22312. div.style.padding = 0;
  22313. CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  22314. }
  22315. }
  22316. }
  22317. };
  22318. function renderTextLayer(renderParameters) {
  22319. var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection);
  22320. task._render(renderParameters.timeout);
  22321. return task;
  22322. }
  22323. return renderTextLayer;
  22324. }();
  22325. exports.renderTextLayer = renderTextLayer;
  22326. /***/ }),
  22327. /* 13 */
  22328. /***/ (function(module, exports, __w_pdfjs_require__) {
  22329. "use strict";
  22330. var ArithmeticDecoder = function ArithmeticDecoderClosure() {
  22331. var QeTable = [
  22332. {
  22333. qe: 0x5601,
  22334. nmps: 1,
  22335. nlps: 1,
  22336. switchFlag: 1
  22337. },
  22338. {
  22339. qe: 0x3401,
  22340. nmps: 2,
  22341. nlps: 6,
  22342. switchFlag: 0
  22343. },
  22344. {
  22345. qe: 0x1801,
  22346. nmps: 3,
  22347. nlps: 9,
  22348. switchFlag: 0
  22349. },
  22350. {
  22351. qe: 0x0AC1,
  22352. nmps: 4,
  22353. nlps: 12,
  22354. switchFlag: 0
  22355. },
  22356. {
  22357. qe: 0x0521,
  22358. nmps: 5,
  22359. nlps: 29,
  22360. switchFlag: 0
  22361. },
  22362. {
  22363. qe: 0x0221,
  22364. nmps: 38,
  22365. nlps: 33,
  22366. switchFlag: 0
  22367. },
  22368. {
  22369. qe: 0x5601,
  22370. nmps: 7,
  22371. nlps: 6,
  22372. switchFlag: 1
  22373. },
  22374. {
  22375. qe: 0x5401,
  22376. nmps: 8,
  22377. nlps: 14,
  22378. switchFlag: 0
  22379. },
  22380. {
  22381. qe: 0x4801,
  22382. nmps: 9,
  22383. nlps: 14,
  22384. switchFlag: 0
  22385. },
  22386. {
  22387. qe: 0x3801,
  22388. nmps: 10,
  22389. nlps: 14,
  22390. switchFlag: 0
  22391. },
  22392. {
  22393. qe: 0x3001,
  22394. nmps: 11,
  22395. nlps: 17,
  22396. switchFlag: 0
  22397. },
  22398. {
  22399. qe: 0x2401,
  22400. nmps: 12,
  22401. nlps: 18,
  22402. switchFlag: 0
  22403. },
  22404. {
  22405. qe: 0x1C01,
  22406. nmps: 13,
  22407. nlps: 20,
  22408. switchFlag: 0
  22409. },
  22410. {
  22411. qe: 0x1601,
  22412. nmps: 29,
  22413. nlps: 21,
  22414. switchFlag: 0
  22415. },
  22416. {
  22417. qe: 0x5601,
  22418. nmps: 15,
  22419. nlps: 14,
  22420. switchFlag: 1
  22421. },
  22422. {
  22423. qe: 0x5401,
  22424. nmps: 16,
  22425. nlps: 14,
  22426. switchFlag: 0
  22427. },
  22428. {
  22429. qe: 0x5101,
  22430. nmps: 17,
  22431. nlps: 15,
  22432. switchFlag: 0
  22433. },
  22434. {
  22435. qe: 0x4801,
  22436. nmps: 18,
  22437. nlps: 16,
  22438. switchFlag: 0
  22439. },
  22440. {
  22441. qe: 0x3801,
  22442. nmps: 19,
  22443. nlps: 17,
  22444. switchFlag: 0
  22445. },
  22446. {
  22447. qe: 0x3401,
  22448. nmps: 20,
  22449. nlps: 18,
  22450. switchFlag: 0
  22451. },
  22452. {
  22453. qe: 0x3001,
  22454. nmps: 21,
  22455. nlps: 19,
  22456. switchFlag: 0
  22457. },
  22458. {
  22459. qe: 0x2801,
  22460. nmps: 22,
  22461. nlps: 19,
  22462. switchFlag: 0
  22463. },
  22464. {
  22465. qe: 0x2401,
  22466. nmps: 23,
  22467. nlps: 20,
  22468. switchFlag: 0
  22469. },
  22470. {
  22471. qe: 0x2201,
  22472. nmps: 24,
  22473. nlps: 21,
  22474. switchFlag: 0
  22475. },
  22476. {
  22477. qe: 0x1C01,
  22478. nmps: 25,
  22479. nlps: 22,
  22480. switchFlag: 0
  22481. },
  22482. {
  22483. qe: 0x1801,
  22484. nmps: 26,
  22485. nlps: 23,
  22486. switchFlag: 0
  22487. },
  22488. {
  22489. qe: 0x1601,
  22490. nmps: 27,
  22491. nlps: 24,
  22492. switchFlag: 0
  22493. },
  22494. {
  22495. qe: 0x1401,
  22496. nmps: 28,
  22497. nlps: 25,
  22498. switchFlag: 0
  22499. },
  22500. {
  22501. qe: 0x1201,
  22502. nmps: 29,
  22503. nlps: 26,
  22504. switchFlag: 0
  22505. },
  22506. {
  22507. qe: 0x1101,
  22508. nmps: 30,
  22509. nlps: 27,
  22510. switchFlag: 0
  22511. },
  22512. {
  22513. qe: 0x0AC1,
  22514. nmps: 31,
  22515. nlps: 28,
  22516. switchFlag: 0
  22517. },
  22518. {
  22519. qe: 0x09C1,
  22520. nmps: 32,
  22521. nlps: 29,
  22522. switchFlag: 0
  22523. },
  22524. {
  22525. qe: 0x08A1,
  22526. nmps: 33,
  22527. nlps: 30,
  22528. switchFlag: 0
  22529. },
  22530. {
  22531. qe: 0x0521,
  22532. nmps: 34,
  22533. nlps: 31,
  22534. switchFlag: 0
  22535. },
  22536. {
  22537. qe: 0x0441,
  22538. nmps: 35,
  22539. nlps: 32,
  22540. switchFlag: 0
  22541. },
  22542. {
  22543. qe: 0x02A1,
  22544. nmps: 36,
  22545. nlps: 33,
  22546. switchFlag: 0
  22547. },
  22548. {
  22549. qe: 0x0221,
  22550. nmps: 37,
  22551. nlps: 34,
  22552. switchFlag: 0
  22553. },
  22554. {
  22555. qe: 0x0141,
  22556. nmps: 38,
  22557. nlps: 35,
  22558. switchFlag: 0
  22559. },
  22560. {
  22561. qe: 0x0111,
  22562. nmps: 39,
  22563. nlps: 36,
  22564. switchFlag: 0
  22565. },
  22566. {
  22567. qe: 0x0085,
  22568. nmps: 40,
  22569. nlps: 37,
  22570. switchFlag: 0
  22571. },
  22572. {
  22573. qe: 0x0049,
  22574. nmps: 41,
  22575. nlps: 38,
  22576. switchFlag: 0
  22577. },
  22578. {
  22579. qe: 0x0025,
  22580. nmps: 42,
  22581. nlps: 39,
  22582. switchFlag: 0
  22583. },
  22584. {
  22585. qe: 0x0015,
  22586. nmps: 43,
  22587. nlps: 40,
  22588. switchFlag: 0
  22589. },
  22590. {
  22591. qe: 0x0009,
  22592. nmps: 44,
  22593. nlps: 41,
  22594. switchFlag: 0
  22595. },
  22596. {
  22597. qe: 0x0005,
  22598. nmps: 45,
  22599. nlps: 42,
  22600. switchFlag: 0
  22601. },
  22602. {
  22603. qe: 0x0001,
  22604. nmps: 45,
  22605. nlps: 43,
  22606. switchFlag: 0
  22607. },
  22608. {
  22609. qe: 0x5601,
  22610. nmps: 46,
  22611. nlps: 46,
  22612. switchFlag: 0
  22613. }
  22614. ];
  22615. function ArithmeticDecoder(data, start, end) {
  22616. this.data = data;
  22617. this.bp = start;
  22618. this.dataEnd = end;
  22619. this.chigh = data[start];
  22620. this.clow = 0;
  22621. this.byteIn();
  22622. this.chigh = this.chigh << 7 & 0xFFFF | this.clow >> 9 & 0x7F;
  22623. this.clow = this.clow << 7 & 0xFFFF;
  22624. this.ct -= 7;
  22625. this.a = 0x8000;
  22626. }
  22627. ArithmeticDecoder.prototype = {
  22628. byteIn: function ArithmeticDecoder_byteIn() {
  22629. var data = this.data;
  22630. var bp = this.bp;
  22631. if (data[bp] === 0xFF) {
  22632. var b1 = data[bp + 1];
  22633. if (b1 > 0x8F) {
  22634. this.clow += 0xFF00;
  22635. this.ct = 8;
  22636. } else {
  22637. bp++;
  22638. this.clow += data[bp] << 9;
  22639. this.ct = 7;
  22640. this.bp = bp;
  22641. }
  22642. } else {
  22643. bp++;
  22644. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xFF00;
  22645. this.ct = 8;
  22646. this.bp = bp;
  22647. }
  22648. if (this.clow > 0xFFFF) {
  22649. this.chigh += this.clow >> 16;
  22650. this.clow &= 0xFFFF;
  22651. }
  22652. },
  22653. readBit: function ArithmeticDecoder_readBit(contexts, pos) {
  22654. var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1;
  22655. var qeTableIcx = QeTable[cx_index];
  22656. var qeIcx = qeTableIcx.qe;
  22657. var d;
  22658. var a = this.a - qeIcx;
  22659. if (this.chigh < qeIcx) {
  22660. if (a < qeIcx) {
  22661. a = qeIcx;
  22662. d = cx_mps;
  22663. cx_index = qeTableIcx.nmps;
  22664. } else {
  22665. a = qeIcx;
  22666. d = 1 ^ cx_mps;
  22667. if (qeTableIcx.switchFlag === 1) {
  22668. cx_mps = d;
  22669. }
  22670. cx_index = qeTableIcx.nlps;
  22671. }
  22672. } else {
  22673. this.chigh -= qeIcx;
  22674. if ((a & 0x8000) !== 0) {
  22675. this.a = a;
  22676. return cx_mps;
  22677. }
  22678. if (a < qeIcx) {
  22679. d = 1 ^ cx_mps;
  22680. if (qeTableIcx.switchFlag === 1) {
  22681. cx_mps = d;
  22682. }
  22683. cx_index = qeTableIcx.nlps;
  22684. } else {
  22685. d = cx_mps;
  22686. cx_index = qeTableIcx.nmps;
  22687. }
  22688. }
  22689. do {
  22690. if (this.ct === 0) {
  22691. this.byteIn();
  22692. }
  22693. a <<= 1;
  22694. this.chigh = this.chigh << 1 & 0xFFFF | this.clow >> 15 & 1;
  22695. this.clow = this.clow << 1 & 0xFFFF;
  22696. this.ct--;
  22697. } while ((a & 0x8000) === 0);
  22698. this.a = a;
  22699. contexts[pos] = cx_index << 1 | cx_mps;
  22700. return d;
  22701. }
  22702. };
  22703. return ArithmeticDecoder;
  22704. }();
  22705. exports.ArithmeticDecoder = ArithmeticDecoder;
  22706. /***/ }),
  22707. /* 14 */
  22708. /***/ (function(module, exports, __w_pdfjs_require__) {
  22709. "use strict";
  22710. var sharedUtil = __w_pdfjs_require__(0);
  22711. var coreCharsets = __w_pdfjs_require__(29);
  22712. var coreEncodings = __w_pdfjs_require__(5);
  22713. var error = sharedUtil.error;
  22714. var info = sharedUtil.info;
  22715. var bytesToString = sharedUtil.bytesToString;
  22716. var warn = sharedUtil.warn;
  22717. var isArray = sharedUtil.isArray;
  22718. var Util = sharedUtil.Util;
  22719. var stringToBytes = sharedUtil.stringToBytes;
  22720. var assert = sharedUtil.assert;
  22721. var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
  22722. var ExpertCharset = coreCharsets.ExpertCharset;
  22723. var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
  22724. var StandardEncoding = coreEncodings.StandardEncoding;
  22725. var ExpertEncoding = coreEncodings.ExpertEncoding;
  22726. var MAX_SUBR_NESTING = 10;
  22727. var CFFStandardStrings = [
  22728. '.notdef',
  22729. 'space',
  22730. 'exclam',
  22731. 'quotedbl',
  22732. 'numbersign',
  22733. 'dollar',
  22734. 'percent',
  22735. 'ampersand',
  22736. 'quoteright',
  22737. 'parenleft',
  22738. 'parenright',
  22739. 'asterisk',
  22740. 'plus',
  22741. 'comma',
  22742. 'hyphen',
  22743. 'period',
  22744. 'slash',
  22745. 'zero',
  22746. 'one',
  22747. 'two',
  22748. 'three',
  22749. 'four',
  22750. 'five',
  22751. 'six',
  22752. 'seven',
  22753. 'eight',
  22754. 'nine',
  22755. 'colon',
  22756. 'semicolon',
  22757. 'less',
  22758. 'equal',
  22759. 'greater',
  22760. 'question',
  22761. 'at',
  22762. 'A',
  22763. 'B',
  22764. 'C',
  22765. 'D',
  22766. 'E',
  22767. 'F',
  22768. 'G',
  22769. 'H',
  22770. 'I',
  22771. 'J',
  22772. 'K',
  22773. 'L',
  22774. 'M',
  22775. 'N',
  22776. 'O',
  22777. 'P',
  22778. 'Q',
  22779. 'R',
  22780. 'S',
  22781. 'T',
  22782. 'U',
  22783. 'V',
  22784. 'W',
  22785. 'X',
  22786. 'Y',
  22787. 'Z',
  22788. 'bracketleft',
  22789. 'backslash',
  22790. 'bracketright',
  22791. 'asciicircum',
  22792. 'underscore',
  22793. 'quoteleft',
  22794. 'a',
  22795. 'b',
  22796. 'c',
  22797. 'd',
  22798. 'e',
  22799. 'f',
  22800. 'g',
  22801. 'h',
  22802. 'i',
  22803. 'j',
  22804. 'k',
  22805. 'l',
  22806. 'm',
  22807. 'n',
  22808. 'o',
  22809. 'p',
  22810. 'q',
  22811. 'r',
  22812. 's',
  22813. 't',
  22814. 'u',
  22815. 'v',
  22816. 'w',
  22817. 'x',
  22818. 'y',
  22819. 'z',
  22820. 'braceleft',
  22821. 'bar',
  22822. 'braceright',
  22823. 'asciitilde',
  22824. 'exclamdown',
  22825. 'cent',
  22826. 'sterling',
  22827. 'fraction',
  22828. 'yen',
  22829. 'florin',
  22830. 'section',
  22831. 'currency',
  22832. 'quotesingle',
  22833. 'quotedblleft',
  22834. 'guillemotleft',
  22835. 'guilsinglleft',
  22836. 'guilsinglright',
  22837. 'fi',
  22838. 'fl',
  22839. 'endash',
  22840. 'dagger',
  22841. 'daggerdbl',
  22842. 'periodcentered',
  22843. 'paragraph',
  22844. 'bullet',
  22845. 'quotesinglbase',
  22846. 'quotedblbase',
  22847. 'quotedblright',
  22848. 'guillemotright',
  22849. 'ellipsis',
  22850. 'perthousand',
  22851. 'questiondown',
  22852. 'grave',
  22853. 'acute',
  22854. 'circumflex',
  22855. 'tilde',
  22856. 'macron',
  22857. 'breve',
  22858. 'dotaccent',
  22859. 'dieresis',
  22860. 'ring',
  22861. 'cedilla',
  22862. 'hungarumlaut',
  22863. 'ogonek',
  22864. 'caron',
  22865. 'emdash',
  22866. 'AE',
  22867. 'ordfeminine',
  22868. 'Lslash',
  22869. 'Oslash',
  22870. 'OE',
  22871. 'ordmasculine',
  22872. 'ae',
  22873. 'dotlessi',
  22874. 'lslash',
  22875. 'oslash',
  22876. 'oe',
  22877. 'germandbls',
  22878. 'onesuperior',
  22879. 'logicalnot',
  22880. 'mu',
  22881. 'trademark',
  22882. 'Eth',
  22883. 'onehalf',
  22884. 'plusminus',
  22885. 'Thorn',
  22886. 'onequarter',
  22887. 'divide',
  22888. 'brokenbar',
  22889. 'degree',
  22890. 'thorn',
  22891. 'threequarters',
  22892. 'twosuperior',
  22893. 'registered',
  22894. 'minus',
  22895. 'eth',
  22896. 'multiply',
  22897. 'threesuperior',
  22898. 'copyright',
  22899. 'Aacute',
  22900. 'Acircumflex',
  22901. 'Adieresis',
  22902. 'Agrave',
  22903. 'Aring',
  22904. 'Atilde',
  22905. 'Ccedilla',
  22906. 'Eacute',
  22907. 'Ecircumflex',
  22908. 'Edieresis',
  22909. 'Egrave',
  22910. 'Iacute',
  22911. 'Icircumflex',
  22912. 'Idieresis',
  22913. 'Igrave',
  22914. 'Ntilde',
  22915. 'Oacute',
  22916. 'Ocircumflex',
  22917. 'Odieresis',
  22918. 'Ograve',
  22919. 'Otilde',
  22920. 'Scaron',
  22921. 'Uacute',
  22922. 'Ucircumflex',
  22923. 'Udieresis',
  22924. 'Ugrave',
  22925. 'Yacute',
  22926. 'Ydieresis',
  22927. 'Zcaron',
  22928. 'aacute',
  22929. 'acircumflex',
  22930. 'adieresis',
  22931. 'agrave',
  22932. 'aring',
  22933. 'atilde',
  22934. 'ccedilla',
  22935. 'eacute',
  22936. 'ecircumflex',
  22937. 'edieresis',
  22938. 'egrave',
  22939. 'iacute',
  22940. 'icircumflex',
  22941. 'idieresis',
  22942. 'igrave',
  22943. 'ntilde',
  22944. 'oacute',
  22945. 'ocircumflex',
  22946. 'odieresis',
  22947. 'ograve',
  22948. 'otilde',
  22949. 'scaron',
  22950. 'uacute',
  22951. 'ucircumflex',
  22952. 'udieresis',
  22953. 'ugrave',
  22954. 'yacute',
  22955. 'ydieresis',
  22956. 'zcaron',
  22957. 'exclamsmall',
  22958. 'Hungarumlautsmall',
  22959. 'dollaroldstyle',
  22960. 'dollarsuperior',
  22961. 'ampersandsmall',
  22962. 'Acutesmall',
  22963. 'parenleftsuperior',
  22964. 'parenrightsuperior',
  22965. 'twodotenleader',
  22966. 'onedotenleader',
  22967. 'zerooldstyle',
  22968. 'oneoldstyle',
  22969. 'twooldstyle',
  22970. 'threeoldstyle',
  22971. 'fouroldstyle',
  22972. 'fiveoldstyle',
  22973. 'sixoldstyle',
  22974. 'sevenoldstyle',
  22975. 'eightoldstyle',
  22976. 'nineoldstyle',
  22977. 'commasuperior',
  22978. 'threequartersemdash',
  22979. 'periodsuperior',
  22980. 'questionsmall',
  22981. 'asuperior',
  22982. 'bsuperior',
  22983. 'centsuperior',
  22984. 'dsuperior',
  22985. 'esuperior',
  22986. 'isuperior',
  22987. 'lsuperior',
  22988. 'msuperior',
  22989. 'nsuperior',
  22990. 'osuperior',
  22991. 'rsuperior',
  22992. 'ssuperior',
  22993. 'tsuperior',
  22994. 'ff',
  22995. 'ffi',
  22996. 'ffl',
  22997. 'parenleftinferior',
  22998. 'parenrightinferior',
  22999. 'Circumflexsmall',
  23000. 'hyphensuperior',
  23001. 'Gravesmall',
  23002. 'Asmall',
  23003. 'Bsmall',
  23004. 'Csmall',
  23005. 'Dsmall',
  23006. 'Esmall',
  23007. 'Fsmall',
  23008. 'Gsmall',
  23009. 'Hsmall',
  23010. 'Ismall',
  23011. 'Jsmall',
  23012. 'Ksmall',
  23013. 'Lsmall',
  23014. 'Msmall',
  23015. 'Nsmall',
  23016. 'Osmall',
  23017. 'Psmall',
  23018. 'Qsmall',
  23019. 'Rsmall',
  23020. 'Ssmall',
  23021. 'Tsmall',
  23022. 'Usmall',
  23023. 'Vsmall',
  23024. 'Wsmall',
  23025. 'Xsmall',
  23026. 'Ysmall',
  23027. 'Zsmall',
  23028. 'colonmonetary',
  23029. 'onefitted',
  23030. 'rupiah',
  23031. 'Tildesmall',
  23032. 'exclamdownsmall',
  23033. 'centoldstyle',
  23034. 'Lslashsmall',
  23035. 'Scaronsmall',
  23036. 'Zcaronsmall',
  23037. 'Dieresissmall',
  23038. 'Brevesmall',
  23039. 'Caronsmall',
  23040. 'Dotaccentsmall',
  23041. 'Macronsmall',
  23042. 'figuredash',
  23043. 'hypheninferior',
  23044. 'Ogoneksmall',
  23045. 'Ringsmall',
  23046. 'Cedillasmall',
  23047. 'questiondownsmall',
  23048. 'oneeighth',
  23049. 'threeeighths',
  23050. 'fiveeighths',
  23051. 'seveneighths',
  23052. 'onethird',
  23053. 'twothirds',
  23054. 'zerosuperior',
  23055. 'foursuperior',
  23056. 'fivesuperior',
  23057. 'sixsuperior',
  23058. 'sevensuperior',
  23059. 'eightsuperior',
  23060. 'ninesuperior',
  23061. 'zeroinferior',
  23062. 'oneinferior',
  23063. 'twoinferior',
  23064. 'threeinferior',
  23065. 'fourinferior',
  23066. 'fiveinferior',
  23067. 'sixinferior',
  23068. 'seveninferior',
  23069. 'eightinferior',
  23070. 'nineinferior',
  23071. 'centinferior',
  23072. 'dollarinferior',
  23073. 'periodinferior',
  23074. 'commainferior',
  23075. 'Agravesmall',
  23076. 'Aacutesmall',
  23077. 'Acircumflexsmall',
  23078. 'Atildesmall',
  23079. 'Adieresissmall',
  23080. 'Aringsmall',
  23081. 'AEsmall',
  23082. 'Ccedillasmall',
  23083. 'Egravesmall',
  23084. 'Eacutesmall',
  23085. 'Ecircumflexsmall',
  23086. 'Edieresissmall',
  23087. 'Igravesmall',
  23088. 'Iacutesmall',
  23089. 'Icircumflexsmall',
  23090. 'Idieresissmall',
  23091. 'Ethsmall',
  23092. 'Ntildesmall',
  23093. 'Ogravesmall',
  23094. 'Oacutesmall',
  23095. 'Ocircumflexsmall',
  23096. 'Otildesmall',
  23097. 'Odieresissmall',
  23098. 'OEsmall',
  23099. 'Oslashsmall',
  23100. 'Ugravesmall',
  23101. 'Uacutesmall',
  23102. 'Ucircumflexsmall',
  23103. 'Udieresissmall',
  23104. 'Yacutesmall',
  23105. 'Thornsmall',
  23106. 'Ydieresissmall',
  23107. '001.000',
  23108. '001.001',
  23109. '001.002',
  23110. '001.003',
  23111. 'Black',
  23112. 'Bold',
  23113. 'Book',
  23114. 'Light',
  23115. 'Medium',
  23116. 'Regular',
  23117. 'Roman',
  23118. 'Semibold'
  23119. ];
  23120. var CFFParser = function CFFParserClosure() {
  23121. var CharstringValidationData = [
  23122. null,
  23123. {
  23124. id: 'hstem',
  23125. min: 2,
  23126. stackClearing: true,
  23127. stem: true
  23128. },
  23129. null,
  23130. {
  23131. id: 'vstem',
  23132. min: 2,
  23133. stackClearing: true,
  23134. stem: true
  23135. },
  23136. {
  23137. id: 'vmoveto',
  23138. min: 1,
  23139. stackClearing: true
  23140. },
  23141. {
  23142. id: 'rlineto',
  23143. min: 2,
  23144. resetStack: true
  23145. },
  23146. {
  23147. id: 'hlineto',
  23148. min: 1,
  23149. resetStack: true
  23150. },
  23151. {
  23152. id: 'vlineto',
  23153. min: 1,
  23154. resetStack: true
  23155. },
  23156. {
  23157. id: 'rrcurveto',
  23158. min: 6,
  23159. resetStack: true
  23160. },
  23161. null,
  23162. {
  23163. id: 'callsubr',
  23164. min: 1,
  23165. undefStack: true
  23166. },
  23167. {
  23168. id: 'return',
  23169. min: 0,
  23170. undefStack: true
  23171. },
  23172. null,
  23173. null,
  23174. {
  23175. id: 'endchar',
  23176. min: 0,
  23177. stackClearing: true
  23178. },
  23179. null,
  23180. null,
  23181. null,
  23182. {
  23183. id: 'hstemhm',
  23184. min: 2,
  23185. stackClearing: true,
  23186. stem: true
  23187. },
  23188. {
  23189. id: 'hintmask',
  23190. min: 0,
  23191. stackClearing: true
  23192. },
  23193. {
  23194. id: 'cntrmask',
  23195. min: 0,
  23196. stackClearing: true
  23197. },
  23198. {
  23199. id: 'rmoveto',
  23200. min: 2,
  23201. stackClearing: true
  23202. },
  23203. {
  23204. id: 'hmoveto',
  23205. min: 1,
  23206. stackClearing: true
  23207. },
  23208. {
  23209. id: 'vstemhm',
  23210. min: 2,
  23211. stackClearing: true,
  23212. stem: true
  23213. },
  23214. {
  23215. id: 'rcurveline',
  23216. min: 8,
  23217. resetStack: true
  23218. },
  23219. {
  23220. id: 'rlinecurve',
  23221. min: 8,
  23222. resetStack: true
  23223. },
  23224. {
  23225. id: 'vvcurveto',
  23226. min: 4,
  23227. resetStack: true
  23228. },
  23229. {
  23230. id: 'hhcurveto',
  23231. min: 4,
  23232. resetStack: true
  23233. },
  23234. null,
  23235. {
  23236. id: 'callgsubr',
  23237. min: 1,
  23238. undefStack: true
  23239. },
  23240. {
  23241. id: 'vhcurveto',
  23242. min: 4,
  23243. resetStack: true
  23244. },
  23245. {
  23246. id: 'hvcurveto',
  23247. min: 4,
  23248. resetStack: true
  23249. }
  23250. ];
  23251. var CharstringValidationData12 = [
  23252. null,
  23253. null,
  23254. null,
  23255. {
  23256. id: 'and',
  23257. min: 2,
  23258. stackDelta: -1
  23259. },
  23260. {
  23261. id: 'or',
  23262. min: 2,
  23263. stackDelta: -1
  23264. },
  23265. {
  23266. id: 'not',
  23267. min: 1,
  23268. stackDelta: 0
  23269. },
  23270. null,
  23271. null,
  23272. null,
  23273. {
  23274. id: 'abs',
  23275. min: 1,
  23276. stackDelta: 0
  23277. },
  23278. {
  23279. id: 'add',
  23280. min: 2,
  23281. stackDelta: -1,
  23282. stackFn: function stack_div(stack, index) {
  23283. stack[index - 2] = stack[index - 2] + stack[index - 1];
  23284. }
  23285. },
  23286. {
  23287. id: 'sub',
  23288. min: 2,
  23289. stackDelta: -1,
  23290. stackFn: function stack_div(stack, index) {
  23291. stack[index - 2] = stack[index - 2] - stack[index - 1];
  23292. }
  23293. },
  23294. {
  23295. id: 'div',
  23296. min: 2,
  23297. stackDelta: -1,
  23298. stackFn: function stack_div(stack, index) {
  23299. stack[index - 2] = stack[index - 2] / stack[index - 1];
  23300. }
  23301. },
  23302. null,
  23303. {
  23304. id: 'neg',
  23305. min: 1,
  23306. stackDelta: 0,
  23307. stackFn: function stack_div(stack, index) {
  23308. stack[index - 1] = -stack[index - 1];
  23309. }
  23310. },
  23311. {
  23312. id: 'eq',
  23313. min: 2,
  23314. stackDelta: -1
  23315. },
  23316. null,
  23317. null,
  23318. {
  23319. id: 'drop',
  23320. min: 1,
  23321. stackDelta: -1
  23322. },
  23323. null,
  23324. {
  23325. id: 'put',
  23326. min: 2,
  23327. stackDelta: -2
  23328. },
  23329. {
  23330. id: 'get',
  23331. min: 1,
  23332. stackDelta: 0
  23333. },
  23334. {
  23335. id: 'ifelse',
  23336. min: 4,
  23337. stackDelta: -3
  23338. },
  23339. {
  23340. id: 'random',
  23341. min: 0,
  23342. stackDelta: 1
  23343. },
  23344. {
  23345. id: 'mul',
  23346. min: 2,
  23347. stackDelta: -1,
  23348. stackFn: function stack_div(stack, index) {
  23349. stack[index - 2] = stack[index - 2] * stack[index - 1];
  23350. }
  23351. },
  23352. null,
  23353. {
  23354. id: 'sqrt',
  23355. min: 1,
  23356. stackDelta: 0
  23357. },
  23358. {
  23359. id: 'dup',
  23360. min: 1,
  23361. stackDelta: 1
  23362. },
  23363. {
  23364. id: 'exch',
  23365. min: 2,
  23366. stackDelta: 0
  23367. },
  23368. {
  23369. id: 'index',
  23370. min: 2,
  23371. stackDelta: 0
  23372. },
  23373. {
  23374. id: 'roll',
  23375. min: 3,
  23376. stackDelta: -2
  23377. },
  23378. null,
  23379. null,
  23380. null,
  23381. {
  23382. id: 'hflex',
  23383. min: 7,
  23384. resetStack: true
  23385. },
  23386. {
  23387. id: 'flex',
  23388. min: 13,
  23389. resetStack: true
  23390. },
  23391. {
  23392. id: 'hflex1',
  23393. min: 9,
  23394. resetStack: true
  23395. },
  23396. {
  23397. id: 'flex1',
  23398. min: 11,
  23399. resetStack: true
  23400. }
  23401. ];
  23402. function CFFParser(file, properties, seacAnalysisEnabled) {
  23403. this.bytes = file.getBytes();
  23404. this.properties = properties;
  23405. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  23406. }
  23407. CFFParser.prototype = {
  23408. parse: function CFFParser_parse() {
  23409. var properties = this.properties;
  23410. var cff = new CFF();
  23411. this.cff = cff;
  23412. var header = this.parseHeader();
  23413. var nameIndex = this.parseIndex(header.endPos);
  23414. var topDictIndex = this.parseIndex(nameIndex.endPos);
  23415. var stringIndex = this.parseIndex(topDictIndex.endPos);
  23416. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  23417. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  23418. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  23419. cff.header = header.obj;
  23420. cff.names = this.parseNameIndex(nameIndex.obj);
  23421. cff.strings = this.parseStringIndex(stringIndex.obj);
  23422. cff.topDict = topDict;
  23423. cff.globalSubrIndex = globalSubrIndex.obj;
  23424. this.parsePrivateDict(cff.topDict);
  23425. cff.isCIDFont = topDict.hasName('ROS');
  23426. var charStringOffset = topDict.getByName('CharStrings');
  23427. var charStringIndex = this.parseIndex(charStringOffset).obj;
  23428. var fontMatrix = topDict.getByName('FontMatrix');
  23429. if (fontMatrix) {
  23430. properties.fontMatrix = fontMatrix;
  23431. }
  23432. var fontBBox = topDict.getByName('FontBBox');
  23433. if (fontBBox) {
  23434. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  23435. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  23436. properties.ascentScaled = true;
  23437. }
  23438. var charset, encoding;
  23439. if (cff.isCIDFont) {
  23440. var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
  23441. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  23442. var dictRaw = fdArrayIndex.get(i);
  23443. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  23444. this.parsePrivateDict(fontDict);
  23445. cff.fdArray.push(fontDict);
  23446. }
  23447. encoding = null;
  23448. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
  23449. cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
  23450. } else {
  23451. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
  23452. encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
  23453. }
  23454. cff.charset = charset;
  23455. cff.encoding = encoding;
  23456. var charStringsAndSeacs = this.parseCharStrings(charStringIndex, topDict.privateDict.subrsIndex, globalSubrIndex.obj, cff.fdSelect, cff.fdArray);
  23457. cff.charStrings = charStringsAndSeacs.charStrings;
  23458. cff.seacs = charStringsAndSeacs.seacs;
  23459. cff.widths = charStringsAndSeacs.widths;
  23460. return cff;
  23461. },
  23462. parseHeader: function CFFParser_parseHeader() {
  23463. var bytes = this.bytes;
  23464. var bytesLength = bytes.length;
  23465. var offset = 0;
  23466. while (offset < bytesLength && bytes[offset] !== 1) {
  23467. ++offset;
  23468. }
  23469. if (offset >= bytesLength) {
  23470. error('Invalid CFF header');
  23471. } else if (offset !== 0) {
  23472. info('cff data is shifted');
  23473. bytes = bytes.subarray(offset);
  23474. this.bytes = bytes;
  23475. }
  23476. var major = bytes[0];
  23477. var minor = bytes[1];
  23478. var hdrSize = bytes[2];
  23479. var offSize = bytes[3];
  23480. var header = new CFFHeader(major, minor, hdrSize, offSize);
  23481. return {
  23482. obj: header,
  23483. endPos: hdrSize
  23484. };
  23485. },
  23486. parseDict: function CFFParser_parseDict(dict) {
  23487. var pos = 0;
  23488. function parseOperand() {
  23489. var value = dict[pos++];
  23490. if (value === 30) {
  23491. return parseFloatOperand();
  23492. } else if (value === 28) {
  23493. value = dict[pos++];
  23494. value = (value << 24 | dict[pos++] << 16) >> 16;
  23495. return value;
  23496. } else if (value === 29) {
  23497. value = dict[pos++];
  23498. value = value << 8 | dict[pos++];
  23499. value = value << 8 | dict[pos++];
  23500. value = value << 8 | dict[pos++];
  23501. return value;
  23502. } else if (value >= 32 && value <= 246) {
  23503. return value - 139;
  23504. } else if (value >= 247 && value <= 250) {
  23505. return (value - 247) * 256 + dict[pos++] + 108;
  23506. } else if (value >= 251 && value <= 254) {
  23507. return -((value - 251) * 256) - dict[pos++] - 108;
  23508. }
  23509. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  23510. return NaN;
  23511. }
  23512. function parseFloatOperand() {
  23513. var str = '';
  23514. var eof = 15;
  23515. var lookup = [
  23516. '0',
  23517. '1',
  23518. '2',
  23519. '3',
  23520. '4',
  23521. '5',
  23522. '6',
  23523. '7',
  23524. '8',
  23525. '9',
  23526. '.',
  23527. 'E',
  23528. 'E-',
  23529. null,
  23530. '-'
  23531. ];
  23532. var length = dict.length;
  23533. while (pos < length) {
  23534. var b = dict[pos++];
  23535. var b1 = b >> 4;
  23536. var b2 = b & 15;
  23537. if (b1 === eof) {
  23538. break;
  23539. }
  23540. str += lookup[b1];
  23541. if (b2 === eof) {
  23542. break;
  23543. }
  23544. str += lookup[b2];
  23545. }
  23546. return parseFloat(str);
  23547. }
  23548. var operands = [];
  23549. var entries = [];
  23550. pos = 0;
  23551. var end = dict.length;
  23552. while (pos < end) {
  23553. var b = dict[pos];
  23554. if (b <= 21) {
  23555. if (b === 12) {
  23556. b = b << 8 | dict[++pos];
  23557. }
  23558. entries.push([
  23559. b,
  23560. operands
  23561. ]);
  23562. operands = [];
  23563. ++pos;
  23564. } else {
  23565. operands.push(parseOperand());
  23566. }
  23567. }
  23568. return entries;
  23569. },
  23570. parseIndex: function CFFParser_parseIndex(pos) {
  23571. var cffIndex = new CFFIndex();
  23572. var bytes = this.bytes;
  23573. var count = bytes[pos++] << 8 | bytes[pos++];
  23574. var offsets = [];
  23575. var end = pos;
  23576. var i, ii;
  23577. if (count !== 0) {
  23578. var offsetSize = bytes[pos++];
  23579. var startPos = pos + (count + 1) * offsetSize - 1;
  23580. for (i = 0, ii = count + 1; i < ii; ++i) {
  23581. var offset = 0;
  23582. for (var j = 0; j < offsetSize; ++j) {
  23583. offset <<= 8;
  23584. offset += bytes[pos++];
  23585. }
  23586. offsets.push(startPos + offset);
  23587. }
  23588. end = offsets[count];
  23589. }
  23590. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  23591. var offsetStart = offsets[i];
  23592. var offsetEnd = offsets[i + 1];
  23593. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  23594. }
  23595. return {
  23596. obj: cffIndex,
  23597. endPos: end
  23598. };
  23599. },
  23600. parseNameIndex: function CFFParser_parseNameIndex(index) {
  23601. var names = [];
  23602. for (var i = 0, ii = index.count; i < ii; ++i) {
  23603. var name = index.get(i);
  23604. var length = Math.min(name.length, 127);
  23605. var data = [];
  23606. for (var j = 0; j < length; ++j) {
  23607. var c = name[j];
  23608. if (j === 0 && c === 0) {
  23609. data[j] = c;
  23610. continue;
  23611. }
  23612. if (c < 33 || c > 126 || c === 91 || c === 93 || c === 40 || c === 41 || c === 123 || c === 125 || c === 60 || c === 62 || c === 47 || c === 37 || c === 35) {
  23613. data[j] = 95;
  23614. continue;
  23615. }
  23616. data[j] = c;
  23617. }
  23618. names.push(bytesToString(data));
  23619. }
  23620. return names;
  23621. },
  23622. parseStringIndex: function CFFParser_parseStringIndex(index) {
  23623. var strings = new CFFStrings();
  23624. for (var i = 0, ii = index.count; i < ii; ++i) {
  23625. var data = index.get(i);
  23626. strings.add(bytesToString(data));
  23627. }
  23628. return strings;
  23629. },
  23630. createDict: function CFFParser_createDict(Type, dict, strings) {
  23631. var cffDict = new Type(strings);
  23632. for (var i = 0, ii = dict.length; i < ii; ++i) {
  23633. var pair = dict[i];
  23634. var key = pair[0];
  23635. var value = pair[1];
  23636. cffDict.setByKey(key, value);
  23637. }
  23638. return cffDict;
  23639. },
  23640. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  23641. if (state.callDepth > MAX_SUBR_NESTING) {
  23642. return false;
  23643. }
  23644. var stackSize = state.stackSize;
  23645. var stack = state.stack;
  23646. var length = data.length;
  23647. for (var j = 0; j < length;) {
  23648. var value = data[j++];
  23649. var validationCommand = null;
  23650. if (value === 12) {
  23651. var q = data[j++];
  23652. if (q === 0) {
  23653. data[j - 2] = 139;
  23654. data[j - 1] = 22;
  23655. stackSize = 0;
  23656. } else {
  23657. validationCommand = CharstringValidationData12[q];
  23658. }
  23659. } else if (value === 28) {
  23660. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  23661. j += 2;
  23662. stackSize++;
  23663. } else if (value === 14) {
  23664. if (stackSize >= 4) {
  23665. stackSize -= 4;
  23666. if (this.seacAnalysisEnabled) {
  23667. state.seac = stack.slice(stackSize, stackSize + 4);
  23668. return false;
  23669. }
  23670. }
  23671. validationCommand = CharstringValidationData[value];
  23672. } else if (value >= 32 && value <= 246) {
  23673. stack[stackSize] = value - 139;
  23674. stackSize++;
  23675. } else if (value >= 247 && value <= 254) {
  23676. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  23677. j++;
  23678. stackSize++;
  23679. } else if (value === 255) {
  23680. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  23681. j += 4;
  23682. stackSize++;
  23683. } else if (value === 19 || value === 20) {
  23684. state.hints += stackSize >> 1;
  23685. j += state.hints + 7 >> 3;
  23686. stackSize %= 2;
  23687. validationCommand = CharstringValidationData[value];
  23688. } else if (value === 10 || value === 29) {
  23689. var subrsIndex;
  23690. if (value === 10) {
  23691. subrsIndex = localSubrIndex;
  23692. } else {
  23693. subrsIndex = globalSubrIndex;
  23694. }
  23695. if (!subrsIndex) {
  23696. validationCommand = CharstringValidationData[value];
  23697. warn('Missing subrsIndex for ' + validationCommand.id);
  23698. return false;
  23699. }
  23700. var bias = 32768;
  23701. if (subrsIndex.count < 1240) {
  23702. bias = 107;
  23703. } else if (subrsIndex.count < 33900) {
  23704. bias = 1131;
  23705. }
  23706. var subrNumber = stack[--stackSize] + bias;
  23707. if (subrNumber < 0 || subrNumber >= subrsIndex.count) {
  23708. validationCommand = CharstringValidationData[value];
  23709. warn('Out of bounds subrIndex for ' + validationCommand.id);
  23710. return false;
  23711. }
  23712. state.stackSize = stackSize;
  23713. state.callDepth++;
  23714. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  23715. if (!valid) {
  23716. return false;
  23717. }
  23718. state.callDepth--;
  23719. stackSize = state.stackSize;
  23720. continue;
  23721. } else if (value === 11) {
  23722. state.stackSize = stackSize;
  23723. return true;
  23724. } else {
  23725. validationCommand = CharstringValidationData[value];
  23726. }
  23727. if (validationCommand) {
  23728. if (validationCommand.stem) {
  23729. state.hints += stackSize >> 1;
  23730. }
  23731. if ('min' in validationCommand) {
  23732. if (!state.undefStack && stackSize < validationCommand.min) {
  23733. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  23734. return false;
  23735. }
  23736. }
  23737. if (state.firstStackClearing && validationCommand.stackClearing) {
  23738. state.firstStackClearing = false;
  23739. stackSize -= validationCommand.min;
  23740. if (stackSize >= 2 && validationCommand.stem) {
  23741. stackSize %= 2;
  23742. } else if (stackSize > 1) {
  23743. warn('Found too many parameters for stack-clearing command');
  23744. }
  23745. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  23746. state.width = stack[stackSize - 1];
  23747. }
  23748. }
  23749. if ('stackDelta' in validationCommand) {
  23750. if ('stackFn' in validationCommand) {
  23751. validationCommand.stackFn(stack, stackSize);
  23752. }
  23753. stackSize += validationCommand.stackDelta;
  23754. } else if (validationCommand.stackClearing) {
  23755. stackSize = 0;
  23756. } else if (validationCommand.resetStack) {
  23757. stackSize = 0;
  23758. state.undefStack = false;
  23759. } else if (validationCommand.undefStack) {
  23760. stackSize = 0;
  23761. state.undefStack = true;
  23762. state.firstStackClearing = false;
  23763. }
  23764. }
  23765. }
  23766. state.stackSize = stackSize;
  23767. return true;
  23768. },
  23769. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  23770. var seacs = [];
  23771. var widths = [];
  23772. var count = charStrings.count;
  23773. for (var i = 0; i < count; i++) {
  23774. var charstring = charStrings.get(i);
  23775. var state = {
  23776. callDepth: 0,
  23777. stackSize: 0,
  23778. stack: [],
  23779. undefStack: true,
  23780. hints: 0,
  23781. firstStackClearing: true,
  23782. seac: null,
  23783. width: null
  23784. };
  23785. var valid = true;
  23786. var localSubrToUse = null;
  23787. if (fdSelect && fdArray.length) {
  23788. var fdIndex = fdSelect.getFDIndex(i);
  23789. if (fdIndex === -1) {
  23790. warn('Glyph index is not in fd select.');
  23791. valid = false;
  23792. }
  23793. if (fdIndex >= fdArray.length) {
  23794. warn('Invalid fd index for glyph index.');
  23795. valid = false;
  23796. }
  23797. if (valid) {
  23798. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  23799. }
  23800. } else if (localSubrIndex) {
  23801. localSubrToUse = localSubrIndex;
  23802. }
  23803. if (valid) {
  23804. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  23805. }
  23806. if (state.width !== null) {
  23807. widths[i] = state.width;
  23808. }
  23809. if (state.seac !== null) {
  23810. seacs[i] = state.seac;
  23811. }
  23812. if (!valid) {
  23813. charStrings.set(i, new Uint8Array([14]));
  23814. }
  23815. }
  23816. return {
  23817. charStrings: charStrings,
  23818. seacs: seacs,
  23819. widths: widths
  23820. };
  23821. },
  23822. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  23823. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  23824. parentDict.setByKey(18, [
  23825. 0,
  23826. 0
  23827. ]);
  23828. parentDict.privateDict = privateDict;
  23829. },
  23830. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  23831. if (!parentDict.hasName('Private')) {
  23832. this.emptyPrivateDictionary(parentDict);
  23833. return;
  23834. }
  23835. var privateOffset = parentDict.getByName('Private');
  23836. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  23837. parentDict.removeByName('Private');
  23838. return;
  23839. }
  23840. var size = privateOffset[0];
  23841. var offset = privateOffset[1];
  23842. if (size === 0 || offset >= this.bytes.length) {
  23843. this.emptyPrivateDictionary(parentDict);
  23844. return;
  23845. }
  23846. var privateDictEnd = offset + size;
  23847. var dictData = this.bytes.subarray(offset, privateDictEnd);
  23848. var dict = this.parseDict(dictData);
  23849. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  23850. parentDict.privateDict = privateDict;
  23851. if (!privateDict.getByName('Subrs')) {
  23852. return;
  23853. }
  23854. var subrsOffset = privateDict.getByName('Subrs');
  23855. var relativeOffset = offset + subrsOffset;
  23856. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  23857. this.emptyPrivateDictionary(parentDict);
  23858. return;
  23859. }
  23860. var subrsIndex = this.parseIndex(relativeOffset);
  23861. privateDict.subrsIndex = subrsIndex.obj;
  23862. },
  23863. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  23864. if (pos === 0) {
  23865. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  23866. } else if (pos === 1) {
  23867. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  23868. } else if (pos === 2) {
  23869. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  23870. }
  23871. var bytes = this.bytes;
  23872. var start = pos;
  23873. var format = bytes[pos++];
  23874. var charset = ['.notdef'];
  23875. var id, count, i;
  23876. length -= 1;
  23877. switch (format) {
  23878. case 0:
  23879. for (i = 0; i < length; i++) {
  23880. id = bytes[pos++] << 8 | bytes[pos++];
  23881. charset.push(cid ? id : strings.get(id));
  23882. }
  23883. break;
  23884. case 1:
  23885. while (charset.length <= length) {
  23886. id = bytes[pos++] << 8 | bytes[pos++];
  23887. count = bytes[pos++];
  23888. for (i = 0; i <= count; i++) {
  23889. charset.push(cid ? id++ : strings.get(id++));
  23890. }
  23891. }
  23892. break;
  23893. case 2:
  23894. while (charset.length <= length) {
  23895. id = bytes[pos++] << 8 | bytes[pos++];
  23896. count = bytes[pos++] << 8 | bytes[pos++];
  23897. for (i = 0; i <= count; i++) {
  23898. charset.push(cid ? id++ : strings.get(id++));
  23899. }
  23900. }
  23901. break;
  23902. default:
  23903. error('Unknown charset format');
  23904. }
  23905. var end = pos;
  23906. var raw = bytes.subarray(start, end);
  23907. return new CFFCharset(false, format, charset, raw);
  23908. },
  23909. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  23910. var encoding = Object.create(null);
  23911. var bytes = this.bytes;
  23912. var predefined = false;
  23913. var format, i, ii;
  23914. var raw = null;
  23915. function readSupplement() {
  23916. var supplementsCount = bytes[pos++];
  23917. for (i = 0; i < supplementsCount; i++) {
  23918. var code = bytes[pos++];
  23919. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  23920. encoding[code] = charset.indexOf(strings.get(sid));
  23921. }
  23922. }
  23923. if (pos === 0 || pos === 1) {
  23924. predefined = true;
  23925. format = pos;
  23926. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  23927. for (i = 0, ii = charset.length; i < ii; i++) {
  23928. var index = baseEncoding.indexOf(charset[i]);
  23929. if (index !== -1) {
  23930. encoding[index] = i;
  23931. }
  23932. }
  23933. } else {
  23934. var dataStart = pos;
  23935. format = bytes[pos++];
  23936. switch (format & 0x7f) {
  23937. case 0:
  23938. var glyphsCount = bytes[pos++];
  23939. for (i = 1; i <= glyphsCount; i++) {
  23940. encoding[bytes[pos++]] = i;
  23941. }
  23942. break;
  23943. case 1:
  23944. var rangesCount = bytes[pos++];
  23945. var gid = 1;
  23946. for (i = 0; i < rangesCount; i++) {
  23947. var start = bytes[pos++];
  23948. var left = bytes[pos++];
  23949. for (var j = start; j <= start + left; j++) {
  23950. encoding[j] = gid++;
  23951. }
  23952. }
  23953. break;
  23954. default:
  23955. error('Unknown encoding format: ' + format + ' in CFF');
  23956. break;
  23957. }
  23958. var dataEnd = pos;
  23959. if (format & 0x80) {
  23960. bytes[dataStart] &= 0x7f;
  23961. readSupplement();
  23962. }
  23963. raw = bytes.subarray(dataStart, dataEnd);
  23964. }
  23965. format = format & 0x7f;
  23966. return new CFFEncoding(predefined, format, encoding, raw);
  23967. },
  23968. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  23969. var start = pos;
  23970. var bytes = this.bytes;
  23971. var format = bytes[pos++];
  23972. var fdSelect = [], rawBytes;
  23973. var i, invalidFirstGID = false;
  23974. switch (format) {
  23975. case 0:
  23976. for (i = 0; i < length; ++i) {
  23977. var id = bytes[pos++];
  23978. fdSelect.push(id);
  23979. }
  23980. rawBytes = bytes.subarray(start, pos);
  23981. break;
  23982. case 3:
  23983. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  23984. for (i = 0; i < rangesCount; ++i) {
  23985. var first = bytes[pos++] << 8 | bytes[pos++];
  23986. if (i === 0 && first !== 0) {
  23987. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  23988. invalidFirstGID = true;
  23989. first = 0;
  23990. }
  23991. var fdIndex = bytes[pos++];
  23992. var next = bytes[pos] << 8 | bytes[pos + 1];
  23993. for (var j = first; j < next; ++j) {
  23994. fdSelect.push(fdIndex);
  23995. }
  23996. }
  23997. pos += 2;
  23998. rawBytes = bytes.subarray(start, pos);
  23999. if (invalidFirstGID) {
  24000. rawBytes[3] = rawBytes[4] = 0;
  24001. }
  24002. break;
  24003. default:
  24004. error('parseFDSelect: Unknown format "' + format + '".');
  24005. break;
  24006. }
  24007. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  24008. return new CFFFDSelect(fdSelect, rawBytes);
  24009. }
  24010. };
  24011. return CFFParser;
  24012. }();
  24013. var CFF = function CFFClosure() {
  24014. function CFF() {
  24015. this.header = null;
  24016. this.names = [];
  24017. this.topDict = null;
  24018. this.strings = new CFFStrings();
  24019. this.globalSubrIndex = null;
  24020. this.encoding = null;
  24021. this.charset = null;
  24022. this.charStrings = null;
  24023. this.fdArray = [];
  24024. this.fdSelect = null;
  24025. this.isCIDFont = false;
  24026. }
  24027. return CFF;
  24028. }();
  24029. var CFFHeader = function CFFHeaderClosure() {
  24030. function CFFHeader(major, minor, hdrSize, offSize) {
  24031. this.major = major;
  24032. this.minor = minor;
  24033. this.hdrSize = hdrSize;
  24034. this.offSize = offSize;
  24035. }
  24036. return CFFHeader;
  24037. }();
  24038. var CFFStrings = function CFFStringsClosure() {
  24039. function CFFStrings() {
  24040. this.strings = [];
  24041. }
  24042. CFFStrings.prototype = {
  24043. get: function CFFStrings_get(index) {
  24044. if (index >= 0 && index <= 390) {
  24045. return CFFStandardStrings[index];
  24046. }
  24047. if (index - 391 <= this.strings.length) {
  24048. return this.strings[index - 391];
  24049. }
  24050. return CFFStandardStrings[0];
  24051. },
  24052. add: function CFFStrings_add(value) {
  24053. this.strings.push(value);
  24054. },
  24055. get count() {
  24056. return this.strings.length;
  24057. }
  24058. };
  24059. return CFFStrings;
  24060. }();
  24061. var CFFIndex = function CFFIndexClosure() {
  24062. function CFFIndex() {
  24063. this.objects = [];
  24064. this.length = 0;
  24065. }
  24066. CFFIndex.prototype = {
  24067. add: function CFFIndex_add(data) {
  24068. this.length += data.length;
  24069. this.objects.push(data);
  24070. },
  24071. set: function CFFIndex_set(index, data) {
  24072. this.length += data.length - this.objects[index].length;
  24073. this.objects[index] = data;
  24074. },
  24075. get: function CFFIndex_get(index) {
  24076. return this.objects[index];
  24077. },
  24078. get count() {
  24079. return this.objects.length;
  24080. }
  24081. };
  24082. return CFFIndex;
  24083. }();
  24084. var CFFDict = function CFFDictClosure() {
  24085. function CFFDict(tables, strings) {
  24086. this.keyToNameMap = tables.keyToNameMap;
  24087. this.nameToKeyMap = tables.nameToKeyMap;
  24088. this.defaults = tables.defaults;
  24089. this.types = tables.types;
  24090. this.opcodes = tables.opcodes;
  24091. this.order = tables.order;
  24092. this.strings = strings;
  24093. this.values = Object.create(null);
  24094. }
  24095. CFFDict.prototype = {
  24096. setByKey: function CFFDict_setByKey(key, value) {
  24097. if (!(key in this.keyToNameMap)) {
  24098. return false;
  24099. }
  24100. var valueLength = value.length;
  24101. if (valueLength === 0) {
  24102. return true;
  24103. }
  24104. for (var i = 0; i < valueLength; i++) {
  24105. if (isNaN(value[i])) {
  24106. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  24107. return true;
  24108. }
  24109. }
  24110. var type = this.types[key];
  24111. if (type === 'num' || type === 'sid' || type === 'offset') {
  24112. value = value[0];
  24113. }
  24114. this.values[key] = value;
  24115. return true;
  24116. },
  24117. setByName: function CFFDict_setByName(name, value) {
  24118. if (!(name in this.nameToKeyMap)) {
  24119. error('Invalid dictionary name "' + name + '"');
  24120. }
  24121. this.values[this.nameToKeyMap[name]] = value;
  24122. },
  24123. hasName: function CFFDict_hasName(name) {
  24124. return this.nameToKeyMap[name] in this.values;
  24125. },
  24126. getByName: function CFFDict_getByName(name) {
  24127. if (!(name in this.nameToKeyMap)) {
  24128. error('Invalid dictionary name "' + name + '"');
  24129. }
  24130. var key = this.nameToKeyMap[name];
  24131. if (!(key in this.values)) {
  24132. return this.defaults[key];
  24133. }
  24134. return this.values[key];
  24135. },
  24136. removeByName: function CFFDict_removeByName(name) {
  24137. delete this.values[this.nameToKeyMap[name]];
  24138. }
  24139. };
  24140. CFFDict.createTables = function CFFDict_createTables(layout) {
  24141. var tables = {
  24142. keyToNameMap: {},
  24143. nameToKeyMap: {},
  24144. defaults: {},
  24145. types: {},
  24146. opcodes: {},
  24147. order: []
  24148. };
  24149. for (var i = 0, ii = layout.length; i < ii; ++i) {
  24150. var entry = layout[i];
  24151. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  24152. tables.keyToNameMap[key] = entry[1];
  24153. tables.nameToKeyMap[entry[1]] = key;
  24154. tables.types[key] = entry[2];
  24155. tables.defaults[key] = entry[3];
  24156. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  24157. tables.order.push(key);
  24158. }
  24159. return tables;
  24160. };
  24161. return CFFDict;
  24162. }();
  24163. var CFFTopDict = function CFFTopDictClosure() {
  24164. var layout = [
  24165. [
  24166. [
  24167. 12,
  24168. 30
  24169. ],
  24170. 'ROS',
  24171. [
  24172. 'sid',
  24173. 'sid',
  24174. 'num'
  24175. ],
  24176. null
  24177. ],
  24178. [
  24179. [
  24180. 12,
  24181. 20
  24182. ],
  24183. 'SyntheticBase',
  24184. 'num',
  24185. null
  24186. ],
  24187. [
  24188. 0,
  24189. 'version',
  24190. 'sid',
  24191. null
  24192. ],
  24193. [
  24194. 1,
  24195. 'Notice',
  24196. 'sid',
  24197. null
  24198. ],
  24199. [
  24200. [
  24201. 12,
  24202. 0
  24203. ],
  24204. 'Copyright',
  24205. 'sid',
  24206. null
  24207. ],
  24208. [
  24209. 2,
  24210. 'FullName',
  24211. 'sid',
  24212. null
  24213. ],
  24214. [
  24215. 3,
  24216. 'FamilyName',
  24217. 'sid',
  24218. null
  24219. ],
  24220. [
  24221. 4,
  24222. 'Weight',
  24223. 'sid',
  24224. null
  24225. ],
  24226. [
  24227. [
  24228. 12,
  24229. 1
  24230. ],
  24231. 'isFixedPitch',
  24232. 'num',
  24233. 0
  24234. ],
  24235. [
  24236. [
  24237. 12,
  24238. 2
  24239. ],
  24240. 'ItalicAngle',
  24241. 'num',
  24242. 0
  24243. ],
  24244. [
  24245. [
  24246. 12,
  24247. 3
  24248. ],
  24249. 'UnderlinePosition',
  24250. 'num',
  24251. -100
  24252. ],
  24253. [
  24254. [
  24255. 12,
  24256. 4
  24257. ],
  24258. 'UnderlineThickness',
  24259. 'num',
  24260. 50
  24261. ],
  24262. [
  24263. [
  24264. 12,
  24265. 5
  24266. ],
  24267. 'PaintType',
  24268. 'num',
  24269. 0
  24270. ],
  24271. [
  24272. [
  24273. 12,
  24274. 6
  24275. ],
  24276. 'CharstringType',
  24277. 'num',
  24278. 2
  24279. ],
  24280. [
  24281. [
  24282. 12,
  24283. 7
  24284. ],
  24285. 'FontMatrix',
  24286. [
  24287. 'num',
  24288. 'num',
  24289. 'num',
  24290. 'num',
  24291. 'num',
  24292. 'num'
  24293. ],
  24294. [
  24295. 0.001,
  24296. 0,
  24297. 0,
  24298. 0.001,
  24299. 0,
  24300. 0
  24301. ]
  24302. ],
  24303. [
  24304. 13,
  24305. 'UniqueID',
  24306. 'num',
  24307. null
  24308. ],
  24309. [
  24310. 5,
  24311. 'FontBBox',
  24312. [
  24313. 'num',
  24314. 'num',
  24315. 'num',
  24316. 'num'
  24317. ],
  24318. [
  24319. 0,
  24320. 0,
  24321. 0,
  24322. 0
  24323. ]
  24324. ],
  24325. [
  24326. [
  24327. 12,
  24328. 8
  24329. ],
  24330. 'StrokeWidth',
  24331. 'num',
  24332. 0
  24333. ],
  24334. [
  24335. 14,
  24336. 'XUID',
  24337. 'array',
  24338. null
  24339. ],
  24340. [
  24341. 15,
  24342. 'charset',
  24343. 'offset',
  24344. 0
  24345. ],
  24346. [
  24347. 16,
  24348. 'Encoding',
  24349. 'offset',
  24350. 0
  24351. ],
  24352. [
  24353. 17,
  24354. 'CharStrings',
  24355. 'offset',
  24356. 0
  24357. ],
  24358. [
  24359. 18,
  24360. 'Private',
  24361. [
  24362. 'offset',
  24363. 'offset'
  24364. ],
  24365. null
  24366. ],
  24367. [
  24368. [
  24369. 12,
  24370. 21
  24371. ],
  24372. 'PostScript',
  24373. 'sid',
  24374. null
  24375. ],
  24376. [
  24377. [
  24378. 12,
  24379. 22
  24380. ],
  24381. 'BaseFontName',
  24382. 'sid',
  24383. null
  24384. ],
  24385. [
  24386. [
  24387. 12,
  24388. 23
  24389. ],
  24390. 'BaseFontBlend',
  24391. 'delta',
  24392. null
  24393. ],
  24394. [
  24395. [
  24396. 12,
  24397. 31
  24398. ],
  24399. 'CIDFontVersion',
  24400. 'num',
  24401. 0
  24402. ],
  24403. [
  24404. [
  24405. 12,
  24406. 32
  24407. ],
  24408. 'CIDFontRevision',
  24409. 'num',
  24410. 0
  24411. ],
  24412. [
  24413. [
  24414. 12,
  24415. 33
  24416. ],
  24417. 'CIDFontType',
  24418. 'num',
  24419. 0
  24420. ],
  24421. [
  24422. [
  24423. 12,
  24424. 34
  24425. ],
  24426. 'CIDCount',
  24427. 'num',
  24428. 8720
  24429. ],
  24430. [
  24431. [
  24432. 12,
  24433. 35
  24434. ],
  24435. 'UIDBase',
  24436. 'num',
  24437. null
  24438. ],
  24439. [
  24440. [
  24441. 12,
  24442. 37
  24443. ],
  24444. 'FDSelect',
  24445. 'offset',
  24446. null
  24447. ],
  24448. [
  24449. [
  24450. 12,
  24451. 36
  24452. ],
  24453. 'FDArray',
  24454. 'offset',
  24455. null
  24456. ],
  24457. [
  24458. [
  24459. 12,
  24460. 38
  24461. ],
  24462. 'FontName',
  24463. 'sid',
  24464. null
  24465. ]
  24466. ];
  24467. var tables = null;
  24468. function CFFTopDict(strings) {
  24469. if (tables === null) {
  24470. tables = CFFDict.createTables(layout);
  24471. }
  24472. CFFDict.call(this, tables, strings);
  24473. this.privateDict = null;
  24474. }
  24475. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  24476. return CFFTopDict;
  24477. }();
  24478. var CFFPrivateDict = function CFFPrivateDictClosure() {
  24479. var layout = [
  24480. [
  24481. 6,
  24482. 'BlueValues',
  24483. 'delta',
  24484. null
  24485. ],
  24486. [
  24487. 7,
  24488. 'OtherBlues',
  24489. 'delta',
  24490. null
  24491. ],
  24492. [
  24493. 8,
  24494. 'FamilyBlues',
  24495. 'delta',
  24496. null
  24497. ],
  24498. [
  24499. 9,
  24500. 'FamilyOtherBlues',
  24501. 'delta',
  24502. null
  24503. ],
  24504. [
  24505. [
  24506. 12,
  24507. 9
  24508. ],
  24509. 'BlueScale',
  24510. 'num',
  24511. 0.039625
  24512. ],
  24513. [
  24514. [
  24515. 12,
  24516. 10
  24517. ],
  24518. 'BlueShift',
  24519. 'num',
  24520. 7
  24521. ],
  24522. [
  24523. [
  24524. 12,
  24525. 11
  24526. ],
  24527. 'BlueFuzz',
  24528. 'num',
  24529. 1
  24530. ],
  24531. [
  24532. 10,
  24533. 'StdHW',
  24534. 'num',
  24535. null
  24536. ],
  24537. [
  24538. 11,
  24539. 'StdVW',
  24540. 'num',
  24541. null
  24542. ],
  24543. [
  24544. [
  24545. 12,
  24546. 12
  24547. ],
  24548. 'StemSnapH',
  24549. 'delta',
  24550. null
  24551. ],
  24552. [
  24553. [
  24554. 12,
  24555. 13
  24556. ],
  24557. 'StemSnapV',
  24558. 'delta',
  24559. null
  24560. ],
  24561. [
  24562. [
  24563. 12,
  24564. 14
  24565. ],
  24566. 'ForceBold',
  24567. 'num',
  24568. 0
  24569. ],
  24570. [
  24571. [
  24572. 12,
  24573. 17
  24574. ],
  24575. 'LanguageGroup',
  24576. 'num',
  24577. 0
  24578. ],
  24579. [
  24580. [
  24581. 12,
  24582. 18
  24583. ],
  24584. 'ExpansionFactor',
  24585. 'num',
  24586. 0.06
  24587. ],
  24588. [
  24589. [
  24590. 12,
  24591. 19
  24592. ],
  24593. 'initialRandomSeed',
  24594. 'num',
  24595. 0
  24596. ],
  24597. [
  24598. 20,
  24599. 'defaultWidthX',
  24600. 'num',
  24601. 0
  24602. ],
  24603. [
  24604. 21,
  24605. 'nominalWidthX',
  24606. 'num',
  24607. 0
  24608. ],
  24609. [
  24610. 19,
  24611. 'Subrs',
  24612. 'offset',
  24613. null
  24614. ]
  24615. ];
  24616. var tables = null;
  24617. function CFFPrivateDict(strings) {
  24618. if (tables === null) {
  24619. tables = CFFDict.createTables(layout);
  24620. }
  24621. CFFDict.call(this, tables, strings);
  24622. this.subrsIndex = null;
  24623. }
  24624. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  24625. return CFFPrivateDict;
  24626. }();
  24627. var CFFCharsetPredefinedTypes = {
  24628. ISO_ADOBE: 0,
  24629. EXPERT: 1,
  24630. EXPERT_SUBSET: 2
  24631. };
  24632. var CFFCharset = function CFFCharsetClosure() {
  24633. function CFFCharset(predefined, format, charset, raw) {
  24634. this.predefined = predefined;
  24635. this.format = format;
  24636. this.charset = charset;
  24637. this.raw = raw;
  24638. }
  24639. return CFFCharset;
  24640. }();
  24641. var CFFEncoding = function CFFEncodingClosure() {
  24642. function CFFEncoding(predefined, format, encoding, raw) {
  24643. this.predefined = predefined;
  24644. this.format = format;
  24645. this.encoding = encoding;
  24646. this.raw = raw;
  24647. }
  24648. return CFFEncoding;
  24649. }();
  24650. var CFFFDSelect = function CFFFDSelectClosure() {
  24651. function CFFFDSelect(fdSelect, raw) {
  24652. this.fdSelect = fdSelect;
  24653. this.raw = raw;
  24654. }
  24655. CFFFDSelect.prototype = {
  24656. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  24657. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  24658. return -1;
  24659. }
  24660. return this.fdSelect[glyphIndex];
  24661. }
  24662. };
  24663. return CFFFDSelect;
  24664. }();
  24665. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  24666. function CFFOffsetTracker() {
  24667. this.offsets = Object.create(null);
  24668. }
  24669. CFFOffsetTracker.prototype = {
  24670. isTracking: function CFFOffsetTracker_isTracking(key) {
  24671. return key in this.offsets;
  24672. },
  24673. track: function CFFOffsetTracker_track(key, location) {
  24674. if (key in this.offsets) {
  24675. error('Already tracking location of ' + key);
  24676. }
  24677. this.offsets[key] = location;
  24678. },
  24679. offset: function CFFOffsetTracker_offset(value) {
  24680. for (var key in this.offsets) {
  24681. this.offsets[key] += value;
  24682. }
  24683. },
  24684. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  24685. if (!(key in this.offsets)) {
  24686. error('Not tracking location of ' + key);
  24687. }
  24688. var data = output.data;
  24689. var dataOffset = this.offsets[key];
  24690. var size = 5;
  24691. for (var i = 0, ii = values.length; i < ii; ++i) {
  24692. var offset0 = i * size + dataOffset;
  24693. var offset1 = offset0 + 1;
  24694. var offset2 = offset0 + 2;
  24695. var offset3 = offset0 + 3;
  24696. var offset4 = offset0 + 4;
  24697. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  24698. error('writing to an offset that is not empty');
  24699. }
  24700. var value = values[i];
  24701. data[offset0] = 0x1d;
  24702. data[offset1] = value >> 24 & 0xFF;
  24703. data[offset2] = value >> 16 & 0xFF;
  24704. data[offset3] = value >> 8 & 0xFF;
  24705. data[offset4] = value & 0xFF;
  24706. }
  24707. }
  24708. };
  24709. return CFFOffsetTracker;
  24710. }();
  24711. var CFFCompiler = function CFFCompilerClosure() {
  24712. function CFFCompiler(cff) {
  24713. this.cff = cff;
  24714. }
  24715. CFFCompiler.prototype = {
  24716. compile: function CFFCompiler_compile() {
  24717. var cff = this.cff;
  24718. var output = {
  24719. data: [],
  24720. length: 0,
  24721. add: function CFFCompiler_add(data) {
  24722. this.data = this.data.concat(data);
  24723. this.length = this.data.length;
  24724. }
  24725. };
  24726. var header = this.compileHeader(cff.header);
  24727. output.add(header);
  24728. var nameIndex = this.compileNameIndex(cff.names);
  24729. output.add(nameIndex);
  24730. if (cff.isCIDFont) {
  24731. if (cff.topDict.hasName('FontMatrix')) {
  24732. var base = cff.topDict.getByName('FontMatrix');
  24733. cff.topDict.removeByName('FontMatrix');
  24734. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  24735. var subDict = cff.fdArray[i];
  24736. var matrix = base.slice(0);
  24737. if (subDict.hasName('FontMatrix')) {
  24738. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  24739. }
  24740. subDict.setByName('FontMatrix', matrix);
  24741. }
  24742. }
  24743. }
  24744. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  24745. output.add(compiled.output);
  24746. var topDictTracker = compiled.trackers[0];
  24747. var stringIndex = this.compileStringIndex(cff.strings.strings);
  24748. output.add(stringIndex);
  24749. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  24750. output.add(globalSubrIndex);
  24751. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  24752. if (cff.encoding.predefined) {
  24753. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  24754. } else {
  24755. var encoding = this.compileEncoding(cff.encoding);
  24756. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  24757. output.add(encoding);
  24758. }
  24759. }
  24760. if (cff.charset && cff.topDict.hasName('charset')) {
  24761. if (cff.charset.predefined) {
  24762. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  24763. } else {
  24764. var charset = this.compileCharset(cff.charset);
  24765. topDictTracker.setEntryLocation('charset', [output.length], output);
  24766. output.add(charset);
  24767. }
  24768. }
  24769. var charStrings = this.compileCharStrings(cff.charStrings);
  24770. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  24771. output.add(charStrings);
  24772. if (cff.isCIDFont) {
  24773. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  24774. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  24775. output.add(fdSelect);
  24776. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  24777. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  24778. output.add(compiled.output);
  24779. var fontDictTrackers = compiled.trackers;
  24780. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  24781. }
  24782. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  24783. output.add([0]);
  24784. return output.data;
  24785. },
  24786. encodeNumber: function CFFCompiler_encodeNumber(value) {
  24787. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  24788. return this.encodeInteger(value);
  24789. }
  24790. return this.encodeFloat(value);
  24791. },
  24792. encodeFloat: function CFFCompiler_encodeFloat(num) {
  24793. var value = num.toString();
  24794. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  24795. if (m) {
  24796. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  24797. value = (Math.round(num * epsilon) / epsilon).toString();
  24798. }
  24799. var nibbles = '';
  24800. var i, ii;
  24801. for (i = 0, ii = value.length; i < ii; ++i) {
  24802. var a = value[i];
  24803. if (a === 'e') {
  24804. nibbles += value[++i] === '-' ? 'c' : 'b';
  24805. } else if (a === '.') {
  24806. nibbles += 'a';
  24807. } else if (a === '-') {
  24808. nibbles += 'e';
  24809. } else {
  24810. nibbles += a;
  24811. }
  24812. }
  24813. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  24814. var out = [30];
  24815. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  24816. out.push(parseInt(nibbles.substr(i, 2), 16));
  24817. }
  24818. return out;
  24819. },
  24820. encodeInteger: function CFFCompiler_encodeInteger(value) {
  24821. var code;
  24822. if (value >= -107 && value <= 107) {
  24823. code = [value + 139];
  24824. } else if (value >= 108 && value <= 1131) {
  24825. value = value - 108;
  24826. code = [
  24827. (value >> 8) + 247,
  24828. value & 0xFF
  24829. ];
  24830. } else if (value >= -1131 && value <= -108) {
  24831. value = -value - 108;
  24832. code = [
  24833. (value >> 8) + 251,
  24834. value & 0xFF
  24835. ];
  24836. } else if (value >= -32768 && value <= 32767) {
  24837. code = [
  24838. 0x1c,
  24839. value >> 8 & 0xFF,
  24840. value & 0xFF
  24841. ];
  24842. } else {
  24843. code = [
  24844. 0x1d,
  24845. value >> 24 & 0xFF,
  24846. value >> 16 & 0xFF,
  24847. value >> 8 & 0xFF,
  24848. value & 0xFF
  24849. ];
  24850. }
  24851. return code;
  24852. },
  24853. compileHeader: function CFFCompiler_compileHeader(header) {
  24854. return [
  24855. header.major,
  24856. header.minor,
  24857. header.hdrSize,
  24858. header.offSize
  24859. ];
  24860. },
  24861. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  24862. var nameIndex = new CFFIndex();
  24863. for (var i = 0, ii = names.length; i < ii; ++i) {
  24864. nameIndex.add(stringToBytes(names[i]));
  24865. }
  24866. return this.compileIndex(nameIndex);
  24867. },
  24868. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  24869. var fontDictTrackers = [];
  24870. var fdArrayIndex = new CFFIndex();
  24871. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24872. var fontDict = dicts[i];
  24873. if (removeCidKeys) {
  24874. fontDict.removeByName('CIDFontVersion');
  24875. fontDict.removeByName('CIDFontRevision');
  24876. fontDict.removeByName('CIDFontType');
  24877. fontDict.removeByName('CIDCount');
  24878. fontDict.removeByName('UIDBase');
  24879. }
  24880. var fontDictTracker = new CFFOffsetTracker();
  24881. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  24882. fontDictTrackers.push(fontDictTracker);
  24883. fdArrayIndex.add(fontDictData);
  24884. fontDictTracker.offset(length);
  24885. }
  24886. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  24887. return {
  24888. trackers: fontDictTrackers,
  24889. output: fdArrayIndex
  24890. };
  24891. },
  24892. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  24893. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  24894. var fontDict = dicts[i];
  24895. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  24896. var privateDict = fontDict.privateDict;
  24897. var privateDictTracker = new CFFOffsetTracker();
  24898. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  24899. var outputLength = output.length;
  24900. privateDictTracker.offset(outputLength);
  24901. if (!privateDictData.length) {
  24902. outputLength = 0;
  24903. }
  24904. trackers[i].setEntryLocation('Private', [
  24905. privateDictData.length,
  24906. outputLength
  24907. ], output);
  24908. output.add(privateDictData);
  24909. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  24910. var subrs = this.compileIndex(privateDict.subrsIndex);
  24911. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  24912. output.add(subrs);
  24913. }
  24914. }
  24915. },
  24916. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  24917. var out = [];
  24918. var order = dict.order;
  24919. for (var i = 0; i < order.length; ++i) {
  24920. var key = order[i];
  24921. if (!(key in dict.values)) {
  24922. continue;
  24923. }
  24924. var values = dict.values[key];
  24925. var types = dict.types[key];
  24926. if (!isArray(types)) {
  24927. types = [types];
  24928. }
  24929. if (!isArray(values)) {
  24930. values = [values];
  24931. }
  24932. if (values.length === 0) {
  24933. continue;
  24934. }
  24935. for (var j = 0, jj = types.length; j < jj; ++j) {
  24936. var type = types[j];
  24937. var value = values[j];
  24938. switch (type) {
  24939. case 'num':
  24940. case 'sid':
  24941. out = out.concat(this.encodeNumber(value));
  24942. break;
  24943. case 'offset':
  24944. var name = dict.keyToNameMap[key];
  24945. if (!offsetTracker.isTracking(name)) {
  24946. offsetTracker.track(name, out.length);
  24947. }
  24948. out = out.concat([
  24949. 0x1d,
  24950. 0,
  24951. 0,
  24952. 0,
  24953. 0
  24954. ]);
  24955. break;
  24956. case 'array':
  24957. case 'delta':
  24958. out = out.concat(this.encodeNumber(value));
  24959. for (var k = 1, kk = values.length; k < kk; ++k) {
  24960. out = out.concat(this.encodeNumber(values[k]));
  24961. }
  24962. break;
  24963. default:
  24964. error('Unknown data type of ' + type);
  24965. break;
  24966. }
  24967. }
  24968. out = out.concat(dict.opcodes[key]);
  24969. }
  24970. return out;
  24971. },
  24972. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  24973. var stringIndex = new CFFIndex();
  24974. for (var i = 0, ii = strings.length; i < ii; ++i) {
  24975. stringIndex.add(stringToBytes(strings[i]));
  24976. }
  24977. return this.compileIndex(stringIndex);
  24978. },
  24979. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  24980. var globalSubrIndex = this.cff.globalSubrIndex;
  24981. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  24982. },
  24983. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  24984. return this.compileIndex(charStrings);
  24985. },
  24986. compileCharset: function CFFCompiler_compileCharset(charset) {
  24987. return this.compileTypedArray(charset.raw);
  24988. },
  24989. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  24990. return this.compileTypedArray(encoding.raw);
  24991. },
  24992. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  24993. return this.compileTypedArray(fdSelect);
  24994. },
  24995. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  24996. var out = [];
  24997. for (var i = 0, ii = data.length; i < ii; ++i) {
  24998. out[i] = data[i];
  24999. }
  25000. return out;
  25001. },
  25002. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  25003. trackers = trackers || [];
  25004. var objects = index.objects;
  25005. var count = objects.length;
  25006. if (count === 0) {
  25007. return [
  25008. 0,
  25009. 0,
  25010. 0
  25011. ];
  25012. }
  25013. var data = [
  25014. count >> 8 & 0xFF,
  25015. count & 0xff
  25016. ];
  25017. var lastOffset = 1, i;
  25018. for (i = 0; i < count; ++i) {
  25019. lastOffset += objects[i].length;
  25020. }
  25021. var offsetSize;
  25022. if (lastOffset < 0x100) {
  25023. offsetSize = 1;
  25024. } else if (lastOffset < 0x10000) {
  25025. offsetSize = 2;
  25026. } else if (lastOffset < 0x1000000) {
  25027. offsetSize = 3;
  25028. } else {
  25029. offsetSize = 4;
  25030. }
  25031. data.push(offsetSize);
  25032. var relativeOffset = 1;
  25033. for (i = 0; i < count + 1; i++) {
  25034. if (offsetSize === 1) {
  25035. data.push(relativeOffset & 0xFF);
  25036. } else if (offsetSize === 2) {
  25037. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  25038. } else if (offsetSize === 3) {
  25039. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  25040. } else {
  25041. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  25042. }
  25043. if (objects[i]) {
  25044. relativeOffset += objects[i].length;
  25045. }
  25046. }
  25047. for (i = 0; i < count; i++) {
  25048. if (trackers[i]) {
  25049. trackers[i].offset(data.length);
  25050. }
  25051. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  25052. data.push(objects[i][j]);
  25053. }
  25054. }
  25055. return data;
  25056. }
  25057. };
  25058. return CFFCompiler;
  25059. }();
  25060. exports.CFFStandardStrings = CFFStandardStrings;
  25061. exports.CFFParser = CFFParser;
  25062. exports.CFF = CFF;
  25063. exports.CFFHeader = CFFHeader;
  25064. exports.CFFStrings = CFFStrings;
  25065. exports.CFFIndex = CFFIndex;
  25066. exports.CFFCharset = CFFCharset;
  25067. exports.CFFTopDict = CFFTopDict;
  25068. exports.CFFPrivateDict = CFFPrivateDict;
  25069. exports.CFFCompiler = CFFCompiler;
  25070. /***/ }),
  25071. /* 15 */
  25072. /***/ (function(module, exports, __w_pdfjs_require__) {
  25073. "use strict";
  25074. var sharedUtil = __w_pdfjs_require__(0);
  25075. var MissingDataException = sharedUtil.MissingDataException;
  25076. var arrayByteLength = sharedUtil.arrayByteLength;
  25077. var arraysToBytes = sharedUtil.arraysToBytes;
  25078. var assert = sharedUtil.assert;
  25079. var createPromiseCapability = sharedUtil.createPromiseCapability;
  25080. var isInt = sharedUtil.isInt;
  25081. var isEmptyObj = sharedUtil.isEmptyObj;
  25082. var ChunkedStream = function ChunkedStreamClosure() {
  25083. function ChunkedStream(length, chunkSize, manager) {
  25084. this.bytes = new Uint8Array(length);
  25085. this.start = 0;
  25086. this.pos = 0;
  25087. this.end = length;
  25088. this.chunkSize = chunkSize;
  25089. this.loadedChunks = [];
  25090. this.numChunksLoaded = 0;
  25091. this.numChunks = Math.ceil(length / chunkSize);
  25092. this.manager = manager;
  25093. this.progressiveDataLength = 0;
  25094. this.lastSuccessfulEnsureByteChunk = -1;
  25095. }
  25096. ChunkedStream.prototype = {
  25097. getMissingChunks: function ChunkedStream_getMissingChunks() {
  25098. var chunks = [];
  25099. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  25100. if (!this.loadedChunks[chunk]) {
  25101. chunks.push(chunk);
  25102. }
  25103. }
  25104. return chunks;
  25105. },
  25106. getBaseStreams: function ChunkedStream_getBaseStreams() {
  25107. return [this];
  25108. },
  25109. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  25110. return this.numChunksLoaded === this.numChunks;
  25111. },
  25112. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  25113. var end = begin + chunk.byteLength;
  25114. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  25115. var length = this.bytes.length;
  25116. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  25117. this.bytes.set(new Uint8Array(chunk), begin);
  25118. var chunkSize = this.chunkSize;
  25119. var beginChunk = Math.floor(begin / chunkSize);
  25120. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  25121. var curChunk;
  25122. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  25123. if (!this.loadedChunks[curChunk]) {
  25124. this.loadedChunks[curChunk] = true;
  25125. ++this.numChunksLoaded;
  25126. }
  25127. }
  25128. },
  25129. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  25130. var position = this.progressiveDataLength;
  25131. var beginChunk = Math.floor(position / this.chunkSize);
  25132. this.bytes.set(new Uint8Array(data), position);
  25133. position += data.byteLength;
  25134. this.progressiveDataLength = position;
  25135. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  25136. var curChunk;
  25137. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  25138. if (!this.loadedChunks[curChunk]) {
  25139. this.loadedChunks[curChunk] = true;
  25140. ++this.numChunksLoaded;
  25141. }
  25142. }
  25143. },
  25144. ensureByte: function ChunkedStream_ensureByte(pos) {
  25145. var chunk = Math.floor(pos / this.chunkSize);
  25146. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  25147. return;
  25148. }
  25149. if (!this.loadedChunks[chunk]) {
  25150. throw new MissingDataException(pos, pos + 1);
  25151. }
  25152. this.lastSuccessfulEnsureByteChunk = chunk;
  25153. },
  25154. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  25155. if (begin >= end) {
  25156. return;
  25157. }
  25158. if (end <= this.progressiveDataLength) {
  25159. return;
  25160. }
  25161. var chunkSize = this.chunkSize;
  25162. var beginChunk = Math.floor(begin / chunkSize);
  25163. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  25164. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25165. if (!this.loadedChunks[chunk]) {
  25166. throw new MissingDataException(begin, end);
  25167. }
  25168. }
  25169. },
  25170. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  25171. var chunk, numChunks = this.numChunks;
  25172. for (var i = 0; i < numChunks; ++i) {
  25173. chunk = (beginChunk + i) % numChunks;
  25174. if (!this.loadedChunks[chunk]) {
  25175. return chunk;
  25176. }
  25177. }
  25178. return null;
  25179. },
  25180. hasChunk: function ChunkedStream_hasChunk(chunk) {
  25181. return !!this.loadedChunks[chunk];
  25182. },
  25183. get length() {
  25184. return this.end - this.start;
  25185. },
  25186. get isEmpty() {
  25187. return this.length === 0;
  25188. },
  25189. getByte: function ChunkedStream_getByte() {
  25190. var pos = this.pos;
  25191. if (pos >= this.end) {
  25192. return -1;
  25193. }
  25194. this.ensureByte(pos);
  25195. return this.bytes[this.pos++];
  25196. },
  25197. getUint16: function ChunkedStream_getUint16() {
  25198. var b0 = this.getByte();
  25199. var b1 = this.getByte();
  25200. if (b0 === -1 || b1 === -1) {
  25201. return -1;
  25202. }
  25203. return (b0 << 8) + b1;
  25204. },
  25205. getInt32: function ChunkedStream_getInt32() {
  25206. var b0 = this.getByte();
  25207. var b1 = this.getByte();
  25208. var b2 = this.getByte();
  25209. var b3 = this.getByte();
  25210. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  25211. },
  25212. getBytes: function ChunkedStream_getBytes(length) {
  25213. var bytes = this.bytes;
  25214. var pos = this.pos;
  25215. var strEnd = this.end;
  25216. if (!length) {
  25217. this.ensureRange(pos, strEnd);
  25218. return bytes.subarray(pos, strEnd);
  25219. }
  25220. var end = pos + length;
  25221. if (end > strEnd) {
  25222. end = strEnd;
  25223. }
  25224. this.ensureRange(pos, end);
  25225. this.pos = end;
  25226. return bytes.subarray(pos, end);
  25227. },
  25228. peekByte: function ChunkedStream_peekByte() {
  25229. var peekedByte = this.getByte();
  25230. this.pos--;
  25231. return peekedByte;
  25232. },
  25233. peekBytes: function ChunkedStream_peekBytes(length) {
  25234. var bytes = this.getBytes(length);
  25235. this.pos -= bytes.length;
  25236. return bytes;
  25237. },
  25238. getByteRange: function ChunkedStream_getBytes(begin, end) {
  25239. this.ensureRange(begin, end);
  25240. return this.bytes.subarray(begin, end);
  25241. },
  25242. skip: function ChunkedStream_skip(n) {
  25243. if (!n) {
  25244. n = 1;
  25245. }
  25246. this.pos += n;
  25247. },
  25248. reset: function ChunkedStream_reset() {
  25249. this.pos = this.start;
  25250. },
  25251. moveStart: function ChunkedStream_moveStart() {
  25252. this.start = this.pos;
  25253. },
  25254. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  25255. this.ensureRange(start, start + length);
  25256. function ChunkedStreamSubstream() {
  25257. }
  25258. ChunkedStreamSubstream.prototype = Object.create(this);
  25259. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  25260. var chunkSize = this.chunkSize;
  25261. var beginChunk = Math.floor(this.start / chunkSize);
  25262. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  25263. var missingChunks = [];
  25264. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25265. if (!this.loadedChunks[chunk]) {
  25266. missingChunks.push(chunk);
  25267. }
  25268. }
  25269. return missingChunks;
  25270. };
  25271. var subStream = new ChunkedStreamSubstream();
  25272. subStream.pos = subStream.start = start;
  25273. subStream.end = start + length || this.end;
  25274. subStream.dict = dict;
  25275. return subStream;
  25276. }
  25277. };
  25278. return ChunkedStream;
  25279. }();
  25280. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  25281. function ChunkedStreamManager(pdfNetworkStream, args) {
  25282. var chunkSize = args.rangeChunkSize;
  25283. var length = args.length;
  25284. this.stream = new ChunkedStream(length, chunkSize, this);
  25285. this.length = length;
  25286. this.chunkSize = chunkSize;
  25287. this.pdfNetworkStream = pdfNetworkStream;
  25288. this.url = args.url;
  25289. this.disableAutoFetch = args.disableAutoFetch;
  25290. this.msgHandler = args.msgHandler;
  25291. this.currRequestId = 0;
  25292. this.chunksNeededByRequest = Object.create(null);
  25293. this.requestsByChunk = Object.create(null);
  25294. this.promisesByRequest = Object.create(null);
  25295. this.progressiveDataLength = 0;
  25296. this.aborted = false;
  25297. this._loadedStreamCapability = createPromiseCapability();
  25298. }
  25299. ChunkedStreamManager.prototype = {
  25300. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  25301. return this._loadedStreamCapability.promise;
  25302. },
  25303. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  25304. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  25305. if (!rangeReader.isStreamingSupported) {
  25306. rangeReader.onProgress = this.onProgress.bind(this);
  25307. }
  25308. var chunks = [], loaded = 0;
  25309. var manager = this;
  25310. var promise = new Promise(function (resolve, reject) {
  25311. var readChunk = function (chunk) {
  25312. try {
  25313. if (!chunk.done) {
  25314. var data = chunk.value;
  25315. chunks.push(data);
  25316. loaded += arrayByteLength(data);
  25317. if (rangeReader.isStreamingSupported) {
  25318. manager.onProgress({ loaded: loaded });
  25319. }
  25320. rangeReader.read().then(readChunk, reject);
  25321. return;
  25322. }
  25323. var chunkData = arraysToBytes(chunks);
  25324. chunks = null;
  25325. resolve(chunkData);
  25326. } catch (e) {
  25327. reject(e);
  25328. }
  25329. };
  25330. rangeReader.read().then(readChunk, reject);
  25331. });
  25332. promise.then(function (data) {
  25333. if (this.aborted) {
  25334. return;
  25335. }
  25336. this.onReceiveData({
  25337. chunk: data,
  25338. begin: begin
  25339. });
  25340. }.bind(this));
  25341. },
  25342. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  25343. var missingChunks = this.stream.getMissingChunks();
  25344. this._requestChunks(missingChunks);
  25345. return this._loadedStreamCapability.promise;
  25346. },
  25347. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  25348. var requestId = this.currRequestId++;
  25349. var i, ii;
  25350. var chunksNeeded = Object.create(null);
  25351. this.chunksNeededByRequest[requestId] = chunksNeeded;
  25352. for (i = 0, ii = chunks.length; i < ii; i++) {
  25353. if (!this.stream.hasChunk(chunks[i])) {
  25354. chunksNeeded[chunks[i]] = true;
  25355. }
  25356. }
  25357. if (isEmptyObj(chunksNeeded)) {
  25358. return Promise.resolve();
  25359. }
  25360. var capability = createPromiseCapability();
  25361. this.promisesByRequest[requestId] = capability;
  25362. var chunksToRequest = [];
  25363. for (var chunk in chunksNeeded) {
  25364. chunk = chunk | 0;
  25365. if (!(chunk in this.requestsByChunk)) {
  25366. this.requestsByChunk[chunk] = [];
  25367. chunksToRequest.push(chunk);
  25368. }
  25369. this.requestsByChunk[chunk].push(requestId);
  25370. }
  25371. if (!chunksToRequest.length) {
  25372. return capability.promise;
  25373. }
  25374. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  25375. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  25376. var groupedChunk = groupedChunksToRequest[i];
  25377. var begin = groupedChunk.beginChunk * this.chunkSize;
  25378. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  25379. this.sendRequest(begin, end);
  25380. }
  25381. return capability.promise;
  25382. },
  25383. getStream: function ChunkedStreamManager_getStream() {
  25384. return this.stream;
  25385. },
  25386. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  25387. end = Math.min(end, this.length);
  25388. var beginChunk = this.getBeginChunk(begin);
  25389. var endChunk = this.getEndChunk(end);
  25390. var chunks = [];
  25391. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25392. chunks.push(chunk);
  25393. }
  25394. return this._requestChunks(chunks);
  25395. },
  25396. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  25397. ranges = ranges || [];
  25398. var chunksToRequest = [];
  25399. for (var i = 0; i < ranges.length; i++) {
  25400. var beginChunk = this.getBeginChunk(ranges[i].begin);
  25401. var endChunk = this.getEndChunk(ranges[i].end);
  25402. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  25403. if (chunksToRequest.indexOf(chunk) < 0) {
  25404. chunksToRequest.push(chunk);
  25405. }
  25406. }
  25407. }
  25408. chunksToRequest.sort(function (a, b) {
  25409. return a - b;
  25410. });
  25411. return this._requestChunks(chunksToRequest);
  25412. },
  25413. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  25414. var groupedChunks = [];
  25415. var beginChunk = -1;
  25416. var prevChunk = -1;
  25417. for (var i = 0; i < chunks.length; ++i) {
  25418. var chunk = chunks[i];
  25419. if (beginChunk < 0) {
  25420. beginChunk = chunk;
  25421. }
  25422. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  25423. groupedChunks.push({
  25424. beginChunk: beginChunk,
  25425. endChunk: prevChunk + 1
  25426. });
  25427. beginChunk = chunk;
  25428. }
  25429. if (i + 1 === chunks.length) {
  25430. groupedChunks.push({
  25431. beginChunk: beginChunk,
  25432. endChunk: chunk + 1
  25433. });
  25434. }
  25435. prevChunk = chunk;
  25436. }
  25437. return groupedChunks;
  25438. },
  25439. onProgress: function ChunkedStreamManager_onProgress(args) {
  25440. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  25441. this.msgHandler.send('DocProgress', {
  25442. loaded: bytesLoaded,
  25443. total: this.length
  25444. });
  25445. },
  25446. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  25447. var chunk = args.chunk;
  25448. var isProgressive = args.begin === undefined;
  25449. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  25450. var end = begin + chunk.byteLength;
  25451. var beginChunk = Math.floor(begin / this.chunkSize);
  25452. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  25453. if (isProgressive) {
  25454. this.stream.onReceiveProgressiveData(chunk);
  25455. this.progressiveDataLength = end;
  25456. } else {
  25457. this.stream.onReceiveData(begin, chunk);
  25458. }
  25459. if (this.stream.allChunksLoaded()) {
  25460. this._loadedStreamCapability.resolve(this.stream);
  25461. }
  25462. var loadedRequests = [];
  25463. var i, requestId;
  25464. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  25465. var requestIds = this.requestsByChunk[chunk] || [];
  25466. delete this.requestsByChunk[chunk];
  25467. for (i = 0; i < requestIds.length; ++i) {
  25468. requestId = requestIds[i];
  25469. var chunksNeeded = this.chunksNeededByRequest[requestId];
  25470. if (chunk in chunksNeeded) {
  25471. delete chunksNeeded[chunk];
  25472. }
  25473. if (!isEmptyObj(chunksNeeded)) {
  25474. continue;
  25475. }
  25476. loadedRequests.push(requestId);
  25477. }
  25478. }
  25479. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  25480. var nextEmptyChunk;
  25481. if (this.stream.numChunksLoaded === 1) {
  25482. var lastChunk = this.stream.numChunks - 1;
  25483. if (!this.stream.hasChunk(lastChunk)) {
  25484. nextEmptyChunk = lastChunk;
  25485. }
  25486. } else {
  25487. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  25488. }
  25489. if (isInt(nextEmptyChunk)) {
  25490. this._requestChunks([nextEmptyChunk]);
  25491. }
  25492. }
  25493. for (i = 0; i < loadedRequests.length; ++i) {
  25494. requestId = loadedRequests[i];
  25495. var capability = this.promisesByRequest[requestId];
  25496. delete this.promisesByRequest[requestId];
  25497. capability.resolve();
  25498. }
  25499. this.msgHandler.send('DocProgress', {
  25500. loaded: this.stream.numChunksLoaded * this.chunkSize,
  25501. total: this.length
  25502. });
  25503. },
  25504. onError: function ChunkedStreamManager_onError(err) {
  25505. this._loadedStreamCapability.reject(err);
  25506. },
  25507. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  25508. var chunk = Math.floor(begin / this.chunkSize);
  25509. return chunk;
  25510. },
  25511. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  25512. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  25513. return chunk;
  25514. },
  25515. abort: function ChunkedStreamManager_abort() {
  25516. this.aborted = true;
  25517. if (this.pdfNetworkStream) {
  25518. this.pdfNetworkStream.cancelAllRequests('abort');
  25519. }
  25520. for (var requestId in this.promisesByRequest) {
  25521. var capability = this.promisesByRequest[requestId];
  25522. capability.reject(new Error('Request was aborted'));
  25523. }
  25524. }
  25525. };
  25526. return ChunkedStreamManager;
  25527. }();
  25528. exports.ChunkedStream = ChunkedStream;
  25529. exports.ChunkedStreamManager = ChunkedStreamManager;
  25530. /***/ }),
  25531. /* 16 */
  25532. /***/ (function(module, exports, __w_pdfjs_require__) {
  25533. "use strict";
  25534. var sharedUtil = __w_pdfjs_require__(0);
  25535. var corePrimitives = __w_pdfjs_require__(1);
  25536. var coreStream = __w_pdfjs_require__(2);
  25537. var PasswordException = sharedUtil.PasswordException;
  25538. var PasswordResponses = sharedUtil.PasswordResponses;
  25539. var bytesToString = sharedUtil.bytesToString;
  25540. var warn = sharedUtil.warn;
  25541. var error = sharedUtil.error;
  25542. var assert = sharedUtil.assert;
  25543. var isInt = sharedUtil.isInt;
  25544. var stringToBytes = sharedUtil.stringToBytes;
  25545. var utf8StringToString = sharedUtil.utf8StringToString;
  25546. var Name = corePrimitives.Name;
  25547. var isName = corePrimitives.isName;
  25548. var isDict = corePrimitives.isDict;
  25549. var DecryptStream = coreStream.DecryptStream;
  25550. var ARCFourCipher = function ARCFourCipherClosure() {
  25551. function ARCFourCipher(key) {
  25552. this.a = 0;
  25553. this.b = 0;
  25554. var s = new Uint8Array(256);
  25555. var i, j = 0, tmp, keyLength = key.length;
  25556. for (i = 0; i < 256; ++i) {
  25557. s[i] = i;
  25558. }
  25559. for (i = 0; i < 256; ++i) {
  25560. tmp = s[i];
  25561. j = j + tmp + key[i % keyLength] & 0xFF;
  25562. s[i] = s[j];
  25563. s[j] = tmp;
  25564. }
  25565. this.s = s;
  25566. }
  25567. ARCFourCipher.prototype = {
  25568. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  25569. var i, n = data.length, tmp, tmp2;
  25570. var a = this.a, b = this.b, s = this.s;
  25571. var output = new Uint8Array(n);
  25572. for (i = 0; i < n; ++i) {
  25573. a = a + 1 & 0xFF;
  25574. tmp = s[a];
  25575. b = b + tmp & 0xFF;
  25576. tmp2 = s[b];
  25577. s[a] = tmp2;
  25578. s[b] = tmp;
  25579. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  25580. }
  25581. this.a = a;
  25582. this.b = b;
  25583. return output;
  25584. }
  25585. };
  25586. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  25587. return ARCFourCipher;
  25588. }();
  25589. var calculateMD5 = function calculateMD5Closure() {
  25590. var r = new Uint8Array([
  25591. 7,
  25592. 12,
  25593. 17,
  25594. 22,
  25595. 7,
  25596. 12,
  25597. 17,
  25598. 22,
  25599. 7,
  25600. 12,
  25601. 17,
  25602. 22,
  25603. 7,
  25604. 12,
  25605. 17,
  25606. 22,
  25607. 5,
  25608. 9,
  25609. 14,
  25610. 20,
  25611. 5,
  25612. 9,
  25613. 14,
  25614. 20,
  25615. 5,
  25616. 9,
  25617. 14,
  25618. 20,
  25619. 5,
  25620. 9,
  25621. 14,
  25622. 20,
  25623. 4,
  25624. 11,
  25625. 16,
  25626. 23,
  25627. 4,
  25628. 11,
  25629. 16,
  25630. 23,
  25631. 4,
  25632. 11,
  25633. 16,
  25634. 23,
  25635. 4,
  25636. 11,
  25637. 16,
  25638. 23,
  25639. 6,
  25640. 10,
  25641. 15,
  25642. 21,
  25643. 6,
  25644. 10,
  25645. 15,
  25646. 21,
  25647. 6,
  25648. 10,
  25649. 15,
  25650. 21,
  25651. 6,
  25652. 10,
  25653. 15,
  25654. 21
  25655. ]);
  25656. var k = new Int32Array([
  25657. -680876936,
  25658. -389564586,
  25659. 606105819,
  25660. -1044525330,
  25661. -176418897,
  25662. 1200080426,
  25663. -1473231341,
  25664. -45705983,
  25665. 1770035416,
  25666. -1958414417,
  25667. -42063,
  25668. -1990404162,
  25669. 1804603682,
  25670. -40341101,
  25671. -1502002290,
  25672. 1236535329,
  25673. -165796510,
  25674. -1069501632,
  25675. 643717713,
  25676. -373897302,
  25677. -701558691,
  25678. 38016083,
  25679. -660478335,
  25680. -405537848,
  25681. 568446438,
  25682. -1019803690,
  25683. -187363961,
  25684. 1163531501,
  25685. -1444681467,
  25686. -51403784,
  25687. 1735328473,
  25688. -1926607734,
  25689. -378558,
  25690. -2022574463,
  25691. 1839030562,
  25692. -35309556,
  25693. -1530992060,
  25694. 1272893353,
  25695. -155497632,
  25696. -1094730640,
  25697. 681279174,
  25698. -358537222,
  25699. -722521979,
  25700. 76029189,
  25701. -640364487,
  25702. -421815835,
  25703. 530742520,
  25704. -995338651,
  25705. -198630844,
  25706. 1126891415,
  25707. -1416354905,
  25708. -57434055,
  25709. 1700485571,
  25710. -1894986606,
  25711. -1051523,
  25712. -2054922799,
  25713. 1873313359,
  25714. -30611744,
  25715. -1560198380,
  25716. 1309151649,
  25717. -145523070,
  25718. -1120210379,
  25719. 718787259,
  25720. -343485551
  25721. ]);
  25722. function hash(data, offset, length) {
  25723. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  25724. var paddedLength = length + 72 & ~63;
  25725. var padded = new Uint8Array(paddedLength);
  25726. var i, j, n;
  25727. for (i = 0; i < length; ++i) {
  25728. padded[i] = data[offset++];
  25729. }
  25730. padded[i++] = 0x80;
  25731. n = paddedLength - 8;
  25732. while (i < n) {
  25733. padded[i++] = 0;
  25734. }
  25735. padded[i++] = length << 3 & 0xFF;
  25736. padded[i++] = length >> 5 & 0xFF;
  25737. padded[i++] = length >> 13 & 0xFF;
  25738. padded[i++] = length >> 21 & 0xFF;
  25739. padded[i++] = length >>> 29 & 0xFF;
  25740. padded[i++] = 0;
  25741. padded[i++] = 0;
  25742. padded[i++] = 0;
  25743. var w = new Int32Array(16);
  25744. for (i = 0; i < paddedLength;) {
  25745. for (j = 0; j < 16; ++j, i += 4) {
  25746. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  25747. }
  25748. var a = h0, b = h1, c = h2, d = h3, f, g;
  25749. for (j = 0; j < 64; ++j) {
  25750. if (j < 16) {
  25751. f = b & c | ~b & d;
  25752. g = j;
  25753. } else if (j < 32) {
  25754. f = d & b | ~d & c;
  25755. g = 5 * j + 1 & 15;
  25756. } else if (j < 48) {
  25757. f = b ^ c ^ d;
  25758. g = 3 * j + 5 & 15;
  25759. } else {
  25760. f = c ^ (b | ~d);
  25761. g = 7 * j & 15;
  25762. }
  25763. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  25764. d = c;
  25765. c = b;
  25766. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  25767. a = tmp;
  25768. }
  25769. h0 = h0 + a | 0;
  25770. h1 = h1 + b | 0;
  25771. h2 = h2 + c | 0;
  25772. h3 = h3 + d | 0;
  25773. }
  25774. return new Uint8Array([
  25775. h0 & 0xFF,
  25776. h0 >> 8 & 0xFF,
  25777. h0 >> 16 & 0xFF,
  25778. h0 >>> 24 & 0xFF,
  25779. h1 & 0xFF,
  25780. h1 >> 8 & 0xFF,
  25781. h1 >> 16 & 0xFF,
  25782. h1 >>> 24 & 0xFF,
  25783. h2 & 0xFF,
  25784. h2 >> 8 & 0xFF,
  25785. h2 >> 16 & 0xFF,
  25786. h2 >>> 24 & 0xFF,
  25787. h3 & 0xFF,
  25788. h3 >> 8 & 0xFF,
  25789. h3 >> 16 & 0xFF,
  25790. h3 >>> 24 & 0xFF
  25791. ]);
  25792. }
  25793. return hash;
  25794. }();
  25795. var Word64 = function Word64Closure() {
  25796. function Word64(highInteger, lowInteger) {
  25797. this.high = highInteger | 0;
  25798. this.low = lowInteger | 0;
  25799. }
  25800. Word64.prototype = {
  25801. and: function Word64_and(word) {
  25802. this.high &= word.high;
  25803. this.low &= word.low;
  25804. },
  25805. xor: function Word64_xor(word) {
  25806. this.high ^= word.high;
  25807. this.low ^= word.low;
  25808. },
  25809. or: function Word64_or(word) {
  25810. this.high |= word.high;
  25811. this.low |= word.low;
  25812. },
  25813. shiftRight: function Word64_shiftRight(places) {
  25814. if (places >= 32) {
  25815. this.low = this.high >>> places - 32 | 0;
  25816. this.high = 0;
  25817. } else {
  25818. this.low = this.low >>> places | this.high << 32 - places;
  25819. this.high = this.high >>> places | 0;
  25820. }
  25821. },
  25822. shiftLeft: function Word64_shiftLeft(places) {
  25823. if (places >= 32) {
  25824. this.high = this.low << places - 32;
  25825. this.low = 0;
  25826. } else {
  25827. this.high = this.high << places | this.low >>> 32 - places;
  25828. this.low = this.low << places;
  25829. }
  25830. },
  25831. rotateRight: function Word64_rotateRight(places) {
  25832. var low, high;
  25833. if (places & 32) {
  25834. high = this.low;
  25835. low = this.high;
  25836. } else {
  25837. low = this.low;
  25838. high = this.high;
  25839. }
  25840. places &= 31;
  25841. this.low = low >>> places | high << 32 - places;
  25842. this.high = high >>> places | low << 32 - places;
  25843. },
  25844. not: function Word64_not() {
  25845. this.high = ~this.high;
  25846. this.low = ~this.low;
  25847. },
  25848. add: function Word64_add(word) {
  25849. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  25850. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  25851. if (lowAdd > 0xFFFFFFFF) {
  25852. highAdd += 1;
  25853. }
  25854. this.low = lowAdd | 0;
  25855. this.high = highAdd | 0;
  25856. },
  25857. copyTo: function Word64_copyTo(bytes, offset) {
  25858. bytes[offset] = this.high >>> 24 & 0xFF;
  25859. bytes[offset + 1] = this.high >> 16 & 0xFF;
  25860. bytes[offset + 2] = this.high >> 8 & 0xFF;
  25861. bytes[offset + 3] = this.high & 0xFF;
  25862. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  25863. bytes[offset + 5] = this.low >> 16 & 0xFF;
  25864. bytes[offset + 6] = this.low >> 8 & 0xFF;
  25865. bytes[offset + 7] = this.low & 0xFF;
  25866. },
  25867. assign: function Word64_assign(word) {
  25868. this.high = word.high;
  25869. this.low = word.low;
  25870. }
  25871. };
  25872. return Word64;
  25873. }();
  25874. var calculateSHA256 = function calculateSHA256Closure() {
  25875. function rotr(x, n) {
  25876. return x >>> n | x << 32 - n;
  25877. }
  25878. function ch(x, y, z) {
  25879. return x & y ^ ~x & z;
  25880. }
  25881. function maj(x, y, z) {
  25882. return x & y ^ x & z ^ y & z;
  25883. }
  25884. function sigma(x) {
  25885. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  25886. }
  25887. function sigmaPrime(x) {
  25888. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  25889. }
  25890. function littleSigma(x) {
  25891. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  25892. }
  25893. function littleSigmaPrime(x) {
  25894. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  25895. }
  25896. var k = [
  25897. 0x428a2f98,
  25898. 0x71374491,
  25899. 0xb5c0fbcf,
  25900. 0xe9b5dba5,
  25901. 0x3956c25b,
  25902. 0x59f111f1,
  25903. 0x923f82a4,
  25904. 0xab1c5ed5,
  25905. 0xd807aa98,
  25906. 0x12835b01,
  25907. 0x243185be,
  25908. 0x550c7dc3,
  25909. 0x72be5d74,
  25910. 0x80deb1fe,
  25911. 0x9bdc06a7,
  25912. 0xc19bf174,
  25913. 0xe49b69c1,
  25914. 0xefbe4786,
  25915. 0x0fc19dc6,
  25916. 0x240ca1cc,
  25917. 0x2de92c6f,
  25918. 0x4a7484aa,
  25919. 0x5cb0a9dc,
  25920. 0x76f988da,
  25921. 0x983e5152,
  25922. 0xa831c66d,
  25923. 0xb00327c8,
  25924. 0xbf597fc7,
  25925. 0xc6e00bf3,
  25926. 0xd5a79147,
  25927. 0x06ca6351,
  25928. 0x14292967,
  25929. 0x27b70a85,
  25930. 0x2e1b2138,
  25931. 0x4d2c6dfc,
  25932. 0x53380d13,
  25933. 0x650a7354,
  25934. 0x766a0abb,
  25935. 0x81c2c92e,
  25936. 0x92722c85,
  25937. 0xa2bfe8a1,
  25938. 0xa81a664b,
  25939. 0xc24b8b70,
  25940. 0xc76c51a3,
  25941. 0xd192e819,
  25942. 0xd6990624,
  25943. 0xf40e3585,
  25944. 0x106aa070,
  25945. 0x19a4c116,
  25946. 0x1e376c08,
  25947. 0x2748774c,
  25948. 0x34b0bcb5,
  25949. 0x391c0cb3,
  25950. 0x4ed8aa4a,
  25951. 0x5b9cca4f,
  25952. 0x682e6ff3,
  25953. 0x748f82ee,
  25954. 0x78a5636f,
  25955. 0x84c87814,
  25956. 0x8cc70208,
  25957. 0x90befffa,
  25958. 0xa4506ceb,
  25959. 0xbef9a3f7,
  25960. 0xc67178f2
  25961. ];
  25962. function hash(data, offset, length) {
  25963. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  25964. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  25965. var padded = new Uint8Array(paddedLength);
  25966. var i, j, n;
  25967. for (i = 0; i < length; ++i) {
  25968. padded[i] = data[offset++];
  25969. }
  25970. padded[i++] = 0x80;
  25971. n = paddedLength - 8;
  25972. while (i < n) {
  25973. padded[i++] = 0;
  25974. }
  25975. padded[i++] = 0;
  25976. padded[i++] = 0;
  25977. padded[i++] = 0;
  25978. padded[i++] = length >>> 29 & 0xFF;
  25979. padded[i++] = length >> 21 & 0xFF;
  25980. padded[i++] = length >> 13 & 0xFF;
  25981. padded[i++] = length >> 5 & 0xFF;
  25982. padded[i++] = length << 3 & 0xFF;
  25983. var w = new Uint32Array(64);
  25984. for (i = 0; i < paddedLength;) {
  25985. for (j = 0; j < 16; ++j) {
  25986. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  25987. i += 4;
  25988. }
  25989. for (j = 16; j < 64; ++j) {
  25990. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  25991. }
  25992. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  25993. for (j = 0; j < 64; ++j) {
  25994. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  25995. t2 = sigma(a) + maj(a, b, c);
  25996. h = g;
  25997. g = f;
  25998. f = e;
  25999. e = d + t1 | 0;
  26000. d = c;
  26001. c = b;
  26002. b = a;
  26003. a = t1 + t2 | 0;
  26004. }
  26005. h0 = h0 + a | 0;
  26006. h1 = h1 + b | 0;
  26007. h2 = h2 + c | 0;
  26008. h3 = h3 + d | 0;
  26009. h4 = h4 + e | 0;
  26010. h5 = h5 + f | 0;
  26011. h6 = h6 + g | 0;
  26012. h7 = h7 + h | 0;
  26013. }
  26014. return new Uint8Array([
  26015. h0 >> 24 & 0xFF,
  26016. h0 >> 16 & 0xFF,
  26017. h0 >> 8 & 0xFF,
  26018. h0 & 0xFF,
  26019. h1 >> 24 & 0xFF,
  26020. h1 >> 16 & 0xFF,
  26021. h1 >> 8 & 0xFF,
  26022. h1 & 0xFF,
  26023. h2 >> 24 & 0xFF,
  26024. h2 >> 16 & 0xFF,
  26025. h2 >> 8 & 0xFF,
  26026. h2 & 0xFF,
  26027. h3 >> 24 & 0xFF,
  26028. h3 >> 16 & 0xFF,
  26029. h3 >> 8 & 0xFF,
  26030. h3 & 0xFF,
  26031. h4 >> 24 & 0xFF,
  26032. h4 >> 16 & 0xFF,
  26033. h4 >> 8 & 0xFF,
  26034. h4 & 0xFF,
  26035. h5 >> 24 & 0xFF,
  26036. h5 >> 16 & 0xFF,
  26037. h5 >> 8 & 0xFF,
  26038. h5 & 0xFF,
  26039. h6 >> 24 & 0xFF,
  26040. h6 >> 16 & 0xFF,
  26041. h6 >> 8 & 0xFF,
  26042. h6 & 0xFF,
  26043. h7 >> 24 & 0xFF,
  26044. h7 >> 16 & 0xFF,
  26045. h7 >> 8 & 0xFF,
  26046. h7 & 0xFF
  26047. ]);
  26048. }
  26049. return hash;
  26050. }();
  26051. var calculateSHA512 = function calculateSHA512Closure() {
  26052. function ch(result, x, y, z, tmp) {
  26053. result.assign(x);
  26054. result.and(y);
  26055. tmp.assign(x);
  26056. tmp.not();
  26057. tmp.and(z);
  26058. result.xor(tmp);
  26059. }
  26060. function maj(result, x, y, z, tmp) {
  26061. result.assign(x);
  26062. result.and(y);
  26063. tmp.assign(x);
  26064. tmp.and(z);
  26065. result.xor(tmp);
  26066. tmp.assign(y);
  26067. tmp.and(z);
  26068. result.xor(tmp);
  26069. }
  26070. function sigma(result, x, tmp) {
  26071. result.assign(x);
  26072. result.rotateRight(28);
  26073. tmp.assign(x);
  26074. tmp.rotateRight(34);
  26075. result.xor(tmp);
  26076. tmp.assign(x);
  26077. tmp.rotateRight(39);
  26078. result.xor(tmp);
  26079. }
  26080. function sigmaPrime(result, x, tmp) {
  26081. result.assign(x);
  26082. result.rotateRight(14);
  26083. tmp.assign(x);
  26084. tmp.rotateRight(18);
  26085. result.xor(tmp);
  26086. tmp.assign(x);
  26087. tmp.rotateRight(41);
  26088. result.xor(tmp);
  26089. }
  26090. function littleSigma(result, x, tmp) {
  26091. result.assign(x);
  26092. result.rotateRight(1);
  26093. tmp.assign(x);
  26094. tmp.rotateRight(8);
  26095. result.xor(tmp);
  26096. tmp.assign(x);
  26097. tmp.shiftRight(7);
  26098. result.xor(tmp);
  26099. }
  26100. function littleSigmaPrime(result, x, tmp) {
  26101. result.assign(x);
  26102. result.rotateRight(19);
  26103. tmp.assign(x);
  26104. tmp.rotateRight(61);
  26105. result.xor(tmp);
  26106. tmp.assign(x);
  26107. tmp.shiftRight(6);
  26108. result.xor(tmp);
  26109. }
  26110. var k = [
  26111. new Word64(0x428a2f98, 0xd728ae22),
  26112. new Word64(0x71374491, 0x23ef65cd),
  26113. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  26114. new Word64(0xe9b5dba5, 0x8189dbbc),
  26115. new Word64(0x3956c25b, 0xf348b538),
  26116. new Word64(0x59f111f1, 0xb605d019),
  26117. new Word64(0x923f82a4, 0xaf194f9b),
  26118. new Word64(0xab1c5ed5, 0xda6d8118),
  26119. new Word64(0xd807aa98, 0xa3030242),
  26120. new Word64(0x12835b01, 0x45706fbe),
  26121. new Word64(0x243185be, 0x4ee4b28c),
  26122. new Word64(0x550c7dc3, 0xd5ffb4e2),
  26123. new Word64(0x72be5d74, 0xf27b896f),
  26124. new Word64(0x80deb1fe, 0x3b1696b1),
  26125. new Word64(0x9bdc06a7, 0x25c71235),
  26126. new Word64(0xc19bf174, 0xcf692694),
  26127. new Word64(0xe49b69c1, 0x9ef14ad2),
  26128. new Word64(0xefbe4786, 0x384f25e3),
  26129. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  26130. new Word64(0x240ca1cc, 0x77ac9c65),
  26131. new Word64(0x2de92c6f, 0x592b0275),
  26132. new Word64(0x4a7484aa, 0x6ea6e483),
  26133. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  26134. new Word64(0x76f988da, 0x831153b5),
  26135. new Word64(0x983e5152, 0xee66dfab),
  26136. new Word64(0xa831c66d, 0x2db43210),
  26137. new Word64(0xb00327c8, 0x98fb213f),
  26138. new Word64(0xbf597fc7, 0xbeef0ee4),
  26139. new Word64(0xc6e00bf3, 0x3da88fc2),
  26140. new Word64(0xd5a79147, 0x930aa725),
  26141. new Word64(0x06ca6351, 0xe003826f),
  26142. new Word64(0x14292967, 0x0a0e6e70),
  26143. new Word64(0x27b70a85, 0x46d22ffc),
  26144. new Word64(0x2e1b2138, 0x5c26c926),
  26145. new Word64(0x4d2c6dfc, 0x5ac42aed),
  26146. new Word64(0x53380d13, 0x9d95b3df),
  26147. new Word64(0x650a7354, 0x8baf63de),
  26148. new Word64(0x766a0abb, 0x3c77b2a8),
  26149. new Word64(0x81c2c92e, 0x47edaee6),
  26150. new Word64(0x92722c85, 0x1482353b),
  26151. new Word64(0xa2bfe8a1, 0x4cf10364),
  26152. new Word64(0xa81a664b, 0xbc423001),
  26153. new Word64(0xc24b8b70, 0xd0f89791),
  26154. new Word64(0xc76c51a3, 0x0654be30),
  26155. new Word64(0xd192e819, 0xd6ef5218),
  26156. new Word64(0xd6990624, 0x5565a910),
  26157. new Word64(0xf40e3585, 0x5771202a),
  26158. new Word64(0x106aa070, 0x32bbd1b8),
  26159. new Word64(0x19a4c116, 0xb8d2d0c8),
  26160. new Word64(0x1e376c08, 0x5141ab53),
  26161. new Word64(0x2748774c, 0xdf8eeb99),
  26162. new Word64(0x34b0bcb5, 0xe19b48a8),
  26163. new Word64(0x391c0cb3, 0xc5c95a63),
  26164. new Word64(0x4ed8aa4a, 0xe3418acb),
  26165. new Word64(0x5b9cca4f, 0x7763e373),
  26166. new Word64(0x682e6ff3, 0xd6b2b8a3),
  26167. new Word64(0x748f82ee, 0x5defb2fc),
  26168. new Word64(0x78a5636f, 0x43172f60),
  26169. new Word64(0x84c87814, 0xa1f0ab72),
  26170. new Word64(0x8cc70208, 0x1a6439ec),
  26171. new Word64(0x90befffa, 0x23631e28),
  26172. new Word64(0xa4506ceb, 0xde82bde9),
  26173. new Word64(0xbef9a3f7, 0xb2c67915),
  26174. new Word64(0xc67178f2, 0xe372532b),
  26175. new Word64(0xca273ece, 0xea26619c),
  26176. new Word64(0xd186b8c7, 0x21c0c207),
  26177. new Word64(0xeada7dd6, 0xcde0eb1e),
  26178. new Word64(0xf57d4f7f, 0xee6ed178),
  26179. new Word64(0x06f067aa, 0x72176fba),
  26180. new Word64(0x0a637dc5, 0xa2c898a6),
  26181. new Word64(0x113f9804, 0xbef90dae),
  26182. new Word64(0x1b710b35, 0x131c471b),
  26183. new Word64(0x28db77f5, 0x23047d84),
  26184. new Word64(0x32caab7b, 0x40c72493),
  26185. new Word64(0x3c9ebe0a, 0x15c9bebc),
  26186. new Word64(0x431d67c4, 0x9c100d4c),
  26187. new Word64(0x4cc5d4be, 0xcb3e42b6),
  26188. new Word64(0x597f299c, 0xfc657e2a),
  26189. new Word64(0x5fcb6fab, 0x3ad6faec),
  26190. new Word64(0x6c44198c, 0x4a475817)
  26191. ];
  26192. function hash(data, offset, length, mode384) {
  26193. mode384 = !!mode384;
  26194. var h0, h1, h2, h3, h4, h5, h6, h7;
  26195. if (!mode384) {
  26196. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  26197. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  26198. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  26199. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  26200. h4 = new Word64(0x510e527f, 0xade682d1);
  26201. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  26202. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  26203. h7 = new Word64(0x5be0cd19, 0x137e2179);
  26204. } else {
  26205. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  26206. h1 = new Word64(0x629a292a, 0x367cd507);
  26207. h2 = new Word64(0x9159015a, 0x3070dd17);
  26208. h3 = new Word64(0x152fecd8, 0xf70e5939);
  26209. h4 = new Word64(0x67332667, 0xffc00b31);
  26210. h5 = new Word64(0x8eb44a87, 0x68581511);
  26211. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  26212. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  26213. }
  26214. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  26215. var padded = new Uint8Array(paddedLength);
  26216. var i, j, n;
  26217. for (i = 0; i < length; ++i) {
  26218. padded[i] = data[offset++];
  26219. }
  26220. padded[i++] = 0x80;
  26221. n = paddedLength - 16;
  26222. while (i < n) {
  26223. padded[i++] = 0;
  26224. }
  26225. padded[i++] = 0;
  26226. padded[i++] = 0;
  26227. padded[i++] = 0;
  26228. padded[i++] = 0;
  26229. padded[i++] = 0;
  26230. padded[i++] = 0;
  26231. padded[i++] = 0;
  26232. padded[i++] = 0;
  26233. padded[i++] = 0;
  26234. padded[i++] = 0;
  26235. padded[i++] = 0;
  26236. padded[i++] = length >>> 29 & 0xFF;
  26237. padded[i++] = length >> 21 & 0xFF;
  26238. padded[i++] = length >> 13 & 0xFF;
  26239. padded[i++] = length >> 5 & 0xFF;
  26240. padded[i++] = length << 3 & 0xFF;
  26241. var w = new Array(80);
  26242. for (i = 0; i < 80; i++) {
  26243. w[i] = new Word64(0, 0);
  26244. }
  26245. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  26246. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  26247. var g = new Word64(0, 0), h = new Word64(0, 0);
  26248. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  26249. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  26250. for (i = 0; i < paddedLength;) {
  26251. for (j = 0; j < 16; ++j) {
  26252. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  26253. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  26254. i += 8;
  26255. }
  26256. for (j = 16; j < 80; ++j) {
  26257. tmp3 = w[j];
  26258. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  26259. tmp3.add(w[j - 7]);
  26260. littleSigma(tmp1, w[j - 15], tmp2);
  26261. tmp3.add(tmp1);
  26262. tmp3.add(w[j - 16]);
  26263. }
  26264. a.assign(h0);
  26265. b.assign(h1);
  26266. c.assign(h2);
  26267. d.assign(h3);
  26268. e.assign(h4);
  26269. f.assign(h5);
  26270. g.assign(h6);
  26271. h.assign(h7);
  26272. for (j = 0; j < 80; ++j) {
  26273. t1.assign(h);
  26274. sigmaPrime(tmp1, e, tmp2);
  26275. t1.add(tmp1);
  26276. ch(tmp1, e, f, g, tmp2);
  26277. t1.add(tmp1);
  26278. t1.add(k[j]);
  26279. t1.add(w[j]);
  26280. sigma(t2, a, tmp2);
  26281. maj(tmp1, a, b, c, tmp2);
  26282. t2.add(tmp1);
  26283. tmp3 = h;
  26284. h = g;
  26285. g = f;
  26286. f = e;
  26287. d.add(t1);
  26288. e = d;
  26289. d = c;
  26290. c = b;
  26291. b = a;
  26292. tmp3.assign(t1);
  26293. tmp3.add(t2);
  26294. a = tmp3;
  26295. }
  26296. h0.add(a);
  26297. h1.add(b);
  26298. h2.add(c);
  26299. h3.add(d);
  26300. h4.add(e);
  26301. h5.add(f);
  26302. h6.add(g);
  26303. h7.add(h);
  26304. }
  26305. var result;
  26306. if (!mode384) {
  26307. result = new Uint8Array(64);
  26308. h0.copyTo(result, 0);
  26309. h1.copyTo(result, 8);
  26310. h2.copyTo(result, 16);
  26311. h3.copyTo(result, 24);
  26312. h4.copyTo(result, 32);
  26313. h5.copyTo(result, 40);
  26314. h6.copyTo(result, 48);
  26315. h7.copyTo(result, 56);
  26316. } else {
  26317. result = new Uint8Array(48);
  26318. h0.copyTo(result, 0);
  26319. h1.copyTo(result, 8);
  26320. h2.copyTo(result, 16);
  26321. h3.copyTo(result, 24);
  26322. h4.copyTo(result, 32);
  26323. h5.copyTo(result, 40);
  26324. }
  26325. return result;
  26326. }
  26327. return hash;
  26328. }();
  26329. var calculateSHA384 = function calculateSHA384Closure() {
  26330. function hash(data, offset, length) {
  26331. return calculateSHA512(data, offset, length, true);
  26332. }
  26333. return hash;
  26334. }();
  26335. var NullCipher = function NullCipherClosure() {
  26336. function NullCipher() {
  26337. }
  26338. NullCipher.prototype = {
  26339. decryptBlock: function NullCipher_decryptBlock(data) {
  26340. return data;
  26341. }
  26342. };
  26343. return NullCipher;
  26344. }();
  26345. var AES128Cipher = function AES128CipherClosure() {
  26346. var rcon = new Uint8Array([
  26347. 0x8d,
  26348. 0x01,
  26349. 0x02,
  26350. 0x04,
  26351. 0x08,
  26352. 0x10,
  26353. 0x20,
  26354. 0x40,
  26355. 0x80,
  26356. 0x1b,
  26357. 0x36,
  26358. 0x6c,
  26359. 0xd8,
  26360. 0xab,
  26361. 0x4d,
  26362. 0x9a,
  26363. 0x2f,
  26364. 0x5e,
  26365. 0xbc,
  26366. 0x63,
  26367. 0xc6,
  26368. 0x97,
  26369. 0x35,
  26370. 0x6a,
  26371. 0xd4,
  26372. 0xb3,
  26373. 0x7d,
  26374. 0xfa,
  26375. 0xef,
  26376. 0xc5,
  26377. 0x91,
  26378. 0x39,
  26379. 0x72,
  26380. 0xe4,
  26381. 0xd3,
  26382. 0xbd,
  26383. 0x61,
  26384. 0xc2,
  26385. 0x9f,
  26386. 0x25,
  26387. 0x4a,
  26388. 0x94,
  26389. 0x33,
  26390. 0x66,
  26391. 0xcc,
  26392. 0x83,
  26393. 0x1d,
  26394. 0x3a,
  26395. 0x74,
  26396. 0xe8,
  26397. 0xcb,
  26398. 0x8d,
  26399. 0x01,
  26400. 0x02,
  26401. 0x04,
  26402. 0x08,
  26403. 0x10,
  26404. 0x20,
  26405. 0x40,
  26406. 0x80,
  26407. 0x1b,
  26408. 0x36,
  26409. 0x6c,
  26410. 0xd8,
  26411. 0xab,
  26412. 0x4d,
  26413. 0x9a,
  26414. 0x2f,
  26415. 0x5e,
  26416. 0xbc,
  26417. 0x63,
  26418. 0xc6,
  26419. 0x97,
  26420. 0x35,
  26421. 0x6a,
  26422. 0xd4,
  26423. 0xb3,
  26424. 0x7d,
  26425. 0xfa,
  26426. 0xef,
  26427. 0xc5,
  26428. 0x91,
  26429. 0x39,
  26430. 0x72,
  26431. 0xe4,
  26432. 0xd3,
  26433. 0xbd,
  26434. 0x61,
  26435. 0xc2,
  26436. 0x9f,
  26437. 0x25,
  26438. 0x4a,
  26439. 0x94,
  26440. 0x33,
  26441. 0x66,
  26442. 0xcc,
  26443. 0x83,
  26444. 0x1d,
  26445. 0x3a,
  26446. 0x74,
  26447. 0xe8,
  26448. 0xcb,
  26449. 0x8d,
  26450. 0x01,
  26451. 0x02,
  26452. 0x04,
  26453. 0x08,
  26454. 0x10,
  26455. 0x20,
  26456. 0x40,
  26457. 0x80,
  26458. 0x1b,
  26459. 0x36,
  26460. 0x6c,
  26461. 0xd8,
  26462. 0xab,
  26463. 0x4d,
  26464. 0x9a,
  26465. 0x2f,
  26466. 0x5e,
  26467. 0xbc,
  26468. 0x63,
  26469. 0xc6,
  26470. 0x97,
  26471. 0x35,
  26472. 0x6a,
  26473. 0xd4,
  26474. 0xb3,
  26475. 0x7d,
  26476. 0xfa,
  26477. 0xef,
  26478. 0xc5,
  26479. 0x91,
  26480. 0x39,
  26481. 0x72,
  26482. 0xe4,
  26483. 0xd3,
  26484. 0xbd,
  26485. 0x61,
  26486. 0xc2,
  26487. 0x9f,
  26488. 0x25,
  26489. 0x4a,
  26490. 0x94,
  26491. 0x33,
  26492. 0x66,
  26493. 0xcc,
  26494. 0x83,
  26495. 0x1d,
  26496. 0x3a,
  26497. 0x74,
  26498. 0xe8,
  26499. 0xcb,
  26500. 0x8d,
  26501. 0x01,
  26502. 0x02,
  26503. 0x04,
  26504. 0x08,
  26505. 0x10,
  26506. 0x20,
  26507. 0x40,
  26508. 0x80,
  26509. 0x1b,
  26510. 0x36,
  26511. 0x6c,
  26512. 0xd8,
  26513. 0xab,
  26514. 0x4d,
  26515. 0x9a,
  26516. 0x2f,
  26517. 0x5e,
  26518. 0xbc,
  26519. 0x63,
  26520. 0xc6,
  26521. 0x97,
  26522. 0x35,
  26523. 0x6a,
  26524. 0xd4,
  26525. 0xb3,
  26526. 0x7d,
  26527. 0xfa,
  26528. 0xef,
  26529. 0xc5,
  26530. 0x91,
  26531. 0x39,
  26532. 0x72,
  26533. 0xe4,
  26534. 0xd3,
  26535. 0xbd,
  26536. 0x61,
  26537. 0xc2,
  26538. 0x9f,
  26539. 0x25,
  26540. 0x4a,
  26541. 0x94,
  26542. 0x33,
  26543. 0x66,
  26544. 0xcc,
  26545. 0x83,
  26546. 0x1d,
  26547. 0x3a,
  26548. 0x74,
  26549. 0xe8,
  26550. 0xcb,
  26551. 0x8d,
  26552. 0x01,
  26553. 0x02,
  26554. 0x04,
  26555. 0x08,
  26556. 0x10,
  26557. 0x20,
  26558. 0x40,
  26559. 0x80,
  26560. 0x1b,
  26561. 0x36,
  26562. 0x6c,
  26563. 0xd8,
  26564. 0xab,
  26565. 0x4d,
  26566. 0x9a,
  26567. 0x2f,
  26568. 0x5e,
  26569. 0xbc,
  26570. 0x63,
  26571. 0xc6,
  26572. 0x97,
  26573. 0x35,
  26574. 0x6a,
  26575. 0xd4,
  26576. 0xb3,
  26577. 0x7d,
  26578. 0xfa,
  26579. 0xef,
  26580. 0xc5,
  26581. 0x91,
  26582. 0x39,
  26583. 0x72,
  26584. 0xe4,
  26585. 0xd3,
  26586. 0xbd,
  26587. 0x61,
  26588. 0xc2,
  26589. 0x9f,
  26590. 0x25,
  26591. 0x4a,
  26592. 0x94,
  26593. 0x33,
  26594. 0x66,
  26595. 0xcc,
  26596. 0x83,
  26597. 0x1d,
  26598. 0x3a,
  26599. 0x74,
  26600. 0xe8,
  26601. 0xcb,
  26602. 0x8d
  26603. ]);
  26604. var s = new Uint8Array([
  26605. 0x63,
  26606. 0x7c,
  26607. 0x77,
  26608. 0x7b,
  26609. 0xf2,
  26610. 0x6b,
  26611. 0x6f,
  26612. 0xc5,
  26613. 0x30,
  26614. 0x01,
  26615. 0x67,
  26616. 0x2b,
  26617. 0xfe,
  26618. 0xd7,
  26619. 0xab,
  26620. 0x76,
  26621. 0xca,
  26622. 0x82,
  26623. 0xc9,
  26624. 0x7d,
  26625. 0xfa,
  26626. 0x59,
  26627. 0x47,
  26628. 0xf0,
  26629. 0xad,
  26630. 0xd4,
  26631. 0xa2,
  26632. 0xaf,
  26633. 0x9c,
  26634. 0xa4,
  26635. 0x72,
  26636. 0xc0,
  26637. 0xb7,
  26638. 0xfd,
  26639. 0x93,
  26640. 0x26,
  26641. 0x36,
  26642. 0x3f,
  26643. 0xf7,
  26644. 0xcc,
  26645. 0x34,
  26646. 0xa5,
  26647. 0xe5,
  26648. 0xf1,
  26649. 0x71,
  26650. 0xd8,
  26651. 0x31,
  26652. 0x15,
  26653. 0x04,
  26654. 0xc7,
  26655. 0x23,
  26656. 0xc3,
  26657. 0x18,
  26658. 0x96,
  26659. 0x05,
  26660. 0x9a,
  26661. 0x07,
  26662. 0x12,
  26663. 0x80,
  26664. 0xe2,
  26665. 0xeb,
  26666. 0x27,
  26667. 0xb2,
  26668. 0x75,
  26669. 0x09,
  26670. 0x83,
  26671. 0x2c,
  26672. 0x1a,
  26673. 0x1b,
  26674. 0x6e,
  26675. 0x5a,
  26676. 0xa0,
  26677. 0x52,
  26678. 0x3b,
  26679. 0xd6,
  26680. 0xb3,
  26681. 0x29,
  26682. 0xe3,
  26683. 0x2f,
  26684. 0x84,
  26685. 0x53,
  26686. 0xd1,
  26687. 0x00,
  26688. 0xed,
  26689. 0x20,
  26690. 0xfc,
  26691. 0xb1,
  26692. 0x5b,
  26693. 0x6a,
  26694. 0xcb,
  26695. 0xbe,
  26696. 0x39,
  26697. 0x4a,
  26698. 0x4c,
  26699. 0x58,
  26700. 0xcf,
  26701. 0xd0,
  26702. 0xef,
  26703. 0xaa,
  26704. 0xfb,
  26705. 0x43,
  26706. 0x4d,
  26707. 0x33,
  26708. 0x85,
  26709. 0x45,
  26710. 0xf9,
  26711. 0x02,
  26712. 0x7f,
  26713. 0x50,
  26714. 0x3c,
  26715. 0x9f,
  26716. 0xa8,
  26717. 0x51,
  26718. 0xa3,
  26719. 0x40,
  26720. 0x8f,
  26721. 0x92,
  26722. 0x9d,
  26723. 0x38,
  26724. 0xf5,
  26725. 0xbc,
  26726. 0xb6,
  26727. 0xda,
  26728. 0x21,
  26729. 0x10,
  26730. 0xff,
  26731. 0xf3,
  26732. 0xd2,
  26733. 0xcd,
  26734. 0x0c,
  26735. 0x13,
  26736. 0xec,
  26737. 0x5f,
  26738. 0x97,
  26739. 0x44,
  26740. 0x17,
  26741. 0xc4,
  26742. 0xa7,
  26743. 0x7e,
  26744. 0x3d,
  26745. 0x64,
  26746. 0x5d,
  26747. 0x19,
  26748. 0x73,
  26749. 0x60,
  26750. 0x81,
  26751. 0x4f,
  26752. 0xdc,
  26753. 0x22,
  26754. 0x2a,
  26755. 0x90,
  26756. 0x88,
  26757. 0x46,
  26758. 0xee,
  26759. 0xb8,
  26760. 0x14,
  26761. 0xde,
  26762. 0x5e,
  26763. 0x0b,
  26764. 0xdb,
  26765. 0xe0,
  26766. 0x32,
  26767. 0x3a,
  26768. 0x0a,
  26769. 0x49,
  26770. 0x06,
  26771. 0x24,
  26772. 0x5c,
  26773. 0xc2,
  26774. 0xd3,
  26775. 0xac,
  26776. 0x62,
  26777. 0x91,
  26778. 0x95,
  26779. 0xe4,
  26780. 0x79,
  26781. 0xe7,
  26782. 0xc8,
  26783. 0x37,
  26784. 0x6d,
  26785. 0x8d,
  26786. 0xd5,
  26787. 0x4e,
  26788. 0xa9,
  26789. 0x6c,
  26790. 0x56,
  26791. 0xf4,
  26792. 0xea,
  26793. 0x65,
  26794. 0x7a,
  26795. 0xae,
  26796. 0x08,
  26797. 0xba,
  26798. 0x78,
  26799. 0x25,
  26800. 0x2e,
  26801. 0x1c,
  26802. 0xa6,
  26803. 0xb4,
  26804. 0xc6,
  26805. 0xe8,
  26806. 0xdd,
  26807. 0x74,
  26808. 0x1f,
  26809. 0x4b,
  26810. 0xbd,
  26811. 0x8b,
  26812. 0x8a,
  26813. 0x70,
  26814. 0x3e,
  26815. 0xb5,
  26816. 0x66,
  26817. 0x48,
  26818. 0x03,
  26819. 0xf6,
  26820. 0x0e,
  26821. 0x61,
  26822. 0x35,
  26823. 0x57,
  26824. 0xb9,
  26825. 0x86,
  26826. 0xc1,
  26827. 0x1d,
  26828. 0x9e,
  26829. 0xe1,
  26830. 0xf8,
  26831. 0x98,
  26832. 0x11,
  26833. 0x69,
  26834. 0xd9,
  26835. 0x8e,
  26836. 0x94,
  26837. 0x9b,
  26838. 0x1e,
  26839. 0x87,
  26840. 0xe9,
  26841. 0xce,
  26842. 0x55,
  26843. 0x28,
  26844. 0xdf,
  26845. 0x8c,
  26846. 0xa1,
  26847. 0x89,
  26848. 0x0d,
  26849. 0xbf,
  26850. 0xe6,
  26851. 0x42,
  26852. 0x68,
  26853. 0x41,
  26854. 0x99,
  26855. 0x2d,
  26856. 0x0f,
  26857. 0xb0,
  26858. 0x54,
  26859. 0xbb,
  26860. 0x16
  26861. ]);
  26862. var inv_s = new Uint8Array([
  26863. 0x52,
  26864. 0x09,
  26865. 0x6a,
  26866. 0xd5,
  26867. 0x30,
  26868. 0x36,
  26869. 0xa5,
  26870. 0x38,
  26871. 0xbf,
  26872. 0x40,
  26873. 0xa3,
  26874. 0x9e,
  26875. 0x81,
  26876. 0xf3,
  26877. 0xd7,
  26878. 0xfb,
  26879. 0x7c,
  26880. 0xe3,
  26881. 0x39,
  26882. 0x82,
  26883. 0x9b,
  26884. 0x2f,
  26885. 0xff,
  26886. 0x87,
  26887. 0x34,
  26888. 0x8e,
  26889. 0x43,
  26890. 0x44,
  26891. 0xc4,
  26892. 0xde,
  26893. 0xe9,
  26894. 0xcb,
  26895. 0x54,
  26896. 0x7b,
  26897. 0x94,
  26898. 0x32,
  26899. 0xa6,
  26900. 0xc2,
  26901. 0x23,
  26902. 0x3d,
  26903. 0xee,
  26904. 0x4c,
  26905. 0x95,
  26906. 0x0b,
  26907. 0x42,
  26908. 0xfa,
  26909. 0xc3,
  26910. 0x4e,
  26911. 0x08,
  26912. 0x2e,
  26913. 0xa1,
  26914. 0x66,
  26915. 0x28,
  26916. 0xd9,
  26917. 0x24,
  26918. 0xb2,
  26919. 0x76,
  26920. 0x5b,
  26921. 0xa2,
  26922. 0x49,
  26923. 0x6d,
  26924. 0x8b,
  26925. 0xd1,
  26926. 0x25,
  26927. 0x72,
  26928. 0xf8,
  26929. 0xf6,
  26930. 0x64,
  26931. 0x86,
  26932. 0x68,
  26933. 0x98,
  26934. 0x16,
  26935. 0xd4,
  26936. 0xa4,
  26937. 0x5c,
  26938. 0xcc,
  26939. 0x5d,
  26940. 0x65,
  26941. 0xb6,
  26942. 0x92,
  26943. 0x6c,
  26944. 0x70,
  26945. 0x48,
  26946. 0x50,
  26947. 0xfd,
  26948. 0xed,
  26949. 0xb9,
  26950. 0xda,
  26951. 0x5e,
  26952. 0x15,
  26953. 0x46,
  26954. 0x57,
  26955. 0xa7,
  26956. 0x8d,
  26957. 0x9d,
  26958. 0x84,
  26959. 0x90,
  26960. 0xd8,
  26961. 0xab,
  26962. 0x00,
  26963. 0x8c,
  26964. 0xbc,
  26965. 0xd3,
  26966. 0x0a,
  26967. 0xf7,
  26968. 0xe4,
  26969. 0x58,
  26970. 0x05,
  26971. 0xb8,
  26972. 0xb3,
  26973. 0x45,
  26974. 0x06,
  26975. 0xd0,
  26976. 0x2c,
  26977. 0x1e,
  26978. 0x8f,
  26979. 0xca,
  26980. 0x3f,
  26981. 0x0f,
  26982. 0x02,
  26983. 0xc1,
  26984. 0xaf,
  26985. 0xbd,
  26986. 0x03,
  26987. 0x01,
  26988. 0x13,
  26989. 0x8a,
  26990. 0x6b,
  26991. 0x3a,
  26992. 0x91,
  26993. 0x11,
  26994. 0x41,
  26995. 0x4f,
  26996. 0x67,
  26997. 0xdc,
  26998. 0xea,
  26999. 0x97,
  27000. 0xf2,
  27001. 0xcf,
  27002. 0xce,
  27003. 0xf0,
  27004. 0xb4,
  27005. 0xe6,
  27006. 0x73,
  27007. 0x96,
  27008. 0xac,
  27009. 0x74,
  27010. 0x22,
  27011. 0xe7,
  27012. 0xad,
  27013. 0x35,
  27014. 0x85,
  27015. 0xe2,
  27016. 0xf9,
  27017. 0x37,
  27018. 0xe8,
  27019. 0x1c,
  27020. 0x75,
  27021. 0xdf,
  27022. 0x6e,
  27023. 0x47,
  27024. 0xf1,
  27025. 0x1a,
  27026. 0x71,
  27027. 0x1d,
  27028. 0x29,
  27029. 0xc5,
  27030. 0x89,
  27031. 0x6f,
  27032. 0xb7,
  27033. 0x62,
  27034. 0x0e,
  27035. 0xaa,
  27036. 0x18,
  27037. 0xbe,
  27038. 0x1b,
  27039. 0xfc,
  27040. 0x56,
  27041. 0x3e,
  27042. 0x4b,
  27043. 0xc6,
  27044. 0xd2,
  27045. 0x79,
  27046. 0x20,
  27047. 0x9a,
  27048. 0xdb,
  27049. 0xc0,
  27050. 0xfe,
  27051. 0x78,
  27052. 0xcd,
  27053. 0x5a,
  27054. 0xf4,
  27055. 0x1f,
  27056. 0xdd,
  27057. 0xa8,
  27058. 0x33,
  27059. 0x88,
  27060. 0x07,
  27061. 0xc7,
  27062. 0x31,
  27063. 0xb1,
  27064. 0x12,
  27065. 0x10,
  27066. 0x59,
  27067. 0x27,
  27068. 0x80,
  27069. 0xec,
  27070. 0x5f,
  27071. 0x60,
  27072. 0x51,
  27073. 0x7f,
  27074. 0xa9,
  27075. 0x19,
  27076. 0xb5,
  27077. 0x4a,
  27078. 0x0d,
  27079. 0x2d,
  27080. 0xe5,
  27081. 0x7a,
  27082. 0x9f,
  27083. 0x93,
  27084. 0xc9,
  27085. 0x9c,
  27086. 0xef,
  27087. 0xa0,
  27088. 0xe0,
  27089. 0x3b,
  27090. 0x4d,
  27091. 0xae,
  27092. 0x2a,
  27093. 0xf5,
  27094. 0xb0,
  27095. 0xc8,
  27096. 0xeb,
  27097. 0xbb,
  27098. 0x3c,
  27099. 0x83,
  27100. 0x53,
  27101. 0x99,
  27102. 0x61,
  27103. 0x17,
  27104. 0x2b,
  27105. 0x04,
  27106. 0x7e,
  27107. 0xba,
  27108. 0x77,
  27109. 0xd6,
  27110. 0x26,
  27111. 0xe1,
  27112. 0x69,
  27113. 0x14,
  27114. 0x63,
  27115. 0x55,
  27116. 0x21,
  27117. 0x0c,
  27118. 0x7d
  27119. ]);
  27120. var mixCol = new Uint8Array(256);
  27121. for (var i = 0; i < 256; i++) {
  27122. if (i < 128) {
  27123. mixCol[i] = i << 1;
  27124. } else {
  27125. mixCol[i] = i << 1 ^ 0x1b;
  27126. }
  27127. }
  27128. var mix = new Uint32Array([
  27129. 0x00000000,
  27130. 0x0e090d0b,
  27131. 0x1c121a16,
  27132. 0x121b171d,
  27133. 0x3824342c,
  27134. 0x362d3927,
  27135. 0x24362e3a,
  27136. 0x2a3f2331,
  27137. 0x70486858,
  27138. 0x7e416553,
  27139. 0x6c5a724e,
  27140. 0x62537f45,
  27141. 0x486c5c74,
  27142. 0x4665517f,
  27143. 0x547e4662,
  27144. 0x5a774b69,
  27145. 0xe090d0b0,
  27146. 0xee99ddbb,
  27147. 0xfc82caa6,
  27148. 0xf28bc7ad,
  27149. 0xd8b4e49c,
  27150. 0xd6bde997,
  27151. 0xc4a6fe8a,
  27152. 0xcaaff381,
  27153. 0x90d8b8e8,
  27154. 0x9ed1b5e3,
  27155. 0x8ccaa2fe,
  27156. 0x82c3aff5,
  27157. 0xa8fc8cc4,
  27158. 0xa6f581cf,
  27159. 0xb4ee96d2,
  27160. 0xbae79bd9,
  27161. 0xdb3bbb7b,
  27162. 0xd532b670,
  27163. 0xc729a16d,
  27164. 0xc920ac66,
  27165. 0xe31f8f57,
  27166. 0xed16825c,
  27167. 0xff0d9541,
  27168. 0xf104984a,
  27169. 0xab73d323,
  27170. 0xa57ade28,
  27171. 0xb761c935,
  27172. 0xb968c43e,
  27173. 0x9357e70f,
  27174. 0x9d5eea04,
  27175. 0x8f45fd19,
  27176. 0x814cf012,
  27177. 0x3bab6bcb,
  27178. 0x35a266c0,
  27179. 0x27b971dd,
  27180. 0x29b07cd6,
  27181. 0x038f5fe7,
  27182. 0x0d8652ec,
  27183. 0x1f9d45f1,
  27184. 0x119448fa,
  27185. 0x4be30393,
  27186. 0x45ea0e98,
  27187. 0x57f11985,
  27188. 0x59f8148e,
  27189. 0x73c737bf,
  27190. 0x7dce3ab4,
  27191. 0x6fd52da9,
  27192. 0x61dc20a2,
  27193. 0xad766df6,
  27194. 0xa37f60fd,
  27195. 0xb16477e0,
  27196. 0xbf6d7aeb,
  27197. 0x955259da,
  27198. 0x9b5b54d1,
  27199. 0x894043cc,
  27200. 0x87494ec7,
  27201. 0xdd3e05ae,
  27202. 0xd33708a5,
  27203. 0xc12c1fb8,
  27204. 0xcf2512b3,
  27205. 0xe51a3182,
  27206. 0xeb133c89,
  27207. 0xf9082b94,
  27208. 0xf701269f,
  27209. 0x4de6bd46,
  27210. 0x43efb04d,
  27211. 0x51f4a750,
  27212. 0x5ffdaa5b,
  27213. 0x75c2896a,
  27214. 0x7bcb8461,
  27215. 0x69d0937c,
  27216. 0x67d99e77,
  27217. 0x3daed51e,
  27218. 0x33a7d815,
  27219. 0x21bccf08,
  27220. 0x2fb5c203,
  27221. 0x058ae132,
  27222. 0x0b83ec39,
  27223. 0x1998fb24,
  27224. 0x1791f62f,
  27225. 0x764dd68d,
  27226. 0x7844db86,
  27227. 0x6a5fcc9b,
  27228. 0x6456c190,
  27229. 0x4e69e2a1,
  27230. 0x4060efaa,
  27231. 0x527bf8b7,
  27232. 0x5c72f5bc,
  27233. 0x0605bed5,
  27234. 0x080cb3de,
  27235. 0x1a17a4c3,
  27236. 0x141ea9c8,
  27237. 0x3e218af9,
  27238. 0x302887f2,
  27239. 0x223390ef,
  27240. 0x2c3a9de4,
  27241. 0x96dd063d,
  27242. 0x98d40b36,
  27243. 0x8acf1c2b,
  27244. 0x84c61120,
  27245. 0xaef93211,
  27246. 0xa0f03f1a,
  27247. 0xb2eb2807,
  27248. 0xbce2250c,
  27249. 0xe6956e65,
  27250. 0xe89c636e,
  27251. 0xfa877473,
  27252. 0xf48e7978,
  27253. 0xdeb15a49,
  27254. 0xd0b85742,
  27255. 0xc2a3405f,
  27256. 0xccaa4d54,
  27257. 0x41ecdaf7,
  27258. 0x4fe5d7fc,
  27259. 0x5dfec0e1,
  27260. 0x53f7cdea,
  27261. 0x79c8eedb,
  27262. 0x77c1e3d0,
  27263. 0x65daf4cd,
  27264. 0x6bd3f9c6,
  27265. 0x31a4b2af,
  27266. 0x3fadbfa4,
  27267. 0x2db6a8b9,
  27268. 0x23bfa5b2,
  27269. 0x09808683,
  27270. 0x07898b88,
  27271. 0x15929c95,
  27272. 0x1b9b919e,
  27273. 0xa17c0a47,
  27274. 0xaf75074c,
  27275. 0xbd6e1051,
  27276. 0xb3671d5a,
  27277. 0x99583e6b,
  27278. 0x97513360,
  27279. 0x854a247d,
  27280. 0x8b432976,
  27281. 0xd134621f,
  27282. 0xdf3d6f14,
  27283. 0xcd267809,
  27284. 0xc32f7502,
  27285. 0xe9105633,
  27286. 0xe7195b38,
  27287. 0xf5024c25,
  27288. 0xfb0b412e,
  27289. 0x9ad7618c,
  27290. 0x94de6c87,
  27291. 0x86c57b9a,
  27292. 0x88cc7691,
  27293. 0xa2f355a0,
  27294. 0xacfa58ab,
  27295. 0xbee14fb6,
  27296. 0xb0e842bd,
  27297. 0xea9f09d4,
  27298. 0xe49604df,
  27299. 0xf68d13c2,
  27300. 0xf8841ec9,
  27301. 0xd2bb3df8,
  27302. 0xdcb230f3,
  27303. 0xcea927ee,
  27304. 0xc0a02ae5,
  27305. 0x7a47b13c,
  27306. 0x744ebc37,
  27307. 0x6655ab2a,
  27308. 0x685ca621,
  27309. 0x42638510,
  27310. 0x4c6a881b,
  27311. 0x5e719f06,
  27312. 0x5078920d,
  27313. 0x0a0fd964,
  27314. 0x0406d46f,
  27315. 0x161dc372,
  27316. 0x1814ce79,
  27317. 0x322bed48,
  27318. 0x3c22e043,
  27319. 0x2e39f75e,
  27320. 0x2030fa55,
  27321. 0xec9ab701,
  27322. 0xe293ba0a,
  27323. 0xf088ad17,
  27324. 0xfe81a01c,
  27325. 0xd4be832d,
  27326. 0xdab78e26,
  27327. 0xc8ac993b,
  27328. 0xc6a59430,
  27329. 0x9cd2df59,
  27330. 0x92dbd252,
  27331. 0x80c0c54f,
  27332. 0x8ec9c844,
  27333. 0xa4f6eb75,
  27334. 0xaaffe67e,
  27335. 0xb8e4f163,
  27336. 0xb6edfc68,
  27337. 0x0c0a67b1,
  27338. 0x02036aba,
  27339. 0x10187da7,
  27340. 0x1e1170ac,
  27341. 0x342e539d,
  27342. 0x3a275e96,
  27343. 0x283c498b,
  27344. 0x26354480,
  27345. 0x7c420fe9,
  27346. 0x724b02e2,
  27347. 0x605015ff,
  27348. 0x6e5918f4,
  27349. 0x44663bc5,
  27350. 0x4a6f36ce,
  27351. 0x587421d3,
  27352. 0x567d2cd8,
  27353. 0x37a10c7a,
  27354. 0x39a80171,
  27355. 0x2bb3166c,
  27356. 0x25ba1b67,
  27357. 0x0f853856,
  27358. 0x018c355d,
  27359. 0x13972240,
  27360. 0x1d9e2f4b,
  27361. 0x47e96422,
  27362. 0x49e06929,
  27363. 0x5bfb7e34,
  27364. 0x55f2733f,
  27365. 0x7fcd500e,
  27366. 0x71c45d05,
  27367. 0x63df4a18,
  27368. 0x6dd64713,
  27369. 0xd731dcca,
  27370. 0xd938d1c1,
  27371. 0xcb23c6dc,
  27372. 0xc52acbd7,
  27373. 0xef15e8e6,
  27374. 0xe11ce5ed,
  27375. 0xf307f2f0,
  27376. 0xfd0efffb,
  27377. 0xa779b492,
  27378. 0xa970b999,
  27379. 0xbb6bae84,
  27380. 0xb562a38f,
  27381. 0x9f5d80be,
  27382. 0x91548db5,
  27383. 0x834f9aa8,
  27384. 0x8d4697a3
  27385. ]);
  27386. function expandKey128(cipherKey) {
  27387. var b = 176, result = new Uint8Array(b);
  27388. result.set(cipherKey);
  27389. for (var j = 16, i = 1; j < b; ++i) {
  27390. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  27391. t1 = s[t1];
  27392. t2 = s[t2];
  27393. t3 = s[t3];
  27394. t4 = s[t4];
  27395. t1 = t1 ^ rcon[i];
  27396. for (var n = 0; n < 4; ++n) {
  27397. result[j] = t1 ^= result[j - 16];
  27398. j++;
  27399. result[j] = t2 ^= result[j - 16];
  27400. j++;
  27401. result[j] = t3 ^= result[j - 16];
  27402. j++;
  27403. result[j] = t4 ^= result[j - 16];
  27404. j++;
  27405. }
  27406. }
  27407. return result;
  27408. }
  27409. function decrypt128(input, key) {
  27410. var state = new Uint8Array(16);
  27411. state.set(input);
  27412. var i, j, k;
  27413. var t, u, v;
  27414. for (j = 0, k = 160; j < 16; ++j, ++k) {
  27415. state[j] ^= key[k];
  27416. }
  27417. for (i = 9; i >= 1; --i) {
  27418. t = state[13];
  27419. state[13] = state[9];
  27420. state[9] = state[5];
  27421. state[5] = state[1];
  27422. state[1] = t;
  27423. t = state[14];
  27424. u = state[10];
  27425. state[14] = state[6];
  27426. state[10] = state[2];
  27427. state[6] = t;
  27428. state[2] = u;
  27429. t = state[15];
  27430. u = state[11];
  27431. v = state[7];
  27432. state[15] = state[3];
  27433. state[11] = t;
  27434. state[7] = u;
  27435. state[3] = v;
  27436. for (j = 0; j < 16; ++j) {
  27437. state[j] = inv_s[state[j]];
  27438. }
  27439. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27440. state[j] ^= key[k];
  27441. }
  27442. for (j = 0; j < 16; j += 4) {
  27443. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  27444. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  27445. state[j] = t >>> 24 & 0xFF;
  27446. state[j + 1] = t >> 16 & 0xFF;
  27447. state[j + 2] = t >> 8 & 0xFF;
  27448. state[j + 3] = t & 0xFF;
  27449. }
  27450. }
  27451. t = state[13];
  27452. state[13] = state[9];
  27453. state[9] = state[5];
  27454. state[5] = state[1];
  27455. state[1] = t;
  27456. t = state[14];
  27457. u = state[10];
  27458. state[14] = state[6];
  27459. state[10] = state[2];
  27460. state[6] = t;
  27461. state[2] = u;
  27462. t = state[15];
  27463. u = state[11];
  27464. v = state[7];
  27465. state[15] = state[3];
  27466. state[11] = t;
  27467. state[7] = u;
  27468. state[3] = v;
  27469. for (j = 0; j < 16; ++j) {
  27470. state[j] = inv_s[state[j]];
  27471. state[j] ^= key[j];
  27472. }
  27473. return state;
  27474. }
  27475. function encrypt128(input, key) {
  27476. var t, u, v, k;
  27477. var state = new Uint8Array(16);
  27478. state.set(input);
  27479. for (j = 0; j < 16; ++j) {
  27480. state[j] ^= key[j];
  27481. }
  27482. for (i = 1; i < 10; i++) {
  27483. for (j = 0; j < 16; ++j) {
  27484. state[j] = s[state[j]];
  27485. }
  27486. v = state[1];
  27487. state[1] = state[5];
  27488. state[5] = state[9];
  27489. state[9] = state[13];
  27490. state[13] = v;
  27491. v = state[2];
  27492. u = state[6];
  27493. state[2] = state[10];
  27494. state[6] = state[14];
  27495. state[10] = v;
  27496. state[14] = u;
  27497. v = state[3];
  27498. u = state[7];
  27499. t = state[11];
  27500. state[3] = state[15];
  27501. state[7] = v;
  27502. state[11] = u;
  27503. state[15] = t;
  27504. for (var j = 0; j < 16; j += 4) {
  27505. var s0 = state[j + 0], s1 = state[j + 1];
  27506. var s2 = state[j + 2], s3 = state[j + 3];
  27507. t = s0 ^ s1 ^ s2 ^ s3;
  27508. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  27509. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  27510. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  27511. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  27512. }
  27513. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  27514. state[j] ^= key[k];
  27515. }
  27516. }
  27517. for (j = 0; j < 16; ++j) {
  27518. state[j] = s[state[j]];
  27519. }
  27520. v = state[1];
  27521. state[1] = state[5];
  27522. state[5] = state[9];
  27523. state[9] = state[13];
  27524. state[13] = v;
  27525. v = state[2];
  27526. u = state[6];
  27527. state[2] = state[10];
  27528. state[6] = state[14];
  27529. state[10] = v;
  27530. state[14] = u;
  27531. v = state[3];
  27532. u = state[7];
  27533. t = state[11];
  27534. state[3] = state[15];
  27535. state[7] = v;
  27536. state[11] = u;
  27537. state[15] = t;
  27538. for (j = 0, k = 160; j < 16; ++j, ++k) {
  27539. state[j] ^= key[k];
  27540. }
  27541. return state;
  27542. }
  27543. function AES128Cipher(key) {
  27544. this.key = expandKey128(key);
  27545. this.buffer = new Uint8Array(16);
  27546. this.bufferPosition = 0;
  27547. }
  27548. function decryptBlock2(data, finalize) {
  27549. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  27550. for (i = 0; i < sourceLength; ++i) {
  27551. buffer[bufferLength] = data[i];
  27552. ++bufferLength;
  27553. if (bufferLength < 16) {
  27554. continue;
  27555. }
  27556. var plain = decrypt128(buffer, this.key);
  27557. for (j = 0; j < 16; ++j) {
  27558. plain[j] ^= iv[j];
  27559. }
  27560. iv = buffer;
  27561. result.push(plain);
  27562. buffer = new Uint8Array(16);
  27563. bufferLength = 0;
  27564. }
  27565. this.buffer = buffer;
  27566. this.bufferLength = bufferLength;
  27567. this.iv = iv;
  27568. if (result.length === 0) {
  27569. return new Uint8Array([]);
  27570. }
  27571. var outputLength = 16 * result.length;
  27572. if (finalize) {
  27573. var lastBlock = result[result.length - 1];
  27574. var psLen = lastBlock[15];
  27575. if (psLen <= 16) {
  27576. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  27577. if (lastBlock[i] !== psLen) {
  27578. psLen = 0;
  27579. break;
  27580. }
  27581. }
  27582. outputLength -= psLen;
  27583. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  27584. }
  27585. }
  27586. var output = new Uint8Array(outputLength);
  27587. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27588. output.set(result[i], j);
  27589. }
  27590. return output;
  27591. }
  27592. AES128Cipher.prototype = {
  27593. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  27594. var i, sourceLength = data.length;
  27595. var buffer = this.buffer, bufferLength = this.bufferPosition;
  27596. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  27597. buffer[bufferLength] = data[i];
  27598. }
  27599. if (bufferLength < 16) {
  27600. this.bufferLength = bufferLength;
  27601. return new Uint8Array([]);
  27602. }
  27603. this.iv = buffer;
  27604. this.buffer = new Uint8Array(16);
  27605. this.bufferLength = 0;
  27606. this.decryptBlock = decryptBlock2;
  27607. return this.decryptBlock(data.subarray(16), finalize);
  27608. },
  27609. encrypt: function AES128Cipher_encrypt(data, iv) {
  27610. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  27611. if (!iv) {
  27612. iv = new Uint8Array(16);
  27613. }
  27614. for (i = 0; i < sourceLength; ++i) {
  27615. buffer[bufferLength] = data[i];
  27616. ++bufferLength;
  27617. if (bufferLength < 16) {
  27618. continue;
  27619. }
  27620. for (j = 0; j < 16; ++j) {
  27621. buffer[j] ^= iv[j];
  27622. }
  27623. var cipher = encrypt128(buffer, this.key);
  27624. iv = cipher;
  27625. result.push(cipher);
  27626. buffer = new Uint8Array(16);
  27627. bufferLength = 0;
  27628. }
  27629. this.buffer = buffer;
  27630. this.bufferLength = bufferLength;
  27631. this.iv = iv;
  27632. if (result.length === 0) {
  27633. return new Uint8Array([]);
  27634. }
  27635. var outputLength = 16 * result.length;
  27636. var output = new Uint8Array(outputLength);
  27637. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  27638. output.set(result[i], j);
  27639. }
  27640. return output;
  27641. }
  27642. };
  27643. return AES128Cipher;
  27644. }();
  27645. var AES256Cipher = function AES256CipherClosure() {
  27646. var s = new Uint8Array([
  27647. 0x63,
  27648. 0x7c,
  27649. 0x77,
  27650. 0x7b,
  27651. 0xf2,
  27652. 0x6b,
  27653. 0x6f,
  27654. 0xc5,
  27655. 0x30,
  27656. 0x01,
  27657. 0x67,
  27658. 0x2b,
  27659. 0xfe,
  27660. 0xd7,
  27661. 0xab,
  27662. 0x76,
  27663. 0xca,
  27664. 0x82,
  27665. 0xc9,
  27666. 0x7d,
  27667. 0xfa,
  27668. 0x59,
  27669. 0x47,
  27670. 0xf0,
  27671. 0xad,
  27672. 0xd4,
  27673. 0xa2,
  27674. 0xaf,
  27675. 0x9c,
  27676. 0xa4,
  27677. 0x72,
  27678. 0xc0,
  27679. 0xb7,
  27680. 0xfd,
  27681. 0x93,
  27682. 0x26,
  27683. 0x36,
  27684. 0x3f,
  27685. 0xf7,
  27686. 0xcc,
  27687. 0x34,
  27688. 0xa5,
  27689. 0xe5,
  27690. 0xf1,
  27691. 0x71,
  27692. 0xd8,
  27693. 0x31,
  27694. 0x15,
  27695. 0x04,
  27696. 0xc7,
  27697. 0x23,
  27698. 0xc3,
  27699. 0x18,
  27700. 0x96,
  27701. 0x05,
  27702. 0x9a,
  27703. 0x07,
  27704. 0x12,
  27705. 0x80,
  27706. 0xe2,
  27707. 0xeb,
  27708. 0x27,
  27709. 0xb2,
  27710. 0x75,
  27711. 0x09,
  27712. 0x83,
  27713. 0x2c,
  27714. 0x1a,
  27715. 0x1b,
  27716. 0x6e,
  27717. 0x5a,
  27718. 0xa0,
  27719. 0x52,
  27720. 0x3b,
  27721. 0xd6,
  27722. 0xb3,
  27723. 0x29,
  27724. 0xe3,
  27725. 0x2f,
  27726. 0x84,
  27727. 0x53,
  27728. 0xd1,
  27729. 0x00,
  27730. 0xed,
  27731. 0x20,
  27732. 0xfc,
  27733. 0xb1,
  27734. 0x5b,
  27735. 0x6a,
  27736. 0xcb,
  27737. 0xbe,
  27738. 0x39,
  27739. 0x4a,
  27740. 0x4c,
  27741. 0x58,
  27742. 0xcf,
  27743. 0xd0,
  27744. 0xef,
  27745. 0xaa,
  27746. 0xfb,
  27747. 0x43,
  27748. 0x4d,
  27749. 0x33,
  27750. 0x85,
  27751. 0x45,
  27752. 0xf9,
  27753. 0x02,
  27754. 0x7f,
  27755. 0x50,
  27756. 0x3c,
  27757. 0x9f,
  27758. 0xa8,
  27759. 0x51,
  27760. 0xa3,
  27761. 0x40,
  27762. 0x8f,
  27763. 0x92,
  27764. 0x9d,
  27765. 0x38,
  27766. 0xf5,
  27767. 0xbc,
  27768. 0xb6,
  27769. 0xda,
  27770. 0x21,
  27771. 0x10,
  27772. 0xff,
  27773. 0xf3,
  27774. 0xd2,
  27775. 0xcd,
  27776. 0x0c,
  27777. 0x13,
  27778. 0xec,
  27779. 0x5f,
  27780. 0x97,
  27781. 0x44,
  27782. 0x17,
  27783. 0xc4,
  27784. 0xa7,
  27785. 0x7e,
  27786. 0x3d,
  27787. 0x64,
  27788. 0x5d,
  27789. 0x19,
  27790. 0x73,
  27791. 0x60,
  27792. 0x81,
  27793. 0x4f,
  27794. 0xdc,
  27795. 0x22,
  27796. 0x2a,
  27797. 0x90,
  27798. 0x88,
  27799. 0x46,
  27800. 0xee,
  27801. 0xb8,
  27802. 0x14,
  27803. 0xde,
  27804. 0x5e,
  27805. 0x0b,
  27806. 0xdb,
  27807. 0xe0,
  27808. 0x32,
  27809. 0x3a,
  27810. 0x0a,
  27811. 0x49,
  27812. 0x06,
  27813. 0x24,
  27814. 0x5c,
  27815. 0xc2,
  27816. 0xd3,
  27817. 0xac,
  27818. 0x62,
  27819. 0x91,
  27820. 0x95,
  27821. 0xe4,
  27822. 0x79,
  27823. 0xe7,
  27824. 0xc8,
  27825. 0x37,
  27826. 0x6d,
  27827. 0x8d,
  27828. 0xd5,
  27829. 0x4e,
  27830. 0xa9,
  27831. 0x6c,
  27832. 0x56,
  27833. 0xf4,
  27834. 0xea,
  27835. 0x65,
  27836. 0x7a,
  27837. 0xae,
  27838. 0x08,
  27839. 0xba,
  27840. 0x78,
  27841. 0x25,
  27842. 0x2e,
  27843. 0x1c,
  27844. 0xa6,
  27845. 0xb4,
  27846. 0xc6,
  27847. 0xe8,
  27848. 0xdd,
  27849. 0x74,
  27850. 0x1f,
  27851. 0x4b,
  27852. 0xbd,
  27853. 0x8b,
  27854. 0x8a,
  27855. 0x70,
  27856. 0x3e,
  27857. 0xb5,
  27858. 0x66,
  27859. 0x48,
  27860. 0x03,
  27861. 0xf6,
  27862. 0x0e,
  27863. 0x61,
  27864. 0x35,
  27865. 0x57,
  27866. 0xb9,
  27867. 0x86,
  27868. 0xc1,
  27869. 0x1d,
  27870. 0x9e,
  27871. 0xe1,
  27872. 0xf8,
  27873. 0x98,
  27874. 0x11,
  27875. 0x69,
  27876. 0xd9,
  27877. 0x8e,
  27878. 0x94,
  27879. 0x9b,
  27880. 0x1e,
  27881. 0x87,
  27882. 0xe9,
  27883. 0xce,
  27884. 0x55,
  27885. 0x28,
  27886. 0xdf,
  27887. 0x8c,
  27888. 0xa1,
  27889. 0x89,
  27890. 0x0d,
  27891. 0xbf,
  27892. 0xe6,
  27893. 0x42,
  27894. 0x68,
  27895. 0x41,
  27896. 0x99,
  27897. 0x2d,
  27898. 0x0f,
  27899. 0xb0,
  27900. 0x54,
  27901. 0xbb,
  27902. 0x16
  27903. ]);
  27904. var inv_s = new Uint8Array([
  27905. 0x52,
  27906. 0x09,
  27907. 0x6a,
  27908. 0xd5,
  27909. 0x30,
  27910. 0x36,
  27911. 0xa5,
  27912. 0x38,
  27913. 0xbf,
  27914. 0x40,
  27915. 0xa3,
  27916. 0x9e,
  27917. 0x81,
  27918. 0xf3,
  27919. 0xd7,
  27920. 0xfb,
  27921. 0x7c,
  27922. 0xe3,
  27923. 0x39,
  27924. 0x82,
  27925. 0x9b,
  27926. 0x2f,
  27927. 0xff,
  27928. 0x87,
  27929. 0x34,
  27930. 0x8e,
  27931. 0x43,
  27932. 0x44,
  27933. 0xc4,
  27934. 0xde,
  27935. 0xe9,
  27936. 0xcb,
  27937. 0x54,
  27938. 0x7b,
  27939. 0x94,
  27940. 0x32,
  27941. 0xa6,
  27942. 0xc2,
  27943. 0x23,
  27944. 0x3d,
  27945. 0xee,
  27946. 0x4c,
  27947. 0x95,
  27948. 0x0b,
  27949. 0x42,
  27950. 0xfa,
  27951. 0xc3,
  27952. 0x4e,
  27953. 0x08,
  27954. 0x2e,
  27955. 0xa1,
  27956. 0x66,
  27957. 0x28,
  27958. 0xd9,
  27959. 0x24,
  27960. 0xb2,
  27961. 0x76,
  27962. 0x5b,
  27963. 0xa2,
  27964. 0x49,
  27965. 0x6d,
  27966. 0x8b,
  27967. 0xd1,
  27968. 0x25,
  27969. 0x72,
  27970. 0xf8,
  27971. 0xf6,
  27972. 0x64,
  27973. 0x86,
  27974. 0x68,
  27975. 0x98,
  27976. 0x16,
  27977. 0xd4,
  27978. 0xa4,
  27979. 0x5c,
  27980. 0xcc,
  27981. 0x5d,
  27982. 0x65,
  27983. 0xb6,
  27984. 0x92,
  27985. 0x6c,
  27986. 0x70,
  27987. 0x48,
  27988. 0x50,
  27989. 0xfd,
  27990. 0xed,
  27991. 0xb9,
  27992. 0xda,
  27993. 0x5e,
  27994. 0x15,
  27995. 0x46,
  27996. 0x57,
  27997. 0xa7,
  27998. 0x8d,
  27999. 0x9d,
  28000. 0x84,
  28001. 0x90,
  28002. 0xd8,
  28003. 0xab,
  28004. 0x00,
  28005. 0x8c,
  28006. 0xbc,
  28007. 0xd3,
  28008. 0x0a,
  28009. 0xf7,
  28010. 0xe4,
  28011. 0x58,
  28012. 0x05,
  28013. 0xb8,
  28014. 0xb3,
  28015. 0x45,
  28016. 0x06,
  28017. 0xd0,
  28018. 0x2c,
  28019. 0x1e,
  28020. 0x8f,
  28021. 0xca,
  28022. 0x3f,
  28023. 0x0f,
  28024. 0x02,
  28025. 0xc1,
  28026. 0xaf,
  28027. 0xbd,
  28028. 0x03,
  28029. 0x01,
  28030. 0x13,
  28031. 0x8a,
  28032. 0x6b,
  28033. 0x3a,
  28034. 0x91,
  28035. 0x11,
  28036. 0x41,
  28037. 0x4f,
  28038. 0x67,
  28039. 0xdc,
  28040. 0xea,
  28041. 0x97,
  28042. 0xf2,
  28043. 0xcf,
  28044. 0xce,
  28045. 0xf0,
  28046. 0xb4,
  28047. 0xe6,
  28048. 0x73,
  28049. 0x96,
  28050. 0xac,
  28051. 0x74,
  28052. 0x22,
  28053. 0xe7,
  28054. 0xad,
  28055. 0x35,
  28056. 0x85,
  28057. 0xe2,
  28058. 0xf9,
  28059. 0x37,
  28060. 0xe8,
  28061. 0x1c,
  28062. 0x75,
  28063. 0xdf,
  28064. 0x6e,
  28065. 0x47,
  28066. 0xf1,
  28067. 0x1a,
  28068. 0x71,
  28069. 0x1d,
  28070. 0x29,
  28071. 0xc5,
  28072. 0x89,
  28073. 0x6f,
  28074. 0xb7,
  28075. 0x62,
  28076. 0x0e,
  28077. 0xaa,
  28078. 0x18,
  28079. 0xbe,
  28080. 0x1b,
  28081. 0xfc,
  28082. 0x56,
  28083. 0x3e,
  28084. 0x4b,
  28085. 0xc6,
  28086. 0xd2,
  28087. 0x79,
  28088. 0x20,
  28089. 0x9a,
  28090. 0xdb,
  28091. 0xc0,
  28092. 0xfe,
  28093. 0x78,
  28094. 0xcd,
  28095. 0x5a,
  28096. 0xf4,
  28097. 0x1f,
  28098. 0xdd,
  28099. 0xa8,
  28100. 0x33,
  28101. 0x88,
  28102. 0x07,
  28103. 0xc7,
  28104. 0x31,
  28105. 0xb1,
  28106. 0x12,
  28107. 0x10,
  28108. 0x59,
  28109. 0x27,
  28110. 0x80,
  28111. 0xec,
  28112. 0x5f,
  28113. 0x60,
  28114. 0x51,
  28115. 0x7f,
  28116. 0xa9,
  28117. 0x19,
  28118. 0xb5,
  28119. 0x4a,
  28120. 0x0d,
  28121. 0x2d,
  28122. 0xe5,
  28123. 0x7a,
  28124. 0x9f,
  28125. 0x93,
  28126. 0xc9,
  28127. 0x9c,
  28128. 0xef,
  28129. 0xa0,
  28130. 0xe0,
  28131. 0x3b,
  28132. 0x4d,
  28133. 0xae,
  28134. 0x2a,
  28135. 0xf5,
  28136. 0xb0,
  28137. 0xc8,
  28138. 0xeb,
  28139. 0xbb,
  28140. 0x3c,
  28141. 0x83,
  28142. 0x53,
  28143. 0x99,
  28144. 0x61,
  28145. 0x17,
  28146. 0x2b,
  28147. 0x04,
  28148. 0x7e,
  28149. 0xba,
  28150. 0x77,
  28151. 0xd6,
  28152. 0x26,
  28153. 0xe1,
  28154. 0x69,
  28155. 0x14,
  28156. 0x63,
  28157. 0x55,
  28158. 0x21,
  28159. 0x0c,
  28160. 0x7d
  28161. ]);
  28162. var mixCol = new Uint8Array(256);
  28163. for (var i = 0; i < 256; i++) {
  28164. if (i < 128) {
  28165. mixCol[i] = i << 1;
  28166. } else {
  28167. mixCol[i] = i << 1 ^ 0x1b;
  28168. }
  28169. }
  28170. var mix = new Uint32Array([
  28171. 0x00000000,
  28172. 0x0e090d0b,
  28173. 0x1c121a16,
  28174. 0x121b171d,
  28175. 0x3824342c,
  28176. 0x362d3927,
  28177. 0x24362e3a,
  28178. 0x2a3f2331,
  28179. 0x70486858,
  28180. 0x7e416553,
  28181. 0x6c5a724e,
  28182. 0x62537f45,
  28183. 0x486c5c74,
  28184. 0x4665517f,
  28185. 0x547e4662,
  28186. 0x5a774b69,
  28187. 0xe090d0b0,
  28188. 0xee99ddbb,
  28189. 0xfc82caa6,
  28190. 0xf28bc7ad,
  28191. 0xd8b4e49c,
  28192. 0xd6bde997,
  28193. 0xc4a6fe8a,
  28194. 0xcaaff381,
  28195. 0x90d8b8e8,
  28196. 0x9ed1b5e3,
  28197. 0x8ccaa2fe,
  28198. 0x82c3aff5,
  28199. 0xa8fc8cc4,
  28200. 0xa6f581cf,
  28201. 0xb4ee96d2,
  28202. 0xbae79bd9,
  28203. 0xdb3bbb7b,
  28204. 0xd532b670,
  28205. 0xc729a16d,
  28206. 0xc920ac66,
  28207. 0xe31f8f57,
  28208. 0xed16825c,
  28209. 0xff0d9541,
  28210. 0xf104984a,
  28211. 0xab73d323,
  28212. 0xa57ade28,
  28213. 0xb761c935,
  28214. 0xb968c43e,
  28215. 0x9357e70f,
  28216. 0x9d5eea04,
  28217. 0x8f45fd19,
  28218. 0x814cf012,
  28219. 0x3bab6bcb,
  28220. 0x35a266c0,
  28221. 0x27b971dd,
  28222. 0x29b07cd6,
  28223. 0x038f5fe7,
  28224. 0x0d8652ec,
  28225. 0x1f9d45f1,
  28226. 0x119448fa,
  28227. 0x4be30393,
  28228. 0x45ea0e98,
  28229. 0x57f11985,
  28230. 0x59f8148e,
  28231. 0x73c737bf,
  28232. 0x7dce3ab4,
  28233. 0x6fd52da9,
  28234. 0x61dc20a2,
  28235. 0xad766df6,
  28236. 0xa37f60fd,
  28237. 0xb16477e0,
  28238. 0xbf6d7aeb,
  28239. 0x955259da,
  28240. 0x9b5b54d1,
  28241. 0x894043cc,
  28242. 0x87494ec7,
  28243. 0xdd3e05ae,
  28244. 0xd33708a5,
  28245. 0xc12c1fb8,
  28246. 0xcf2512b3,
  28247. 0xe51a3182,
  28248. 0xeb133c89,
  28249. 0xf9082b94,
  28250. 0xf701269f,
  28251. 0x4de6bd46,
  28252. 0x43efb04d,
  28253. 0x51f4a750,
  28254. 0x5ffdaa5b,
  28255. 0x75c2896a,
  28256. 0x7bcb8461,
  28257. 0x69d0937c,
  28258. 0x67d99e77,
  28259. 0x3daed51e,
  28260. 0x33a7d815,
  28261. 0x21bccf08,
  28262. 0x2fb5c203,
  28263. 0x058ae132,
  28264. 0x0b83ec39,
  28265. 0x1998fb24,
  28266. 0x1791f62f,
  28267. 0x764dd68d,
  28268. 0x7844db86,
  28269. 0x6a5fcc9b,
  28270. 0x6456c190,
  28271. 0x4e69e2a1,
  28272. 0x4060efaa,
  28273. 0x527bf8b7,
  28274. 0x5c72f5bc,
  28275. 0x0605bed5,
  28276. 0x080cb3de,
  28277. 0x1a17a4c3,
  28278. 0x141ea9c8,
  28279. 0x3e218af9,
  28280. 0x302887f2,
  28281. 0x223390ef,
  28282. 0x2c3a9de4,
  28283. 0x96dd063d,
  28284. 0x98d40b36,
  28285. 0x8acf1c2b,
  28286. 0x84c61120,
  28287. 0xaef93211,
  28288. 0xa0f03f1a,
  28289. 0xb2eb2807,
  28290. 0xbce2250c,
  28291. 0xe6956e65,
  28292. 0xe89c636e,
  28293. 0xfa877473,
  28294. 0xf48e7978,
  28295. 0xdeb15a49,
  28296. 0xd0b85742,
  28297. 0xc2a3405f,
  28298. 0xccaa4d54,
  28299. 0x41ecdaf7,
  28300. 0x4fe5d7fc,
  28301. 0x5dfec0e1,
  28302. 0x53f7cdea,
  28303. 0x79c8eedb,
  28304. 0x77c1e3d0,
  28305. 0x65daf4cd,
  28306. 0x6bd3f9c6,
  28307. 0x31a4b2af,
  28308. 0x3fadbfa4,
  28309. 0x2db6a8b9,
  28310. 0x23bfa5b2,
  28311. 0x09808683,
  28312. 0x07898b88,
  28313. 0x15929c95,
  28314. 0x1b9b919e,
  28315. 0xa17c0a47,
  28316. 0xaf75074c,
  28317. 0xbd6e1051,
  28318. 0xb3671d5a,
  28319. 0x99583e6b,
  28320. 0x97513360,
  28321. 0x854a247d,
  28322. 0x8b432976,
  28323. 0xd134621f,
  28324. 0xdf3d6f14,
  28325. 0xcd267809,
  28326. 0xc32f7502,
  28327. 0xe9105633,
  28328. 0xe7195b38,
  28329. 0xf5024c25,
  28330. 0xfb0b412e,
  28331. 0x9ad7618c,
  28332. 0x94de6c87,
  28333. 0x86c57b9a,
  28334. 0x88cc7691,
  28335. 0xa2f355a0,
  28336. 0xacfa58ab,
  28337. 0xbee14fb6,
  28338. 0xb0e842bd,
  28339. 0xea9f09d4,
  28340. 0xe49604df,
  28341. 0xf68d13c2,
  28342. 0xf8841ec9,
  28343. 0xd2bb3df8,
  28344. 0xdcb230f3,
  28345. 0xcea927ee,
  28346. 0xc0a02ae5,
  28347. 0x7a47b13c,
  28348. 0x744ebc37,
  28349. 0x6655ab2a,
  28350. 0x685ca621,
  28351. 0x42638510,
  28352. 0x4c6a881b,
  28353. 0x5e719f06,
  28354. 0x5078920d,
  28355. 0x0a0fd964,
  28356. 0x0406d46f,
  28357. 0x161dc372,
  28358. 0x1814ce79,
  28359. 0x322bed48,
  28360. 0x3c22e043,
  28361. 0x2e39f75e,
  28362. 0x2030fa55,
  28363. 0xec9ab701,
  28364. 0xe293ba0a,
  28365. 0xf088ad17,
  28366. 0xfe81a01c,
  28367. 0xd4be832d,
  28368. 0xdab78e26,
  28369. 0xc8ac993b,
  28370. 0xc6a59430,
  28371. 0x9cd2df59,
  28372. 0x92dbd252,
  28373. 0x80c0c54f,
  28374. 0x8ec9c844,
  28375. 0xa4f6eb75,
  28376. 0xaaffe67e,
  28377. 0xb8e4f163,
  28378. 0xb6edfc68,
  28379. 0x0c0a67b1,
  28380. 0x02036aba,
  28381. 0x10187da7,
  28382. 0x1e1170ac,
  28383. 0x342e539d,
  28384. 0x3a275e96,
  28385. 0x283c498b,
  28386. 0x26354480,
  28387. 0x7c420fe9,
  28388. 0x724b02e2,
  28389. 0x605015ff,
  28390. 0x6e5918f4,
  28391. 0x44663bc5,
  28392. 0x4a6f36ce,
  28393. 0x587421d3,
  28394. 0x567d2cd8,
  28395. 0x37a10c7a,
  28396. 0x39a80171,
  28397. 0x2bb3166c,
  28398. 0x25ba1b67,
  28399. 0x0f853856,
  28400. 0x018c355d,
  28401. 0x13972240,
  28402. 0x1d9e2f4b,
  28403. 0x47e96422,
  28404. 0x49e06929,
  28405. 0x5bfb7e34,
  28406. 0x55f2733f,
  28407. 0x7fcd500e,
  28408. 0x71c45d05,
  28409. 0x63df4a18,
  28410. 0x6dd64713,
  28411. 0xd731dcca,
  28412. 0xd938d1c1,
  28413. 0xcb23c6dc,
  28414. 0xc52acbd7,
  28415. 0xef15e8e6,
  28416. 0xe11ce5ed,
  28417. 0xf307f2f0,
  28418. 0xfd0efffb,
  28419. 0xa779b492,
  28420. 0xa970b999,
  28421. 0xbb6bae84,
  28422. 0xb562a38f,
  28423. 0x9f5d80be,
  28424. 0x91548db5,
  28425. 0x834f9aa8,
  28426. 0x8d4697a3
  28427. ]);
  28428. function expandKey256(cipherKey) {
  28429. var b = 240, result = new Uint8Array(b);
  28430. var r = 1;
  28431. result.set(cipherKey);
  28432. for (var j = 32, i = 1; j < b; ++i) {
  28433. if (j % 32 === 16) {
  28434. t1 = s[t1];
  28435. t2 = s[t2];
  28436. t3 = s[t3];
  28437. t4 = s[t4];
  28438. } else if (j % 32 === 0) {
  28439. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  28440. t1 = s[t1];
  28441. t2 = s[t2];
  28442. t3 = s[t3];
  28443. t4 = s[t4];
  28444. t1 = t1 ^ r;
  28445. if ((r <<= 1) >= 256) {
  28446. r = (r ^ 0x1b) & 0xFF;
  28447. }
  28448. }
  28449. for (var n = 0; n < 4; ++n) {
  28450. result[j] = t1 ^= result[j - 32];
  28451. j++;
  28452. result[j] = t2 ^= result[j - 32];
  28453. j++;
  28454. result[j] = t3 ^= result[j - 32];
  28455. j++;
  28456. result[j] = t4 ^= result[j - 32];
  28457. j++;
  28458. }
  28459. }
  28460. return result;
  28461. }
  28462. function decrypt256(input, key) {
  28463. var state = new Uint8Array(16);
  28464. state.set(input);
  28465. var i, j, k;
  28466. var t, u, v;
  28467. for (j = 0, k = 224; j < 16; ++j, ++k) {
  28468. state[j] ^= key[k];
  28469. }
  28470. for (i = 13; i >= 1; --i) {
  28471. t = state[13];
  28472. state[13] = state[9];
  28473. state[9] = state[5];
  28474. state[5] = state[1];
  28475. state[1] = t;
  28476. t = state[14];
  28477. u = state[10];
  28478. state[14] = state[6];
  28479. state[10] = state[2];
  28480. state[6] = t;
  28481. state[2] = u;
  28482. t = state[15];
  28483. u = state[11];
  28484. v = state[7];
  28485. state[15] = state[3];
  28486. state[11] = t;
  28487. state[7] = u;
  28488. state[3] = v;
  28489. for (j = 0; j < 16; ++j) {
  28490. state[j] = inv_s[state[j]];
  28491. }
  28492. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  28493. state[j] ^= key[k];
  28494. }
  28495. for (j = 0; j < 16; j += 4) {
  28496. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  28497. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  28498. state[j] = t >>> 24 & 0xFF;
  28499. state[j + 1] = t >> 16 & 0xFF;
  28500. state[j + 2] = t >> 8 & 0xFF;
  28501. state[j + 3] = t & 0xFF;
  28502. }
  28503. }
  28504. t = state[13];
  28505. state[13] = state[9];
  28506. state[9] = state[5];
  28507. state[5] = state[1];
  28508. state[1] = t;
  28509. t = state[14];
  28510. u = state[10];
  28511. state[14] = state[6];
  28512. state[10] = state[2];
  28513. state[6] = t;
  28514. state[2] = u;
  28515. t = state[15];
  28516. u = state[11];
  28517. v = state[7];
  28518. state[15] = state[3];
  28519. state[11] = t;
  28520. state[7] = u;
  28521. state[3] = v;
  28522. for (j = 0; j < 16; ++j) {
  28523. state[j] = inv_s[state[j]];
  28524. state[j] ^= key[j];
  28525. }
  28526. return state;
  28527. }
  28528. function encrypt256(input, key) {
  28529. var t, u, v, k;
  28530. var state = new Uint8Array(16);
  28531. state.set(input);
  28532. for (j = 0; j < 16; ++j) {
  28533. state[j] ^= key[j];
  28534. }
  28535. for (i = 1; i < 14; i++) {
  28536. for (j = 0; j < 16; ++j) {
  28537. state[j] = s[state[j]];
  28538. }
  28539. v = state[1];
  28540. state[1] = state[5];
  28541. state[5] = state[9];
  28542. state[9] = state[13];
  28543. state[13] = v;
  28544. v = state[2];
  28545. u = state[6];
  28546. state[2] = state[10];
  28547. state[6] = state[14];
  28548. state[10] = v;
  28549. state[14] = u;
  28550. v = state[3];
  28551. u = state[7];
  28552. t = state[11];
  28553. state[3] = state[15];
  28554. state[7] = v;
  28555. state[11] = u;
  28556. state[15] = t;
  28557. for (var j = 0; j < 16; j += 4) {
  28558. var s0 = state[j + 0], s1 = state[j + 1];
  28559. var s2 = state[j + 2], s3 = state[j + 3];
  28560. t = s0 ^ s1 ^ s2 ^ s3;
  28561. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  28562. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  28563. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  28564. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  28565. }
  28566. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  28567. state[j] ^= key[k];
  28568. }
  28569. }
  28570. for (j = 0; j < 16; ++j) {
  28571. state[j] = s[state[j]];
  28572. }
  28573. v = state[1];
  28574. state[1] = state[5];
  28575. state[5] = state[9];
  28576. state[9] = state[13];
  28577. state[13] = v;
  28578. v = state[2];
  28579. u = state[6];
  28580. state[2] = state[10];
  28581. state[6] = state[14];
  28582. state[10] = v;
  28583. state[14] = u;
  28584. v = state[3];
  28585. u = state[7];
  28586. t = state[11];
  28587. state[3] = state[15];
  28588. state[7] = v;
  28589. state[11] = u;
  28590. state[15] = t;
  28591. for (j = 0, k = 224; j < 16; ++j, ++k) {
  28592. state[j] ^= key[k];
  28593. }
  28594. return state;
  28595. }
  28596. function AES256Cipher(key) {
  28597. this.key = expandKey256(key);
  28598. this.buffer = new Uint8Array(16);
  28599. this.bufferPosition = 0;
  28600. }
  28601. function decryptBlock2(data, finalize) {
  28602. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  28603. for (i = 0; i < sourceLength; ++i) {
  28604. buffer[bufferLength] = data[i];
  28605. ++bufferLength;
  28606. if (bufferLength < 16) {
  28607. continue;
  28608. }
  28609. var plain = decrypt256(buffer, this.key);
  28610. for (j = 0; j < 16; ++j) {
  28611. plain[j] ^= iv[j];
  28612. }
  28613. iv = buffer;
  28614. result.push(plain);
  28615. buffer = new Uint8Array(16);
  28616. bufferLength = 0;
  28617. }
  28618. this.buffer = buffer;
  28619. this.bufferLength = bufferLength;
  28620. this.iv = iv;
  28621. if (result.length === 0) {
  28622. return new Uint8Array([]);
  28623. }
  28624. var outputLength = 16 * result.length;
  28625. if (finalize) {
  28626. var lastBlock = result[result.length - 1];
  28627. var psLen = lastBlock[15];
  28628. if (psLen <= 16) {
  28629. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  28630. if (lastBlock[i] !== psLen) {
  28631. psLen = 0;
  28632. break;
  28633. }
  28634. }
  28635. outputLength -= psLen;
  28636. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  28637. }
  28638. }
  28639. var output = new Uint8Array(outputLength);
  28640. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  28641. output.set(result[i], j);
  28642. }
  28643. return output;
  28644. }
  28645. AES256Cipher.prototype = {
  28646. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  28647. var i, sourceLength = data.length;
  28648. var buffer = this.buffer, bufferLength = this.bufferPosition;
  28649. if (iv) {
  28650. this.iv = iv;
  28651. } else {
  28652. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  28653. buffer[bufferLength] = data[i];
  28654. }
  28655. if (bufferLength < 16) {
  28656. this.bufferLength = bufferLength;
  28657. return new Uint8Array([]);
  28658. }
  28659. this.iv = buffer;
  28660. data = data.subarray(16);
  28661. }
  28662. this.buffer = new Uint8Array(16);
  28663. this.bufferLength = 0;
  28664. this.decryptBlock = decryptBlock2;
  28665. return this.decryptBlock(data, finalize);
  28666. },
  28667. encrypt: function AES256Cipher_encrypt(data, iv) {
  28668. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  28669. if (!iv) {
  28670. iv = new Uint8Array(16);
  28671. }
  28672. for (i = 0; i < sourceLength; ++i) {
  28673. buffer[bufferLength] = data[i];
  28674. ++bufferLength;
  28675. if (bufferLength < 16) {
  28676. continue;
  28677. }
  28678. for (j = 0; j < 16; ++j) {
  28679. buffer[j] ^= iv[j];
  28680. }
  28681. var cipher = encrypt256(buffer, this.key);
  28682. this.iv = cipher;
  28683. result.push(cipher);
  28684. buffer = new Uint8Array(16);
  28685. bufferLength = 0;
  28686. }
  28687. this.buffer = buffer;
  28688. this.bufferLength = bufferLength;
  28689. this.iv = iv;
  28690. if (result.length === 0) {
  28691. return new Uint8Array([]);
  28692. }
  28693. var outputLength = 16 * result.length;
  28694. var output = new Uint8Array(outputLength);
  28695. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  28696. output.set(result[i], j);
  28697. }
  28698. return output;
  28699. }
  28700. };
  28701. return AES256Cipher;
  28702. }();
  28703. var PDF17 = function PDF17Closure() {
  28704. function compareByteArrays(array1, array2) {
  28705. if (array1.length !== array2.length) {
  28706. return false;
  28707. }
  28708. for (var i = 0; i < array1.length; i++) {
  28709. if (array1[i] !== array2[i]) {
  28710. return false;
  28711. }
  28712. }
  28713. return true;
  28714. }
  28715. function PDF17() {
  28716. }
  28717. PDF17.prototype = {
  28718. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  28719. var hashData = new Uint8Array(password.length + 56);
  28720. hashData.set(password, 0);
  28721. hashData.set(ownerValidationSalt, password.length);
  28722. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  28723. var result = calculateSHA256(hashData, 0, hashData.length);
  28724. return compareByteArrays(result, ownerPassword);
  28725. },
  28726. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  28727. var hashData = new Uint8Array(password.length + 8);
  28728. hashData.set(password, 0);
  28729. hashData.set(userValidationSalt, password.length);
  28730. var result = calculateSHA256(hashData, 0, hashData.length);
  28731. return compareByteArrays(result, userPassword);
  28732. },
  28733. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  28734. var hashData = new Uint8Array(password.length + 56);
  28735. hashData.set(password, 0);
  28736. hashData.set(ownerKeySalt, password.length);
  28737. hashData.set(userBytes, password.length + ownerKeySalt.length);
  28738. var key = calculateSHA256(hashData, 0, hashData.length);
  28739. var cipher = new AES256Cipher(key);
  28740. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  28741. },
  28742. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  28743. var hashData = new Uint8Array(password.length + 8);
  28744. hashData.set(password, 0);
  28745. hashData.set(userKeySalt, password.length);
  28746. var key = calculateSHA256(hashData, 0, hashData.length);
  28747. var cipher = new AES256Cipher(key);
  28748. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  28749. }
  28750. };
  28751. return PDF17;
  28752. }();
  28753. var PDF20 = function PDF20Closure() {
  28754. function concatArrays(array1, array2) {
  28755. var t = new Uint8Array(array1.length + array2.length);
  28756. t.set(array1, 0);
  28757. t.set(array2, array1.length);
  28758. return t;
  28759. }
  28760. function calculatePDF20Hash(password, input, userBytes) {
  28761. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  28762. var e = [0];
  28763. var i = 0;
  28764. while (i < 64 || e[e.length - 1] > i - 32) {
  28765. var arrayLength = password.length + k.length + userBytes.length;
  28766. var k1 = new Uint8Array(arrayLength * 64);
  28767. var array = concatArrays(password, k);
  28768. array = concatArrays(array, userBytes);
  28769. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  28770. k1.set(array, pos);
  28771. }
  28772. var cipher = new AES128Cipher(k.subarray(0, 16));
  28773. e = cipher.encrypt(k1, k.subarray(16, 32));
  28774. var remainder = 0;
  28775. for (var z = 0; z < 16; z++) {
  28776. remainder *= 256 % 3;
  28777. remainder %= 3;
  28778. remainder += (e[z] >>> 0) % 3;
  28779. remainder %= 3;
  28780. }
  28781. if (remainder === 0) {
  28782. k = calculateSHA256(e, 0, e.length);
  28783. } else if (remainder === 1) {
  28784. k = calculateSHA384(e, 0, e.length);
  28785. } else if (remainder === 2) {
  28786. k = calculateSHA512(e, 0, e.length);
  28787. }
  28788. i++;
  28789. }
  28790. return k.subarray(0, 32);
  28791. }
  28792. function PDF20() {
  28793. }
  28794. function compareByteArrays(array1, array2) {
  28795. if (array1.length !== array2.length) {
  28796. return false;
  28797. }
  28798. for (var i = 0; i < array1.length; i++) {
  28799. if (array1[i] !== array2[i]) {
  28800. return false;
  28801. }
  28802. }
  28803. return true;
  28804. }
  28805. PDF20.prototype = {
  28806. hash: function PDF20_hash(password, concatBytes, userBytes) {
  28807. return calculatePDF20Hash(password, concatBytes, userBytes);
  28808. },
  28809. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  28810. var hashData = new Uint8Array(password.length + 56);
  28811. hashData.set(password, 0);
  28812. hashData.set(ownerValidationSalt, password.length);
  28813. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  28814. var result = calculatePDF20Hash(password, hashData, userBytes);
  28815. return compareByteArrays(result, ownerPassword);
  28816. },
  28817. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  28818. var hashData = new Uint8Array(password.length + 8);
  28819. hashData.set(password, 0);
  28820. hashData.set(userValidationSalt, password.length);
  28821. var result = calculatePDF20Hash(password, hashData, []);
  28822. return compareByteArrays(result, userPassword);
  28823. },
  28824. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  28825. var hashData = new Uint8Array(password.length + 56);
  28826. hashData.set(password, 0);
  28827. hashData.set(ownerKeySalt, password.length);
  28828. hashData.set(userBytes, password.length + ownerKeySalt.length);
  28829. var key = calculatePDF20Hash(password, hashData, userBytes);
  28830. var cipher = new AES256Cipher(key);
  28831. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  28832. },
  28833. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  28834. var hashData = new Uint8Array(password.length + 8);
  28835. hashData.set(password, 0);
  28836. hashData.set(userKeySalt, password.length);
  28837. var key = calculatePDF20Hash(password, hashData, []);
  28838. var cipher = new AES256Cipher(key);
  28839. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  28840. }
  28841. };
  28842. return PDF20;
  28843. }();
  28844. var CipherTransform = function CipherTransformClosure() {
  28845. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  28846. this.StringCipherConstructor = stringCipherConstructor;
  28847. this.StreamCipherConstructor = streamCipherConstructor;
  28848. }
  28849. CipherTransform.prototype = {
  28850. createStream: function CipherTransform_createStream(stream, length) {
  28851. var cipher = new this.StreamCipherConstructor();
  28852. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  28853. return cipher.decryptBlock(data, finalize);
  28854. });
  28855. },
  28856. decryptString: function CipherTransform_decryptString(s) {
  28857. var cipher = new this.StringCipherConstructor();
  28858. var data = stringToBytes(s);
  28859. data = cipher.decryptBlock(data, true);
  28860. return bytesToString(data);
  28861. }
  28862. };
  28863. return CipherTransform;
  28864. }();
  28865. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  28866. var defaultPasswordBytes = new Uint8Array([
  28867. 0x28,
  28868. 0xBF,
  28869. 0x4E,
  28870. 0x5E,
  28871. 0x4E,
  28872. 0x75,
  28873. 0x8A,
  28874. 0x41,
  28875. 0x64,
  28876. 0x00,
  28877. 0x4E,
  28878. 0x56,
  28879. 0xFF,
  28880. 0xFA,
  28881. 0x01,
  28882. 0x08,
  28883. 0x2E,
  28884. 0x2E,
  28885. 0x00,
  28886. 0xB6,
  28887. 0xD0,
  28888. 0x68,
  28889. 0x3E,
  28890. 0x80,
  28891. 0x2F,
  28892. 0x0C,
  28893. 0xA9,
  28894. 0xFE,
  28895. 0x64,
  28896. 0x53,
  28897. 0x69,
  28898. 0x7A
  28899. ]);
  28900. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  28901. if (password) {
  28902. var passwordLength = Math.min(127, password.length);
  28903. password = password.subarray(0, passwordLength);
  28904. } else {
  28905. password = [];
  28906. }
  28907. var pdfAlgorithm;
  28908. if (revision === 6) {
  28909. pdfAlgorithm = new PDF20();
  28910. } else {
  28911. pdfAlgorithm = new PDF17();
  28912. }
  28913. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  28914. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  28915. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  28916. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  28917. }
  28918. return null;
  28919. }
  28920. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  28921. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  28922. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  28923. if (password) {
  28924. n = Math.min(32, password.length);
  28925. for (; i < n; ++i) {
  28926. hashData[i] = password[i];
  28927. }
  28928. }
  28929. j = 0;
  28930. while (i < 32) {
  28931. hashData[i++] = defaultPasswordBytes[j++];
  28932. }
  28933. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  28934. hashData[i++] = ownerPassword[j];
  28935. }
  28936. hashData[i++] = flags & 0xFF;
  28937. hashData[i++] = flags >> 8 & 0xFF;
  28938. hashData[i++] = flags >> 16 & 0xFF;
  28939. hashData[i++] = flags >>> 24 & 0xFF;
  28940. for (j = 0, n = fileId.length; j < n; ++j) {
  28941. hashData[i++] = fileId[j];
  28942. }
  28943. if (revision >= 4 && !encryptMetadata) {
  28944. hashData[i++] = 0xFF;
  28945. hashData[i++] = 0xFF;
  28946. hashData[i++] = 0xFF;
  28947. hashData[i++] = 0xFF;
  28948. }
  28949. var hash = calculateMD5(hashData, 0, i);
  28950. var keyLengthInBytes = keyLength >> 3;
  28951. if (revision >= 3) {
  28952. for (j = 0; j < 50; ++j) {
  28953. hash = calculateMD5(hash, 0, keyLengthInBytes);
  28954. }
  28955. }
  28956. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  28957. var cipher, checkData;
  28958. if (revision >= 3) {
  28959. for (i = 0; i < 32; ++i) {
  28960. hashData[i] = defaultPasswordBytes[i];
  28961. }
  28962. for (j = 0, n = fileId.length; j < n; ++j) {
  28963. hashData[i++] = fileId[j];
  28964. }
  28965. cipher = new ARCFourCipher(encryptionKey);
  28966. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  28967. n = encryptionKey.length;
  28968. var derivedKey = new Uint8Array(n), k;
  28969. for (j = 1; j <= 19; ++j) {
  28970. for (k = 0; k < n; ++k) {
  28971. derivedKey[k] = encryptionKey[k] ^ j;
  28972. }
  28973. cipher = new ARCFourCipher(derivedKey);
  28974. checkData = cipher.encryptBlock(checkData);
  28975. }
  28976. for (j = 0, n = checkData.length; j < n; ++j) {
  28977. if (userPassword[j] !== checkData[j]) {
  28978. return null;
  28979. }
  28980. }
  28981. } else {
  28982. cipher = new ARCFourCipher(encryptionKey);
  28983. checkData = cipher.encryptBlock(defaultPasswordBytes);
  28984. for (j = 0, n = checkData.length; j < n; ++j) {
  28985. if (userPassword[j] !== checkData[j]) {
  28986. return null;
  28987. }
  28988. }
  28989. }
  28990. return encryptionKey;
  28991. }
  28992. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  28993. var hashData = new Uint8Array(32), i = 0, j, n;
  28994. n = Math.min(32, password.length);
  28995. for (; i < n; ++i) {
  28996. hashData[i] = password[i];
  28997. }
  28998. j = 0;
  28999. while (i < 32) {
  29000. hashData[i++] = defaultPasswordBytes[j++];
  29001. }
  29002. var hash = calculateMD5(hashData, 0, i);
  29003. var keyLengthInBytes = keyLength >> 3;
  29004. if (revision >= 3) {
  29005. for (j = 0; j < 50; ++j) {
  29006. hash = calculateMD5(hash, 0, hash.length);
  29007. }
  29008. }
  29009. var cipher, userPassword;
  29010. if (revision >= 3) {
  29011. userPassword = ownerPassword;
  29012. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  29013. for (j = 19; j >= 0; j--) {
  29014. for (k = 0; k < keyLengthInBytes; ++k) {
  29015. derivedKey[k] = hash[k] ^ j;
  29016. }
  29017. cipher = new ARCFourCipher(derivedKey);
  29018. userPassword = cipher.encryptBlock(userPassword);
  29019. }
  29020. } else {
  29021. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  29022. userPassword = cipher.encryptBlock(ownerPassword);
  29023. }
  29024. return userPassword;
  29025. }
  29026. var identityName = Name.get('Identity');
  29027. function CipherTransformFactory(dict, fileId, password) {
  29028. var filter = dict.get('Filter');
  29029. if (!isName(filter, 'Standard')) {
  29030. error('unknown encryption method');
  29031. }
  29032. this.dict = dict;
  29033. var algorithm = dict.get('V');
  29034. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  29035. error('unsupported encryption algorithm');
  29036. }
  29037. this.algorithm = algorithm;
  29038. var keyLength = dict.get('Length');
  29039. if (!keyLength) {
  29040. if (algorithm <= 3) {
  29041. keyLength = 40;
  29042. } else {
  29043. var cfDict = dict.get('CF');
  29044. var streamCryptoName = dict.get('StmF');
  29045. if (isDict(cfDict) && isName(streamCryptoName)) {
  29046. cfDict.suppressEncryption = true;
  29047. var handlerDict = cfDict.get(streamCryptoName.name);
  29048. keyLength = handlerDict && handlerDict.get('Length') || 128;
  29049. if (keyLength < 40) {
  29050. keyLength <<= 3;
  29051. }
  29052. }
  29053. }
  29054. }
  29055. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  29056. error('invalid key length');
  29057. }
  29058. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  29059. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  29060. var flags = dict.get('P');
  29061. var revision = dict.get('R');
  29062. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  29063. this.encryptMetadata = encryptMetadata;
  29064. var fileIdBytes = stringToBytes(fileId);
  29065. var passwordBytes;
  29066. if (password) {
  29067. if (revision === 6) {
  29068. try {
  29069. password = utf8StringToString(password);
  29070. } catch (ex) {
  29071. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  29072. }
  29073. }
  29074. passwordBytes = stringToBytes(password);
  29075. }
  29076. var encryptionKey;
  29077. if (algorithm !== 5) {
  29078. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  29079. } else {
  29080. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  29081. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  29082. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  29083. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  29084. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  29085. var ownerEncryption = stringToBytes(dict.get('OE'));
  29086. var userEncryption = stringToBytes(dict.get('UE'));
  29087. var perms = stringToBytes(dict.get('Perms'));
  29088. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  29089. }
  29090. if (!encryptionKey && !password) {
  29091. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  29092. } else if (!encryptionKey && password) {
  29093. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  29094. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  29095. }
  29096. if (!encryptionKey) {
  29097. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  29098. }
  29099. this.encryptionKey = encryptionKey;
  29100. if (algorithm >= 4) {
  29101. var cf = dict.get('CF');
  29102. if (isDict(cf)) {
  29103. cf.suppressEncryption = true;
  29104. }
  29105. this.cf = cf;
  29106. this.stmf = dict.get('StmF') || identityName;
  29107. this.strf = dict.get('StrF') || identityName;
  29108. this.eff = dict.get('EFF') || this.stmf;
  29109. }
  29110. }
  29111. function buildObjectKey(num, gen, encryptionKey, isAes) {
  29112. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  29113. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  29114. key[i] = encryptionKey[i];
  29115. }
  29116. key[i++] = num & 0xFF;
  29117. key[i++] = num >> 8 & 0xFF;
  29118. key[i++] = num >> 16 & 0xFF;
  29119. key[i++] = gen & 0xFF;
  29120. key[i++] = gen >> 8 & 0xFF;
  29121. if (isAes) {
  29122. key[i++] = 0x73;
  29123. key[i++] = 0x41;
  29124. key[i++] = 0x6C;
  29125. key[i++] = 0x54;
  29126. }
  29127. var hash = calculateMD5(key, 0, i);
  29128. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  29129. }
  29130. function buildCipherConstructor(cf, name, num, gen, key) {
  29131. assert(isName(name), 'Invalid crypt filter name.');
  29132. var cryptFilter = cf.get(name.name);
  29133. var cfm;
  29134. if (cryptFilter !== null && cryptFilter !== undefined) {
  29135. cfm = cryptFilter.get('CFM');
  29136. }
  29137. if (!cfm || cfm.name === 'None') {
  29138. return function cipherTransformFactoryBuildCipherConstructorNone() {
  29139. return new NullCipher();
  29140. };
  29141. }
  29142. if (cfm.name === 'V2') {
  29143. return function cipherTransformFactoryBuildCipherConstructorV2() {
  29144. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  29145. };
  29146. }
  29147. if (cfm.name === 'AESV2') {
  29148. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  29149. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  29150. };
  29151. }
  29152. if (cfm.name === 'AESV3') {
  29153. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  29154. return new AES256Cipher(key);
  29155. };
  29156. }
  29157. error('Unknown crypto method');
  29158. }
  29159. CipherTransformFactory.prototype = {
  29160. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  29161. if (this.algorithm === 4 || this.algorithm === 5) {
  29162. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  29163. }
  29164. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  29165. var cipherConstructor = function buildCipherCipherConstructor() {
  29166. return new ARCFourCipher(key);
  29167. };
  29168. return new CipherTransform(cipherConstructor, cipherConstructor);
  29169. }
  29170. };
  29171. return CipherTransformFactory;
  29172. }();
  29173. exports.AES128Cipher = AES128Cipher;
  29174. exports.AES256Cipher = AES256Cipher;
  29175. exports.ARCFourCipher = ARCFourCipher;
  29176. exports.CipherTransformFactory = CipherTransformFactory;
  29177. exports.PDF17 = PDF17;
  29178. exports.PDF20 = PDF20;
  29179. exports.calculateMD5 = calculateMD5;
  29180. exports.calculateSHA256 = calculateSHA256;
  29181. exports.calculateSHA384 = calculateSHA384;
  29182. exports.calculateSHA512 = calculateSHA512;
  29183. /***/ }),
  29184. /* 17 */
  29185. /***/ (function(module, exports, __w_pdfjs_require__) {
  29186. "use strict";
  29187. var sharedUtil = __w_pdfjs_require__(0);
  29188. var corePrimitives = __w_pdfjs_require__(1);
  29189. var coreStream = __w_pdfjs_require__(2);
  29190. var coreParser = __w_pdfjs_require__(6);
  29191. var coreImage = __w_pdfjs_require__(34);
  29192. var coreColorSpace = __w_pdfjs_require__(4);
  29193. var coreMurmurHash3 = __w_pdfjs_require__(38);
  29194. var coreFonts = __w_pdfjs_require__(33);
  29195. var coreFunction = __w_pdfjs_require__(7);
  29196. var corePattern = __w_pdfjs_require__(40);
  29197. var coreCMap = __w_pdfjs_require__(30);
  29198. var coreMetrics = __w_pdfjs_require__(37);
  29199. var coreBidi = __w_pdfjs_require__(28);
  29200. var coreEncodings = __w_pdfjs_require__(5);
  29201. var coreStandardFonts = __w_pdfjs_require__(20);
  29202. var coreUnicode = __w_pdfjs_require__(21);
  29203. var coreGlyphList = __w_pdfjs_require__(8);
  29204. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  29205. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  29206. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  29207. var ImageKind = sharedUtil.ImageKind;
  29208. var OPS = sharedUtil.OPS;
  29209. var TextRenderingMode = sharedUtil.TextRenderingMode;
  29210. var CMapCompressionType = sharedUtil.CMapCompressionType;
  29211. var Util = sharedUtil.Util;
  29212. var assert = sharedUtil.assert;
  29213. var createPromiseCapability = sharedUtil.createPromiseCapability;
  29214. var error = sharedUtil.error;
  29215. var info = sharedUtil.info;
  29216. var isArray = sharedUtil.isArray;
  29217. var isNum = sharedUtil.isNum;
  29218. var isString = sharedUtil.isString;
  29219. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  29220. var warn = sharedUtil.warn;
  29221. var Dict = corePrimitives.Dict;
  29222. var Name = corePrimitives.Name;
  29223. var isEOF = corePrimitives.isEOF;
  29224. var isCmd = corePrimitives.isCmd;
  29225. var isDict = corePrimitives.isDict;
  29226. var isName = corePrimitives.isName;
  29227. var isRef = corePrimitives.isRef;
  29228. var isStream = corePrimitives.isStream;
  29229. var DecodeStream = coreStream.DecodeStream;
  29230. var JpegStream = coreStream.JpegStream;
  29231. var Stream = coreStream.Stream;
  29232. var Lexer = coreParser.Lexer;
  29233. var Parser = coreParser.Parser;
  29234. var PDFImage = coreImage.PDFImage;
  29235. var ColorSpace = coreColorSpace.ColorSpace;
  29236. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  29237. var ErrorFont = coreFonts.ErrorFont;
  29238. var FontFlags = coreFonts.FontFlags;
  29239. var Font = coreFonts.Font;
  29240. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  29241. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  29242. var getFontType = coreFonts.getFontType;
  29243. var isPDFFunction = coreFunction.isPDFFunction;
  29244. var PDFFunction = coreFunction.PDFFunction;
  29245. var Pattern = corePattern.Pattern;
  29246. var getTilingPatternIR = corePattern.getTilingPatternIR;
  29247. var CMapFactory = coreCMap.CMapFactory;
  29248. var IdentityCMap = coreCMap.IdentityCMap;
  29249. var getMetrics = coreMetrics.getMetrics;
  29250. var bidi = coreBidi.bidi;
  29251. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  29252. var StandardEncoding = coreEncodings.StandardEncoding;
  29253. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  29254. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  29255. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  29256. var getEncoding = coreEncodings.getEncoding;
  29257. var getStdFontMap = coreStandardFonts.getStdFontMap;
  29258. var getSerifFonts = coreStandardFonts.getSerifFonts;
  29259. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  29260. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  29261. var reverseIfRtl = coreUnicode.reverseIfRtl;
  29262. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  29263. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  29264. var PartialEvaluator = function PartialEvaluatorClosure() {
  29265. var DefaultPartialEvaluatorOptions = {
  29266. forceDataSchema: false,
  29267. maxImageSize: -1,
  29268. disableFontFace: false,
  29269. disableNativeImageDecoder: false
  29270. };
  29271. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  29272. this.xref = xref;
  29273. this.resources = resources;
  29274. this.handler = handler;
  29275. this.forceDataSchema = forceDataSchema;
  29276. }
  29277. NativeImageDecoder.prototype = {
  29278. canDecode: function (image) {
  29279. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  29280. },
  29281. decode: function (image) {
  29282. var dict = image.dict;
  29283. var colorSpace = dict.get('ColorSpace', 'CS');
  29284. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  29285. var numComps = colorSpace.numComps;
  29286. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  29287. image.getIR(this.forceDataSchema),
  29288. numComps
  29289. ]);
  29290. return decodePromise.then(function (message) {
  29291. var data = message.data;
  29292. return new Stream(data, 0, data.length, image.dict);
  29293. });
  29294. }
  29295. };
  29296. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  29297. var dict = image.dict;
  29298. if (dict.has('DecodeParms') || dict.has('DP')) {
  29299. return false;
  29300. }
  29301. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  29302. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  29303. };
  29304. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  29305. var dict = image.dict;
  29306. if (dict.has('DecodeParms') || dict.has('DP')) {
  29307. return false;
  29308. }
  29309. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  29310. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  29311. };
  29312. function PartialEvaluator(pdfManager, xref, handler, pageIndex, idFactory, fontCache, builtInCMapCache, options) {
  29313. this.pdfManager = pdfManager;
  29314. this.xref = xref;
  29315. this.handler = handler;
  29316. this.pageIndex = pageIndex;
  29317. this.idFactory = idFactory;
  29318. this.fontCache = fontCache;
  29319. this.builtInCMapCache = builtInCMapCache;
  29320. this.options = options || DefaultPartialEvaluatorOptions;
  29321. this.fetchBuiltInCMap = function (name) {
  29322. var cachedCMap = builtInCMapCache[name];
  29323. if (cachedCMap) {
  29324. return Promise.resolve(cachedCMap);
  29325. }
  29326. return handler.sendWithPromise('FetchBuiltInCMap', { name: name }).then(function (data) {
  29327. if (data.compressionType !== CMapCompressionType.NONE) {
  29328. builtInCMapCache[name] = data;
  29329. }
  29330. return data;
  29331. });
  29332. };
  29333. }
  29334. var TIME_SLOT_DURATION_MS = 20;
  29335. var CHECK_TIME_EVERY = 100;
  29336. function TimeSlotManager() {
  29337. this.reset();
  29338. }
  29339. TimeSlotManager.prototype = {
  29340. check: function TimeSlotManager_check() {
  29341. if (++this.checked < CHECK_TIME_EVERY) {
  29342. return false;
  29343. }
  29344. this.checked = 0;
  29345. return this.endTime <= Date.now();
  29346. },
  29347. reset: function TimeSlotManager_reset() {
  29348. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  29349. this.checked = 0;
  29350. }
  29351. };
  29352. var deferred = Promise.resolve();
  29353. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  29354. PartialEvaluator.prototype = {
  29355. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  29356. if (!isDict(resources)) {
  29357. return false;
  29358. }
  29359. var processed = Object.create(null);
  29360. if (resources.objId) {
  29361. processed[resources.objId] = true;
  29362. }
  29363. var nodes = [resources], xref = this.xref;
  29364. while (nodes.length) {
  29365. var key, i, ii;
  29366. var node = nodes.shift();
  29367. var graphicStates = node.get('ExtGState');
  29368. if (isDict(graphicStates)) {
  29369. var graphicStatesKeys = graphicStates.getKeys();
  29370. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  29371. key = graphicStatesKeys[i];
  29372. var graphicState = graphicStates.get(key);
  29373. var bm = graphicState.get('BM');
  29374. if (isName(bm) && bm.name !== 'Normal') {
  29375. return true;
  29376. }
  29377. }
  29378. }
  29379. var xObjects = node.get('XObject');
  29380. if (!isDict(xObjects)) {
  29381. continue;
  29382. }
  29383. var xObjectsKeys = xObjects.getKeys();
  29384. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  29385. key = xObjectsKeys[i];
  29386. var xObject = xObjects.getRaw(key);
  29387. if (isRef(xObject)) {
  29388. if (processed[xObject.toString()]) {
  29389. continue;
  29390. }
  29391. xObject = xref.fetch(xObject);
  29392. }
  29393. if (!isStream(xObject)) {
  29394. continue;
  29395. }
  29396. if (xObject.dict.objId) {
  29397. if (processed[xObject.dict.objId]) {
  29398. continue;
  29399. }
  29400. processed[xObject.dict.objId] = true;
  29401. }
  29402. var xResources = xObject.dict.get('Resources');
  29403. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  29404. nodes.push(xResources);
  29405. if (xResources.objId) {
  29406. processed[xResources.objId] = true;
  29407. }
  29408. }
  29409. }
  29410. }
  29411. return false;
  29412. },
  29413. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  29414. var matrix = xobj.dict.getArray('Matrix');
  29415. var bbox = xobj.dict.getArray('BBox');
  29416. var group = xobj.dict.get('Group');
  29417. if (group) {
  29418. var groupOptions = {
  29419. matrix: matrix,
  29420. bbox: bbox,
  29421. smask: smask,
  29422. isolated: false,
  29423. knockout: false
  29424. };
  29425. var groupSubtype = group.get('S');
  29426. var colorSpace;
  29427. if (isName(groupSubtype, 'Transparency')) {
  29428. groupOptions.isolated = group.get('I') || false;
  29429. groupOptions.knockout = group.get('K') || false;
  29430. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  29431. }
  29432. if (smask && smask.backdrop) {
  29433. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  29434. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  29435. }
  29436. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  29437. }
  29438. operatorList.addOp(OPS.paintFormXObjectBegin, [
  29439. matrix,
  29440. bbox
  29441. ]);
  29442. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  29443. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  29444. if (group) {
  29445. operatorList.addOp(OPS.endGroup, [groupOptions]);
  29446. }
  29447. });
  29448. },
  29449. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  29450. var self = this;
  29451. var dict = image.dict;
  29452. var w = dict.get('Width', 'W');
  29453. var h = dict.get('Height', 'H');
  29454. if (!(w && isNum(w)) || !(h && isNum(h))) {
  29455. warn('Image dimensions are missing, or not numbers.');
  29456. return;
  29457. }
  29458. var maxImageSize = this.options.maxImageSize;
  29459. if (maxImageSize !== -1 && w * h > maxImageSize) {
  29460. warn('Image exceeded maximum allowed size and was removed.');
  29461. return;
  29462. }
  29463. var imageMask = dict.get('ImageMask', 'IM') || false;
  29464. var imgData, args;
  29465. if (imageMask) {
  29466. var width = dict.get('Width', 'W');
  29467. var height = dict.get('Height', 'H');
  29468. var bitStrideLength = width + 7 >> 3;
  29469. var imgArray = image.getBytes(bitStrideLength * height);
  29470. var decode = dict.getArray('Decode', 'D');
  29471. var inverseDecode = !!decode && decode[0] > 0;
  29472. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  29473. imgData.cached = true;
  29474. args = [imgData];
  29475. operatorList.addOp(OPS.paintImageMaskXObject, args);
  29476. if (cacheKey) {
  29477. imageCache[cacheKey] = {
  29478. fn: OPS.paintImageMaskXObject,
  29479. args: args
  29480. };
  29481. }
  29482. return;
  29483. }
  29484. var softMask = dict.get('SMask', 'SM') || false;
  29485. var mask = dict.get('Mask') || false;
  29486. var SMALL_IMAGE_DIMENSIONS = 200;
  29487. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  29488. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  29489. imgData = imageObj.createImageData(true);
  29490. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  29491. return;
  29492. }
  29493. var useNativeImageDecoder = !this.options.disableNativeImageDecoder;
  29494. var objId = 'img_' + this.idFactory.createObjId();
  29495. operatorList.addDependency(objId);
  29496. args = [
  29497. objId,
  29498. w,
  29499. h
  29500. ];
  29501. if (useNativeImageDecoder && !softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  29502. operatorList.addOp(OPS.paintJpegXObject, args);
  29503. this.handler.send('obj', [
  29504. objId,
  29505. this.pageIndex,
  29506. 'JpegStream',
  29507. image.getIR(this.options.forceDataSchema)
  29508. ]);
  29509. return;
  29510. }
  29511. var nativeImageDecoder = null;
  29512. if (useNativeImageDecoder && (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream)) {
  29513. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  29514. }
  29515. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  29516. var imgData = imageObj.createImageData(false);
  29517. self.handler.send('obj', [
  29518. objId,
  29519. self.pageIndex,
  29520. 'Image',
  29521. imgData
  29522. ], [imgData.data.buffer]);
  29523. }).then(undefined, function (reason) {
  29524. warn('Unable to decode image: ' + reason);
  29525. self.handler.send('obj', [
  29526. objId,
  29527. self.pageIndex,
  29528. 'Image',
  29529. null
  29530. ]);
  29531. });
  29532. operatorList.addOp(OPS.paintImageXObject, args);
  29533. if (cacheKey) {
  29534. imageCache[cacheKey] = {
  29535. fn: OPS.paintImageXObject,
  29536. args: args
  29537. };
  29538. }
  29539. },
  29540. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  29541. var smaskContent = smask.get('G');
  29542. var smaskOptions = {
  29543. subtype: smask.get('S').name,
  29544. backdrop: smask.get('BC')
  29545. };
  29546. var transferObj = smask.get('TR');
  29547. if (isPDFFunction(transferObj)) {
  29548. var transferFn = PDFFunction.parse(this.xref, transferObj);
  29549. var transferMap = new Uint8Array(256);
  29550. var tmp = new Float32Array(1);
  29551. for (var i = 0; i < 256; i++) {
  29552. tmp[0] = i / 255;
  29553. transferFn(tmp, 0, tmp, 0);
  29554. transferMap[i] = tmp[0] * 255 | 0;
  29555. }
  29556. smaskOptions.transferMap = transferMap;
  29557. }
  29558. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  29559. },
  29560. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  29561. var tilingOpList = new OperatorList();
  29562. var resourcesArray = [
  29563. patternDict.get('Resources'),
  29564. resources
  29565. ];
  29566. var patternResources = Dict.merge(this.xref, resourcesArray);
  29567. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  29568. operatorList.addDependencies(tilingOpList.dependencies);
  29569. operatorList.addOp(fn, getTilingPatternIR({
  29570. fnArray: tilingOpList.fnArray,
  29571. argsArray: tilingOpList.argsArray
  29572. }, patternDict, args));
  29573. });
  29574. },
  29575. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  29576. var fontName;
  29577. if (fontArgs) {
  29578. fontArgs = fontArgs.slice();
  29579. fontName = fontArgs[0].name;
  29580. }
  29581. var self = this;
  29582. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  29583. if (!translated.font.isType3Font) {
  29584. return translated;
  29585. }
  29586. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  29587. return translated;
  29588. }, function (reason) {
  29589. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  29590. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  29591. });
  29592. }).then(function (translated) {
  29593. state.font = translated.font;
  29594. translated.send(self.handler);
  29595. return translated.loadedName;
  29596. });
  29597. },
  29598. handleText: function PartialEvaluator_handleText(chars, state) {
  29599. var font = state.font;
  29600. var glyphs = font.charsToGlyphs(chars);
  29601. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  29602. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  29603. var buildPath = function (fontChar) {
  29604. if (!font.renderer.hasBuiltPath(fontChar)) {
  29605. var path = font.renderer.getPathJs(fontChar);
  29606. this.handler.send('commonobj', [
  29607. font.loadedName + '_path_' + fontChar,
  29608. 'FontPath',
  29609. path
  29610. ]);
  29611. }
  29612. }.bind(this);
  29613. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  29614. var glyph = glyphs[i];
  29615. buildPath(glyph.fontChar);
  29616. var accent = glyph.accent;
  29617. if (accent && accent.fontChar) {
  29618. buildPath(accent.fontChar);
  29619. }
  29620. }
  29621. }
  29622. return glyphs;
  29623. },
  29624. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  29625. var gStateObj = [];
  29626. var gStateKeys = gState.getKeys();
  29627. var self = this;
  29628. var promise = Promise.resolve();
  29629. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  29630. var key = gStateKeys[i];
  29631. var value = gState.get(key);
  29632. switch (key) {
  29633. case 'Type':
  29634. break;
  29635. case 'LW':
  29636. case 'LC':
  29637. case 'LJ':
  29638. case 'ML':
  29639. case 'D':
  29640. case 'RI':
  29641. case 'FL':
  29642. case 'CA':
  29643. case 'ca':
  29644. gStateObj.push([
  29645. key,
  29646. value
  29647. ]);
  29648. break;
  29649. case 'Font':
  29650. promise = promise.then(function () {
  29651. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  29652. operatorList.addDependency(loadedName);
  29653. gStateObj.push([
  29654. key,
  29655. [
  29656. loadedName,
  29657. value[1]
  29658. ]
  29659. ]);
  29660. });
  29661. });
  29662. break;
  29663. case 'BM':
  29664. gStateObj.push([
  29665. key,
  29666. value
  29667. ]);
  29668. break;
  29669. case 'SMask':
  29670. if (isName(value, 'None')) {
  29671. gStateObj.push([
  29672. key,
  29673. false
  29674. ]);
  29675. break;
  29676. }
  29677. if (isDict(value)) {
  29678. promise = promise.then(function (dict) {
  29679. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  29680. }.bind(this, value));
  29681. gStateObj.push([
  29682. key,
  29683. true
  29684. ]);
  29685. } else {
  29686. warn('Unsupported SMask type');
  29687. }
  29688. break;
  29689. case 'OP':
  29690. case 'op':
  29691. case 'OPM':
  29692. case 'BG':
  29693. case 'BG2':
  29694. case 'UCR':
  29695. case 'UCR2':
  29696. case 'TR':
  29697. case 'TR2':
  29698. case 'HT':
  29699. case 'SM':
  29700. case 'SA':
  29701. case 'AIS':
  29702. case 'TK':
  29703. info('graphic state operator ' + key);
  29704. break;
  29705. default:
  29706. info('Unknown graphic state operator ' + key);
  29707. break;
  29708. }
  29709. }
  29710. return promise.then(function () {
  29711. if (gStateObj.length > 0) {
  29712. operatorList.addOp(OPS.setGState, [gStateObj]);
  29713. }
  29714. });
  29715. },
  29716. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  29717. function errorFont() {
  29718. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  29719. }
  29720. var fontRef;
  29721. if (font) {
  29722. assert(isRef(font));
  29723. fontRef = font;
  29724. } else {
  29725. var fontRes = resources.get('Font');
  29726. if (fontRes) {
  29727. fontRef = fontRes.getRaw(fontName);
  29728. } else {
  29729. warn('fontRes not available');
  29730. return errorFont();
  29731. }
  29732. }
  29733. if (!fontRef) {
  29734. warn('fontRef not available');
  29735. return errorFont();
  29736. }
  29737. if (this.fontCache.has(fontRef)) {
  29738. return this.fontCache.get(fontRef);
  29739. }
  29740. font = xref.fetchIfRef(fontRef);
  29741. if (!isDict(font)) {
  29742. return errorFont();
  29743. }
  29744. if (font.translated) {
  29745. return font.translated;
  29746. }
  29747. var fontCapability = createPromiseCapability();
  29748. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  29749. var descriptor = preEvaluatedFont.descriptor;
  29750. var fontRefIsRef = isRef(fontRef), fontID;
  29751. if (fontRefIsRef) {
  29752. fontID = fontRef.toString();
  29753. }
  29754. if (isDict(descriptor)) {
  29755. if (!descriptor.fontAliases) {
  29756. descriptor.fontAliases = Object.create(null);
  29757. }
  29758. var fontAliases = descriptor.fontAliases;
  29759. var hash = preEvaluatedFont.hash;
  29760. if (fontAliases[hash]) {
  29761. var aliasFontRef = fontAliases[hash].aliasRef;
  29762. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  29763. this.fontCache.putAlias(fontRef, aliasFontRef);
  29764. return this.fontCache.get(fontRef);
  29765. }
  29766. } else {
  29767. fontAliases[hash] = { fontID: Font.getFontID() };
  29768. }
  29769. if (fontRefIsRef) {
  29770. fontAliases[hash].aliasRef = fontRef;
  29771. }
  29772. fontID = fontAliases[hash].fontID;
  29773. }
  29774. if (fontRefIsRef) {
  29775. this.fontCache.put(fontRef, fontCapability.promise);
  29776. } else {
  29777. if (!fontID) {
  29778. fontID = this.idFactory.createObjId();
  29779. }
  29780. this.fontCache.put('id_' + fontID, fontCapability.promise);
  29781. }
  29782. assert(fontID, 'The "fontID" must be defined.');
  29783. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  29784. font.translated = fontCapability.promise;
  29785. var translatedPromise;
  29786. try {
  29787. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  29788. } catch (e) {
  29789. translatedPromise = Promise.reject(e);
  29790. }
  29791. var self = this;
  29792. translatedPromise.then(function (translatedFont) {
  29793. if (translatedFont.fontType !== undefined) {
  29794. var xrefFontStats = xref.stats.fontTypes;
  29795. xrefFontStats[translatedFont.fontType] = true;
  29796. }
  29797. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  29798. }, function (reason) {
  29799. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  29800. try {
  29801. var descriptor = preEvaluatedFont.descriptor;
  29802. var fontFile3 = descriptor && descriptor.get('FontFile3');
  29803. var subtype = fontFile3 && fontFile3.get('Subtype');
  29804. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  29805. var xrefFontStats = xref.stats.fontTypes;
  29806. xrefFontStats[fontType] = true;
  29807. } catch (ex) {
  29808. }
  29809. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  29810. });
  29811. return fontCapability.promise;
  29812. },
  29813. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  29814. var lastIndex = operatorList.length - 1;
  29815. if (!args) {
  29816. args = [];
  29817. }
  29818. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  29819. operatorList.addOp(OPS.constructPath, [
  29820. [fn],
  29821. args
  29822. ]);
  29823. } else {
  29824. var opArgs = operatorList.argsArray[lastIndex];
  29825. opArgs[0].push(fn);
  29826. Array.prototype.push.apply(opArgs[1], args);
  29827. }
  29828. },
  29829. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  29830. var patternName = args[args.length - 1];
  29831. var pattern;
  29832. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  29833. var dict = isStream(pattern) ? pattern.dict : pattern;
  29834. var typeNum = dict.get('PatternType');
  29835. if (typeNum === TILING_PATTERN) {
  29836. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  29837. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  29838. } else if (typeNum === SHADING_PATTERN) {
  29839. var shading = dict.get('Shading');
  29840. var matrix = dict.getArray('Matrix');
  29841. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  29842. operatorList.addOp(fn, pattern.getIR());
  29843. return Promise.resolve();
  29844. }
  29845. return Promise.reject('Unknown PatternType: ' + typeNum);
  29846. }
  29847. operatorList.addOp(fn, args);
  29848. return Promise.resolve();
  29849. },
  29850. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  29851. var self = this;
  29852. var xref = this.xref;
  29853. var imageCache = Object.create(null);
  29854. assert(operatorList);
  29855. resources = resources || Dict.empty;
  29856. var xobjs = resources.get('XObject') || Dict.empty;
  29857. var patterns = resources.get('Pattern') || Dict.empty;
  29858. var stateManager = new StateManager(initialState || new EvalState());
  29859. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  29860. var timeSlotManager = new TimeSlotManager();
  29861. return new Promise(function promiseBody(resolve, reject) {
  29862. var next = function (promise) {
  29863. promise.then(function () {
  29864. try {
  29865. promiseBody(resolve, reject);
  29866. } catch (ex) {
  29867. reject(ex);
  29868. }
  29869. }, reject);
  29870. };
  29871. task.ensureNotTerminated();
  29872. timeSlotManager.reset();
  29873. var stop, operation = {}, i, ii, cs;
  29874. while (!(stop = timeSlotManager.check())) {
  29875. operation.args = null;
  29876. if (!preprocessor.read(operation)) {
  29877. break;
  29878. }
  29879. var args = operation.args;
  29880. var fn = operation.fn;
  29881. switch (fn | 0) {
  29882. case OPS.paintXObject:
  29883. if (args[0].code) {
  29884. break;
  29885. }
  29886. var name = args[0].name;
  29887. if (!name) {
  29888. warn('XObject must be referred to by name.');
  29889. continue;
  29890. }
  29891. if (imageCache[name] !== undefined) {
  29892. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  29893. args = null;
  29894. continue;
  29895. }
  29896. var xobj = xobjs.get(name);
  29897. if (xobj) {
  29898. assert(isStream(xobj), 'XObject should be a stream');
  29899. var type = xobj.dict.get('Subtype');
  29900. assert(isName(type), 'XObject should have a Name subtype');
  29901. if (type.name === 'Form') {
  29902. stateManager.save();
  29903. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  29904. stateManager.restore();
  29905. }));
  29906. return;
  29907. } else if (type.name === 'Image') {
  29908. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  29909. args = null;
  29910. continue;
  29911. } else if (type.name === 'PS') {
  29912. info('Ignored XObject subtype PS');
  29913. continue;
  29914. } else {
  29915. error('Unhandled XObject subtype ' + type.name);
  29916. }
  29917. }
  29918. break;
  29919. case OPS.setFont:
  29920. var fontSize = args[1];
  29921. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  29922. operatorList.addDependency(loadedName);
  29923. operatorList.addOp(OPS.setFont, [
  29924. loadedName,
  29925. fontSize
  29926. ]);
  29927. }));
  29928. return;
  29929. case OPS.endInlineImage:
  29930. var cacheKey = args[0].cacheKey;
  29931. if (cacheKey) {
  29932. var cacheEntry = imageCache[cacheKey];
  29933. if (cacheEntry !== undefined) {
  29934. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  29935. args = null;
  29936. continue;
  29937. }
  29938. }
  29939. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  29940. args = null;
  29941. continue;
  29942. case OPS.showText:
  29943. args[0] = self.handleText(args[0], stateManager.state);
  29944. break;
  29945. case OPS.showSpacedText:
  29946. var arr = args[0];
  29947. var combinedGlyphs = [];
  29948. var arrLength = arr.length;
  29949. var state = stateManager.state;
  29950. for (i = 0; i < arrLength; ++i) {
  29951. var arrItem = arr[i];
  29952. if (isString(arrItem)) {
  29953. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  29954. } else if (isNum(arrItem)) {
  29955. combinedGlyphs.push(arrItem);
  29956. }
  29957. }
  29958. args[0] = combinedGlyphs;
  29959. fn = OPS.showText;
  29960. break;
  29961. case OPS.nextLineShowText:
  29962. operatorList.addOp(OPS.nextLine);
  29963. args[0] = self.handleText(args[0], stateManager.state);
  29964. fn = OPS.showText;
  29965. break;
  29966. case OPS.nextLineSetSpacingShowText:
  29967. operatorList.addOp(OPS.nextLine);
  29968. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  29969. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  29970. args[0] = self.handleText(args[0], stateManager.state);
  29971. fn = OPS.showText;
  29972. break;
  29973. case OPS.setTextRenderingMode:
  29974. stateManager.state.textRenderingMode = args[0];
  29975. break;
  29976. case OPS.setFillColorSpace:
  29977. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  29978. continue;
  29979. case OPS.setStrokeColorSpace:
  29980. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  29981. continue;
  29982. case OPS.setFillColor:
  29983. cs = stateManager.state.fillColorSpace;
  29984. args = cs.getRgb(args, 0);
  29985. fn = OPS.setFillRGBColor;
  29986. break;
  29987. case OPS.setStrokeColor:
  29988. cs = stateManager.state.strokeColorSpace;
  29989. args = cs.getRgb(args, 0);
  29990. fn = OPS.setStrokeRGBColor;
  29991. break;
  29992. case OPS.setFillGray:
  29993. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  29994. args = ColorSpace.singletons.gray.getRgb(args, 0);
  29995. fn = OPS.setFillRGBColor;
  29996. break;
  29997. case OPS.setStrokeGray:
  29998. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  29999. args = ColorSpace.singletons.gray.getRgb(args, 0);
  30000. fn = OPS.setStrokeRGBColor;
  30001. break;
  30002. case OPS.setFillCMYKColor:
  30003. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  30004. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  30005. fn = OPS.setFillRGBColor;
  30006. break;
  30007. case OPS.setStrokeCMYKColor:
  30008. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  30009. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  30010. fn = OPS.setStrokeRGBColor;
  30011. break;
  30012. case OPS.setFillRGBColor:
  30013. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  30014. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  30015. break;
  30016. case OPS.setStrokeRGBColor:
  30017. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  30018. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  30019. break;
  30020. case OPS.setFillColorN:
  30021. cs = stateManager.state.fillColorSpace;
  30022. if (cs.name === 'Pattern') {
  30023. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  30024. return;
  30025. }
  30026. args = cs.getRgb(args, 0);
  30027. fn = OPS.setFillRGBColor;
  30028. break;
  30029. case OPS.setStrokeColorN:
  30030. cs = stateManager.state.strokeColorSpace;
  30031. if (cs.name === 'Pattern') {
  30032. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  30033. return;
  30034. }
  30035. args = cs.getRgb(args, 0);
  30036. fn = OPS.setStrokeRGBColor;
  30037. break;
  30038. case OPS.shadingFill:
  30039. var shadingRes = resources.get('Shading');
  30040. if (!shadingRes) {
  30041. error('No shading resource found');
  30042. }
  30043. var shading = shadingRes.get(args[0].name);
  30044. if (!shading) {
  30045. error('No shading object found');
  30046. }
  30047. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  30048. var patternIR = shadingFill.getIR();
  30049. args = [patternIR];
  30050. fn = OPS.shadingFill;
  30051. break;
  30052. case OPS.setGState:
  30053. var dictName = args[0];
  30054. var extGState = resources.get('ExtGState');
  30055. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  30056. break;
  30057. }
  30058. var gState = extGState.get(dictName.name);
  30059. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  30060. return;
  30061. case OPS.moveTo:
  30062. case OPS.lineTo:
  30063. case OPS.curveTo:
  30064. case OPS.curveTo2:
  30065. case OPS.curveTo3:
  30066. case OPS.closePath:
  30067. self.buildPath(operatorList, fn, args);
  30068. continue;
  30069. case OPS.rectangle:
  30070. self.buildPath(operatorList, fn, args);
  30071. continue;
  30072. case OPS.markPoint:
  30073. case OPS.markPointProps:
  30074. case OPS.beginMarkedContent:
  30075. case OPS.beginMarkedContentProps:
  30076. case OPS.endMarkedContent:
  30077. case OPS.beginCompat:
  30078. case OPS.endCompat:
  30079. continue;
  30080. default:
  30081. if (args !== null) {
  30082. for (i = 0, ii = args.length; i < ii; i++) {
  30083. if (args[i] instanceof Dict) {
  30084. break;
  30085. }
  30086. }
  30087. if (i < ii) {
  30088. warn('getOperatorList - ignoring operator: ' + fn);
  30089. continue;
  30090. }
  30091. }
  30092. }
  30093. operatorList.addOp(fn, args);
  30094. }
  30095. if (stop) {
  30096. next(deferred);
  30097. return;
  30098. }
  30099. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  30100. operatorList.addOp(OPS.restore, []);
  30101. }
  30102. resolve();
  30103. });
  30104. },
  30105. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  30106. stateManager = stateManager || new StateManager(new TextState());
  30107. var WhitespaceRegexp = /\s/g;
  30108. var textContent = {
  30109. items: [],
  30110. styles: Object.create(null)
  30111. };
  30112. var textContentItem = {
  30113. initialized: false,
  30114. str: [],
  30115. width: 0,
  30116. height: 0,
  30117. vertical: false,
  30118. lastAdvanceWidth: 0,
  30119. lastAdvanceHeight: 0,
  30120. textAdvanceScale: 0,
  30121. spaceWidth: 0,
  30122. fakeSpaceMin: Infinity,
  30123. fakeMultiSpaceMin: Infinity,
  30124. fakeMultiSpaceMax: -0,
  30125. textRunBreakAllowed: false,
  30126. transform: null,
  30127. fontName: null
  30128. };
  30129. var SPACE_FACTOR = 0.3;
  30130. var MULTI_SPACE_FACTOR = 1.5;
  30131. var MULTI_SPACE_FACTOR_MAX = 4;
  30132. var self = this;
  30133. var xref = this.xref;
  30134. resources = xref.fetchIfRef(resources) || Dict.empty;
  30135. var xobjs = null;
  30136. var xobjsCache = Object.create(null);
  30137. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  30138. var textState;
  30139. function ensureTextContentItem() {
  30140. if (textContentItem.initialized) {
  30141. return textContentItem;
  30142. }
  30143. var font = textState.font;
  30144. if (!(font.loadedName in textContent.styles)) {
  30145. textContent.styles[font.loadedName] = {
  30146. fontFamily: font.fallbackName,
  30147. ascent: font.ascent,
  30148. descent: font.descent,
  30149. vertical: font.vertical
  30150. };
  30151. }
  30152. textContentItem.fontName = font.loadedName;
  30153. var tsm = [
  30154. textState.fontSize * textState.textHScale,
  30155. 0,
  30156. 0,
  30157. textState.fontSize,
  30158. 0,
  30159. textState.textRise
  30160. ];
  30161. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  30162. var glyphHeight = font.bbox[3] - font.bbox[1];
  30163. if (glyphHeight > 0) {
  30164. glyphHeight = glyphHeight * textState.fontMatrix[3];
  30165. tsm[3] *= glyphHeight;
  30166. }
  30167. }
  30168. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  30169. textContentItem.transform = trm;
  30170. if (!font.vertical) {
  30171. textContentItem.width = 0;
  30172. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  30173. textContentItem.vertical = false;
  30174. } else {
  30175. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  30176. textContentItem.height = 0;
  30177. textContentItem.vertical = true;
  30178. }
  30179. var a = textState.textLineMatrix[0];
  30180. var b = textState.textLineMatrix[1];
  30181. var scaleLineX = Math.sqrt(a * a + b * b);
  30182. a = textState.ctm[0];
  30183. b = textState.ctm[1];
  30184. var scaleCtmX = Math.sqrt(a * a + b * b);
  30185. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  30186. textContentItem.lastAdvanceWidth = 0;
  30187. textContentItem.lastAdvanceHeight = 0;
  30188. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  30189. if (spaceWidth) {
  30190. textContentItem.spaceWidth = spaceWidth;
  30191. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  30192. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  30193. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  30194. textContentItem.textRunBreakAllowed = !font.isMonospace;
  30195. } else {
  30196. textContentItem.spaceWidth = 0;
  30197. textContentItem.fakeSpaceMin = Infinity;
  30198. textContentItem.fakeMultiSpaceMin = Infinity;
  30199. textContentItem.fakeMultiSpaceMax = 0;
  30200. textContentItem.textRunBreakAllowed = false;
  30201. }
  30202. textContentItem.initialized = true;
  30203. return textContentItem;
  30204. }
  30205. function replaceWhitespace(str) {
  30206. var i = 0, ii = str.length, code;
  30207. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  30208. i++;
  30209. }
  30210. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  30211. }
  30212. function runBidiTransform(textChunk) {
  30213. var str = textChunk.str.join('');
  30214. var bidiResult = bidi(str, -1, textChunk.vertical);
  30215. return {
  30216. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  30217. dir: bidiResult.dir,
  30218. width: textChunk.width,
  30219. height: textChunk.height,
  30220. transform: textChunk.transform,
  30221. fontName: textChunk.fontName
  30222. };
  30223. }
  30224. function handleSetFont(fontName, fontRef) {
  30225. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  30226. textState.font = translated.font;
  30227. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  30228. });
  30229. }
  30230. function buildTextContentItem(chars) {
  30231. var font = textState.font;
  30232. var textChunk = ensureTextContentItem();
  30233. var width = 0;
  30234. var height = 0;
  30235. var glyphs = font.charsToGlyphs(chars);
  30236. for (var i = 0; i < glyphs.length; i++) {
  30237. var glyph = glyphs[i];
  30238. var glyphWidth = null;
  30239. if (font.vertical && glyph.vmetric) {
  30240. glyphWidth = glyph.vmetric[0];
  30241. } else {
  30242. glyphWidth = glyph.width;
  30243. }
  30244. var glyphUnicode = glyph.unicode;
  30245. var NormalizedUnicodes = getNormalizedUnicodes();
  30246. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  30247. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  30248. }
  30249. glyphUnicode = reverseIfRtl(glyphUnicode);
  30250. var charSpacing = textState.charSpacing;
  30251. if (glyph.isSpace) {
  30252. var wordSpacing = textState.wordSpacing;
  30253. charSpacing += wordSpacing;
  30254. if (wordSpacing > 0) {
  30255. addFakeSpaces(wordSpacing, textChunk.str);
  30256. }
  30257. }
  30258. var tx = 0;
  30259. var ty = 0;
  30260. if (!font.vertical) {
  30261. var w0 = glyphWidth * textState.fontMatrix[0];
  30262. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  30263. width += tx;
  30264. } else {
  30265. var w1 = glyphWidth * textState.fontMatrix[0];
  30266. ty = w1 * textState.fontSize + charSpacing;
  30267. height += ty;
  30268. }
  30269. textState.translateTextMatrix(tx, ty);
  30270. textChunk.str.push(glyphUnicode);
  30271. }
  30272. if (!font.vertical) {
  30273. textChunk.lastAdvanceWidth = width;
  30274. textChunk.width += width;
  30275. } else {
  30276. textChunk.lastAdvanceHeight = height;
  30277. textChunk.height += Math.abs(height);
  30278. }
  30279. return textChunk;
  30280. }
  30281. function addFakeSpaces(width, strBuf) {
  30282. if (width < textContentItem.fakeSpaceMin) {
  30283. return;
  30284. }
  30285. if (width < textContentItem.fakeMultiSpaceMin) {
  30286. strBuf.push(' ');
  30287. return;
  30288. }
  30289. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  30290. while (fakeSpaces-- > 0) {
  30291. strBuf.push(' ');
  30292. }
  30293. }
  30294. function flushTextContentItem() {
  30295. if (!textContentItem.initialized) {
  30296. return;
  30297. }
  30298. textContentItem.width *= textContentItem.textAdvanceScale;
  30299. textContentItem.height *= textContentItem.textAdvanceScale;
  30300. textContent.items.push(runBidiTransform(textContentItem));
  30301. textContentItem.initialized = false;
  30302. textContentItem.str.length = 0;
  30303. }
  30304. var timeSlotManager = new TimeSlotManager();
  30305. return new Promise(function promiseBody(resolve, reject) {
  30306. var next = function (promise) {
  30307. promise.then(function () {
  30308. try {
  30309. promiseBody(resolve, reject);
  30310. } catch (ex) {
  30311. reject(ex);
  30312. }
  30313. }, reject);
  30314. };
  30315. task.ensureNotTerminated();
  30316. timeSlotManager.reset();
  30317. var stop, operation = {}, args = [];
  30318. while (!(stop = timeSlotManager.check())) {
  30319. args.length = 0;
  30320. operation.args = args;
  30321. if (!preprocessor.read(operation)) {
  30322. break;
  30323. }
  30324. textState = stateManager.state;
  30325. var fn = operation.fn;
  30326. args = operation.args;
  30327. var advance, diff;
  30328. switch (fn | 0) {
  30329. case OPS.setFont:
  30330. var fontNameArg = args[0].name, fontSizeArg = args[1];
  30331. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  30332. break;
  30333. }
  30334. flushTextContentItem();
  30335. textState.fontName = fontNameArg;
  30336. textState.fontSize = fontSizeArg;
  30337. next(handleSetFont(fontNameArg, null));
  30338. return;
  30339. case OPS.setTextRise:
  30340. flushTextContentItem();
  30341. textState.textRise = args[0];
  30342. break;
  30343. case OPS.setHScale:
  30344. flushTextContentItem();
  30345. textState.textHScale = args[0] / 100;
  30346. break;
  30347. case OPS.setLeading:
  30348. flushTextContentItem();
  30349. textState.leading = args[0];
  30350. break;
  30351. case OPS.moveText:
  30352. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  30353. advance = args[0] - args[1];
  30354. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  30355. textState.translateTextLineMatrix(args[0], args[1]);
  30356. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  30357. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  30358. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  30359. addFakeSpaces(diff, textContentItem.str);
  30360. break;
  30361. }
  30362. flushTextContentItem();
  30363. textState.translateTextLineMatrix(args[0], args[1]);
  30364. textState.textMatrix = textState.textLineMatrix.slice();
  30365. break;
  30366. case OPS.setLeadingMoveText:
  30367. flushTextContentItem();
  30368. textState.leading = -args[1];
  30369. textState.translateTextLineMatrix(args[0], args[1]);
  30370. textState.textMatrix = textState.textLineMatrix.slice();
  30371. break;
  30372. case OPS.nextLine:
  30373. flushTextContentItem();
  30374. textState.carriageReturn();
  30375. break;
  30376. case OPS.setTextMatrix:
  30377. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  30378. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  30379. textState.translateTextLineMatrix(advance.width, advance.height);
  30380. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  30381. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  30382. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  30383. addFakeSpaces(diff, textContentItem.str);
  30384. break;
  30385. }
  30386. flushTextContentItem();
  30387. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  30388. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  30389. break;
  30390. case OPS.setCharSpacing:
  30391. textState.charSpacing = args[0];
  30392. break;
  30393. case OPS.setWordSpacing:
  30394. textState.wordSpacing = args[0];
  30395. break;
  30396. case OPS.beginText:
  30397. flushTextContentItem();
  30398. textState.textMatrix = IDENTITY_MATRIX.slice();
  30399. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  30400. break;
  30401. case OPS.showSpacedText:
  30402. var items = args[0];
  30403. var offset;
  30404. for (var j = 0, jj = items.length; j < jj; j++) {
  30405. if (typeof items[j] === 'string') {
  30406. buildTextContentItem(items[j]);
  30407. } else if (isNum(items[j])) {
  30408. ensureTextContentItem();
  30409. advance = items[j] * textState.fontSize / 1000;
  30410. var breakTextRun = false;
  30411. if (textState.font.vertical) {
  30412. offset = advance;
  30413. textState.translateTextMatrix(0, offset);
  30414. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  30415. if (!breakTextRun) {
  30416. textContentItem.height += offset;
  30417. }
  30418. } else {
  30419. advance = -advance;
  30420. offset = advance * textState.textHScale;
  30421. textState.translateTextMatrix(offset, 0);
  30422. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  30423. if (!breakTextRun) {
  30424. textContentItem.width += offset;
  30425. }
  30426. }
  30427. if (breakTextRun) {
  30428. flushTextContentItem();
  30429. } else if (advance > 0) {
  30430. addFakeSpaces(advance, textContentItem.str);
  30431. }
  30432. }
  30433. }
  30434. break;
  30435. case OPS.showText:
  30436. buildTextContentItem(args[0]);
  30437. break;
  30438. case OPS.nextLineShowText:
  30439. flushTextContentItem();
  30440. textState.carriageReturn();
  30441. buildTextContentItem(args[0]);
  30442. break;
  30443. case OPS.nextLineSetSpacingShowText:
  30444. flushTextContentItem();
  30445. textState.wordSpacing = args[0];
  30446. textState.charSpacing = args[1];
  30447. textState.carriageReturn();
  30448. buildTextContentItem(args[2]);
  30449. break;
  30450. case OPS.paintXObject:
  30451. flushTextContentItem();
  30452. if (args[0].code) {
  30453. break;
  30454. }
  30455. if (!xobjs) {
  30456. xobjs = resources.get('XObject') || Dict.empty;
  30457. }
  30458. var name = args[0].name;
  30459. if (xobjsCache.key === name) {
  30460. if (xobjsCache.texts) {
  30461. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  30462. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  30463. }
  30464. break;
  30465. }
  30466. var xobj = xobjs.get(name);
  30467. if (!xobj) {
  30468. break;
  30469. }
  30470. assert(isStream(xobj), 'XObject should be a stream');
  30471. var type = xobj.dict.get('Subtype');
  30472. assert(isName(type), 'XObject should have a Name subtype');
  30473. if ('Form' !== type.name) {
  30474. xobjsCache.key = name;
  30475. xobjsCache.texts = null;
  30476. break;
  30477. }
  30478. stateManager.save();
  30479. var matrix = xobj.dict.getArray('Matrix');
  30480. if (isArray(matrix) && matrix.length === 6) {
  30481. stateManager.transform(matrix);
  30482. }
  30483. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  30484. Util.appendToArray(textContent.items, formTextContent.items);
  30485. Util.extendObj(textContent.styles, formTextContent.styles);
  30486. stateManager.restore();
  30487. xobjsCache.key = name;
  30488. xobjsCache.texts = formTextContent;
  30489. }));
  30490. return;
  30491. case OPS.setGState:
  30492. flushTextContentItem();
  30493. var dictName = args[0];
  30494. var extGState = resources.get('ExtGState');
  30495. if (!isDict(extGState) || !isName(dictName)) {
  30496. break;
  30497. }
  30498. var gState = extGState.get(dictName.name);
  30499. if (!isDict(gState)) {
  30500. break;
  30501. }
  30502. var gStateFont = gState.get('Font');
  30503. if (gStateFont) {
  30504. textState.fontName = null;
  30505. textState.fontSize = gStateFont[1];
  30506. next(handleSetFont(null, gStateFont[0]));
  30507. return;
  30508. }
  30509. break;
  30510. }
  30511. }
  30512. if (stop) {
  30513. next(deferred);
  30514. return;
  30515. }
  30516. flushTextContentItem();
  30517. resolve(textContent);
  30518. });
  30519. },
  30520. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  30521. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  30522. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  30523. if (properties.composite) {
  30524. var cidSystemInfo = dict.get('CIDSystemInfo');
  30525. if (isDict(cidSystemInfo)) {
  30526. properties.cidSystemInfo = {
  30527. registry: cidSystemInfo.get('Registry'),
  30528. ordering: cidSystemInfo.get('Ordering'),
  30529. supplement: cidSystemInfo.get('Supplement')
  30530. };
  30531. }
  30532. var cidToGidMap = dict.get('CIDToGIDMap');
  30533. if (isStream(cidToGidMap)) {
  30534. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  30535. }
  30536. }
  30537. var differences = [];
  30538. var baseEncodingName = null;
  30539. var encoding;
  30540. if (dict.has('Encoding')) {
  30541. encoding = dict.get('Encoding');
  30542. if (isDict(encoding)) {
  30543. baseEncodingName = encoding.get('BaseEncoding');
  30544. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  30545. if (encoding.has('Differences')) {
  30546. var diffEncoding = encoding.get('Differences');
  30547. var index = 0;
  30548. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  30549. var data = xref.fetchIfRef(diffEncoding[j]);
  30550. if (isNum(data)) {
  30551. index = data;
  30552. } else if (isName(data)) {
  30553. differences[index++] = data.name;
  30554. } else {
  30555. error('Invalid entry in \'Differences\' array: ' + data);
  30556. }
  30557. }
  30558. }
  30559. } else if (isName(encoding)) {
  30560. baseEncodingName = encoding.name;
  30561. } else {
  30562. error('Encoding is not a Name nor a Dict');
  30563. }
  30564. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  30565. baseEncodingName = null;
  30566. }
  30567. }
  30568. if (baseEncodingName) {
  30569. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  30570. } else {
  30571. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  30572. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  30573. encoding = StandardEncoding;
  30574. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  30575. encoding = WinAnsiEncoding;
  30576. }
  30577. if (isSymbolicFont) {
  30578. encoding = MacRomanEncoding;
  30579. if (!properties.file) {
  30580. if (/Symbol/i.test(properties.name)) {
  30581. encoding = SymbolSetEncoding;
  30582. } else if (/Dingbats/i.test(properties.name)) {
  30583. encoding = ZapfDingbatsEncoding;
  30584. }
  30585. }
  30586. }
  30587. properties.defaultEncoding = encoding;
  30588. }
  30589. properties.differences = differences;
  30590. properties.baseEncodingName = baseEncodingName;
  30591. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  30592. properties.dict = dict;
  30593. return toUnicodePromise.then(function (toUnicode) {
  30594. properties.toUnicode = toUnicode;
  30595. return this.buildToUnicode(properties);
  30596. }.bind(this)).then(function (toUnicode) {
  30597. properties.toUnicode = toUnicode;
  30598. return properties;
  30599. });
  30600. },
  30601. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  30602. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  30603. if (properties.hasIncludedToUnicodeMap) {
  30604. return Promise.resolve(properties.toUnicode);
  30605. }
  30606. var toUnicode, charcode, glyphName;
  30607. if (!properties.composite) {
  30608. toUnicode = [];
  30609. var encoding = properties.defaultEncoding.slice();
  30610. var baseEncodingName = properties.baseEncodingName;
  30611. var differences = properties.differences;
  30612. for (charcode in differences) {
  30613. glyphName = differences[charcode];
  30614. if (glyphName === '.notdef') {
  30615. continue;
  30616. }
  30617. encoding[charcode] = glyphName;
  30618. }
  30619. var glyphsUnicodeMap = getGlyphsUnicode();
  30620. for (charcode in encoding) {
  30621. glyphName = encoding[charcode];
  30622. if (glyphName === '') {
  30623. continue;
  30624. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  30625. var code = 0;
  30626. switch (glyphName[0]) {
  30627. case 'G':
  30628. if (glyphName.length === 3) {
  30629. code = parseInt(glyphName.substr(1), 16);
  30630. }
  30631. break;
  30632. case 'g':
  30633. if (glyphName.length === 5) {
  30634. code = parseInt(glyphName.substr(1), 16);
  30635. }
  30636. break;
  30637. case 'C':
  30638. case 'c':
  30639. if (glyphName.length >= 3) {
  30640. code = +glyphName.substr(1);
  30641. }
  30642. break;
  30643. default:
  30644. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  30645. if (unicode !== -1) {
  30646. code = unicode;
  30647. }
  30648. }
  30649. if (code) {
  30650. if (baseEncodingName && code === +charcode) {
  30651. var baseEncoding = getEncoding(baseEncodingName);
  30652. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  30653. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  30654. continue;
  30655. }
  30656. }
  30657. toUnicode[charcode] = String.fromCharCode(code);
  30658. }
  30659. continue;
  30660. }
  30661. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  30662. }
  30663. return Promise.resolve(new ToUnicodeMap(toUnicode));
  30664. }
  30665. if (properties.composite && (properties.cMap.builtInCMap && !(properties.cMap instanceof IdentityCMap) || properties.cidSystemInfo.registry === 'Adobe' && (properties.cidSystemInfo.ordering === 'GB1' || properties.cidSystemInfo.ordering === 'CNS1' || properties.cidSystemInfo.ordering === 'Japan1' || properties.cidSystemInfo.ordering === 'Korea1'))) {
  30666. var registry = properties.cidSystemInfo.registry;
  30667. var ordering = properties.cidSystemInfo.ordering;
  30668. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  30669. return CMapFactory.create({
  30670. encoding: ucs2CMapName,
  30671. fetchBuiltInCMap: this.fetchBuiltInCMap,
  30672. useCMap: null
  30673. }).then(function (ucs2CMap) {
  30674. var cMap = properties.cMap;
  30675. toUnicode = [];
  30676. cMap.forEach(function (charcode, cid) {
  30677. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  30678. var ucs2 = ucs2CMap.lookup(cid);
  30679. if (ucs2) {
  30680. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  30681. }
  30682. });
  30683. return new ToUnicodeMap(toUnicode);
  30684. });
  30685. }
  30686. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  30687. },
  30688. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  30689. var cmapObj = toUnicode;
  30690. if (isName(cmapObj)) {
  30691. return CMapFactory.create({
  30692. encoding: cmapObj,
  30693. fetchBuiltInCMap: this.fetchBuiltInCMap,
  30694. useCMap: null
  30695. }).then(function (cmap) {
  30696. if (cmap instanceof IdentityCMap) {
  30697. return new IdentityToUnicodeMap(0, 0xFFFF);
  30698. }
  30699. return new ToUnicodeMap(cmap.getMap());
  30700. });
  30701. } else if (isStream(cmapObj)) {
  30702. return CMapFactory.create({
  30703. encoding: cmapObj,
  30704. fetchBuiltInCMap: this.fetchBuiltInCMap,
  30705. useCMap: null
  30706. }).then(function (cmap) {
  30707. if (cmap instanceof IdentityCMap) {
  30708. return new IdentityToUnicodeMap(0, 0xFFFF);
  30709. }
  30710. var map = new Array(cmap.length);
  30711. cmap.forEach(function (charCode, token) {
  30712. var str = [];
  30713. for (var k = 0; k < token.length; k += 2) {
  30714. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  30715. if ((w1 & 0xF800) !== 0xD800) {
  30716. str.push(w1);
  30717. continue;
  30718. }
  30719. k += 2;
  30720. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  30721. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  30722. }
  30723. map[charCode] = String.fromCharCode.apply(String, str);
  30724. });
  30725. return new ToUnicodeMap(map);
  30726. });
  30727. }
  30728. return Promise.resolve(null);
  30729. },
  30730. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  30731. var glyphsData = cidToGidStream.getBytes();
  30732. var result = [];
  30733. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  30734. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  30735. if (glyphID === 0) {
  30736. continue;
  30737. }
  30738. var code = j >> 1;
  30739. result[code] = glyphID;
  30740. }
  30741. return result;
  30742. },
  30743. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  30744. var glyphsWidths = [];
  30745. var defaultWidth = 0;
  30746. var glyphsVMetrics = [];
  30747. var defaultVMetrics;
  30748. var i, ii, j, jj, start, code, widths;
  30749. if (properties.composite) {
  30750. defaultWidth = dict.get('DW') || 1000;
  30751. widths = dict.get('W');
  30752. if (widths) {
  30753. for (i = 0, ii = widths.length; i < ii; i++) {
  30754. start = xref.fetchIfRef(widths[i++]);
  30755. code = xref.fetchIfRef(widths[i]);
  30756. if (isArray(code)) {
  30757. for (j = 0, jj = code.length; j < jj; j++) {
  30758. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  30759. }
  30760. } else {
  30761. var width = xref.fetchIfRef(widths[++i]);
  30762. for (j = start; j <= code; j++) {
  30763. glyphsWidths[j] = width;
  30764. }
  30765. }
  30766. }
  30767. }
  30768. if (properties.vertical) {
  30769. var vmetrics = dict.getArray('DW2') || [
  30770. 880,
  30771. -1000
  30772. ];
  30773. defaultVMetrics = [
  30774. vmetrics[1],
  30775. defaultWidth * 0.5,
  30776. vmetrics[0]
  30777. ];
  30778. vmetrics = dict.get('W2');
  30779. if (vmetrics) {
  30780. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  30781. start = xref.fetchIfRef(vmetrics[i++]);
  30782. code = xref.fetchIfRef(vmetrics[i]);
  30783. if (isArray(code)) {
  30784. for (j = 0, jj = code.length; j < jj; j++) {
  30785. glyphsVMetrics[start++] = [
  30786. xref.fetchIfRef(code[j++]),
  30787. xref.fetchIfRef(code[j++]),
  30788. xref.fetchIfRef(code[j])
  30789. ];
  30790. }
  30791. } else {
  30792. var vmetric = [
  30793. xref.fetchIfRef(vmetrics[++i]),
  30794. xref.fetchIfRef(vmetrics[++i]),
  30795. xref.fetchIfRef(vmetrics[++i])
  30796. ];
  30797. for (j = start; j <= code; j++) {
  30798. glyphsVMetrics[j] = vmetric;
  30799. }
  30800. }
  30801. }
  30802. }
  30803. }
  30804. } else {
  30805. var firstChar = properties.firstChar;
  30806. widths = dict.get('Widths');
  30807. if (widths) {
  30808. j = firstChar;
  30809. for (i = 0, ii = widths.length; i < ii; i++) {
  30810. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  30811. }
  30812. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  30813. } else {
  30814. var baseFontName = dict.get('BaseFont');
  30815. if (isName(baseFontName)) {
  30816. var metrics = this.getBaseFontMetrics(baseFontName.name);
  30817. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  30818. defaultWidth = metrics.defaultWidth;
  30819. }
  30820. }
  30821. }
  30822. var isMonospace = true;
  30823. var firstWidth = defaultWidth;
  30824. for (var glyph in glyphsWidths) {
  30825. var glyphWidth = glyphsWidths[glyph];
  30826. if (!glyphWidth) {
  30827. continue;
  30828. }
  30829. if (!firstWidth) {
  30830. firstWidth = glyphWidth;
  30831. continue;
  30832. }
  30833. if (firstWidth !== glyphWidth) {
  30834. isMonospace = false;
  30835. break;
  30836. }
  30837. }
  30838. if (isMonospace) {
  30839. properties.flags |= FontFlags.FixedPitch;
  30840. }
  30841. properties.defaultWidth = defaultWidth;
  30842. properties.widths = glyphsWidths;
  30843. properties.defaultVMetrics = defaultVMetrics;
  30844. properties.vmetrics = glyphsVMetrics;
  30845. },
  30846. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  30847. var fontNameWoStyle = baseFontName.split('-')[0];
  30848. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  30849. },
  30850. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  30851. var defaultWidth = 0;
  30852. var widths = [];
  30853. var monospace = false;
  30854. var stdFontMap = getStdFontMap();
  30855. var lookupName = stdFontMap[name] || name;
  30856. var Metrics = getMetrics();
  30857. if (!(lookupName in Metrics)) {
  30858. if (this.isSerifFont(name)) {
  30859. lookupName = 'Times-Roman';
  30860. } else {
  30861. lookupName = 'Helvetica';
  30862. }
  30863. }
  30864. var glyphWidths = Metrics[lookupName];
  30865. if (isNum(glyphWidths)) {
  30866. defaultWidth = glyphWidths;
  30867. monospace = true;
  30868. } else {
  30869. widths = glyphWidths();
  30870. }
  30871. return {
  30872. defaultWidth: defaultWidth,
  30873. monospace: monospace,
  30874. widths: widths
  30875. };
  30876. },
  30877. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  30878. var widths = Object.create(null);
  30879. var differences = properties.differences;
  30880. var encoding = properties.defaultEncoding;
  30881. for (var charCode = 0; charCode < 256; charCode++) {
  30882. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  30883. widths[charCode] = widthsByGlyphName[differences[charCode]];
  30884. continue;
  30885. }
  30886. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  30887. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  30888. continue;
  30889. }
  30890. }
  30891. return widths;
  30892. },
  30893. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  30894. var baseDict = dict;
  30895. var type = dict.get('Subtype');
  30896. assert(isName(type), 'invalid font Subtype');
  30897. var composite = false;
  30898. var uint8array;
  30899. if (type.name === 'Type0') {
  30900. var df = dict.get('DescendantFonts');
  30901. if (!df) {
  30902. error('Descendant fonts are not specified');
  30903. }
  30904. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  30905. type = dict.get('Subtype');
  30906. assert(isName(type), 'invalid font Subtype');
  30907. composite = true;
  30908. }
  30909. var descriptor = dict.get('FontDescriptor');
  30910. if (descriptor) {
  30911. var hash = new MurmurHash3_64();
  30912. var encoding = baseDict.getRaw('Encoding');
  30913. if (isName(encoding)) {
  30914. hash.update(encoding.name);
  30915. } else if (isRef(encoding)) {
  30916. hash.update(encoding.toString());
  30917. } else if (isDict(encoding)) {
  30918. var keys = encoding.getKeys();
  30919. for (var i = 0, ii = keys.length; i < ii; i++) {
  30920. var entry = encoding.getRaw(keys[i]);
  30921. if (isName(entry)) {
  30922. hash.update(entry.name);
  30923. } else if (isRef(entry)) {
  30924. hash.update(entry.toString());
  30925. } else if (isArray(entry)) {
  30926. var diffLength = entry.length, diffBuf = new Array(diffLength);
  30927. for (var j = 0; j < diffLength; j++) {
  30928. var diffEntry = entry[j];
  30929. if (isName(diffEntry)) {
  30930. diffBuf[j] = diffEntry.name;
  30931. } else if (isNum(diffEntry) || isRef(diffEntry)) {
  30932. diffBuf[j] = diffEntry.toString();
  30933. }
  30934. }
  30935. hash.update(diffBuf.join());
  30936. }
  30937. }
  30938. }
  30939. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  30940. if (isStream(toUnicode)) {
  30941. var stream = toUnicode.str || toUnicode;
  30942. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  30943. hash.update(uint8array);
  30944. } else if (isName(toUnicode)) {
  30945. hash.update(toUnicode.name);
  30946. }
  30947. var widths = dict.get('Widths') || baseDict.get('Widths');
  30948. if (widths) {
  30949. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  30950. hash.update(uint8array);
  30951. }
  30952. }
  30953. return {
  30954. descriptor: descriptor,
  30955. dict: dict,
  30956. baseDict: baseDict,
  30957. composite: composite,
  30958. type: type.name,
  30959. hash: hash ? hash.hexdigest() : ''
  30960. };
  30961. },
  30962. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  30963. var baseDict = preEvaluatedFont.baseDict;
  30964. var dict = preEvaluatedFont.dict;
  30965. var composite = preEvaluatedFont.composite;
  30966. var descriptor = preEvaluatedFont.descriptor;
  30967. var type = preEvaluatedFont.type;
  30968. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  30969. var properties;
  30970. if (!descriptor) {
  30971. if (type === 'Type3') {
  30972. descriptor = new Dict(null);
  30973. descriptor.set('FontName', Name.get(type));
  30974. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  30975. } else {
  30976. var baseFontName = dict.get('BaseFont');
  30977. if (!isName(baseFontName)) {
  30978. error('Base font is not specified');
  30979. }
  30980. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  30981. var metrics = this.getBaseFontMetrics(baseFontName);
  30982. var fontNameWoStyle = baseFontName.split('-')[0];
  30983. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  30984. properties = {
  30985. type: type,
  30986. name: baseFontName,
  30987. widths: metrics.widths,
  30988. defaultWidth: metrics.defaultWidth,
  30989. flags: flags,
  30990. firstChar: 0,
  30991. lastChar: maxCharIndex
  30992. };
  30993. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  30994. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  30995. return new Font(baseFontName, null, properties);
  30996. }.bind(this));
  30997. }
  30998. }
  30999. var firstChar = dict.get('FirstChar') || 0;
  31000. var lastChar = dict.get('LastChar') || maxCharIndex;
  31001. var fontName = descriptor.get('FontName');
  31002. var baseFont = dict.get('BaseFont');
  31003. if (isString(fontName)) {
  31004. fontName = Name.get(fontName);
  31005. }
  31006. if (isString(baseFont)) {
  31007. baseFont = Name.get(baseFont);
  31008. }
  31009. if (type !== 'Type3') {
  31010. var fontNameStr = fontName && fontName.name;
  31011. var baseFontStr = baseFont && baseFont.name;
  31012. if (fontNameStr !== baseFontStr) {
  31013. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  31014. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  31015. fontName = baseFont;
  31016. }
  31017. }
  31018. }
  31019. fontName = fontName || baseFont;
  31020. assert(isName(fontName), 'invalid font name');
  31021. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  31022. if (fontFile) {
  31023. if (fontFile.dict) {
  31024. var subtype = fontFile.dict.get('Subtype');
  31025. if (subtype) {
  31026. subtype = subtype.name;
  31027. }
  31028. var length1 = fontFile.dict.get('Length1');
  31029. var length2 = fontFile.dict.get('Length2');
  31030. var length3 = fontFile.dict.get('Length3');
  31031. }
  31032. }
  31033. properties = {
  31034. type: type,
  31035. name: fontName.name,
  31036. subtype: subtype,
  31037. file: fontFile,
  31038. length1: length1,
  31039. length2: length2,
  31040. length3: length3,
  31041. loadedName: baseDict.loadedName,
  31042. composite: composite,
  31043. wideChars: composite,
  31044. fixedPitch: false,
  31045. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  31046. firstChar: firstChar || 0,
  31047. lastChar: lastChar || maxCharIndex,
  31048. bbox: descriptor.getArray('FontBBox'),
  31049. ascent: descriptor.get('Ascent'),
  31050. descent: descriptor.get('Descent'),
  31051. xHeight: descriptor.get('XHeight'),
  31052. capHeight: descriptor.get('CapHeight'),
  31053. flags: descriptor.get('Flags'),
  31054. italicAngle: descriptor.get('ItalicAngle'),
  31055. coded: false
  31056. };
  31057. var cMapPromise;
  31058. if (composite) {
  31059. var cidEncoding = baseDict.get('Encoding');
  31060. if (isName(cidEncoding)) {
  31061. properties.cidEncoding = cidEncoding.name;
  31062. }
  31063. cMapPromise = CMapFactory.create({
  31064. encoding: cidEncoding,
  31065. fetchBuiltInCMap: this.fetchBuiltInCMap,
  31066. useCMap: null
  31067. }).then(function (cMap) {
  31068. properties.cMap = cMap;
  31069. properties.vertical = properties.cMap.vertical;
  31070. });
  31071. } else {
  31072. cMapPromise = Promise.resolve(undefined);
  31073. }
  31074. return cMapPromise.then(function () {
  31075. return this.extractDataStructures(dict, baseDict, xref, properties);
  31076. }.bind(this)).then(function (properties) {
  31077. this.extractWidths(dict, xref, descriptor, properties);
  31078. if (type === 'Type3') {
  31079. properties.isType3Font = true;
  31080. }
  31081. return new Font(fontName.name, fontFile, properties);
  31082. }.bind(this));
  31083. }
  31084. };
  31085. return PartialEvaluator;
  31086. }();
  31087. var TranslatedFont = function TranslatedFontClosure() {
  31088. function TranslatedFont(loadedName, font, dict) {
  31089. this.loadedName = loadedName;
  31090. this.font = font;
  31091. this.dict = dict;
  31092. this.type3Loaded = null;
  31093. this.sent = false;
  31094. }
  31095. TranslatedFont.prototype = {
  31096. send: function (handler) {
  31097. if (this.sent) {
  31098. return;
  31099. }
  31100. var fontData = this.font.exportData();
  31101. handler.send('commonobj', [
  31102. this.loadedName,
  31103. 'Font',
  31104. fontData
  31105. ]);
  31106. this.sent = true;
  31107. },
  31108. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  31109. assert(this.font.isType3Font);
  31110. if (this.type3Loaded) {
  31111. return this.type3Loaded;
  31112. }
  31113. var translatedFont = this.font;
  31114. var loadCharProcsPromise = Promise.resolve();
  31115. var charProcs = this.dict.get('CharProcs');
  31116. var fontResources = this.dict.get('Resources') || resources;
  31117. var charProcKeys = charProcs.getKeys();
  31118. var charProcOperatorList = Object.create(null);
  31119. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  31120. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  31121. var glyphStream = charProcs.get(key);
  31122. var operatorList = new OperatorList();
  31123. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  31124. charProcOperatorList[key] = operatorList.getIR();
  31125. parentOperatorList.addDependencies(operatorList.dependencies);
  31126. }, function (reason) {
  31127. warn('Type3 font resource \"' + key + '\" is not available');
  31128. var operatorList = new OperatorList();
  31129. charProcOperatorList[key] = operatorList.getIR();
  31130. });
  31131. }.bind(this, charProcKeys[i]));
  31132. }
  31133. this.type3Loaded = loadCharProcsPromise.then(function () {
  31134. translatedFont.charProcOperatorList = charProcOperatorList;
  31135. });
  31136. return this.type3Loaded;
  31137. }
  31138. };
  31139. return TranslatedFont;
  31140. }();
  31141. var OperatorList = function OperatorListClosure() {
  31142. var CHUNK_SIZE = 1000;
  31143. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  31144. function getTransfers(queue) {
  31145. var transfers = [];
  31146. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  31147. for (var i = 0, ii = queue.length; i < ii; i++) {
  31148. switch (fnArray[i]) {
  31149. case OPS.paintInlineImageXObject:
  31150. case OPS.paintInlineImageXObjectGroup:
  31151. case OPS.paintImageMaskXObject:
  31152. var arg = argsArray[i][0];
  31153. if (!arg.cached) {
  31154. transfers.push(arg.data.buffer);
  31155. }
  31156. break;
  31157. }
  31158. }
  31159. return transfers;
  31160. }
  31161. function OperatorList(intent, messageHandler, pageIndex) {
  31162. this.messageHandler = messageHandler;
  31163. this.fnArray = [];
  31164. this.argsArray = [];
  31165. this.dependencies = Object.create(null);
  31166. this._totalLength = 0;
  31167. this.pageIndex = pageIndex;
  31168. this.intent = intent;
  31169. }
  31170. OperatorList.prototype = {
  31171. get length() {
  31172. return this.argsArray.length;
  31173. },
  31174. get totalLength() {
  31175. return this._totalLength + this.length;
  31176. },
  31177. addOp: function (fn, args) {
  31178. this.fnArray.push(fn);
  31179. this.argsArray.push(args);
  31180. if (this.messageHandler) {
  31181. if (this.fnArray.length >= CHUNK_SIZE) {
  31182. this.flush();
  31183. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  31184. this.flush();
  31185. }
  31186. }
  31187. },
  31188. addDependency: function (dependency) {
  31189. if (dependency in this.dependencies) {
  31190. return;
  31191. }
  31192. this.dependencies[dependency] = true;
  31193. this.addOp(OPS.dependency, [dependency]);
  31194. },
  31195. addDependencies: function (dependencies) {
  31196. for (var key in dependencies) {
  31197. this.addDependency(key);
  31198. }
  31199. },
  31200. addOpList: function (opList) {
  31201. Util.extendObj(this.dependencies, opList.dependencies);
  31202. for (var i = 0, ii = opList.length; i < ii; i++) {
  31203. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  31204. }
  31205. },
  31206. getIR: function () {
  31207. return {
  31208. fnArray: this.fnArray,
  31209. argsArray: this.argsArray,
  31210. length: this.length
  31211. };
  31212. },
  31213. flush: function (lastChunk) {
  31214. if (this.intent !== 'oplist') {
  31215. new QueueOptimizer().optimize(this);
  31216. }
  31217. var transfers = getTransfers(this);
  31218. var length = this.length;
  31219. this._totalLength += length;
  31220. this.messageHandler.send('RenderPageChunk', {
  31221. operatorList: {
  31222. fnArray: this.fnArray,
  31223. argsArray: this.argsArray,
  31224. lastChunk: lastChunk,
  31225. length: length
  31226. },
  31227. pageIndex: this.pageIndex,
  31228. intent: this.intent
  31229. }, transfers);
  31230. this.dependencies = Object.create(null);
  31231. this.fnArray.length = 0;
  31232. this.argsArray.length = 0;
  31233. }
  31234. };
  31235. return OperatorList;
  31236. }();
  31237. var StateManager = function StateManagerClosure() {
  31238. function StateManager(initialState) {
  31239. this.state = initialState;
  31240. this.stateStack = [];
  31241. }
  31242. StateManager.prototype = {
  31243. save: function () {
  31244. var old = this.state;
  31245. this.stateStack.push(this.state);
  31246. this.state = old.clone();
  31247. },
  31248. restore: function () {
  31249. var prev = this.stateStack.pop();
  31250. if (prev) {
  31251. this.state = prev;
  31252. }
  31253. },
  31254. transform: function (args) {
  31255. this.state.ctm = Util.transform(this.state.ctm, args);
  31256. }
  31257. };
  31258. return StateManager;
  31259. }();
  31260. var TextState = function TextStateClosure() {
  31261. function TextState() {
  31262. this.ctm = new Float32Array(IDENTITY_MATRIX);
  31263. this.fontName = null;
  31264. this.fontSize = 0;
  31265. this.font = null;
  31266. this.fontMatrix = FONT_IDENTITY_MATRIX;
  31267. this.textMatrix = IDENTITY_MATRIX.slice();
  31268. this.textLineMatrix = IDENTITY_MATRIX.slice();
  31269. this.charSpacing = 0;
  31270. this.wordSpacing = 0;
  31271. this.leading = 0;
  31272. this.textHScale = 1;
  31273. this.textRise = 0;
  31274. }
  31275. TextState.prototype = {
  31276. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  31277. var m = this.textMatrix;
  31278. m[0] = a;
  31279. m[1] = b;
  31280. m[2] = c;
  31281. m[3] = d;
  31282. m[4] = e;
  31283. m[5] = f;
  31284. },
  31285. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  31286. var m = this.textLineMatrix;
  31287. m[0] = a;
  31288. m[1] = b;
  31289. m[2] = c;
  31290. m[3] = d;
  31291. m[4] = e;
  31292. m[5] = f;
  31293. },
  31294. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  31295. var m = this.textMatrix;
  31296. m[4] = m[0] * x + m[2] * y + m[4];
  31297. m[5] = m[1] * x + m[3] * y + m[5];
  31298. },
  31299. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  31300. var m = this.textLineMatrix;
  31301. m[4] = m[0] * x + m[2] * y + m[4];
  31302. m[5] = m[1] * x + m[3] * y + m[5];
  31303. },
  31304. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  31305. var font = this.font;
  31306. if (!font) {
  31307. return null;
  31308. }
  31309. var m = this.textLineMatrix;
  31310. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  31311. return null;
  31312. }
  31313. var txDiff = e - m[4], tyDiff = f - m[5];
  31314. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  31315. return null;
  31316. }
  31317. var tx, ty, denominator = a * d - b * c;
  31318. if (font.vertical) {
  31319. tx = -tyDiff * c / denominator;
  31320. ty = tyDiff * a / denominator;
  31321. } else {
  31322. tx = txDiff * d / denominator;
  31323. ty = -txDiff * b / denominator;
  31324. }
  31325. return {
  31326. width: tx,
  31327. height: ty,
  31328. value: font.vertical ? ty : tx
  31329. };
  31330. },
  31331. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  31332. var tsm = [
  31333. this.fontSize * this.textHScale,
  31334. 0,
  31335. 0,
  31336. this.fontSize,
  31337. 0,
  31338. this.textRise
  31339. ];
  31340. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  31341. },
  31342. carriageReturn: function TextState_carriageReturn() {
  31343. this.translateTextLineMatrix(0, -this.leading);
  31344. this.textMatrix = this.textLineMatrix.slice();
  31345. },
  31346. clone: function TextState_clone() {
  31347. var clone = Object.create(this);
  31348. clone.textMatrix = this.textMatrix.slice();
  31349. clone.textLineMatrix = this.textLineMatrix.slice();
  31350. clone.fontMatrix = this.fontMatrix.slice();
  31351. return clone;
  31352. }
  31353. };
  31354. return TextState;
  31355. }();
  31356. var EvalState = function EvalStateClosure() {
  31357. function EvalState() {
  31358. this.ctm = new Float32Array(IDENTITY_MATRIX);
  31359. this.font = null;
  31360. this.textRenderingMode = TextRenderingMode.FILL;
  31361. this.fillColorSpace = ColorSpace.singletons.gray;
  31362. this.strokeColorSpace = ColorSpace.singletons.gray;
  31363. }
  31364. EvalState.prototype = {
  31365. clone: function CanvasExtraState_clone() {
  31366. return Object.create(this);
  31367. }
  31368. };
  31369. return EvalState;
  31370. }();
  31371. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  31372. var getOPMap = getLookupTableFactory(function (t) {
  31373. t['w'] = {
  31374. id: OPS.setLineWidth,
  31375. numArgs: 1,
  31376. variableArgs: false
  31377. };
  31378. t['J'] = {
  31379. id: OPS.setLineCap,
  31380. numArgs: 1,
  31381. variableArgs: false
  31382. };
  31383. t['j'] = {
  31384. id: OPS.setLineJoin,
  31385. numArgs: 1,
  31386. variableArgs: false
  31387. };
  31388. t['M'] = {
  31389. id: OPS.setMiterLimit,
  31390. numArgs: 1,
  31391. variableArgs: false
  31392. };
  31393. t['d'] = {
  31394. id: OPS.setDash,
  31395. numArgs: 2,
  31396. variableArgs: false
  31397. };
  31398. t['ri'] = {
  31399. id: OPS.setRenderingIntent,
  31400. numArgs: 1,
  31401. variableArgs: false
  31402. };
  31403. t['i'] = {
  31404. id: OPS.setFlatness,
  31405. numArgs: 1,
  31406. variableArgs: false
  31407. };
  31408. t['gs'] = {
  31409. id: OPS.setGState,
  31410. numArgs: 1,
  31411. variableArgs: false
  31412. };
  31413. t['q'] = {
  31414. id: OPS.save,
  31415. numArgs: 0,
  31416. variableArgs: false
  31417. };
  31418. t['Q'] = {
  31419. id: OPS.restore,
  31420. numArgs: 0,
  31421. variableArgs: false
  31422. };
  31423. t['cm'] = {
  31424. id: OPS.transform,
  31425. numArgs: 6,
  31426. variableArgs: false
  31427. };
  31428. t['m'] = {
  31429. id: OPS.moveTo,
  31430. numArgs: 2,
  31431. variableArgs: false
  31432. };
  31433. t['l'] = {
  31434. id: OPS.lineTo,
  31435. numArgs: 2,
  31436. variableArgs: false
  31437. };
  31438. t['c'] = {
  31439. id: OPS.curveTo,
  31440. numArgs: 6,
  31441. variableArgs: false
  31442. };
  31443. t['v'] = {
  31444. id: OPS.curveTo2,
  31445. numArgs: 4,
  31446. variableArgs: false
  31447. };
  31448. t['y'] = {
  31449. id: OPS.curveTo3,
  31450. numArgs: 4,
  31451. variableArgs: false
  31452. };
  31453. t['h'] = {
  31454. id: OPS.closePath,
  31455. numArgs: 0,
  31456. variableArgs: false
  31457. };
  31458. t['re'] = {
  31459. id: OPS.rectangle,
  31460. numArgs: 4,
  31461. variableArgs: false
  31462. };
  31463. t['S'] = {
  31464. id: OPS.stroke,
  31465. numArgs: 0,
  31466. variableArgs: false
  31467. };
  31468. t['s'] = {
  31469. id: OPS.closeStroke,
  31470. numArgs: 0,
  31471. variableArgs: false
  31472. };
  31473. t['f'] = {
  31474. id: OPS.fill,
  31475. numArgs: 0,
  31476. variableArgs: false
  31477. };
  31478. t['F'] = {
  31479. id: OPS.fill,
  31480. numArgs: 0,
  31481. variableArgs: false
  31482. };
  31483. t['f*'] = {
  31484. id: OPS.eoFill,
  31485. numArgs: 0,
  31486. variableArgs: false
  31487. };
  31488. t['B'] = {
  31489. id: OPS.fillStroke,
  31490. numArgs: 0,
  31491. variableArgs: false
  31492. };
  31493. t['B*'] = {
  31494. id: OPS.eoFillStroke,
  31495. numArgs: 0,
  31496. variableArgs: false
  31497. };
  31498. t['b'] = {
  31499. id: OPS.closeFillStroke,
  31500. numArgs: 0,
  31501. variableArgs: false
  31502. };
  31503. t['b*'] = {
  31504. id: OPS.closeEOFillStroke,
  31505. numArgs: 0,
  31506. variableArgs: false
  31507. };
  31508. t['n'] = {
  31509. id: OPS.endPath,
  31510. numArgs: 0,
  31511. variableArgs: false
  31512. };
  31513. t['W'] = {
  31514. id: OPS.clip,
  31515. numArgs: 0,
  31516. variableArgs: false
  31517. };
  31518. t['W*'] = {
  31519. id: OPS.eoClip,
  31520. numArgs: 0,
  31521. variableArgs: false
  31522. };
  31523. t['BT'] = {
  31524. id: OPS.beginText,
  31525. numArgs: 0,
  31526. variableArgs: false
  31527. };
  31528. t['ET'] = {
  31529. id: OPS.endText,
  31530. numArgs: 0,
  31531. variableArgs: false
  31532. };
  31533. t['Tc'] = {
  31534. id: OPS.setCharSpacing,
  31535. numArgs: 1,
  31536. variableArgs: false
  31537. };
  31538. t['Tw'] = {
  31539. id: OPS.setWordSpacing,
  31540. numArgs: 1,
  31541. variableArgs: false
  31542. };
  31543. t['Tz'] = {
  31544. id: OPS.setHScale,
  31545. numArgs: 1,
  31546. variableArgs: false
  31547. };
  31548. t['TL'] = {
  31549. id: OPS.setLeading,
  31550. numArgs: 1,
  31551. variableArgs: false
  31552. };
  31553. t['Tf'] = {
  31554. id: OPS.setFont,
  31555. numArgs: 2,
  31556. variableArgs: false
  31557. };
  31558. t['Tr'] = {
  31559. id: OPS.setTextRenderingMode,
  31560. numArgs: 1,
  31561. variableArgs: false
  31562. };
  31563. t['Ts'] = {
  31564. id: OPS.setTextRise,
  31565. numArgs: 1,
  31566. variableArgs: false
  31567. };
  31568. t['Td'] = {
  31569. id: OPS.moveText,
  31570. numArgs: 2,
  31571. variableArgs: false
  31572. };
  31573. t['TD'] = {
  31574. id: OPS.setLeadingMoveText,
  31575. numArgs: 2,
  31576. variableArgs: false
  31577. };
  31578. t['Tm'] = {
  31579. id: OPS.setTextMatrix,
  31580. numArgs: 6,
  31581. variableArgs: false
  31582. };
  31583. t['T*'] = {
  31584. id: OPS.nextLine,
  31585. numArgs: 0,
  31586. variableArgs: false
  31587. };
  31588. t['Tj'] = {
  31589. id: OPS.showText,
  31590. numArgs: 1,
  31591. variableArgs: false
  31592. };
  31593. t['TJ'] = {
  31594. id: OPS.showSpacedText,
  31595. numArgs: 1,
  31596. variableArgs: false
  31597. };
  31598. t['\''] = {
  31599. id: OPS.nextLineShowText,
  31600. numArgs: 1,
  31601. variableArgs: false
  31602. };
  31603. t['"'] = {
  31604. id: OPS.nextLineSetSpacingShowText,
  31605. numArgs: 3,
  31606. variableArgs: false
  31607. };
  31608. t['d0'] = {
  31609. id: OPS.setCharWidth,
  31610. numArgs: 2,
  31611. variableArgs: false
  31612. };
  31613. t['d1'] = {
  31614. id: OPS.setCharWidthAndBounds,
  31615. numArgs: 6,
  31616. variableArgs: false
  31617. };
  31618. t['CS'] = {
  31619. id: OPS.setStrokeColorSpace,
  31620. numArgs: 1,
  31621. variableArgs: false
  31622. };
  31623. t['cs'] = {
  31624. id: OPS.setFillColorSpace,
  31625. numArgs: 1,
  31626. variableArgs: false
  31627. };
  31628. t['SC'] = {
  31629. id: OPS.setStrokeColor,
  31630. numArgs: 4,
  31631. variableArgs: true
  31632. };
  31633. t['SCN'] = {
  31634. id: OPS.setStrokeColorN,
  31635. numArgs: 33,
  31636. variableArgs: true
  31637. };
  31638. t['sc'] = {
  31639. id: OPS.setFillColor,
  31640. numArgs: 4,
  31641. variableArgs: true
  31642. };
  31643. t['scn'] = {
  31644. id: OPS.setFillColorN,
  31645. numArgs: 33,
  31646. variableArgs: true
  31647. };
  31648. t['G'] = {
  31649. id: OPS.setStrokeGray,
  31650. numArgs: 1,
  31651. variableArgs: false
  31652. };
  31653. t['g'] = {
  31654. id: OPS.setFillGray,
  31655. numArgs: 1,
  31656. variableArgs: false
  31657. };
  31658. t['RG'] = {
  31659. id: OPS.setStrokeRGBColor,
  31660. numArgs: 3,
  31661. variableArgs: false
  31662. };
  31663. t['rg'] = {
  31664. id: OPS.setFillRGBColor,
  31665. numArgs: 3,
  31666. variableArgs: false
  31667. };
  31668. t['K'] = {
  31669. id: OPS.setStrokeCMYKColor,
  31670. numArgs: 4,
  31671. variableArgs: false
  31672. };
  31673. t['k'] = {
  31674. id: OPS.setFillCMYKColor,
  31675. numArgs: 4,
  31676. variableArgs: false
  31677. };
  31678. t['sh'] = {
  31679. id: OPS.shadingFill,
  31680. numArgs: 1,
  31681. variableArgs: false
  31682. };
  31683. t['BI'] = {
  31684. id: OPS.beginInlineImage,
  31685. numArgs: 0,
  31686. variableArgs: false
  31687. };
  31688. t['ID'] = {
  31689. id: OPS.beginImageData,
  31690. numArgs: 0,
  31691. variableArgs: false
  31692. };
  31693. t['EI'] = {
  31694. id: OPS.endInlineImage,
  31695. numArgs: 1,
  31696. variableArgs: false
  31697. };
  31698. t['Do'] = {
  31699. id: OPS.paintXObject,
  31700. numArgs: 1,
  31701. variableArgs: false
  31702. };
  31703. t['MP'] = {
  31704. id: OPS.markPoint,
  31705. numArgs: 1,
  31706. variableArgs: false
  31707. };
  31708. t['DP'] = {
  31709. id: OPS.markPointProps,
  31710. numArgs: 2,
  31711. variableArgs: false
  31712. };
  31713. t['BMC'] = {
  31714. id: OPS.beginMarkedContent,
  31715. numArgs: 1,
  31716. variableArgs: false
  31717. };
  31718. t['BDC'] = {
  31719. id: OPS.beginMarkedContentProps,
  31720. numArgs: 2,
  31721. variableArgs: false
  31722. };
  31723. t['EMC'] = {
  31724. id: OPS.endMarkedContent,
  31725. numArgs: 0,
  31726. variableArgs: false
  31727. };
  31728. t['BX'] = {
  31729. id: OPS.beginCompat,
  31730. numArgs: 0,
  31731. variableArgs: false
  31732. };
  31733. t['EX'] = {
  31734. id: OPS.endCompat,
  31735. numArgs: 0,
  31736. variableArgs: false
  31737. };
  31738. t['BM'] = null;
  31739. t['BD'] = null;
  31740. t['true'] = null;
  31741. t['fa'] = null;
  31742. t['fal'] = null;
  31743. t['fals'] = null;
  31744. t['false'] = null;
  31745. t['nu'] = null;
  31746. t['nul'] = null;
  31747. t['null'] = null;
  31748. });
  31749. function EvaluatorPreprocessor(stream, xref, stateManager) {
  31750. this.opMap = getOPMap();
  31751. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  31752. this.stateManager = stateManager;
  31753. this.nonProcessedArgs = [];
  31754. }
  31755. EvaluatorPreprocessor.prototype = {
  31756. get savedStatesDepth() {
  31757. return this.stateManager.stateStack.length;
  31758. },
  31759. read: function EvaluatorPreprocessor_read(operation) {
  31760. var args = operation.args;
  31761. while (true) {
  31762. var obj = this.parser.getObj();
  31763. if (isCmd(obj)) {
  31764. var cmd = obj.cmd;
  31765. var opSpec = this.opMap[cmd];
  31766. if (!opSpec) {
  31767. warn('Unknown command "' + cmd + '"');
  31768. continue;
  31769. }
  31770. var fn = opSpec.id;
  31771. var numArgs = opSpec.numArgs;
  31772. var argsLength = args !== null ? args.length : 0;
  31773. if (!opSpec.variableArgs) {
  31774. if (argsLength !== numArgs) {
  31775. var nonProcessedArgs = this.nonProcessedArgs;
  31776. while (argsLength > numArgs) {
  31777. nonProcessedArgs.push(args.shift());
  31778. argsLength--;
  31779. }
  31780. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  31781. if (args === null) {
  31782. args = [];
  31783. }
  31784. args.unshift(nonProcessedArgs.pop());
  31785. argsLength++;
  31786. }
  31787. }
  31788. if (argsLength < numArgs) {
  31789. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  31790. if (args !== null) {
  31791. args.length = 0;
  31792. }
  31793. continue;
  31794. }
  31795. } else if (argsLength > numArgs) {
  31796. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  31797. }
  31798. this.preprocessCommand(fn, args);
  31799. operation.fn = fn;
  31800. operation.args = args;
  31801. return true;
  31802. }
  31803. if (isEOF(obj)) {
  31804. return false;
  31805. }
  31806. if (obj !== null) {
  31807. if (args === null) {
  31808. args = [];
  31809. }
  31810. args.push(obj);
  31811. assert(args.length <= 33, 'Too many arguments');
  31812. }
  31813. }
  31814. },
  31815. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  31816. switch (fn | 0) {
  31817. case OPS.save:
  31818. this.stateManager.save();
  31819. break;
  31820. case OPS.restore:
  31821. this.stateManager.restore();
  31822. break;
  31823. case OPS.transform:
  31824. this.stateManager.transform(args);
  31825. break;
  31826. }
  31827. }
  31828. };
  31829. return EvaluatorPreprocessor;
  31830. }();
  31831. var QueueOptimizer = function QueueOptimizerClosure() {
  31832. function addState(parentState, pattern, fn) {
  31833. var state = parentState;
  31834. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  31835. var item = pattern[i];
  31836. state = state[item] || (state[item] = []);
  31837. }
  31838. state[pattern[pattern.length - 1]] = fn;
  31839. }
  31840. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  31841. var iFirstPIMXO = iFirstSave + 2;
  31842. for (var i = 0; i < count; i++) {
  31843. var arg = argsArray[iFirstPIMXO + 4 * i];
  31844. var imageMask = arg.length === 1 && arg[0];
  31845. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  31846. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  31847. continue;
  31848. }
  31849. break;
  31850. }
  31851. return count - i;
  31852. }
  31853. var InitialState = [];
  31854. addState(InitialState, [
  31855. OPS.save,
  31856. OPS.transform,
  31857. OPS.paintInlineImageXObject,
  31858. OPS.restore
  31859. ], function foundInlineImageGroup(context) {
  31860. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  31861. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  31862. var MAX_WIDTH = 1000;
  31863. var IMAGE_PADDING = 1;
  31864. var fnArray = context.fnArray, argsArray = context.argsArray;
  31865. var curr = context.iCurr;
  31866. var iFirstSave = curr - 3;
  31867. var iFirstTransform = curr - 2;
  31868. var iFirstPIIXO = curr - 1;
  31869. var i = iFirstSave + 4;
  31870. var ii = fnArray.length;
  31871. while (i + 3 < ii) {
  31872. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  31873. break;
  31874. }
  31875. i += 4;
  31876. }
  31877. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  31878. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  31879. return i;
  31880. }
  31881. var maxX = 0;
  31882. var map = [], maxLineHeight = 0;
  31883. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  31884. var q;
  31885. for (q = 0; q < count; q++) {
  31886. var transform = argsArray[iFirstTransform + (q << 2)];
  31887. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  31888. if (currentX + img.width > MAX_WIDTH) {
  31889. maxX = Math.max(maxX, currentX);
  31890. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  31891. currentX = 0;
  31892. maxLineHeight = 0;
  31893. }
  31894. map.push({
  31895. transform: transform,
  31896. x: currentX,
  31897. y: currentY,
  31898. w: img.width,
  31899. h: img.height
  31900. });
  31901. currentX += img.width + 2 * IMAGE_PADDING;
  31902. maxLineHeight = Math.max(maxLineHeight, img.height);
  31903. }
  31904. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  31905. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  31906. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  31907. var imgRowSize = imgWidth << 2;
  31908. for (q = 0; q < count; q++) {
  31909. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  31910. var rowSize = map[q].w << 2;
  31911. var dataOffset = 0;
  31912. var offset = map[q].x + map[q].y * imgWidth << 2;
  31913. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  31914. for (var k = 0, kk = map[q].h; k < kk; k++) {
  31915. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  31916. dataOffset += rowSize;
  31917. offset += imgRowSize;
  31918. }
  31919. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  31920. while (offset >= 0) {
  31921. data[offset - 4] = data[offset];
  31922. data[offset - 3] = data[offset + 1];
  31923. data[offset - 2] = data[offset + 2];
  31924. data[offset - 1] = data[offset + 3];
  31925. data[offset + rowSize] = data[offset + rowSize - 4];
  31926. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  31927. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  31928. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  31929. offset -= imgRowSize;
  31930. }
  31931. }
  31932. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  31933. argsArray.splice(iFirstSave, count * 4, [
  31934. {
  31935. width: imgWidth,
  31936. height: imgHeight,
  31937. kind: ImageKind.RGBA_32BPP,
  31938. data: imgData
  31939. },
  31940. map
  31941. ]);
  31942. return iFirstSave + 1;
  31943. });
  31944. addState(InitialState, [
  31945. OPS.save,
  31946. OPS.transform,
  31947. OPS.paintImageMaskXObject,
  31948. OPS.restore
  31949. ], function foundImageMaskGroup(context) {
  31950. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  31951. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  31952. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  31953. var fnArray = context.fnArray, argsArray = context.argsArray;
  31954. var curr = context.iCurr;
  31955. var iFirstSave = curr - 3;
  31956. var iFirstTransform = curr - 2;
  31957. var iFirstPIMXO = curr - 1;
  31958. var i = iFirstSave + 4;
  31959. var ii = fnArray.length;
  31960. while (i + 3 < ii) {
  31961. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  31962. break;
  31963. }
  31964. i += 4;
  31965. }
  31966. var count = (i - iFirstSave) / 4;
  31967. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  31968. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  31969. return i;
  31970. }
  31971. var q;
  31972. var isSameImage = false;
  31973. var iTransform, transformArgs;
  31974. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  31975. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  31976. isSameImage = true;
  31977. var firstTransformArg0 = argsArray[iFirstTransform][0];
  31978. var firstTransformArg3 = argsArray[iFirstTransform][3];
  31979. iTransform = iFirstTransform + 4;
  31980. var iPIMXO = iFirstPIMXO + 4;
  31981. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  31982. transformArgs = argsArray[iTransform];
  31983. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  31984. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  31985. isSameImage = false;
  31986. } else {
  31987. count = q;
  31988. }
  31989. break;
  31990. }
  31991. }
  31992. }
  31993. if (isSameImage) {
  31994. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  31995. var positions = new Float32Array(count * 2);
  31996. iTransform = iFirstTransform;
  31997. for (q = 0; q < count; q++, iTransform += 4) {
  31998. transformArgs = argsArray[iTransform];
  31999. positions[q << 1] = transformArgs[4];
  32000. positions[(q << 1) + 1] = transformArgs[5];
  32001. }
  32002. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  32003. argsArray.splice(iFirstSave, count * 4, [
  32004. firstPIMXOArg0,
  32005. firstTransformArg0,
  32006. firstTransformArg3,
  32007. positions
  32008. ]);
  32009. } else {
  32010. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  32011. var images = [];
  32012. for (q = 0; q < count; q++) {
  32013. transformArgs = argsArray[iFirstTransform + (q << 2)];
  32014. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  32015. images.push({
  32016. data: maskParams.data,
  32017. width: maskParams.width,
  32018. height: maskParams.height,
  32019. transform: transformArgs
  32020. });
  32021. }
  32022. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  32023. argsArray.splice(iFirstSave, count * 4, [images]);
  32024. }
  32025. return iFirstSave + 1;
  32026. });
  32027. addState(InitialState, [
  32028. OPS.save,
  32029. OPS.transform,
  32030. OPS.paintImageXObject,
  32031. OPS.restore
  32032. ], function (context) {
  32033. var MIN_IMAGES_IN_BLOCK = 3;
  32034. var MAX_IMAGES_IN_BLOCK = 1000;
  32035. var fnArray = context.fnArray, argsArray = context.argsArray;
  32036. var curr = context.iCurr;
  32037. var iFirstSave = curr - 3;
  32038. var iFirstTransform = curr - 2;
  32039. var iFirstPIXO = curr - 1;
  32040. var iFirstRestore = curr;
  32041. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  32042. return iFirstRestore + 1;
  32043. }
  32044. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  32045. var firstTransformArg0 = argsArray[iFirstTransform][0];
  32046. var firstTransformArg3 = argsArray[iFirstTransform][3];
  32047. var i = iFirstSave + 4;
  32048. var ii = fnArray.length;
  32049. while (i + 3 < ii) {
  32050. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  32051. break;
  32052. }
  32053. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  32054. break;
  32055. }
  32056. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  32057. break;
  32058. }
  32059. i += 4;
  32060. }
  32061. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  32062. if (count < MIN_IMAGES_IN_BLOCK) {
  32063. return i;
  32064. }
  32065. var positions = new Float32Array(count * 2);
  32066. var iTransform = iFirstTransform;
  32067. for (var q = 0; q < count; q++, iTransform += 4) {
  32068. var transformArgs = argsArray[iTransform];
  32069. positions[q << 1] = transformArgs[4];
  32070. positions[(q << 1) + 1] = transformArgs[5];
  32071. }
  32072. var args = [
  32073. firstPIXOArg0,
  32074. firstTransformArg0,
  32075. firstTransformArg3,
  32076. positions
  32077. ];
  32078. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  32079. argsArray.splice(iFirstSave, count * 4, args);
  32080. return iFirstSave + 1;
  32081. });
  32082. addState(InitialState, [
  32083. OPS.beginText,
  32084. OPS.setFont,
  32085. OPS.setTextMatrix,
  32086. OPS.showText,
  32087. OPS.endText
  32088. ], function (context) {
  32089. var MIN_CHARS_IN_BLOCK = 3;
  32090. var MAX_CHARS_IN_BLOCK = 1000;
  32091. var fnArray = context.fnArray, argsArray = context.argsArray;
  32092. var curr = context.iCurr;
  32093. var iFirstBeginText = curr - 4;
  32094. var iFirstSetFont = curr - 3;
  32095. var iFirstSetTextMatrix = curr - 2;
  32096. var iFirstShowText = curr - 1;
  32097. var iFirstEndText = curr;
  32098. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  32099. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  32100. var i = iFirstBeginText + 5;
  32101. var ii = fnArray.length;
  32102. while (i + 4 < ii) {
  32103. if (fnArray[i] !== OPS.beginText || fnArray[i + 1] !== OPS.setFont || fnArray[i + 2] !== OPS.setTextMatrix || fnArray[i + 3] !== OPS.showText || fnArray[i + 4] !== OPS.endText) {
  32104. break;
  32105. }
  32106. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  32107. break;
  32108. }
  32109. i += 5;
  32110. }
  32111. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  32112. if (count < MIN_CHARS_IN_BLOCK) {
  32113. return i;
  32114. }
  32115. var iFirst = iFirstBeginText;
  32116. 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) {
  32117. count++;
  32118. iFirst -= 5;
  32119. }
  32120. var iEndText = iFirst + 4;
  32121. for (var q = 1; q < count; q++) {
  32122. fnArray.splice(iEndText, 3);
  32123. argsArray.splice(iEndText, 3);
  32124. iEndText += 2;
  32125. }
  32126. return iEndText + 1;
  32127. });
  32128. function QueueOptimizer() {
  32129. }
  32130. QueueOptimizer.prototype = {
  32131. optimize: function QueueOptimizer_optimize(queue) {
  32132. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  32133. var context = {
  32134. iCurr: 0,
  32135. fnArray: fnArray,
  32136. argsArray: argsArray
  32137. };
  32138. var state;
  32139. var i = 0, ii = fnArray.length;
  32140. while (i < ii) {
  32141. state = (state || InitialState)[fnArray[i]];
  32142. if (typeof state === 'function') {
  32143. context.iCurr = i;
  32144. i = state(context);
  32145. state = undefined;
  32146. ii = context.fnArray.length;
  32147. } else {
  32148. i++;
  32149. }
  32150. }
  32151. }
  32152. };
  32153. return QueueOptimizer;
  32154. }();
  32155. exports.OperatorList = OperatorList;
  32156. exports.PartialEvaluator = PartialEvaluator;
  32157. /***/ }),
  32158. /* 18 */
  32159. /***/ (function(module, exports, __w_pdfjs_require__) {
  32160. "use strict";
  32161. var sharedUtil = __w_pdfjs_require__(0);
  32162. var coreArithmeticDecoder = __w_pdfjs_require__(13);
  32163. var info = sharedUtil.info;
  32164. var warn = sharedUtil.warn;
  32165. var error = sharedUtil.error;
  32166. var log2 = sharedUtil.log2;
  32167. var readUint16 = sharedUtil.readUint16;
  32168. var readUint32 = sharedUtil.readUint32;
  32169. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  32170. var JpxImage = function JpxImageClosure() {
  32171. var SubbandsGainLog2 = {
  32172. 'LL': 0,
  32173. 'LH': 1,
  32174. 'HL': 1,
  32175. 'HH': 2
  32176. };
  32177. function JpxImage() {
  32178. this.failOnCorruptedImage = false;
  32179. }
  32180. JpxImage.prototype = {
  32181. parse: function JpxImage_parse(data) {
  32182. var head = readUint16(data, 0);
  32183. if (head === 0xFF4F) {
  32184. this.parseCodestream(data, 0, data.length);
  32185. return;
  32186. }
  32187. var position = 0, length = data.length;
  32188. while (position < length) {
  32189. var headerSize = 8;
  32190. var lbox = readUint32(data, position);
  32191. var tbox = readUint32(data, position + 4);
  32192. position += headerSize;
  32193. if (lbox === 1) {
  32194. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  32195. position += 8;
  32196. headerSize += 8;
  32197. }
  32198. if (lbox === 0) {
  32199. lbox = length - position + headerSize;
  32200. }
  32201. if (lbox < headerSize) {
  32202. error('JPX Error: Invalid box field size');
  32203. }
  32204. var dataLength = lbox - headerSize;
  32205. var jumpDataLength = true;
  32206. switch (tbox) {
  32207. case 0x6A703268:
  32208. jumpDataLength = false;
  32209. break;
  32210. case 0x636F6C72:
  32211. var method = data[position];
  32212. if (method === 1) {
  32213. var colorspace = readUint32(data, position + 3);
  32214. switch (colorspace) {
  32215. case 16:
  32216. case 17:
  32217. case 18:
  32218. break;
  32219. default:
  32220. warn('Unknown colorspace ' + colorspace);
  32221. break;
  32222. }
  32223. } else if (method === 2) {
  32224. info('ICC profile not supported');
  32225. }
  32226. break;
  32227. case 0x6A703263:
  32228. this.parseCodestream(data, position, position + dataLength);
  32229. break;
  32230. case 0x6A502020:
  32231. if (0x0d0a870a !== readUint32(data, position)) {
  32232. warn('Invalid JP2 signature');
  32233. }
  32234. break;
  32235. case 0x6A501A1A:
  32236. case 0x66747970:
  32237. case 0x72726571:
  32238. case 0x72657320:
  32239. case 0x69686472:
  32240. break;
  32241. default:
  32242. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  32243. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  32244. break;
  32245. }
  32246. if (jumpDataLength) {
  32247. position += dataLength;
  32248. }
  32249. }
  32250. },
  32251. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  32252. var newByte = stream.getByte();
  32253. while (newByte >= 0) {
  32254. var oldByte = newByte;
  32255. newByte = stream.getByte();
  32256. var code = oldByte << 8 | newByte;
  32257. if (code === 0xFF51) {
  32258. stream.skip(4);
  32259. var Xsiz = stream.getInt32() >>> 0;
  32260. var Ysiz = stream.getInt32() >>> 0;
  32261. var XOsiz = stream.getInt32() >>> 0;
  32262. var YOsiz = stream.getInt32() >>> 0;
  32263. stream.skip(16);
  32264. var Csiz = stream.getUint16();
  32265. this.width = Xsiz - XOsiz;
  32266. this.height = Ysiz - YOsiz;
  32267. this.componentsCount = Csiz;
  32268. this.bitsPerComponent = 8;
  32269. return;
  32270. }
  32271. }
  32272. error('JPX Error: No size marker found in JPX stream');
  32273. },
  32274. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  32275. var context = {};
  32276. var doNotRecover = false;
  32277. try {
  32278. var position = start;
  32279. while (position + 1 < end) {
  32280. var code = readUint16(data, position);
  32281. position += 2;
  32282. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  32283. switch (code) {
  32284. case 0xFF4F:
  32285. context.mainHeader = true;
  32286. break;
  32287. case 0xFFD9:
  32288. break;
  32289. case 0xFF51:
  32290. length = readUint16(data, position);
  32291. var siz = {};
  32292. siz.Xsiz = readUint32(data, position + 4);
  32293. siz.Ysiz = readUint32(data, position + 8);
  32294. siz.XOsiz = readUint32(data, position + 12);
  32295. siz.YOsiz = readUint32(data, position + 16);
  32296. siz.XTsiz = readUint32(data, position + 20);
  32297. siz.YTsiz = readUint32(data, position + 24);
  32298. siz.XTOsiz = readUint32(data, position + 28);
  32299. siz.YTOsiz = readUint32(data, position + 32);
  32300. var componentsCount = readUint16(data, position + 36);
  32301. siz.Csiz = componentsCount;
  32302. var components = [];
  32303. j = position + 38;
  32304. for (var i = 0; i < componentsCount; i++) {
  32305. var component = {
  32306. precision: (data[j] & 0x7F) + 1,
  32307. isSigned: !!(data[j] & 0x80),
  32308. XRsiz: data[j + 1],
  32309. YRsiz: data[j + 1]
  32310. };
  32311. calculateComponentDimensions(component, siz);
  32312. components.push(component);
  32313. }
  32314. context.SIZ = siz;
  32315. context.components = components;
  32316. calculateTileGrids(context, components);
  32317. context.QCC = [];
  32318. context.COC = [];
  32319. break;
  32320. case 0xFF5C:
  32321. length = readUint16(data, position);
  32322. var qcd = {};
  32323. j = position + 2;
  32324. sqcd = data[j++];
  32325. switch (sqcd & 0x1F) {
  32326. case 0:
  32327. spqcdSize = 8;
  32328. scalarExpounded = true;
  32329. break;
  32330. case 1:
  32331. spqcdSize = 16;
  32332. scalarExpounded = false;
  32333. break;
  32334. case 2:
  32335. spqcdSize = 16;
  32336. scalarExpounded = true;
  32337. break;
  32338. default:
  32339. throw new Error('Invalid SQcd value ' + sqcd);
  32340. }
  32341. qcd.noQuantization = spqcdSize === 8;
  32342. qcd.scalarExpounded = scalarExpounded;
  32343. qcd.guardBits = sqcd >> 5;
  32344. spqcds = [];
  32345. while (j < length + position) {
  32346. var spqcd = {};
  32347. if (spqcdSize === 8) {
  32348. spqcd.epsilon = data[j++] >> 3;
  32349. spqcd.mu = 0;
  32350. } else {
  32351. spqcd.epsilon = data[j] >> 3;
  32352. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  32353. j += 2;
  32354. }
  32355. spqcds.push(spqcd);
  32356. }
  32357. qcd.SPqcds = spqcds;
  32358. if (context.mainHeader) {
  32359. context.QCD = qcd;
  32360. } else {
  32361. context.currentTile.QCD = qcd;
  32362. context.currentTile.QCC = [];
  32363. }
  32364. break;
  32365. case 0xFF5D:
  32366. length = readUint16(data, position);
  32367. var qcc = {};
  32368. j = position + 2;
  32369. var cqcc;
  32370. if (context.SIZ.Csiz < 257) {
  32371. cqcc = data[j++];
  32372. } else {
  32373. cqcc = readUint16(data, j);
  32374. j += 2;
  32375. }
  32376. sqcd = data[j++];
  32377. switch (sqcd & 0x1F) {
  32378. case 0:
  32379. spqcdSize = 8;
  32380. scalarExpounded = true;
  32381. break;
  32382. case 1:
  32383. spqcdSize = 16;
  32384. scalarExpounded = false;
  32385. break;
  32386. case 2:
  32387. spqcdSize = 16;
  32388. scalarExpounded = true;
  32389. break;
  32390. default:
  32391. throw new Error('Invalid SQcd value ' + sqcd);
  32392. }
  32393. qcc.noQuantization = spqcdSize === 8;
  32394. qcc.scalarExpounded = scalarExpounded;
  32395. qcc.guardBits = sqcd >> 5;
  32396. spqcds = [];
  32397. while (j < length + position) {
  32398. spqcd = {};
  32399. if (spqcdSize === 8) {
  32400. spqcd.epsilon = data[j++] >> 3;
  32401. spqcd.mu = 0;
  32402. } else {
  32403. spqcd.epsilon = data[j] >> 3;
  32404. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  32405. j += 2;
  32406. }
  32407. spqcds.push(spqcd);
  32408. }
  32409. qcc.SPqcds = spqcds;
  32410. if (context.mainHeader) {
  32411. context.QCC[cqcc] = qcc;
  32412. } else {
  32413. context.currentTile.QCC[cqcc] = qcc;
  32414. }
  32415. break;
  32416. case 0xFF52:
  32417. length = readUint16(data, position);
  32418. var cod = {};
  32419. j = position + 2;
  32420. var scod = data[j++];
  32421. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  32422. cod.sopMarkerUsed = !!(scod & 2);
  32423. cod.ephMarkerUsed = !!(scod & 4);
  32424. cod.progressionOrder = data[j++];
  32425. cod.layersCount = readUint16(data, j);
  32426. j += 2;
  32427. cod.multipleComponentTransform = data[j++];
  32428. cod.decompositionLevelsCount = data[j++];
  32429. cod.xcb = (data[j++] & 0xF) + 2;
  32430. cod.ycb = (data[j++] & 0xF) + 2;
  32431. var blockStyle = data[j++];
  32432. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  32433. cod.resetContextProbabilities = !!(blockStyle & 2);
  32434. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  32435. cod.verticalyStripe = !!(blockStyle & 8);
  32436. cod.predictableTermination = !!(blockStyle & 16);
  32437. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  32438. cod.reversibleTransformation = data[j++];
  32439. if (cod.entropyCoderWithCustomPrecincts) {
  32440. var precinctsSizes = [];
  32441. while (j < length + position) {
  32442. var precinctsSize = data[j++];
  32443. precinctsSizes.push({
  32444. PPx: precinctsSize & 0xF,
  32445. PPy: precinctsSize >> 4
  32446. });
  32447. }
  32448. cod.precinctsSizes = precinctsSizes;
  32449. }
  32450. var unsupported = [];
  32451. if (cod.selectiveArithmeticCodingBypass) {
  32452. unsupported.push('selectiveArithmeticCodingBypass');
  32453. }
  32454. if (cod.resetContextProbabilities) {
  32455. unsupported.push('resetContextProbabilities');
  32456. }
  32457. if (cod.terminationOnEachCodingPass) {
  32458. unsupported.push('terminationOnEachCodingPass');
  32459. }
  32460. if (cod.verticalyStripe) {
  32461. unsupported.push('verticalyStripe');
  32462. }
  32463. if (cod.predictableTermination) {
  32464. unsupported.push('predictableTermination');
  32465. }
  32466. if (unsupported.length > 0) {
  32467. doNotRecover = true;
  32468. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  32469. }
  32470. if (context.mainHeader) {
  32471. context.COD = cod;
  32472. } else {
  32473. context.currentTile.COD = cod;
  32474. context.currentTile.COC = [];
  32475. }
  32476. break;
  32477. case 0xFF90:
  32478. length = readUint16(data, position);
  32479. tile = {};
  32480. tile.index = readUint16(data, position + 2);
  32481. tile.length = readUint32(data, position + 4);
  32482. tile.dataEnd = tile.length + position - 2;
  32483. tile.partIndex = data[position + 8];
  32484. tile.partsCount = data[position + 9];
  32485. context.mainHeader = false;
  32486. if (tile.partIndex === 0) {
  32487. tile.COD = context.COD;
  32488. tile.COC = context.COC.slice(0);
  32489. tile.QCD = context.QCD;
  32490. tile.QCC = context.QCC.slice(0);
  32491. }
  32492. context.currentTile = tile;
  32493. break;
  32494. case 0xFF93:
  32495. tile = context.currentTile;
  32496. if (tile.partIndex === 0) {
  32497. initializeTile(context, tile.index);
  32498. buildPackets(context);
  32499. }
  32500. length = tile.dataEnd - position;
  32501. parseTilePackets(context, data, position, length);
  32502. break;
  32503. case 0xFF55:
  32504. case 0xFF57:
  32505. case 0xFF58:
  32506. case 0xFF64:
  32507. length = readUint16(data, position);
  32508. break;
  32509. case 0xFF53:
  32510. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  32511. default:
  32512. throw new Error('Unknown codestream code: ' + code.toString(16));
  32513. }
  32514. position += length;
  32515. }
  32516. } catch (e) {
  32517. if (doNotRecover || this.failOnCorruptedImage) {
  32518. error('JPX Error: ' + e.message);
  32519. } else {
  32520. warn('JPX: Trying to recover from: ' + e.message);
  32521. }
  32522. }
  32523. this.tiles = transformComponents(context);
  32524. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  32525. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  32526. this.componentsCount = context.SIZ.Csiz;
  32527. }
  32528. };
  32529. function calculateComponentDimensions(component, siz) {
  32530. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  32531. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  32532. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  32533. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  32534. component.width = component.x1 - component.x0;
  32535. component.height = component.y1 - component.y0;
  32536. }
  32537. function calculateTileGrids(context, components) {
  32538. var siz = context.SIZ;
  32539. var tile, tiles = [];
  32540. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  32541. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  32542. for (var q = 0; q < numYtiles; q++) {
  32543. for (var p = 0; p < numXtiles; p++) {
  32544. tile = {};
  32545. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  32546. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  32547. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  32548. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  32549. tile.width = tile.tx1 - tile.tx0;
  32550. tile.height = tile.ty1 - tile.ty0;
  32551. tile.components = [];
  32552. tiles.push(tile);
  32553. }
  32554. }
  32555. context.tiles = tiles;
  32556. var componentsCount = siz.Csiz;
  32557. for (var i = 0, ii = componentsCount; i < ii; i++) {
  32558. var component = components[i];
  32559. for (var j = 0, jj = tiles.length; j < jj; j++) {
  32560. var tileComponent = {};
  32561. tile = tiles[j];
  32562. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  32563. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  32564. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  32565. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  32566. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  32567. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  32568. tile.components[i] = tileComponent;
  32569. }
  32570. }
  32571. }
  32572. function getBlocksDimensions(context, component, r) {
  32573. var codOrCoc = component.codingStyleParameters;
  32574. var result = {};
  32575. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  32576. result.PPx = 15;
  32577. result.PPy = 15;
  32578. } else {
  32579. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  32580. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  32581. }
  32582. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  32583. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  32584. return result;
  32585. }
  32586. function buildPrecincts(context, resolution, dimensions) {
  32587. var precinctWidth = 1 << dimensions.PPx;
  32588. var precinctHeight = 1 << dimensions.PPy;
  32589. var isZeroRes = resolution.resLevel === 0;
  32590. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  32591. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  32592. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  32593. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  32594. var numprecincts = numprecinctswide * numprecinctshigh;
  32595. resolution.precinctParameters = {
  32596. precinctWidth: precinctWidth,
  32597. precinctHeight: precinctHeight,
  32598. numprecinctswide: numprecinctswide,
  32599. numprecinctshigh: numprecinctshigh,
  32600. numprecincts: numprecincts,
  32601. precinctWidthInSubband: precinctWidthInSubband,
  32602. precinctHeightInSubband: precinctHeightInSubband
  32603. };
  32604. }
  32605. function buildCodeblocks(context, subband, dimensions) {
  32606. var xcb_ = dimensions.xcb_;
  32607. var ycb_ = dimensions.ycb_;
  32608. var codeblockWidth = 1 << xcb_;
  32609. var codeblockHeight = 1 << ycb_;
  32610. var cbx0 = subband.tbx0 >> xcb_;
  32611. var cby0 = subband.tby0 >> ycb_;
  32612. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  32613. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  32614. var precinctParameters = subband.resolution.precinctParameters;
  32615. var codeblocks = [];
  32616. var precincts = [];
  32617. var i, j, codeblock, precinctNumber;
  32618. for (j = cby0; j < cby1; j++) {
  32619. for (i = cbx0; i < cbx1; i++) {
  32620. codeblock = {
  32621. cbx: i,
  32622. cby: j,
  32623. tbx0: codeblockWidth * i,
  32624. tby0: codeblockHeight * j,
  32625. tbx1: codeblockWidth * (i + 1),
  32626. tby1: codeblockHeight * (j + 1)
  32627. };
  32628. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  32629. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  32630. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  32631. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  32632. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  32633. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  32634. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  32635. codeblock.precinctNumber = precinctNumber;
  32636. codeblock.subbandType = subband.type;
  32637. codeblock.Lblock = 3;
  32638. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  32639. continue;
  32640. }
  32641. codeblocks.push(codeblock);
  32642. var precinct = precincts[precinctNumber];
  32643. if (precinct !== undefined) {
  32644. if (i < precinct.cbxMin) {
  32645. precinct.cbxMin = i;
  32646. } else if (i > precinct.cbxMax) {
  32647. precinct.cbxMax = i;
  32648. }
  32649. if (j < precinct.cbyMin) {
  32650. precinct.cbxMin = j;
  32651. } else if (j > precinct.cbyMax) {
  32652. precinct.cbyMax = j;
  32653. }
  32654. } else {
  32655. precincts[precinctNumber] = precinct = {
  32656. cbxMin: i,
  32657. cbyMin: j,
  32658. cbxMax: i,
  32659. cbyMax: j
  32660. };
  32661. }
  32662. codeblock.precinct = precinct;
  32663. }
  32664. }
  32665. subband.codeblockParameters = {
  32666. codeblockWidth: xcb_,
  32667. codeblockHeight: ycb_,
  32668. numcodeblockwide: cbx1 - cbx0 + 1,
  32669. numcodeblockhigh: cby1 - cby0 + 1
  32670. };
  32671. subband.codeblocks = codeblocks;
  32672. subband.precincts = precincts;
  32673. }
  32674. function createPacket(resolution, precinctNumber, layerNumber) {
  32675. var precinctCodeblocks = [];
  32676. var subbands = resolution.subbands;
  32677. for (var i = 0, ii = subbands.length; i < ii; i++) {
  32678. var subband = subbands[i];
  32679. var codeblocks = subband.codeblocks;
  32680. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  32681. var codeblock = codeblocks[j];
  32682. if (codeblock.precinctNumber !== precinctNumber) {
  32683. continue;
  32684. }
  32685. precinctCodeblocks.push(codeblock);
  32686. }
  32687. }
  32688. return {
  32689. layerNumber: layerNumber,
  32690. codeblocks: precinctCodeblocks
  32691. };
  32692. }
  32693. function LayerResolutionComponentPositionIterator(context) {
  32694. var siz = context.SIZ;
  32695. var tileIndex = context.currentTile.index;
  32696. var tile = context.tiles[tileIndex];
  32697. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32698. var componentsCount = siz.Csiz;
  32699. var maxDecompositionLevelsCount = 0;
  32700. for (var q = 0; q < componentsCount; q++) {
  32701. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  32702. }
  32703. var l = 0, r = 0, i = 0, k = 0;
  32704. this.nextPacket = function JpxImage_nextPacket() {
  32705. for (; l < layersCount; l++) {
  32706. for (; r <= maxDecompositionLevelsCount; r++) {
  32707. for (; i < componentsCount; i++) {
  32708. var component = tile.components[i];
  32709. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  32710. continue;
  32711. }
  32712. var resolution = component.resolutions[r];
  32713. var numprecincts = resolution.precinctParameters.numprecincts;
  32714. for (; k < numprecincts;) {
  32715. var packet = createPacket(resolution, k, l);
  32716. k++;
  32717. return packet;
  32718. }
  32719. k = 0;
  32720. }
  32721. i = 0;
  32722. }
  32723. r = 0;
  32724. }
  32725. error('JPX Error: Out of packets');
  32726. };
  32727. }
  32728. function ResolutionLayerComponentPositionIterator(context) {
  32729. var siz = context.SIZ;
  32730. var tileIndex = context.currentTile.index;
  32731. var tile = context.tiles[tileIndex];
  32732. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32733. var componentsCount = siz.Csiz;
  32734. var maxDecompositionLevelsCount = 0;
  32735. for (var q = 0; q < componentsCount; q++) {
  32736. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  32737. }
  32738. var r = 0, l = 0, i = 0, k = 0;
  32739. this.nextPacket = function JpxImage_nextPacket() {
  32740. for (; r <= maxDecompositionLevelsCount; r++) {
  32741. for (; l < layersCount; l++) {
  32742. for (; i < componentsCount; i++) {
  32743. var component = tile.components[i];
  32744. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  32745. continue;
  32746. }
  32747. var resolution = component.resolutions[r];
  32748. var numprecincts = resolution.precinctParameters.numprecincts;
  32749. for (; k < numprecincts;) {
  32750. var packet = createPacket(resolution, k, l);
  32751. k++;
  32752. return packet;
  32753. }
  32754. k = 0;
  32755. }
  32756. i = 0;
  32757. }
  32758. l = 0;
  32759. }
  32760. error('JPX Error: Out of packets');
  32761. };
  32762. }
  32763. function ResolutionPositionComponentLayerIterator(context) {
  32764. var siz = context.SIZ;
  32765. var tileIndex = context.currentTile.index;
  32766. var tile = context.tiles[tileIndex];
  32767. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32768. var componentsCount = siz.Csiz;
  32769. var l, r, c, p;
  32770. var maxDecompositionLevelsCount = 0;
  32771. for (c = 0; c < componentsCount; c++) {
  32772. var component = tile.components[c];
  32773. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  32774. }
  32775. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  32776. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  32777. var maxNumPrecincts = 0;
  32778. for (c = 0; c < componentsCount; ++c) {
  32779. var resolutions = tile.components[c].resolutions;
  32780. if (r < resolutions.length) {
  32781. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  32782. }
  32783. }
  32784. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  32785. }
  32786. l = 0;
  32787. r = 0;
  32788. c = 0;
  32789. p = 0;
  32790. this.nextPacket = function JpxImage_nextPacket() {
  32791. for (; r <= maxDecompositionLevelsCount; r++) {
  32792. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  32793. for (; c < componentsCount; c++) {
  32794. var component = tile.components[c];
  32795. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  32796. continue;
  32797. }
  32798. var resolution = component.resolutions[r];
  32799. var numprecincts = resolution.precinctParameters.numprecincts;
  32800. if (p >= numprecincts) {
  32801. continue;
  32802. }
  32803. for (; l < layersCount;) {
  32804. var packet = createPacket(resolution, p, l);
  32805. l++;
  32806. return packet;
  32807. }
  32808. l = 0;
  32809. }
  32810. c = 0;
  32811. }
  32812. p = 0;
  32813. }
  32814. error('JPX Error: Out of packets');
  32815. };
  32816. }
  32817. function PositionComponentResolutionLayerIterator(context) {
  32818. var siz = context.SIZ;
  32819. var tileIndex = context.currentTile.index;
  32820. var tile = context.tiles[tileIndex];
  32821. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32822. var componentsCount = siz.Csiz;
  32823. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32824. var precinctsIterationSizes = precinctsSizes;
  32825. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32826. this.nextPacket = function JpxImage_nextPacket() {
  32827. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32828. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32829. for (; c < componentsCount; c++) {
  32830. var component = tile.components[c];
  32831. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32832. for (; r <= decompositionLevelsCount; r++) {
  32833. var resolution = component.resolutions[r];
  32834. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  32835. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32836. if (k === null) {
  32837. continue;
  32838. }
  32839. for (; l < layersCount;) {
  32840. var packet = createPacket(resolution, k, l);
  32841. l++;
  32842. return packet;
  32843. }
  32844. l = 0;
  32845. }
  32846. r = 0;
  32847. }
  32848. c = 0;
  32849. }
  32850. px = 0;
  32851. }
  32852. error('JPX Error: Out of packets');
  32853. };
  32854. }
  32855. function ComponentPositionResolutionLayerIterator(context) {
  32856. var siz = context.SIZ;
  32857. var tileIndex = context.currentTile.index;
  32858. var tile = context.tiles[tileIndex];
  32859. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  32860. var componentsCount = siz.Csiz;
  32861. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  32862. var l = 0, r = 0, c = 0, px = 0, py = 0;
  32863. this.nextPacket = function JpxImage_nextPacket() {
  32864. for (; c < componentsCount; ++c) {
  32865. var component = tile.components[c];
  32866. var precinctsIterationSizes = precinctsSizes.components[c];
  32867. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32868. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  32869. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  32870. for (; r <= decompositionLevelsCount; r++) {
  32871. var resolution = component.resolutions[r];
  32872. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  32873. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  32874. if (k === null) {
  32875. continue;
  32876. }
  32877. for (; l < layersCount;) {
  32878. var packet = createPacket(resolution, k, l);
  32879. l++;
  32880. return packet;
  32881. }
  32882. l = 0;
  32883. }
  32884. r = 0;
  32885. }
  32886. px = 0;
  32887. }
  32888. py = 0;
  32889. }
  32890. error('JPX Error: Out of packets');
  32891. };
  32892. }
  32893. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  32894. var posX = pxIndex * precinctIterationSizes.minWidth;
  32895. var posY = pyIndex * precinctIterationSizes.minHeight;
  32896. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  32897. return null;
  32898. }
  32899. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  32900. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  32901. }
  32902. function getPrecinctSizesInImageScale(tile) {
  32903. var componentsCount = tile.components.length;
  32904. var minWidth = Number.MAX_VALUE;
  32905. var minHeight = Number.MAX_VALUE;
  32906. var maxNumWide = 0;
  32907. var maxNumHigh = 0;
  32908. var sizePerComponent = new Array(componentsCount);
  32909. for (var c = 0; c < componentsCount; c++) {
  32910. var component = tile.components[c];
  32911. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32912. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  32913. var minWidthCurrentComponent = Number.MAX_VALUE;
  32914. var minHeightCurrentComponent = Number.MAX_VALUE;
  32915. var maxNumWideCurrentComponent = 0;
  32916. var maxNumHighCurrentComponent = 0;
  32917. var scale = 1;
  32918. for (var r = decompositionLevelsCount; r >= 0; --r) {
  32919. var resolution = component.resolutions[r];
  32920. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  32921. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  32922. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  32923. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  32924. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  32925. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  32926. sizePerResolution[r] = {
  32927. width: widthCurrentResolution,
  32928. height: heightCurrentResolution
  32929. };
  32930. scale <<= 1;
  32931. }
  32932. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  32933. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  32934. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  32935. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  32936. sizePerComponent[c] = {
  32937. resolutions: sizePerResolution,
  32938. minWidth: minWidthCurrentComponent,
  32939. minHeight: minHeightCurrentComponent,
  32940. maxNumWide: maxNumWideCurrentComponent,
  32941. maxNumHigh: maxNumHighCurrentComponent
  32942. };
  32943. }
  32944. return {
  32945. components: sizePerComponent,
  32946. minWidth: minWidth,
  32947. minHeight: minHeight,
  32948. maxNumWide: maxNumWide,
  32949. maxNumHigh: maxNumHigh
  32950. };
  32951. }
  32952. function buildPackets(context) {
  32953. var siz = context.SIZ;
  32954. var tileIndex = context.currentTile.index;
  32955. var tile = context.tiles[tileIndex];
  32956. var componentsCount = siz.Csiz;
  32957. for (var c = 0; c < componentsCount; c++) {
  32958. var component = tile.components[c];
  32959. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  32960. var resolutions = [];
  32961. var subbands = [];
  32962. for (var r = 0; r <= decompositionLevelsCount; r++) {
  32963. var blocksDimensions = getBlocksDimensions(context, component, r);
  32964. var resolution = {};
  32965. var scale = 1 << decompositionLevelsCount - r;
  32966. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  32967. resolution.try0 = Math.ceil(component.tcy0 / scale);
  32968. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  32969. resolution.try1 = Math.ceil(component.tcy1 / scale);
  32970. resolution.resLevel = r;
  32971. buildPrecincts(context, resolution, blocksDimensions);
  32972. resolutions.push(resolution);
  32973. var subband;
  32974. if (r === 0) {
  32975. subband = {};
  32976. subband.type = 'LL';
  32977. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  32978. subband.tby0 = Math.ceil(component.tcy0 / scale);
  32979. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  32980. subband.tby1 = Math.ceil(component.tcy1 / scale);
  32981. subband.resolution = resolution;
  32982. buildCodeblocks(context, subband, blocksDimensions);
  32983. subbands.push(subband);
  32984. resolution.subbands = [subband];
  32985. } else {
  32986. var bscale = 1 << decompositionLevelsCount - r + 1;
  32987. var resolutionSubbands = [];
  32988. subband = {};
  32989. subband.type = 'HL';
  32990. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  32991. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  32992. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  32993. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  32994. subband.resolution = resolution;
  32995. buildCodeblocks(context, subband, blocksDimensions);
  32996. subbands.push(subband);
  32997. resolutionSubbands.push(subband);
  32998. subband = {};
  32999. subband.type = 'LH';
  33000. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  33001. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  33002. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  33003. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  33004. subband.resolution = resolution;
  33005. buildCodeblocks(context, subband, blocksDimensions);
  33006. subbands.push(subband);
  33007. resolutionSubbands.push(subband);
  33008. subband = {};
  33009. subband.type = 'HH';
  33010. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  33011. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  33012. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  33013. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  33014. subband.resolution = resolution;
  33015. buildCodeblocks(context, subband, blocksDimensions);
  33016. subbands.push(subband);
  33017. resolutionSubbands.push(subband);
  33018. resolution.subbands = resolutionSubbands;
  33019. }
  33020. }
  33021. component.resolutions = resolutions;
  33022. component.subbands = subbands;
  33023. }
  33024. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  33025. switch (progressionOrder) {
  33026. case 0:
  33027. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  33028. break;
  33029. case 1:
  33030. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  33031. break;
  33032. case 2:
  33033. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  33034. break;
  33035. case 3:
  33036. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  33037. break;
  33038. case 4:
  33039. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  33040. break;
  33041. default:
  33042. error('JPX Error: Unsupported progression order ' + progressionOrder);
  33043. }
  33044. }
  33045. function parseTilePackets(context, data, offset, dataLength) {
  33046. var position = 0;
  33047. var buffer, bufferSize = 0, skipNextBit = false;
  33048. function readBits(count) {
  33049. while (bufferSize < count) {
  33050. var b = data[offset + position];
  33051. position++;
  33052. if (skipNextBit) {
  33053. buffer = buffer << 7 | b;
  33054. bufferSize += 7;
  33055. skipNextBit = false;
  33056. } else {
  33057. buffer = buffer << 8 | b;
  33058. bufferSize += 8;
  33059. }
  33060. if (b === 0xFF) {
  33061. skipNextBit = true;
  33062. }
  33063. }
  33064. bufferSize -= count;
  33065. return buffer >>> bufferSize & (1 << count) - 1;
  33066. }
  33067. function skipMarkerIfEqual(value) {
  33068. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  33069. skipBytes(1);
  33070. return true;
  33071. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  33072. skipBytes(2);
  33073. return true;
  33074. }
  33075. return false;
  33076. }
  33077. function skipBytes(count) {
  33078. position += count;
  33079. }
  33080. function alignToByte() {
  33081. bufferSize = 0;
  33082. if (skipNextBit) {
  33083. position++;
  33084. skipNextBit = false;
  33085. }
  33086. }
  33087. function readCodingpasses() {
  33088. if (readBits(1) === 0) {
  33089. return 1;
  33090. }
  33091. if (readBits(1) === 0) {
  33092. return 2;
  33093. }
  33094. var value = readBits(2);
  33095. if (value < 3) {
  33096. return value + 3;
  33097. }
  33098. value = readBits(5);
  33099. if (value < 31) {
  33100. return value + 6;
  33101. }
  33102. value = readBits(7);
  33103. return value + 37;
  33104. }
  33105. var tileIndex = context.currentTile.index;
  33106. var tile = context.tiles[tileIndex];
  33107. var sopMarkerUsed = context.COD.sopMarkerUsed;
  33108. var ephMarkerUsed = context.COD.ephMarkerUsed;
  33109. var packetsIterator = tile.packetsIterator;
  33110. while (position < dataLength) {
  33111. alignToByte();
  33112. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  33113. skipBytes(4);
  33114. }
  33115. var packet = packetsIterator.nextPacket();
  33116. if (!readBits(1)) {
  33117. continue;
  33118. }
  33119. var layerNumber = packet.layerNumber;
  33120. var queue = [], codeblock;
  33121. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  33122. codeblock = packet.codeblocks[i];
  33123. var precinct = codeblock.precinct;
  33124. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  33125. var codeblockRow = codeblock.cby - precinct.cbyMin;
  33126. var codeblockIncluded = false;
  33127. var firstTimeInclusion = false;
  33128. var valueReady;
  33129. if (codeblock['included'] !== undefined) {
  33130. codeblockIncluded = !!readBits(1);
  33131. } else {
  33132. precinct = codeblock.precinct;
  33133. var inclusionTree, zeroBitPlanesTree;
  33134. if (precinct['inclusionTree'] !== undefined) {
  33135. inclusionTree = precinct.inclusionTree;
  33136. } else {
  33137. var width = precinct.cbxMax - precinct.cbxMin + 1;
  33138. var height = precinct.cbyMax - precinct.cbyMin + 1;
  33139. inclusionTree = new InclusionTree(width, height, layerNumber);
  33140. zeroBitPlanesTree = new TagTree(width, height);
  33141. precinct.inclusionTree = inclusionTree;
  33142. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  33143. }
  33144. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  33145. while (true) {
  33146. if (readBits(1)) {
  33147. valueReady = !inclusionTree.nextLevel();
  33148. if (valueReady) {
  33149. codeblock.included = true;
  33150. codeblockIncluded = firstTimeInclusion = true;
  33151. break;
  33152. }
  33153. } else {
  33154. inclusionTree.incrementValue(layerNumber);
  33155. break;
  33156. }
  33157. }
  33158. }
  33159. }
  33160. if (!codeblockIncluded) {
  33161. continue;
  33162. }
  33163. if (firstTimeInclusion) {
  33164. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  33165. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  33166. while (true) {
  33167. if (readBits(1)) {
  33168. valueReady = !zeroBitPlanesTree.nextLevel();
  33169. if (valueReady) {
  33170. break;
  33171. }
  33172. } else {
  33173. zeroBitPlanesTree.incrementValue();
  33174. }
  33175. }
  33176. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  33177. }
  33178. var codingpasses = readCodingpasses();
  33179. while (readBits(1)) {
  33180. codeblock.Lblock++;
  33181. }
  33182. var codingpassesLog2 = log2(codingpasses);
  33183. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  33184. var codedDataLength = readBits(bits);
  33185. queue.push({
  33186. codeblock: codeblock,
  33187. codingpasses: codingpasses,
  33188. dataLength: codedDataLength
  33189. });
  33190. }
  33191. alignToByte();
  33192. if (ephMarkerUsed) {
  33193. skipMarkerIfEqual(0x92);
  33194. }
  33195. while (queue.length > 0) {
  33196. var packetItem = queue.shift();
  33197. codeblock = packetItem.codeblock;
  33198. if (codeblock['data'] === undefined) {
  33199. codeblock.data = [];
  33200. }
  33201. codeblock.data.push({
  33202. data: data,
  33203. start: offset + position,
  33204. end: offset + position + packetItem.dataLength,
  33205. codingpasses: packetItem.codingpasses
  33206. });
  33207. position += packetItem.dataLength;
  33208. }
  33209. }
  33210. return position;
  33211. }
  33212. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  33213. var x0 = subband.tbx0;
  33214. var y0 = subband.tby0;
  33215. var width = subband.tbx1 - subband.tbx0;
  33216. var codeblocks = subband.codeblocks;
  33217. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  33218. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  33219. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  33220. var codeblock = codeblocks[i];
  33221. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  33222. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  33223. if (blockWidth === 0 || blockHeight === 0) {
  33224. continue;
  33225. }
  33226. if (codeblock['data'] === undefined) {
  33227. continue;
  33228. }
  33229. var bitModel, currentCodingpassType;
  33230. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  33231. currentCodingpassType = 2;
  33232. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  33233. var j, jj, dataItem;
  33234. for (j = 0, jj = data.length; j < jj; j++) {
  33235. dataItem = data[j];
  33236. totalLength += dataItem.end - dataItem.start;
  33237. codingpasses += dataItem.codingpasses;
  33238. }
  33239. var encodedData = new Uint8Array(totalLength);
  33240. var position = 0;
  33241. for (j = 0, jj = data.length; j < jj; j++) {
  33242. dataItem = data[j];
  33243. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  33244. encodedData.set(chunk, position);
  33245. position += chunk.length;
  33246. }
  33247. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  33248. bitModel.setDecoder(decoder);
  33249. for (j = 0; j < codingpasses; j++) {
  33250. switch (currentCodingpassType) {
  33251. case 0:
  33252. bitModel.runSignificancePropagationPass();
  33253. break;
  33254. case 1:
  33255. bitModel.runMagnitudeRefinementPass();
  33256. break;
  33257. case 2:
  33258. bitModel.runCleanupPass();
  33259. if (segmentationSymbolUsed) {
  33260. bitModel.checkSegmentationSymbol();
  33261. }
  33262. break;
  33263. }
  33264. currentCodingpassType = (currentCodingpassType + 1) % 3;
  33265. }
  33266. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  33267. var sign = bitModel.coefficentsSign;
  33268. var magnitude = bitModel.coefficentsMagnitude;
  33269. var bitsDecoded = bitModel.bitsDecoded;
  33270. var magnitudeCorrection = reversible ? 0 : 0.5;
  33271. var k, n, nb;
  33272. position = 0;
  33273. var interleave = subband.type !== 'LL';
  33274. for (j = 0; j < blockHeight; j++) {
  33275. var row = offset / width | 0;
  33276. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  33277. for (k = 0; k < blockWidth; k++) {
  33278. n = magnitude[position];
  33279. if (n !== 0) {
  33280. n = (n + magnitudeCorrection) * delta;
  33281. if (sign[position] !== 0) {
  33282. n = -n;
  33283. }
  33284. nb = bitsDecoded[position];
  33285. var pos = interleave ? levelOffset + (offset << 1) : offset;
  33286. if (reversible && nb >= mb) {
  33287. coefficients[pos] = n;
  33288. } else {
  33289. coefficients[pos] = n * (1 << mb - nb);
  33290. }
  33291. }
  33292. offset++;
  33293. position++;
  33294. }
  33295. offset += width - blockWidth;
  33296. }
  33297. }
  33298. }
  33299. function transformTile(context, tile, c) {
  33300. var component = tile.components[c];
  33301. var codingStyleParameters = component.codingStyleParameters;
  33302. var quantizationParameters = component.quantizationParameters;
  33303. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  33304. var spqcds = quantizationParameters.SPqcds;
  33305. var scalarExpounded = quantizationParameters.scalarExpounded;
  33306. var guardBits = quantizationParameters.guardBits;
  33307. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  33308. var precision = context.components[c].precision;
  33309. var reversible = codingStyleParameters.reversibleTransformation;
  33310. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  33311. var subbandCoefficients = [];
  33312. var b = 0;
  33313. for (var i = 0; i <= decompositionLevelsCount; i++) {
  33314. var resolution = component.resolutions[i];
  33315. var width = resolution.trx1 - resolution.trx0;
  33316. var height = resolution.try1 - resolution.try0;
  33317. var coefficients = new Float32Array(width * height);
  33318. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  33319. var mu, epsilon;
  33320. if (!scalarExpounded) {
  33321. mu = spqcds[0].mu;
  33322. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  33323. } else {
  33324. mu = spqcds[b].mu;
  33325. epsilon = spqcds[b].epsilon;
  33326. b++;
  33327. }
  33328. var subband = resolution.subbands[j];
  33329. var gainLog2 = SubbandsGainLog2[subband.type];
  33330. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  33331. var mb = guardBits + epsilon - 1;
  33332. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  33333. }
  33334. subbandCoefficients.push({
  33335. width: width,
  33336. height: height,
  33337. items: coefficients
  33338. });
  33339. }
  33340. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  33341. return {
  33342. left: component.tcx0,
  33343. top: component.tcy0,
  33344. width: result.width,
  33345. height: result.height,
  33346. items: result.items
  33347. };
  33348. }
  33349. function transformComponents(context) {
  33350. var siz = context.SIZ;
  33351. var components = context.components;
  33352. var componentsCount = siz.Csiz;
  33353. var resultImages = [];
  33354. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  33355. var tile = context.tiles[i];
  33356. var transformedTiles = [];
  33357. var c;
  33358. for (c = 0; c < componentsCount; c++) {
  33359. transformedTiles[c] = transformTile(context, tile, c);
  33360. }
  33361. var tile0 = transformedTiles[0];
  33362. var out = new Uint8Array(tile0.items.length * componentsCount);
  33363. var result = {
  33364. left: tile0.left,
  33365. top: tile0.top,
  33366. width: tile0.width,
  33367. height: tile0.height,
  33368. items: out
  33369. };
  33370. var shift, offset, max, min, maxK;
  33371. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  33372. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  33373. var fourComponents = componentsCount === 4;
  33374. var y0items = transformedTiles[0].items;
  33375. var y1items = transformedTiles[1].items;
  33376. var y2items = transformedTiles[2].items;
  33377. var y3items = fourComponents ? transformedTiles[3].items : null;
  33378. shift = components[0].precision - 8;
  33379. offset = (128 << shift) + 0.5;
  33380. max = 255 * (1 << shift);
  33381. maxK = max * 0.5;
  33382. min = -maxK;
  33383. var component0 = tile.components[0];
  33384. var alpha01 = componentsCount - 3;
  33385. jj = y0items.length;
  33386. if (!component0.codingStyleParameters.reversibleTransformation) {
  33387. for (j = 0; j < jj; j++, pos += alpha01) {
  33388. y0 = y0items[j] + offset;
  33389. y1 = y1items[j];
  33390. y2 = y2items[j];
  33391. r = y0 + 1.402 * y2;
  33392. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  33393. b = y0 + 1.772 * y1;
  33394. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  33395. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  33396. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  33397. }
  33398. } else {
  33399. for (j = 0; j < jj; j++, pos += alpha01) {
  33400. y0 = y0items[j] + offset;
  33401. y1 = y1items[j];
  33402. y2 = y2items[j];
  33403. g = y0 - (y2 + y1 >> 2);
  33404. r = g + y2;
  33405. b = g + y1;
  33406. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  33407. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  33408. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  33409. }
  33410. }
  33411. if (fourComponents) {
  33412. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  33413. k = y3items[j];
  33414. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  33415. }
  33416. }
  33417. } else {
  33418. for (c = 0; c < componentsCount; c++) {
  33419. var items = transformedTiles[c].items;
  33420. shift = components[c].precision - 8;
  33421. offset = (128 << shift) + 0.5;
  33422. max = 127.5 * (1 << shift);
  33423. min = -max;
  33424. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  33425. val = items[j];
  33426. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  33427. pos += componentsCount;
  33428. }
  33429. }
  33430. }
  33431. resultImages.push(result);
  33432. }
  33433. return resultImages;
  33434. }
  33435. function initializeTile(context, tileIndex) {
  33436. var siz = context.SIZ;
  33437. var componentsCount = siz.Csiz;
  33438. var tile = context.tiles[tileIndex];
  33439. for (var c = 0; c < componentsCount; c++) {
  33440. var component = tile.components[c];
  33441. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  33442. component.quantizationParameters = qcdOrQcc;
  33443. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  33444. component.codingStyleParameters = codOrCoc;
  33445. }
  33446. tile.codingStyleDefaultParameters = context.currentTile.COD;
  33447. }
  33448. var TagTree = function TagTreeClosure() {
  33449. function TagTree(width, height) {
  33450. var levelsLength = log2(Math.max(width, height)) + 1;
  33451. this.levels = [];
  33452. for (var i = 0; i < levelsLength; i++) {
  33453. var level = {
  33454. width: width,
  33455. height: height,
  33456. items: []
  33457. };
  33458. this.levels.push(level);
  33459. width = Math.ceil(width / 2);
  33460. height = Math.ceil(height / 2);
  33461. }
  33462. }
  33463. TagTree.prototype = {
  33464. reset: function TagTree_reset(i, j) {
  33465. var currentLevel = 0, value = 0, level;
  33466. while (currentLevel < this.levels.length) {
  33467. level = this.levels[currentLevel];
  33468. var index = i + j * level.width;
  33469. if (level.items[index] !== undefined) {
  33470. value = level.items[index];
  33471. break;
  33472. }
  33473. level.index = index;
  33474. i >>= 1;
  33475. j >>= 1;
  33476. currentLevel++;
  33477. }
  33478. currentLevel--;
  33479. level = this.levels[currentLevel];
  33480. level.items[level.index] = value;
  33481. this.currentLevel = currentLevel;
  33482. delete this.value;
  33483. },
  33484. incrementValue: function TagTree_incrementValue() {
  33485. var level = this.levels[this.currentLevel];
  33486. level.items[level.index]++;
  33487. },
  33488. nextLevel: function TagTree_nextLevel() {
  33489. var currentLevel = this.currentLevel;
  33490. var level = this.levels[currentLevel];
  33491. var value = level.items[level.index];
  33492. currentLevel--;
  33493. if (currentLevel < 0) {
  33494. this.value = value;
  33495. return false;
  33496. }
  33497. this.currentLevel = currentLevel;
  33498. level = this.levels[currentLevel];
  33499. level.items[level.index] = value;
  33500. return true;
  33501. }
  33502. };
  33503. return TagTree;
  33504. }();
  33505. var InclusionTree = function InclusionTreeClosure() {
  33506. function InclusionTree(width, height, defaultValue) {
  33507. var levelsLength = log2(Math.max(width, height)) + 1;
  33508. this.levels = [];
  33509. for (var i = 0; i < levelsLength; i++) {
  33510. var items = new Uint8Array(width * height);
  33511. for (var j = 0, jj = items.length; j < jj; j++) {
  33512. items[j] = defaultValue;
  33513. }
  33514. var level = {
  33515. width: width,
  33516. height: height,
  33517. items: items
  33518. };
  33519. this.levels.push(level);
  33520. width = Math.ceil(width / 2);
  33521. height = Math.ceil(height / 2);
  33522. }
  33523. }
  33524. InclusionTree.prototype = {
  33525. reset: function InclusionTree_reset(i, j, stopValue) {
  33526. var currentLevel = 0;
  33527. while (currentLevel < this.levels.length) {
  33528. var level = this.levels[currentLevel];
  33529. var index = i + j * level.width;
  33530. level.index = index;
  33531. var value = level.items[index];
  33532. if (value === 0xFF) {
  33533. break;
  33534. }
  33535. if (value > stopValue) {
  33536. this.currentLevel = currentLevel;
  33537. this.propagateValues();
  33538. return false;
  33539. }
  33540. i >>= 1;
  33541. j >>= 1;
  33542. currentLevel++;
  33543. }
  33544. this.currentLevel = currentLevel - 1;
  33545. return true;
  33546. },
  33547. incrementValue: function InclusionTree_incrementValue(stopValue) {
  33548. var level = this.levels[this.currentLevel];
  33549. level.items[level.index] = stopValue + 1;
  33550. this.propagateValues();
  33551. },
  33552. propagateValues: function InclusionTree_propagateValues() {
  33553. var levelIndex = this.currentLevel;
  33554. var level = this.levels[levelIndex];
  33555. var currentValue = level.items[level.index];
  33556. while (--levelIndex >= 0) {
  33557. level = this.levels[levelIndex];
  33558. level.items[level.index] = currentValue;
  33559. }
  33560. },
  33561. nextLevel: function InclusionTree_nextLevel() {
  33562. var currentLevel = this.currentLevel;
  33563. var level = this.levels[currentLevel];
  33564. var value = level.items[level.index];
  33565. level.items[level.index] = 0xFF;
  33566. currentLevel--;
  33567. if (currentLevel < 0) {
  33568. return false;
  33569. }
  33570. this.currentLevel = currentLevel;
  33571. level = this.levels[currentLevel];
  33572. level.items[level.index] = value;
  33573. return true;
  33574. }
  33575. };
  33576. return InclusionTree;
  33577. }();
  33578. var BitModel = function BitModelClosure() {
  33579. var UNIFORM_CONTEXT = 17;
  33580. var RUNLENGTH_CONTEXT = 18;
  33581. var LLAndLHContextsLabel = new Uint8Array([
  33582. 0,
  33583. 5,
  33584. 8,
  33585. 0,
  33586. 3,
  33587. 7,
  33588. 8,
  33589. 0,
  33590. 4,
  33591. 7,
  33592. 8,
  33593. 0,
  33594. 0,
  33595. 0,
  33596. 0,
  33597. 0,
  33598. 1,
  33599. 6,
  33600. 8,
  33601. 0,
  33602. 3,
  33603. 7,
  33604. 8,
  33605. 0,
  33606. 4,
  33607. 7,
  33608. 8,
  33609. 0,
  33610. 0,
  33611. 0,
  33612. 0,
  33613. 0,
  33614. 2,
  33615. 6,
  33616. 8,
  33617. 0,
  33618. 3,
  33619. 7,
  33620. 8,
  33621. 0,
  33622. 4,
  33623. 7,
  33624. 8,
  33625. 0,
  33626. 0,
  33627. 0,
  33628. 0,
  33629. 0,
  33630. 2,
  33631. 6,
  33632. 8,
  33633. 0,
  33634. 3,
  33635. 7,
  33636. 8,
  33637. 0,
  33638. 4,
  33639. 7,
  33640. 8,
  33641. 0,
  33642. 0,
  33643. 0,
  33644. 0,
  33645. 0,
  33646. 2,
  33647. 6,
  33648. 8,
  33649. 0,
  33650. 3,
  33651. 7,
  33652. 8,
  33653. 0,
  33654. 4,
  33655. 7,
  33656. 8
  33657. ]);
  33658. var HLContextLabel = new Uint8Array([
  33659. 0,
  33660. 3,
  33661. 4,
  33662. 0,
  33663. 5,
  33664. 7,
  33665. 7,
  33666. 0,
  33667. 8,
  33668. 8,
  33669. 8,
  33670. 0,
  33671. 0,
  33672. 0,
  33673. 0,
  33674. 0,
  33675. 1,
  33676. 3,
  33677. 4,
  33678. 0,
  33679. 6,
  33680. 7,
  33681. 7,
  33682. 0,
  33683. 8,
  33684. 8,
  33685. 8,
  33686. 0,
  33687. 0,
  33688. 0,
  33689. 0,
  33690. 0,
  33691. 2,
  33692. 3,
  33693. 4,
  33694. 0,
  33695. 6,
  33696. 7,
  33697. 7,
  33698. 0,
  33699. 8,
  33700. 8,
  33701. 8,
  33702. 0,
  33703. 0,
  33704. 0,
  33705. 0,
  33706. 0,
  33707. 2,
  33708. 3,
  33709. 4,
  33710. 0,
  33711. 6,
  33712. 7,
  33713. 7,
  33714. 0,
  33715. 8,
  33716. 8,
  33717. 8,
  33718. 0,
  33719. 0,
  33720. 0,
  33721. 0,
  33722. 0,
  33723. 2,
  33724. 3,
  33725. 4,
  33726. 0,
  33727. 6,
  33728. 7,
  33729. 7,
  33730. 0,
  33731. 8,
  33732. 8,
  33733. 8
  33734. ]);
  33735. var HHContextLabel = new Uint8Array([
  33736. 0,
  33737. 1,
  33738. 2,
  33739. 0,
  33740. 1,
  33741. 2,
  33742. 2,
  33743. 0,
  33744. 2,
  33745. 2,
  33746. 2,
  33747. 0,
  33748. 0,
  33749. 0,
  33750. 0,
  33751. 0,
  33752. 3,
  33753. 4,
  33754. 5,
  33755. 0,
  33756. 4,
  33757. 5,
  33758. 5,
  33759. 0,
  33760. 5,
  33761. 5,
  33762. 5,
  33763. 0,
  33764. 0,
  33765. 0,
  33766. 0,
  33767. 0,
  33768. 6,
  33769. 7,
  33770. 7,
  33771. 0,
  33772. 7,
  33773. 7,
  33774. 7,
  33775. 0,
  33776. 7,
  33777. 7,
  33778. 7,
  33779. 0,
  33780. 0,
  33781. 0,
  33782. 0,
  33783. 0,
  33784. 8,
  33785. 8,
  33786. 8,
  33787. 0,
  33788. 8,
  33789. 8,
  33790. 8,
  33791. 0,
  33792. 8,
  33793. 8,
  33794. 8,
  33795. 0,
  33796. 0,
  33797. 0,
  33798. 0,
  33799. 0,
  33800. 8,
  33801. 8,
  33802. 8,
  33803. 0,
  33804. 8,
  33805. 8,
  33806. 8,
  33807. 0,
  33808. 8,
  33809. 8,
  33810. 8
  33811. ]);
  33812. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  33813. this.width = width;
  33814. this.height = height;
  33815. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  33816. var coefficientCount = width * height;
  33817. this.neighborsSignificance = new Uint8Array(coefficientCount);
  33818. this.coefficentsSign = new Uint8Array(coefficientCount);
  33819. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  33820. this.processingFlags = new Uint8Array(coefficientCount);
  33821. var bitsDecoded = new Uint8Array(coefficientCount);
  33822. if (zeroBitPlanes !== 0) {
  33823. for (var i = 0; i < coefficientCount; i++) {
  33824. bitsDecoded[i] = zeroBitPlanes;
  33825. }
  33826. }
  33827. this.bitsDecoded = bitsDecoded;
  33828. this.reset();
  33829. }
  33830. BitModel.prototype = {
  33831. setDecoder: function BitModel_setDecoder(decoder) {
  33832. this.decoder = decoder;
  33833. },
  33834. reset: function BitModel_reset() {
  33835. this.contexts = new Int8Array(19);
  33836. this.contexts[0] = 4 << 1 | 0;
  33837. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  33838. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  33839. },
  33840. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  33841. var neighborsSignificance = this.neighborsSignificance;
  33842. var width = this.width, height = this.height;
  33843. var left = column > 0;
  33844. var right = column + 1 < width;
  33845. var i;
  33846. if (row > 0) {
  33847. i = index - width;
  33848. if (left) {
  33849. neighborsSignificance[i - 1] += 0x10;
  33850. }
  33851. if (right) {
  33852. neighborsSignificance[i + 1] += 0x10;
  33853. }
  33854. neighborsSignificance[i] += 0x04;
  33855. }
  33856. if (row + 1 < height) {
  33857. i = index + width;
  33858. if (left) {
  33859. neighborsSignificance[i - 1] += 0x10;
  33860. }
  33861. if (right) {
  33862. neighborsSignificance[i + 1] += 0x10;
  33863. }
  33864. neighborsSignificance[i] += 0x04;
  33865. }
  33866. if (left) {
  33867. neighborsSignificance[index - 1] += 0x01;
  33868. }
  33869. if (right) {
  33870. neighborsSignificance[index + 1] += 0x01;
  33871. }
  33872. neighborsSignificance[index] |= 0x80;
  33873. },
  33874. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  33875. var decoder = this.decoder;
  33876. var width = this.width, height = this.height;
  33877. var coefficentsMagnitude = this.coefficentsMagnitude;
  33878. var coefficentsSign = this.coefficentsSign;
  33879. var neighborsSignificance = this.neighborsSignificance;
  33880. var processingFlags = this.processingFlags;
  33881. var contexts = this.contexts;
  33882. var labels = this.contextLabelTable;
  33883. var bitsDecoded = this.bitsDecoded;
  33884. var processedInverseMask = ~1;
  33885. var processedMask = 1;
  33886. var firstMagnitudeBitMask = 2;
  33887. for (var i0 = 0; i0 < height; i0 += 4) {
  33888. for (var j = 0; j < width; j++) {
  33889. var index = i0 * width + j;
  33890. for (var i1 = 0; i1 < 4; i1++, index += width) {
  33891. var i = i0 + i1;
  33892. if (i >= height) {
  33893. break;
  33894. }
  33895. processingFlags[index] &= processedInverseMask;
  33896. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  33897. continue;
  33898. }
  33899. var contextLabel = labels[neighborsSignificance[index]];
  33900. var decision = decoder.readBit(contexts, contextLabel);
  33901. if (decision) {
  33902. var sign = this.decodeSignBit(i, j, index);
  33903. coefficentsSign[index] = sign;
  33904. coefficentsMagnitude[index] = 1;
  33905. this.setNeighborsSignificance(i, j, index);
  33906. processingFlags[index] |= firstMagnitudeBitMask;
  33907. }
  33908. bitsDecoded[index]++;
  33909. processingFlags[index] |= processedMask;
  33910. }
  33911. }
  33912. }
  33913. },
  33914. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  33915. var width = this.width, height = this.height;
  33916. var coefficentsMagnitude = this.coefficentsMagnitude;
  33917. var coefficentsSign = this.coefficentsSign;
  33918. var contribution, sign0, sign1, significance1;
  33919. var contextLabel, decoded;
  33920. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  33921. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  33922. sign1 = coefficentsSign[index + 1];
  33923. if (significance1) {
  33924. sign0 = coefficentsSign[index - 1];
  33925. contribution = 1 - sign1 - sign0;
  33926. } else {
  33927. contribution = 1 - sign1 - sign1;
  33928. }
  33929. } else if (significance1) {
  33930. sign0 = coefficentsSign[index - 1];
  33931. contribution = 1 - sign0 - sign0;
  33932. } else {
  33933. contribution = 0;
  33934. }
  33935. var horizontalContribution = 3 * contribution;
  33936. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  33937. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  33938. sign1 = coefficentsSign[index + width];
  33939. if (significance1) {
  33940. sign0 = coefficentsSign[index - width];
  33941. contribution = 1 - sign1 - sign0 + horizontalContribution;
  33942. } else {
  33943. contribution = 1 - sign1 - sign1 + horizontalContribution;
  33944. }
  33945. } else if (significance1) {
  33946. sign0 = coefficentsSign[index - width];
  33947. contribution = 1 - sign0 - sign0 + horizontalContribution;
  33948. } else {
  33949. contribution = horizontalContribution;
  33950. }
  33951. if (contribution >= 0) {
  33952. contextLabel = 9 + contribution;
  33953. decoded = this.decoder.readBit(this.contexts, contextLabel);
  33954. } else {
  33955. contextLabel = 9 - contribution;
  33956. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  33957. }
  33958. return decoded;
  33959. },
  33960. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  33961. var decoder = this.decoder;
  33962. var width = this.width, height = this.height;
  33963. var coefficentsMagnitude = this.coefficentsMagnitude;
  33964. var neighborsSignificance = this.neighborsSignificance;
  33965. var contexts = this.contexts;
  33966. var bitsDecoded = this.bitsDecoded;
  33967. var processingFlags = this.processingFlags;
  33968. var processedMask = 1;
  33969. var firstMagnitudeBitMask = 2;
  33970. var length = width * height;
  33971. var width4 = width * 4;
  33972. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  33973. indexNext = Math.min(length, index0 + width4);
  33974. for (var j = 0; j < width; j++) {
  33975. for (var index = index0 + j; index < indexNext; index += width) {
  33976. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  33977. continue;
  33978. }
  33979. var contextLabel = 16;
  33980. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  33981. processingFlags[index] ^= firstMagnitudeBitMask;
  33982. var significance = neighborsSignificance[index] & 127;
  33983. contextLabel = significance === 0 ? 15 : 14;
  33984. }
  33985. var bit = decoder.readBit(contexts, contextLabel);
  33986. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  33987. bitsDecoded[index]++;
  33988. processingFlags[index] |= processedMask;
  33989. }
  33990. }
  33991. }
  33992. },
  33993. runCleanupPass: function BitModel_runCleanupPass() {
  33994. var decoder = this.decoder;
  33995. var width = this.width, height = this.height;
  33996. var neighborsSignificance = this.neighborsSignificance;
  33997. var coefficentsMagnitude = this.coefficentsMagnitude;
  33998. var coefficentsSign = this.coefficentsSign;
  33999. var contexts = this.contexts;
  34000. var labels = this.contextLabelTable;
  34001. var bitsDecoded = this.bitsDecoded;
  34002. var processingFlags = this.processingFlags;
  34003. var processedMask = 1;
  34004. var firstMagnitudeBitMask = 2;
  34005. var oneRowDown = width;
  34006. var twoRowsDown = width * 2;
  34007. var threeRowsDown = width * 3;
  34008. var iNext;
  34009. for (var i0 = 0; i0 < height; i0 = iNext) {
  34010. iNext = Math.min(i0 + 4, height);
  34011. var indexBase = i0 * width;
  34012. var checkAllEmpty = i0 + 3 < height;
  34013. for (var j = 0; j < width; j++) {
  34014. var index0 = indexBase + j;
  34015. 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;
  34016. var i1 = 0, index = index0;
  34017. var i = i0, sign;
  34018. if (allEmpty) {
  34019. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  34020. if (!hasSignificantCoefficent) {
  34021. bitsDecoded[index0]++;
  34022. bitsDecoded[index0 + oneRowDown]++;
  34023. bitsDecoded[index0 + twoRowsDown]++;
  34024. bitsDecoded[index0 + threeRowsDown]++;
  34025. continue;
  34026. }
  34027. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  34028. if (i1 !== 0) {
  34029. i = i0 + i1;
  34030. index += i1 * width;
  34031. }
  34032. sign = this.decodeSignBit(i, j, index);
  34033. coefficentsSign[index] = sign;
  34034. coefficentsMagnitude[index] = 1;
  34035. this.setNeighborsSignificance(i, j, index);
  34036. processingFlags[index] |= firstMagnitudeBitMask;
  34037. index = index0;
  34038. for (var i2 = i0; i2 <= i; i2++, index += width) {
  34039. bitsDecoded[index]++;
  34040. }
  34041. i1++;
  34042. }
  34043. for (i = i0 + i1; i < iNext; i++, index += width) {
  34044. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  34045. continue;
  34046. }
  34047. var contextLabel = labels[neighborsSignificance[index]];
  34048. var decision = decoder.readBit(contexts, contextLabel);
  34049. if (decision === 1) {
  34050. sign = this.decodeSignBit(i, j, index);
  34051. coefficentsSign[index] = sign;
  34052. coefficentsMagnitude[index] = 1;
  34053. this.setNeighborsSignificance(i, j, index);
  34054. processingFlags[index] |= firstMagnitudeBitMask;
  34055. }
  34056. bitsDecoded[index]++;
  34057. }
  34058. }
  34059. }
  34060. },
  34061. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  34062. var decoder = this.decoder;
  34063. var contexts = this.contexts;
  34064. 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);
  34065. if (symbol !== 0xA) {
  34066. error('JPX Error: Invalid segmentation symbol');
  34067. }
  34068. }
  34069. };
  34070. return BitModel;
  34071. }();
  34072. var Transform = function TransformClosure() {
  34073. function Transform() {
  34074. }
  34075. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  34076. var ll = subbands[0];
  34077. for (var i = 1, ii = subbands.length; i < ii; i++) {
  34078. ll = this.iterate(ll, subbands[i], u0, v0);
  34079. }
  34080. return ll;
  34081. };
  34082. Transform.prototype.extend = function extend(buffer, offset, size) {
  34083. var i1 = offset - 1, j1 = offset + 1;
  34084. var i2 = offset + size - 2, j2 = offset + size;
  34085. buffer[i1--] = buffer[j1++];
  34086. buffer[j2++] = buffer[i2--];
  34087. buffer[i1--] = buffer[j1++];
  34088. buffer[j2++] = buffer[i2--];
  34089. buffer[i1--] = buffer[j1++];
  34090. buffer[j2++] = buffer[i2--];
  34091. buffer[i1] = buffer[j1];
  34092. buffer[j2] = buffer[i2];
  34093. };
  34094. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  34095. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  34096. var width = hl_lh_hh.width;
  34097. var height = hl_lh_hh.height;
  34098. var items = hl_lh_hh.items;
  34099. var i, j, k, l, u, v;
  34100. for (k = 0, i = 0; i < llHeight; i++) {
  34101. l = i * 2 * width;
  34102. for (j = 0; j < llWidth; j++, k++, l += 2) {
  34103. items[l] = llItems[k];
  34104. }
  34105. }
  34106. llItems = ll.items = null;
  34107. var bufferPadding = 4;
  34108. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  34109. if (width === 1) {
  34110. if ((u0 & 1) !== 0) {
  34111. for (v = 0, k = 0; v < height; v++, k += width) {
  34112. items[k] *= 0.5;
  34113. }
  34114. }
  34115. } else {
  34116. for (v = 0, k = 0; v < height; v++, k += width) {
  34117. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  34118. this.extend(rowBuffer, bufferPadding, width);
  34119. this.filter(rowBuffer, bufferPadding, width);
  34120. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  34121. }
  34122. }
  34123. var numBuffers = 16;
  34124. var colBuffers = [];
  34125. for (i = 0; i < numBuffers; i++) {
  34126. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  34127. }
  34128. var b, currentBuffer = 0;
  34129. ll = bufferPadding + height;
  34130. if (height === 1) {
  34131. if ((v0 & 1) !== 0) {
  34132. for (u = 0; u < width; u++) {
  34133. items[u] *= 0.5;
  34134. }
  34135. }
  34136. } else {
  34137. for (u = 0; u < width; u++) {
  34138. if (currentBuffer === 0) {
  34139. numBuffers = Math.min(width - u, numBuffers);
  34140. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  34141. for (b = 0; b < numBuffers; b++) {
  34142. colBuffers[b][l] = items[k + b];
  34143. }
  34144. }
  34145. currentBuffer = numBuffers;
  34146. }
  34147. currentBuffer--;
  34148. var buffer = colBuffers[currentBuffer];
  34149. this.extend(buffer, bufferPadding, height);
  34150. this.filter(buffer, bufferPadding, height);
  34151. if (currentBuffer === 0) {
  34152. k = u - numBuffers + 1;
  34153. for (l = bufferPadding; l < ll; k += width, l++) {
  34154. for (b = 0; b < numBuffers; b++) {
  34155. items[k + b] = colBuffers[b][l];
  34156. }
  34157. }
  34158. }
  34159. }
  34160. }
  34161. return {
  34162. width: width,
  34163. height: height,
  34164. items: items
  34165. };
  34166. };
  34167. return Transform;
  34168. }();
  34169. var IrreversibleTransform = function IrreversibleTransformClosure() {
  34170. function IrreversibleTransform() {
  34171. Transform.call(this);
  34172. }
  34173. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  34174. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  34175. var len = length >> 1;
  34176. offset = offset | 0;
  34177. var j, n, current, next;
  34178. var alpha = -1.586134342059924;
  34179. var beta = -0.052980118572961;
  34180. var gamma = 0.882911075530934;
  34181. var delta = 0.443506852043971;
  34182. var K = 1.230174104914001;
  34183. var K_ = 1 / K;
  34184. j = offset - 3;
  34185. for (n = len + 4; n--; j += 2) {
  34186. x[j] *= K_;
  34187. }
  34188. j = offset - 2;
  34189. current = delta * x[j - 1];
  34190. for (n = len + 3; n--; j += 2) {
  34191. next = delta * x[j + 1];
  34192. x[j] = K * x[j] - current - next;
  34193. if (n--) {
  34194. j += 2;
  34195. current = delta * x[j + 1];
  34196. x[j] = K * x[j] - current - next;
  34197. } else {
  34198. break;
  34199. }
  34200. }
  34201. j = offset - 1;
  34202. current = gamma * x[j - 1];
  34203. for (n = len + 2; n--; j += 2) {
  34204. next = gamma * x[j + 1];
  34205. x[j] -= current + next;
  34206. if (n--) {
  34207. j += 2;
  34208. current = gamma * x[j + 1];
  34209. x[j] -= current + next;
  34210. } else {
  34211. break;
  34212. }
  34213. }
  34214. j = offset;
  34215. current = beta * x[j - 1];
  34216. for (n = len + 1; n--; j += 2) {
  34217. next = beta * x[j + 1];
  34218. x[j] -= current + next;
  34219. if (n--) {
  34220. j += 2;
  34221. current = beta * x[j + 1];
  34222. x[j] -= current + next;
  34223. } else {
  34224. break;
  34225. }
  34226. }
  34227. if (len !== 0) {
  34228. j = offset + 1;
  34229. current = alpha * x[j - 1];
  34230. for (n = len; n--; j += 2) {
  34231. next = alpha * x[j + 1];
  34232. x[j] -= current + next;
  34233. if (n--) {
  34234. j += 2;
  34235. current = alpha * x[j + 1];
  34236. x[j] -= current + next;
  34237. } else {
  34238. break;
  34239. }
  34240. }
  34241. }
  34242. };
  34243. return IrreversibleTransform;
  34244. }();
  34245. var ReversibleTransform = function ReversibleTransformClosure() {
  34246. function ReversibleTransform() {
  34247. Transform.call(this);
  34248. }
  34249. ReversibleTransform.prototype = Object.create(Transform.prototype);
  34250. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  34251. var len = length >> 1;
  34252. offset = offset | 0;
  34253. var j, n;
  34254. for (j = offset, n = len + 1; n--; j += 2) {
  34255. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  34256. }
  34257. for (j = offset + 1, n = len; n--; j += 2) {
  34258. x[j] += x[j - 1] + x[j + 1] >> 1;
  34259. }
  34260. };
  34261. return ReversibleTransform;
  34262. }();
  34263. return JpxImage;
  34264. }();
  34265. exports.JpxImage = JpxImage;
  34266. /***/ }),
  34267. /* 19 */
  34268. /***/ (function(module, exports, __w_pdfjs_require__) {
  34269. "use strict";
  34270. var sharedUtil = __w_pdfjs_require__(0);
  34271. var corePrimitives = __w_pdfjs_require__(1);
  34272. var coreCrypto = __w_pdfjs_require__(16);
  34273. var coreParser = __w_pdfjs_require__(6);
  34274. var coreChunkedStream = __w_pdfjs_require__(15);
  34275. var coreColorSpace = __w_pdfjs_require__(4);
  34276. var InvalidPDFException = sharedUtil.InvalidPDFException;
  34277. var MissingDataException = sharedUtil.MissingDataException;
  34278. var XRefParseException = sharedUtil.XRefParseException;
  34279. var assert = sharedUtil.assert;
  34280. var bytesToString = sharedUtil.bytesToString;
  34281. var createPromiseCapability = sharedUtil.createPromiseCapability;
  34282. var error = sharedUtil.error;
  34283. var info = sharedUtil.info;
  34284. var isArray = sharedUtil.isArray;
  34285. var isBool = sharedUtil.isBool;
  34286. var isInt = sharedUtil.isInt;
  34287. var isString = sharedUtil.isString;
  34288. var shadow = sharedUtil.shadow;
  34289. var stringToPDFString = sharedUtil.stringToPDFString;
  34290. var stringToUTF8String = sharedUtil.stringToUTF8String;
  34291. var warn = sharedUtil.warn;
  34292. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  34293. var Util = sharedUtil.Util;
  34294. var Ref = corePrimitives.Ref;
  34295. var RefSet = corePrimitives.RefSet;
  34296. var RefSetCache = corePrimitives.RefSetCache;
  34297. var isName = corePrimitives.isName;
  34298. var isCmd = corePrimitives.isCmd;
  34299. var isDict = corePrimitives.isDict;
  34300. var isRef = corePrimitives.isRef;
  34301. var isRefsEqual = corePrimitives.isRefsEqual;
  34302. var isStream = corePrimitives.isStream;
  34303. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  34304. var Lexer = coreParser.Lexer;
  34305. var Parser = coreParser.Parser;
  34306. var ChunkedStream = coreChunkedStream.ChunkedStream;
  34307. var ColorSpace = coreColorSpace.ColorSpace;
  34308. var Catalog = function CatalogClosure() {
  34309. function Catalog(pdfManager, xref, pageFactory) {
  34310. this.pdfManager = pdfManager;
  34311. this.xref = xref;
  34312. this.catDict = xref.getCatalogObj();
  34313. this.fontCache = new RefSetCache();
  34314. this.builtInCMapCache = Object.create(null);
  34315. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  34316. this.pageFactory = pageFactory;
  34317. this.pagePromises = [];
  34318. }
  34319. Catalog.prototype = {
  34320. get metadata() {
  34321. var streamRef = this.catDict.getRaw('Metadata');
  34322. if (!isRef(streamRef)) {
  34323. return shadow(this, 'metadata', null);
  34324. }
  34325. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  34326. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  34327. var metadata;
  34328. if (stream && isDict(stream.dict)) {
  34329. var type = stream.dict.get('Type');
  34330. var subtype = stream.dict.get('Subtype');
  34331. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  34332. try {
  34333. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  34334. } catch (e) {
  34335. info('Skipping invalid metadata.');
  34336. }
  34337. }
  34338. }
  34339. return shadow(this, 'metadata', metadata);
  34340. },
  34341. get toplevelPagesDict() {
  34342. var pagesObj = this.catDict.get('Pages');
  34343. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  34344. return shadow(this, 'toplevelPagesDict', pagesObj);
  34345. },
  34346. get documentOutline() {
  34347. var obj = null;
  34348. try {
  34349. obj = this.readDocumentOutline();
  34350. } catch (ex) {
  34351. if (ex instanceof MissingDataException) {
  34352. throw ex;
  34353. }
  34354. warn('Unable to read document outline');
  34355. }
  34356. return shadow(this, 'documentOutline', obj);
  34357. },
  34358. readDocumentOutline: function Catalog_readDocumentOutline() {
  34359. var obj = this.catDict.get('Outlines');
  34360. if (!isDict(obj)) {
  34361. return null;
  34362. }
  34363. obj = obj.getRaw('First');
  34364. if (!isRef(obj)) {
  34365. return null;
  34366. }
  34367. var root = { items: [] };
  34368. var queue = [{
  34369. obj: obj,
  34370. parent: root
  34371. }];
  34372. var processed = new RefSet();
  34373. processed.put(obj);
  34374. var xref = this.xref, blackColor = new Uint8Array(3);
  34375. while (queue.length > 0) {
  34376. var i = queue.shift();
  34377. var outlineDict = xref.fetchIfRef(i.obj);
  34378. if (outlineDict === null) {
  34379. continue;
  34380. }
  34381. assert(outlineDict.has('Title'), 'Invalid outline item');
  34382. var data = {
  34383. url: null,
  34384. dest: null
  34385. };
  34386. Catalog.parseDestDictionary({
  34387. destDict: outlineDict,
  34388. resultObj: data,
  34389. docBaseUrl: this.pdfManager.docBaseUrl
  34390. });
  34391. var title = outlineDict.get('Title');
  34392. var flags = outlineDict.get('F') || 0;
  34393. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  34394. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  34395. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  34396. }
  34397. var outlineItem = {
  34398. dest: data.dest,
  34399. url: data.url,
  34400. unsafeUrl: data.unsafeUrl,
  34401. newWindow: data.newWindow,
  34402. title: stringToPDFString(title),
  34403. color: rgbColor,
  34404. count: outlineDict.get('Count'),
  34405. bold: !!(flags & 2),
  34406. italic: !!(flags & 1),
  34407. items: []
  34408. };
  34409. i.parent.items.push(outlineItem);
  34410. obj = outlineDict.getRaw('First');
  34411. if (isRef(obj) && !processed.has(obj)) {
  34412. queue.push({
  34413. obj: obj,
  34414. parent: outlineItem
  34415. });
  34416. processed.put(obj);
  34417. }
  34418. obj = outlineDict.getRaw('Next');
  34419. if (isRef(obj) && !processed.has(obj)) {
  34420. queue.push({
  34421. obj: obj,
  34422. parent: i.parent
  34423. });
  34424. processed.put(obj);
  34425. }
  34426. }
  34427. return root.items.length > 0 ? root.items : null;
  34428. },
  34429. get numPages() {
  34430. var obj = this.toplevelPagesDict.get('Count');
  34431. assert(isInt(obj), 'page count in top level pages object is not an integer');
  34432. return shadow(this, 'num', obj);
  34433. },
  34434. get destinations() {
  34435. function fetchDestination(dest) {
  34436. return isDict(dest) ? dest.get('D') : dest;
  34437. }
  34438. var xref = this.xref;
  34439. var dests = {}, nameTreeRef, nameDictionaryRef;
  34440. var obj = this.catDict.get('Names');
  34441. if (obj && obj.has('Dests')) {
  34442. nameTreeRef = obj.getRaw('Dests');
  34443. } else if (this.catDict.has('Dests')) {
  34444. nameDictionaryRef = this.catDict.get('Dests');
  34445. }
  34446. if (nameDictionaryRef) {
  34447. obj = nameDictionaryRef;
  34448. obj.forEach(function catalogForEach(key, value) {
  34449. if (!value) {
  34450. return;
  34451. }
  34452. dests[key] = fetchDestination(value);
  34453. });
  34454. }
  34455. if (nameTreeRef) {
  34456. var nameTree = new NameTree(nameTreeRef, xref);
  34457. var names = nameTree.getAll();
  34458. for (var name in names) {
  34459. dests[name] = fetchDestination(names[name]);
  34460. }
  34461. }
  34462. return shadow(this, 'destinations', dests);
  34463. },
  34464. getDestination: function Catalog_getDestination(destinationId) {
  34465. function fetchDestination(dest) {
  34466. return isDict(dest) ? dest.get('D') : dest;
  34467. }
  34468. var xref = this.xref;
  34469. var dest = null, nameTreeRef, nameDictionaryRef;
  34470. var obj = this.catDict.get('Names');
  34471. if (obj && obj.has('Dests')) {
  34472. nameTreeRef = obj.getRaw('Dests');
  34473. } else if (this.catDict.has('Dests')) {
  34474. nameDictionaryRef = this.catDict.get('Dests');
  34475. }
  34476. if (nameDictionaryRef) {
  34477. var value = nameDictionaryRef.get(destinationId);
  34478. if (value) {
  34479. dest = fetchDestination(value);
  34480. }
  34481. }
  34482. if (nameTreeRef) {
  34483. var nameTree = new NameTree(nameTreeRef, xref);
  34484. dest = fetchDestination(nameTree.get(destinationId));
  34485. }
  34486. return dest;
  34487. },
  34488. get pageLabels() {
  34489. var obj = null;
  34490. try {
  34491. obj = this.readPageLabels();
  34492. } catch (ex) {
  34493. if (ex instanceof MissingDataException) {
  34494. throw ex;
  34495. }
  34496. warn('Unable to read page labels.');
  34497. }
  34498. return shadow(this, 'pageLabels', obj);
  34499. },
  34500. readPageLabels: function Catalog_readPageLabels() {
  34501. var obj = this.catDict.getRaw('PageLabels');
  34502. if (!obj) {
  34503. return null;
  34504. }
  34505. var pageLabels = new Array(this.numPages);
  34506. var style = null;
  34507. var prefix = '';
  34508. var numberTree = new NumberTree(obj, this.xref);
  34509. var nums = numberTree.getAll();
  34510. var currentLabel = '', currentIndex = 1;
  34511. for (var i = 0, ii = this.numPages; i < ii; i++) {
  34512. if (i in nums) {
  34513. var labelDict = nums[i];
  34514. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  34515. var type = labelDict.get('Type');
  34516. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  34517. var s = labelDict.get('S');
  34518. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  34519. style = s ? s.name : null;
  34520. var p = labelDict.get('P');
  34521. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  34522. prefix = p ? stringToPDFString(p) : '';
  34523. var st = labelDict.get('St');
  34524. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  34525. currentIndex = st || 1;
  34526. }
  34527. switch (style) {
  34528. case 'D':
  34529. currentLabel = currentIndex;
  34530. break;
  34531. case 'R':
  34532. case 'r':
  34533. currentLabel = Util.toRoman(currentIndex, style === 'r');
  34534. break;
  34535. case 'A':
  34536. case 'a':
  34537. var LIMIT = 26;
  34538. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  34539. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  34540. var letterIndex = currentIndex - 1;
  34541. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  34542. var charBuf = [];
  34543. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  34544. charBuf.push(character);
  34545. }
  34546. currentLabel = charBuf.join('');
  34547. break;
  34548. default:
  34549. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  34550. }
  34551. pageLabels[i] = prefix + currentLabel;
  34552. currentLabel = '';
  34553. currentIndex++;
  34554. }
  34555. return pageLabels;
  34556. },
  34557. get attachments() {
  34558. var xref = this.xref;
  34559. var attachments = null, nameTreeRef;
  34560. var obj = this.catDict.get('Names');
  34561. if (obj) {
  34562. nameTreeRef = obj.getRaw('EmbeddedFiles');
  34563. }
  34564. if (nameTreeRef) {
  34565. var nameTree = new NameTree(nameTreeRef, xref);
  34566. var names = nameTree.getAll();
  34567. for (var name in names) {
  34568. var fs = new FileSpec(names[name], xref);
  34569. if (!attachments) {
  34570. attachments = Object.create(null);
  34571. }
  34572. attachments[stringToPDFString(name)] = fs.serializable;
  34573. }
  34574. }
  34575. return shadow(this, 'attachments', attachments);
  34576. },
  34577. get javaScript() {
  34578. var xref = this.xref;
  34579. var obj = this.catDict.get('Names');
  34580. var javaScript = [];
  34581. function appendIfJavaScriptDict(jsDict) {
  34582. var type = jsDict.get('S');
  34583. if (!isName(type, 'JavaScript')) {
  34584. return;
  34585. }
  34586. var js = jsDict.get('JS');
  34587. if (isStream(js)) {
  34588. js = bytesToString(js.getBytes());
  34589. } else if (!isString(js)) {
  34590. return;
  34591. }
  34592. javaScript.push(stringToPDFString(js));
  34593. }
  34594. if (obj && obj.has('JavaScript')) {
  34595. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  34596. var names = nameTree.getAll();
  34597. for (var name in names) {
  34598. var jsDict = names[name];
  34599. if (isDict(jsDict)) {
  34600. appendIfJavaScriptDict(jsDict);
  34601. }
  34602. }
  34603. }
  34604. var openactionDict = this.catDict.get('OpenAction');
  34605. if (isDict(openactionDict, 'Action')) {
  34606. var actionType = openactionDict.get('S');
  34607. if (isName(actionType, 'Named')) {
  34608. var action = openactionDict.get('N');
  34609. if (isName(action, 'Print')) {
  34610. javaScript.push('print({});');
  34611. }
  34612. } else {
  34613. appendIfJavaScriptDict(openactionDict);
  34614. }
  34615. }
  34616. return shadow(this, 'javaScript', javaScript);
  34617. },
  34618. cleanup: function Catalog_cleanup() {
  34619. var promises = [];
  34620. this.fontCache.forEach(function (promise) {
  34621. promises.push(promise);
  34622. });
  34623. return Promise.all(promises).then(function (translatedFonts) {
  34624. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  34625. var font = translatedFonts[i].dict;
  34626. delete font.translated;
  34627. }
  34628. this.fontCache.clear();
  34629. this.builtInCMapCache = Object.create(null);
  34630. }.bind(this));
  34631. },
  34632. getPage: function Catalog_getPage(pageIndex) {
  34633. if (!(pageIndex in this.pagePromises)) {
  34634. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  34635. var dict = a[0];
  34636. var ref = a[1];
  34637. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache, this.builtInCMapCache);
  34638. }.bind(this));
  34639. }
  34640. return this.pagePromises[pageIndex];
  34641. },
  34642. getPageDict: function Catalog_getPageDict(pageIndex) {
  34643. var capability = createPromiseCapability();
  34644. var nodesToVisit = [this.catDict.getRaw('Pages')];
  34645. var currentPageIndex = 0;
  34646. var xref = this.xref;
  34647. function next() {
  34648. while (nodesToVisit.length) {
  34649. var currentNode = nodesToVisit.pop();
  34650. if (isRef(currentNode)) {
  34651. xref.fetchAsync(currentNode).then(function (obj) {
  34652. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  34653. if (pageIndex === currentPageIndex) {
  34654. capability.resolve([
  34655. obj,
  34656. currentNode
  34657. ]);
  34658. } else {
  34659. currentPageIndex++;
  34660. next();
  34661. }
  34662. return;
  34663. }
  34664. nodesToVisit.push(obj);
  34665. next();
  34666. }, capability.reject);
  34667. return;
  34668. }
  34669. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  34670. var count = currentNode.get('Count');
  34671. if (currentPageIndex + count <= pageIndex) {
  34672. currentPageIndex += count;
  34673. continue;
  34674. }
  34675. var kids = currentNode.get('Kids');
  34676. assert(isArray(kids), 'page dictionary kids object is not an array');
  34677. for (var last = kids.length - 1; last >= 0; last--) {
  34678. nodesToVisit.push(kids[last]);
  34679. }
  34680. }
  34681. capability.reject('Page index ' + pageIndex + ' not found.');
  34682. }
  34683. next();
  34684. return capability.promise;
  34685. },
  34686. getPageIndex: function Catalog_getPageIndex(pageRef) {
  34687. var xref = this.xref;
  34688. function pagesBeforeRef(kidRef) {
  34689. var total = 0;
  34690. var parentRef;
  34691. return xref.fetchAsync(kidRef).then(function (node) {
  34692. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  34693. throw new Error('The reference does not point to a /Page Dict.');
  34694. }
  34695. if (!node) {
  34696. return null;
  34697. }
  34698. assert(isDict(node), 'node must be a Dict.');
  34699. parentRef = node.getRaw('Parent');
  34700. return node.getAsync('Parent');
  34701. }).then(function (parent) {
  34702. if (!parent) {
  34703. return null;
  34704. }
  34705. assert(isDict(parent), 'parent must be a Dict.');
  34706. return parent.getAsync('Kids');
  34707. }).then(function (kids) {
  34708. if (!kids) {
  34709. return null;
  34710. }
  34711. var kidPromises = [];
  34712. var found = false;
  34713. for (var i = 0; i < kids.length; i++) {
  34714. var kid = kids[i];
  34715. assert(isRef(kid), 'kid must be a Ref.');
  34716. if (kid.num === kidRef.num) {
  34717. found = true;
  34718. break;
  34719. }
  34720. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  34721. if (kid.has('Count')) {
  34722. var count = kid.get('Count');
  34723. total += count;
  34724. } else {
  34725. total++;
  34726. }
  34727. }));
  34728. }
  34729. if (!found) {
  34730. error('kid ref not found in parents kids');
  34731. }
  34732. return Promise.all(kidPromises).then(function () {
  34733. return [
  34734. total,
  34735. parentRef
  34736. ];
  34737. });
  34738. });
  34739. }
  34740. var total = 0;
  34741. function next(ref) {
  34742. return pagesBeforeRef(ref).then(function (args) {
  34743. if (!args) {
  34744. return total;
  34745. }
  34746. var count = args[0];
  34747. var parentRef = args[1];
  34748. total += count;
  34749. return next(parentRef);
  34750. });
  34751. }
  34752. return next(pageRef);
  34753. }
  34754. };
  34755. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  34756. function addDefaultProtocolToUrl(url) {
  34757. if (url.indexOf('www.') === 0) {
  34758. return 'http://' + url;
  34759. }
  34760. return url;
  34761. }
  34762. function tryConvertUrlEncoding(url) {
  34763. try {
  34764. return stringToUTF8String(url);
  34765. } catch (e) {
  34766. return url;
  34767. }
  34768. }
  34769. var destDict = params.destDict;
  34770. if (!isDict(destDict)) {
  34771. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  34772. return;
  34773. }
  34774. var resultObj = params.resultObj;
  34775. if (typeof resultObj !== 'object') {
  34776. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  34777. return;
  34778. }
  34779. var docBaseUrl = params.docBaseUrl || null;
  34780. var action = destDict.get('A'), url, dest;
  34781. if (isDict(action)) {
  34782. var linkType = action.get('S').name;
  34783. switch (linkType) {
  34784. case 'URI':
  34785. url = action.get('URI');
  34786. if (isName(url)) {
  34787. url = '/' + url.name;
  34788. } else if (isString(url)) {
  34789. url = addDefaultProtocolToUrl(url);
  34790. }
  34791. break;
  34792. case 'GoTo':
  34793. dest = action.get('D');
  34794. break;
  34795. case 'Launch':
  34796. case 'GoToR':
  34797. var urlDict = action.get('F');
  34798. if (isDict(urlDict)) {
  34799. url = urlDict.get('F') || null;
  34800. } else if (isString(urlDict)) {
  34801. url = urlDict;
  34802. }
  34803. var remoteDest = action.get('D');
  34804. if (remoteDest) {
  34805. if (isName(remoteDest)) {
  34806. remoteDest = remoteDest.name;
  34807. }
  34808. if (isString(url)) {
  34809. var baseUrl = url.split('#')[0];
  34810. if (isString(remoteDest)) {
  34811. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  34812. } else if (isArray(remoteDest)) {
  34813. url = baseUrl + '#' + JSON.stringify(remoteDest);
  34814. }
  34815. }
  34816. }
  34817. var newWindow = action.get('NewWindow');
  34818. if (isBool(newWindow)) {
  34819. resultObj.newWindow = newWindow;
  34820. }
  34821. break;
  34822. case 'Named':
  34823. var namedAction = action.get('N');
  34824. if (isName(namedAction)) {
  34825. resultObj.action = namedAction.name;
  34826. }
  34827. break;
  34828. case 'JavaScript':
  34829. var jsAction = action.get('JS'), js;
  34830. if (isStream(jsAction)) {
  34831. js = bytesToString(jsAction.getBytes());
  34832. } else if (isString(jsAction)) {
  34833. js = jsAction;
  34834. }
  34835. if (js) {
  34836. var URL_OPEN_METHODS = [
  34837. 'app.launchURL',
  34838. 'window.open'
  34839. ];
  34840. var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  34841. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  34842. if (jsUrl && jsUrl[1]) {
  34843. url = jsUrl[1];
  34844. break;
  34845. }
  34846. }
  34847. default:
  34848. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  34849. break;
  34850. }
  34851. } else if (destDict.has('Dest')) {
  34852. dest = destDict.get('Dest');
  34853. }
  34854. if (isString(url)) {
  34855. url = tryConvertUrlEncoding(url);
  34856. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  34857. if (absoluteUrl) {
  34858. resultObj.url = absoluteUrl.href;
  34859. }
  34860. resultObj.unsafeUrl = url;
  34861. }
  34862. if (dest) {
  34863. if (isName(dest)) {
  34864. dest = dest.name;
  34865. }
  34866. if (isString(dest) || isArray(dest)) {
  34867. resultObj.dest = dest;
  34868. }
  34869. }
  34870. };
  34871. return Catalog;
  34872. }();
  34873. var XRef = function XRefClosure() {
  34874. function XRef(stream, pdfManager) {
  34875. this.stream = stream;
  34876. this.pdfManager = pdfManager;
  34877. this.entries = [];
  34878. this.xrefstms = Object.create(null);
  34879. this.cache = [];
  34880. this.stats = {
  34881. streamTypes: [],
  34882. fontTypes: []
  34883. };
  34884. }
  34885. XRef.prototype = {
  34886. setStartXRef: function XRef_setStartXRef(startXRef) {
  34887. this.startXRefQueue = [startXRef];
  34888. },
  34889. parse: function XRef_parse(recoveryMode) {
  34890. var trailerDict;
  34891. if (!recoveryMode) {
  34892. trailerDict = this.readXRef();
  34893. } else {
  34894. warn('Indexing all PDF objects');
  34895. trailerDict = this.indexObjects();
  34896. }
  34897. trailerDict.assignXref(this);
  34898. this.trailer = trailerDict;
  34899. var encrypt = trailerDict.get('Encrypt');
  34900. if (isDict(encrypt)) {
  34901. var ids = trailerDict.get('ID');
  34902. var fileId = ids && ids.length ? ids[0] : '';
  34903. encrypt.suppressEncryption = true;
  34904. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
  34905. }
  34906. if (!(this.root = trailerDict.get('Root'))) {
  34907. error('Invalid root reference');
  34908. }
  34909. },
  34910. processXRefTable: function XRef_processXRefTable(parser) {
  34911. if (!('tableState' in this)) {
  34912. this.tableState = {
  34913. entryNum: 0,
  34914. streamPos: parser.lexer.stream.pos,
  34915. parserBuf1: parser.buf1,
  34916. parserBuf2: parser.buf2
  34917. };
  34918. }
  34919. var obj = this.readXRefTable(parser);
  34920. if (!isCmd(obj, 'trailer')) {
  34921. error('Invalid XRef table: could not find trailer dictionary');
  34922. }
  34923. var dict = parser.getObj();
  34924. if (!isDict(dict) && dict.dict) {
  34925. dict = dict.dict;
  34926. }
  34927. if (!isDict(dict)) {
  34928. error('Invalid XRef table: could not parse trailer dictionary');
  34929. }
  34930. delete this.tableState;
  34931. return dict;
  34932. },
  34933. readXRefTable: function XRef_readXRefTable(parser) {
  34934. var stream = parser.lexer.stream;
  34935. var tableState = this.tableState;
  34936. stream.pos = tableState.streamPos;
  34937. parser.buf1 = tableState.parserBuf1;
  34938. parser.buf2 = tableState.parserBuf2;
  34939. var obj;
  34940. while (true) {
  34941. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  34942. if (isCmd(obj = parser.getObj(), 'trailer')) {
  34943. break;
  34944. }
  34945. tableState.firstEntryNum = obj;
  34946. tableState.entryCount = parser.getObj();
  34947. }
  34948. var first = tableState.firstEntryNum;
  34949. var count = tableState.entryCount;
  34950. if (!isInt(first) || !isInt(count)) {
  34951. error('Invalid XRef table: wrong types in subsection header');
  34952. }
  34953. for (var i = tableState.entryNum; i < count; i++) {
  34954. tableState.streamPos = stream.pos;
  34955. tableState.entryNum = i;
  34956. tableState.parserBuf1 = parser.buf1;
  34957. tableState.parserBuf2 = parser.buf2;
  34958. var entry = {};
  34959. entry.offset = parser.getObj();
  34960. entry.gen = parser.getObj();
  34961. var type = parser.getObj();
  34962. if (isCmd(type, 'f')) {
  34963. entry.free = true;
  34964. } else if (isCmd(type, 'n')) {
  34965. entry.uncompressed = true;
  34966. }
  34967. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  34968. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  34969. }
  34970. if (i === 0 && entry.free && first === 1) {
  34971. first = 0;
  34972. }
  34973. if (!this.entries[i + first]) {
  34974. this.entries[i + first] = entry;
  34975. }
  34976. }
  34977. tableState.entryNum = 0;
  34978. tableState.streamPos = stream.pos;
  34979. tableState.parserBuf1 = parser.buf1;
  34980. tableState.parserBuf2 = parser.buf2;
  34981. delete tableState.firstEntryNum;
  34982. delete tableState.entryCount;
  34983. }
  34984. if (this.entries[0] && !this.entries[0].free) {
  34985. error('Invalid XRef table: unexpected first object');
  34986. }
  34987. return obj;
  34988. },
  34989. processXRefStream: function XRef_processXRefStream(stream) {
  34990. if (!('streamState' in this)) {
  34991. var streamParameters = stream.dict;
  34992. var byteWidths = streamParameters.get('W');
  34993. var range = streamParameters.get('Index');
  34994. if (!range) {
  34995. range = [
  34996. 0,
  34997. streamParameters.get('Size')
  34998. ];
  34999. }
  35000. this.streamState = {
  35001. entryRanges: range,
  35002. byteWidths: byteWidths,
  35003. entryNum: 0,
  35004. streamPos: stream.pos
  35005. };
  35006. }
  35007. this.readXRefStream(stream);
  35008. delete this.streamState;
  35009. return stream.dict;
  35010. },
  35011. readXRefStream: function XRef_readXRefStream(stream) {
  35012. var i, j;
  35013. var streamState = this.streamState;
  35014. stream.pos = streamState.streamPos;
  35015. var byteWidths = streamState.byteWidths;
  35016. var typeFieldWidth = byteWidths[0];
  35017. var offsetFieldWidth = byteWidths[1];
  35018. var generationFieldWidth = byteWidths[2];
  35019. var entryRanges = streamState.entryRanges;
  35020. while (entryRanges.length > 0) {
  35021. var first = entryRanges[0];
  35022. var n = entryRanges[1];
  35023. if (!isInt(first) || !isInt(n)) {
  35024. error('Invalid XRef range fields: ' + first + ', ' + n);
  35025. }
  35026. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  35027. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  35028. }
  35029. for (i = streamState.entryNum; i < n; ++i) {
  35030. streamState.entryNum = i;
  35031. streamState.streamPos = stream.pos;
  35032. var type = 0, offset = 0, generation = 0;
  35033. for (j = 0; j < typeFieldWidth; ++j) {
  35034. type = type << 8 | stream.getByte();
  35035. }
  35036. if (typeFieldWidth === 0) {
  35037. type = 1;
  35038. }
  35039. for (j = 0; j < offsetFieldWidth; ++j) {
  35040. offset = offset << 8 | stream.getByte();
  35041. }
  35042. for (j = 0; j < generationFieldWidth; ++j) {
  35043. generation = generation << 8 | stream.getByte();
  35044. }
  35045. var entry = {};
  35046. entry.offset = offset;
  35047. entry.gen = generation;
  35048. switch (type) {
  35049. case 0:
  35050. entry.free = true;
  35051. break;
  35052. case 1:
  35053. entry.uncompressed = true;
  35054. break;
  35055. case 2:
  35056. break;
  35057. default:
  35058. error('Invalid XRef entry type: ' + type);
  35059. }
  35060. if (!this.entries[first + i]) {
  35061. this.entries[first + i] = entry;
  35062. }
  35063. }
  35064. streamState.entryNum = 0;
  35065. streamState.streamPos = stream.pos;
  35066. entryRanges.splice(0, 2);
  35067. }
  35068. },
  35069. indexObjects: function XRef_indexObjects() {
  35070. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  35071. var PERCENT = 0x25, LT = 0x3C;
  35072. function readToken(data, offset) {
  35073. var token = '', ch = data[offset];
  35074. while (ch !== LF && ch !== CR && ch !== LT) {
  35075. if (++offset >= data.length) {
  35076. break;
  35077. }
  35078. token += String.fromCharCode(ch);
  35079. ch = data[offset];
  35080. }
  35081. return token;
  35082. }
  35083. function skipUntil(data, offset, what) {
  35084. var length = what.length, dataLength = data.length;
  35085. var skipped = 0;
  35086. while (offset < dataLength) {
  35087. var i = 0;
  35088. while (i < length && data[offset + i] === what[i]) {
  35089. ++i;
  35090. }
  35091. if (i >= length) {
  35092. break;
  35093. }
  35094. offset++;
  35095. skipped++;
  35096. }
  35097. return skipped;
  35098. }
  35099. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  35100. var trailerBytes = new Uint8Array([
  35101. 116,
  35102. 114,
  35103. 97,
  35104. 105,
  35105. 108,
  35106. 101,
  35107. 114
  35108. ]);
  35109. var startxrefBytes = new Uint8Array([
  35110. 115,
  35111. 116,
  35112. 97,
  35113. 114,
  35114. 116,
  35115. 120,
  35116. 114,
  35117. 101,
  35118. 102
  35119. ]);
  35120. var endobjBytes = new Uint8Array([
  35121. 101,
  35122. 110,
  35123. 100,
  35124. 111,
  35125. 98,
  35126. 106
  35127. ]);
  35128. var xrefBytes = new Uint8Array([
  35129. 47,
  35130. 88,
  35131. 82,
  35132. 101,
  35133. 102
  35134. ]);
  35135. this.entries.length = 0;
  35136. var stream = this.stream;
  35137. stream.pos = 0;
  35138. var buffer = stream.getBytes();
  35139. var position = stream.start, length = buffer.length;
  35140. var trailers = [], xrefStms = [];
  35141. while (position < length) {
  35142. var ch = buffer[position];
  35143. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  35144. ++position;
  35145. continue;
  35146. }
  35147. if (ch === PERCENT) {
  35148. do {
  35149. ++position;
  35150. if (position >= length) {
  35151. break;
  35152. }
  35153. ch = buffer[position];
  35154. } while (ch !== LF && ch !== CR);
  35155. continue;
  35156. }
  35157. var token = readToken(buffer, position);
  35158. var m;
  35159. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  35160. position += skipUntil(buffer, position, trailerBytes);
  35161. trailers.push(position);
  35162. position += skipUntil(buffer, position, startxrefBytes);
  35163. } else if (m = objRegExp.exec(token)) {
  35164. if (typeof this.entries[m[1]] === 'undefined') {
  35165. this.entries[m[1]] = {
  35166. offset: position - stream.start,
  35167. gen: m[2] | 0,
  35168. uncompressed: true
  35169. };
  35170. }
  35171. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  35172. var content = buffer.subarray(position, position + contentLength);
  35173. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  35174. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  35175. xrefStms.push(position - stream.start);
  35176. this.xrefstms[position - stream.start] = 1;
  35177. }
  35178. position += contentLength;
  35179. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  35180. trailers.push(position);
  35181. position += skipUntil(buffer, position, startxrefBytes);
  35182. } else {
  35183. position += token.length + 1;
  35184. }
  35185. }
  35186. var i, ii;
  35187. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  35188. this.startXRefQueue.push(xrefStms[i]);
  35189. this.readXRef(true);
  35190. }
  35191. var dict;
  35192. for (i = 0, ii = trailers.length; i < ii; ++i) {
  35193. stream.pos = trailers[i];
  35194. var parser = new Parser(new Lexer(stream), true, this, true);
  35195. var obj = parser.getObj();
  35196. if (!isCmd(obj, 'trailer')) {
  35197. continue;
  35198. }
  35199. dict = parser.getObj();
  35200. if (!isDict(dict)) {
  35201. continue;
  35202. }
  35203. if (dict.has('ID')) {
  35204. return dict;
  35205. }
  35206. }
  35207. if (dict) {
  35208. return dict;
  35209. }
  35210. throw new InvalidPDFException('Invalid PDF structure');
  35211. },
  35212. readXRef: function XRef_readXRef(recoveryMode) {
  35213. var stream = this.stream;
  35214. try {
  35215. while (this.startXRefQueue.length) {
  35216. var startXRef = this.startXRefQueue[0];
  35217. stream.pos = startXRef + stream.start;
  35218. var parser = new Parser(new Lexer(stream), true, this);
  35219. var obj = parser.getObj();
  35220. var dict;
  35221. if (isCmd(obj, 'xref')) {
  35222. dict = this.processXRefTable(parser);
  35223. if (!this.topDict) {
  35224. this.topDict = dict;
  35225. }
  35226. obj = dict.get('XRefStm');
  35227. if (isInt(obj)) {
  35228. var pos = obj;
  35229. if (!(pos in this.xrefstms)) {
  35230. this.xrefstms[pos] = 1;
  35231. this.startXRefQueue.push(pos);
  35232. }
  35233. }
  35234. } else if (isInt(obj)) {
  35235. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  35236. error('Invalid XRef stream');
  35237. }
  35238. dict = this.processXRefStream(obj);
  35239. if (!this.topDict) {
  35240. this.topDict = dict;
  35241. }
  35242. if (!dict) {
  35243. error('Failed to read XRef stream');
  35244. }
  35245. } else {
  35246. error('Invalid XRef stream header');
  35247. }
  35248. obj = dict.get('Prev');
  35249. if (isInt(obj)) {
  35250. this.startXRefQueue.push(obj);
  35251. } else if (isRef(obj)) {
  35252. this.startXRefQueue.push(obj.num);
  35253. }
  35254. this.startXRefQueue.shift();
  35255. }
  35256. return this.topDict;
  35257. } catch (e) {
  35258. if (e instanceof MissingDataException) {
  35259. throw e;
  35260. }
  35261. info('(while reading XRef): ' + e);
  35262. }
  35263. if (recoveryMode) {
  35264. return;
  35265. }
  35266. throw new XRefParseException();
  35267. },
  35268. getEntry: function XRef_getEntry(i) {
  35269. var xrefEntry = this.entries[i];
  35270. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  35271. return xrefEntry;
  35272. }
  35273. return null;
  35274. },
  35275. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  35276. if (!isRef(obj)) {
  35277. return obj;
  35278. }
  35279. return this.fetch(obj, suppressEncryption);
  35280. },
  35281. fetch: function XRef_fetch(ref, suppressEncryption) {
  35282. assert(isRef(ref), 'ref object is not a reference');
  35283. var num = ref.num;
  35284. if (num in this.cache) {
  35285. var cacheEntry = this.cache[num];
  35286. return cacheEntry;
  35287. }
  35288. var xrefEntry = this.getEntry(num);
  35289. if (xrefEntry === null) {
  35290. return this.cache[num] = null;
  35291. }
  35292. if (xrefEntry.uncompressed) {
  35293. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  35294. } else {
  35295. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  35296. }
  35297. if (isDict(xrefEntry)) {
  35298. xrefEntry.objId = ref.toString();
  35299. } else if (isStream(xrefEntry)) {
  35300. xrefEntry.dict.objId = ref.toString();
  35301. }
  35302. return xrefEntry;
  35303. },
  35304. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  35305. var gen = ref.gen;
  35306. var num = ref.num;
  35307. if (xrefEntry.gen !== gen) {
  35308. error('inconsistent generation in XRef');
  35309. }
  35310. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  35311. var parser = new Parser(new Lexer(stream), true, this);
  35312. var obj1 = parser.getObj();
  35313. var obj2 = parser.getObj();
  35314. var obj3 = parser.getObj();
  35315. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  35316. error('bad XRef entry');
  35317. }
  35318. if (!isCmd(obj3, 'obj')) {
  35319. if (obj3.cmd.indexOf('obj') === 0) {
  35320. num = parseInt(obj3.cmd.substring(3), 10);
  35321. if (!isNaN(num)) {
  35322. return num;
  35323. }
  35324. }
  35325. error('bad XRef entry');
  35326. }
  35327. if (this.encrypt && !suppressEncryption) {
  35328. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  35329. } else {
  35330. xrefEntry = parser.getObj();
  35331. }
  35332. if (!isStream(xrefEntry)) {
  35333. this.cache[num] = xrefEntry;
  35334. }
  35335. return xrefEntry;
  35336. },
  35337. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  35338. var tableOffset = xrefEntry.offset;
  35339. var stream = this.fetch(new Ref(tableOffset, 0));
  35340. if (!isStream(stream)) {
  35341. error('bad ObjStm stream');
  35342. }
  35343. var first = stream.dict.get('First');
  35344. var n = stream.dict.get('N');
  35345. if (!isInt(first) || !isInt(n)) {
  35346. error('invalid first and n parameters for ObjStm stream');
  35347. }
  35348. var parser = new Parser(new Lexer(stream), false, this);
  35349. parser.allowStreams = true;
  35350. var i, entries = [], num, nums = [];
  35351. for (i = 0; i < n; ++i) {
  35352. num = parser.getObj();
  35353. if (!isInt(num)) {
  35354. error('invalid object number in the ObjStm stream: ' + num);
  35355. }
  35356. nums.push(num);
  35357. var offset = parser.getObj();
  35358. if (!isInt(offset)) {
  35359. error('invalid object offset in the ObjStm stream: ' + offset);
  35360. }
  35361. }
  35362. for (i = 0; i < n; ++i) {
  35363. entries.push(parser.getObj());
  35364. if (isCmd(parser.buf1, 'endobj')) {
  35365. parser.shift();
  35366. }
  35367. num = nums[i];
  35368. var entry = this.entries[num];
  35369. if (entry && entry.offset === tableOffset && entry.gen === i) {
  35370. this.cache[num] = entries[i];
  35371. }
  35372. }
  35373. xrefEntry = entries[xrefEntry.gen];
  35374. if (xrefEntry === undefined) {
  35375. error('bad XRef entry for compressed object');
  35376. }
  35377. return xrefEntry;
  35378. },
  35379. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  35380. if (!isRef(obj)) {
  35381. return Promise.resolve(obj);
  35382. }
  35383. return this.fetchAsync(obj, suppressEncryption);
  35384. },
  35385. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  35386. var streamManager = this.stream.manager;
  35387. var xref = this;
  35388. return new Promise(function tryFetch(resolve, reject) {
  35389. try {
  35390. resolve(xref.fetch(ref, suppressEncryption));
  35391. } catch (e) {
  35392. if (e instanceof MissingDataException) {
  35393. streamManager.requestRange(e.begin, e.end).then(function () {
  35394. tryFetch(resolve, reject);
  35395. }, reject);
  35396. return;
  35397. }
  35398. reject(e);
  35399. }
  35400. });
  35401. },
  35402. getCatalogObj: function XRef_getCatalogObj() {
  35403. return this.root;
  35404. }
  35405. };
  35406. return XRef;
  35407. }();
  35408. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  35409. function NameOrNumberTree(root, xref) {
  35410. throw new Error('Cannot initialize NameOrNumberTree.');
  35411. }
  35412. NameOrNumberTree.prototype = {
  35413. getAll: function NameOrNumberTree_getAll() {
  35414. var dict = Object.create(null);
  35415. if (!this.root) {
  35416. return dict;
  35417. }
  35418. var xref = this.xref;
  35419. var processed = new RefSet();
  35420. processed.put(this.root);
  35421. var queue = [this.root];
  35422. while (queue.length > 0) {
  35423. var i, n;
  35424. var obj = xref.fetchIfRef(queue.shift());
  35425. if (!isDict(obj)) {
  35426. continue;
  35427. }
  35428. if (obj.has('Kids')) {
  35429. var kids = obj.get('Kids');
  35430. for (i = 0, n = kids.length; i < n; i++) {
  35431. var kid = kids[i];
  35432. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  35433. queue.push(kid);
  35434. processed.put(kid);
  35435. }
  35436. continue;
  35437. }
  35438. var entries = obj.get(this._type);
  35439. if (isArray(entries)) {
  35440. for (i = 0, n = entries.length; i < n; i += 2) {
  35441. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  35442. }
  35443. }
  35444. }
  35445. return dict;
  35446. },
  35447. get: function NameOrNumberTree_get(key) {
  35448. if (!this.root) {
  35449. return null;
  35450. }
  35451. var xref = this.xref;
  35452. var kidsOrEntries = xref.fetchIfRef(this.root);
  35453. var loopCount = 0;
  35454. var MAX_LEVELS = 10;
  35455. var l, r, m;
  35456. while (kidsOrEntries.has('Kids')) {
  35457. if (++loopCount > MAX_LEVELS) {
  35458. warn('Search depth limit reached for "' + this._type + '" tree.');
  35459. return null;
  35460. }
  35461. var kids = kidsOrEntries.get('Kids');
  35462. if (!isArray(kids)) {
  35463. return null;
  35464. }
  35465. l = 0;
  35466. r = kids.length - 1;
  35467. while (l <= r) {
  35468. m = l + r >> 1;
  35469. var kid = xref.fetchIfRef(kids[m]);
  35470. var limits = kid.get('Limits');
  35471. if (key < xref.fetchIfRef(limits[0])) {
  35472. r = m - 1;
  35473. } else if (key > xref.fetchIfRef(limits[1])) {
  35474. l = m + 1;
  35475. } else {
  35476. kidsOrEntries = xref.fetchIfRef(kids[m]);
  35477. break;
  35478. }
  35479. }
  35480. if (l > r) {
  35481. return null;
  35482. }
  35483. }
  35484. var entries = kidsOrEntries.get(this._type);
  35485. if (isArray(entries)) {
  35486. l = 0;
  35487. r = entries.length - 2;
  35488. while (l <= r) {
  35489. m = l + r & ~1;
  35490. var currentKey = xref.fetchIfRef(entries[m]);
  35491. if (key < currentKey) {
  35492. r = m - 2;
  35493. } else if (key > currentKey) {
  35494. l = m + 2;
  35495. } else {
  35496. return xref.fetchIfRef(entries[m + 1]);
  35497. }
  35498. }
  35499. }
  35500. return null;
  35501. }
  35502. };
  35503. return NameOrNumberTree;
  35504. }();
  35505. var NameTree = function NameTreeClosure() {
  35506. function NameTree(root, xref) {
  35507. this.root = root;
  35508. this.xref = xref;
  35509. this._type = 'Names';
  35510. }
  35511. Util.inherit(NameTree, NameOrNumberTree, {});
  35512. return NameTree;
  35513. }();
  35514. var NumberTree = function NumberTreeClosure() {
  35515. function NumberTree(root, xref) {
  35516. this.root = root;
  35517. this.xref = xref;
  35518. this._type = 'Nums';
  35519. }
  35520. Util.inherit(NumberTree, NameOrNumberTree, {});
  35521. return NumberTree;
  35522. }();
  35523. var FileSpec = function FileSpecClosure() {
  35524. function FileSpec(root, xref) {
  35525. if (!root || !isDict(root)) {
  35526. return;
  35527. }
  35528. this.xref = xref;
  35529. this.root = root;
  35530. if (root.has('FS')) {
  35531. this.fs = root.get('FS');
  35532. }
  35533. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  35534. if (root.has('RF')) {
  35535. warn('Related file specifications are not supported');
  35536. }
  35537. this.contentAvailable = true;
  35538. if (!root.has('EF')) {
  35539. this.contentAvailable = false;
  35540. warn('Non-embedded file specifications are not supported');
  35541. }
  35542. }
  35543. function pickPlatformItem(dict) {
  35544. if (dict.has('UF')) {
  35545. return dict.get('UF');
  35546. } else if (dict.has('F')) {
  35547. return dict.get('F');
  35548. } else if (dict.has('Unix')) {
  35549. return dict.get('Unix');
  35550. } else if (dict.has('Mac')) {
  35551. return dict.get('Mac');
  35552. } else if (dict.has('DOS')) {
  35553. return dict.get('DOS');
  35554. }
  35555. return null;
  35556. }
  35557. FileSpec.prototype = {
  35558. get filename() {
  35559. if (!this._filename && this.root) {
  35560. var filename = pickPlatformItem(this.root) || 'unnamed';
  35561. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  35562. }
  35563. return this._filename;
  35564. },
  35565. get content() {
  35566. if (!this.contentAvailable) {
  35567. return null;
  35568. }
  35569. if (!this.contentRef && this.root) {
  35570. this.contentRef = pickPlatformItem(this.root.get('EF'));
  35571. }
  35572. var content = null;
  35573. if (this.contentRef) {
  35574. var xref = this.xref;
  35575. var fileObj = xref.fetchIfRef(this.contentRef);
  35576. if (fileObj && isStream(fileObj)) {
  35577. content = fileObj.getBytes();
  35578. } else {
  35579. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  35580. }
  35581. } else {
  35582. warn('Embedded file specification does not have a content');
  35583. }
  35584. return content;
  35585. },
  35586. get serializable() {
  35587. return {
  35588. filename: this.filename,
  35589. content: this.content
  35590. };
  35591. }
  35592. };
  35593. return FileSpec;
  35594. }();
  35595. var ObjectLoader = function () {
  35596. function mayHaveChildren(value) {
  35597. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  35598. }
  35599. function addChildren(node, nodesToVisit) {
  35600. var value;
  35601. if (isDict(node) || isStream(node)) {
  35602. var map;
  35603. if (isDict(node)) {
  35604. map = node.map;
  35605. } else {
  35606. map = node.dict.map;
  35607. }
  35608. for (var key in map) {
  35609. value = map[key];
  35610. if (mayHaveChildren(value)) {
  35611. nodesToVisit.push(value);
  35612. }
  35613. }
  35614. } else if (isArray(node)) {
  35615. for (var i = 0, ii = node.length; i < ii; i++) {
  35616. value = node[i];
  35617. if (mayHaveChildren(value)) {
  35618. nodesToVisit.push(value);
  35619. }
  35620. }
  35621. }
  35622. }
  35623. function ObjectLoader(obj, keys, xref) {
  35624. this.obj = obj;
  35625. this.keys = keys;
  35626. this.xref = xref;
  35627. this.refSet = null;
  35628. this.capability = null;
  35629. }
  35630. ObjectLoader.prototype = {
  35631. load: function ObjectLoader_load() {
  35632. var keys = this.keys;
  35633. this.capability = createPromiseCapability();
  35634. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  35635. this.capability.resolve();
  35636. return this.capability.promise;
  35637. }
  35638. this.refSet = new RefSet();
  35639. var nodesToVisit = [];
  35640. for (var i = 0; i < keys.length; i++) {
  35641. nodesToVisit.push(this.obj[keys[i]]);
  35642. }
  35643. this._walk(nodesToVisit);
  35644. return this.capability.promise;
  35645. },
  35646. _walk: function ObjectLoader_walk(nodesToVisit) {
  35647. var nodesToRevisit = [];
  35648. var pendingRequests = [];
  35649. while (nodesToVisit.length) {
  35650. var currentNode = nodesToVisit.pop();
  35651. if (isRef(currentNode)) {
  35652. if (this.refSet.has(currentNode)) {
  35653. continue;
  35654. }
  35655. try {
  35656. var ref = currentNode;
  35657. this.refSet.put(ref);
  35658. currentNode = this.xref.fetch(currentNode);
  35659. } catch (e) {
  35660. if (!(e instanceof MissingDataException)) {
  35661. throw e;
  35662. }
  35663. nodesToRevisit.push(currentNode);
  35664. pendingRequests.push({
  35665. begin: e.begin,
  35666. end: e.end
  35667. });
  35668. }
  35669. }
  35670. if (currentNode && currentNode.getBaseStreams) {
  35671. var baseStreams = currentNode.getBaseStreams();
  35672. var foundMissingData = false;
  35673. for (var i = 0; i < baseStreams.length; i++) {
  35674. var stream = baseStreams[i];
  35675. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  35676. foundMissingData = true;
  35677. pendingRequests.push({
  35678. begin: stream.start,
  35679. end: stream.end
  35680. });
  35681. }
  35682. }
  35683. if (foundMissingData) {
  35684. nodesToRevisit.push(currentNode);
  35685. }
  35686. }
  35687. addChildren(currentNode, nodesToVisit);
  35688. }
  35689. if (pendingRequests.length) {
  35690. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  35691. nodesToVisit = nodesToRevisit;
  35692. for (var i = 0; i < nodesToRevisit.length; i++) {
  35693. var node = nodesToRevisit[i];
  35694. if (isRef(node)) {
  35695. this.refSet.remove(node);
  35696. }
  35697. }
  35698. this._walk(nodesToVisit);
  35699. }.bind(this), this.capability.reject);
  35700. return;
  35701. }
  35702. this.refSet = null;
  35703. this.capability.resolve();
  35704. }
  35705. };
  35706. return ObjectLoader;
  35707. }();
  35708. exports.Catalog = Catalog;
  35709. exports.ObjectLoader = ObjectLoader;
  35710. exports.XRef = XRef;
  35711. exports.FileSpec = FileSpec;
  35712. /***/ }),
  35713. /* 20 */
  35714. /***/ (function(module, exports, __w_pdfjs_require__) {
  35715. "use strict";
  35716. var sharedUtil = __w_pdfjs_require__(0);
  35717. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  35718. var getStdFontMap = getLookupTableFactory(function (t) {
  35719. t['ArialNarrow'] = 'Helvetica';
  35720. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  35721. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  35722. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  35723. t['ArialBlack'] = 'Helvetica';
  35724. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  35725. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  35726. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  35727. t['Arial-Black'] = 'Helvetica';
  35728. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  35729. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  35730. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  35731. t['Arial'] = 'Helvetica';
  35732. t['Arial-Bold'] = 'Helvetica-Bold';
  35733. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  35734. t['Arial-Italic'] = 'Helvetica-Oblique';
  35735. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  35736. t['Arial-BoldMT'] = 'Helvetica-Bold';
  35737. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  35738. t['ArialMT'] = 'Helvetica';
  35739. t['Courier-Bold'] = 'Courier-Bold';
  35740. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  35741. t['Courier-Italic'] = 'Courier-Oblique';
  35742. t['CourierNew'] = 'Courier';
  35743. t['CourierNew-Bold'] = 'Courier-Bold';
  35744. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  35745. t['CourierNew-Italic'] = 'Courier-Oblique';
  35746. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  35747. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  35748. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  35749. t['CourierNewPSMT'] = 'Courier';
  35750. t['Helvetica'] = 'Helvetica';
  35751. t['Helvetica-Bold'] = 'Helvetica-Bold';
  35752. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  35753. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  35754. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  35755. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  35756. t['Symbol-Bold'] = 'Symbol';
  35757. t['Symbol-BoldItalic'] = 'Symbol';
  35758. t['Symbol-Italic'] = 'Symbol';
  35759. t['TimesNewRoman'] = 'Times-Roman';
  35760. t['TimesNewRoman-Bold'] = 'Times-Bold';
  35761. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  35762. t['TimesNewRoman-Italic'] = 'Times-Italic';
  35763. t['TimesNewRomanPS'] = 'Times-Roman';
  35764. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  35765. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  35766. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  35767. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  35768. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  35769. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  35770. t['TimesNewRomanPSMT'] = 'Times-Roman';
  35771. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  35772. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  35773. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  35774. });
  35775. var getNonStdFontMap = getLookupTableFactory(function (t) {
  35776. t['CenturyGothic'] = 'Helvetica';
  35777. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  35778. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  35779. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  35780. t['ComicSansMS'] = 'Comic Sans MS';
  35781. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  35782. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  35783. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  35784. t['LucidaConsole'] = 'Courier';
  35785. t['LucidaConsole-Bold'] = 'Courier-Bold';
  35786. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  35787. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  35788. t['MS-Gothic'] = 'MS Gothic';
  35789. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  35790. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  35791. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  35792. t['MS-Mincho'] = 'MS Mincho';
  35793. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  35794. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  35795. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  35796. t['MS-PGothic'] = 'MS PGothic';
  35797. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  35798. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  35799. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  35800. t['MS-PMincho'] = 'MS PMincho';
  35801. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  35802. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  35803. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  35804. t['NuptialScript'] = 'Times-Italic';
  35805. t['Wingdings'] = 'ZapfDingbats';
  35806. });
  35807. var getSerifFonts = getLookupTableFactory(function (t) {
  35808. t['Adobe Jenson'] = true;
  35809. t['Adobe Text'] = true;
  35810. t['Albertus'] = true;
  35811. t['Aldus'] = true;
  35812. t['Alexandria'] = true;
  35813. t['Algerian'] = true;
  35814. t['American Typewriter'] = true;
  35815. t['Antiqua'] = true;
  35816. t['Apex'] = true;
  35817. t['Arno'] = true;
  35818. t['Aster'] = true;
  35819. t['Aurora'] = true;
  35820. t['Baskerville'] = true;
  35821. t['Bell'] = true;
  35822. t['Bembo'] = true;
  35823. t['Bembo Schoolbook'] = true;
  35824. t['Benguiat'] = true;
  35825. t['Berkeley Old Style'] = true;
  35826. t['Bernhard Modern'] = true;
  35827. t['Berthold City'] = true;
  35828. t['Bodoni'] = true;
  35829. t['Bauer Bodoni'] = true;
  35830. t['Book Antiqua'] = true;
  35831. t['Bookman'] = true;
  35832. t['Bordeaux Roman'] = true;
  35833. t['Californian FB'] = true;
  35834. t['Calisto'] = true;
  35835. t['Calvert'] = true;
  35836. t['Capitals'] = true;
  35837. t['Cambria'] = true;
  35838. t['Cartier'] = true;
  35839. t['Caslon'] = true;
  35840. t['Catull'] = true;
  35841. t['Centaur'] = true;
  35842. t['Century Old Style'] = true;
  35843. t['Century Schoolbook'] = true;
  35844. t['Chaparral'] = true;
  35845. t['Charis SIL'] = true;
  35846. t['Cheltenham'] = true;
  35847. t['Cholla Slab'] = true;
  35848. t['Clarendon'] = true;
  35849. t['Clearface'] = true;
  35850. t['Cochin'] = true;
  35851. t['Colonna'] = true;
  35852. t['Computer Modern'] = true;
  35853. t['Concrete Roman'] = true;
  35854. t['Constantia'] = true;
  35855. t['Cooper Black'] = true;
  35856. t['Corona'] = true;
  35857. t['Ecotype'] = true;
  35858. t['Egyptienne'] = true;
  35859. t['Elephant'] = true;
  35860. t['Excelsior'] = true;
  35861. t['Fairfield'] = true;
  35862. t['FF Scala'] = true;
  35863. t['Folkard'] = true;
  35864. t['Footlight'] = true;
  35865. t['FreeSerif'] = true;
  35866. t['Friz Quadrata'] = true;
  35867. t['Garamond'] = true;
  35868. t['Gentium'] = true;
  35869. t['Georgia'] = true;
  35870. t['Gloucester'] = true;
  35871. t['Goudy Old Style'] = true;
  35872. t['Goudy Schoolbook'] = true;
  35873. t['Goudy Pro Font'] = true;
  35874. t['Granjon'] = true;
  35875. t['Guardian Egyptian'] = true;
  35876. t['Heather'] = true;
  35877. t['Hercules'] = true;
  35878. t['High Tower Text'] = true;
  35879. t['Hiroshige'] = true;
  35880. t['Hoefler Text'] = true;
  35881. t['Humana Serif'] = true;
  35882. t['Imprint'] = true;
  35883. t['Ionic No. 5'] = true;
  35884. t['Janson'] = true;
  35885. t['Joanna'] = true;
  35886. t['Korinna'] = true;
  35887. t['Lexicon'] = true;
  35888. t['Liberation Serif'] = true;
  35889. t['Linux Libertine'] = true;
  35890. t['Literaturnaya'] = true;
  35891. t['Lucida'] = true;
  35892. t['Lucida Bright'] = true;
  35893. t['Melior'] = true;
  35894. t['Memphis'] = true;
  35895. t['Miller'] = true;
  35896. t['Minion'] = true;
  35897. t['Modern'] = true;
  35898. t['Mona Lisa'] = true;
  35899. t['Mrs Eaves'] = true;
  35900. t['MS Serif'] = true;
  35901. t['Museo Slab'] = true;
  35902. t['New York'] = true;
  35903. t['Nimbus Roman'] = true;
  35904. t['NPS Rawlinson Roadway'] = true;
  35905. t['NuptialScript'] = true;
  35906. t['Palatino'] = true;
  35907. t['Perpetua'] = true;
  35908. t['Plantin'] = true;
  35909. t['Plantin Schoolbook'] = true;
  35910. t['Playbill'] = true;
  35911. t['Poor Richard'] = true;
  35912. t['Rawlinson Roadway'] = true;
  35913. t['Renault'] = true;
  35914. t['Requiem'] = true;
  35915. t['Rockwell'] = true;
  35916. t['Roman'] = true;
  35917. t['Rotis Serif'] = true;
  35918. t['Sabon'] = true;
  35919. t['Scala'] = true;
  35920. t['Seagull'] = true;
  35921. t['Sistina'] = true;
  35922. t['Souvenir'] = true;
  35923. t['STIX'] = true;
  35924. t['Stone Informal'] = true;
  35925. t['Stone Serif'] = true;
  35926. t['Sylfaen'] = true;
  35927. t['Times'] = true;
  35928. t['Trajan'] = true;
  35929. t['Trinité'] = true;
  35930. t['Trump Mediaeval'] = true;
  35931. t['Utopia'] = true;
  35932. t['Vale Type'] = true;
  35933. t['Bitstream Vera'] = true;
  35934. t['Vera Serif'] = true;
  35935. t['Versailles'] = true;
  35936. t['Wanted'] = true;
  35937. t['Weiss'] = true;
  35938. t['Wide Latin'] = true;
  35939. t['Windsor'] = true;
  35940. t['XITS'] = true;
  35941. });
  35942. var getSymbolsFonts = getLookupTableFactory(function (t) {
  35943. t['Dingbats'] = true;
  35944. t['Symbol'] = true;
  35945. t['ZapfDingbats'] = true;
  35946. });
  35947. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  35948. t[2] = 10;
  35949. t[3] = 32;
  35950. t[4] = 33;
  35951. t[5] = 34;
  35952. t[6] = 35;
  35953. t[7] = 36;
  35954. t[8] = 37;
  35955. t[9] = 38;
  35956. t[10] = 39;
  35957. t[11] = 40;
  35958. t[12] = 41;
  35959. t[13] = 42;
  35960. t[14] = 43;
  35961. t[15] = 44;
  35962. t[16] = 45;
  35963. t[17] = 46;
  35964. t[18] = 47;
  35965. t[19] = 48;
  35966. t[20] = 49;
  35967. t[21] = 50;
  35968. t[22] = 51;
  35969. t[23] = 52;
  35970. t[24] = 53;
  35971. t[25] = 54;
  35972. t[26] = 55;
  35973. t[27] = 56;
  35974. t[28] = 57;
  35975. t[29] = 58;
  35976. t[30] = 894;
  35977. t[31] = 60;
  35978. t[32] = 61;
  35979. t[33] = 62;
  35980. t[34] = 63;
  35981. t[35] = 64;
  35982. t[36] = 65;
  35983. t[37] = 66;
  35984. t[38] = 67;
  35985. t[39] = 68;
  35986. t[40] = 69;
  35987. t[41] = 70;
  35988. t[42] = 71;
  35989. t[43] = 72;
  35990. t[44] = 73;
  35991. t[45] = 74;
  35992. t[46] = 75;
  35993. t[47] = 76;
  35994. t[48] = 77;
  35995. t[49] = 78;
  35996. t[50] = 79;
  35997. t[51] = 80;
  35998. t[52] = 81;
  35999. t[53] = 82;
  36000. t[54] = 83;
  36001. t[55] = 84;
  36002. t[56] = 85;
  36003. t[57] = 86;
  36004. t[58] = 87;
  36005. t[59] = 88;
  36006. t[60] = 89;
  36007. t[61] = 90;
  36008. t[62] = 91;
  36009. t[63] = 92;
  36010. t[64] = 93;
  36011. t[65] = 94;
  36012. t[66] = 95;
  36013. t[67] = 96;
  36014. t[68] = 97;
  36015. t[69] = 98;
  36016. t[70] = 99;
  36017. t[71] = 100;
  36018. t[72] = 101;
  36019. t[73] = 102;
  36020. t[74] = 103;
  36021. t[75] = 104;
  36022. t[76] = 105;
  36023. t[77] = 106;
  36024. t[78] = 107;
  36025. t[79] = 108;
  36026. t[80] = 109;
  36027. t[81] = 110;
  36028. t[82] = 111;
  36029. t[83] = 112;
  36030. t[84] = 113;
  36031. t[85] = 114;
  36032. t[86] = 115;
  36033. t[87] = 116;
  36034. t[88] = 117;
  36035. t[89] = 118;
  36036. t[90] = 119;
  36037. t[91] = 120;
  36038. t[92] = 121;
  36039. t[93] = 122;
  36040. t[94] = 123;
  36041. t[95] = 124;
  36042. t[96] = 125;
  36043. t[97] = 126;
  36044. t[98] = 196;
  36045. t[99] = 197;
  36046. t[100] = 199;
  36047. t[101] = 201;
  36048. t[102] = 209;
  36049. t[103] = 214;
  36050. t[104] = 220;
  36051. t[105] = 225;
  36052. t[106] = 224;
  36053. t[107] = 226;
  36054. t[108] = 228;
  36055. t[109] = 227;
  36056. t[110] = 229;
  36057. t[111] = 231;
  36058. t[112] = 233;
  36059. t[113] = 232;
  36060. t[114] = 234;
  36061. t[115] = 235;
  36062. t[116] = 237;
  36063. t[117] = 236;
  36064. t[118] = 238;
  36065. t[119] = 239;
  36066. t[120] = 241;
  36067. t[121] = 243;
  36068. t[122] = 242;
  36069. t[123] = 244;
  36070. t[124] = 246;
  36071. t[125] = 245;
  36072. t[126] = 250;
  36073. t[127] = 249;
  36074. t[128] = 251;
  36075. t[129] = 252;
  36076. t[130] = 8224;
  36077. t[131] = 176;
  36078. t[132] = 162;
  36079. t[133] = 163;
  36080. t[134] = 167;
  36081. t[135] = 8226;
  36082. t[136] = 182;
  36083. t[137] = 223;
  36084. t[138] = 174;
  36085. t[139] = 169;
  36086. t[140] = 8482;
  36087. t[141] = 180;
  36088. t[142] = 168;
  36089. t[143] = 8800;
  36090. t[144] = 198;
  36091. t[145] = 216;
  36092. t[146] = 8734;
  36093. t[147] = 177;
  36094. t[148] = 8804;
  36095. t[149] = 8805;
  36096. t[150] = 165;
  36097. t[151] = 181;
  36098. t[152] = 8706;
  36099. t[153] = 8721;
  36100. t[154] = 8719;
  36101. t[156] = 8747;
  36102. t[157] = 170;
  36103. t[158] = 186;
  36104. t[159] = 8486;
  36105. t[160] = 230;
  36106. t[161] = 248;
  36107. t[162] = 191;
  36108. t[163] = 161;
  36109. t[164] = 172;
  36110. t[165] = 8730;
  36111. t[166] = 402;
  36112. t[167] = 8776;
  36113. t[168] = 8710;
  36114. t[169] = 171;
  36115. t[170] = 187;
  36116. t[171] = 8230;
  36117. t[210] = 218;
  36118. t[223] = 711;
  36119. t[224] = 321;
  36120. t[225] = 322;
  36121. t[227] = 353;
  36122. t[229] = 382;
  36123. t[234] = 253;
  36124. t[252] = 263;
  36125. t[253] = 268;
  36126. t[254] = 269;
  36127. t[258] = 258;
  36128. t[260] = 260;
  36129. t[261] = 261;
  36130. t[265] = 280;
  36131. t[266] = 281;
  36132. t[268] = 283;
  36133. t[269] = 313;
  36134. t[275] = 323;
  36135. t[276] = 324;
  36136. t[278] = 328;
  36137. t[284] = 345;
  36138. t[285] = 346;
  36139. t[286] = 347;
  36140. t[292] = 367;
  36141. t[295] = 377;
  36142. t[296] = 378;
  36143. t[298] = 380;
  36144. t[305] = 963;
  36145. t[306] = 964;
  36146. t[307] = 966;
  36147. t[308] = 8215;
  36148. t[309] = 8252;
  36149. t[310] = 8319;
  36150. t[311] = 8359;
  36151. t[312] = 8592;
  36152. t[313] = 8593;
  36153. t[337] = 9552;
  36154. t[493] = 1039;
  36155. t[494] = 1040;
  36156. t[705] = 1524;
  36157. t[706] = 8362;
  36158. t[710] = 64288;
  36159. t[711] = 64298;
  36160. t[759] = 1617;
  36161. t[761] = 1776;
  36162. t[763] = 1778;
  36163. t[775] = 1652;
  36164. t[777] = 1764;
  36165. t[778] = 1780;
  36166. t[779] = 1781;
  36167. t[780] = 1782;
  36168. t[782] = 771;
  36169. t[783] = 64726;
  36170. t[786] = 8363;
  36171. t[788] = 8532;
  36172. t[790] = 768;
  36173. t[791] = 769;
  36174. t[792] = 768;
  36175. t[795] = 803;
  36176. t[797] = 64336;
  36177. t[798] = 64337;
  36178. t[799] = 64342;
  36179. t[800] = 64343;
  36180. t[801] = 64344;
  36181. t[802] = 64345;
  36182. t[803] = 64362;
  36183. t[804] = 64363;
  36184. t[805] = 64364;
  36185. t[2424] = 7821;
  36186. t[2425] = 7822;
  36187. t[2426] = 7823;
  36188. t[2427] = 7824;
  36189. t[2428] = 7825;
  36190. t[2429] = 7826;
  36191. t[2430] = 7827;
  36192. t[2433] = 7682;
  36193. t[2678] = 8045;
  36194. t[2679] = 8046;
  36195. t[2830] = 1552;
  36196. t[2838] = 686;
  36197. t[2840] = 751;
  36198. t[2842] = 753;
  36199. t[2843] = 754;
  36200. t[2844] = 755;
  36201. t[2846] = 757;
  36202. t[2856] = 767;
  36203. t[2857] = 848;
  36204. t[2858] = 849;
  36205. t[2862] = 853;
  36206. t[2863] = 854;
  36207. t[2864] = 855;
  36208. t[2865] = 861;
  36209. t[2866] = 862;
  36210. t[2906] = 7460;
  36211. t[2908] = 7462;
  36212. t[2909] = 7463;
  36213. t[2910] = 7464;
  36214. t[2912] = 7466;
  36215. t[2913] = 7467;
  36216. t[2914] = 7468;
  36217. t[2916] = 7470;
  36218. t[2917] = 7471;
  36219. t[2918] = 7472;
  36220. t[2920] = 7474;
  36221. t[2921] = 7475;
  36222. t[2922] = 7476;
  36223. t[2924] = 7478;
  36224. t[2925] = 7479;
  36225. t[2926] = 7480;
  36226. t[2928] = 7482;
  36227. t[2929] = 7483;
  36228. t[2930] = 7484;
  36229. t[2932] = 7486;
  36230. t[2933] = 7487;
  36231. t[2934] = 7488;
  36232. t[2936] = 7490;
  36233. t[2937] = 7491;
  36234. t[2938] = 7492;
  36235. t[2940] = 7494;
  36236. t[2941] = 7495;
  36237. t[2942] = 7496;
  36238. t[2944] = 7498;
  36239. t[2946] = 7500;
  36240. t[2948] = 7502;
  36241. t[2950] = 7504;
  36242. t[2951] = 7505;
  36243. t[2952] = 7506;
  36244. t[2954] = 7508;
  36245. t[2955] = 7509;
  36246. t[2956] = 7510;
  36247. t[2958] = 7512;
  36248. t[2959] = 7513;
  36249. t[2960] = 7514;
  36250. t[2962] = 7516;
  36251. t[2963] = 7517;
  36252. t[2964] = 7518;
  36253. t[2966] = 7520;
  36254. t[2967] = 7521;
  36255. t[2968] = 7522;
  36256. t[2970] = 7524;
  36257. t[2971] = 7525;
  36258. t[2972] = 7526;
  36259. t[2974] = 7528;
  36260. t[2975] = 7529;
  36261. t[2976] = 7530;
  36262. t[2978] = 1537;
  36263. t[2979] = 1538;
  36264. t[2980] = 1539;
  36265. t[2982] = 1549;
  36266. t[2983] = 1551;
  36267. t[2984] = 1552;
  36268. t[2986] = 1554;
  36269. t[2987] = 1555;
  36270. t[2988] = 1556;
  36271. t[2990] = 1623;
  36272. t[2991] = 1624;
  36273. t[2995] = 1775;
  36274. t[2999] = 1791;
  36275. t[3002] = 64290;
  36276. t[3003] = 64291;
  36277. t[3004] = 64292;
  36278. t[3006] = 64294;
  36279. t[3007] = 64295;
  36280. t[3008] = 64296;
  36281. t[3011] = 1900;
  36282. t[3014] = 8223;
  36283. t[3015] = 8244;
  36284. t[3017] = 7532;
  36285. t[3018] = 7533;
  36286. t[3019] = 7534;
  36287. t[3075] = 7590;
  36288. t[3076] = 7591;
  36289. t[3079] = 7594;
  36290. t[3080] = 7595;
  36291. t[3083] = 7598;
  36292. t[3084] = 7599;
  36293. t[3087] = 7602;
  36294. t[3088] = 7603;
  36295. t[3091] = 7606;
  36296. t[3092] = 7607;
  36297. t[3095] = 7610;
  36298. t[3096] = 7611;
  36299. t[3099] = 7614;
  36300. t[3100] = 7615;
  36301. t[3103] = 7618;
  36302. t[3104] = 7619;
  36303. t[3107] = 8337;
  36304. t[3108] = 8338;
  36305. t[3116] = 1884;
  36306. t[3119] = 1885;
  36307. t[3120] = 1885;
  36308. t[3123] = 1886;
  36309. t[3124] = 1886;
  36310. t[3127] = 1887;
  36311. t[3128] = 1887;
  36312. t[3131] = 1888;
  36313. t[3132] = 1888;
  36314. t[3135] = 1889;
  36315. t[3136] = 1889;
  36316. t[3139] = 1890;
  36317. t[3140] = 1890;
  36318. t[3143] = 1891;
  36319. t[3144] = 1891;
  36320. t[3147] = 1892;
  36321. t[3148] = 1892;
  36322. t[3153] = 580;
  36323. t[3154] = 581;
  36324. t[3157] = 584;
  36325. t[3158] = 585;
  36326. t[3161] = 588;
  36327. t[3162] = 589;
  36328. t[3165] = 891;
  36329. t[3166] = 892;
  36330. t[3169] = 1274;
  36331. t[3170] = 1275;
  36332. t[3173] = 1278;
  36333. t[3174] = 1279;
  36334. t[3181] = 7622;
  36335. t[3182] = 7623;
  36336. t[3282] = 11799;
  36337. t[3316] = 578;
  36338. t[3379] = 42785;
  36339. t[3393] = 1159;
  36340. t[3416] = 8377;
  36341. });
  36342. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  36343. t[227] = 322;
  36344. t[264] = 261;
  36345. t[291] = 346;
  36346. });
  36347. exports.getStdFontMap = getStdFontMap;
  36348. exports.getNonStdFontMap = getNonStdFontMap;
  36349. exports.getSerifFonts = getSerifFonts;
  36350. exports.getSymbolsFonts = getSymbolsFonts;
  36351. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  36352. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  36353. /***/ }),
  36354. /* 21 */
  36355. /***/ (function(module, exports, __w_pdfjs_require__) {
  36356. "use strict";
  36357. var sharedUtil = __w_pdfjs_require__(0);
  36358. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  36359. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  36360. t[63721] = 0x00A9;
  36361. t[63193] = 0x00A9;
  36362. t[63720] = 0x00AE;
  36363. t[63194] = 0x00AE;
  36364. t[63722] = 0x2122;
  36365. t[63195] = 0x2122;
  36366. t[63729] = 0x23A7;
  36367. t[63730] = 0x23A8;
  36368. t[63731] = 0x23A9;
  36369. t[63740] = 0x23AB;
  36370. t[63741] = 0x23AC;
  36371. t[63742] = 0x23AD;
  36372. t[63726] = 0x23A1;
  36373. t[63727] = 0x23A2;
  36374. t[63728] = 0x23A3;
  36375. t[63737] = 0x23A4;
  36376. t[63738] = 0x23A5;
  36377. t[63739] = 0x23A6;
  36378. t[63723] = 0x239B;
  36379. t[63724] = 0x239C;
  36380. t[63725] = 0x239D;
  36381. t[63734] = 0x239E;
  36382. t[63735] = 0x239F;
  36383. t[63736] = 0x23A0;
  36384. });
  36385. function mapSpecialUnicodeValues(code) {
  36386. if (code >= 0xFFF0 && code <= 0xFFFF) {
  36387. return 0;
  36388. } else if (code >= 0xF600 && code <= 0xF8FF) {
  36389. return getSpecialPUASymbols()[code] || code;
  36390. }
  36391. return code;
  36392. }
  36393. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  36394. var unicode = glyphsUnicodeMap[name];
  36395. if (unicode !== undefined) {
  36396. return unicode;
  36397. }
  36398. if (!name) {
  36399. return -1;
  36400. }
  36401. if (name[0] === 'u') {
  36402. var nameLen = name.length, hexStr;
  36403. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  36404. hexStr = name.substr(3);
  36405. } else if (nameLen >= 5 && nameLen <= 7) {
  36406. hexStr = name.substr(1);
  36407. } else {
  36408. return -1;
  36409. }
  36410. if (hexStr === hexStr.toUpperCase()) {
  36411. unicode = parseInt(hexStr, 16);
  36412. if (unicode >= 0) {
  36413. return unicode;
  36414. }
  36415. }
  36416. }
  36417. return -1;
  36418. }
  36419. var UnicodeRanges = [
  36420. {
  36421. 'begin': 0x0000,
  36422. 'end': 0x007F
  36423. },
  36424. {
  36425. 'begin': 0x0080,
  36426. 'end': 0x00FF
  36427. },
  36428. {
  36429. 'begin': 0x0100,
  36430. 'end': 0x017F
  36431. },
  36432. {
  36433. 'begin': 0x0180,
  36434. 'end': 0x024F
  36435. },
  36436. {
  36437. 'begin': 0x0250,
  36438. 'end': 0x02AF
  36439. },
  36440. {
  36441. 'begin': 0x02B0,
  36442. 'end': 0x02FF
  36443. },
  36444. {
  36445. 'begin': 0x0300,
  36446. 'end': 0x036F
  36447. },
  36448. {
  36449. 'begin': 0x0370,
  36450. 'end': 0x03FF
  36451. },
  36452. {
  36453. 'begin': 0x2C80,
  36454. 'end': 0x2CFF
  36455. },
  36456. {
  36457. 'begin': 0x0400,
  36458. 'end': 0x04FF
  36459. },
  36460. {
  36461. 'begin': 0x0530,
  36462. 'end': 0x058F
  36463. },
  36464. {
  36465. 'begin': 0x0590,
  36466. 'end': 0x05FF
  36467. },
  36468. {
  36469. 'begin': 0xA500,
  36470. 'end': 0xA63F
  36471. },
  36472. {
  36473. 'begin': 0x0600,
  36474. 'end': 0x06FF
  36475. },
  36476. {
  36477. 'begin': 0x07C0,
  36478. 'end': 0x07FF
  36479. },
  36480. {
  36481. 'begin': 0x0900,
  36482. 'end': 0x097F
  36483. },
  36484. {
  36485. 'begin': 0x0980,
  36486. 'end': 0x09FF
  36487. },
  36488. {
  36489. 'begin': 0x0A00,
  36490. 'end': 0x0A7F
  36491. },
  36492. {
  36493. 'begin': 0x0A80,
  36494. 'end': 0x0AFF
  36495. },
  36496. {
  36497. 'begin': 0x0B00,
  36498. 'end': 0x0B7F
  36499. },
  36500. {
  36501. 'begin': 0x0B80,
  36502. 'end': 0x0BFF
  36503. },
  36504. {
  36505. 'begin': 0x0C00,
  36506. 'end': 0x0C7F
  36507. },
  36508. {
  36509. 'begin': 0x0C80,
  36510. 'end': 0x0CFF
  36511. },
  36512. {
  36513. 'begin': 0x0D00,
  36514. 'end': 0x0D7F
  36515. },
  36516. {
  36517. 'begin': 0x0E00,
  36518. 'end': 0x0E7F
  36519. },
  36520. {
  36521. 'begin': 0x0E80,
  36522. 'end': 0x0EFF
  36523. },
  36524. {
  36525. 'begin': 0x10A0,
  36526. 'end': 0x10FF
  36527. },
  36528. {
  36529. 'begin': 0x1B00,
  36530. 'end': 0x1B7F
  36531. },
  36532. {
  36533. 'begin': 0x1100,
  36534. 'end': 0x11FF
  36535. },
  36536. {
  36537. 'begin': 0x1E00,
  36538. 'end': 0x1EFF
  36539. },
  36540. {
  36541. 'begin': 0x1F00,
  36542. 'end': 0x1FFF
  36543. },
  36544. {
  36545. 'begin': 0x2000,
  36546. 'end': 0x206F
  36547. },
  36548. {
  36549. 'begin': 0x2070,
  36550. 'end': 0x209F
  36551. },
  36552. {
  36553. 'begin': 0x20A0,
  36554. 'end': 0x20CF
  36555. },
  36556. {
  36557. 'begin': 0x20D0,
  36558. 'end': 0x20FF
  36559. },
  36560. {
  36561. 'begin': 0x2100,
  36562. 'end': 0x214F
  36563. },
  36564. {
  36565. 'begin': 0x2150,
  36566. 'end': 0x218F
  36567. },
  36568. {
  36569. 'begin': 0x2190,
  36570. 'end': 0x21FF
  36571. },
  36572. {
  36573. 'begin': 0x2200,
  36574. 'end': 0x22FF
  36575. },
  36576. {
  36577. 'begin': 0x2300,
  36578. 'end': 0x23FF
  36579. },
  36580. {
  36581. 'begin': 0x2400,
  36582. 'end': 0x243F
  36583. },
  36584. {
  36585. 'begin': 0x2440,
  36586. 'end': 0x245F
  36587. },
  36588. {
  36589. 'begin': 0x2460,
  36590. 'end': 0x24FF
  36591. },
  36592. {
  36593. 'begin': 0x2500,
  36594. 'end': 0x257F
  36595. },
  36596. {
  36597. 'begin': 0x2580,
  36598. 'end': 0x259F
  36599. },
  36600. {
  36601. 'begin': 0x25A0,
  36602. 'end': 0x25FF
  36603. },
  36604. {
  36605. 'begin': 0x2600,
  36606. 'end': 0x26FF
  36607. },
  36608. {
  36609. 'begin': 0x2700,
  36610. 'end': 0x27BF
  36611. },
  36612. {
  36613. 'begin': 0x3000,
  36614. 'end': 0x303F
  36615. },
  36616. {
  36617. 'begin': 0x3040,
  36618. 'end': 0x309F
  36619. },
  36620. {
  36621. 'begin': 0x30A0,
  36622. 'end': 0x30FF
  36623. },
  36624. {
  36625. 'begin': 0x3100,
  36626. 'end': 0x312F
  36627. },
  36628. {
  36629. 'begin': 0x3130,
  36630. 'end': 0x318F
  36631. },
  36632. {
  36633. 'begin': 0xA840,
  36634. 'end': 0xA87F
  36635. },
  36636. {
  36637. 'begin': 0x3200,
  36638. 'end': 0x32FF
  36639. },
  36640. {
  36641. 'begin': 0x3300,
  36642. 'end': 0x33FF
  36643. },
  36644. {
  36645. 'begin': 0xAC00,
  36646. 'end': 0xD7AF
  36647. },
  36648. {
  36649. 'begin': 0xD800,
  36650. 'end': 0xDFFF
  36651. },
  36652. {
  36653. 'begin': 0x10900,
  36654. 'end': 0x1091F
  36655. },
  36656. {
  36657. 'begin': 0x4E00,
  36658. 'end': 0x9FFF
  36659. },
  36660. {
  36661. 'begin': 0xE000,
  36662. 'end': 0xF8FF
  36663. },
  36664. {
  36665. 'begin': 0x31C0,
  36666. 'end': 0x31EF
  36667. },
  36668. {
  36669. 'begin': 0xFB00,
  36670. 'end': 0xFB4F
  36671. },
  36672. {
  36673. 'begin': 0xFB50,
  36674. 'end': 0xFDFF
  36675. },
  36676. {
  36677. 'begin': 0xFE20,
  36678. 'end': 0xFE2F
  36679. },
  36680. {
  36681. 'begin': 0xFE10,
  36682. 'end': 0xFE1F
  36683. },
  36684. {
  36685. 'begin': 0xFE50,
  36686. 'end': 0xFE6F
  36687. },
  36688. {
  36689. 'begin': 0xFE70,
  36690. 'end': 0xFEFF
  36691. },
  36692. {
  36693. 'begin': 0xFF00,
  36694. 'end': 0xFFEF
  36695. },
  36696. {
  36697. 'begin': 0xFFF0,
  36698. 'end': 0xFFFF
  36699. },
  36700. {
  36701. 'begin': 0x0F00,
  36702. 'end': 0x0FFF
  36703. },
  36704. {
  36705. 'begin': 0x0700,
  36706. 'end': 0x074F
  36707. },
  36708. {
  36709. 'begin': 0x0780,
  36710. 'end': 0x07BF
  36711. },
  36712. {
  36713. 'begin': 0x0D80,
  36714. 'end': 0x0DFF
  36715. },
  36716. {
  36717. 'begin': 0x1000,
  36718. 'end': 0x109F
  36719. },
  36720. {
  36721. 'begin': 0x1200,
  36722. 'end': 0x137F
  36723. },
  36724. {
  36725. 'begin': 0x13A0,
  36726. 'end': 0x13FF
  36727. },
  36728. {
  36729. 'begin': 0x1400,
  36730. 'end': 0x167F
  36731. },
  36732. {
  36733. 'begin': 0x1680,
  36734. 'end': 0x169F
  36735. },
  36736. {
  36737. 'begin': 0x16A0,
  36738. 'end': 0x16FF
  36739. },
  36740. {
  36741. 'begin': 0x1780,
  36742. 'end': 0x17FF
  36743. },
  36744. {
  36745. 'begin': 0x1800,
  36746. 'end': 0x18AF
  36747. },
  36748. {
  36749. 'begin': 0x2800,
  36750. 'end': 0x28FF
  36751. },
  36752. {
  36753. 'begin': 0xA000,
  36754. 'end': 0xA48F
  36755. },
  36756. {
  36757. 'begin': 0x1700,
  36758. 'end': 0x171F
  36759. },
  36760. {
  36761. 'begin': 0x10300,
  36762. 'end': 0x1032F
  36763. },
  36764. {
  36765. 'begin': 0x10330,
  36766. 'end': 0x1034F
  36767. },
  36768. {
  36769. 'begin': 0x10400,
  36770. 'end': 0x1044F
  36771. },
  36772. {
  36773. 'begin': 0x1D000,
  36774. 'end': 0x1D0FF
  36775. },
  36776. {
  36777. 'begin': 0x1D400,
  36778. 'end': 0x1D7FF
  36779. },
  36780. {
  36781. 'begin': 0xFF000,
  36782. 'end': 0xFFFFD
  36783. },
  36784. {
  36785. 'begin': 0xFE00,
  36786. 'end': 0xFE0F
  36787. },
  36788. {
  36789. 'begin': 0xE0000,
  36790. 'end': 0xE007F
  36791. },
  36792. {
  36793. 'begin': 0x1900,
  36794. 'end': 0x194F
  36795. },
  36796. {
  36797. 'begin': 0x1950,
  36798. 'end': 0x197F
  36799. },
  36800. {
  36801. 'begin': 0x1980,
  36802. 'end': 0x19DF
  36803. },
  36804. {
  36805. 'begin': 0x1A00,
  36806. 'end': 0x1A1F
  36807. },
  36808. {
  36809. 'begin': 0x2C00,
  36810. 'end': 0x2C5F
  36811. },
  36812. {
  36813. 'begin': 0x2D30,
  36814. 'end': 0x2D7F
  36815. },
  36816. {
  36817. 'begin': 0x4DC0,
  36818. 'end': 0x4DFF
  36819. },
  36820. {
  36821. 'begin': 0xA800,
  36822. 'end': 0xA82F
  36823. },
  36824. {
  36825. 'begin': 0x10000,
  36826. 'end': 0x1007F
  36827. },
  36828. {
  36829. 'begin': 0x10140,
  36830. 'end': 0x1018F
  36831. },
  36832. {
  36833. 'begin': 0x10380,
  36834. 'end': 0x1039F
  36835. },
  36836. {
  36837. 'begin': 0x103A0,
  36838. 'end': 0x103DF
  36839. },
  36840. {
  36841. 'begin': 0x10450,
  36842. 'end': 0x1047F
  36843. },
  36844. {
  36845. 'begin': 0x10480,
  36846. 'end': 0x104AF
  36847. },
  36848. {
  36849. 'begin': 0x10800,
  36850. 'end': 0x1083F
  36851. },
  36852. {
  36853. 'begin': 0x10A00,
  36854. 'end': 0x10A5F
  36855. },
  36856. {
  36857. 'begin': 0x1D300,
  36858. 'end': 0x1D35F
  36859. },
  36860. {
  36861. 'begin': 0x12000,
  36862. 'end': 0x123FF
  36863. },
  36864. {
  36865. 'begin': 0x1D360,
  36866. 'end': 0x1D37F
  36867. },
  36868. {
  36869. 'begin': 0x1B80,
  36870. 'end': 0x1BBF
  36871. },
  36872. {
  36873. 'begin': 0x1C00,
  36874. 'end': 0x1C4F
  36875. },
  36876. {
  36877. 'begin': 0x1C50,
  36878. 'end': 0x1C7F
  36879. },
  36880. {
  36881. 'begin': 0xA880,
  36882. 'end': 0xA8DF
  36883. },
  36884. {
  36885. 'begin': 0xA900,
  36886. 'end': 0xA92F
  36887. },
  36888. {
  36889. 'begin': 0xA930,
  36890. 'end': 0xA95F
  36891. },
  36892. {
  36893. 'begin': 0xAA00,
  36894. 'end': 0xAA5F
  36895. },
  36896. {
  36897. 'begin': 0x10190,
  36898. 'end': 0x101CF
  36899. },
  36900. {
  36901. 'begin': 0x101D0,
  36902. 'end': 0x101FF
  36903. },
  36904. {
  36905. 'begin': 0x102A0,
  36906. 'end': 0x102DF
  36907. },
  36908. {
  36909. 'begin': 0x1F030,
  36910. 'end': 0x1F09F
  36911. }
  36912. ];
  36913. function getUnicodeRangeFor(value) {
  36914. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  36915. var range = UnicodeRanges[i];
  36916. if (value >= range.begin && value < range.end) {
  36917. return i;
  36918. }
  36919. }
  36920. return -1;
  36921. }
  36922. function isRTLRangeFor(value) {
  36923. var range = UnicodeRanges[13];
  36924. if (value >= range.begin && value < range.end) {
  36925. return true;
  36926. }
  36927. range = UnicodeRanges[11];
  36928. if (value >= range.begin && value < range.end) {
  36929. return true;
  36930. }
  36931. return false;
  36932. }
  36933. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  36934. t['\u00A8'] = '\u0020\u0308';
  36935. t['\u00AF'] = '\u0020\u0304';
  36936. t['\u00B4'] = '\u0020\u0301';
  36937. t['\u00B5'] = '\u03BC';
  36938. t['\u00B8'] = '\u0020\u0327';
  36939. t['\u0132'] = '\u0049\u004A';
  36940. t['\u0133'] = '\u0069\u006A';
  36941. t['\u013F'] = '\u004C\u00B7';
  36942. t['\u0140'] = '\u006C\u00B7';
  36943. t['\u0149'] = '\u02BC\u006E';
  36944. t['\u017F'] = '\u0073';
  36945. t['\u01C4'] = '\u0044\u017D';
  36946. t['\u01C5'] = '\u0044\u017E';
  36947. t['\u01C6'] = '\u0064\u017E';
  36948. t['\u01C7'] = '\u004C\u004A';
  36949. t['\u01C8'] = '\u004C\u006A';
  36950. t['\u01C9'] = '\u006C\u006A';
  36951. t['\u01CA'] = '\u004E\u004A';
  36952. t['\u01CB'] = '\u004E\u006A';
  36953. t['\u01CC'] = '\u006E\u006A';
  36954. t['\u01F1'] = '\u0044\u005A';
  36955. t['\u01F2'] = '\u0044\u007A';
  36956. t['\u01F3'] = '\u0064\u007A';
  36957. t['\u02D8'] = '\u0020\u0306';
  36958. t['\u02D9'] = '\u0020\u0307';
  36959. t['\u02DA'] = '\u0020\u030A';
  36960. t['\u02DB'] = '\u0020\u0328';
  36961. t['\u02DC'] = '\u0020\u0303';
  36962. t['\u02DD'] = '\u0020\u030B';
  36963. t['\u037A'] = '\u0020\u0345';
  36964. t['\u0384'] = '\u0020\u0301';
  36965. t['\u03D0'] = '\u03B2';
  36966. t['\u03D1'] = '\u03B8';
  36967. t['\u03D2'] = '\u03A5';
  36968. t['\u03D5'] = '\u03C6';
  36969. t['\u03D6'] = '\u03C0';
  36970. t['\u03F0'] = '\u03BA';
  36971. t['\u03F1'] = '\u03C1';
  36972. t['\u03F2'] = '\u03C2';
  36973. t['\u03F4'] = '\u0398';
  36974. t['\u03F5'] = '\u03B5';
  36975. t['\u03F9'] = '\u03A3';
  36976. t['\u0587'] = '\u0565\u0582';
  36977. t['\u0675'] = '\u0627\u0674';
  36978. t['\u0676'] = '\u0648\u0674';
  36979. t['\u0677'] = '\u06C7\u0674';
  36980. t['\u0678'] = '\u064A\u0674';
  36981. t['\u0E33'] = '\u0E4D\u0E32';
  36982. t['\u0EB3'] = '\u0ECD\u0EB2';
  36983. t['\u0EDC'] = '\u0EAB\u0E99';
  36984. t['\u0EDD'] = '\u0EAB\u0EA1';
  36985. t['\u0F77'] = '\u0FB2\u0F81';
  36986. t['\u0F79'] = '\u0FB3\u0F81';
  36987. t['\u1E9A'] = '\u0061\u02BE';
  36988. t['\u1FBD'] = '\u0020\u0313';
  36989. t['\u1FBF'] = '\u0020\u0313';
  36990. t['\u1FC0'] = '\u0020\u0342';
  36991. t['\u1FFE'] = '\u0020\u0314';
  36992. t['\u2002'] = '\u0020';
  36993. t['\u2003'] = '\u0020';
  36994. t['\u2004'] = '\u0020';
  36995. t['\u2005'] = '\u0020';
  36996. t['\u2006'] = '\u0020';
  36997. t['\u2008'] = '\u0020';
  36998. t['\u2009'] = '\u0020';
  36999. t['\u200A'] = '\u0020';
  37000. t['\u2017'] = '\u0020\u0333';
  37001. t['\u2024'] = '\u002E';
  37002. t['\u2025'] = '\u002E\u002E';
  37003. t['\u2026'] = '\u002E\u002E\u002E';
  37004. t['\u2033'] = '\u2032\u2032';
  37005. t['\u2034'] = '\u2032\u2032\u2032';
  37006. t['\u2036'] = '\u2035\u2035';
  37007. t['\u2037'] = '\u2035\u2035\u2035';
  37008. t['\u203C'] = '\u0021\u0021';
  37009. t['\u203E'] = '\u0020\u0305';
  37010. t['\u2047'] = '\u003F\u003F';
  37011. t['\u2048'] = '\u003F\u0021';
  37012. t['\u2049'] = '\u0021\u003F';
  37013. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  37014. t['\u205F'] = '\u0020';
  37015. t['\u20A8'] = '\u0052\u0073';
  37016. t['\u2100'] = '\u0061\u002F\u0063';
  37017. t['\u2101'] = '\u0061\u002F\u0073';
  37018. t['\u2103'] = '\u00B0\u0043';
  37019. t['\u2105'] = '\u0063\u002F\u006F';
  37020. t['\u2106'] = '\u0063\u002F\u0075';
  37021. t['\u2107'] = '\u0190';
  37022. t['\u2109'] = '\u00B0\u0046';
  37023. t['\u2116'] = '\u004E\u006F';
  37024. t['\u2121'] = '\u0054\u0045\u004C';
  37025. t['\u2135'] = '\u05D0';
  37026. t['\u2136'] = '\u05D1';
  37027. t['\u2137'] = '\u05D2';
  37028. t['\u2138'] = '\u05D3';
  37029. t['\u213B'] = '\u0046\u0041\u0058';
  37030. t['\u2160'] = '\u0049';
  37031. t['\u2161'] = '\u0049\u0049';
  37032. t['\u2162'] = '\u0049\u0049\u0049';
  37033. t['\u2163'] = '\u0049\u0056';
  37034. t['\u2164'] = '\u0056';
  37035. t['\u2165'] = '\u0056\u0049';
  37036. t['\u2166'] = '\u0056\u0049\u0049';
  37037. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  37038. t['\u2168'] = '\u0049\u0058';
  37039. t['\u2169'] = '\u0058';
  37040. t['\u216A'] = '\u0058\u0049';
  37041. t['\u216B'] = '\u0058\u0049\u0049';
  37042. t['\u216C'] = '\u004C';
  37043. t['\u216D'] = '\u0043';
  37044. t['\u216E'] = '\u0044';
  37045. t['\u216F'] = '\u004D';
  37046. t['\u2170'] = '\u0069';
  37047. t['\u2171'] = '\u0069\u0069';
  37048. t['\u2172'] = '\u0069\u0069\u0069';
  37049. t['\u2173'] = '\u0069\u0076';
  37050. t['\u2174'] = '\u0076';
  37051. t['\u2175'] = '\u0076\u0069';
  37052. t['\u2176'] = '\u0076\u0069\u0069';
  37053. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  37054. t['\u2178'] = '\u0069\u0078';
  37055. t['\u2179'] = '\u0078';
  37056. t['\u217A'] = '\u0078\u0069';
  37057. t['\u217B'] = '\u0078\u0069\u0069';
  37058. t['\u217C'] = '\u006C';
  37059. t['\u217D'] = '\u0063';
  37060. t['\u217E'] = '\u0064';
  37061. t['\u217F'] = '\u006D';
  37062. t['\u222C'] = '\u222B\u222B';
  37063. t['\u222D'] = '\u222B\u222B\u222B';
  37064. t['\u222F'] = '\u222E\u222E';
  37065. t['\u2230'] = '\u222E\u222E\u222E';
  37066. t['\u2474'] = '\u0028\u0031\u0029';
  37067. t['\u2475'] = '\u0028\u0032\u0029';
  37068. t['\u2476'] = '\u0028\u0033\u0029';
  37069. t['\u2477'] = '\u0028\u0034\u0029';
  37070. t['\u2478'] = '\u0028\u0035\u0029';
  37071. t['\u2479'] = '\u0028\u0036\u0029';
  37072. t['\u247A'] = '\u0028\u0037\u0029';
  37073. t['\u247B'] = '\u0028\u0038\u0029';
  37074. t['\u247C'] = '\u0028\u0039\u0029';
  37075. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  37076. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  37077. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  37078. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  37079. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  37080. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  37081. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  37082. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  37083. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  37084. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  37085. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  37086. t['\u2488'] = '\u0031\u002E';
  37087. t['\u2489'] = '\u0032\u002E';
  37088. t['\u248A'] = '\u0033\u002E';
  37089. t['\u248B'] = '\u0034\u002E';
  37090. t['\u248C'] = '\u0035\u002E';
  37091. t['\u248D'] = '\u0036\u002E';
  37092. t['\u248E'] = '\u0037\u002E';
  37093. t['\u248F'] = '\u0038\u002E';
  37094. t['\u2490'] = '\u0039\u002E';
  37095. t['\u2491'] = '\u0031\u0030\u002E';
  37096. t['\u2492'] = '\u0031\u0031\u002E';
  37097. t['\u2493'] = '\u0031\u0032\u002E';
  37098. t['\u2494'] = '\u0031\u0033\u002E';
  37099. t['\u2495'] = '\u0031\u0034\u002E';
  37100. t['\u2496'] = '\u0031\u0035\u002E';
  37101. t['\u2497'] = '\u0031\u0036\u002E';
  37102. t['\u2498'] = '\u0031\u0037\u002E';
  37103. t['\u2499'] = '\u0031\u0038\u002E';
  37104. t['\u249A'] = '\u0031\u0039\u002E';
  37105. t['\u249B'] = '\u0032\u0030\u002E';
  37106. t['\u249C'] = '\u0028\u0061\u0029';
  37107. t['\u249D'] = '\u0028\u0062\u0029';
  37108. t['\u249E'] = '\u0028\u0063\u0029';
  37109. t['\u249F'] = '\u0028\u0064\u0029';
  37110. t['\u24A0'] = '\u0028\u0065\u0029';
  37111. t['\u24A1'] = '\u0028\u0066\u0029';
  37112. t['\u24A2'] = '\u0028\u0067\u0029';
  37113. t['\u24A3'] = '\u0028\u0068\u0029';
  37114. t['\u24A4'] = '\u0028\u0069\u0029';
  37115. t['\u24A5'] = '\u0028\u006A\u0029';
  37116. t['\u24A6'] = '\u0028\u006B\u0029';
  37117. t['\u24A7'] = '\u0028\u006C\u0029';
  37118. t['\u24A8'] = '\u0028\u006D\u0029';
  37119. t['\u24A9'] = '\u0028\u006E\u0029';
  37120. t['\u24AA'] = '\u0028\u006F\u0029';
  37121. t['\u24AB'] = '\u0028\u0070\u0029';
  37122. t['\u24AC'] = '\u0028\u0071\u0029';
  37123. t['\u24AD'] = '\u0028\u0072\u0029';
  37124. t['\u24AE'] = '\u0028\u0073\u0029';
  37125. t['\u24AF'] = '\u0028\u0074\u0029';
  37126. t['\u24B0'] = '\u0028\u0075\u0029';
  37127. t['\u24B1'] = '\u0028\u0076\u0029';
  37128. t['\u24B2'] = '\u0028\u0077\u0029';
  37129. t['\u24B3'] = '\u0028\u0078\u0029';
  37130. t['\u24B4'] = '\u0028\u0079\u0029';
  37131. t['\u24B5'] = '\u0028\u007A\u0029';
  37132. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  37133. t['\u2A74'] = '\u003A\u003A\u003D';
  37134. t['\u2A75'] = '\u003D\u003D';
  37135. t['\u2A76'] = '\u003D\u003D\u003D';
  37136. t['\u2E9F'] = '\u6BCD';
  37137. t['\u2EF3'] = '\u9F9F';
  37138. t['\u2F00'] = '\u4E00';
  37139. t['\u2F01'] = '\u4E28';
  37140. t['\u2F02'] = '\u4E36';
  37141. t['\u2F03'] = '\u4E3F';
  37142. t['\u2F04'] = '\u4E59';
  37143. t['\u2F05'] = '\u4E85';
  37144. t['\u2F06'] = '\u4E8C';
  37145. t['\u2F07'] = '\u4EA0';
  37146. t['\u2F08'] = '\u4EBA';
  37147. t['\u2F09'] = '\u513F';
  37148. t['\u2F0A'] = '\u5165';
  37149. t['\u2F0B'] = '\u516B';
  37150. t['\u2F0C'] = '\u5182';
  37151. t['\u2F0D'] = '\u5196';
  37152. t['\u2F0E'] = '\u51AB';
  37153. t['\u2F0F'] = '\u51E0';
  37154. t['\u2F10'] = '\u51F5';
  37155. t['\u2F11'] = '\u5200';
  37156. t['\u2F12'] = '\u529B';
  37157. t['\u2F13'] = '\u52F9';
  37158. t['\u2F14'] = '\u5315';
  37159. t['\u2F15'] = '\u531A';
  37160. t['\u2F16'] = '\u5338';
  37161. t['\u2F17'] = '\u5341';
  37162. t['\u2F18'] = '\u535C';
  37163. t['\u2F19'] = '\u5369';
  37164. t['\u2F1A'] = '\u5382';
  37165. t['\u2F1B'] = '\u53B6';
  37166. t['\u2F1C'] = '\u53C8';
  37167. t['\u2F1D'] = '\u53E3';
  37168. t['\u2F1E'] = '\u56D7';
  37169. t['\u2F1F'] = '\u571F';
  37170. t['\u2F20'] = '\u58EB';
  37171. t['\u2F21'] = '\u5902';
  37172. t['\u2F22'] = '\u590A';
  37173. t['\u2F23'] = '\u5915';
  37174. t['\u2F24'] = '\u5927';
  37175. t['\u2F25'] = '\u5973';
  37176. t['\u2F26'] = '\u5B50';
  37177. t['\u2F27'] = '\u5B80';
  37178. t['\u2F28'] = '\u5BF8';
  37179. t['\u2F29'] = '\u5C0F';
  37180. t['\u2F2A'] = '\u5C22';
  37181. t['\u2F2B'] = '\u5C38';
  37182. t['\u2F2C'] = '\u5C6E';
  37183. t['\u2F2D'] = '\u5C71';
  37184. t['\u2F2E'] = '\u5DDB';
  37185. t['\u2F2F'] = '\u5DE5';
  37186. t['\u2F30'] = '\u5DF1';
  37187. t['\u2F31'] = '\u5DFE';
  37188. t['\u2F32'] = '\u5E72';
  37189. t['\u2F33'] = '\u5E7A';
  37190. t['\u2F34'] = '\u5E7F';
  37191. t['\u2F35'] = '\u5EF4';
  37192. t['\u2F36'] = '\u5EFE';
  37193. t['\u2F37'] = '\u5F0B';
  37194. t['\u2F38'] = '\u5F13';
  37195. t['\u2F39'] = '\u5F50';
  37196. t['\u2F3A'] = '\u5F61';
  37197. t['\u2F3B'] = '\u5F73';
  37198. t['\u2F3C'] = '\u5FC3';
  37199. t['\u2F3D'] = '\u6208';
  37200. t['\u2F3E'] = '\u6236';
  37201. t['\u2F3F'] = '\u624B';
  37202. t['\u2F40'] = '\u652F';
  37203. t['\u2F41'] = '\u6534';
  37204. t['\u2F42'] = '\u6587';
  37205. t['\u2F43'] = '\u6597';
  37206. t['\u2F44'] = '\u65A4';
  37207. t['\u2F45'] = '\u65B9';
  37208. t['\u2F46'] = '\u65E0';
  37209. t['\u2F47'] = '\u65E5';
  37210. t['\u2F48'] = '\u66F0';
  37211. t['\u2F49'] = '\u6708';
  37212. t['\u2F4A'] = '\u6728';
  37213. t['\u2F4B'] = '\u6B20';
  37214. t['\u2F4C'] = '\u6B62';
  37215. t['\u2F4D'] = '\u6B79';
  37216. t['\u2F4E'] = '\u6BB3';
  37217. t['\u2F4F'] = '\u6BCB';
  37218. t['\u2F50'] = '\u6BD4';
  37219. t['\u2F51'] = '\u6BDB';
  37220. t['\u2F52'] = '\u6C0F';
  37221. t['\u2F53'] = '\u6C14';
  37222. t['\u2F54'] = '\u6C34';
  37223. t['\u2F55'] = '\u706B';
  37224. t['\u2F56'] = '\u722A';
  37225. t['\u2F57'] = '\u7236';
  37226. t['\u2F58'] = '\u723B';
  37227. t['\u2F59'] = '\u723F';
  37228. t['\u2F5A'] = '\u7247';
  37229. t['\u2F5B'] = '\u7259';
  37230. t['\u2F5C'] = '\u725B';
  37231. t['\u2F5D'] = '\u72AC';
  37232. t['\u2F5E'] = '\u7384';
  37233. t['\u2F5F'] = '\u7389';
  37234. t['\u2F60'] = '\u74DC';
  37235. t['\u2F61'] = '\u74E6';
  37236. t['\u2F62'] = '\u7518';
  37237. t['\u2F63'] = '\u751F';
  37238. t['\u2F64'] = '\u7528';
  37239. t['\u2F65'] = '\u7530';
  37240. t['\u2F66'] = '\u758B';
  37241. t['\u2F67'] = '\u7592';
  37242. t['\u2F68'] = '\u7676';
  37243. t['\u2F69'] = '\u767D';
  37244. t['\u2F6A'] = '\u76AE';
  37245. t['\u2F6B'] = '\u76BF';
  37246. t['\u2F6C'] = '\u76EE';
  37247. t['\u2F6D'] = '\u77DB';
  37248. t['\u2F6E'] = '\u77E2';
  37249. t['\u2F6F'] = '\u77F3';
  37250. t['\u2F70'] = '\u793A';
  37251. t['\u2F71'] = '\u79B8';
  37252. t['\u2F72'] = '\u79BE';
  37253. t['\u2F73'] = '\u7A74';
  37254. t['\u2F74'] = '\u7ACB';
  37255. t['\u2F75'] = '\u7AF9';
  37256. t['\u2F76'] = '\u7C73';
  37257. t['\u2F77'] = '\u7CF8';
  37258. t['\u2F78'] = '\u7F36';
  37259. t['\u2F79'] = '\u7F51';
  37260. t['\u2F7A'] = '\u7F8A';
  37261. t['\u2F7B'] = '\u7FBD';
  37262. t['\u2F7C'] = '\u8001';
  37263. t['\u2F7D'] = '\u800C';
  37264. t['\u2F7E'] = '\u8012';
  37265. t['\u2F7F'] = '\u8033';
  37266. t['\u2F80'] = '\u807F';
  37267. t['\u2F81'] = '\u8089';
  37268. t['\u2F82'] = '\u81E3';
  37269. t['\u2F83'] = '\u81EA';
  37270. t['\u2F84'] = '\u81F3';
  37271. t['\u2F85'] = '\u81FC';
  37272. t['\u2F86'] = '\u820C';
  37273. t['\u2F87'] = '\u821B';
  37274. t['\u2F88'] = '\u821F';
  37275. t['\u2F89'] = '\u826E';
  37276. t['\u2F8A'] = '\u8272';
  37277. t['\u2F8B'] = '\u8278';
  37278. t['\u2F8C'] = '\u864D';
  37279. t['\u2F8D'] = '\u866B';
  37280. t['\u2F8E'] = '\u8840';
  37281. t['\u2F8F'] = '\u884C';
  37282. t['\u2F90'] = '\u8863';
  37283. t['\u2F91'] = '\u897E';
  37284. t['\u2F92'] = '\u898B';
  37285. t['\u2F93'] = '\u89D2';
  37286. t['\u2F94'] = '\u8A00';
  37287. t['\u2F95'] = '\u8C37';
  37288. t['\u2F96'] = '\u8C46';
  37289. t['\u2F97'] = '\u8C55';
  37290. t['\u2F98'] = '\u8C78';
  37291. t['\u2F99'] = '\u8C9D';
  37292. t['\u2F9A'] = '\u8D64';
  37293. t['\u2F9B'] = '\u8D70';
  37294. t['\u2F9C'] = '\u8DB3';
  37295. t['\u2F9D'] = '\u8EAB';
  37296. t['\u2F9E'] = '\u8ECA';
  37297. t['\u2F9F'] = '\u8F9B';
  37298. t['\u2FA0'] = '\u8FB0';
  37299. t['\u2FA1'] = '\u8FB5';
  37300. t['\u2FA2'] = '\u9091';
  37301. t['\u2FA3'] = '\u9149';
  37302. t['\u2FA4'] = '\u91C6';
  37303. t['\u2FA5'] = '\u91CC';
  37304. t['\u2FA6'] = '\u91D1';
  37305. t['\u2FA7'] = '\u9577';
  37306. t['\u2FA8'] = '\u9580';
  37307. t['\u2FA9'] = '\u961C';
  37308. t['\u2FAA'] = '\u96B6';
  37309. t['\u2FAB'] = '\u96B9';
  37310. t['\u2FAC'] = '\u96E8';
  37311. t['\u2FAD'] = '\u9751';
  37312. t['\u2FAE'] = '\u975E';
  37313. t['\u2FAF'] = '\u9762';
  37314. t['\u2FB0'] = '\u9769';
  37315. t['\u2FB1'] = '\u97CB';
  37316. t['\u2FB2'] = '\u97ED';
  37317. t['\u2FB3'] = '\u97F3';
  37318. t['\u2FB4'] = '\u9801';
  37319. t['\u2FB5'] = '\u98A8';
  37320. t['\u2FB6'] = '\u98DB';
  37321. t['\u2FB7'] = '\u98DF';
  37322. t['\u2FB8'] = '\u9996';
  37323. t['\u2FB9'] = '\u9999';
  37324. t['\u2FBA'] = '\u99AC';
  37325. t['\u2FBB'] = '\u9AA8';
  37326. t['\u2FBC'] = '\u9AD8';
  37327. t['\u2FBD'] = '\u9ADF';
  37328. t['\u2FBE'] = '\u9B25';
  37329. t['\u2FBF'] = '\u9B2F';
  37330. t['\u2FC0'] = '\u9B32';
  37331. t['\u2FC1'] = '\u9B3C';
  37332. t['\u2FC2'] = '\u9B5A';
  37333. t['\u2FC3'] = '\u9CE5';
  37334. t['\u2FC4'] = '\u9E75';
  37335. t['\u2FC5'] = '\u9E7F';
  37336. t['\u2FC6'] = '\u9EA5';
  37337. t['\u2FC7'] = '\u9EBB';
  37338. t['\u2FC8'] = '\u9EC3';
  37339. t['\u2FC9'] = '\u9ECD';
  37340. t['\u2FCA'] = '\u9ED1';
  37341. t['\u2FCB'] = '\u9EF9';
  37342. t['\u2FCC'] = '\u9EFD';
  37343. t['\u2FCD'] = '\u9F0E';
  37344. t['\u2FCE'] = '\u9F13';
  37345. t['\u2FCF'] = '\u9F20';
  37346. t['\u2FD0'] = '\u9F3B';
  37347. t['\u2FD1'] = '\u9F4A';
  37348. t['\u2FD2'] = '\u9F52';
  37349. t['\u2FD3'] = '\u9F8D';
  37350. t['\u2FD4'] = '\u9F9C';
  37351. t['\u2FD5'] = '\u9FA0';
  37352. t['\u3036'] = '\u3012';
  37353. t['\u3038'] = '\u5341';
  37354. t['\u3039'] = '\u5344';
  37355. t['\u303A'] = '\u5345';
  37356. t['\u309B'] = '\u0020\u3099';
  37357. t['\u309C'] = '\u0020\u309A';
  37358. t['\u3131'] = '\u1100';
  37359. t['\u3132'] = '\u1101';
  37360. t['\u3133'] = '\u11AA';
  37361. t['\u3134'] = '\u1102';
  37362. t['\u3135'] = '\u11AC';
  37363. t['\u3136'] = '\u11AD';
  37364. t['\u3137'] = '\u1103';
  37365. t['\u3138'] = '\u1104';
  37366. t['\u3139'] = '\u1105';
  37367. t['\u313A'] = '\u11B0';
  37368. t['\u313B'] = '\u11B1';
  37369. t['\u313C'] = '\u11B2';
  37370. t['\u313D'] = '\u11B3';
  37371. t['\u313E'] = '\u11B4';
  37372. t['\u313F'] = '\u11B5';
  37373. t['\u3140'] = '\u111A';
  37374. t['\u3141'] = '\u1106';
  37375. t['\u3142'] = '\u1107';
  37376. t['\u3143'] = '\u1108';
  37377. t['\u3144'] = '\u1121';
  37378. t['\u3145'] = '\u1109';
  37379. t['\u3146'] = '\u110A';
  37380. t['\u3147'] = '\u110B';
  37381. t['\u3148'] = '\u110C';
  37382. t['\u3149'] = '\u110D';
  37383. t['\u314A'] = '\u110E';
  37384. t['\u314B'] = '\u110F';
  37385. t['\u314C'] = '\u1110';
  37386. t['\u314D'] = '\u1111';
  37387. t['\u314E'] = '\u1112';
  37388. t['\u314F'] = '\u1161';
  37389. t['\u3150'] = '\u1162';
  37390. t['\u3151'] = '\u1163';
  37391. t['\u3152'] = '\u1164';
  37392. t['\u3153'] = '\u1165';
  37393. t['\u3154'] = '\u1166';
  37394. t['\u3155'] = '\u1167';
  37395. t['\u3156'] = '\u1168';
  37396. t['\u3157'] = '\u1169';
  37397. t['\u3158'] = '\u116A';
  37398. t['\u3159'] = '\u116B';
  37399. t['\u315A'] = '\u116C';
  37400. t['\u315B'] = '\u116D';
  37401. t['\u315C'] = '\u116E';
  37402. t['\u315D'] = '\u116F';
  37403. t['\u315E'] = '\u1170';
  37404. t['\u315F'] = '\u1171';
  37405. t['\u3160'] = '\u1172';
  37406. t['\u3161'] = '\u1173';
  37407. t['\u3162'] = '\u1174';
  37408. t['\u3163'] = '\u1175';
  37409. t['\u3164'] = '\u1160';
  37410. t['\u3165'] = '\u1114';
  37411. t['\u3166'] = '\u1115';
  37412. t['\u3167'] = '\u11C7';
  37413. t['\u3168'] = '\u11C8';
  37414. t['\u3169'] = '\u11CC';
  37415. t['\u316A'] = '\u11CE';
  37416. t['\u316B'] = '\u11D3';
  37417. t['\u316C'] = '\u11D7';
  37418. t['\u316D'] = '\u11D9';
  37419. t['\u316E'] = '\u111C';
  37420. t['\u316F'] = '\u11DD';
  37421. t['\u3170'] = '\u11DF';
  37422. t['\u3171'] = '\u111D';
  37423. t['\u3172'] = '\u111E';
  37424. t['\u3173'] = '\u1120';
  37425. t['\u3174'] = '\u1122';
  37426. t['\u3175'] = '\u1123';
  37427. t['\u3176'] = '\u1127';
  37428. t['\u3177'] = '\u1129';
  37429. t['\u3178'] = '\u112B';
  37430. t['\u3179'] = '\u112C';
  37431. t['\u317A'] = '\u112D';
  37432. t['\u317B'] = '\u112E';
  37433. t['\u317C'] = '\u112F';
  37434. t['\u317D'] = '\u1132';
  37435. t['\u317E'] = '\u1136';
  37436. t['\u317F'] = '\u1140';
  37437. t['\u3180'] = '\u1147';
  37438. t['\u3181'] = '\u114C';
  37439. t['\u3182'] = '\u11F1';
  37440. t['\u3183'] = '\u11F2';
  37441. t['\u3184'] = '\u1157';
  37442. t['\u3185'] = '\u1158';
  37443. t['\u3186'] = '\u1159';
  37444. t['\u3187'] = '\u1184';
  37445. t['\u3188'] = '\u1185';
  37446. t['\u3189'] = '\u1188';
  37447. t['\u318A'] = '\u1191';
  37448. t['\u318B'] = '\u1192';
  37449. t['\u318C'] = '\u1194';
  37450. t['\u318D'] = '\u119E';
  37451. t['\u318E'] = '\u11A1';
  37452. t['\u3200'] = '\u0028\u1100\u0029';
  37453. t['\u3201'] = '\u0028\u1102\u0029';
  37454. t['\u3202'] = '\u0028\u1103\u0029';
  37455. t['\u3203'] = '\u0028\u1105\u0029';
  37456. t['\u3204'] = '\u0028\u1106\u0029';
  37457. t['\u3205'] = '\u0028\u1107\u0029';
  37458. t['\u3206'] = '\u0028\u1109\u0029';
  37459. t['\u3207'] = '\u0028\u110B\u0029';
  37460. t['\u3208'] = '\u0028\u110C\u0029';
  37461. t['\u3209'] = '\u0028\u110E\u0029';
  37462. t['\u320A'] = '\u0028\u110F\u0029';
  37463. t['\u320B'] = '\u0028\u1110\u0029';
  37464. t['\u320C'] = '\u0028\u1111\u0029';
  37465. t['\u320D'] = '\u0028\u1112\u0029';
  37466. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  37467. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  37468. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  37469. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  37470. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  37471. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  37472. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  37473. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  37474. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  37475. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  37476. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  37477. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  37478. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  37479. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  37480. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  37481. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  37482. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  37483. t['\u3220'] = '\u0028\u4E00\u0029';
  37484. t['\u3221'] = '\u0028\u4E8C\u0029';
  37485. t['\u3222'] = '\u0028\u4E09\u0029';
  37486. t['\u3223'] = '\u0028\u56DB\u0029';
  37487. t['\u3224'] = '\u0028\u4E94\u0029';
  37488. t['\u3225'] = '\u0028\u516D\u0029';
  37489. t['\u3226'] = '\u0028\u4E03\u0029';
  37490. t['\u3227'] = '\u0028\u516B\u0029';
  37491. t['\u3228'] = '\u0028\u4E5D\u0029';
  37492. t['\u3229'] = '\u0028\u5341\u0029';
  37493. t['\u322A'] = '\u0028\u6708\u0029';
  37494. t['\u322B'] = '\u0028\u706B\u0029';
  37495. t['\u322C'] = '\u0028\u6C34\u0029';
  37496. t['\u322D'] = '\u0028\u6728\u0029';
  37497. t['\u322E'] = '\u0028\u91D1\u0029';
  37498. t['\u322F'] = '\u0028\u571F\u0029';
  37499. t['\u3230'] = '\u0028\u65E5\u0029';
  37500. t['\u3231'] = '\u0028\u682A\u0029';
  37501. t['\u3232'] = '\u0028\u6709\u0029';
  37502. t['\u3233'] = '\u0028\u793E\u0029';
  37503. t['\u3234'] = '\u0028\u540D\u0029';
  37504. t['\u3235'] = '\u0028\u7279\u0029';
  37505. t['\u3236'] = '\u0028\u8CA1\u0029';
  37506. t['\u3237'] = '\u0028\u795D\u0029';
  37507. t['\u3238'] = '\u0028\u52B4\u0029';
  37508. t['\u3239'] = '\u0028\u4EE3\u0029';
  37509. t['\u323A'] = '\u0028\u547C\u0029';
  37510. t['\u323B'] = '\u0028\u5B66\u0029';
  37511. t['\u323C'] = '\u0028\u76E3\u0029';
  37512. t['\u323D'] = '\u0028\u4F01\u0029';
  37513. t['\u323E'] = '\u0028\u8CC7\u0029';
  37514. t['\u323F'] = '\u0028\u5354\u0029';
  37515. t['\u3240'] = '\u0028\u796D\u0029';
  37516. t['\u3241'] = '\u0028\u4F11\u0029';
  37517. t['\u3242'] = '\u0028\u81EA\u0029';
  37518. t['\u3243'] = '\u0028\u81F3\u0029';
  37519. t['\u32C0'] = '\u0031\u6708';
  37520. t['\u32C1'] = '\u0032\u6708';
  37521. t['\u32C2'] = '\u0033\u6708';
  37522. t['\u32C3'] = '\u0034\u6708';
  37523. t['\u32C4'] = '\u0035\u6708';
  37524. t['\u32C5'] = '\u0036\u6708';
  37525. t['\u32C6'] = '\u0037\u6708';
  37526. t['\u32C7'] = '\u0038\u6708';
  37527. t['\u32C8'] = '\u0039\u6708';
  37528. t['\u32C9'] = '\u0031\u0030\u6708';
  37529. t['\u32CA'] = '\u0031\u0031\u6708';
  37530. t['\u32CB'] = '\u0031\u0032\u6708';
  37531. t['\u3358'] = '\u0030\u70B9';
  37532. t['\u3359'] = '\u0031\u70B9';
  37533. t['\u335A'] = '\u0032\u70B9';
  37534. t['\u335B'] = '\u0033\u70B9';
  37535. t['\u335C'] = '\u0034\u70B9';
  37536. t['\u335D'] = '\u0035\u70B9';
  37537. t['\u335E'] = '\u0036\u70B9';
  37538. t['\u335F'] = '\u0037\u70B9';
  37539. t['\u3360'] = '\u0038\u70B9';
  37540. t['\u3361'] = '\u0039\u70B9';
  37541. t['\u3362'] = '\u0031\u0030\u70B9';
  37542. t['\u3363'] = '\u0031\u0031\u70B9';
  37543. t['\u3364'] = '\u0031\u0032\u70B9';
  37544. t['\u3365'] = '\u0031\u0033\u70B9';
  37545. t['\u3366'] = '\u0031\u0034\u70B9';
  37546. t['\u3367'] = '\u0031\u0035\u70B9';
  37547. t['\u3368'] = '\u0031\u0036\u70B9';
  37548. t['\u3369'] = '\u0031\u0037\u70B9';
  37549. t['\u336A'] = '\u0031\u0038\u70B9';
  37550. t['\u336B'] = '\u0031\u0039\u70B9';
  37551. t['\u336C'] = '\u0032\u0030\u70B9';
  37552. t['\u336D'] = '\u0032\u0031\u70B9';
  37553. t['\u336E'] = '\u0032\u0032\u70B9';
  37554. t['\u336F'] = '\u0032\u0033\u70B9';
  37555. t['\u3370'] = '\u0032\u0034\u70B9';
  37556. t['\u33E0'] = '\u0031\u65E5';
  37557. t['\u33E1'] = '\u0032\u65E5';
  37558. t['\u33E2'] = '\u0033\u65E5';
  37559. t['\u33E3'] = '\u0034\u65E5';
  37560. t['\u33E4'] = '\u0035\u65E5';
  37561. t['\u33E5'] = '\u0036\u65E5';
  37562. t['\u33E6'] = '\u0037\u65E5';
  37563. t['\u33E7'] = '\u0038\u65E5';
  37564. t['\u33E8'] = '\u0039\u65E5';
  37565. t['\u33E9'] = '\u0031\u0030\u65E5';
  37566. t['\u33EA'] = '\u0031\u0031\u65E5';
  37567. t['\u33EB'] = '\u0031\u0032\u65E5';
  37568. t['\u33EC'] = '\u0031\u0033\u65E5';
  37569. t['\u33ED'] = '\u0031\u0034\u65E5';
  37570. t['\u33EE'] = '\u0031\u0035\u65E5';
  37571. t['\u33EF'] = '\u0031\u0036\u65E5';
  37572. t['\u33F0'] = '\u0031\u0037\u65E5';
  37573. t['\u33F1'] = '\u0031\u0038\u65E5';
  37574. t['\u33F2'] = '\u0031\u0039\u65E5';
  37575. t['\u33F3'] = '\u0032\u0030\u65E5';
  37576. t['\u33F4'] = '\u0032\u0031\u65E5';
  37577. t['\u33F5'] = '\u0032\u0032\u65E5';
  37578. t['\u33F6'] = '\u0032\u0033\u65E5';
  37579. t['\u33F7'] = '\u0032\u0034\u65E5';
  37580. t['\u33F8'] = '\u0032\u0035\u65E5';
  37581. t['\u33F9'] = '\u0032\u0036\u65E5';
  37582. t['\u33FA'] = '\u0032\u0037\u65E5';
  37583. t['\u33FB'] = '\u0032\u0038\u65E5';
  37584. t['\u33FC'] = '\u0032\u0039\u65E5';
  37585. t['\u33FD'] = '\u0033\u0030\u65E5';
  37586. t['\u33FE'] = '\u0033\u0031\u65E5';
  37587. t['\uFB00'] = '\u0066\u0066';
  37588. t['\uFB01'] = '\u0066\u0069';
  37589. t['\uFB02'] = '\u0066\u006C';
  37590. t['\uFB03'] = '\u0066\u0066\u0069';
  37591. t['\uFB04'] = '\u0066\u0066\u006C';
  37592. t['\uFB05'] = '\u017F\u0074';
  37593. t['\uFB06'] = '\u0073\u0074';
  37594. t['\uFB13'] = '\u0574\u0576';
  37595. t['\uFB14'] = '\u0574\u0565';
  37596. t['\uFB15'] = '\u0574\u056B';
  37597. t['\uFB16'] = '\u057E\u0576';
  37598. t['\uFB17'] = '\u0574\u056D';
  37599. t['\uFB4F'] = '\u05D0\u05DC';
  37600. t['\uFB50'] = '\u0671';
  37601. t['\uFB51'] = '\u0671';
  37602. t['\uFB52'] = '\u067B';
  37603. t['\uFB53'] = '\u067B';
  37604. t['\uFB54'] = '\u067B';
  37605. t['\uFB55'] = '\u067B';
  37606. t['\uFB56'] = '\u067E';
  37607. t['\uFB57'] = '\u067E';
  37608. t['\uFB58'] = '\u067E';
  37609. t['\uFB59'] = '\u067E';
  37610. t['\uFB5A'] = '\u0680';
  37611. t['\uFB5B'] = '\u0680';
  37612. t['\uFB5C'] = '\u0680';
  37613. t['\uFB5D'] = '\u0680';
  37614. t['\uFB5E'] = '\u067A';
  37615. t['\uFB5F'] = '\u067A';
  37616. t['\uFB60'] = '\u067A';
  37617. t['\uFB61'] = '\u067A';
  37618. t['\uFB62'] = '\u067F';
  37619. t['\uFB63'] = '\u067F';
  37620. t['\uFB64'] = '\u067F';
  37621. t['\uFB65'] = '\u067F';
  37622. t['\uFB66'] = '\u0679';
  37623. t['\uFB67'] = '\u0679';
  37624. t['\uFB68'] = '\u0679';
  37625. t['\uFB69'] = '\u0679';
  37626. t['\uFB6A'] = '\u06A4';
  37627. t['\uFB6B'] = '\u06A4';
  37628. t['\uFB6C'] = '\u06A4';
  37629. t['\uFB6D'] = '\u06A4';
  37630. t['\uFB6E'] = '\u06A6';
  37631. t['\uFB6F'] = '\u06A6';
  37632. t['\uFB70'] = '\u06A6';
  37633. t['\uFB71'] = '\u06A6';
  37634. t['\uFB72'] = '\u0684';
  37635. t['\uFB73'] = '\u0684';
  37636. t['\uFB74'] = '\u0684';
  37637. t['\uFB75'] = '\u0684';
  37638. t['\uFB76'] = '\u0683';
  37639. t['\uFB77'] = '\u0683';
  37640. t['\uFB78'] = '\u0683';
  37641. t['\uFB79'] = '\u0683';
  37642. t['\uFB7A'] = '\u0686';
  37643. t['\uFB7B'] = '\u0686';
  37644. t['\uFB7C'] = '\u0686';
  37645. t['\uFB7D'] = '\u0686';
  37646. t['\uFB7E'] = '\u0687';
  37647. t['\uFB7F'] = '\u0687';
  37648. t['\uFB80'] = '\u0687';
  37649. t['\uFB81'] = '\u0687';
  37650. t['\uFB82'] = '\u068D';
  37651. t['\uFB83'] = '\u068D';
  37652. t['\uFB84'] = '\u068C';
  37653. t['\uFB85'] = '\u068C';
  37654. t['\uFB86'] = '\u068E';
  37655. t['\uFB87'] = '\u068E';
  37656. t['\uFB88'] = '\u0688';
  37657. t['\uFB89'] = '\u0688';
  37658. t['\uFB8A'] = '\u0698';
  37659. t['\uFB8B'] = '\u0698';
  37660. t['\uFB8C'] = '\u0691';
  37661. t['\uFB8D'] = '\u0691';
  37662. t['\uFB8E'] = '\u06A9';
  37663. t['\uFB8F'] = '\u06A9';
  37664. t['\uFB90'] = '\u06A9';
  37665. t['\uFB91'] = '\u06A9';
  37666. t['\uFB92'] = '\u06AF';
  37667. t['\uFB93'] = '\u06AF';
  37668. t['\uFB94'] = '\u06AF';
  37669. t['\uFB95'] = '\u06AF';
  37670. t['\uFB96'] = '\u06B3';
  37671. t['\uFB97'] = '\u06B3';
  37672. t['\uFB98'] = '\u06B3';
  37673. t['\uFB99'] = '\u06B3';
  37674. t['\uFB9A'] = '\u06B1';
  37675. t['\uFB9B'] = '\u06B1';
  37676. t['\uFB9C'] = '\u06B1';
  37677. t['\uFB9D'] = '\u06B1';
  37678. t['\uFB9E'] = '\u06BA';
  37679. t['\uFB9F'] = '\u06BA';
  37680. t['\uFBA0'] = '\u06BB';
  37681. t['\uFBA1'] = '\u06BB';
  37682. t['\uFBA2'] = '\u06BB';
  37683. t['\uFBA3'] = '\u06BB';
  37684. t['\uFBA4'] = '\u06C0';
  37685. t['\uFBA5'] = '\u06C0';
  37686. t['\uFBA6'] = '\u06C1';
  37687. t['\uFBA7'] = '\u06C1';
  37688. t['\uFBA8'] = '\u06C1';
  37689. t['\uFBA9'] = '\u06C1';
  37690. t['\uFBAA'] = '\u06BE';
  37691. t['\uFBAB'] = '\u06BE';
  37692. t['\uFBAC'] = '\u06BE';
  37693. t['\uFBAD'] = '\u06BE';
  37694. t['\uFBAE'] = '\u06D2';
  37695. t['\uFBAF'] = '\u06D2';
  37696. t['\uFBB0'] = '\u06D3';
  37697. t['\uFBB1'] = '\u06D3';
  37698. t['\uFBD3'] = '\u06AD';
  37699. t['\uFBD4'] = '\u06AD';
  37700. t['\uFBD5'] = '\u06AD';
  37701. t['\uFBD6'] = '\u06AD';
  37702. t['\uFBD7'] = '\u06C7';
  37703. t['\uFBD8'] = '\u06C7';
  37704. t['\uFBD9'] = '\u06C6';
  37705. t['\uFBDA'] = '\u06C6';
  37706. t['\uFBDB'] = '\u06C8';
  37707. t['\uFBDC'] = '\u06C8';
  37708. t['\uFBDD'] = '\u0677';
  37709. t['\uFBDE'] = '\u06CB';
  37710. t['\uFBDF'] = '\u06CB';
  37711. t['\uFBE0'] = '\u06C5';
  37712. t['\uFBE1'] = '\u06C5';
  37713. t['\uFBE2'] = '\u06C9';
  37714. t['\uFBE3'] = '\u06C9';
  37715. t['\uFBE4'] = '\u06D0';
  37716. t['\uFBE5'] = '\u06D0';
  37717. t['\uFBE6'] = '\u06D0';
  37718. t['\uFBE7'] = '\u06D0';
  37719. t['\uFBE8'] = '\u0649';
  37720. t['\uFBE9'] = '\u0649';
  37721. t['\uFBEA'] = '\u0626\u0627';
  37722. t['\uFBEB'] = '\u0626\u0627';
  37723. t['\uFBEC'] = '\u0626\u06D5';
  37724. t['\uFBED'] = '\u0626\u06D5';
  37725. t['\uFBEE'] = '\u0626\u0648';
  37726. t['\uFBEF'] = '\u0626\u0648';
  37727. t['\uFBF0'] = '\u0626\u06C7';
  37728. t['\uFBF1'] = '\u0626\u06C7';
  37729. t['\uFBF2'] = '\u0626\u06C6';
  37730. t['\uFBF3'] = '\u0626\u06C6';
  37731. t['\uFBF4'] = '\u0626\u06C8';
  37732. t['\uFBF5'] = '\u0626\u06C8';
  37733. t['\uFBF6'] = '\u0626\u06D0';
  37734. t['\uFBF7'] = '\u0626\u06D0';
  37735. t['\uFBF8'] = '\u0626\u06D0';
  37736. t['\uFBF9'] = '\u0626\u0649';
  37737. t['\uFBFA'] = '\u0626\u0649';
  37738. t['\uFBFB'] = '\u0626\u0649';
  37739. t['\uFBFC'] = '\u06CC';
  37740. t['\uFBFD'] = '\u06CC';
  37741. t['\uFBFE'] = '\u06CC';
  37742. t['\uFBFF'] = '\u06CC';
  37743. t['\uFC00'] = '\u0626\u062C';
  37744. t['\uFC01'] = '\u0626\u062D';
  37745. t['\uFC02'] = '\u0626\u0645';
  37746. t['\uFC03'] = '\u0626\u0649';
  37747. t['\uFC04'] = '\u0626\u064A';
  37748. t['\uFC05'] = '\u0628\u062C';
  37749. t['\uFC06'] = '\u0628\u062D';
  37750. t['\uFC07'] = '\u0628\u062E';
  37751. t['\uFC08'] = '\u0628\u0645';
  37752. t['\uFC09'] = '\u0628\u0649';
  37753. t['\uFC0A'] = '\u0628\u064A';
  37754. t['\uFC0B'] = '\u062A\u062C';
  37755. t['\uFC0C'] = '\u062A\u062D';
  37756. t['\uFC0D'] = '\u062A\u062E';
  37757. t['\uFC0E'] = '\u062A\u0645';
  37758. t['\uFC0F'] = '\u062A\u0649';
  37759. t['\uFC10'] = '\u062A\u064A';
  37760. t['\uFC11'] = '\u062B\u062C';
  37761. t['\uFC12'] = '\u062B\u0645';
  37762. t['\uFC13'] = '\u062B\u0649';
  37763. t['\uFC14'] = '\u062B\u064A';
  37764. t['\uFC15'] = '\u062C\u062D';
  37765. t['\uFC16'] = '\u062C\u0645';
  37766. t['\uFC17'] = '\u062D\u062C';
  37767. t['\uFC18'] = '\u062D\u0645';
  37768. t['\uFC19'] = '\u062E\u062C';
  37769. t['\uFC1A'] = '\u062E\u062D';
  37770. t['\uFC1B'] = '\u062E\u0645';
  37771. t['\uFC1C'] = '\u0633\u062C';
  37772. t['\uFC1D'] = '\u0633\u062D';
  37773. t['\uFC1E'] = '\u0633\u062E';
  37774. t['\uFC1F'] = '\u0633\u0645';
  37775. t['\uFC20'] = '\u0635\u062D';
  37776. t['\uFC21'] = '\u0635\u0645';
  37777. t['\uFC22'] = '\u0636\u062C';
  37778. t['\uFC23'] = '\u0636\u062D';
  37779. t['\uFC24'] = '\u0636\u062E';
  37780. t['\uFC25'] = '\u0636\u0645';
  37781. t['\uFC26'] = '\u0637\u062D';
  37782. t['\uFC27'] = '\u0637\u0645';
  37783. t['\uFC28'] = '\u0638\u0645';
  37784. t['\uFC29'] = '\u0639\u062C';
  37785. t['\uFC2A'] = '\u0639\u0645';
  37786. t['\uFC2B'] = '\u063A\u062C';
  37787. t['\uFC2C'] = '\u063A\u0645';
  37788. t['\uFC2D'] = '\u0641\u062C';
  37789. t['\uFC2E'] = '\u0641\u062D';
  37790. t['\uFC2F'] = '\u0641\u062E';
  37791. t['\uFC30'] = '\u0641\u0645';
  37792. t['\uFC31'] = '\u0641\u0649';
  37793. t['\uFC32'] = '\u0641\u064A';
  37794. t['\uFC33'] = '\u0642\u062D';
  37795. t['\uFC34'] = '\u0642\u0645';
  37796. t['\uFC35'] = '\u0642\u0649';
  37797. t['\uFC36'] = '\u0642\u064A';
  37798. t['\uFC37'] = '\u0643\u0627';
  37799. t['\uFC38'] = '\u0643\u062C';
  37800. t['\uFC39'] = '\u0643\u062D';
  37801. t['\uFC3A'] = '\u0643\u062E';
  37802. t['\uFC3B'] = '\u0643\u0644';
  37803. t['\uFC3C'] = '\u0643\u0645';
  37804. t['\uFC3D'] = '\u0643\u0649';
  37805. t['\uFC3E'] = '\u0643\u064A';
  37806. t['\uFC3F'] = '\u0644\u062C';
  37807. t['\uFC40'] = '\u0644\u062D';
  37808. t['\uFC41'] = '\u0644\u062E';
  37809. t['\uFC42'] = '\u0644\u0645';
  37810. t['\uFC43'] = '\u0644\u0649';
  37811. t['\uFC44'] = '\u0644\u064A';
  37812. t['\uFC45'] = '\u0645\u062C';
  37813. t['\uFC46'] = '\u0645\u062D';
  37814. t['\uFC47'] = '\u0645\u062E';
  37815. t['\uFC48'] = '\u0645\u0645';
  37816. t['\uFC49'] = '\u0645\u0649';
  37817. t['\uFC4A'] = '\u0645\u064A';
  37818. t['\uFC4B'] = '\u0646\u062C';
  37819. t['\uFC4C'] = '\u0646\u062D';
  37820. t['\uFC4D'] = '\u0646\u062E';
  37821. t['\uFC4E'] = '\u0646\u0645';
  37822. t['\uFC4F'] = '\u0646\u0649';
  37823. t['\uFC50'] = '\u0646\u064A';
  37824. t['\uFC51'] = '\u0647\u062C';
  37825. t['\uFC52'] = '\u0647\u0645';
  37826. t['\uFC53'] = '\u0647\u0649';
  37827. t['\uFC54'] = '\u0647\u064A';
  37828. t['\uFC55'] = '\u064A\u062C';
  37829. t['\uFC56'] = '\u064A\u062D';
  37830. t['\uFC57'] = '\u064A\u062E';
  37831. t['\uFC58'] = '\u064A\u0645';
  37832. t['\uFC59'] = '\u064A\u0649';
  37833. t['\uFC5A'] = '\u064A\u064A';
  37834. t['\uFC5B'] = '\u0630\u0670';
  37835. t['\uFC5C'] = '\u0631\u0670';
  37836. t['\uFC5D'] = '\u0649\u0670';
  37837. t['\uFC5E'] = '\u0020\u064C\u0651';
  37838. t['\uFC5F'] = '\u0020\u064D\u0651';
  37839. t['\uFC60'] = '\u0020\u064E\u0651';
  37840. t['\uFC61'] = '\u0020\u064F\u0651';
  37841. t['\uFC62'] = '\u0020\u0650\u0651';
  37842. t['\uFC63'] = '\u0020\u0651\u0670';
  37843. t['\uFC64'] = '\u0626\u0631';
  37844. t['\uFC65'] = '\u0626\u0632';
  37845. t['\uFC66'] = '\u0626\u0645';
  37846. t['\uFC67'] = '\u0626\u0646';
  37847. t['\uFC68'] = '\u0626\u0649';
  37848. t['\uFC69'] = '\u0626\u064A';
  37849. t['\uFC6A'] = '\u0628\u0631';
  37850. t['\uFC6B'] = '\u0628\u0632';
  37851. t['\uFC6C'] = '\u0628\u0645';
  37852. t['\uFC6D'] = '\u0628\u0646';
  37853. t['\uFC6E'] = '\u0628\u0649';
  37854. t['\uFC6F'] = '\u0628\u064A';
  37855. t['\uFC70'] = '\u062A\u0631';
  37856. t['\uFC71'] = '\u062A\u0632';
  37857. t['\uFC72'] = '\u062A\u0645';
  37858. t['\uFC73'] = '\u062A\u0646';
  37859. t['\uFC74'] = '\u062A\u0649';
  37860. t['\uFC75'] = '\u062A\u064A';
  37861. t['\uFC76'] = '\u062B\u0631';
  37862. t['\uFC77'] = '\u062B\u0632';
  37863. t['\uFC78'] = '\u062B\u0645';
  37864. t['\uFC79'] = '\u062B\u0646';
  37865. t['\uFC7A'] = '\u062B\u0649';
  37866. t['\uFC7B'] = '\u062B\u064A';
  37867. t['\uFC7C'] = '\u0641\u0649';
  37868. t['\uFC7D'] = '\u0641\u064A';
  37869. t['\uFC7E'] = '\u0642\u0649';
  37870. t['\uFC7F'] = '\u0642\u064A';
  37871. t['\uFC80'] = '\u0643\u0627';
  37872. t['\uFC81'] = '\u0643\u0644';
  37873. t['\uFC82'] = '\u0643\u0645';
  37874. t['\uFC83'] = '\u0643\u0649';
  37875. t['\uFC84'] = '\u0643\u064A';
  37876. t['\uFC85'] = '\u0644\u0645';
  37877. t['\uFC86'] = '\u0644\u0649';
  37878. t['\uFC87'] = '\u0644\u064A';
  37879. t['\uFC88'] = '\u0645\u0627';
  37880. t['\uFC89'] = '\u0645\u0645';
  37881. t['\uFC8A'] = '\u0646\u0631';
  37882. t['\uFC8B'] = '\u0646\u0632';
  37883. t['\uFC8C'] = '\u0646\u0645';
  37884. t['\uFC8D'] = '\u0646\u0646';
  37885. t['\uFC8E'] = '\u0646\u0649';
  37886. t['\uFC8F'] = '\u0646\u064A';
  37887. t['\uFC90'] = '\u0649\u0670';
  37888. t['\uFC91'] = '\u064A\u0631';
  37889. t['\uFC92'] = '\u064A\u0632';
  37890. t['\uFC93'] = '\u064A\u0645';
  37891. t['\uFC94'] = '\u064A\u0646';
  37892. t['\uFC95'] = '\u064A\u0649';
  37893. t['\uFC96'] = '\u064A\u064A';
  37894. t['\uFC97'] = '\u0626\u062C';
  37895. t['\uFC98'] = '\u0626\u062D';
  37896. t['\uFC99'] = '\u0626\u062E';
  37897. t['\uFC9A'] = '\u0626\u0645';
  37898. t['\uFC9B'] = '\u0626\u0647';
  37899. t['\uFC9C'] = '\u0628\u062C';
  37900. t['\uFC9D'] = '\u0628\u062D';
  37901. t['\uFC9E'] = '\u0628\u062E';
  37902. t['\uFC9F'] = '\u0628\u0645';
  37903. t['\uFCA0'] = '\u0628\u0647';
  37904. t['\uFCA1'] = '\u062A\u062C';
  37905. t['\uFCA2'] = '\u062A\u062D';
  37906. t['\uFCA3'] = '\u062A\u062E';
  37907. t['\uFCA4'] = '\u062A\u0645';
  37908. t['\uFCA5'] = '\u062A\u0647';
  37909. t['\uFCA6'] = '\u062B\u0645';
  37910. t['\uFCA7'] = '\u062C\u062D';
  37911. t['\uFCA8'] = '\u062C\u0645';
  37912. t['\uFCA9'] = '\u062D\u062C';
  37913. t['\uFCAA'] = '\u062D\u0645';
  37914. t['\uFCAB'] = '\u062E\u062C';
  37915. t['\uFCAC'] = '\u062E\u0645';
  37916. t['\uFCAD'] = '\u0633\u062C';
  37917. t['\uFCAE'] = '\u0633\u062D';
  37918. t['\uFCAF'] = '\u0633\u062E';
  37919. t['\uFCB0'] = '\u0633\u0645';
  37920. t['\uFCB1'] = '\u0635\u062D';
  37921. t['\uFCB2'] = '\u0635\u062E';
  37922. t['\uFCB3'] = '\u0635\u0645';
  37923. t['\uFCB4'] = '\u0636\u062C';
  37924. t['\uFCB5'] = '\u0636\u062D';
  37925. t['\uFCB6'] = '\u0636\u062E';
  37926. t['\uFCB7'] = '\u0636\u0645';
  37927. t['\uFCB8'] = '\u0637\u062D';
  37928. t['\uFCB9'] = '\u0638\u0645';
  37929. t['\uFCBA'] = '\u0639\u062C';
  37930. t['\uFCBB'] = '\u0639\u0645';
  37931. t['\uFCBC'] = '\u063A\u062C';
  37932. t['\uFCBD'] = '\u063A\u0645';
  37933. t['\uFCBE'] = '\u0641\u062C';
  37934. t['\uFCBF'] = '\u0641\u062D';
  37935. t['\uFCC0'] = '\u0641\u062E';
  37936. t['\uFCC1'] = '\u0641\u0645';
  37937. t['\uFCC2'] = '\u0642\u062D';
  37938. t['\uFCC3'] = '\u0642\u0645';
  37939. t['\uFCC4'] = '\u0643\u062C';
  37940. t['\uFCC5'] = '\u0643\u062D';
  37941. t['\uFCC6'] = '\u0643\u062E';
  37942. t['\uFCC7'] = '\u0643\u0644';
  37943. t['\uFCC8'] = '\u0643\u0645';
  37944. t['\uFCC9'] = '\u0644\u062C';
  37945. t['\uFCCA'] = '\u0644\u062D';
  37946. t['\uFCCB'] = '\u0644\u062E';
  37947. t['\uFCCC'] = '\u0644\u0645';
  37948. t['\uFCCD'] = '\u0644\u0647';
  37949. t['\uFCCE'] = '\u0645\u062C';
  37950. t['\uFCCF'] = '\u0645\u062D';
  37951. t['\uFCD0'] = '\u0645\u062E';
  37952. t['\uFCD1'] = '\u0645\u0645';
  37953. t['\uFCD2'] = '\u0646\u062C';
  37954. t['\uFCD3'] = '\u0646\u062D';
  37955. t['\uFCD4'] = '\u0646\u062E';
  37956. t['\uFCD5'] = '\u0646\u0645';
  37957. t['\uFCD6'] = '\u0646\u0647';
  37958. t['\uFCD7'] = '\u0647\u062C';
  37959. t['\uFCD8'] = '\u0647\u0645';
  37960. t['\uFCD9'] = '\u0647\u0670';
  37961. t['\uFCDA'] = '\u064A\u062C';
  37962. t['\uFCDB'] = '\u064A\u062D';
  37963. t['\uFCDC'] = '\u064A\u062E';
  37964. t['\uFCDD'] = '\u064A\u0645';
  37965. t['\uFCDE'] = '\u064A\u0647';
  37966. t['\uFCDF'] = '\u0626\u0645';
  37967. t['\uFCE0'] = '\u0626\u0647';
  37968. t['\uFCE1'] = '\u0628\u0645';
  37969. t['\uFCE2'] = '\u0628\u0647';
  37970. t['\uFCE3'] = '\u062A\u0645';
  37971. t['\uFCE4'] = '\u062A\u0647';
  37972. t['\uFCE5'] = '\u062B\u0645';
  37973. t['\uFCE6'] = '\u062B\u0647';
  37974. t['\uFCE7'] = '\u0633\u0645';
  37975. t['\uFCE8'] = '\u0633\u0647';
  37976. t['\uFCE9'] = '\u0634\u0645';
  37977. t['\uFCEA'] = '\u0634\u0647';
  37978. t['\uFCEB'] = '\u0643\u0644';
  37979. t['\uFCEC'] = '\u0643\u0645';
  37980. t['\uFCED'] = '\u0644\u0645';
  37981. t['\uFCEE'] = '\u0646\u0645';
  37982. t['\uFCEF'] = '\u0646\u0647';
  37983. t['\uFCF0'] = '\u064A\u0645';
  37984. t['\uFCF1'] = '\u064A\u0647';
  37985. t['\uFCF2'] = '\u0640\u064E\u0651';
  37986. t['\uFCF3'] = '\u0640\u064F\u0651';
  37987. t['\uFCF4'] = '\u0640\u0650\u0651';
  37988. t['\uFCF5'] = '\u0637\u0649';
  37989. t['\uFCF6'] = '\u0637\u064A';
  37990. t['\uFCF7'] = '\u0639\u0649';
  37991. t['\uFCF8'] = '\u0639\u064A';
  37992. t['\uFCF9'] = '\u063A\u0649';
  37993. t['\uFCFA'] = '\u063A\u064A';
  37994. t['\uFCFB'] = '\u0633\u0649';
  37995. t['\uFCFC'] = '\u0633\u064A';
  37996. t['\uFCFD'] = '\u0634\u0649';
  37997. t['\uFCFE'] = '\u0634\u064A';
  37998. t['\uFCFF'] = '\u062D\u0649';
  37999. t['\uFD00'] = '\u062D\u064A';
  38000. t['\uFD01'] = '\u062C\u0649';
  38001. t['\uFD02'] = '\u062C\u064A';
  38002. t['\uFD03'] = '\u062E\u0649';
  38003. t['\uFD04'] = '\u062E\u064A';
  38004. t['\uFD05'] = '\u0635\u0649';
  38005. t['\uFD06'] = '\u0635\u064A';
  38006. t['\uFD07'] = '\u0636\u0649';
  38007. t['\uFD08'] = '\u0636\u064A';
  38008. t['\uFD09'] = '\u0634\u062C';
  38009. t['\uFD0A'] = '\u0634\u062D';
  38010. t['\uFD0B'] = '\u0634\u062E';
  38011. t['\uFD0C'] = '\u0634\u0645';
  38012. t['\uFD0D'] = '\u0634\u0631';
  38013. t['\uFD0E'] = '\u0633\u0631';
  38014. t['\uFD0F'] = '\u0635\u0631';
  38015. t['\uFD10'] = '\u0636\u0631';
  38016. t['\uFD11'] = '\u0637\u0649';
  38017. t['\uFD12'] = '\u0637\u064A';
  38018. t['\uFD13'] = '\u0639\u0649';
  38019. t['\uFD14'] = '\u0639\u064A';
  38020. t['\uFD15'] = '\u063A\u0649';
  38021. t['\uFD16'] = '\u063A\u064A';
  38022. t['\uFD17'] = '\u0633\u0649';
  38023. t['\uFD18'] = '\u0633\u064A';
  38024. t['\uFD19'] = '\u0634\u0649';
  38025. t['\uFD1A'] = '\u0634\u064A';
  38026. t['\uFD1B'] = '\u062D\u0649';
  38027. t['\uFD1C'] = '\u062D\u064A';
  38028. t['\uFD1D'] = '\u062C\u0649';
  38029. t['\uFD1E'] = '\u062C\u064A';
  38030. t['\uFD1F'] = '\u062E\u0649';
  38031. t['\uFD20'] = '\u062E\u064A';
  38032. t['\uFD21'] = '\u0635\u0649';
  38033. t['\uFD22'] = '\u0635\u064A';
  38034. t['\uFD23'] = '\u0636\u0649';
  38035. t['\uFD24'] = '\u0636\u064A';
  38036. t['\uFD25'] = '\u0634\u062C';
  38037. t['\uFD26'] = '\u0634\u062D';
  38038. t['\uFD27'] = '\u0634\u062E';
  38039. t['\uFD28'] = '\u0634\u0645';
  38040. t['\uFD29'] = '\u0634\u0631';
  38041. t['\uFD2A'] = '\u0633\u0631';
  38042. t['\uFD2B'] = '\u0635\u0631';
  38043. t['\uFD2C'] = '\u0636\u0631';
  38044. t['\uFD2D'] = '\u0634\u062C';
  38045. t['\uFD2E'] = '\u0634\u062D';
  38046. t['\uFD2F'] = '\u0634\u062E';
  38047. t['\uFD30'] = '\u0634\u0645';
  38048. t['\uFD31'] = '\u0633\u0647';
  38049. t['\uFD32'] = '\u0634\u0647';
  38050. t['\uFD33'] = '\u0637\u0645';
  38051. t['\uFD34'] = '\u0633\u062C';
  38052. t['\uFD35'] = '\u0633\u062D';
  38053. t['\uFD36'] = '\u0633\u062E';
  38054. t['\uFD37'] = '\u0634\u062C';
  38055. t['\uFD38'] = '\u0634\u062D';
  38056. t['\uFD39'] = '\u0634\u062E';
  38057. t['\uFD3A'] = '\u0637\u0645';
  38058. t['\uFD3B'] = '\u0638\u0645';
  38059. t['\uFD3C'] = '\u0627\u064B';
  38060. t['\uFD3D'] = '\u0627\u064B';
  38061. t['\uFD50'] = '\u062A\u062C\u0645';
  38062. t['\uFD51'] = '\u062A\u062D\u062C';
  38063. t['\uFD52'] = '\u062A\u062D\u062C';
  38064. t['\uFD53'] = '\u062A\u062D\u0645';
  38065. t['\uFD54'] = '\u062A\u062E\u0645';
  38066. t['\uFD55'] = '\u062A\u0645\u062C';
  38067. t['\uFD56'] = '\u062A\u0645\u062D';
  38068. t['\uFD57'] = '\u062A\u0645\u062E';
  38069. t['\uFD58'] = '\u062C\u0645\u062D';
  38070. t['\uFD59'] = '\u062C\u0645\u062D';
  38071. t['\uFD5A'] = '\u062D\u0645\u064A';
  38072. t['\uFD5B'] = '\u062D\u0645\u0649';
  38073. t['\uFD5C'] = '\u0633\u062D\u062C';
  38074. t['\uFD5D'] = '\u0633\u062C\u062D';
  38075. t['\uFD5E'] = '\u0633\u062C\u0649';
  38076. t['\uFD5F'] = '\u0633\u0645\u062D';
  38077. t['\uFD60'] = '\u0633\u0645\u062D';
  38078. t['\uFD61'] = '\u0633\u0645\u062C';
  38079. t['\uFD62'] = '\u0633\u0645\u0645';
  38080. t['\uFD63'] = '\u0633\u0645\u0645';
  38081. t['\uFD64'] = '\u0635\u062D\u062D';
  38082. t['\uFD65'] = '\u0635\u062D\u062D';
  38083. t['\uFD66'] = '\u0635\u0645\u0645';
  38084. t['\uFD67'] = '\u0634\u062D\u0645';
  38085. t['\uFD68'] = '\u0634\u062D\u0645';
  38086. t['\uFD69'] = '\u0634\u062C\u064A';
  38087. t['\uFD6A'] = '\u0634\u0645\u062E';
  38088. t['\uFD6B'] = '\u0634\u0645\u062E';
  38089. t['\uFD6C'] = '\u0634\u0645\u0645';
  38090. t['\uFD6D'] = '\u0634\u0645\u0645';
  38091. t['\uFD6E'] = '\u0636\u062D\u0649';
  38092. t['\uFD6F'] = '\u0636\u062E\u0645';
  38093. t['\uFD70'] = '\u0636\u062E\u0645';
  38094. t['\uFD71'] = '\u0637\u0645\u062D';
  38095. t['\uFD72'] = '\u0637\u0645\u062D';
  38096. t['\uFD73'] = '\u0637\u0645\u0645';
  38097. t['\uFD74'] = '\u0637\u0645\u064A';
  38098. t['\uFD75'] = '\u0639\u062C\u0645';
  38099. t['\uFD76'] = '\u0639\u0645\u0645';
  38100. t['\uFD77'] = '\u0639\u0645\u0645';
  38101. t['\uFD78'] = '\u0639\u0645\u0649';
  38102. t['\uFD79'] = '\u063A\u0645\u0645';
  38103. t['\uFD7A'] = '\u063A\u0645\u064A';
  38104. t['\uFD7B'] = '\u063A\u0645\u0649';
  38105. t['\uFD7C'] = '\u0641\u062E\u0645';
  38106. t['\uFD7D'] = '\u0641\u062E\u0645';
  38107. t['\uFD7E'] = '\u0642\u0645\u062D';
  38108. t['\uFD7F'] = '\u0642\u0645\u0645';
  38109. t['\uFD80'] = '\u0644\u062D\u0645';
  38110. t['\uFD81'] = '\u0644\u062D\u064A';
  38111. t['\uFD82'] = '\u0644\u062D\u0649';
  38112. t['\uFD83'] = '\u0644\u062C\u062C';
  38113. t['\uFD84'] = '\u0644\u062C\u062C';
  38114. t['\uFD85'] = '\u0644\u062E\u0645';
  38115. t['\uFD86'] = '\u0644\u062E\u0645';
  38116. t['\uFD87'] = '\u0644\u0645\u062D';
  38117. t['\uFD88'] = '\u0644\u0645\u062D';
  38118. t['\uFD89'] = '\u0645\u062D\u062C';
  38119. t['\uFD8A'] = '\u0645\u062D\u0645';
  38120. t['\uFD8B'] = '\u0645\u062D\u064A';
  38121. t['\uFD8C'] = '\u0645\u062C\u062D';
  38122. t['\uFD8D'] = '\u0645\u062C\u0645';
  38123. t['\uFD8E'] = '\u0645\u062E\u062C';
  38124. t['\uFD8F'] = '\u0645\u062E\u0645';
  38125. t['\uFD92'] = '\u0645\u062C\u062E';
  38126. t['\uFD93'] = '\u0647\u0645\u062C';
  38127. t['\uFD94'] = '\u0647\u0645\u0645';
  38128. t['\uFD95'] = '\u0646\u062D\u0645';
  38129. t['\uFD96'] = '\u0646\u062D\u0649';
  38130. t['\uFD97'] = '\u0646\u062C\u0645';
  38131. t['\uFD98'] = '\u0646\u062C\u0645';
  38132. t['\uFD99'] = '\u0646\u062C\u0649';
  38133. t['\uFD9A'] = '\u0646\u0645\u064A';
  38134. t['\uFD9B'] = '\u0646\u0645\u0649';
  38135. t['\uFD9C'] = '\u064A\u0645\u0645';
  38136. t['\uFD9D'] = '\u064A\u0645\u0645';
  38137. t['\uFD9E'] = '\u0628\u062E\u064A';
  38138. t['\uFD9F'] = '\u062A\u062C\u064A';
  38139. t['\uFDA0'] = '\u062A\u062C\u0649';
  38140. t['\uFDA1'] = '\u062A\u062E\u064A';
  38141. t['\uFDA2'] = '\u062A\u062E\u0649';
  38142. t['\uFDA3'] = '\u062A\u0645\u064A';
  38143. t['\uFDA4'] = '\u062A\u0645\u0649';
  38144. t['\uFDA5'] = '\u062C\u0645\u064A';
  38145. t['\uFDA6'] = '\u062C\u062D\u0649';
  38146. t['\uFDA7'] = '\u062C\u0645\u0649';
  38147. t['\uFDA8'] = '\u0633\u062E\u0649';
  38148. t['\uFDA9'] = '\u0635\u062D\u064A';
  38149. t['\uFDAA'] = '\u0634\u062D\u064A';
  38150. t['\uFDAB'] = '\u0636\u062D\u064A';
  38151. t['\uFDAC'] = '\u0644\u062C\u064A';
  38152. t['\uFDAD'] = '\u0644\u0645\u064A';
  38153. t['\uFDAE'] = '\u064A\u062D\u064A';
  38154. t['\uFDAF'] = '\u064A\u062C\u064A';
  38155. t['\uFDB0'] = '\u064A\u0645\u064A';
  38156. t['\uFDB1'] = '\u0645\u0645\u064A';
  38157. t['\uFDB2'] = '\u0642\u0645\u064A';
  38158. t['\uFDB3'] = '\u0646\u062D\u064A';
  38159. t['\uFDB4'] = '\u0642\u0645\u062D';
  38160. t['\uFDB5'] = '\u0644\u062D\u0645';
  38161. t['\uFDB6'] = '\u0639\u0645\u064A';
  38162. t['\uFDB7'] = '\u0643\u0645\u064A';
  38163. t['\uFDB8'] = '\u0646\u062C\u062D';
  38164. t['\uFDB9'] = '\u0645\u062E\u064A';
  38165. t['\uFDBA'] = '\u0644\u062C\u0645';
  38166. t['\uFDBB'] = '\u0643\u0645\u0645';
  38167. t['\uFDBC'] = '\u0644\u062C\u0645';
  38168. t['\uFDBD'] = '\u0646\u062C\u062D';
  38169. t['\uFDBE'] = '\u062C\u062D\u064A';
  38170. t['\uFDBF'] = '\u062D\u062C\u064A';
  38171. t['\uFDC0'] = '\u0645\u062C\u064A';
  38172. t['\uFDC1'] = '\u0641\u0645\u064A';
  38173. t['\uFDC2'] = '\u0628\u062D\u064A';
  38174. t['\uFDC3'] = '\u0643\u0645\u0645';
  38175. t['\uFDC4'] = '\u0639\u062C\u0645';
  38176. t['\uFDC5'] = '\u0635\u0645\u0645';
  38177. t['\uFDC6'] = '\u0633\u062E\u064A';
  38178. t['\uFDC7'] = '\u0646\u062C\u064A';
  38179. t['\uFE49'] = '\u203E';
  38180. t['\uFE4A'] = '\u203E';
  38181. t['\uFE4B'] = '\u203E';
  38182. t['\uFE4C'] = '\u203E';
  38183. t['\uFE4D'] = '\u005F';
  38184. t['\uFE4E'] = '\u005F';
  38185. t['\uFE4F'] = '\u005F';
  38186. t['\uFE80'] = '\u0621';
  38187. t['\uFE81'] = '\u0622';
  38188. t['\uFE82'] = '\u0622';
  38189. t['\uFE83'] = '\u0623';
  38190. t['\uFE84'] = '\u0623';
  38191. t['\uFE85'] = '\u0624';
  38192. t['\uFE86'] = '\u0624';
  38193. t['\uFE87'] = '\u0625';
  38194. t['\uFE88'] = '\u0625';
  38195. t['\uFE89'] = '\u0626';
  38196. t['\uFE8A'] = '\u0626';
  38197. t['\uFE8B'] = '\u0626';
  38198. t['\uFE8C'] = '\u0626';
  38199. t['\uFE8D'] = '\u0627';
  38200. t['\uFE8E'] = '\u0627';
  38201. t['\uFE8F'] = '\u0628';
  38202. t['\uFE90'] = '\u0628';
  38203. t['\uFE91'] = '\u0628';
  38204. t['\uFE92'] = '\u0628';
  38205. t['\uFE93'] = '\u0629';
  38206. t['\uFE94'] = '\u0629';
  38207. t['\uFE95'] = '\u062A';
  38208. t['\uFE96'] = '\u062A';
  38209. t['\uFE97'] = '\u062A';
  38210. t['\uFE98'] = '\u062A';
  38211. t['\uFE99'] = '\u062B';
  38212. t['\uFE9A'] = '\u062B';
  38213. t['\uFE9B'] = '\u062B';
  38214. t['\uFE9C'] = '\u062B';
  38215. t['\uFE9D'] = '\u062C';
  38216. t['\uFE9E'] = '\u062C';
  38217. t['\uFE9F'] = '\u062C';
  38218. t['\uFEA0'] = '\u062C';
  38219. t['\uFEA1'] = '\u062D';
  38220. t['\uFEA2'] = '\u062D';
  38221. t['\uFEA3'] = '\u062D';
  38222. t['\uFEA4'] = '\u062D';
  38223. t['\uFEA5'] = '\u062E';
  38224. t['\uFEA6'] = '\u062E';
  38225. t['\uFEA7'] = '\u062E';
  38226. t['\uFEA8'] = '\u062E';
  38227. t['\uFEA9'] = '\u062F';
  38228. t['\uFEAA'] = '\u062F';
  38229. t['\uFEAB'] = '\u0630';
  38230. t['\uFEAC'] = '\u0630';
  38231. t['\uFEAD'] = '\u0631';
  38232. t['\uFEAE'] = '\u0631';
  38233. t['\uFEAF'] = '\u0632';
  38234. t['\uFEB0'] = '\u0632';
  38235. t['\uFEB1'] = '\u0633';
  38236. t['\uFEB2'] = '\u0633';
  38237. t['\uFEB3'] = '\u0633';
  38238. t['\uFEB4'] = '\u0633';
  38239. t['\uFEB5'] = '\u0634';
  38240. t['\uFEB6'] = '\u0634';
  38241. t['\uFEB7'] = '\u0634';
  38242. t['\uFEB8'] = '\u0634';
  38243. t['\uFEB9'] = '\u0635';
  38244. t['\uFEBA'] = '\u0635';
  38245. t['\uFEBB'] = '\u0635';
  38246. t['\uFEBC'] = '\u0635';
  38247. t['\uFEBD'] = '\u0636';
  38248. t['\uFEBE'] = '\u0636';
  38249. t['\uFEBF'] = '\u0636';
  38250. t['\uFEC0'] = '\u0636';
  38251. t['\uFEC1'] = '\u0637';
  38252. t['\uFEC2'] = '\u0637';
  38253. t['\uFEC3'] = '\u0637';
  38254. t['\uFEC4'] = '\u0637';
  38255. t['\uFEC5'] = '\u0638';
  38256. t['\uFEC6'] = '\u0638';
  38257. t['\uFEC7'] = '\u0638';
  38258. t['\uFEC8'] = '\u0638';
  38259. t['\uFEC9'] = '\u0639';
  38260. t['\uFECA'] = '\u0639';
  38261. t['\uFECB'] = '\u0639';
  38262. t['\uFECC'] = '\u0639';
  38263. t['\uFECD'] = '\u063A';
  38264. t['\uFECE'] = '\u063A';
  38265. t['\uFECF'] = '\u063A';
  38266. t['\uFED0'] = '\u063A';
  38267. t['\uFED1'] = '\u0641';
  38268. t['\uFED2'] = '\u0641';
  38269. t['\uFED3'] = '\u0641';
  38270. t['\uFED4'] = '\u0641';
  38271. t['\uFED5'] = '\u0642';
  38272. t['\uFED6'] = '\u0642';
  38273. t['\uFED7'] = '\u0642';
  38274. t['\uFED8'] = '\u0642';
  38275. t['\uFED9'] = '\u0643';
  38276. t['\uFEDA'] = '\u0643';
  38277. t['\uFEDB'] = '\u0643';
  38278. t['\uFEDC'] = '\u0643';
  38279. t['\uFEDD'] = '\u0644';
  38280. t['\uFEDE'] = '\u0644';
  38281. t['\uFEDF'] = '\u0644';
  38282. t['\uFEE0'] = '\u0644';
  38283. t['\uFEE1'] = '\u0645';
  38284. t['\uFEE2'] = '\u0645';
  38285. t['\uFEE3'] = '\u0645';
  38286. t['\uFEE4'] = '\u0645';
  38287. t['\uFEE5'] = '\u0646';
  38288. t['\uFEE6'] = '\u0646';
  38289. t['\uFEE7'] = '\u0646';
  38290. t['\uFEE8'] = '\u0646';
  38291. t['\uFEE9'] = '\u0647';
  38292. t['\uFEEA'] = '\u0647';
  38293. t['\uFEEB'] = '\u0647';
  38294. t['\uFEEC'] = '\u0647';
  38295. t['\uFEED'] = '\u0648';
  38296. t['\uFEEE'] = '\u0648';
  38297. t['\uFEEF'] = '\u0649';
  38298. t['\uFEF0'] = '\u0649';
  38299. t['\uFEF1'] = '\u064A';
  38300. t['\uFEF2'] = '\u064A';
  38301. t['\uFEF3'] = '\u064A';
  38302. t['\uFEF4'] = '\u064A';
  38303. t['\uFEF5'] = '\u0644\u0622';
  38304. t['\uFEF6'] = '\u0644\u0622';
  38305. t['\uFEF7'] = '\u0644\u0623';
  38306. t['\uFEF8'] = '\u0644\u0623';
  38307. t['\uFEF9'] = '\u0644\u0625';
  38308. t['\uFEFA'] = '\u0644\u0625';
  38309. t['\uFEFB'] = '\u0644\u0627';
  38310. t['\uFEFC'] = '\u0644\u0627';
  38311. });
  38312. function reverseIfRtl(chars) {
  38313. var charsLength = chars.length;
  38314. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  38315. return chars;
  38316. }
  38317. var s = '';
  38318. for (var ii = charsLength - 1; ii >= 0; ii--) {
  38319. s += chars[ii];
  38320. }
  38321. return s;
  38322. }
  38323. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  38324. exports.reverseIfRtl = reverseIfRtl;
  38325. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  38326. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  38327. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  38328. /***/ }),
  38329. /* 22 */
  38330. /***/ (function(module, exports, __w_pdfjs_require__) {
  38331. "use strict";
  38332. var sharedUtil = __w_pdfjs_require__(0);
  38333. var corePrimitives = __w_pdfjs_require__(1);
  38334. var corePdfManager = __w_pdfjs_require__(41);
  38335. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  38336. var InvalidPDFException = sharedUtil.InvalidPDFException;
  38337. var MessageHandler = sharedUtil.MessageHandler;
  38338. var MissingPDFException = sharedUtil.MissingPDFException;
  38339. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  38340. var PasswordException = sharedUtil.PasswordException;
  38341. var UnknownErrorException = sharedUtil.UnknownErrorException;
  38342. var XRefParseException = sharedUtil.XRefParseException;
  38343. var arrayByteLength = sharedUtil.arrayByteLength;
  38344. var arraysToBytes = sharedUtil.arraysToBytes;
  38345. var assert = sharedUtil.assert;
  38346. var createPromiseCapability = sharedUtil.createPromiseCapability;
  38347. var error = sharedUtil.error;
  38348. var info = sharedUtil.info;
  38349. var warn = sharedUtil.warn;
  38350. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  38351. var isNodeJS = sharedUtil.isNodeJS;
  38352. var Ref = corePrimitives.Ref;
  38353. var LocalPdfManager = corePdfManager.LocalPdfManager;
  38354. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  38355. var globalScope = sharedUtil.globalScope;
  38356. var WorkerTask = function WorkerTaskClosure() {
  38357. function WorkerTask(name) {
  38358. this.name = name;
  38359. this.terminated = false;
  38360. this._capability = createPromiseCapability();
  38361. }
  38362. WorkerTask.prototype = {
  38363. get finished() {
  38364. return this._capability.promise;
  38365. },
  38366. finish: function () {
  38367. this._capability.resolve();
  38368. },
  38369. terminate: function () {
  38370. this.terminated = true;
  38371. },
  38372. ensureNotTerminated: function () {
  38373. if (this.terminated) {
  38374. throw new Error('Worker task was terminated');
  38375. }
  38376. }
  38377. };
  38378. return WorkerTask;
  38379. }();
  38380. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  38381. function PDFWorkerStream(params, msgHandler) {
  38382. this._queuedChunks = [];
  38383. var initialData = params.initialData;
  38384. if (initialData && initialData.length > 0) {
  38385. this._queuedChunks.push(initialData);
  38386. }
  38387. this._msgHandler = msgHandler;
  38388. this._isRangeSupported = !params.disableRange;
  38389. this._isStreamingSupported = !params.disableStream;
  38390. this._contentLength = params.length;
  38391. this._fullRequestReader = null;
  38392. this._rangeReaders = [];
  38393. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  38394. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  38395. }
  38396. PDFWorkerStream.prototype = {
  38397. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  38398. if (args.begin === undefined) {
  38399. if (this._fullRequestReader) {
  38400. this._fullRequestReader._enqueue(args.chunk);
  38401. } else {
  38402. this._queuedChunks.push(args.chunk);
  38403. }
  38404. } else {
  38405. var found = this._rangeReaders.some(function (rangeReader) {
  38406. if (rangeReader._begin !== args.begin) {
  38407. return false;
  38408. }
  38409. rangeReader._enqueue(args.chunk);
  38410. return true;
  38411. });
  38412. assert(found);
  38413. }
  38414. },
  38415. _onProgress: function PDFWorkerStream_onProgress(evt) {
  38416. if (this._rangeReaders.length > 0) {
  38417. var firstReader = this._rangeReaders[0];
  38418. if (firstReader.onProgress) {
  38419. firstReader.onProgress({ loaded: evt.loaded });
  38420. }
  38421. }
  38422. },
  38423. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  38424. var i = this._rangeReaders.indexOf(reader);
  38425. if (i >= 0) {
  38426. this._rangeReaders.splice(i, 1);
  38427. }
  38428. },
  38429. getFullReader: function PDFWorkerStream_getFullReader() {
  38430. assert(!this._fullRequestReader);
  38431. var queuedChunks = this._queuedChunks;
  38432. this._queuedChunks = null;
  38433. return new PDFWorkerStreamReader(this, queuedChunks);
  38434. },
  38435. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  38436. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  38437. this._msgHandler.send('RequestDataRange', {
  38438. begin: begin,
  38439. end: end
  38440. });
  38441. this._rangeReaders.push(reader);
  38442. return reader;
  38443. },
  38444. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  38445. if (this._fullRequestReader) {
  38446. this._fullRequestReader.cancel(reason);
  38447. }
  38448. var readers = this._rangeReaders.slice(0);
  38449. readers.forEach(function (rangeReader) {
  38450. rangeReader.cancel(reason);
  38451. });
  38452. }
  38453. };
  38454. function PDFWorkerStreamReader(stream, queuedChunks) {
  38455. this._stream = stream;
  38456. this._done = false;
  38457. this._queuedChunks = queuedChunks || [];
  38458. this._requests = [];
  38459. this._headersReady = Promise.resolve();
  38460. stream._fullRequestReader = this;
  38461. this.onProgress = null;
  38462. }
  38463. PDFWorkerStreamReader.prototype = {
  38464. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  38465. if (this._done) {
  38466. return;
  38467. }
  38468. if (this._requests.length > 0) {
  38469. var requestCapability = this._requests.shift();
  38470. requestCapability.resolve({
  38471. value: chunk,
  38472. done: false
  38473. });
  38474. return;
  38475. }
  38476. this._queuedChunks.push(chunk);
  38477. },
  38478. get headersReady() {
  38479. return this._headersReady;
  38480. },
  38481. get isRangeSupported() {
  38482. return this._stream._isRangeSupported;
  38483. },
  38484. get isStreamingSupported() {
  38485. return this._stream._isStreamingSupported;
  38486. },
  38487. get contentLength() {
  38488. return this._stream._contentLength;
  38489. },
  38490. read: function PDFWorkerStreamReader_read() {
  38491. if (this._queuedChunks.length > 0) {
  38492. var chunk = this._queuedChunks.shift();
  38493. return Promise.resolve({
  38494. value: chunk,
  38495. done: false
  38496. });
  38497. }
  38498. if (this._done) {
  38499. return Promise.resolve({
  38500. value: undefined,
  38501. done: true
  38502. });
  38503. }
  38504. var requestCapability = createPromiseCapability();
  38505. this._requests.push(requestCapability);
  38506. return requestCapability.promise;
  38507. },
  38508. cancel: function PDFWorkerStreamReader_cancel(reason) {
  38509. this._done = true;
  38510. this._requests.forEach(function (requestCapability) {
  38511. requestCapability.resolve({
  38512. value: undefined,
  38513. done: true
  38514. });
  38515. });
  38516. this._requests = [];
  38517. }
  38518. };
  38519. function PDFWorkerStreamRangeReader(stream, begin, end) {
  38520. this._stream = stream;
  38521. this._begin = begin;
  38522. this._end = end;
  38523. this._queuedChunk = null;
  38524. this._requests = [];
  38525. this._done = false;
  38526. this.onProgress = null;
  38527. }
  38528. PDFWorkerStreamRangeReader.prototype = {
  38529. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  38530. if (this._done) {
  38531. return;
  38532. }
  38533. if (this._requests.length === 0) {
  38534. this._queuedChunk = chunk;
  38535. } else {
  38536. var requestsCapability = this._requests.shift();
  38537. requestsCapability.resolve({
  38538. value: chunk,
  38539. done: false
  38540. });
  38541. this._requests.forEach(function (requestCapability) {
  38542. requestCapability.resolve({
  38543. value: undefined,
  38544. done: true
  38545. });
  38546. });
  38547. this._requests = [];
  38548. }
  38549. this._done = true;
  38550. this._stream._removeRangeReader(this);
  38551. },
  38552. get isStreamingSupported() {
  38553. return false;
  38554. },
  38555. read: function PDFWorkerStreamRangeReader_read() {
  38556. if (this._queuedChunk) {
  38557. return Promise.resolve({
  38558. value: this._queuedChunk,
  38559. done: false
  38560. });
  38561. }
  38562. if (this._done) {
  38563. return Promise.resolve({
  38564. value: undefined,
  38565. done: true
  38566. });
  38567. }
  38568. var requestCapability = createPromiseCapability();
  38569. this._requests.push(requestCapability);
  38570. return requestCapability.promise;
  38571. },
  38572. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  38573. this._done = true;
  38574. this._requests.forEach(function (requestCapability) {
  38575. requestCapability.resolve({
  38576. value: undefined,
  38577. done: true
  38578. });
  38579. });
  38580. this._requests = [];
  38581. this._stream._removeRangeReader(this);
  38582. }
  38583. };
  38584. return PDFWorkerStream;
  38585. }();
  38586. var PDFNetworkStream;
  38587. function setPDFNetworkStreamClass(cls) {
  38588. PDFNetworkStream = cls;
  38589. }
  38590. var WorkerMessageHandler = {
  38591. setup: function wphSetup(handler, port) {
  38592. var testMessageProcessed = false;
  38593. handler.on('test', function wphSetupTest(data) {
  38594. if (testMessageProcessed) {
  38595. return;
  38596. }
  38597. testMessageProcessed = true;
  38598. if (!(data instanceof Uint8Array)) {
  38599. handler.send('test', 'main', false);
  38600. return;
  38601. }
  38602. var supportTransfers = data[0] === 255;
  38603. handler.postMessageTransfers = supportTransfers;
  38604. var xhr = new XMLHttpRequest();
  38605. var responseExists = 'response' in xhr;
  38606. try {
  38607. xhr.responseType;
  38608. } catch (e) {
  38609. responseExists = false;
  38610. }
  38611. if (!responseExists) {
  38612. handler.send('test', false);
  38613. return;
  38614. }
  38615. handler.send('test', {
  38616. supportTypedArray: true,
  38617. supportTransfers: supportTransfers
  38618. });
  38619. });
  38620. handler.on('configure', function wphConfigure(data) {
  38621. setVerbosityLevel(data.verbosity);
  38622. });
  38623. handler.on('GetDocRequest', function wphSetupDoc(data) {
  38624. return WorkerMessageHandler.createDocumentHandler(data, port);
  38625. });
  38626. },
  38627. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  38628. var pdfManager;
  38629. var terminated = false;
  38630. var cancelXHRs = null;
  38631. var WorkerTasks = [];
  38632. var docId = docParams.docId;
  38633. var docBaseUrl = docParams.docBaseUrl;
  38634. var workerHandlerName = docParams.docId + '_worker';
  38635. var handler = new MessageHandler(workerHandlerName, docId, port);
  38636. handler.postMessageTransfers = docParams.postMessageTransfers;
  38637. function ensureNotTerminated() {
  38638. if (terminated) {
  38639. throw new Error('Worker was terminated');
  38640. }
  38641. }
  38642. function startWorkerTask(task) {
  38643. WorkerTasks.push(task);
  38644. }
  38645. function finishWorkerTask(task) {
  38646. task.finish();
  38647. var i = WorkerTasks.indexOf(task);
  38648. WorkerTasks.splice(i, 1);
  38649. }
  38650. function loadDocument(recoveryMode) {
  38651. var loadDocumentCapability = createPromiseCapability();
  38652. var parseSuccess = function parseSuccess() {
  38653. var numPagesPromise = pdfManager.ensureDoc('numPages');
  38654. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  38655. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  38656. Promise.all([
  38657. numPagesPromise,
  38658. fingerprintPromise,
  38659. encryptedPromise
  38660. ]).then(function onDocReady(results) {
  38661. var doc = {
  38662. numPages: results[0],
  38663. fingerprint: results[1],
  38664. encrypted: !!results[2]
  38665. };
  38666. loadDocumentCapability.resolve(doc);
  38667. }, parseFailure);
  38668. };
  38669. var parseFailure = function parseFailure(e) {
  38670. loadDocumentCapability.reject(e);
  38671. };
  38672. pdfManager.ensureDoc('checkHeader', []).then(function () {
  38673. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  38674. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  38675. }, parseFailure);
  38676. }, parseFailure);
  38677. return loadDocumentCapability.promise;
  38678. }
  38679. function getPdfManager(data, evaluatorOptions) {
  38680. var pdfManagerCapability = createPromiseCapability();
  38681. var pdfManager;
  38682. var source = data.source;
  38683. if (source.data) {
  38684. try {
  38685. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  38686. pdfManagerCapability.resolve(pdfManager);
  38687. } catch (ex) {
  38688. pdfManagerCapability.reject(ex);
  38689. }
  38690. return pdfManagerCapability.promise;
  38691. }
  38692. var pdfStream;
  38693. try {
  38694. if (source.chunkedViewerLoading) {
  38695. pdfStream = new PDFWorkerStream(source, handler);
  38696. } else {
  38697. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  38698. pdfStream = new PDFNetworkStream(data);
  38699. }
  38700. } catch (ex) {
  38701. pdfManagerCapability.reject(ex);
  38702. return pdfManagerCapability.promise;
  38703. }
  38704. var fullRequest = pdfStream.getFullReader();
  38705. fullRequest.headersReady.then(function () {
  38706. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  38707. fullRequest.onProgress = function (evt) {
  38708. handler.send('DocProgress', {
  38709. loaded: evt.loaded,
  38710. total: evt.total
  38711. });
  38712. };
  38713. }
  38714. if (!fullRequest.isRangeSupported) {
  38715. return;
  38716. }
  38717. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  38718. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  38719. msgHandler: handler,
  38720. url: source.url,
  38721. password: source.password,
  38722. length: fullRequest.contentLength,
  38723. disableAutoFetch: disableAutoFetch,
  38724. rangeChunkSize: source.rangeChunkSize
  38725. }, evaluatorOptions, docBaseUrl);
  38726. pdfManagerCapability.resolve(pdfManager);
  38727. cancelXHRs = null;
  38728. }).catch(function (reason) {
  38729. pdfManagerCapability.reject(reason);
  38730. cancelXHRs = null;
  38731. });
  38732. var cachedChunks = [], loaded = 0;
  38733. var flushChunks = function () {
  38734. var pdfFile = arraysToBytes(cachedChunks);
  38735. if (source.length && pdfFile.length !== source.length) {
  38736. warn('reported HTTP length is different from actual');
  38737. }
  38738. try {
  38739. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  38740. pdfManagerCapability.resolve(pdfManager);
  38741. } catch (ex) {
  38742. pdfManagerCapability.reject(ex);
  38743. }
  38744. cachedChunks = [];
  38745. };
  38746. var readPromise = new Promise(function (resolve, reject) {
  38747. var readChunk = function (chunk) {
  38748. try {
  38749. ensureNotTerminated();
  38750. if (chunk.done) {
  38751. if (!pdfManager) {
  38752. flushChunks();
  38753. }
  38754. cancelXHRs = null;
  38755. return;
  38756. }
  38757. var data = chunk.value;
  38758. loaded += arrayByteLength(data);
  38759. if (!fullRequest.isStreamingSupported) {
  38760. handler.send('DocProgress', {
  38761. loaded: loaded,
  38762. total: Math.max(loaded, fullRequest.contentLength || 0)
  38763. });
  38764. }
  38765. if (pdfManager) {
  38766. pdfManager.sendProgressiveData(data);
  38767. } else {
  38768. cachedChunks.push(data);
  38769. }
  38770. fullRequest.read().then(readChunk, reject);
  38771. } catch (e) {
  38772. reject(e);
  38773. }
  38774. };
  38775. fullRequest.read().then(readChunk, reject);
  38776. });
  38777. readPromise.catch(function (e) {
  38778. pdfManagerCapability.reject(e);
  38779. cancelXHRs = null;
  38780. });
  38781. cancelXHRs = function () {
  38782. pdfStream.cancelAllRequests('abort');
  38783. };
  38784. return pdfManagerCapability.promise;
  38785. }
  38786. function setupDoc(data) {
  38787. function onSuccess(doc) {
  38788. ensureNotTerminated();
  38789. handler.send('GetDoc', { pdfInfo: doc });
  38790. }
  38791. function onFailure(e) {
  38792. if (e instanceof PasswordException) {
  38793. var task = new WorkerTask('PasswordException: response ' + e.code);
  38794. startWorkerTask(task);
  38795. handler.sendWithPromise('PasswordRequest', e).then(function (data) {
  38796. finishWorkerTask(task);
  38797. pdfManager.updatePassword(data.password);
  38798. pdfManagerReady();
  38799. }).catch(function (ex) {
  38800. finishWorkerTask(task);
  38801. handler.send('PasswordException', ex);
  38802. }.bind(null, e));
  38803. } else if (e instanceof InvalidPDFException) {
  38804. handler.send('InvalidPDF', e);
  38805. } else if (e instanceof MissingPDFException) {
  38806. handler.send('MissingPDF', e);
  38807. } else if (e instanceof UnexpectedResponseException) {
  38808. handler.send('UnexpectedResponse', e);
  38809. } else {
  38810. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  38811. }
  38812. }
  38813. function pdfManagerReady() {
  38814. ensureNotTerminated();
  38815. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  38816. ensureNotTerminated();
  38817. if (!(ex instanceof XRefParseException)) {
  38818. onFailure(ex);
  38819. return;
  38820. }
  38821. pdfManager.requestLoadedStream();
  38822. pdfManager.onLoadedStream().then(function () {
  38823. ensureNotTerminated();
  38824. loadDocument(true).then(onSuccess, onFailure);
  38825. });
  38826. }, onFailure);
  38827. }
  38828. ensureNotTerminated();
  38829. var evaluatorOptions = {
  38830. forceDataSchema: data.disableCreateObjectURL,
  38831. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  38832. disableFontFace: data.disableFontFace,
  38833. disableNativeImageDecoder: data.disableNativeImageDecoder
  38834. };
  38835. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  38836. if (terminated) {
  38837. newPdfManager.terminate();
  38838. throw new Error('Worker was terminated');
  38839. }
  38840. pdfManager = newPdfManager;
  38841. handler.send('PDFManagerReady', null);
  38842. pdfManager.onLoadedStream().then(function (stream) {
  38843. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  38844. });
  38845. }).then(pdfManagerReady, onFailure);
  38846. }
  38847. handler.on('GetPage', function wphSetupGetPage(data) {
  38848. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38849. var rotatePromise = pdfManager.ensure(page, 'rotate');
  38850. var refPromise = pdfManager.ensure(page, 'ref');
  38851. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  38852. var viewPromise = pdfManager.ensure(page, 'view');
  38853. return Promise.all([
  38854. rotatePromise,
  38855. refPromise,
  38856. userUnitPromise,
  38857. viewPromise
  38858. ]).then(function (results) {
  38859. return {
  38860. rotate: results[0],
  38861. ref: results[1],
  38862. userUnit: results[2],
  38863. view: results[3]
  38864. };
  38865. });
  38866. });
  38867. });
  38868. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  38869. var ref = new Ref(data.ref.num, data.ref.gen);
  38870. var catalog = pdfManager.pdfDocument.catalog;
  38871. return catalog.getPageIndex(ref);
  38872. });
  38873. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  38874. return pdfManager.ensureCatalog('destinations');
  38875. });
  38876. handler.on('GetDestination', function wphSetupGetDestination(data) {
  38877. return pdfManager.ensureCatalog('getDestination', [data.id]);
  38878. });
  38879. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  38880. return pdfManager.ensureCatalog('pageLabels');
  38881. });
  38882. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  38883. return pdfManager.ensureCatalog('attachments');
  38884. });
  38885. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  38886. return pdfManager.ensureCatalog('javaScript');
  38887. });
  38888. handler.on('GetOutline', function wphSetupGetOutline(data) {
  38889. return pdfManager.ensureCatalog('documentOutline');
  38890. });
  38891. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  38892. return Promise.all([
  38893. pdfManager.ensureDoc('documentInfo'),
  38894. pdfManager.ensureCatalog('metadata')
  38895. ]);
  38896. });
  38897. handler.on('GetData', function wphSetupGetData(data) {
  38898. pdfManager.requestLoadedStream();
  38899. return pdfManager.onLoadedStream().then(function (stream) {
  38900. return stream.bytes;
  38901. });
  38902. });
  38903. handler.on('GetStats', function wphSetupGetStats(data) {
  38904. return pdfManager.pdfDocument.xref.stats;
  38905. });
  38906. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  38907. return pdfManager.getPage(data.pageIndex).then(function (page) {
  38908. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  38909. });
  38910. });
  38911. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  38912. var pageIndex = data.pageIndex;
  38913. pdfManager.getPage(pageIndex).then(function (page) {
  38914. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  38915. startWorkerTask(task);
  38916. var pageNum = pageIndex + 1;
  38917. var start = Date.now();
  38918. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  38919. finishWorkerTask(task);
  38920. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  38921. }, function (e) {
  38922. finishWorkerTask(task);
  38923. if (task.terminated) {
  38924. return;
  38925. }
  38926. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  38927. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  38928. var wrappedException;
  38929. if (typeof e === 'string') {
  38930. wrappedException = {
  38931. message: e,
  38932. stack: minimumStackMessage
  38933. };
  38934. } else if (typeof e === 'object') {
  38935. wrappedException = {
  38936. message: e.message || e.toString(),
  38937. stack: e.stack || minimumStackMessage
  38938. };
  38939. } else {
  38940. wrappedException = {
  38941. message: 'Unknown exception type: ' + typeof e,
  38942. stack: minimumStackMessage
  38943. };
  38944. }
  38945. handler.send('PageError', {
  38946. pageNum: pageNum,
  38947. error: wrappedException,
  38948. intent: data.intent
  38949. });
  38950. });
  38951. });
  38952. }, this);
  38953. handler.on('GetTextContent', function wphExtractText(data) {
  38954. var pageIndex = data.pageIndex;
  38955. var normalizeWhitespace = data.normalizeWhitespace;
  38956. var combineTextItems = data.combineTextItems;
  38957. return pdfManager.getPage(pageIndex).then(function (page) {
  38958. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  38959. startWorkerTask(task);
  38960. var pageNum = pageIndex + 1;
  38961. var start = Date.now();
  38962. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  38963. finishWorkerTask(task);
  38964. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  38965. return textContent;
  38966. }, function (reason) {
  38967. finishWorkerTask(task);
  38968. if (task.terminated) {
  38969. return;
  38970. }
  38971. throw reason;
  38972. });
  38973. });
  38974. });
  38975. handler.on('Cleanup', function wphCleanup(data) {
  38976. return pdfManager.cleanup();
  38977. });
  38978. handler.on('Terminate', function wphTerminate(data) {
  38979. terminated = true;
  38980. if (pdfManager) {
  38981. pdfManager.terminate();
  38982. pdfManager = null;
  38983. }
  38984. if (cancelXHRs) {
  38985. cancelXHRs();
  38986. }
  38987. var waitOn = [];
  38988. WorkerTasks.forEach(function (task) {
  38989. waitOn.push(task.finished);
  38990. task.terminate();
  38991. });
  38992. return Promise.all(waitOn).then(function () {
  38993. handler.destroy();
  38994. handler = null;
  38995. });
  38996. });
  38997. handler.on('Ready', function wphReady(data) {
  38998. setupDoc(docParams);
  38999. docParams = null;
  39000. });
  39001. return workerHandlerName;
  39002. }
  39003. };
  39004. function initializeWorker() {
  39005. if (!('console' in globalScope)) {
  39006. var consoleTimer = {};
  39007. var workerConsole = {
  39008. log: function log() {
  39009. var args = Array.prototype.slice.call(arguments);
  39010. globalScope.postMessage({
  39011. targetName: 'main',
  39012. action: 'console_log',
  39013. data: args
  39014. });
  39015. },
  39016. error: function error() {
  39017. var args = Array.prototype.slice.call(arguments);
  39018. globalScope.postMessage({
  39019. targetName: 'main',
  39020. action: 'console_error',
  39021. data: args
  39022. });
  39023. throw 'pdf.js execution error';
  39024. },
  39025. time: function time(name) {
  39026. consoleTimer[name] = Date.now();
  39027. },
  39028. timeEnd: function timeEnd(name) {
  39029. var time = consoleTimer[name];
  39030. if (!time) {
  39031. error('Unknown timer name ' + name);
  39032. }
  39033. this.log('Timer:', name, Date.now() - time);
  39034. }
  39035. };
  39036. globalScope.console = workerConsole;
  39037. }
  39038. var handler = new MessageHandler('worker', 'main', self);
  39039. WorkerMessageHandler.setup(handler, self);
  39040. handler.send('ready', null);
  39041. }
  39042. if (typeof window === 'undefined' && !isNodeJS()) {
  39043. initializeWorker();
  39044. }
  39045. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  39046. exports.WorkerTask = WorkerTask;
  39047. exports.WorkerMessageHandler = WorkerMessageHandler;
  39048. /***/ }),
  39049. /* 23 */
  39050. /***/ (function(module, exports, __w_pdfjs_require__) {
  39051. "use strict";
  39052. var sharedUtil = __w_pdfjs_require__(0);
  39053. var error = sharedUtil.error;
  39054. function fixMetadata(meta) {
  39055. return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  39056. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  39057. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  39058. });
  39059. var chars = '';
  39060. for (var i = 0; i < bytes.length; i += 2) {
  39061. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  39062. chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  39063. }
  39064. return '>' + chars;
  39065. });
  39066. }
  39067. function Metadata(meta) {
  39068. if (typeof meta === 'string') {
  39069. meta = fixMetadata(meta);
  39070. var parser = new DOMParser();
  39071. meta = parser.parseFromString(meta, 'application/xml');
  39072. } else if (!(meta instanceof Document)) {
  39073. error('Metadata: Invalid metadata object');
  39074. }
  39075. this.metaDocument = meta;
  39076. this.metadata = Object.create(null);
  39077. this.parse();
  39078. }
  39079. Metadata.prototype = {
  39080. parse: function Metadata_parse() {
  39081. var doc = this.metaDocument;
  39082. var rdf = doc.documentElement;
  39083. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  39084. rdf = rdf.firstChild;
  39085. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  39086. rdf = rdf.nextSibling;
  39087. }
  39088. }
  39089. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  39090. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  39091. return;
  39092. }
  39093. var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
  39094. for (i = 0, length = children.length; i < length; i++) {
  39095. desc = children[i];
  39096. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  39097. continue;
  39098. }
  39099. for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
  39100. if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
  39101. entry = desc.childNodes[ii];
  39102. name = entry.nodeName.toLowerCase();
  39103. this.metadata[name] = entry.textContent.trim();
  39104. }
  39105. }
  39106. }
  39107. },
  39108. get: function Metadata_get(name) {
  39109. return this.metadata[name] || null;
  39110. },
  39111. has: function Metadata_has(name) {
  39112. return typeof this.metadata[name] !== 'undefined';
  39113. }
  39114. };
  39115. exports.Metadata = Metadata;
  39116. /***/ }),
  39117. /* 24 */
  39118. /***/ (function(module, exports, __w_pdfjs_require__) {
  39119. "use strict";
  39120. var sharedUtil = __w_pdfjs_require__(0);
  39121. var displayDOMUtils = __w_pdfjs_require__(3);
  39122. var shadow = sharedUtil.shadow;
  39123. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  39124. var WebGLUtils = function WebGLUtilsClosure() {
  39125. function loadShader(gl, code, shaderType) {
  39126. var shader = gl.createShader(shaderType);
  39127. gl.shaderSource(shader, code);
  39128. gl.compileShader(shader);
  39129. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  39130. if (!compiled) {
  39131. var errorMsg = gl.getShaderInfoLog(shader);
  39132. throw new Error('Error during shader compilation: ' + errorMsg);
  39133. }
  39134. return shader;
  39135. }
  39136. function createVertexShader(gl, code) {
  39137. return loadShader(gl, code, gl.VERTEX_SHADER);
  39138. }
  39139. function createFragmentShader(gl, code) {
  39140. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  39141. }
  39142. function createProgram(gl, shaders) {
  39143. var program = gl.createProgram();
  39144. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  39145. gl.attachShader(program, shaders[i]);
  39146. }
  39147. gl.linkProgram(program);
  39148. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  39149. if (!linked) {
  39150. var errorMsg = gl.getProgramInfoLog(program);
  39151. throw new Error('Error during program linking: ' + errorMsg);
  39152. }
  39153. return program;
  39154. }
  39155. function createTexture(gl, image, textureId) {
  39156. gl.activeTexture(textureId);
  39157. var texture = gl.createTexture();
  39158. gl.bindTexture(gl.TEXTURE_2D, texture);
  39159. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  39160. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  39161. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  39162. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  39163. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  39164. return texture;
  39165. }
  39166. var currentGL, currentCanvas;
  39167. function generateGL() {
  39168. if (currentGL) {
  39169. return;
  39170. }
  39171. currentCanvas = document.createElement('canvas');
  39172. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  39173. }
  39174. var smaskVertexShaderCode = '\
  39175. attribute vec2 a_position; \
  39176. attribute vec2 a_texCoord; \
  39177. \
  39178. uniform vec2 u_resolution; \
  39179. \
  39180. varying vec2 v_texCoord; \
  39181. \
  39182. void main() { \
  39183. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  39184. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  39185. \
  39186. v_texCoord = a_texCoord; \
  39187. } ';
  39188. var smaskFragmentShaderCode = '\
  39189. precision mediump float; \
  39190. \
  39191. uniform vec4 u_backdrop; \
  39192. uniform int u_subtype; \
  39193. uniform sampler2D u_image; \
  39194. uniform sampler2D u_mask; \
  39195. \
  39196. varying vec2 v_texCoord; \
  39197. \
  39198. void main() { \
  39199. vec4 imageColor = texture2D(u_image, v_texCoord); \
  39200. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  39201. if (u_backdrop.a > 0.0) { \
  39202. maskColor.rgb = maskColor.rgb * maskColor.a + \
  39203. u_backdrop.rgb * (1.0 - maskColor.a); \
  39204. } \
  39205. float lum; \
  39206. if (u_subtype == 0) { \
  39207. lum = maskColor.a; \
  39208. } else { \
  39209. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  39210. maskColor.b * 0.11; \
  39211. } \
  39212. imageColor.a *= lum; \
  39213. imageColor.rgb *= imageColor.a; \
  39214. gl_FragColor = imageColor; \
  39215. } ';
  39216. var smaskCache = null;
  39217. function initSmaskGL() {
  39218. var canvas, gl;
  39219. generateGL();
  39220. canvas = currentCanvas;
  39221. currentCanvas = null;
  39222. gl = currentGL;
  39223. currentGL = null;
  39224. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  39225. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  39226. var program = createProgram(gl, [
  39227. vertexShader,
  39228. fragmentShader
  39229. ]);
  39230. gl.useProgram(program);
  39231. var cache = {};
  39232. cache.gl = gl;
  39233. cache.canvas = canvas;
  39234. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  39235. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  39236. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  39237. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  39238. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  39239. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  39240. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  39241. var texCoordBuffer = gl.createBuffer();
  39242. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  39243. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  39244. 0.0,
  39245. 0.0,
  39246. 1.0,
  39247. 0.0,
  39248. 0.0,
  39249. 1.0,
  39250. 0.0,
  39251. 1.0,
  39252. 1.0,
  39253. 0.0,
  39254. 1.0,
  39255. 1.0
  39256. ]), gl.STATIC_DRAW);
  39257. gl.enableVertexAttribArray(texCoordLocation);
  39258. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  39259. gl.uniform1i(texLayerLocation, 0);
  39260. gl.uniform1i(texMaskLocation, 1);
  39261. smaskCache = cache;
  39262. }
  39263. function composeSMask(layer, mask, properties) {
  39264. var width = layer.width, height = layer.height;
  39265. if (!smaskCache) {
  39266. initSmaskGL();
  39267. }
  39268. var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
  39269. canvas.width = width;
  39270. canvas.height = height;
  39271. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  39272. gl.uniform2f(cache.resolutionLocation, width, height);
  39273. if (properties.backdrop) {
  39274. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  39275. } else {
  39276. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  39277. }
  39278. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  39279. var texture = createTexture(gl, layer, gl.TEXTURE0);
  39280. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  39281. var buffer = gl.createBuffer();
  39282. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  39283. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  39284. 0,
  39285. 0,
  39286. width,
  39287. 0,
  39288. 0,
  39289. height,
  39290. 0,
  39291. height,
  39292. width,
  39293. 0,
  39294. width,
  39295. height
  39296. ]), gl.STATIC_DRAW);
  39297. gl.enableVertexAttribArray(cache.positionLocation);
  39298. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  39299. gl.clearColor(0, 0, 0, 0);
  39300. gl.enable(gl.BLEND);
  39301. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  39302. gl.clear(gl.COLOR_BUFFER_BIT);
  39303. gl.drawArrays(gl.TRIANGLES, 0, 6);
  39304. gl.flush();
  39305. gl.deleteTexture(texture);
  39306. gl.deleteTexture(maskTexture);
  39307. gl.deleteBuffer(buffer);
  39308. return canvas;
  39309. }
  39310. var figuresVertexShaderCode = '\
  39311. attribute vec2 a_position; \
  39312. attribute vec3 a_color; \
  39313. \
  39314. uniform vec2 u_resolution; \
  39315. uniform vec2 u_scale; \
  39316. uniform vec2 u_offset; \
  39317. \
  39318. varying vec4 v_color; \
  39319. \
  39320. void main() { \
  39321. vec2 position = (a_position + u_offset) * u_scale; \
  39322. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  39323. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  39324. \
  39325. v_color = vec4(a_color / 255.0, 1.0); \
  39326. } ';
  39327. var figuresFragmentShaderCode = '\
  39328. precision mediump float; \
  39329. \
  39330. varying vec4 v_color; \
  39331. \
  39332. void main() { \
  39333. gl_FragColor = v_color; \
  39334. } ';
  39335. var figuresCache = null;
  39336. function initFiguresGL() {
  39337. var canvas, gl;
  39338. generateGL();
  39339. canvas = currentCanvas;
  39340. currentCanvas = null;
  39341. gl = currentGL;
  39342. currentGL = null;
  39343. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  39344. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  39345. var program = createProgram(gl, [
  39346. vertexShader,
  39347. fragmentShader
  39348. ]);
  39349. gl.useProgram(program);
  39350. var cache = {};
  39351. cache.gl = gl;
  39352. cache.canvas = canvas;
  39353. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  39354. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  39355. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  39356. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  39357. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  39358. figuresCache = cache;
  39359. }
  39360. function drawFigures(width, height, backgroundColor, figures, context) {
  39361. if (!figuresCache) {
  39362. initFiguresGL();
  39363. }
  39364. var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
  39365. canvas.width = width;
  39366. canvas.height = height;
  39367. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  39368. gl.uniform2f(cache.resolutionLocation, width, height);
  39369. var count = 0;
  39370. var i, ii, rows;
  39371. for (i = 0, ii = figures.length; i < ii; i++) {
  39372. switch (figures[i].type) {
  39373. case 'lattice':
  39374. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  39375. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  39376. break;
  39377. case 'triangles':
  39378. count += figures[i].coords.length;
  39379. break;
  39380. }
  39381. }
  39382. var coords = new Float32Array(count * 2);
  39383. var colors = new Uint8Array(count * 3);
  39384. var coordsMap = context.coords, colorsMap = context.colors;
  39385. var pIndex = 0, cIndex = 0;
  39386. for (i = 0, ii = figures.length; i < ii; i++) {
  39387. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  39388. switch (figure.type) {
  39389. case 'lattice':
  39390. var cols = figure.verticesPerRow;
  39391. rows = ps.length / cols | 0;
  39392. for (var row = 1; row < rows; row++) {
  39393. var offset = row * cols + 1;
  39394. for (var col = 1; col < cols; col++, offset++) {
  39395. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  39396. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  39397. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  39398. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  39399. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  39400. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  39401. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  39402. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  39403. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  39404. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  39405. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  39406. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  39407. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  39408. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  39409. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  39410. coords[pIndex + 6] = coords[pIndex + 2];
  39411. coords[pIndex + 7] = coords[pIndex + 3];
  39412. coords[pIndex + 8] = coords[pIndex + 4];
  39413. coords[pIndex + 9] = coords[pIndex + 5];
  39414. coords[pIndex + 10] = coordsMap[ps[offset]];
  39415. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  39416. colors[cIndex + 9] = colors[cIndex + 3];
  39417. colors[cIndex + 10] = colors[cIndex + 4];
  39418. colors[cIndex + 11] = colors[cIndex + 5];
  39419. colors[cIndex + 12] = colors[cIndex + 6];
  39420. colors[cIndex + 13] = colors[cIndex + 7];
  39421. colors[cIndex + 14] = colors[cIndex + 8];
  39422. colors[cIndex + 15] = colorsMap[cs[offset]];
  39423. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  39424. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  39425. pIndex += 12;
  39426. cIndex += 18;
  39427. }
  39428. }
  39429. break;
  39430. case 'triangles':
  39431. for (var j = 0, jj = ps.length; j < jj; j++) {
  39432. coords[pIndex] = coordsMap[ps[j]];
  39433. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  39434. colors[cIndex] = colorsMap[cs[j]];
  39435. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  39436. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  39437. pIndex += 2;
  39438. cIndex += 3;
  39439. }
  39440. break;
  39441. }
  39442. }
  39443. if (backgroundColor) {
  39444. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  39445. } else {
  39446. gl.clearColor(0, 0, 0, 0);
  39447. }
  39448. gl.clear(gl.COLOR_BUFFER_BIT);
  39449. var coordsBuffer = gl.createBuffer();
  39450. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  39451. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  39452. gl.enableVertexAttribArray(cache.positionLocation);
  39453. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  39454. var colorsBuffer = gl.createBuffer();
  39455. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  39456. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  39457. gl.enableVertexAttribArray(cache.colorLocation);
  39458. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  39459. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  39460. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  39461. gl.drawArrays(gl.TRIANGLES, 0, count);
  39462. gl.flush();
  39463. gl.deleteBuffer(coordsBuffer);
  39464. gl.deleteBuffer(colorsBuffer);
  39465. return canvas;
  39466. }
  39467. function cleanup() {
  39468. if (smaskCache && smaskCache.canvas) {
  39469. smaskCache.canvas.width = 0;
  39470. smaskCache.canvas.height = 0;
  39471. }
  39472. if (figuresCache && figuresCache.canvas) {
  39473. figuresCache.canvas.width = 0;
  39474. figuresCache.canvas.height = 0;
  39475. }
  39476. smaskCache = null;
  39477. figuresCache = null;
  39478. }
  39479. return {
  39480. get isEnabled() {
  39481. if (getDefaultSetting('disableWebGL')) {
  39482. return false;
  39483. }
  39484. var enabled = false;
  39485. try {
  39486. generateGL();
  39487. enabled = !!currentGL;
  39488. } catch (e) {
  39489. }
  39490. return shadow(this, 'isEnabled', enabled);
  39491. },
  39492. composeSMask: composeSMask,
  39493. drawFigures: drawFigures,
  39494. clear: cleanup
  39495. };
  39496. }();
  39497. exports.WebGLUtils = WebGLUtils;
  39498. /***/ }),
  39499. /* 25 */
  39500. /***/ (function(module, exports, __w_pdfjs_require__) {
  39501. "use strict";
  39502. var sharedUtil = __w_pdfjs_require__(0);
  39503. var displayDOMUtils = __w_pdfjs_require__(3);
  39504. var displayAPI = __w_pdfjs_require__(10);
  39505. var displayAnnotationLayer = __w_pdfjs_require__(9);
  39506. var displayTextLayer = __w_pdfjs_require__(12);
  39507. var displayMetadata = __w_pdfjs_require__(23);
  39508. var displaySVG = __w_pdfjs_require__(11);
  39509. var globalScope = sharedUtil.globalScope;
  39510. var deprecated = sharedUtil.deprecated;
  39511. var warn = sharedUtil.warn;
  39512. var LinkTarget = displayDOMUtils.LinkTarget;
  39513. var DEFAULT_LINK_REL = displayDOMUtils.DEFAULT_LINK_REL;
  39514. var isWorker = typeof window === 'undefined';
  39515. if (!globalScope.PDFJS) {
  39516. globalScope.PDFJS = {};
  39517. }
  39518. var PDFJS = globalScope.PDFJS;
  39519. PDFJS.version = '1.7.314';
  39520. PDFJS.build = '912c952d';
  39521. PDFJS.pdfBug = false;
  39522. if (PDFJS.verbosity !== undefined) {
  39523. sharedUtil.setVerbosityLevel(PDFJS.verbosity);
  39524. }
  39525. delete PDFJS.verbosity;
  39526. Object.defineProperty(PDFJS, 'verbosity', {
  39527. get: function () {
  39528. return sharedUtil.getVerbosityLevel();
  39529. },
  39530. set: function (level) {
  39531. sharedUtil.setVerbosityLevel(level);
  39532. },
  39533. enumerable: true,
  39534. configurable: true
  39535. });
  39536. PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
  39537. PDFJS.OPS = sharedUtil.OPS;
  39538. PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  39539. PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
  39540. PDFJS.shadow = sharedUtil.shadow;
  39541. PDFJS.createBlob = sharedUtil.createBlob;
  39542. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  39543. return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
  39544. };
  39545. Object.defineProperty(PDFJS, 'isLittleEndian', {
  39546. configurable: true,
  39547. get: function PDFJS_isLittleEndian() {
  39548. var value = sharedUtil.isLittleEndian();
  39549. return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
  39550. }
  39551. });
  39552. PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
  39553. PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
  39554. PDFJS.PasswordException = sharedUtil.PasswordException;
  39555. PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
  39556. PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
  39557. PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
  39558. PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  39559. PDFJS.Util = sharedUtil.Util;
  39560. PDFJS.PageViewport = sharedUtil.PageViewport;
  39561. PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
  39562. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  39563. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  39564. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  39565. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  39566. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  39567. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  39568. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  39569. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  39570. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  39571. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  39572. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  39573. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  39574. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  39575. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  39576. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
  39577. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? DEFAULT_LINK_REL : PDFJS.externalLinkRel;
  39578. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  39579. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  39580. delete PDFJS.openExternalLinksInNewWindow;
  39581. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  39582. get: function () {
  39583. return PDFJS.externalLinkTarget === LinkTarget.BLANK;
  39584. },
  39585. set: function (value) {
  39586. if (value) {
  39587. deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  39588. }
  39589. if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
  39590. warn('PDFJS.externalLinkTarget is already initialized');
  39591. return;
  39592. }
  39593. PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
  39594. },
  39595. enumerable: true,
  39596. configurable: true
  39597. });
  39598. if (savedOpenExternalLinksInNewWindow) {
  39599. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  39600. }
  39601. PDFJS.getDocument = displayAPI.getDocument;
  39602. PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
  39603. PDFJS.PDFWorker = displayAPI.PDFWorker;
  39604. Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
  39605. configurable: true,
  39606. get: function PDFJS_hasCanvasTypedArrays() {
  39607. var value = displayDOMUtils.hasCanvasTypedArrays();
  39608. return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
  39609. }
  39610. });
  39611. PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
  39612. PDFJS.LinkTarget = LinkTarget;
  39613. PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
  39614. PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  39615. PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
  39616. PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
  39617. PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
  39618. PDFJS.Metadata = displayMetadata.Metadata;
  39619. PDFJS.SVGGraphics = displaySVG.SVGGraphics;
  39620. PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
  39621. exports.globalScope = globalScope;
  39622. exports.isWorker = isWorker;
  39623. exports.PDFJS = globalScope.PDFJS;
  39624. /***/ }),
  39625. /* 26 */
  39626. /***/ (function(module, exports) {
  39627. var g;
  39628. g = function () {
  39629. return this;
  39630. }();
  39631. try {
  39632. g = g || Function("return this")() || (1, eval)("this");
  39633. } catch (e) {
  39634. if (typeof window === "object")
  39635. g = window;
  39636. }
  39637. module.exports = g;
  39638. /***/ }),
  39639. /* 27 */
  39640. /***/ (function(module, exports, __w_pdfjs_require__) {
  39641. "use strict";
  39642. var sharedUtil = __w_pdfjs_require__(0);
  39643. var corePrimitives = __w_pdfjs_require__(1);
  39644. var coreStream = __w_pdfjs_require__(2);
  39645. var coreColorSpace = __w_pdfjs_require__(4);
  39646. var coreObj = __w_pdfjs_require__(19);
  39647. var coreEvaluator = __w_pdfjs_require__(17);
  39648. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  39649. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  39650. var AnnotationFlag = sharedUtil.AnnotationFlag;
  39651. var AnnotationType = sharedUtil.AnnotationType;
  39652. var OPS = sharedUtil.OPS;
  39653. var Util = sharedUtil.Util;
  39654. var isArray = sharedUtil.isArray;
  39655. var isInt = sharedUtil.isInt;
  39656. var stringToBytes = sharedUtil.stringToBytes;
  39657. var stringToPDFString = sharedUtil.stringToPDFString;
  39658. var warn = sharedUtil.warn;
  39659. var Dict = corePrimitives.Dict;
  39660. var isDict = corePrimitives.isDict;
  39661. var isName = corePrimitives.isName;
  39662. var isRef = corePrimitives.isRef;
  39663. var isStream = corePrimitives.isStream;
  39664. var Stream = coreStream.Stream;
  39665. var ColorSpace = coreColorSpace.ColorSpace;
  39666. var Catalog = coreObj.Catalog;
  39667. var ObjectLoader = coreObj.ObjectLoader;
  39668. var FileSpec = coreObj.FileSpec;
  39669. var OperatorList = coreEvaluator.OperatorList;
  39670. function AnnotationFactory() {
  39671. }
  39672. AnnotationFactory.prototype = {
  39673. create: function AnnotationFactory_create(xref, ref, pdfManager, idFactory) {
  39674. var dict = xref.fetchIfRef(ref);
  39675. if (!isDict(dict)) {
  39676. return;
  39677. }
  39678. var id = isRef(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
  39679. var subtype = dict.get('Subtype');
  39680. subtype = isName(subtype) ? subtype.name : null;
  39681. var parameters = {
  39682. xref: xref,
  39683. dict: dict,
  39684. ref: isRef(ref) ? ref : null,
  39685. subtype: subtype,
  39686. id: id,
  39687. pdfManager: pdfManager
  39688. };
  39689. switch (subtype) {
  39690. case 'Link':
  39691. return new LinkAnnotation(parameters);
  39692. case 'Text':
  39693. return new TextAnnotation(parameters);
  39694. case 'Widget':
  39695. var fieldType = Util.getInheritableProperty(dict, 'FT');
  39696. fieldType = isName(fieldType) ? fieldType.name : null;
  39697. switch (fieldType) {
  39698. case 'Tx':
  39699. return new TextWidgetAnnotation(parameters);
  39700. case 'Btn':
  39701. return new ButtonWidgetAnnotation(parameters);
  39702. case 'Ch':
  39703. return new ChoiceWidgetAnnotation(parameters);
  39704. }
  39705. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  39706. return new WidgetAnnotation(parameters);
  39707. case 'Popup':
  39708. return new PopupAnnotation(parameters);
  39709. case 'Highlight':
  39710. return new HighlightAnnotation(parameters);
  39711. case 'Underline':
  39712. return new UnderlineAnnotation(parameters);
  39713. case 'Squiggly':
  39714. return new SquigglyAnnotation(parameters);
  39715. case 'StrikeOut':
  39716. return new StrikeOutAnnotation(parameters);
  39717. case 'FileAttachment':
  39718. return new FileAttachmentAnnotation(parameters);
  39719. default:
  39720. if (!subtype) {
  39721. warn('Annotation is missing the required /Subtype.');
  39722. } else {
  39723. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  39724. }
  39725. return new Annotation(parameters);
  39726. }
  39727. }
  39728. };
  39729. var Annotation = function AnnotationClosure() {
  39730. function getTransformMatrix(rect, bbox, matrix) {
  39731. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  39732. var minX = bounds[0];
  39733. var minY = bounds[1];
  39734. var maxX = bounds[2];
  39735. var maxY = bounds[3];
  39736. if (minX === maxX || minY === maxY) {
  39737. return [
  39738. 1,
  39739. 0,
  39740. 0,
  39741. 1,
  39742. rect[0],
  39743. rect[1]
  39744. ];
  39745. }
  39746. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  39747. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  39748. return [
  39749. xRatio,
  39750. 0,
  39751. 0,
  39752. yRatio,
  39753. rect[0] - minX * xRatio,
  39754. rect[1] - minY * yRatio
  39755. ];
  39756. }
  39757. function Annotation(params) {
  39758. var dict = params.dict;
  39759. this.setFlags(dict.get('F'));
  39760. this.setRectangle(dict.getArray('Rect'));
  39761. this.setColor(dict.getArray('C'));
  39762. this.setBorderStyle(dict);
  39763. this.setAppearance(dict);
  39764. this.data = {};
  39765. this.data.id = params.id;
  39766. this.data.subtype = params.subtype;
  39767. this.data.annotationFlags = this.flags;
  39768. this.data.rect = this.rectangle;
  39769. this.data.color = this.color;
  39770. this.data.borderStyle = this.borderStyle;
  39771. this.data.hasAppearance = !!this.appearance;
  39772. }
  39773. Annotation.prototype = {
  39774. _hasFlag: function Annotation_hasFlag(flags, flag) {
  39775. return !!(flags & flag);
  39776. },
  39777. _isViewable: function Annotation_isViewable(flags) {
  39778. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  39779. },
  39780. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  39781. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  39782. },
  39783. get viewable() {
  39784. if (this.flags === 0) {
  39785. return true;
  39786. }
  39787. return this._isViewable(this.flags);
  39788. },
  39789. get printable() {
  39790. if (this.flags === 0) {
  39791. return false;
  39792. }
  39793. return this._isPrintable(this.flags);
  39794. },
  39795. setFlags: function Annotation_setFlags(flags) {
  39796. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  39797. },
  39798. hasFlag: function Annotation_hasFlag(flag) {
  39799. return this._hasFlag(this.flags, flag);
  39800. },
  39801. setRectangle: function Annotation_setRectangle(rectangle) {
  39802. if (isArray(rectangle) && rectangle.length === 4) {
  39803. this.rectangle = Util.normalizeRect(rectangle);
  39804. } else {
  39805. this.rectangle = [
  39806. 0,
  39807. 0,
  39808. 0,
  39809. 0
  39810. ];
  39811. }
  39812. },
  39813. setColor: function Annotation_setColor(color) {
  39814. var rgbColor = new Uint8Array(3);
  39815. if (!isArray(color)) {
  39816. this.color = rgbColor;
  39817. return;
  39818. }
  39819. switch (color.length) {
  39820. case 0:
  39821. this.color = null;
  39822. break;
  39823. case 1:
  39824. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  39825. this.color = rgbColor;
  39826. break;
  39827. case 3:
  39828. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  39829. this.color = rgbColor;
  39830. break;
  39831. case 4:
  39832. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  39833. this.color = rgbColor;
  39834. break;
  39835. default:
  39836. this.color = rgbColor;
  39837. break;
  39838. }
  39839. },
  39840. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  39841. this.borderStyle = new AnnotationBorderStyle();
  39842. if (!isDict(borderStyle)) {
  39843. return;
  39844. }
  39845. if (borderStyle.has('BS')) {
  39846. var dict = borderStyle.get('BS');
  39847. var dictType = dict.get('Type');
  39848. if (!dictType || isName(dictType, 'Border')) {
  39849. this.borderStyle.setWidth(dict.get('W'));
  39850. this.borderStyle.setStyle(dict.get('S'));
  39851. this.borderStyle.setDashArray(dict.getArray('D'));
  39852. }
  39853. } else if (borderStyle.has('Border')) {
  39854. var array = borderStyle.getArray('Border');
  39855. if (isArray(array) && array.length >= 3) {
  39856. this.borderStyle.setHorizontalCornerRadius(array[0]);
  39857. this.borderStyle.setVerticalCornerRadius(array[1]);
  39858. this.borderStyle.setWidth(array[2]);
  39859. if (array.length === 4) {
  39860. this.borderStyle.setDashArray(array[3]);
  39861. }
  39862. }
  39863. } else {
  39864. this.borderStyle.setWidth(0);
  39865. }
  39866. },
  39867. setAppearance: function Annotation_setAppearance(dict) {
  39868. this.appearance = null;
  39869. var appearanceStates = dict.get('AP');
  39870. if (!isDict(appearanceStates)) {
  39871. return;
  39872. }
  39873. var normalAppearanceState = appearanceStates.get('N');
  39874. if (isStream(normalAppearanceState)) {
  39875. this.appearance = normalAppearanceState;
  39876. return;
  39877. }
  39878. if (!isDict(normalAppearanceState)) {
  39879. return;
  39880. }
  39881. var as = dict.get('AS');
  39882. if (!isName(as) || !normalAppearanceState.has(as.name)) {
  39883. return;
  39884. }
  39885. this.appearance = normalAppearanceState.get(as.name);
  39886. },
  39887. _preparePopup: function Annotation_preparePopup(dict) {
  39888. if (!dict.has('C')) {
  39889. this.data.color = null;
  39890. }
  39891. this.data.hasPopup = dict.has('Popup');
  39892. this.data.title = stringToPDFString(dict.get('T') || '');
  39893. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  39894. },
  39895. loadResources: function Annotation_loadResources(keys) {
  39896. return new Promise(function (resolve, reject) {
  39897. this.appearance.dict.getAsync('Resources').then(function (resources) {
  39898. if (!resources) {
  39899. resolve();
  39900. return;
  39901. }
  39902. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  39903. objectLoader.load().then(function () {
  39904. resolve(resources);
  39905. }, reject);
  39906. }, reject);
  39907. }.bind(this));
  39908. },
  39909. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  39910. if (!this.appearance) {
  39911. return Promise.resolve(new OperatorList());
  39912. }
  39913. var data = this.data;
  39914. var appearanceDict = this.appearance.dict;
  39915. var resourcesPromise = this.loadResources([
  39916. 'ExtGState',
  39917. 'ColorSpace',
  39918. 'Pattern',
  39919. 'Shading',
  39920. 'XObject',
  39921. 'Font'
  39922. ]);
  39923. var bbox = appearanceDict.getArray('BBox') || [
  39924. 0,
  39925. 0,
  39926. 1,
  39927. 1
  39928. ];
  39929. var matrix = appearanceDict.getArray('Matrix') || [
  39930. 1,
  39931. 0,
  39932. 0,
  39933. 1,
  39934. 0,
  39935. 0
  39936. ];
  39937. var transform = getTransformMatrix(data.rect, bbox, matrix);
  39938. var self = this;
  39939. return resourcesPromise.then(function (resources) {
  39940. var opList = new OperatorList();
  39941. opList.addOp(OPS.beginAnnotation, [
  39942. data.rect,
  39943. transform,
  39944. matrix
  39945. ]);
  39946. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  39947. opList.addOp(OPS.endAnnotation, []);
  39948. self.appearance.reset();
  39949. return opList;
  39950. });
  39951. });
  39952. }
  39953. };
  39954. Annotation.appendToOperatorList = function Annotation_appendToOperatorList(annotations, opList, partialEvaluator, task, intent, renderForms) {
  39955. var annotationPromises = [];
  39956. for (var i = 0, n = annotations.length; i < n; ++i) {
  39957. if (intent === 'display' && annotations[i].viewable || intent === 'print' && annotations[i].printable) {
  39958. annotationPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderForms));
  39959. }
  39960. }
  39961. return Promise.all(annotationPromises).then(function (operatorLists) {
  39962. opList.addOp(OPS.beginAnnotations, []);
  39963. for (var i = 0, n = operatorLists.length; i < n; ++i) {
  39964. opList.addOpList(operatorLists[i]);
  39965. }
  39966. opList.addOp(OPS.endAnnotations, []);
  39967. });
  39968. };
  39969. return Annotation;
  39970. }();
  39971. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  39972. function AnnotationBorderStyle() {
  39973. this.width = 1;
  39974. this.style = AnnotationBorderStyleType.SOLID;
  39975. this.dashArray = [3];
  39976. this.horizontalCornerRadius = 0;
  39977. this.verticalCornerRadius = 0;
  39978. }
  39979. AnnotationBorderStyle.prototype = {
  39980. setWidth: function AnnotationBorderStyle_setWidth(width) {
  39981. if (width === (width | 0)) {
  39982. this.width = width;
  39983. }
  39984. },
  39985. setStyle: function AnnotationBorderStyle_setStyle(style) {
  39986. if (!style) {
  39987. return;
  39988. }
  39989. switch (style.name) {
  39990. case 'S':
  39991. this.style = AnnotationBorderStyleType.SOLID;
  39992. break;
  39993. case 'D':
  39994. this.style = AnnotationBorderStyleType.DASHED;
  39995. break;
  39996. case 'B':
  39997. this.style = AnnotationBorderStyleType.BEVELED;
  39998. break;
  39999. case 'I':
  40000. this.style = AnnotationBorderStyleType.INSET;
  40001. break;
  40002. case 'U':
  40003. this.style = AnnotationBorderStyleType.UNDERLINE;
  40004. break;
  40005. default:
  40006. break;
  40007. }
  40008. },
  40009. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  40010. if (isArray(dashArray) && dashArray.length > 0) {
  40011. var isValid = true;
  40012. var allZeros = true;
  40013. for (var i = 0, len = dashArray.length; i < len; i++) {
  40014. var element = dashArray[i];
  40015. var validNumber = +element >= 0;
  40016. if (!validNumber) {
  40017. isValid = false;
  40018. break;
  40019. } else if (element > 0) {
  40020. allZeros = false;
  40021. }
  40022. }
  40023. if (isValid && !allZeros) {
  40024. this.dashArray = dashArray;
  40025. } else {
  40026. this.width = 0;
  40027. }
  40028. } else if (dashArray) {
  40029. this.width = 0;
  40030. }
  40031. },
  40032. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  40033. if (radius === (radius | 0)) {
  40034. this.horizontalCornerRadius = radius;
  40035. }
  40036. },
  40037. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  40038. if (radius === (radius | 0)) {
  40039. this.verticalCornerRadius = radius;
  40040. }
  40041. }
  40042. };
  40043. return AnnotationBorderStyle;
  40044. }();
  40045. var WidgetAnnotation = function WidgetAnnotationClosure() {
  40046. function WidgetAnnotation(params) {
  40047. Annotation.call(this, params);
  40048. var dict = params.dict;
  40049. var data = this.data;
  40050. data.annotationType = AnnotationType.WIDGET;
  40051. data.fieldName = this._constructFieldName(dict);
  40052. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  40053. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  40054. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  40055. var fieldType = Util.getInheritableProperty(dict, 'FT');
  40056. data.fieldType = isName(fieldType) ? fieldType.name : null;
  40057. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  40058. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  40059. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  40060. data.fieldFlags = 0;
  40061. }
  40062. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  40063. if (data.fieldType === 'Sig') {
  40064. this.setFlags(AnnotationFlag.HIDDEN);
  40065. }
  40066. }
  40067. Util.inherit(WidgetAnnotation, Annotation, {
  40068. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  40069. if (!dict.has('T') && !dict.has('Parent')) {
  40070. warn('Unknown field name, falling back to empty field name.');
  40071. return '';
  40072. }
  40073. if (!dict.has('Parent')) {
  40074. return stringToPDFString(dict.get('T'));
  40075. }
  40076. var fieldName = [];
  40077. if (dict.has('T')) {
  40078. fieldName.unshift(stringToPDFString(dict.get('T')));
  40079. }
  40080. var loopDict = dict;
  40081. while (loopDict.has('Parent')) {
  40082. loopDict = loopDict.get('Parent');
  40083. if (loopDict.has('T')) {
  40084. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  40085. }
  40086. }
  40087. return fieldName.join('.');
  40088. },
  40089. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  40090. return !!(this.data.fieldFlags & flag);
  40091. }
  40092. });
  40093. return WidgetAnnotation;
  40094. }();
  40095. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  40096. function TextWidgetAnnotation(params) {
  40097. WidgetAnnotation.call(this, params);
  40098. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  40099. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  40100. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  40101. alignment = null;
  40102. }
  40103. this.data.textAlignment = alignment;
  40104. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  40105. if (!isInt(maximumLength) || maximumLength < 0) {
  40106. maximumLength = null;
  40107. }
  40108. this.data.maxLen = maximumLength;
  40109. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  40110. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  40111. }
  40112. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  40113. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  40114. var operatorList = new OperatorList();
  40115. if (renderForms) {
  40116. return Promise.resolve(operatorList);
  40117. }
  40118. if (this.appearance) {
  40119. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  40120. }
  40121. if (!this.data.defaultAppearance) {
  40122. return Promise.resolve(operatorList);
  40123. }
  40124. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  40125. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  40126. return operatorList;
  40127. });
  40128. }
  40129. });
  40130. return TextWidgetAnnotation;
  40131. }();
  40132. var ButtonWidgetAnnotation = function ButtonWidgetAnnotationClosure() {
  40133. function ButtonWidgetAnnotation(params) {
  40134. WidgetAnnotation.call(this, params);
  40135. this.data.checkBox = !this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  40136. if (this.data.checkBox) {
  40137. if (!isName(this.data.fieldValue)) {
  40138. return;
  40139. }
  40140. this.data.fieldValue = this.data.fieldValue.name;
  40141. }
  40142. this.data.radioButton = this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  40143. if (this.data.radioButton) {
  40144. this.data.fieldValue = this.data.buttonValue = null;
  40145. var fieldParent = params.dict.get('Parent');
  40146. if (isDict(fieldParent) && fieldParent.has('V')) {
  40147. var fieldParentValue = fieldParent.get('V');
  40148. if (isName(fieldParentValue)) {
  40149. this.data.fieldValue = fieldParentValue.name;
  40150. }
  40151. }
  40152. var appearanceStates = params.dict.get('AP');
  40153. if (!isDict(appearanceStates)) {
  40154. return;
  40155. }
  40156. var normalAppearanceState = appearanceStates.get('N');
  40157. if (!isDict(normalAppearanceState)) {
  40158. return;
  40159. }
  40160. var keys = normalAppearanceState.getKeys();
  40161. for (var i = 0, ii = keys.length; i < ii; i++) {
  40162. if (keys[i] !== 'Off') {
  40163. this.data.buttonValue = keys[i];
  40164. break;
  40165. }
  40166. }
  40167. }
  40168. }
  40169. Util.inherit(ButtonWidgetAnnotation, WidgetAnnotation, {
  40170. getOperatorList: function ButtonWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  40171. var operatorList = new OperatorList();
  40172. if (renderForms) {
  40173. return Promise.resolve(operatorList);
  40174. }
  40175. if (this.appearance) {
  40176. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  40177. }
  40178. return Promise.resolve(operatorList);
  40179. }
  40180. });
  40181. return ButtonWidgetAnnotation;
  40182. }();
  40183. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  40184. function ChoiceWidgetAnnotation(params) {
  40185. WidgetAnnotation.call(this, params);
  40186. this.data.options = [];
  40187. var options = params.dict.get('Opt');
  40188. if (isArray(options)) {
  40189. var xref = params.xref;
  40190. for (var i = 0, ii = options.length; i < ii; i++) {
  40191. var option = xref.fetchIfRef(options[i]);
  40192. var isOptionArray = isArray(option);
  40193. this.data.options[i] = {
  40194. exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
  40195. displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
  40196. };
  40197. }
  40198. }
  40199. if (!isArray(this.data.fieldValue)) {
  40200. this.data.fieldValue = [this.data.fieldValue];
  40201. }
  40202. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  40203. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  40204. }
  40205. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  40206. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  40207. var operatorList = new OperatorList();
  40208. if (renderForms) {
  40209. return Promise.resolve(operatorList);
  40210. }
  40211. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  40212. }
  40213. });
  40214. return ChoiceWidgetAnnotation;
  40215. }();
  40216. var TextAnnotation = function TextAnnotationClosure() {
  40217. var DEFAULT_ICON_SIZE = 22;
  40218. function TextAnnotation(parameters) {
  40219. Annotation.call(this, parameters);
  40220. this.data.annotationType = AnnotationType.TEXT;
  40221. if (this.data.hasAppearance) {
  40222. this.data.name = 'NoIcon';
  40223. } else {
  40224. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  40225. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  40226. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  40227. }
  40228. this._preparePopup(parameters.dict);
  40229. }
  40230. Util.inherit(TextAnnotation, Annotation, {});
  40231. return TextAnnotation;
  40232. }();
  40233. var LinkAnnotation = function LinkAnnotationClosure() {
  40234. function LinkAnnotation(params) {
  40235. Annotation.call(this, params);
  40236. var data = this.data;
  40237. data.annotationType = AnnotationType.LINK;
  40238. Catalog.parseDestDictionary({
  40239. destDict: params.dict,
  40240. resultObj: data,
  40241. docBaseUrl: params.pdfManager.docBaseUrl
  40242. });
  40243. }
  40244. Util.inherit(LinkAnnotation, Annotation, {});
  40245. return LinkAnnotation;
  40246. }();
  40247. var PopupAnnotation = function PopupAnnotationClosure() {
  40248. function PopupAnnotation(parameters) {
  40249. Annotation.call(this, parameters);
  40250. this.data.annotationType = AnnotationType.POPUP;
  40251. var dict = parameters.dict;
  40252. var parentItem = dict.get('Parent');
  40253. if (!parentItem) {
  40254. warn('Popup annotation has a missing or invalid parent annotation.');
  40255. return;
  40256. }
  40257. this.data.parentId = dict.getRaw('Parent').toString();
  40258. this.data.title = stringToPDFString(parentItem.get('T') || '');
  40259. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  40260. if (!parentItem.has('C')) {
  40261. this.data.color = null;
  40262. } else {
  40263. this.setColor(parentItem.getArray('C'));
  40264. this.data.color = this.color;
  40265. }
  40266. if (!this.viewable) {
  40267. var parentFlags = parentItem.get('F');
  40268. if (this._isViewable(parentFlags)) {
  40269. this.setFlags(parentFlags);
  40270. }
  40271. }
  40272. }
  40273. Util.inherit(PopupAnnotation, Annotation, {});
  40274. return PopupAnnotation;
  40275. }();
  40276. var HighlightAnnotation = function HighlightAnnotationClosure() {
  40277. function HighlightAnnotation(parameters) {
  40278. Annotation.call(this, parameters);
  40279. this.data.annotationType = AnnotationType.HIGHLIGHT;
  40280. this._preparePopup(parameters.dict);
  40281. this.data.borderStyle.setWidth(0);
  40282. }
  40283. Util.inherit(HighlightAnnotation, Annotation, {});
  40284. return HighlightAnnotation;
  40285. }();
  40286. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  40287. function UnderlineAnnotation(parameters) {
  40288. Annotation.call(this, parameters);
  40289. this.data.annotationType = AnnotationType.UNDERLINE;
  40290. this._preparePopup(parameters.dict);
  40291. this.data.borderStyle.setWidth(0);
  40292. }
  40293. Util.inherit(UnderlineAnnotation, Annotation, {});
  40294. return UnderlineAnnotation;
  40295. }();
  40296. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  40297. function SquigglyAnnotation(parameters) {
  40298. Annotation.call(this, parameters);
  40299. this.data.annotationType = AnnotationType.SQUIGGLY;
  40300. this._preparePopup(parameters.dict);
  40301. this.data.borderStyle.setWidth(0);
  40302. }
  40303. Util.inherit(SquigglyAnnotation, Annotation, {});
  40304. return SquigglyAnnotation;
  40305. }();
  40306. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  40307. function StrikeOutAnnotation(parameters) {
  40308. Annotation.call(this, parameters);
  40309. this.data.annotationType = AnnotationType.STRIKEOUT;
  40310. this._preparePopup(parameters.dict);
  40311. this.data.borderStyle.setWidth(0);
  40312. }
  40313. Util.inherit(StrikeOutAnnotation, Annotation, {});
  40314. return StrikeOutAnnotation;
  40315. }();
  40316. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  40317. function FileAttachmentAnnotation(parameters) {
  40318. Annotation.call(this, parameters);
  40319. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  40320. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  40321. this.data.file = file.serializable;
  40322. this._preparePopup(parameters.dict);
  40323. }
  40324. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  40325. return FileAttachmentAnnotation;
  40326. }();
  40327. exports.Annotation = Annotation;
  40328. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  40329. exports.AnnotationFactory = AnnotationFactory;
  40330. /***/ }),
  40331. /* 28 */
  40332. /***/ (function(module, exports, __w_pdfjs_require__) {
  40333. "use strict";
  40334. var sharedUtil = __w_pdfjs_require__(0);
  40335. var warn = sharedUtil.warn;
  40336. var baseTypes = [
  40337. 'BN',
  40338. 'BN',
  40339. 'BN',
  40340. 'BN',
  40341. 'BN',
  40342. 'BN',
  40343. 'BN',
  40344. 'BN',
  40345. 'BN',
  40346. 'S',
  40347. 'B',
  40348. 'S',
  40349. 'WS',
  40350. 'B',
  40351. 'BN',
  40352. 'BN',
  40353. 'BN',
  40354. 'BN',
  40355. 'BN',
  40356. 'BN',
  40357. 'BN',
  40358. 'BN',
  40359. 'BN',
  40360. 'BN',
  40361. 'BN',
  40362. 'BN',
  40363. 'BN',
  40364. 'BN',
  40365. 'B',
  40366. 'B',
  40367. 'B',
  40368. 'S',
  40369. 'WS',
  40370. 'ON',
  40371. 'ON',
  40372. 'ET',
  40373. 'ET',
  40374. 'ET',
  40375. 'ON',
  40376. 'ON',
  40377. 'ON',
  40378. 'ON',
  40379. 'ON',
  40380. 'ES',
  40381. 'CS',
  40382. 'ES',
  40383. 'CS',
  40384. 'CS',
  40385. 'EN',
  40386. 'EN',
  40387. 'EN',
  40388. 'EN',
  40389. 'EN',
  40390. 'EN',
  40391. 'EN',
  40392. 'EN',
  40393. 'EN',
  40394. 'EN',
  40395. 'CS',
  40396. 'ON',
  40397. 'ON',
  40398. 'ON',
  40399. 'ON',
  40400. 'ON',
  40401. 'ON',
  40402. 'L',
  40403. 'L',
  40404. 'L',
  40405. 'L',
  40406. 'L',
  40407. 'L',
  40408. 'L',
  40409. 'L',
  40410. 'L',
  40411. 'L',
  40412. 'L',
  40413. 'L',
  40414. 'L',
  40415. 'L',
  40416. 'L',
  40417. 'L',
  40418. 'L',
  40419. 'L',
  40420. 'L',
  40421. 'L',
  40422. 'L',
  40423. 'L',
  40424. 'L',
  40425. 'L',
  40426. 'L',
  40427. 'L',
  40428. 'ON',
  40429. 'ON',
  40430. 'ON',
  40431. 'ON',
  40432. 'ON',
  40433. 'ON',
  40434. 'L',
  40435. 'L',
  40436. 'L',
  40437. 'L',
  40438. 'L',
  40439. 'L',
  40440. 'L',
  40441. 'L',
  40442. 'L',
  40443. 'L',
  40444. 'L',
  40445. 'L',
  40446. 'L',
  40447. 'L',
  40448. 'L',
  40449. 'L',
  40450. 'L',
  40451. 'L',
  40452. 'L',
  40453. 'L',
  40454. 'L',
  40455. 'L',
  40456. 'L',
  40457. 'L',
  40458. 'L',
  40459. 'L',
  40460. 'ON',
  40461. 'ON',
  40462. 'ON',
  40463. 'ON',
  40464. 'BN',
  40465. 'BN',
  40466. 'BN',
  40467. 'BN',
  40468. 'BN',
  40469. 'BN',
  40470. 'B',
  40471. 'BN',
  40472. 'BN',
  40473. 'BN',
  40474. 'BN',
  40475. 'BN',
  40476. 'BN',
  40477. 'BN',
  40478. 'BN',
  40479. 'BN',
  40480. 'BN',
  40481. 'BN',
  40482. 'BN',
  40483. 'BN',
  40484. 'BN',
  40485. 'BN',
  40486. 'BN',
  40487. 'BN',
  40488. 'BN',
  40489. 'BN',
  40490. 'BN',
  40491. 'BN',
  40492. 'BN',
  40493. 'BN',
  40494. 'BN',
  40495. 'BN',
  40496. 'BN',
  40497. 'CS',
  40498. 'ON',
  40499. 'ET',
  40500. 'ET',
  40501. 'ET',
  40502. 'ET',
  40503. 'ON',
  40504. 'ON',
  40505. 'ON',
  40506. 'ON',
  40507. 'L',
  40508. 'ON',
  40509. 'ON',
  40510. 'BN',
  40511. 'ON',
  40512. 'ON',
  40513. 'ET',
  40514. 'ET',
  40515. 'EN',
  40516. 'EN',
  40517. 'ON',
  40518. 'L',
  40519. 'ON',
  40520. 'ON',
  40521. 'ON',
  40522. 'EN',
  40523. 'L',
  40524. 'ON',
  40525. 'ON',
  40526. 'ON',
  40527. 'ON',
  40528. 'ON',
  40529. 'L',
  40530. 'L',
  40531. 'L',
  40532. 'L',
  40533. 'L',
  40534. 'L',
  40535. 'L',
  40536. 'L',
  40537. 'L',
  40538. 'L',
  40539. 'L',
  40540. 'L',
  40541. 'L',
  40542. 'L',
  40543. 'L',
  40544. 'L',
  40545. 'L',
  40546. 'L',
  40547. 'L',
  40548. 'L',
  40549. 'L',
  40550. 'L',
  40551. 'L',
  40552. 'ON',
  40553. 'L',
  40554. 'L',
  40555. 'L',
  40556. 'L',
  40557. 'L',
  40558. 'L',
  40559. 'L',
  40560. 'L',
  40561. 'L',
  40562. 'L',
  40563. 'L',
  40564. 'L',
  40565. 'L',
  40566. 'L',
  40567. 'L',
  40568. 'L',
  40569. 'L',
  40570. 'L',
  40571. 'L',
  40572. 'L',
  40573. 'L',
  40574. 'L',
  40575. 'L',
  40576. 'L',
  40577. 'L',
  40578. 'L',
  40579. 'L',
  40580. 'L',
  40581. 'L',
  40582. 'L',
  40583. 'L',
  40584. 'ON',
  40585. 'L',
  40586. 'L',
  40587. 'L',
  40588. 'L',
  40589. 'L',
  40590. 'L',
  40591. 'L',
  40592. 'L'
  40593. ];
  40594. var arabicTypes = [
  40595. 'AN',
  40596. 'AN',
  40597. 'AN',
  40598. 'AN',
  40599. 'AN',
  40600. 'AN',
  40601. 'ON',
  40602. 'ON',
  40603. 'AL',
  40604. 'ET',
  40605. 'ET',
  40606. 'AL',
  40607. 'CS',
  40608. 'AL',
  40609. 'ON',
  40610. 'ON',
  40611. 'NSM',
  40612. 'NSM',
  40613. 'NSM',
  40614. 'NSM',
  40615. 'NSM',
  40616. 'NSM',
  40617. 'NSM',
  40618. 'NSM',
  40619. 'NSM',
  40620. 'NSM',
  40621. 'NSM',
  40622. 'AL',
  40623. 'AL',
  40624. '',
  40625. 'AL',
  40626. 'AL',
  40627. 'AL',
  40628. 'AL',
  40629. 'AL',
  40630. 'AL',
  40631. 'AL',
  40632. 'AL',
  40633. 'AL',
  40634. 'AL',
  40635. 'AL',
  40636. 'AL',
  40637. 'AL',
  40638. 'AL',
  40639. 'AL',
  40640. 'AL',
  40641. 'AL',
  40642. 'AL',
  40643. 'AL',
  40644. 'AL',
  40645. 'AL',
  40646. 'AL',
  40647. 'AL',
  40648. 'AL',
  40649. 'AL',
  40650. 'AL',
  40651. 'AL',
  40652. 'AL',
  40653. 'AL',
  40654. 'AL',
  40655. 'AL',
  40656. 'AL',
  40657. 'AL',
  40658. 'AL',
  40659. 'AL',
  40660. 'AL',
  40661. 'AL',
  40662. 'AL',
  40663. 'AL',
  40664. 'AL',
  40665. 'AL',
  40666. 'AL',
  40667. 'AL',
  40668. 'AL',
  40669. 'AL',
  40670. 'NSM',
  40671. 'NSM',
  40672. 'NSM',
  40673. 'NSM',
  40674. 'NSM',
  40675. 'NSM',
  40676. 'NSM',
  40677. 'NSM',
  40678. 'NSM',
  40679. 'NSM',
  40680. 'NSM',
  40681. 'NSM',
  40682. 'NSM',
  40683. 'NSM',
  40684. 'NSM',
  40685. 'NSM',
  40686. 'NSM',
  40687. 'NSM',
  40688. 'NSM',
  40689. 'NSM',
  40690. 'NSM',
  40691. 'AN',
  40692. 'AN',
  40693. 'AN',
  40694. 'AN',
  40695. 'AN',
  40696. 'AN',
  40697. 'AN',
  40698. 'AN',
  40699. 'AN',
  40700. 'AN',
  40701. 'ET',
  40702. 'AN',
  40703. 'AN',
  40704. 'AL',
  40705. 'AL',
  40706. 'AL',
  40707. 'NSM',
  40708. 'AL',
  40709. 'AL',
  40710. 'AL',
  40711. 'AL',
  40712. 'AL',
  40713. 'AL',
  40714. 'AL',
  40715. 'AL',
  40716. 'AL',
  40717. 'AL',
  40718. 'AL',
  40719. 'AL',
  40720. 'AL',
  40721. 'AL',
  40722. 'AL',
  40723. 'AL',
  40724. 'AL',
  40725. 'AL',
  40726. 'AL',
  40727. 'AL',
  40728. 'AL',
  40729. 'AL',
  40730. 'AL',
  40731. 'AL',
  40732. 'AL',
  40733. 'AL',
  40734. 'AL',
  40735. 'AL',
  40736. 'AL',
  40737. 'AL',
  40738. 'AL',
  40739. 'AL',
  40740. 'AL',
  40741. 'AL',
  40742. 'AL',
  40743. 'AL',
  40744. 'AL',
  40745. 'AL',
  40746. 'AL',
  40747. 'AL',
  40748. 'AL',
  40749. 'AL',
  40750. 'AL',
  40751. 'AL',
  40752. 'AL',
  40753. 'AL',
  40754. 'AL',
  40755. 'AL',
  40756. 'AL',
  40757. 'AL',
  40758. 'AL',
  40759. 'AL',
  40760. 'AL',
  40761. 'AL',
  40762. 'AL',
  40763. 'AL',
  40764. 'AL',
  40765. 'AL',
  40766. 'AL',
  40767. 'AL',
  40768. 'AL',
  40769. 'AL',
  40770. 'AL',
  40771. 'AL',
  40772. 'AL',
  40773. 'AL',
  40774. 'AL',
  40775. 'AL',
  40776. 'AL',
  40777. 'AL',
  40778. 'AL',
  40779. 'AL',
  40780. 'AL',
  40781. 'AL',
  40782. 'AL',
  40783. 'AL',
  40784. 'AL',
  40785. 'AL',
  40786. 'AL',
  40787. 'AL',
  40788. 'AL',
  40789. 'AL',
  40790. 'AL',
  40791. 'AL',
  40792. 'AL',
  40793. 'AL',
  40794. 'AL',
  40795. 'AL',
  40796. 'AL',
  40797. 'AL',
  40798. 'AL',
  40799. 'AL',
  40800. 'AL',
  40801. 'AL',
  40802. 'AL',
  40803. 'AL',
  40804. 'AL',
  40805. 'AL',
  40806. 'AL',
  40807. 'AL',
  40808. 'AL',
  40809. 'NSM',
  40810. 'NSM',
  40811. 'NSM',
  40812. 'NSM',
  40813. 'NSM',
  40814. 'NSM',
  40815. 'NSM',
  40816. 'AN',
  40817. 'ON',
  40818. 'NSM',
  40819. 'NSM',
  40820. 'NSM',
  40821. 'NSM',
  40822. 'NSM',
  40823. 'NSM',
  40824. 'AL',
  40825. 'AL',
  40826. 'NSM',
  40827. 'NSM',
  40828. 'ON',
  40829. 'NSM',
  40830. 'NSM',
  40831. 'NSM',
  40832. 'NSM',
  40833. 'AL',
  40834. 'AL',
  40835. 'EN',
  40836. 'EN',
  40837. 'EN',
  40838. 'EN',
  40839. 'EN',
  40840. 'EN',
  40841. 'EN',
  40842. 'EN',
  40843. 'EN',
  40844. 'EN',
  40845. 'AL',
  40846. 'AL',
  40847. 'AL',
  40848. 'AL',
  40849. 'AL',
  40850. 'AL'
  40851. ];
  40852. function isOdd(i) {
  40853. return (i & 1) !== 0;
  40854. }
  40855. function isEven(i) {
  40856. return (i & 1) === 0;
  40857. }
  40858. function findUnequal(arr, start, value) {
  40859. for (var j = start, jj = arr.length; j < jj; ++j) {
  40860. if (arr[j] !== value) {
  40861. return j;
  40862. }
  40863. }
  40864. return j;
  40865. }
  40866. function setValues(arr, start, end, value) {
  40867. for (var j = start; j < end; ++j) {
  40868. arr[j] = value;
  40869. }
  40870. }
  40871. function reverseValues(arr, start, end) {
  40872. for (var i = start, j = end - 1; i < j; ++i, --j) {
  40873. var temp = arr[i];
  40874. arr[i] = arr[j];
  40875. arr[j] = temp;
  40876. }
  40877. }
  40878. function createBidiText(str, isLTR, vertical) {
  40879. return {
  40880. str: str,
  40881. dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
  40882. };
  40883. }
  40884. var chars = [];
  40885. var types = [];
  40886. function bidi(str, startLevel, vertical) {
  40887. var isLTR = true;
  40888. var strLength = str.length;
  40889. if (strLength === 0 || vertical) {
  40890. return createBidiText(str, isLTR, vertical);
  40891. }
  40892. chars.length = strLength;
  40893. types.length = strLength;
  40894. var numBidi = 0;
  40895. var i, ii;
  40896. for (i = 0; i < strLength; ++i) {
  40897. chars[i] = str.charAt(i);
  40898. var charCode = str.charCodeAt(i);
  40899. var charType = 'L';
  40900. if (charCode <= 0x00ff) {
  40901. charType = baseTypes[charCode];
  40902. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  40903. charType = 'R';
  40904. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  40905. charType = arabicTypes[charCode & 0xff];
  40906. if (!charType) {
  40907. warn('Bidi: invalid Unicode character ' + charCode.toString(16));
  40908. }
  40909. } else if (0x0700 <= charCode && charCode <= 0x08AC) {
  40910. charType = 'AL';
  40911. }
  40912. if (charType === 'R' || charType === 'AL' || charType === 'AN') {
  40913. numBidi++;
  40914. }
  40915. types[i] = charType;
  40916. }
  40917. if (numBidi === 0) {
  40918. isLTR = true;
  40919. return createBidiText(str, isLTR);
  40920. }
  40921. if (startLevel === -1) {
  40922. if (numBidi / strLength < 0.3) {
  40923. isLTR = true;
  40924. startLevel = 0;
  40925. } else {
  40926. isLTR = false;
  40927. startLevel = 1;
  40928. }
  40929. }
  40930. var levels = [];
  40931. for (i = 0; i < strLength; ++i) {
  40932. levels[i] = startLevel;
  40933. }
  40934. var e = isOdd(startLevel) ? 'R' : 'L';
  40935. var sor = e;
  40936. var eor = sor;
  40937. var lastType = sor;
  40938. for (i = 0; i < strLength; ++i) {
  40939. if (types[i] === 'NSM') {
  40940. types[i] = lastType;
  40941. } else {
  40942. lastType = types[i];
  40943. }
  40944. }
  40945. lastType = sor;
  40946. var t;
  40947. for (i = 0; i < strLength; ++i) {
  40948. t = types[i];
  40949. if (t === 'EN') {
  40950. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  40951. } else if (t === 'R' || t === 'L' || t === 'AL') {
  40952. lastType = t;
  40953. }
  40954. }
  40955. for (i = 0; i < strLength; ++i) {
  40956. t = types[i];
  40957. if (t === 'AL') {
  40958. types[i] = 'R';
  40959. }
  40960. }
  40961. for (i = 1; i < strLength - 1; ++i) {
  40962. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  40963. types[i] = 'EN';
  40964. }
  40965. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  40966. types[i] = types[i - 1];
  40967. }
  40968. }
  40969. for (i = 0; i < strLength; ++i) {
  40970. if (types[i] === 'EN') {
  40971. var j;
  40972. for (j = i - 1; j >= 0; --j) {
  40973. if (types[j] !== 'ET') {
  40974. break;
  40975. }
  40976. types[j] = 'EN';
  40977. }
  40978. for (j = i + 1; j < strLength; ++j) {
  40979. if (types[j] !== 'ET') {
  40980. break;
  40981. }
  40982. types[j] = 'EN';
  40983. }
  40984. }
  40985. }
  40986. for (i = 0; i < strLength; ++i) {
  40987. t = types[i];
  40988. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  40989. types[i] = 'ON';
  40990. }
  40991. }
  40992. lastType = sor;
  40993. for (i = 0; i < strLength; ++i) {
  40994. t = types[i];
  40995. if (t === 'EN') {
  40996. types[i] = lastType === 'L' ? 'L' : 'EN';
  40997. } else if (t === 'R' || t === 'L') {
  40998. lastType = t;
  40999. }
  41000. }
  41001. for (i = 0; i < strLength; ++i) {
  41002. if (types[i] === 'ON') {
  41003. var end = findUnequal(types, i + 1, 'ON');
  41004. var before = sor;
  41005. if (i > 0) {
  41006. before = types[i - 1];
  41007. }
  41008. var after = eor;
  41009. if (end + 1 < strLength) {
  41010. after = types[end + 1];
  41011. }
  41012. if (before !== 'L') {
  41013. before = 'R';
  41014. }
  41015. if (after !== 'L') {
  41016. after = 'R';
  41017. }
  41018. if (before === after) {
  41019. setValues(types, i, end, before);
  41020. }
  41021. i = end - 1;
  41022. }
  41023. }
  41024. for (i = 0; i < strLength; ++i) {
  41025. if (types[i] === 'ON') {
  41026. types[i] = e;
  41027. }
  41028. }
  41029. for (i = 0; i < strLength; ++i) {
  41030. t = types[i];
  41031. if (isEven(levels[i])) {
  41032. if (t === 'R') {
  41033. levels[i] += 1;
  41034. } else if (t === 'AN' || t === 'EN') {
  41035. levels[i] += 2;
  41036. }
  41037. } else {
  41038. if (t === 'L' || t === 'AN' || t === 'EN') {
  41039. levels[i] += 1;
  41040. }
  41041. }
  41042. }
  41043. var highestLevel = -1;
  41044. var lowestOddLevel = 99;
  41045. var level;
  41046. for (i = 0, ii = levels.length; i < ii; ++i) {
  41047. level = levels[i];
  41048. if (highestLevel < level) {
  41049. highestLevel = level;
  41050. }
  41051. if (lowestOddLevel > level && isOdd(level)) {
  41052. lowestOddLevel = level;
  41053. }
  41054. }
  41055. for (level = highestLevel; level >= lowestOddLevel; --level) {
  41056. var start = -1;
  41057. for (i = 0, ii = levels.length; i < ii; ++i) {
  41058. if (levels[i] < level) {
  41059. if (start >= 0) {
  41060. reverseValues(chars, start, i);
  41061. start = -1;
  41062. }
  41063. } else if (start < 0) {
  41064. start = i;
  41065. }
  41066. }
  41067. if (start >= 0) {
  41068. reverseValues(chars, start, levels.length);
  41069. }
  41070. }
  41071. for (i = 0, ii = chars.length; i < ii; ++i) {
  41072. var ch = chars[i];
  41073. if (ch === '<' || ch === '>') {
  41074. chars[i] = '';
  41075. }
  41076. }
  41077. return createBidiText(chars.join(''), isLTR);
  41078. }
  41079. exports.bidi = bidi;
  41080. /***/ }),
  41081. /* 29 */
  41082. /***/ (function(module, exports, __w_pdfjs_require__) {
  41083. "use strict";
  41084. var ISOAdobeCharset = [
  41085. '.notdef',
  41086. 'space',
  41087. 'exclam',
  41088. 'quotedbl',
  41089. 'numbersign',
  41090. 'dollar',
  41091. 'percent',
  41092. 'ampersand',
  41093. 'quoteright',
  41094. 'parenleft',
  41095. 'parenright',
  41096. 'asterisk',
  41097. 'plus',
  41098. 'comma',
  41099. 'hyphen',
  41100. 'period',
  41101. 'slash',
  41102. 'zero',
  41103. 'one',
  41104. 'two',
  41105. 'three',
  41106. 'four',
  41107. 'five',
  41108. 'six',
  41109. 'seven',
  41110. 'eight',
  41111. 'nine',
  41112. 'colon',
  41113. 'semicolon',
  41114. 'less',
  41115. 'equal',
  41116. 'greater',
  41117. 'question',
  41118. 'at',
  41119. 'A',
  41120. 'B',
  41121. 'C',
  41122. 'D',
  41123. 'E',
  41124. 'F',
  41125. 'G',
  41126. 'H',
  41127. 'I',
  41128. 'J',
  41129. 'K',
  41130. 'L',
  41131. 'M',
  41132. 'N',
  41133. 'O',
  41134. 'P',
  41135. 'Q',
  41136. 'R',
  41137. 'S',
  41138. 'T',
  41139. 'U',
  41140. 'V',
  41141. 'W',
  41142. 'X',
  41143. 'Y',
  41144. 'Z',
  41145. 'bracketleft',
  41146. 'backslash',
  41147. 'bracketright',
  41148. 'asciicircum',
  41149. 'underscore',
  41150. 'quoteleft',
  41151. 'a',
  41152. 'b',
  41153. 'c',
  41154. 'd',
  41155. 'e',
  41156. 'f',
  41157. 'g',
  41158. 'h',
  41159. 'i',
  41160. 'j',
  41161. 'k',
  41162. 'l',
  41163. 'm',
  41164. 'n',
  41165. 'o',
  41166. 'p',
  41167. 'q',
  41168. 'r',
  41169. 's',
  41170. 't',
  41171. 'u',
  41172. 'v',
  41173. 'w',
  41174. 'x',
  41175. 'y',
  41176. 'z',
  41177. 'braceleft',
  41178. 'bar',
  41179. 'braceright',
  41180. 'asciitilde',
  41181. 'exclamdown',
  41182. 'cent',
  41183. 'sterling',
  41184. 'fraction',
  41185. 'yen',
  41186. 'florin',
  41187. 'section',
  41188. 'currency',
  41189. 'quotesingle',
  41190. 'quotedblleft',
  41191. 'guillemotleft',
  41192. 'guilsinglleft',
  41193. 'guilsinglright',
  41194. 'fi',
  41195. 'fl',
  41196. 'endash',
  41197. 'dagger',
  41198. 'daggerdbl',
  41199. 'periodcentered',
  41200. 'paragraph',
  41201. 'bullet',
  41202. 'quotesinglbase',
  41203. 'quotedblbase',
  41204. 'quotedblright',
  41205. 'guillemotright',
  41206. 'ellipsis',
  41207. 'perthousand',
  41208. 'questiondown',
  41209. 'grave',
  41210. 'acute',
  41211. 'circumflex',
  41212. 'tilde',
  41213. 'macron',
  41214. 'breve',
  41215. 'dotaccent',
  41216. 'dieresis',
  41217. 'ring',
  41218. 'cedilla',
  41219. 'hungarumlaut',
  41220. 'ogonek',
  41221. 'caron',
  41222. 'emdash',
  41223. 'AE',
  41224. 'ordfeminine',
  41225. 'Lslash',
  41226. 'Oslash',
  41227. 'OE',
  41228. 'ordmasculine',
  41229. 'ae',
  41230. 'dotlessi',
  41231. 'lslash',
  41232. 'oslash',
  41233. 'oe',
  41234. 'germandbls',
  41235. 'onesuperior',
  41236. 'logicalnot',
  41237. 'mu',
  41238. 'trademark',
  41239. 'Eth',
  41240. 'onehalf',
  41241. 'plusminus',
  41242. 'Thorn',
  41243. 'onequarter',
  41244. 'divide',
  41245. 'brokenbar',
  41246. 'degree',
  41247. 'thorn',
  41248. 'threequarters',
  41249. 'twosuperior',
  41250. 'registered',
  41251. 'minus',
  41252. 'eth',
  41253. 'multiply',
  41254. 'threesuperior',
  41255. 'copyright',
  41256. 'Aacute',
  41257. 'Acircumflex',
  41258. 'Adieresis',
  41259. 'Agrave',
  41260. 'Aring',
  41261. 'Atilde',
  41262. 'Ccedilla',
  41263. 'Eacute',
  41264. 'Ecircumflex',
  41265. 'Edieresis',
  41266. 'Egrave',
  41267. 'Iacute',
  41268. 'Icircumflex',
  41269. 'Idieresis',
  41270. 'Igrave',
  41271. 'Ntilde',
  41272. 'Oacute',
  41273. 'Ocircumflex',
  41274. 'Odieresis',
  41275. 'Ograve',
  41276. 'Otilde',
  41277. 'Scaron',
  41278. 'Uacute',
  41279. 'Ucircumflex',
  41280. 'Udieresis',
  41281. 'Ugrave',
  41282. 'Yacute',
  41283. 'Ydieresis',
  41284. 'Zcaron',
  41285. 'aacute',
  41286. 'acircumflex',
  41287. 'adieresis',
  41288. 'agrave',
  41289. 'aring',
  41290. 'atilde',
  41291. 'ccedilla',
  41292. 'eacute',
  41293. 'ecircumflex',
  41294. 'edieresis',
  41295. 'egrave',
  41296. 'iacute',
  41297. 'icircumflex',
  41298. 'idieresis',
  41299. 'igrave',
  41300. 'ntilde',
  41301. 'oacute',
  41302. 'ocircumflex',
  41303. 'odieresis',
  41304. 'ograve',
  41305. 'otilde',
  41306. 'scaron',
  41307. 'uacute',
  41308. 'ucircumflex',
  41309. 'udieresis',
  41310. 'ugrave',
  41311. 'yacute',
  41312. 'ydieresis',
  41313. 'zcaron'
  41314. ];
  41315. var ExpertCharset = [
  41316. '.notdef',
  41317. 'space',
  41318. 'exclamsmall',
  41319. 'Hungarumlautsmall',
  41320. 'dollaroldstyle',
  41321. 'dollarsuperior',
  41322. 'ampersandsmall',
  41323. 'Acutesmall',
  41324. 'parenleftsuperior',
  41325. 'parenrightsuperior',
  41326. 'twodotenleader',
  41327. 'onedotenleader',
  41328. 'comma',
  41329. 'hyphen',
  41330. 'period',
  41331. 'fraction',
  41332. 'zerooldstyle',
  41333. 'oneoldstyle',
  41334. 'twooldstyle',
  41335. 'threeoldstyle',
  41336. 'fouroldstyle',
  41337. 'fiveoldstyle',
  41338. 'sixoldstyle',
  41339. 'sevenoldstyle',
  41340. 'eightoldstyle',
  41341. 'nineoldstyle',
  41342. 'colon',
  41343. 'semicolon',
  41344. 'commasuperior',
  41345. 'threequartersemdash',
  41346. 'periodsuperior',
  41347. 'questionsmall',
  41348. 'asuperior',
  41349. 'bsuperior',
  41350. 'centsuperior',
  41351. 'dsuperior',
  41352. 'esuperior',
  41353. 'isuperior',
  41354. 'lsuperior',
  41355. 'msuperior',
  41356. 'nsuperior',
  41357. 'osuperior',
  41358. 'rsuperior',
  41359. 'ssuperior',
  41360. 'tsuperior',
  41361. 'ff',
  41362. 'fi',
  41363. 'fl',
  41364. 'ffi',
  41365. 'ffl',
  41366. 'parenleftinferior',
  41367. 'parenrightinferior',
  41368. 'Circumflexsmall',
  41369. 'hyphensuperior',
  41370. 'Gravesmall',
  41371. 'Asmall',
  41372. 'Bsmall',
  41373. 'Csmall',
  41374. 'Dsmall',
  41375. 'Esmall',
  41376. 'Fsmall',
  41377. 'Gsmall',
  41378. 'Hsmall',
  41379. 'Ismall',
  41380. 'Jsmall',
  41381. 'Ksmall',
  41382. 'Lsmall',
  41383. 'Msmall',
  41384. 'Nsmall',
  41385. 'Osmall',
  41386. 'Psmall',
  41387. 'Qsmall',
  41388. 'Rsmall',
  41389. 'Ssmall',
  41390. 'Tsmall',
  41391. 'Usmall',
  41392. 'Vsmall',
  41393. 'Wsmall',
  41394. 'Xsmall',
  41395. 'Ysmall',
  41396. 'Zsmall',
  41397. 'colonmonetary',
  41398. 'onefitted',
  41399. 'rupiah',
  41400. 'Tildesmall',
  41401. 'exclamdownsmall',
  41402. 'centoldstyle',
  41403. 'Lslashsmall',
  41404. 'Scaronsmall',
  41405. 'Zcaronsmall',
  41406. 'Dieresissmall',
  41407. 'Brevesmall',
  41408. 'Caronsmall',
  41409. 'Dotaccentsmall',
  41410. 'Macronsmall',
  41411. 'figuredash',
  41412. 'hypheninferior',
  41413. 'Ogoneksmall',
  41414. 'Ringsmall',
  41415. 'Cedillasmall',
  41416. 'onequarter',
  41417. 'onehalf',
  41418. 'threequarters',
  41419. 'questiondownsmall',
  41420. 'oneeighth',
  41421. 'threeeighths',
  41422. 'fiveeighths',
  41423. 'seveneighths',
  41424. 'onethird',
  41425. 'twothirds',
  41426. 'zerosuperior',
  41427. 'onesuperior',
  41428. 'twosuperior',
  41429. 'threesuperior',
  41430. 'foursuperior',
  41431. 'fivesuperior',
  41432. 'sixsuperior',
  41433. 'sevensuperior',
  41434. 'eightsuperior',
  41435. 'ninesuperior',
  41436. 'zeroinferior',
  41437. 'oneinferior',
  41438. 'twoinferior',
  41439. 'threeinferior',
  41440. 'fourinferior',
  41441. 'fiveinferior',
  41442. 'sixinferior',
  41443. 'seveninferior',
  41444. 'eightinferior',
  41445. 'nineinferior',
  41446. 'centinferior',
  41447. 'dollarinferior',
  41448. 'periodinferior',
  41449. 'commainferior',
  41450. 'Agravesmall',
  41451. 'Aacutesmall',
  41452. 'Acircumflexsmall',
  41453. 'Atildesmall',
  41454. 'Adieresissmall',
  41455. 'Aringsmall',
  41456. 'AEsmall',
  41457. 'Ccedillasmall',
  41458. 'Egravesmall',
  41459. 'Eacutesmall',
  41460. 'Ecircumflexsmall',
  41461. 'Edieresissmall',
  41462. 'Igravesmall',
  41463. 'Iacutesmall',
  41464. 'Icircumflexsmall',
  41465. 'Idieresissmall',
  41466. 'Ethsmall',
  41467. 'Ntildesmall',
  41468. 'Ogravesmall',
  41469. 'Oacutesmall',
  41470. 'Ocircumflexsmall',
  41471. 'Otildesmall',
  41472. 'Odieresissmall',
  41473. 'OEsmall',
  41474. 'Oslashsmall',
  41475. 'Ugravesmall',
  41476. 'Uacutesmall',
  41477. 'Ucircumflexsmall',
  41478. 'Udieresissmall',
  41479. 'Yacutesmall',
  41480. 'Thornsmall',
  41481. 'Ydieresissmall'
  41482. ];
  41483. var ExpertSubsetCharset = [
  41484. '.notdef',
  41485. 'space',
  41486. 'dollaroldstyle',
  41487. 'dollarsuperior',
  41488. 'parenleftsuperior',
  41489. 'parenrightsuperior',
  41490. 'twodotenleader',
  41491. 'onedotenleader',
  41492. 'comma',
  41493. 'hyphen',
  41494. 'period',
  41495. 'fraction',
  41496. 'zerooldstyle',
  41497. 'oneoldstyle',
  41498. 'twooldstyle',
  41499. 'threeoldstyle',
  41500. 'fouroldstyle',
  41501. 'fiveoldstyle',
  41502. 'sixoldstyle',
  41503. 'sevenoldstyle',
  41504. 'eightoldstyle',
  41505. 'nineoldstyle',
  41506. 'colon',
  41507. 'semicolon',
  41508. 'commasuperior',
  41509. 'threequartersemdash',
  41510. 'periodsuperior',
  41511. 'asuperior',
  41512. 'bsuperior',
  41513. 'centsuperior',
  41514. 'dsuperior',
  41515. 'esuperior',
  41516. 'isuperior',
  41517. 'lsuperior',
  41518. 'msuperior',
  41519. 'nsuperior',
  41520. 'osuperior',
  41521. 'rsuperior',
  41522. 'ssuperior',
  41523. 'tsuperior',
  41524. 'ff',
  41525. 'fi',
  41526. 'fl',
  41527. 'ffi',
  41528. 'ffl',
  41529. 'parenleftinferior',
  41530. 'parenrightinferior',
  41531. 'hyphensuperior',
  41532. 'colonmonetary',
  41533. 'onefitted',
  41534. 'rupiah',
  41535. 'centoldstyle',
  41536. 'figuredash',
  41537. 'hypheninferior',
  41538. 'onequarter',
  41539. 'onehalf',
  41540. 'threequarters',
  41541. 'oneeighth',
  41542. 'threeeighths',
  41543. 'fiveeighths',
  41544. 'seveneighths',
  41545. 'onethird',
  41546. 'twothirds',
  41547. 'zerosuperior',
  41548. 'onesuperior',
  41549. 'twosuperior',
  41550. 'threesuperior',
  41551. 'foursuperior',
  41552. 'fivesuperior',
  41553. 'sixsuperior',
  41554. 'sevensuperior',
  41555. 'eightsuperior',
  41556. 'ninesuperior',
  41557. 'zeroinferior',
  41558. 'oneinferior',
  41559. 'twoinferior',
  41560. 'threeinferior',
  41561. 'fourinferior',
  41562. 'fiveinferior',
  41563. 'sixinferior',
  41564. 'seveninferior',
  41565. 'eightinferior',
  41566. 'nineinferior',
  41567. 'centinferior',
  41568. 'dollarinferior',
  41569. 'periodinferior',
  41570. 'commainferior'
  41571. ];
  41572. exports.ISOAdobeCharset = ISOAdobeCharset;
  41573. exports.ExpertCharset = ExpertCharset;
  41574. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  41575. /***/ }),
  41576. /* 30 */
  41577. /***/ (function(module, exports, __w_pdfjs_require__) {
  41578. "use strict";
  41579. var sharedUtil = __w_pdfjs_require__(0);
  41580. var corePrimitives = __w_pdfjs_require__(1);
  41581. var coreStream = __w_pdfjs_require__(2);
  41582. var coreParser = __w_pdfjs_require__(6);
  41583. var Util = sharedUtil.Util;
  41584. var assert = sharedUtil.assert;
  41585. var warn = sharedUtil.warn;
  41586. var error = sharedUtil.error;
  41587. var isInt = sharedUtil.isInt;
  41588. var isString = sharedUtil.isString;
  41589. var MissingDataException = sharedUtil.MissingDataException;
  41590. var CMapCompressionType = sharedUtil.CMapCompressionType;
  41591. var isEOF = corePrimitives.isEOF;
  41592. var isName = corePrimitives.isName;
  41593. var isCmd = corePrimitives.isCmd;
  41594. var isStream = corePrimitives.isStream;
  41595. var Stream = coreStream.Stream;
  41596. var Lexer = coreParser.Lexer;
  41597. var BUILT_IN_CMAPS = [
  41598. 'Adobe-GB1-UCS2',
  41599. 'Adobe-CNS1-UCS2',
  41600. 'Adobe-Japan1-UCS2',
  41601. 'Adobe-Korea1-UCS2',
  41602. '78-EUC-H',
  41603. '78-EUC-V',
  41604. '78-H',
  41605. '78-RKSJ-H',
  41606. '78-RKSJ-V',
  41607. '78-V',
  41608. '78ms-RKSJ-H',
  41609. '78ms-RKSJ-V',
  41610. '83pv-RKSJ-H',
  41611. '90ms-RKSJ-H',
  41612. '90ms-RKSJ-V',
  41613. '90msp-RKSJ-H',
  41614. '90msp-RKSJ-V',
  41615. '90pv-RKSJ-H',
  41616. '90pv-RKSJ-V',
  41617. 'Add-H',
  41618. 'Add-RKSJ-H',
  41619. 'Add-RKSJ-V',
  41620. 'Add-V',
  41621. 'Adobe-CNS1-0',
  41622. 'Adobe-CNS1-1',
  41623. 'Adobe-CNS1-2',
  41624. 'Adobe-CNS1-3',
  41625. 'Adobe-CNS1-4',
  41626. 'Adobe-CNS1-5',
  41627. 'Adobe-CNS1-6',
  41628. 'Adobe-GB1-0',
  41629. 'Adobe-GB1-1',
  41630. 'Adobe-GB1-2',
  41631. 'Adobe-GB1-3',
  41632. 'Adobe-GB1-4',
  41633. 'Adobe-GB1-5',
  41634. 'Adobe-Japan1-0',
  41635. 'Adobe-Japan1-1',
  41636. 'Adobe-Japan1-2',
  41637. 'Adobe-Japan1-3',
  41638. 'Adobe-Japan1-4',
  41639. 'Adobe-Japan1-5',
  41640. 'Adobe-Japan1-6',
  41641. 'Adobe-Korea1-0',
  41642. 'Adobe-Korea1-1',
  41643. 'Adobe-Korea1-2',
  41644. 'B5-H',
  41645. 'B5-V',
  41646. 'B5pc-H',
  41647. 'B5pc-V',
  41648. 'CNS-EUC-H',
  41649. 'CNS-EUC-V',
  41650. 'CNS1-H',
  41651. 'CNS1-V',
  41652. 'CNS2-H',
  41653. 'CNS2-V',
  41654. 'ETHK-B5-H',
  41655. 'ETHK-B5-V',
  41656. 'ETen-B5-H',
  41657. 'ETen-B5-V',
  41658. 'ETenms-B5-H',
  41659. 'ETenms-B5-V',
  41660. 'EUC-H',
  41661. 'EUC-V',
  41662. 'Ext-H',
  41663. 'Ext-RKSJ-H',
  41664. 'Ext-RKSJ-V',
  41665. 'Ext-V',
  41666. 'GB-EUC-H',
  41667. 'GB-EUC-V',
  41668. 'GB-H',
  41669. 'GB-V',
  41670. 'GBK-EUC-H',
  41671. 'GBK-EUC-V',
  41672. 'GBK2K-H',
  41673. 'GBK2K-V',
  41674. 'GBKp-EUC-H',
  41675. 'GBKp-EUC-V',
  41676. 'GBT-EUC-H',
  41677. 'GBT-EUC-V',
  41678. 'GBT-H',
  41679. 'GBT-V',
  41680. 'GBTpc-EUC-H',
  41681. 'GBTpc-EUC-V',
  41682. 'GBpc-EUC-H',
  41683. 'GBpc-EUC-V',
  41684. 'H',
  41685. 'HKdla-B5-H',
  41686. 'HKdla-B5-V',
  41687. 'HKdlb-B5-H',
  41688. 'HKdlb-B5-V',
  41689. 'HKgccs-B5-H',
  41690. 'HKgccs-B5-V',
  41691. 'HKm314-B5-H',
  41692. 'HKm314-B5-V',
  41693. 'HKm471-B5-H',
  41694. 'HKm471-B5-V',
  41695. 'HKscs-B5-H',
  41696. 'HKscs-B5-V',
  41697. 'Hankaku',
  41698. 'Hiragana',
  41699. 'KSC-EUC-H',
  41700. 'KSC-EUC-V',
  41701. 'KSC-H',
  41702. 'KSC-Johab-H',
  41703. 'KSC-Johab-V',
  41704. 'KSC-V',
  41705. 'KSCms-UHC-H',
  41706. 'KSCms-UHC-HW-H',
  41707. 'KSCms-UHC-HW-V',
  41708. 'KSCms-UHC-V',
  41709. 'KSCpc-EUC-H',
  41710. 'KSCpc-EUC-V',
  41711. 'Katakana',
  41712. 'NWP-H',
  41713. 'NWP-V',
  41714. 'RKSJ-H',
  41715. 'RKSJ-V',
  41716. 'Roman',
  41717. 'UniCNS-UCS2-H',
  41718. 'UniCNS-UCS2-V',
  41719. 'UniCNS-UTF16-H',
  41720. 'UniCNS-UTF16-V',
  41721. 'UniCNS-UTF32-H',
  41722. 'UniCNS-UTF32-V',
  41723. 'UniCNS-UTF8-H',
  41724. 'UniCNS-UTF8-V',
  41725. 'UniGB-UCS2-H',
  41726. 'UniGB-UCS2-V',
  41727. 'UniGB-UTF16-H',
  41728. 'UniGB-UTF16-V',
  41729. 'UniGB-UTF32-H',
  41730. 'UniGB-UTF32-V',
  41731. 'UniGB-UTF8-H',
  41732. 'UniGB-UTF8-V',
  41733. 'UniJIS-UCS2-H',
  41734. 'UniJIS-UCS2-HW-H',
  41735. 'UniJIS-UCS2-HW-V',
  41736. 'UniJIS-UCS2-V',
  41737. 'UniJIS-UTF16-H',
  41738. 'UniJIS-UTF16-V',
  41739. 'UniJIS-UTF32-H',
  41740. 'UniJIS-UTF32-V',
  41741. 'UniJIS-UTF8-H',
  41742. 'UniJIS-UTF8-V',
  41743. 'UniJIS2004-UTF16-H',
  41744. 'UniJIS2004-UTF16-V',
  41745. 'UniJIS2004-UTF32-H',
  41746. 'UniJIS2004-UTF32-V',
  41747. 'UniJIS2004-UTF8-H',
  41748. 'UniJIS2004-UTF8-V',
  41749. 'UniJISPro-UCS2-HW-V',
  41750. 'UniJISPro-UCS2-V',
  41751. 'UniJISPro-UTF8-V',
  41752. 'UniJISX0213-UTF32-H',
  41753. 'UniJISX0213-UTF32-V',
  41754. 'UniJISX02132004-UTF32-H',
  41755. 'UniJISX02132004-UTF32-V',
  41756. 'UniKS-UCS2-H',
  41757. 'UniKS-UCS2-V',
  41758. 'UniKS-UTF16-H',
  41759. 'UniKS-UTF16-V',
  41760. 'UniKS-UTF32-H',
  41761. 'UniKS-UTF32-V',
  41762. 'UniKS-UTF8-H',
  41763. 'UniKS-UTF8-V',
  41764. 'V',
  41765. 'WP-Symbol'
  41766. ];
  41767. var CMap = function CMapClosure() {
  41768. function CMap(builtInCMap) {
  41769. this.codespaceRanges = [
  41770. [],
  41771. [],
  41772. [],
  41773. []
  41774. ];
  41775. this.numCodespaceRanges = 0;
  41776. this._map = [];
  41777. this.name = '';
  41778. this.vertical = false;
  41779. this.useCMap = null;
  41780. this.builtInCMap = builtInCMap;
  41781. }
  41782. CMap.prototype = {
  41783. addCodespaceRange: function (n, low, high) {
  41784. this.codespaceRanges[n - 1].push(low, high);
  41785. this.numCodespaceRanges++;
  41786. },
  41787. mapCidRange: function (low, high, dstLow) {
  41788. while (low <= high) {
  41789. this._map[low++] = dstLow++;
  41790. }
  41791. },
  41792. mapBfRange: function (low, high, dstLow) {
  41793. var lastByte = dstLow.length - 1;
  41794. while (low <= high) {
  41795. this._map[low++] = dstLow;
  41796. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  41797. }
  41798. },
  41799. mapBfRangeToArray: function (low, high, array) {
  41800. var i = 0, ii = array.length;
  41801. while (low <= high && i < ii) {
  41802. this._map[low] = array[i++];
  41803. ++low;
  41804. }
  41805. },
  41806. mapOne: function (src, dst) {
  41807. this._map[src] = dst;
  41808. },
  41809. lookup: function (code) {
  41810. return this._map[code];
  41811. },
  41812. contains: function (code) {
  41813. return this._map[code] !== undefined;
  41814. },
  41815. forEach: function (callback) {
  41816. var map = this._map;
  41817. var length = map.length;
  41818. var i;
  41819. if (length <= 0x10000) {
  41820. for (i = 0; i < length; i++) {
  41821. if (map[i] !== undefined) {
  41822. callback(i, map[i]);
  41823. }
  41824. }
  41825. } else {
  41826. for (i in this._map) {
  41827. callback(i, map[i]);
  41828. }
  41829. }
  41830. },
  41831. charCodeOf: function (value) {
  41832. return this._map.indexOf(value);
  41833. },
  41834. getMap: function () {
  41835. return this._map;
  41836. },
  41837. readCharCode: function (str, offset, out) {
  41838. var c = 0;
  41839. var codespaceRanges = this.codespaceRanges;
  41840. var codespaceRangesLen = this.codespaceRanges.length;
  41841. for (var n = 0; n < codespaceRangesLen; n++) {
  41842. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  41843. var codespaceRange = codespaceRanges[n];
  41844. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  41845. var low = codespaceRange[k++];
  41846. var high = codespaceRange[k++];
  41847. if (c >= low && c <= high) {
  41848. out.charcode = c;
  41849. out.length = n + 1;
  41850. return;
  41851. }
  41852. }
  41853. }
  41854. out.charcode = 0;
  41855. out.length = 1;
  41856. },
  41857. get length() {
  41858. return this._map.length;
  41859. },
  41860. get isIdentityCMap() {
  41861. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  41862. return false;
  41863. }
  41864. if (this._map.length !== 0x10000) {
  41865. return false;
  41866. }
  41867. for (var i = 0; i < 0x10000; i++) {
  41868. if (this._map[i] !== i) {
  41869. return false;
  41870. }
  41871. }
  41872. return true;
  41873. }
  41874. };
  41875. return CMap;
  41876. }();
  41877. var IdentityCMap = function IdentityCMapClosure() {
  41878. function IdentityCMap(vertical, n) {
  41879. CMap.call(this);
  41880. this.vertical = vertical;
  41881. this.addCodespaceRange(n, 0, 0xffff);
  41882. }
  41883. Util.inherit(IdentityCMap, CMap, {});
  41884. IdentityCMap.prototype = {
  41885. addCodespaceRange: CMap.prototype.addCodespaceRange,
  41886. mapCidRange: function (low, high, dstLow) {
  41887. error('should not call mapCidRange');
  41888. },
  41889. mapBfRange: function (low, high, dstLow) {
  41890. error('should not call mapBfRange');
  41891. },
  41892. mapBfRangeToArray: function (low, high, array) {
  41893. error('should not call mapBfRangeToArray');
  41894. },
  41895. mapOne: function (src, dst) {
  41896. error('should not call mapCidOne');
  41897. },
  41898. lookup: function (code) {
  41899. return isInt(code) && code <= 0xffff ? code : undefined;
  41900. },
  41901. contains: function (code) {
  41902. return isInt(code) && code <= 0xffff;
  41903. },
  41904. forEach: function (callback) {
  41905. for (var i = 0; i <= 0xffff; i++) {
  41906. callback(i, i);
  41907. }
  41908. },
  41909. charCodeOf: function (value) {
  41910. return isInt(value) && value <= 0xffff ? value : -1;
  41911. },
  41912. getMap: function () {
  41913. var map = new Array(0x10000);
  41914. for (var i = 0; i <= 0xffff; i++) {
  41915. map[i] = i;
  41916. }
  41917. return map;
  41918. },
  41919. readCharCode: CMap.prototype.readCharCode,
  41920. get length() {
  41921. return 0x10000;
  41922. },
  41923. get isIdentityCMap() {
  41924. error('should not access .isIdentityCMap');
  41925. }
  41926. };
  41927. return IdentityCMap;
  41928. }();
  41929. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  41930. function hexToInt(a, size) {
  41931. var n = 0;
  41932. for (var i = 0; i <= size; i++) {
  41933. n = n << 8 | a[i];
  41934. }
  41935. return n >>> 0;
  41936. }
  41937. function hexToStr(a, size) {
  41938. if (size === 1) {
  41939. return String.fromCharCode(a[0], a[1]);
  41940. }
  41941. if (size === 3) {
  41942. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  41943. }
  41944. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  41945. }
  41946. function addHex(a, b, size) {
  41947. var c = 0;
  41948. for (var i = size; i >= 0; i--) {
  41949. c += a[i] + b[i];
  41950. a[i] = c & 255;
  41951. c >>= 8;
  41952. }
  41953. }
  41954. function incHex(a, size) {
  41955. var c = 1;
  41956. for (var i = size; i >= 0 && c > 0; i--) {
  41957. c += a[i];
  41958. a[i] = c & 255;
  41959. c >>= 8;
  41960. }
  41961. }
  41962. var MAX_NUM_SIZE = 16;
  41963. var MAX_ENCODED_NUM_SIZE = 19;
  41964. function BinaryCMapStream(data) {
  41965. this.buffer = data;
  41966. this.pos = 0;
  41967. this.end = data.length;
  41968. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  41969. }
  41970. BinaryCMapStream.prototype = {
  41971. readByte: function () {
  41972. if (this.pos >= this.end) {
  41973. return -1;
  41974. }
  41975. return this.buffer[this.pos++];
  41976. },
  41977. readNumber: function () {
  41978. var n = 0;
  41979. var last;
  41980. do {
  41981. var b = this.readByte();
  41982. if (b < 0) {
  41983. error('unexpected EOF in bcmap');
  41984. }
  41985. last = !(b & 0x80);
  41986. n = n << 7 | b & 0x7F;
  41987. } while (!last);
  41988. return n;
  41989. },
  41990. readSigned: function () {
  41991. var n = this.readNumber();
  41992. return n & 1 ? ~(n >>> 1) : n >>> 1;
  41993. },
  41994. readHex: function (num, size) {
  41995. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  41996. this.pos += size + 1;
  41997. },
  41998. readHexNumber: function (num, size) {
  41999. var last;
  42000. var stack = this.tmpBuf, sp = 0;
  42001. do {
  42002. var b = this.readByte();
  42003. if (b < 0) {
  42004. error('unexpected EOF in bcmap');
  42005. }
  42006. last = !(b & 0x80);
  42007. stack[sp++] = b & 0x7F;
  42008. } while (!last);
  42009. var i = size, buffer = 0, bufferSize = 0;
  42010. while (i >= 0) {
  42011. while (bufferSize < 8 && stack.length > 0) {
  42012. buffer = stack[--sp] << bufferSize | buffer;
  42013. bufferSize += 7;
  42014. }
  42015. num[i] = buffer & 255;
  42016. i--;
  42017. buffer >>= 8;
  42018. bufferSize -= 8;
  42019. }
  42020. },
  42021. readHexSigned: function (num, size) {
  42022. this.readHexNumber(num, size);
  42023. var sign = num[size] & 1 ? 255 : 0;
  42024. var c = 0;
  42025. for (var i = 0; i <= size; i++) {
  42026. c = (c & 1) << 8 | num[i];
  42027. num[i] = c >> 1 ^ sign;
  42028. }
  42029. },
  42030. readString: function () {
  42031. var len = this.readNumber();
  42032. var s = '';
  42033. for (var i = 0; i < len; i++) {
  42034. s += String.fromCharCode(this.readNumber());
  42035. }
  42036. return s;
  42037. }
  42038. };
  42039. function processBinaryCMap(data, cMap, extend) {
  42040. return new Promise(function (resolve, reject) {
  42041. var stream = new BinaryCMapStream(data);
  42042. var header = stream.readByte();
  42043. cMap.vertical = !!(header & 1);
  42044. var useCMap = null;
  42045. var start = new Uint8Array(MAX_NUM_SIZE);
  42046. var end = new Uint8Array(MAX_NUM_SIZE);
  42047. var char = new Uint8Array(MAX_NUM_SIZE);
  42048. var charCode = new Uint8Array(MAX_NUM_SIZE);
  42049. var tmp = new Uint8Array(MAX_NUM_SIZE);
  42050. var code;
  42051. var b;
  42052. while ((b = stream.readByte()) >= 0) {
  42053. var type = b >> 5;
  42054. if (type === 7) {
  42055. switch (b & 0x1F) {
  42056. case 0:
  42057. stream.readString();
  42058. break;
  42059. case 1:
  42060. useCMap = stream.readString();
  42061. break;
  42062. }
  42063. continue;
  42064. }
  42065. var sequence = !!(b & 0x10);
  42066. var dataSize = b & 15;
  42067. assert(dataSize + 1 <= MAX_NUM_SIZE);
  42068. var ucs2DataSize = 1;
  42069. var subitemsCount = stream.readNumber();
  42070. var i;
  42071. switch (type) {
  42072. case 0:
  42073. stream.readHex(start, dataSize);
  42074. stream.readHexNumber(end, dataSize);
  42075. addHex(end, start, dataSize);
  42076. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  42077. for (i = 1; i < subitemsCount; i++) {
  42078. incHex(end, dataSize);
  42079. stream.readHexNumber(start, dataSize);
  42080. addHex(start, end, dataSize);
  42081. stream.readHexNumber(end, dataSize);
  42082. addHex(end, start, dataSize);
  42083. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  42084. }
  42085. break;
  42086. case 1:
  42087. stream.readHex(start, dataSize);
  42088. stream.readHexNumber(end, dataSize);
  42089. addHex(end, start, dataSize);
  42090. code = stream.readNumber();
  42091. for (i = 1; i < subitemsCount; i++) {
  42092. incHex(end, dataSize);
  42093. stream.readHexNumber(start, dataSize);
  42094. addHex(start, end, dataSize);
  42095. stream.readHexNumber(end, dataSize);
  42096. addHex(end, start, dataSize);
  42097. code = stream.readNumber();
  42098. }
  42099. break;
  42100. case 2:
  42101. stream.readHex(char, dataSize);
  42102. code = stream.readNumber();
  42103. cMap.mapOne(hexToInt(char, dataSize), code);
  42104. for (i = 1; i < subitemsCount; i++) {
  42105. incHex(char, dataSize);
  42106. if (!sequence) {
  42107. stream.readHexNumber(tmp, dataSize);
  42108. addHex(char, tmp, dataSize);
  42109. }
  42110. code = stream.readSigned() + (code + 1);
  42111. cMap.mapOne(hexToInt(char, dataSize), code);
  42112. }
  42113. break;
  42114. case 3:
  42115. stream.readHex(start, dataSize);
  42116. stream.readHexNumber(end, dataSize);
  42117. addHex(end, start, dataSize);
  42118. code = stream.readNumber();
  42119. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  42120. for (i = 1; i < subitemsCount; i++) {
  42121. incHex(end, dataSize);
  42122. if (!sequence) {
  42123. stream.readHexNumber(start, dataSize);
  42124. addHex(start, end, dataSize);
  42125. } else {
  42126. start.set(end);
  42127. }
  42128. stream.readHexNumber(end, dataSize);
  42129. addHex(end, start, dataSize);
  42130. code = stream.readNumber();
  42131. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  42132. }
  42133. break;
  42134. case 4:
  42135. stream.readHex(char, ucs2DataSize);
  42136. stream.readHex(charCode, dataSize);
  42137. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  42138. for (i = 1; i < subitemsCount; i++) {
  42139. incHex(char, ucs2DataSize);
  42140. if (!sequence) {
  42141. stream.readHexNumber(tmp, ucs2DataSize);
  42142. addHex(char, tmp, ucs2DataSize);
  42143. }
  42144. incHex(charCode, dataSize);
  42145. stream.readHexSigned(tmp, dataSize);
  42146. addHex(charCode, tmp, dataSize);
  42147. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  42148. }
  42149. break;
  42150. case 5:
  42151. stream.readHex(start, ucs2DataSize);
  42152. stream.readHexNumber(end, ucs2DataSize);
  42153. addHex(end, start, ucs2DataSize);
  42154. stream.readHex(charCode, dataSize);
  42155. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  42156. for (i = 1; i < subitemsCount; i++) {
  42157. incHex(end, ucs2DataSize);
  42158. if (!sequence) {
  42159. stream.readHexNumber(start, ucs2DataSize);
  42160. addHex(start, end, ucs2DataSize);
  42161. } else {
  42162. start.set(end);
  42163. }
  42164. stream.readHexNumber(end, ucs2DataSize);
  42165. addHex(end, start, ucs2DataSize);
  42166. stream.readHex(charCode, dataSize);
  42167. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  42168. }
  42169. break;
  42170. default:
  42171. reject(new Error('processBinaryCMap: Unknown type: ' + type));
  42172. return;
  42173. }
  42174. }
  42175. if (useCMap) {
  42176. resolve(extend(useCMap));
  42177. return;
  42178. }
  42179. resolve(cMap);
  42180. });
  42181. }
  42182. function BinaryCMapReader() {
  42183. }
  42184. BinaryCMapReader.prototype = { process: processBinaryCMap };
  42185. return BinaryCMapReader;
  42186. }();
  42187. var CMapFactory = function CMapFactoryClosure() {
  42188. function strToInt(str) {
  42189. var a = 0;
  42190. for (var i = 0; i < str.length; i++) {
  42191. a = a << 8 | str.charCodeAt(i);
  42192. }
  42193. return a >>> 0;
  42194. }
  42195. function expectString(obj) {
  42196. if (!isString(obj)) {
  42197. error('Malformed CMap: expected string.');
  42198. }
  42199. }
  42200. function expectInt(obj) {
  42201. if (!isInt(obj)) {
  42202. error('Malformed CMap: expected int.');
  42203. }
  42204. }
  42205. function parseBfChar(cMap, lexer) {
  42206. while (true) {
  42207. var obj = lexer.getObj();
  42208. if (isEOF(obj)) {
  42209. break;
  42210. }
  42211. if (isCmd(obj, 'endbfchar')) {
  42212. return;
  42213. }
  42214. expectString(obj);
  42215. var src = strToInt(obj);
  42216. obj = lexer.getObj();
  42217. expectString(obj);
  42218. var dst = obj;
  42219. cMap.mapOne(src, dst);
  42220. }
  42221. }
  42222. function parseBfRange(cMap, lexer) {
  42223. while (true) {
  42224. var obj = lexer.getObj();
  42225. if (isEOF(obj)) {
  42226. break;
  42227. }
  42228. if (isCmd(obj, 'endbfrange')) {
  42229. return;
  42230. }
  42231. expectString(obj);
  42232. var low = strToInt(obj);
  42233. obj = lexer.getObj();
  42234. expectString(obj);
  42235. var high = strToInt(obj);
  42236. obj = lexer.getObj();
  42237. if (isInt(obj) || isString(obj)) {
  42238. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  42239. cMap.mapBfRange(low, high, dstLow);
  42240. } else if (isCmd(obj, '[')) {
  42241. obj = lexer.getObj();
  42242. var array = [];
  42243. while (!isCmd(obj, ']') && !isEOF(obj)) {
  42244. array.push(obj);
  42245. obj = lexer.getObj();
  42246. }
  42247. cMap.mapBfRangeToArray(low, high, array);
  42248. } else {
  42249. break;
  42250. }
  42251. }
  42252. error('Invalid bf range.');
  42253. }
  42254. function parseCidChar(cMap, lexer) {
  42255. while (true) {
  42256. var obj = lexer.getObj();
  42257. if (isEOF(obj)) {
  42258. break;
  42259. }
  42260. if (isCmd(obj, 'endcidchar')) {
  42261. return;
  42262. }
  42263. expectString(obj);
  42264. var src = strToInt(obj);
  42265. obj = lexer.getObj();
  42266. expectInt(obj);
  42267. var dst = obj;
  42268. cMap.mapOne(src, dst);
  42269. }
  42270. }
  42271. function parseCidRange(cMap, lexer) {
  42272. while (true) {
  42273. var obj = lexer.getObj();
  42274. if (isEOF(obj)) {
  42275. break;
  42276. }
  42277. if (isCmd(obj, 'endcidrange')) {
  42278. return;
  42279. }
  42280. expectString(obj);
  42281. var low = strToInt(obj);
  42282. obj = lexer.getObj();
  42283. expectString(obj);
  42284. var high = strToInt(obj);
  42285. obj = lexer.getObj();
  42286. expectInt(obj);
  42287. var dstLow = obj;
  42288. cMap.mapCidRange(low, high, dstLow);
  42289. }
  42290. }
  42291. function parseCodespaceRange(cMap, lexer) {
  42292. while (true) {
  42293. var obj = lexer.getObj();
  42294. if (isEOF(obj)) {
  42295. break;
  42296. }
  42297. if (isCmd(obj, 'endcodespacerange')) {
  42298. return;
  42299. }
  42300. if (!isString(obj)) {
  42301. break;
  42302. }
  42303. var low = strToInt(obj);
  42304. obj = lexer.getObj();
  42305. if (!isString(obj)) {
  42306. break;
  42307. }
  42308. var high = strToInt(obj);
  42309. cMap.addCodespaceRange(obj.length, low, high);
  42310. }
  42311. error('Invalid codespace range.');
  42312. }
  42313. function parseWMode(cMap, lexer) {
  42314. var obj = lexer.getObj();
  42315. if (isInt(obj)) {
  42316. cMap.vertical = !!obj;
  42317. }
  42318. }
  42319. function parseCMapName(cMap, lexer) {
  42320. var obj = lexer.getObj();
  42321. if (isName(obj) && isString(obj.name)) {
  42322. cMap.name = obj.name;
  42323. }
  42324. }
  42325. function parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap) {
  42326. var previous;
  42327. var embededUseCMap;
  42328. objLoop:
  42329. while (true) {
  42330. try {
  42331. var obj = lexer.getObj();
  42332. if (isEOF(obj)) {
  42333. break;
  42334. } else if (isName(obj)) {
  42335. if (obj.name === 'WMode') {
  42336. parseWMode(cMap, lexer);
  42337. } else if (obj.name === 'CMapName') {
  42338. parseCMapName(cMap, lexer);
  42339. }
  42340. previous = obj;
  42341. } else if (isCmd(obj)) {
  42342. switch (obj.cmd) {
  42343. case 'endcmap':
  42344. break objLoop;
  42345. case 'usecmap':
  42346. if (isName(previous)) {
  42347. embededUseCMap = previous.name;
  42348. }
  42349. break;
  42350. case 'begincodespacerange':
  42351. parseCodespaceRange(cMap, lexer);
  42352. break;
  42353. case 'beginbfchar':
  42354. parseBfChar(cMap, lexer);
  42355. break;
  42356. case 'begincidchar':
  42357. parseCidChar(cMap, lexer);
  42358. break;
  42359. case 'beginbfrange':
  42360. parseBfRange(cMap, lexer);
  42361. break;
  42362. case 'begincidrange':
  42363. parseCidRange(cMap, lexer);
  42364. break;
  42365. }
  42366. }
  42367. } catch (ex) {
  42368. if (ex instanceof MissingDataException) {
  42369. throw ex;
  42370. }
  42371. warn('Invalid cMap data: ' + ex);
  42372. continue;
  42373. }
  42374. }
  42375. if (!useCMap && embededUseCMap) {
  42376. useCMap = embededUseCMap;
  42377. }
  42378. if (useCMap) {
  42379. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  42380. }
  42381. return Promise.resolve(cMap);
  42382. }
  42383. function extendCMap(cMap, fetchBuiltInCMap, useCMap) {
  42384. return createBuiltInCMap(useCMap, fetchBuiltInCMap).then(function (newCMap) {
  42385. cMap.useCMap = newCMap;
  42386. if (cMap.numCodespaceRanges === 0) {
  42387. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  42388. for (var i = 0; i < useCodespaceRanges.length; i++) {
  42389. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  42390. }
  42391. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  42392. }
  42393. cMap.useCMap.forEach(function (key, value) {
  42394. if (!cMap.contains(key)) {
  42395. cMap.mapOne(key, cMap.useCMap.lookup(key));
  42396. }
  42397. });
  42398. return cMap;
  42399. });
  42400. }
  42401. function createBuiltInCMap(name, fetchBuiltInCMap) {
  42402. if (name === 'Identity-H') {
  42403. return Promise.resolve(new IdentityCMap(false, 2));
  42404. } else if (name === 'Identity-V') {
  42405. return Promise.resolve(new IdentityCMap(true, 2));
  42406. }
  42407. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  42408. return Promise.reject(new Error('Unknown cMap name: ' + name));
  42409. }
  42410. assert(fetchBuiltInCMap, 'Built-in CMap parameters are not provided.');
  42411. return fetchBuiltInCMap(name).then(function (data) {
  42412. var cMapData = data.cMapData, compressionType = data.compressionType;
  42413. var cMap = new CMap(true);
  42414. if (compressionType === CMapCompressionType.BINARY) {
  42415. return new BinaryCMapReader().process(cMapData, cMap, function (useCMap) {
  42416. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  42417. });
  42418. }
  42419. assert(compressionType === CMapCompressionType.NONE, 'TODO: Only BINARY/NONE CMap compression is currently supported.');
  42420. var lexer = new Lexer(new Stream(cMapData));
  42421. return parseCMap(cMap, lexer, fetchBuiltInCMap, null);
  42422. });
  42423. }
  42424. return {
  42425. create: function (params) {
  42426. var encoding = params.encoding;
  42427. var fetchBuiltInCMap = params.fetchBuiltInCMap;
  42428. var useCMap = params.useCMap;
  42429. if (isName(encoding)) {
  42430. return createBuiltInCMap(encoding.name, fetchBuiltInCMap);
  42431. } else if (isStream(encoding)) {
  42432. var cMap = new CMap();
  42433. var lexer = new Lexer(encoding);
  42434. return parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap).then(function (parsedCMap) {
  42435. if (parsedCMap.isIdentityCMap) {
  42436. return createBuiltInCMap(parsedCMap.name, fetchBuiltInCMap);
  42437. }
  42438. return parsedCMap;
  42439. });
  42440. }
  42441. return Promise.reject(new Error('Encoding required.'));
  42442. }
  42443. };
  42444. }();
  42445. exports.CMap = CMap;
  42446. exports.CMapFactory = CMapFactory;
  42447. exports.IdentityCMap = IdentityCMap;
  42448. /***/ }),
  42449. /* 31 */
  42450. /***/ (function(module, exports, __w_pdfjs_require__) {
  42451. "use strict";
  42452. var sharedUtil = __w_pdfjs_require__(0);
  42453. var corePrimitives = __w_pdfjs_require__(1);
  42454. var coreStream = __w_pdfjs_require__(2);
  42455. var coreObj = __w_pdfjs_require__(19);
  42456. var coreParser = __w_pdfjs_require__(6);
  42457. var coreCrypto = __w_pdfjs_require__(16);
  42458. var coreEvaluator = __w_pdfjs_require__(17);
  42459. var coreAnnotation = __w_pdfjs_require__(27);
  42460. var MissingDataException = sharedUtil.MissingDataException;
  42461. var Util = sharedUtil.Util;
  42462. var assert = sharedUtil.assert;
  42463. var error = sharedUtil.error;
  42464. var info = sharedUtil.info;
  42465. var isArray = sharedUtil.isArray;
  42466. var isArrayBuffer = sharedUtil.isArrayBuffer;
  42467. var isNum = sharedUtil.isNum;
  42468. var isString = sharedUtil.isString;
  42469. var shadow = sharedUtil.shadow;
  42470. var stringToBytes = sharedUtil.stringToBytes;
  42471. var stringToPDFString = sharedUtil.stringToPDFString;
  42472. var warn = sharedUtil.warn;
  42473. var isSpace = sharedUtil.isSpace;
  42474. var Dict = corePrimitives.Dict;
  42475. var isDict = corePrimitives.isDict;
  42476. var isName = corePrimitives.isName;
  42477. var isStream = corePrimitives.isStream;
  42478. var NullStream = coreStream.NullStream;
  42479. var Stream = coreStream.Stream;
  42480. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  42481. var Catalog = coreObj.Catalog;
  42482. var ObjectLoader = coreObj.ObjectLoader;
  42483. var XRef = coreObj.XRef;
  42484. var Linearization = coreParser.Linearization;
  42485. var calculateMD5 = coreCrypto.calculateMD5;
  42486. var OperatorList = coreEvaluator.OperatorList;
  42487. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  42488. var Annotation = coreAnnotation.Annotation;
  42489. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  42490. var Page = function PageClosure() {
  42491. var DEFAULT_USER_UNIT = 1.0;
  42492. var LETTER_SIZE_MEDIABOX = [
  42493. 0,
  42494. 0,
  42495. 612,
  42496. 792
  42497. ];
  42498. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache, builtInCMapCache) {
  42499. this.pdfManager = pdfManager;
  42500. this.pageIndex = pageIndex;
  42501. this.pageDict = pageDict;
  42502. this.xref = xref;
  42503. this.ref = ref;
  42504. this.fontCache = fontCache;
  42505. this.builtInCMapCache = builtInCMapCache;
  42506. this.evaluatorOptions = pdfManager.evaluatorOptions;
  42507. this.resourcesPromise = null;
  42508. var uniquePrefix = 'p' + this.pageIndex + '_';
  42509. var idCounters = { obj: 0 };
  42510. this.idFactory = {
  42511. createObjId: function () {
  42512. return uniquePrefix + ++idCounters.obj;
  42513. }
  42514. };
  42515. }
  42516. Page.prototype = {
  42517. getPageProp: function Page_getPageProp(key) {
  42518. return this.pageDict.get(key);
  42519. },
  42520. getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
  42521. var dict = this.pageDict, valueArray = null, loopCount = 0;
  42522. var MAX_LOOP_COUNT = 100;
  42523. getArray = getArray || false;
  42524. while (dict) {
  42525. var value = getArray ? dict.getArray(key) : dict.get(key);
  42526. if (value) {
  42527. if (!valueArray) {
  42528. valueArray = [];
  42529. }
  42530. valueArray.push(value);
  42531. }
  42532. if (++loopCount > MAX_LOOP_COUNT) {
  42533. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  42534. break;
  42535. }
  42536. dict = dict.get('Parent');
  42537. }
  42538. if (!valueArray) {
  42539. return Dict.empty;
  42540. }
  42541. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  42542. return valueArray[0];
  42543. }
  42544. return Dict.merge(this.xref, valueArray);
  42545. },
  42546. get content() {
  42547. return this.getPageProp('Contents');
  42548. },
  42549. get resources() {
  42550. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  42551. },
  42552. get mediaBox() {
  42553. var mediaBox = this.getInheritedPageProp('MediaBox', true);
  42554. if (!isArray(mediaBox) || mediaBox.length !== 4) {
  42555. return shadow(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
  42556. }
  42557. return shadow(this, 'mediaBox', mediaBox);
  42558. },
  42559. get cropBox() {
  42560. var cropBox = this.getInheritedPageProp('CropBox', true);
  42561. if (!isArray(cropBox) || cropBox.length !== 4) {
  42562. return shadow(this, 'cropBox', this.mediaBox);
  42563. }
  42564. return shadow(this, 'cropBox', cropBox);
  42565. },
  42566. get userUnit() {
  42567. var obj = this.getPageProp('UserUnit');
  42568. if (!isNum(obj) || obj <= 0) {
  42569. obj = DEFAULT_USER_UNIT;
  42570. }
  42571. return shadow(this, 'userUnit', obj);
  42572. },
  42573. get view() {
  42574. var mediaBox = this.mediaBox, cropBox = this.cropBox;
  42575. if (mediaBox === cropBox) {
  42576. return shadow(this, 'view', mediaBox);
  42577. }
  42578. var intersection = Util.intersect(cropBox, mediaBox);
  42579. return shadow(this, 'view', intersection || mediaBox);
  42580. },
  42581. get rotate() {
  42582. var rotate = this.getInheritedPageProp('Rotate') || 0;
  42583. if (rotate % 90 !== 0) {
  42584. rotate = 0;
  42585. } else if (rotate >= 360) {
  42586. rotate = rotate % 360;
  42587. } else if (rotate < 0) {
  42588. rotate = (rotate % 360 + 360) % 360;
  42589. }
  42590. return shadow(this, 'rotate', rotate);
  42591. },
  42592. getContentStream: function Page_getContentStream() {
  42593. var content = this.content;
  42594. var stream;
  42595. if (isArray(content)) {
  42596. var xref = this.xref;
  42597. var i, n = content.length;
  42598. var streams = [];
  42599. for (i = 0; i < n; ++i) {
  42600. streams.push(xref.fetchIfRef(content[i]));
  42601. }
  42602. stream = new StreamsSequenceStream(streams);
  42603. } else if (isStream(content)) {
  42604. stream = content;
  42605. } else {
  42606. stream = new NullStream();
  42607. }
  42608. return stream;
  42609. },
  42610. loadResources: function Page_loadResources(keys) {
  42611. if (!this.resourcesPromise) {
  42612. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  42613. }
  42614. return this.resourcesPromise.then(function resourceSuccess() {
  42615. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  42616. return objectLoader.load();
  42617. }.bind(this));
  42618. },
  42619. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  42620. var self = this;
  42621. var pdfManager = this.pdfManager;
  42622. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  42623. var resourcesPromise = this.loadResources([
  42624. 'ExtGState',
  42625. 'ColorSpace',
  42626. 'Pattern',
  42627. 'Shading',
  42628. 'XObject',
  42629. 'Font'
  42630. ]);
  42631. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.idFactory, this.fontCache, this.builtInCMapCache, this.evaluatorOptions);
  42632. var dataPromises = Promise.all([
  42633. contentStreamPromise,
  42634. resourcesPromise
  42635. ]);
  42636. var pageListPromise = dataPromises.then(function (data) {
  42637. var contentStream = data[0];
  42638. var opList = new OperatorList(intent, handler, self.pageIndex);
  42639. handler.send('StartRenderPage', {
  42640. transparency: partialEvaluator.hasBlendModes(self.resources),
  42641. pageIndex: self.pageIndex,
  42642. intent: intent
  42643. });
  42644. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  42645. return opList;
  42646. });
  42647. });
  42648. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  42649. return Promise.all([
  42650. pageListPromise,
  42651. annotationsPromise
  42652. ]).then(function (datas) {
  42653. var pageOpList = datas[0];
  42654. var annotations = datas[1];
  42655. if (annotations.length === 0) {
  42656. pageOpList.flush(true);
  42657. return pageOpList;
  42658. }
  42659. var annotationsReadyPromise = Annotation.appendToOperatorList(annotations, pageOpList, partialEvaluator, task, intent, renderInteractiveForms);
  42660. return annotationsReadyPromise.then(function () {
  42661. pageOpList.flush(true);
  42662. return pageOpList;
  42663. });
  42664. });
  42665. },
  42666. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  42667. var handler = {
  42668. on: function nullHandlerOn() {
  42669. },
  42670. send: function nullHandlerSend() {
  42671. }
  42672. };
  42673. var self = this;
  42674. var pdfManager = this.pdfManager;
  42675. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  42676. var resourcesPromise = this.loadResources([
  42677. 'ExtGState',
  42678. 'XObject',
  42679. 'Font'
  42680. ]);
  42681. var dataPromises = Promise.all([
  42682. contentStreamPromise,
  42683. resourcesPromise
  42684. ]);
  42685. return dataPromises.then(function (data) {
  42686. var contentStream = data[0];
  42687. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.idFactory, self.fontCache, self.builtInCMapCache, self.evaluatorOptions);
  42688. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  42689. });
  42690. },
  42691. getAnnotationsData: function Page_getAnnotationsData(intent) {
  42692. var annotations = this.annotations;
  42693. var annotationsData = [];
  42694. for (var i = 0, n = annotations.length; i < n; ++i) {
  42695. if (intent) {
  42696. if (!(intent === 'display' && annotations[i].viewable) && !(intent === 'print' && annotations[i].printable)) {
  42697. continue;
  42698. }
  42699. }
  42700. annotationsData.push(annotations[i].data);
  42701. }
  42702. return annotationsData;
  42703. },
  42704. get annotations() {
  42705. var annotations = [];
  42706. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  42707. var annotationFactory = new AnnotationFactory();
  42708. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  42709. var annotationRef = annotationRefs[i];
  42710. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory);
  42711. if (annotation) {
  42712. annotations.push(annotation);
  42713. }
  42714. }
  42715. return shadow(this, 'annotations', annotations);
  42716. }
  42717. };
  42718. return Page;
  42719. }();
  42720. var PDFDocument = function PDFDocumentClosure() {
  42721. var FINGERPRINT_FIRST_BYTES = 1024;
  42722. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  42723. function PDFDocument(pdfManager, arg) {
  42724. var stream;
  42725. if (isStream(arg)) {
  42726. stream = arg;
  42727. } else if (isArrayBuffer(arg)) {
  42728. stream = new Stream(arg);
  42729. } else {
  42730. error('PDFDocument: Unknown argument type');
  42731. }
  42732. assert(stream.length > 0, 'stream must have data');
  42733. this.pdfManager = pdfManager;
  42734. this.stream = stream;
  42735. this.xref = new XRef(stream, pdfManager);
  42736. }
  42737. function find(stream, needle, limit, backwards) {
  42738. var pos = stream.pos;
  42739. var end = stream.end;
  42740. var strBuf = [];
  42741. if (pos + limit > end) {
  42742. limit = end - pos;
  42743. }
  42744. for (var n = 0; n < limit; ++n) {
  42745. strBuf.push(String.fromCharCode(stream.getByte()));
  42746. }
  42747. var str = strBuf.join('');
  42748. stream.pos = pos;
  42749. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  42750. if (index === -1) {
  42751. return false;
  42752. }
  42753. stream.pos += index;
  42754. return true;
  42755. }
  42756. var DocumentInfoValidators = {
  42757. get entries() {
  42758. return shadow(this, 'entries', {
  42759. Title: isString,
  42760. Author: isString,
  42761. Subject: isString,
  42762. Keywords: isString,
  42763. Creator: isString,
  42764. Producer: isString,
  42765. CreationDate: isString,
  42766. ModDate: isString,
  42767. Trapped: isName
  42768. });
  42769. }
  42770. };
  42771. PDFDocument.prototype = {
  42772. parse: function PDFDocument_parse(recoveryMode) {
  42773. this.setup(recoveryMode);
  42774. var version = this.catalog.catDict.get('Version');
  42775. if (isName(version)) {
  42776. this.pdfFormatVersion = version.name;
  42777. }
  42778. try {
  42779. this.acroForm = this.catalog.catDict.get('AcroForm');
  42780. if (this.acroForm) {
  42781. this.xfa = this.acroForm.get('XFA');
  42782. var fields = this.acroForm.get('Fields');
  42783. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  42784. this.acroForm = null;
  42785. }
  42786. }
  42787. } catch (ex) {
  42788. info('Something wrong with AcroForm entry');
  42789. this.acroForm = null;
  42790. }
  42791. },
  42792. get linearization() {
  42793. var linearization = null;
  42794. if (this.stream.length) {
  42795. try {
  42796. linearization = Linearization.create(this.stream);
  42797. } catch (err) {
  42798. if (err instanceof MissingDataException) {
  42799. throw err;
  42800. }
  42801. info(err);
  42802. }
  42803. }
  42804. return shadow(this, 'linearization', linearization);
  42805. },
  42806. get startXRef() {
  42807. var stream = this.stream;
  42808. var startXRef = 0;
  42809. var linearization = this.linearization;
  42810. if (linearization) {
  42811. stream.reset();
  42812. if (find(stream, 'endobj', 1024)) {
  42813. startXRef = stream.pos + 6;
  42814. }
  42815. } else {
  42816. var step = 1024;
  42817. var found = false, pos = stream.end;
  42818. while (!found && pos > 0) {
  42819. pos -= step - 'startxref'.length;
  42820. if (pos < 0) {
  42821. pos = 0;
  42822. }
  42823. stream.pos = pos;
  42824. found = find(stream, 'startxref', step, true);
  42825. }
  42826. if (found) {
  42827. stream.skip(9);
  42828. var ch;
  42829. do {
  42830. ch = stream.getByte();
  42831. } while (isSpace(ch));
  42832. var str = '';
  42833. while (ch >= 0x20 && ch <= 0x39) {
  42834. str += String.fromCharCode(ch);
  42835. ch = stream.getByte();
  42836. }
  42837. startXRef = parseInt(str, 10);
  42838. if (isNaN(startXRef)) {
  42839. startXRef = 0;
  42840. }
  42841. }
  42842. }
  42843. return shadow(this, 'startXRef', startXRef);
  42844. },
  42845. get mainXRefEntriesOffset() {
  42846. var mainXRefEntriesOffset = 0;
  42847. var linearization = this.linearization;
  42848. if (linearization) {
  42849. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  42850. }
  42851. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  42852. },
  42853. checkHeader: function PDFDocument_checkHeader() {
  42854. var stream = this.stream;
  42855. stream.reset();
  42856. if (find(stream, '%PDF-', 1024)) {
  42857. stream.moveStart();
  42858. var MAX_VERSION_LENGTH = 12;
  42859. var version = '', ch;
  42860. while ((ch = stream.getByte()) > 0x20) {
  42861. if (version.length >= MAX_VERSION_LENGTH) {
  42862. break;
  42863. }
  42864. version += String.fromCharCode(ch);
  42865. }
  42866. if (!this.pdfFormatVersion) {
  42867. this.pdfFormatVersion = version.substring(5);
  42868. }
  42869. return;
  42870. }
  42871. },
  42872. parseStartXRef: function PDFDocument_parseStartXRef() {
  42873. var startXRef = this.startXRef;
  42874. this.xref.setStartXRef(startXRef);
  42875. },
  42876. setup: function PDFDocument_setup(recoveryMode) {
  42877. this.xref.parse(recoveryMode);
  42878. var self = this;
  42879. var pageFactory = {
  42880. createPage: function (pageIndex, dict, ref, fontCache, builtInCMapCache) {
  42881. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache, builtInCMapCache);
  42882. }
  42883. };
  42884. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  42885. },
  42886. get numPages() {
  42887. var linearization = this.linearization;
  42888. var num = linearization ? linearization.numPages : this.catalog.numPages;
  42889. return shadow(this, 'numPages', num);
  42890. },
  42891. get documentInfo() {
  42892. var docInfo = {
  42893. PDFFormatVersion: this.pdfFormatVersion,
  42894. IsAcroFormPresent: !!this.acroForm,
  42895. IsXFAPresent: !!this.xfa
  42896. };
  42897. var infoDict;
  42898. try {
  42899. infoDict = this.xref.trailer.get('Info');
  42900. } catch (err) {
  42901. info('The document information dictionary is invalid.');
  42902. }
  42903. if (infoDict) {
  42904. var validEntries = DocumentInfoValidators.entries;
  42905. for (var key in validEntries) {
  42906. if (infoDict.has(key)) {
  42907. var value = infoDict.get(key);
  42908. if (validEntries[key](value)) {
  42909. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  42910. } else {
  42911. info('Bad value in document info for "' + key + '"');
  42912. }
  42913. }
  42914. }
  42915. }
  42916. return shadow(this, 'documentInfo', docInfo);
  42917. },
  42918. get fingerprint() {
  42919. var xref = this.xref, hash, fileID = '';
  42920. var idArray = xref.trailer.get('ID');
  42921. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  42922. hash = stringToBytes(idArray[0]);
  42923. } else {
  42924. if (this.stream.ensureRange) {
  42925. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  42926. }
  42927. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  42928. }
  42929. for (var i = 0, n = hash.length; i < n; i++) {
  42930. var hex = hash[i].toString(16);
  42931. fileID += hex.length === 1 ? '0' + hex : hex;
  42932. }
  42933. return shadow(this, 'fingerprint', fileID);
  42934. },
  42935. getPage: function PDFDocument_getPage(pageIndex) {
  42936. return this.catalog.getPage(pageIndex);
  42937. },
  42938. cleanup: function PDFDocument_cleanup() {
  42939. return this.catalog.cleanup();
  42940. }
  42941. };
  42942. return PDFDocument;
  42943. }();
  42944. exports.Page = Page;
  42945. exports.PDFDocument = PDFDocument;
  42946. /***/ }),
  42947. /* 32 */
  42948. /***/ (function(module, exports, __w_pdfjs_require__) {
  42949. "use strict";
  42950. var sharedUtil = __w_pdfjs_require__(0);
  42951. var coreStream = __w_pdfjs_require__(2);
  42952. var coreGlyphList = __w_pdfjs_require__(8);
  42953. var coreEncodings = __w_pdfjs_require__(5);
  42954. var coreCFFParser = __w_pdfjs_require__(14);
  42955. var Util = sharedUtil.Util;
  42956. var bytesToString = sharedUtil.bytesToString;
  42957. var error = sharedUtil.error;
  42958. var Stream = coreStream.Stream;
  42959. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  42960. var StandardEncoding = coreEncodings.StandardEncoding;
  42961. var CFFParser = coreCFFParser.CFFParser;
  42962. var FontRendererFactory = function FontRendererFactoryClosure() {
  42963. function getLong(data, offset) {
  42964. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  42965. }
  42966. function getUshort(data, offset) {
  42967. return data[offset] << 8 | data[offset + 1];
  42968. }
  42969. function parseCmap(data, start, end) {
  42970. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  42971. var format = getUshort(data, start + offset);
  42972. var ranges, p, i;
  42973. if (format === 4) {
  42974. getUshort(data, start + offset + 2);
  42975. var segCount = getUshort(data, start + offset + 6) >> 1;
  42976. p = start + offset + 14;
  42977. ranges = [];
  42978. for (i = 0; i < segCount; i++, p += 2) {
  42979. ranges[i] = { end: getUshort(data, p) };
  42980. }
  42981. p += 2;
  42982. for (i = 0; i < segCount; i++, p += 2) {
  42983. ranges[i].start = getUshort(data, p);
  42984. }
  42985. for (i = 0; i < segCount; i++, p += 2) {
  42986. ranges[i].idDelta = getUshort(data, p);
  42987. }
  42988. for (i = 0; i < segCount; i++, p += 2) {
  42989. var idOffset = getUshort(data, p);
  42990. if (idOffset === 0) {
  42991. continue;
  42992. }
  42993. ranges[i].ids = [];
  42994. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  42995. ranges[i].ids[j] = getUshort(data, p + idOffset);
  42996. idOffset += 2;
  42997. }
  42998. }
  42999. return ranges;
  43000. } else if (format === 12) {
  43001. getLong(data, start + offset + 4);
  43002. var groups = getLong(data, start + offset + 12);
  43003. p = start + offset + 16;
  43004. ranges = [];
  43005. for (i = 0; i < groups; i++) {
  43006. ranges.push({
  43007. start: getLong(data, p),
  43008. end: getLong(data, p + 4),
  43009. idDelta: getLong(data, p + 8) - getLong(data, p)
  43010. });
  43011. p += 12;
  43012. }
  43013. return ranges;
  43014. }
  43015. error('not supported cmap: ' + format);
  43016. }
  43017. function parseCff(data, start, end, seacAnalysisEnabled) {
  43018. var properties = {};
  43019. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  43020. var cff = parser.parse();
  43021. return {
  43022. glyphs: cff.charStrings.objects,
  43023. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  43024. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  43025. };
  43026. }
  43027. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  43028. var itemSize, itemDecode;
  43029. if (isGlyphLocationsLong) {
  43030. itemSize = 4;
  43031. itemDecode = function fontItemDecodeLong(data, offset) {
  43032. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  43033. };
  43034. } else {
  43035. itemSize = 2;
  43036. itemDecode = function fontItemDecode(data, offset) {
  43037. return data[offset] << 9 | data[offset + 1] << 1;
  43038. };
  43039. }
  43040. var glyphs = [];
  43041. var startOffset = itemDecode(loca, 0);
  43042. for (var j = itemSize; j < loca.length; j += itemSize) {
  43043. var endOffset = itemDecode(loca, j);
  43044. glyphs.push(glyf.subarray(startOffset, endOffset));
  43045. startOffset = endOffset;
  43046. }
  43047. return glyphs;
  43048. }
  43049. function lookupCmap(ranges, unicode) {
  43050. var code = unicode.charCodeAt(0), gid = 0;
  43051. var l = 0, r = ranges.length - 1;
  43052. while (l < r) {
  43053. var c = l + r + 1 >> 1;
  43054. if (code < ranges[c].start) {
  43055. r = c - 1;
  43056. } else {
  43057. l = c;
  43058. }
  43059. }
  43060. if (ranges[l].start <= code && code <= ranges[l].end) {
  43061. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  43062. }
  43063. return {
  43064. charCode: code,
  43065. glyphId: gid
  43066. };
  43067. }
  43068. function compileGlyf(code, cmds, font) {
  43069. function moveTo(x, y) {
  43070. cmds.push({
  43071. cmd: 'moveTo',
  43072. args: [
  43073. x,
  43074. y
  43075. ]
  43076. });
  43077. }
  43078. function lineTo(x, y) {
  43079. cmds.push({
  43080. cmd: 'lineTo',
  43081. args: [
  43082. x,
  43083. y
  43084. ]
  43085. });
  43086. }
  43087. function quadraticCurveTo(xa, ya, x, y) {
  43088. cmds.push({
  43089. cmd: 'quadraticCurveTo',
  43090. args: [
  43091. xa,
  43092. ya,
  43093. x,
  43094. y
  43095. ]
  43096. });
  43097. }
  43098. var i = 0;
  43099. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  43100. var flags;
  43101. var x = 0, y = 0;
  43102. i += 10;
  43103. if (numberOfContours < 0) {
  43104. do {
  43105. flags = code[i] << 8 | code[i + 1];
  43106. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  43107. i += 4;
  43108. var arg1, arg2;
  43109. if (flags & 0x01) {
  43110. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  43111. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  43112. i += 4;
  43113. } else {
  43114. arg1 = code[i++];
  43115. arg2 = code[i++];
  43116. }
  43117. if (flags & 0x02) {
  43118. x = arg1;
  43119. y = arg2;
  43120. } else {
  43121. x = 0;
  43122. y = 0;
  43123. }
  43124. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  43125. if (flags & 0x08) {
  43126. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  43127. i += 2;
  43128. } else if (flags & 0x40) {
  43129. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  43130. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  43131. i += 4;
  43132. } else if (flags & 0x80) {
  43133. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  43134. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  43135. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  43136. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  43137. i += 8;
  43138. }
  43139. var subglyph = font.glyphs[glyphIndex];
  43140. if (subglyph) {
  43141. cmds.push({ cmd: 'save' });
  43142. cmds.push({
  43143. cmd: 'transform',
  43144. args: [
  43145. scaleX,
  43146. scale01,
  43147. scale10,
  43148. scaleY,
  43149. x,
  43150. y
  43151. ]
  43152. });
  43153. compileGlyf(subglyph, cmds, font);
  43154. cmds.push({ cmd: 'restore' });
  43155. }
  43156. } while (flags & 0x20);
  43157. } else {
  43158. var endPtsOfContours = [];
  43159. var j, jj;
  43160. for (j = 0; j < numberOfContours; j++) {
  43161. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  43162. i += 2;
  43163. }
  43164. var instructionLength = code[i] << 8 | code[i + 1];
  43165. i += 2 + instructionLength;
  43166. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  43167. var points = [];
  43168. while (points.length < numberOfPoints) {
  43169. flags = code[i++];
  43170. var repeat = 1;
  43171. if (flags & 0x08) {
  43172. repeat += code[i++];
  43173. }
  43174. while (repeat-- > 0) {
  43175. points.push({ flags: flags });
  43176. }
  43177. }
  43178. for (j = 0; j < numberOfPoints; j++) {
  43179. switch (points[j].flags & 0x12) {
  43180. case 0x00:
  43181. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  43182. i += 2;
  43183. break;
  43184. case 0x02:
  43185. x -= code[i++];
  43186. break;
  43187. case 0x12:
  43188. x += code[i++];
  43189. break;
  43190. }
  43191. points[j].x = x;
  43192. }
  43193. for (j = 0; j < numberOfPoints; j++) {
  43194. switch (points[j].flags & 0x24) {
  43195. case 0x00:
  43196. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  43197. i += 2;
  43198. break;
  43199. case 0x04:
  43200. y -= code[i++];
  43201. break;
  43202. case 0x24:
  43203. y += code[i++];
  43204. break;
  43205. }
  43206. points[j].y = y;
  43207. }
  43208. var startPoint = 0;
  43209. for (i = 0; i < numberOfContours; i++) {
  43210. var endPoint = endPtsOfContours[i];
  43211. var contour = points.slice(startPoint, endPoint + 1);
  43212. if (contour[0].flags & 1) {
  43213. contour.push(contour[0]);
  43214. } else if (contour[contour.length - 1].flags & 1) {
  43215. contour.unshift(contour[contour.length - 1]);
  43216. } else {
  43217. var p = {
  43218. flags: 1,
  43219. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  43220. y: (contour[0].y + contour[contour.length - 1].y) / 2
  43221. };
  43222. contour.unshift(p);
  43223. contour.push(p);
  43224. }
  43225. moveTo(contour[0].x, contour[0].y);
  43226. for (j = 1, jj = contour.length; j < jj; j++) {
  43227. if (contour[j].flags & 1) {
  43228. lineTo(contour[j].x, contour[j].y);
  43229. } else if (contour[j + 1].flags & 1) {
  43230. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  43231. j++;
  43232. } else {
  43233. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  43234. }
  43235. }
  43236. startPoint = endPoint + 1;
  43237. }
  43238. }
  43239. }
  43240. function compileCharString(code, cmds, font) {
  43241. var stack = [];
  43242. var x = 0, y = 0;
  43243. var stems = 0;
  43244. function moveTo(x, y) {
  43245. cmds.push({
  43246. cmd: 'moveTo',
  43247. args: [
  43248. x,
  43249. y
  43250. ]
  43251. });
  43252. }
  43253. function lineTo(x, y) {
  43254. cmds.push({
  43255. cmd: 'lineTo',
  43256. args: [
  43257. x,
  43258. y
  43259. ]
  43260. });
  43261. }
  43262. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  43263. cmds.push({
  43264. cmd: 'bezierCurveTo',
  43265. args: [
  43266. x1,
  43267. y1,
  43268. x2,
  43269. y2,
  43270. x,
  43271. y
  43272. ]
  43273. });
  43274. }
  43275. function parse(code) {
  43276. var i = 0;
  43277. while (i < code.length) {
  43278. var stackClean = false;
  43279. var v = code[i++];
  43280. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  43281. switch (v) {
  43282. case 1:
  43283. stems += stack.length >> 1;
  43284. stackClean = true;
  43285. break;
  43286. case 3:
  43287. stems += stack.length >> 1;
  43288. stackClean = true;
  43289. break;
  43290. case 4:
  43291. y += stack.pop();
  43292. moveTo(x, y);
  43293. stackClean = true;
  43294. break;
  43295. case 5:
  43296. while (stack.length > 0) {
  43297. x += stack.shift();
  43298. y += stack.shift();
  43299. lineTo(x, y);
  43300. }
  43301. break;
  43302. case 6:
  43303. while (stack.length > 0) {
  43304. x += stack.shift();
  43305. lineTo(x, y);
  43306. if (stack.length === 0) {
  43307. break;
  43308. }
  43309. y += stack.shift();
  43310. lineTo(x, y);
  43311. }
  43312. break;
  43313. case 7:
  43314. while (stack.length > 0) {
  43315. y += stack.shift();
  43316. lineTo(x, y);
  43317. if (stack.length === 0) {
  43318. break;
  43319. }
  43320. x += stack.shift();
  43321. lineTo(x, y);
  43322. }
  43323. break;
  43324. case 8:
  43325. while (stack.length > 0) {
  43326. xa = x + stack.shift();
  43327. ya = y + stack.shift();
  43328. xb = xa + stack.shift();
  43329. yb = ya + stack.shift();
  43330. x = xb + stack.shift();
  43331. y = yb + stack.shift();
  43332. bezierCurveTo(xa, ya, xb, yb, x, y);
  43333. }
  43334. break;
  43335. case 10:
  43336. n = stack.pop() + font.subrsBias;
  43337. subrCode = font.subrs[n];
  43338. if (subrCode) {
  43339. parse(subrCode);
  43340. }
  43341. break;
  43342. case 11:
  43343. return;
  43344. case 12:
  43345. v = code[i++];
  43346. switch (v) {
  43347. case 34:
  43348. xa = x + stack.shift();
  43349. xb = xa + stack.shift();
  43350. y1 = y + stack.shift();
  43351. x = xb + stack.shift();
  43352. bezierCurveTo(xa, y, xb, y1, x, y1);
  43353. xa = x + stack.shift();
  43354. xb = xa + stack.shift();
  43355. x = xb + stack.shift();
  43356. bezierCurveTo(xa, y1, xb, y, x, y);
  43357. break;
  43358. case 35:
  43359. xa = x + stack.shift();
  43360. ya = y + stack.shift();
  43361. xb = xa + stack.shift();
  43362. yb = ya + stack.shift();
  43363. x = xb + stack.shift();
  43364. y = yb + stack.shift();
  43365. bezierCurveTo(xa, ya, xb, yb, x, y);
  43366. xa = x + stack.shift();
  43367. ya = y + stack.shift();
  43368. xb = xa + stack.shift();
  43369. yb = ya + stack.shift();
  43370. x = xb + stack.shift();
  43371. y = yb + stack.shift();
  43372. bezierCurveTo(xa, ya, xb, yb, x, y);
  43373. stack.pop();
  43374. break;
  43375. case 36:
  43376. xa = x + stack.shift();
  43377. y1 = y + stack.shift();
  43378. xb = xa + stack.shift();
  43379. y2 = y1 + stack.shift();
  43380. x = xb + stack.shift();
  43381. bezierCurveTo(xa, y1, xb, y2, x, y2);
  43382. xa = x + stack.shift();
  43383. xb = xa + stack.shift();
  43384. y3 = y2 + stack.shift();
  43385. x = xb + stack.shift();
  43386. bezierCurveTo(xa, y2, xb, y3, x, y);
  43387. break;
  43388. case 37:
  43389. var x0 = x, y0 = y;
  43390. xa = x + stack.shift();
  43391. ya = y + stack.shift();
  43392. xb = xa + stack.shift();
  43393. yb = ya + stack.shift();
  43394. x = xb + stack.shift();
  43395. y = yb + stack.shift();
  43396. bezierCurveTo(xa, ya, xb, yb, x, y);
  43397. xa = x + stack.shift();
  43398. ya = y + stack.shift();
  43399. xb = xa + stack.shift();
  43400. yb = ya + stack.shift();
  43401. x = xb;
  43402. y = yb;
  43403. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  43404. x += stack.shift();
  43405. } else {
  43406. y += stack.shift();
  43407. }
  43408. bezierCurveTo(xa, ya, xb, yb, x, y);
  43409. break;
  43410. default:
  43411. error('unknown operator: 12 ' + v);
  43412. }
  43413. break;
  43414. case 14:
  43415. if (stack.length >= 4) {
  43416. var achar = stack.pop();
  43417. var bchar = stack.pop();
  43418. y = stack.pop();
  43419. x = stack.pop();
  43420. cmds.push({ cmd: 'save' });
  43421. cmds.push({
  43422. cmd: 'translate',
  43423. args: [
  43424. x,
  43425. y
  43426. ]
  43427. });
  43428. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  43429. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  43430. cmds.push({ cmd: 'restore' });
  43431. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  43432. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  43433. }
  43434. return;
  43435. case 18:
  43436. stems += stack.length >> 1;
  43437. stackClean = true;
  43438. break;
  43439. case 19:
  43440. stems += stack.length >> 1;
  43441. i += stems + 7 >> 3;
  43442. stackClean = true;
  43443. break;
  43444. case 20:
  43445. stems += stack.length >> 1;
  43446. i += stems + 7 >> 3;
  43447. stackClean = true;
  43448. break;
  43449. case 21:
  43450. y += stack.pop();
  43451. x += stack.pop();
  43452. moveTo(x, y);
  43453. stackClean = true;
  43454. break;
  43455. case 22:
  43456. x += stack.pop();
  43457. moveTo(x, y);
  43458. stackClean = true;
  43459. break;
  43460. case 23:
  43461. stems += stack.length >> 1;
  43462. stackClean = true;
  43463. break;
  43464. case 24:
  43465. while (stack.length > 2) {
  43466. xa = x + stack.shift();
  43467. ya = y + stack.shift();
  43468. xb = xa + stack.shift();
  43469. yb = ya + stack.shift();
  43470. x = xb + stack.shift();
  43471. y = yb + stack.shift();
  43472. bezierCurveTo(xa, ya, xb, yb, x, y);
  43473. }
  43474. x += stack.shift();
  43475. y += stack.shift();
  43476. lineTo(x, y);
  43477. break;
  43478. case 25:
  43479. while (stack.length > 6) {
  43480. x += stack.shift();
  43481. y += stack.shift();
  43482. lineTo(x, y);
  43483. }
  43484. xa = x + stack.shift();
  43485. ya = y + stack.shift();
  43486. xb = xa + stack.shift();
  43487. yb = ya + stack.shift();
  43488. x = xb + stack.shift();
  43489. y = yb + stack.shift();
  43490. bezierCurveTo(xa, ya, xb, yb, x, y);
  43491. break;
  43492. case 26:
  43493. if (stack.length % 2) {
  43494. x += stack.shift();
  43495. }
  43496. while (stack.length > 0) {
  43497. xa = x;
  43498. ya = y + stack.shift();
  43499. xb = xa + stack.shift();
  43500. yb = ya + stack.shift();
  43501. x = xb;
  43502. y = yb + stack.shift();
  43503. bezierCurveTo(xa, ya, xb, yb, x, y);
  43504. }
  43505. break;
  43506. case 27:
  43507. if (stack.length % 2) {
  43508. y += stack.shift();
  43509. }
  43510. while (stack.length > 0) {
  43511. xa = x + stack.shift();
  43512. ya = y;
  43513. xb = xa + stack.shift();
  43514. yb = ya + stack.shift();
  43515. x = xb + stack.shift();
  43516. y = yb;
  43517. bezierCurveTo(xa, ya, xb, yb, x, y);
  43518. }
  43519. break;
  43520. case 28:
  43521. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  43522. i += 2;
  43523. break;
  43524. case 29:
  43525. n = stack.pop() + font.gsubrsBias;
  43526. subrCode = font.gsubrs[n];
  43527. if (subrCode) {
  43528. parse(subrCode);
  43529. }
  43530. break;
  43531. case 30:
  43532. while (stack.length > 0) {
  43533. xa = x;
  43534. ya = y + stack.shift();
  43535. xb = xa + stack.shift();
  43536. yb = ya + stack.shift();
  43537. x = xb + stack.shift();
  43538. y = yb + (stack.length === 1 ? stack.shift() : 0);
  43539. bezierCurveTo(xa, ya, xb, yb, x, y);
  43540. if (stack.length === 0) {
  43541. break;
  43542. }
  43543. xa = x + stack.shift();
  43544. ya = y;
  43545. xb = xa + stack.shift();
  43546. yb = ya + stack.shift();
  43547. y = yb + stack.shift();
  43548. x = xb + (stack.length === 1 ? stack.shift() : 0);
  43549. bezierCurveTo(xa, ya, xb, yb, x, y);
  43550. }
  43551. break;
  43552. case 31:
  43553. while (stack.length > 0) {
  43554. xa = x + stack.shift();
  43555. ya = y;
  43556. xb = xa + stack.shift();
  43557. yb = ya + stack.shift();
  43558. y = yb + stack.shift();
  43559. x = xb + (stack.length === 1 ? stack.shift() : 0);
  43560. bezierCurveTo(xa, ya, xb, yb, x, y);
  43561. if (stack.length === 0) {
  43562. break;
  43563. }
  43564. xa = x;
  43565. ya = y + stack.shift();
  43566. xb = xa + stack.shift();
  43567. yb = ya + stack.shift();
  43568. x = xb + stack.shift();
  43569. y = yb + (stack.length === 1 ? stack.shift() : 0);
  43570. bezierCurveTo(xa, ya, xb, yb, x, y);
  43571. }
  43572. break;
  43573. default:
  43574. if (v < 32) {
  43575. error('unknown operator: ' + v);
  43576. }
  43577. if (v < 247) {
  43578. stack.push(v - 139);
  43579. } else if (v < 251) {
  43580. stack.push((v - 247) * 256 + code[i++] + 108);
  43581. } else if (v < 255) {
  43582. stack.push(-(v - 251) * 256 - code[i++] - 108);
  43583. } else {
  43584. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  43585. i += 4;
  43586. }
  43587. break;
  43588. }
  43589. if (stackClean) {
  43590. stack.length = 0;
  43591. }
  43592. }
  43593. }
  43594. parse(code);
  43595. }
  43596. var noop = '';
  43597. function CompiledFont(fontMatrix) {
  43598. this.compiledGlyphs = Object.create(null);
  43599. this.compiledCharCodeToGlyphId = Object.create(null);
  43600. this.fontMatrix = fontMatrix;
  43601. }
  43602. CompiledFont.prototype = {
  43603. getPathJs: function (unicode) {
  43604. var cmap = lookupCmap(this.cmap, unicode);
  43605. var fn = this.compiledGlyphs[cmap.glyphId];
  43606. if (!fn) {
  43607. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  43608. this.compiledGlyphs[cmap.glyphId] = fn;
  43609. }
  43610. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  43611. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  43612. }
  43613. return fn;
  43614. },
  43615. compileGlyph: function (code) {
  43616. if (!code || code.length === 0 || code[0] === 14) {
  43617. return noop;
  43618. }
  43619. var cmds = [];
  43620. cmds.push({ cmd: 'save' });
  43621. cmds.push({
  43622. cmd: 'transform',
  43623. args: this.fontMatrix.slice()
  43624. });
  43625. cmds.push({
  43626. cmd: 'scale',
  43627. args: [
  43628. 'size',
  43629. '-size'
  43630. ]
  43631. });
  43632. this.compileGlyphImpl(code, cmds);
  43633. cmds.push({ cmd: 'restore' });
  43634. return cmds;
  43635. },
  43636. compileGlyphImpl: function () {
  43637. error('Children classes should implement this.');
  43638. },
  43639. hasBuiltPath: function (unicode) {
  43640. var cmap = lookupCmap(this.cmap, unicode);
  43641. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  43642. }
  43643. };
  43644. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  43645. fontMatrix = fontMatrix || [
  43646. 0.000488,
  43647. 0,
  43648. 0,
  43649. 0.000488,
  43650. 0,
  43651. 0
  43652. ];
  43653. CompiledFont.call(this, fontMatrix);
  43654. this.glyphs = glyphs;
  43655. this.cmap = cmap;
  43656. }
  43657. Util.inherit(TrueTypeCompiled, CompiledFont, {
  43658. compileGlyphImpl: function (code, cmds) {
  43659. compileGlyf(code, cmds, this);
  43660. }
  43661. });
  43662. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  43663. fontMatrix = fontMatrix || [
  43664. 0.001,
  43665. 0,
  43666. 0,
  43667. 0.001,
  43668. 0,
  43669. 0
  43670. ];
  43671. CompiledFont.call(this, fontMatrix);
  43672. this.glyphs = cffInfo.glyphs;
  43673. this.gsubrs = cffInfo.gsubrs || [];
  43674. this.subrs = cffInfo.subrs || [];
  43675. this.cmap = cmap;
  43676. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  43677. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  43678. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  43679. }
  43680. Util.inherit(Type2Compiled, CompiledFont, {
  43681. compileGlyphImpl: function (code, cmds) {
  43682. compileCharString(code, cmds, this);
  43683. }
  43684. });
  43685. return {
  43686. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  43687. var data = new Uint8Array(font.data);
  43688. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  43689. var numTables = getUshort(data, 4);
  43690. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  43691. var tag = bytesToString(data.subarray(p, p + 4));
  43692. var offset = getLong(data, p + 8);
  43693. var length = getLong(data, p + 12);
  43694. switch (tag) {
  43695. case 'cmap':
  43696. cmap = parseCmap(data, offset, offset + length);
  43697. break;
  43698. case 'glyf':
  43699. glyf = data.subarray(offset, offset + length);
  43700. break;
  43701. case 'loca':
  43702. loca = data.subarray(offset, offset + length);
  43703. break;
  43704. case 'head':
  43705. unitsPerEm = getUshort(data, offset + 18);
  43706. indexToLocFormat = getUshort(data, offset + 50);
  43707. break;
  43708. case 'CFF ':
  43709. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  43710. break;
  43711. }
  43712. }
  43713. if (glyf) {
  43714. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  43715. 1 / unitsPerEm,
  43716. 0,
  43717. 0,
  43718. 1 / unitsPerEm,
  43719. 0,
  43720. 0
  43721. ];
  43722. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  43723. }
  43724. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  43725. }
  43726. };
  43727. }();
  43728. exports.FontRendererFactory = FontRendererFactory;
  43729. /***/ }),
  43730. /* 33 */
  43731. /***/ (function(module, exports, __w_pdfjs_require__) {
  43732. "use strict";
  43733. var sharedUtil = __w_pdfjs_require__(0);
  43734. var corePrimitives = __w_pdfjs_require__(1);
  43735. var coreStream = __w_pdfjs_require__(2);
  43736. var coreGlyphList = __w_pdfjs_require__(8);
  43737. var coreFontRenderer = __w_pdfjs_require__(32);
  43738. var coreEncodings = __w_pdfjs_require__(5);
  43739. var coreStandardFonts = __w_pdfjs_require__(20);
  43740. var coreUnicode = __w_pdfjs_require__(21);
  43741. var coreType1Parser = __w_pdfjs_require__(43);
  43742. var coreCFFParser = __w_pdfjs_require__(14);
  43743. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  43744. var FontType = sharedUtil.FontType;
  43745. var assert = sharedUtil.assert;
  43746. var bytesToString = sharedUtil.bytesToString;
  43747. var error = sharedUtil.error;
  43748. var info = sharedUtil.info;
  43749. var isArray = sharedUtil.isArray;
  43750. var isInt = sharedUtil.isInt;
  43751. var isNum = sharedUtil.isNum;
  43752. var readUint32 = sharedUtil.readUint32;
  43753. var shadow = sharedUtil.shadow;
  43754. var string32 = sharedUtil.string32;
  43755. var warn = sharedUtil.warn;
  43756. var MissingDataException = sharedUtil.MissingDataException;
  43757. var isSpace = sharedUtil.isSpace;
  43758. var Stream = coreStream.Stream;
  43759. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  43760. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  43761. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  43762. var StandardEncoding = coreEncodings.StandardEncoding;
  43763. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  43764. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  43765. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  43766. var getEncoding = coreEncodings.getEncoding;
  43767. var getStdFontMap = coreStandardFonts.getStdFontMap;
  43768. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  43769. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  43770. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  43771. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  43772. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  43773. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  43774. var Type1Parser = coreType1Parser.Type1Parser;
  43775. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  43776. var CFFParser = coreCFFParser.CFFParser;
  43777. var CFFCompiler = coreCFFParser.CFFCompiler;
  43778. var CFF = coreCFFParser.CFF;
  43779. var CFFHeader = coreCFFParser.CFFHeader;
  43780. var CFFTopDict = coreCFFParser.CFFTopDict;
  43781. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  43782. var CFFStrings = coreCFFParser.CFFStrings;
  43783. var CFFIndex = coreCFFParser.CFFIndex;
  43784. var CFFCharset = coreCFFParser.CFFCharset;
  43785. var PRIVATE_USE_OFFSET_START = 0xE000;
  43786. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  43787. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  43788. var PDF_GLYPH_SPACE_UNITS = 1000;
  43789. var SEAC_ANALYSIS_ENABLED = false;
  43790. var FontFlags = {
  43791. FixedPitch: 1,
  43792. Serif: 2,
  43793. Symbolic: 4,
  43794. Script: 8,
  43795. Nonsymbolic: 32,
  43796. Italic: 64,
  43797. AllCap: 65536,
  43798. SmallCap: 131072,
  43799. ForceBold: 262144
  43800. };
  43801. var MacStandardGlyphOrdering = [
  43802. '.notdef',
  43803. '.null',
  43804. 'nonmarkingreturn',
  43805. 'space',
  43806. 'exclam',
  43807. 'quotedbl',
  43808. 'numbersign',
  43809. 'dollar',
  43810. 'percent',
  43811. 'ampersand',
  43812. 'quotesingle',
  43813. 'parenleft',
  43814. 'parenright',
  43815. 'asterisk',
  43816. 'plus',
  43817. 'comma',
  43818. 'hyphen',
  43819. 'period',
  43820. 'slash',
  43821. 'zero',
  43822. 'one',
  43823. 'two',
  43824. 'three',
  43825. 'four',
  43826. 'five',
  43827. 'six',
  43828. 'seven',
  43829. 'eight',
  43830. 'nine',
  43831. 'colon',
  43832. 'semicolon',
  43833. 'less',
  43834. 'equal',
  43835. 'greater',
  43836. 'question',
  43837. 'at',
  43838. 'A',
  43839. 'B',
  43840. 'C',
  43841. 'D',
  43842. 'E',
  43843. 'F',
  43844. 'G',
  43845. 'H',
  43846. 'I',
  43847. 'J',
  43848. 'K',
  43849. 'L',
  43850. 'M',
  43851. 'N',
  43852. 'O',
  43853. 'P',
  43854. 'Q',
  43855. 'R',
  43856. 'S',
  43857. 'T',
  43858. 'U',
  43859. 'V',
  43860. 'W',
  43861. 'X',
  43862. 'Y',
  43863. 'Z',
  43864. 'bracketleft',
  43865. 'backslash',
  43866. 'bracketright',
  43867. 'asciicircum',
  43868. 'underscore',
  43869. 'grave',
  43870. 'a',
  43871. 'b',
  43872. 'c',
  43873. 'd',
  43874. 'e',
  43875. 'f',
  43876. 'g',
  43877. 'h',
  43878. 'i',
  43879. 'j',
  43880. 'k',
  43881. 'l',
  43882. 'm',
  43883. 'n',
  43884. 'o',
  43885. 'p',
  43886. 'q',
  43887. 'r',
  43888. 's',
  43889. 't',
  43890. 'u',
  43891. 'v',
  43892. 'w',
  43893. 'x',
  43894. 'y',
  43895. 'z',
  43896. 'braceleft',
  43897. 'bar',
  43898. 'braceright',
  43899. 'asciitilde',
  43900. 'Adieresis',
  43901. 'Aring',
  43902. 'Ccedilla',
  43903. 'Eacute',
  43904. 'Ntilde',
  43905. 'Odieresis',
  43906. 'Udieresis',
  43907. 'aacute',
  43908. 'agrave',
  43909. 'acircumflex',
  43910. 'adieresis',
  43911. 'atilde',
  43912. 'aring',
  43913. 'ccedilla',
  43914. 'eacute',
  43915. 'egrave',
  43916. 'ecircumflex',
  43917. 'edieresis',
  43918. 'iacute',
  43919. 'igrave',
  43920. 'icircumflex',
  43921. 'idieresis',
  43922. 'ntilde',
  43923. 'oacute',
  43924. 'ograve',
  43925. 'ocircumflex',
  43926. 'odieresis',
  43927. 'otilde',
  43928. 'uacute',
  43929. 'ugrave',
  43930. 'ucircumflex',
  43931. 'udieresis',
  43932. 'dagger',
  43933. 'degree',
  43934. 'cent',
  43935. 'sterling',
  43936. 'section',
  43937. 'bullet',
  43938. 'paragraph',
  43939. 'germandbls',
  43940. 'registered',
  43941. 'copyright',
  43942. 'trademark',
  43943. 'acute',
  43944. 'dieresis',
  43945. 'notequal',
  43946. 'AE',
  43947. 'Oslash',
  43948. 'infinity',
  43949. 'plusminus',
  43950. 'lessequal',
  43951. 'greaterequal',
  43952. 'yen',
  43953. 'mu',
  43954. 'partialdiff',
  43955. 'summation',
  43956. 'product',
  43957. 'pi',
  43958. 'integral',
  43959. 'ordfeminine',
  43960. 'ordmasculine',
  43961. 'Omega',
  43962. 'ae',
  43963. 'oslash',
  43964. 'questiondown',
  43965. 'exclamdown',
  43966. 'logicalnot',
  43967. 'radical',
  43968. 'florin',
  43969. 'approxequal',
  43970. 'Delta',
  43971. 'guillemotleft',
  43972. 'guillemotright',
  43973. 'ellipsis',
  43974. 'nonbreakingspace',
  43975. 'Agrave',
  43976. 'Atilde',
  43977. 'Otilde',
  43978. 'OE',
  43979. 'oe',
  43980. 'endash',
  43981. 'emdash',
  43982. 'quotedblleft',
  43983. 'quotedblright',
  43984. 'quoteleft',
  43985. 'quoteright',
  43986. 'divide',
  43987. 'lozenge',
  43988. 'ydieresis',
  43989. 'Ydieresis',
  43990. 'fraction',
  43991. 'currency',
  43992. 'guilsinglleft',
  43993. 'guilsinglright',
  43994. 'fi',
  43995. 'fl',
  43996. 'daggerdbl',
  43997. 'periodcentered',
  43998. 'quotesinglbase',
  43999. 'quotedblbase',
  44000. 'perthousand',
  44001. 'Acircumflex',
  44002. 'Ecircumflex',
  44003. 'Aacute',
  44004. 'Edieresis',
  44005. 'Egrave',
  44006. 'Iacute',
  44007. 'Icircumflex',
  44008. 'Idieresis',
  44009. 'Igrave',
  44010. 'Oacute',
  44011. 'Ocircumflex',
  44012. 'apple',
  44013. 'Ograve',
  44014. 'Uacute',
  44015. 'Ucircumflex',
  44016. 'Ugrave',
  44017. 'dotlessi',
  44018. 'circumflex',
  44019. 'tilde',
  44020. 'macron',
  44021. 'breve',
  44022. 'dotaccent',
  44023. 'ring',
  44024. 'cedilla',
  44025. 'hungarumlaut',
  44026. 'ogonek',
  44027. 'caron',
  44028. 'Lslash',
  44029. 'lslash',
  44030. 'Scaron',
  44031. 'scaron',
  44032. 'Zcaron',
  44033. 'zcaron',
  44034. 'brokenbar',
  44035. 'Eth',
  44036. 'eth',
  44037. 'Yacute',
  44038. 'yacute',
  44039. 'Thorn',
  44040. 'thorn',
  44041. 'minus',
  44042. 'multiply',
  44043. 'onesuperior',
  44044. 'twosuperior',
  44045. 'threesuperior',
  44046. 'onehalf',
  44047. 'onequarter',
  44048. 'threequarters',
  44049. 'franc',
  44050. 'Gbreve',
  44051. 'gbreve',
  44052. 'Idotaccent',
  44053. 'Scedilla',
  44054. 'scedilla',
  44055. 'Cacute',
  44056. 'cacute',
  44057. 'Ccaron',
  44058. 'ccaron',
  44059. 'dcroat'
  44060. ];
  44061. function adjustWidths(properties) {
  44062. if (!properties.fontMatrix) {
  44063. return;
  44064. }
  44065. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  44066. return;
  44067. }
  44068. var scale = 0.001 / properties.fontMatrix[0];
  44069. var glyphsWidths = properties.widths;
  44070. for (var glyph in glyphsWidths) {
  44071. glyphsWidths[glyph] *= scale;
  44072. }
  44073. properties.defaultWidth *= scale;
  44074. }
  44075. function adjustToUnicode(properties, builtInEncoding) {
  44076. if (properties.hasIncludedToUnicodeMap) {
  44077. return;
  44078. }
  44079. if (properties.hasEncoding) {
  44080. return;
  44081. }
  44082. if (builtInEncoding === properties.defaultEncoding) {
  44083. return;
  44084. }
  44085. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  44086. return;
  44087. }
  44088. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  44089. for (var charCode in builtInEncoding) {
  44090. var glyphName = builtInEncoding[charCode];
  44091. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  44092. if (unicode !== -1) {
  44093. toUnicode[charCode] = String.fromCharCode(unicode);
  44094. }
  44095. }
  44096. properties.toUnicode.amend(toUnicode);
  44097. }
  44098. function getFontType(type, subtype) {
  44099. switch (type) {
  44100. case 'Type1':
  44101. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  44102. case 'CIDFontType0':
  44103. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  44104. case 'OpenType':
  44105. return FontType.OPENTYPE;
  44106. case 'TrueType':
  44107. return FontType.TRUETYPE;
  44108. case 'CIDFontType2':
  44109. return FontType.CIDFONTTYPE2;
  44110. case 'MMType1':
  44111. return FontType.MMTYPE1;
  44112. case 'Type0':
  44113. return FontType.TYPE0;
  44114. default:
  44115. return FontType.UNKNOWN;
  44116. }
  44117. }
  44118. function recoverGlyphName(name, glyphsUnicodeMap) {
  44119. if (glyphsUnicodeMap[name] !== undefined) {
  44120. return name;
  44121. }
  44122. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  44123. if (unicode !== -1) {
  44124. for (var key in glyphsUnicodeMap) {
  44125. if (glyphsUnicodeMap[key] === unicode) {
  44126. return key;
  44127. }
  44128. }
  44129. }
  44130. info('Unable to recover a standard glyph name for: ' + name);
  44131. return name;
  44132. }
  44133. var Glyph = function GlyphClosure() {
  44134. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  44135. this.fontChar = fontChar;
  44136. this.unicode = unicode;
  44137. this.accent = accent;
  44138. this.width = width;
  44139. this.vmetric = vmetric;
  44140. this.operatorListId = operatorListId;
  44141. this.isSpace = isSpace;
  44142. this.isInFont = isInFont;
  44143. }
  44144. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  44145. 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;
  44146. };
  44147. return Glyph;
  44148. }();
  44149. var ToUnicodeMap = function ToUnicodeMapClosure() {
  44150. function ToUnicodeMap(cmap) {
  44151. this._map = cmap;
  44152. }
  44153. ToUnicodeMap.prototype = {
  44154. get length() {
  44155. return this._map.length;
  44156. },
  44157. forEach: function (callback) {
  44158. for (var charCode in this._map) {
  44159. callback(charCode, this._map[charCode].charCodeAt(0));
  44160. }
  44161. },
  44162. has: function (i) {
  44163. return this._map[i] !== undefined;
  44164. },
  44165. get: function (i) {
  44166. return this._map[i];
  44167. },
  44168. charCodeOf: function (v) {
  44169. return this._map.indexOf(v);
  44170. },
  44171. amend: function (map) {
  44172. for (var charCode in map) {
  44173. this._map[charCode] = map[charCode];
  44174. }
  44175. }
  44176. };
  44177. return ToUnicodeMap;
  44178. }();
  44179. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  44180. function IdentityToUnicodeMap(firstChar, lastChar) {
  44181. this.firstChar = firstChar;
  44182. this.lastChar = lastChar;
  44183. }
  44184. IdentityToUnicodeMap.prototype = {
  44185. get length() {
  44186. return this.lastChar + 1 - this.firstChar;
  44187. },
  44188. forEach: function (callback) {
  44189. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  44190. callback(i, i);
  44191. }
  44192. },
  44193. has: function (i) {
  44194. return this.firstChar <= i && i <= this.lastChar;
  44195. },
  44196. get: function (i) {
  44197. if (this.firstChar <= i && i <= this.lastChar) {
  44198. return String.fromCharCode(i);
  44199. }
  44200. return undefined;
  44201. },
  44202. charCodeOf: function (v) {
  44203. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  44204. },
  44205. amend: function (map) {
  44206. error('Should not call amend()');
  44207. }
  44208. };
  44209. return IdentityToUnicodeMap;
  44210. }();
  44211. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  44212. function writeInt16(dest, offset, num) {
  44213. dest[offset] = num >> 8 & 0xFF;
  44214. dest[offset + 1] = num & 0xFF;
  44215. }
  44216. function writeInt32(dest, offset, num) {
  44217. dest[offset] = num >> 24 & 0xFF;
  44218. dest[offset + 1] = num >> 16 & 0xFF;
  44219. dest[offset + 2] = num >> 8 & 0xFF;
  44220. dest[offset + 3] = num & 0xFF;
  44221. }
  44222. function writeData(dest, offset, data) {
  44223. var i, ii;
  44224. if (data instanceof Uint8Array) {
  44225. dest.set(data, offset);
  44226. } else if (typeof data === 'string') {
  44227. for (i = 0, ii = data.length; i < ii; i++) {
  44228. dest[offset++] = data.charCodeAt(i) & 0xFF;
  44229. }
  44230. } else {
  44231. for (i = 0, ii = data.length; i < ii; i++) {
  44232. dest[offset++] = data[i] & 0xFF;
  44233. }
  44234. }
  44235. }
  44236. function OpenTypeFileBuilder(sfnt) {
  44237. this.sfnt = sfnt;
  44238. this.tables = Object.create(null);
  44239. }
  44240. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  44241. var maxPower2 = 1, log2 = 0;
  44242. while ((maxPower2 ^ entriesCount) > maxPower2) {
  44243. maxPower2 <<= 1;
  44244. log2++;
  44245. }
  44246. var searchRange = maxPower2 * entrySize;
  44247. return {
  44248. range: searchRange,
  44249. entry: log2,
  44250. rangeShift: entrySize * entriesCount - searchRange
  44251. };
  44252. };
  44253. var OTF_HEADER_SIZE = 12;
  44254. var OTF_TABLE_ENTRY_SIZE = 16;
  44255. OpenTypeFileBuilder.prototype = {
  44256. toArray: function OpenTypeFileBuilder_toArray() {
  44257. var sfnt = this.sfnt;
  44258. var tables = this.tables;
  44259. var tablesNames = Object.keys(tables);
  44260. tablesNames.sort();
  44261. var numTables = tablesNames.length;
  44262. var i, j, jj, table, tableName;
  44263. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  44264. var tableOffsets = [offset];
  44265. for (i = 0; i < numTables; i++) {
  44266. table = tables[tablesNames[i]];
  44267. var paddedLength = (table.length + 3 & ~3) >>> 0;
  44268. offset += paddedLength;
  44269. tableOffsets.push(offset);
  44270. }
  44271. var file = new Uint8Array(offset);
  44272. for (i = 0; i < numTables; i++) {
  44273. table = tables[tablesNames[i]];
  44274. writeData(file, tableOffsets[i], table);
  44275. }
  44276. if (sfnt === 'true') {
  44277. sfnt = string32(0x00010000);
  44278. }
  44279. file[0] = sfnt.charCodeAt(0) & 0xFF;
  44280. file[1] = sfnt.charCodeAt(1) & 0xFF;
  44281. file[2] = sfnt.charCodeAt(2) & 0xFF;
  44282. file[3] = sfnt.charCodeAt(3) & 0xFF;
  44283. writeInt16(file, 4, numTables);
  44284. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  44285. writeInt16(file, 6, searchParams.range);
  44286. writeInt16(file, 8, searchParams.entry);
  44287. writeInt16(file, 10, searchParams.rangeShift);
  44288. offset = OTF_HEADER_SIZE;
  44289. for (i = 0; i < numTables; i++) {
  44290. tableName = tablesNames[i];
  44291. file[offset] = tableName.charCodeAt(0) & 0xFF;
  44292. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  44293. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  44294. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  44295. var checksum = 0;
  44296. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  44297. var quad = readUint32(file, j);
  44298. checksum = checksum + quad >>> 0;
  44299. }
  44300. writeInt32(file, offset + 4, checksum);
  44301. writeInt32(file, offset + 8, tableOffsets[i]);
  44302. writeInt32(file, offset + 12, tables[tableName].length);
  44303. offset += OTF_TABLE_ENTRY_SIZE;
  44304. }
  44305. return file;
  44306. },
  44307. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  44308. if (tag in this.tables) {
  44309. throw new Error('Table ' + tag + ' already exists');
  44310. }
  44311. this.tables[tag] = data;
  44312. }
  44313. };
  44314. return OpenTypeFileBuilder;
  44315. }();
  44316. var ProblematicCharRanges = new Int32Array([
  44317. 0x0000,
  44318. 0x0020,
  44319. 0x007F,
  44320. 0x00A1,
  44321. 0x00AD,
  44322. 0x00AE,
  44323. 0x0600,
  44324. 0x0780,
  44325. 0x08A0,
  44326. 0x10A0,
  44327. 0x1780,
  44328. 0x1800,
  44329. 0x1C00,
  44330. 0x1C50,
  44331. 0x2000,
  44332. 0x2010,
  44333. 0x2011,
  44334. 0x2012,
  44335. 0x2028,
  44336. 0x2030,
  44337. 0x205F,
  44338. 0x2070,
  44339. 0x25CC,
  44340. 0x25CD,
  44341. 0x3000,
  44342. 0x3001,
  44343. 0xAA60,
  44344. 0xAA80,
  44345. 0xFFF0,
  44346. 0x10000
  44347. ]);
  44348. var Font = function FontClosure() {
  44349. function Font(name, file, properties) {
  44350. var charCode, glyphName, unicode;
  44351. this.name = name;
  44352. this.loadedName = properties.loadedName;
  44353. this.isType3Font = properties.isType3Font;
  44354. this.sizes = [];
  44355. this.missingFile = false;
  44356. this.glyphCache = Object.create(null);
  44357. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  44358. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  44359. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  44360. var type = properties.type;
  44361. var subtype = properties.subtype;
  44362. this.type = type;
  44363. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  44364. this.differences = properties.differences;
  44365. this.widths = properties.widths;
  44366. this.defaultWidth = properties.defaultWidth;
  44367. this.composite = properties.composite;
  44368. this.wideChars = properties.wideChars;
  44369. this.cMap = properties.cMap;
  44370. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  44371. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  44372. this.fontMatrix = properties.fontMatrix;
  44373. this.bbox = properties.bbox;
  44374. this.toUnicode = properties.toUnicode;
  44375. this.toFontChar = [];
  44376. if (properties.type === 'Type3') {
  44377. for (charCode = 0; charCode < 256; charCode++) {
  44378. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  44379. }
  44380. this.fontType = FontType.TYPE3;
  44381. return;
  44382. }
  44383. this.cidEncoding = properties.cidEncoding;
  44384. this.vertical = properties.vertical;
  44385. if (this.vertical) {
  44386. this.vmetrics = properties.vmetrics;
  44387. this.defaultVMetrics = properties.defaultVMetrics;
  44388. }
  44389. var glyphsUnicodeMap;
  44390. if (!file || file.isEmpty) {
  44391. if (file) {
  44392. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  44393. }
  44394. this.missingFile = true;
  44395. var fontName = name.replace(/[,_]/g, '-');
  44396. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  44397. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  44398. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  44399. this.bold = fontName.search(/bold/gi) !== -1;
  44400. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  44401. this.black = name.search(/Black/g) !== -1;
  44402. this.remeasure = Object.keys(this.widths).length > 0;
  44403. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  44404. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  44405. var map = [];
  44406. for (charCode in GlyphMapForStandardFonts) {
  44407. map[+charCode] = GlyphMapForStandardFonts[charCode];
  44408. }
  44409. if (/Arial-?Black/i.test(name)) {
  44410. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  44411. for (charCode in SupplementalGlyphMapForArialBlack) {
  44412. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  44413. }
  44414. }
  44415. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  44416. if (!isIdentityUnicode) {
  44417. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  44418. map[+charCode] = unicodeCharCode;
  44419. });
  44420. }
  44421. this.toFontChar = map;
  44422. this.toUnicode = new ToUnicodeMap(map);
  44423. } else if (/Symbol/i.test(fontName)) {
  44424. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  44425. } else if (/Dingbats/i.test(fontName)) {
  44426. if (/Wingdings/i.test(name)) {
  44427. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  44428. }
  44429. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  44430. } else if (isStandardFont) {
  44431. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  44432. } else {
  44433. glyphsUnicodeMap = getGlyphsUnicode();
  44434. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  44435. if (!this.composite) {
  44436. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  44437. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  44438. if (unicode !== -1) {
  44439. unicodeCharCode = unicode;
  44440. }
  44441. }
  44442. this.toFontChar[charCode] = unicodeCharCode;
  44443. }.bind(this));
  44444. }
  44445. this.loadedName = fontName.split('-')[0];
  44446. this.loading = false;
  44447. this.fontType = getFontType(type, subtype);
  44448. return;
  44449. }
  44450. if (subtype === 'Type1C') {
  44451. if (type !== 'Type1' && type !== 'MMType1') {
  44452. if (isTrueTypeFile(file)) {
  44453. subtype = 'TrueType';
  44454. } else {
  44455. type = 'Type1';
  44456. }
  44457. } else if (isOpenTypeFile(file)) {
  44458. type = subtype = 'OpenType';
  44459. }
  44460. }
  44461. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  44462. type = 'CIDFontType0';
  44463. }
  44464. if (subtype === 'OpenType') {
  44465. type = 'OpenType';
  44466. }
  44467. if (type === 'CIDFontType0') {
  44468. if (isType1File(file)) {
  44469. subtype = 'CIDFontType0';
  44470. } else if (isOpenTypeFile(file)) {
  44471. type = subtype = 'OpenType';
  44472. } else {
  44473. subtype = 'CIDFontType0C';
  44474. }
  44475. }
  44476. var data;
  44477. switch (type) {
  44478. case 'MMType1':
  44479. info('MMType1 font (' + name + '), falling back to Type1.');
  44480. case 'Type1':
  44481. case 'CIDFontType0':
  44482. this.mimetype = 'font/opentype';
  44483. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  44484. adjustWidths(properties);
  44485. data = this.convert(name, cff, properties);
  44486. break;
  44487. case 'OpenType':
  44488. case 'TrueType':
  44489. case 'CIDFontType2':
  44490. this.mimetype = 'font/opentype';
  44491. data = this.checkAndRepair(name, file, properties);
  44492. if (this.isOpenType) {
  44493. adjustWidths(properties);
  44494. type = 'OpenType';
  44495. }
  44496. break;
  44497. default:
  44498. error('Font ' + type + ' is not supported');
  44499. break;
  44500. }
  44501. this.data = data;
  44502. this.fontType = getFontType(type, subtype);
  44503. this.fontMatrix = properties.fontMatrix;
  44504. this.widths = properties.widths;
  44505. this.defaultWidth = properties.defaultWidth;
  44506. this.toUnicode = properties.toUnicode;
  44507. this.encoding = properties.baseEncoding;
  44508. this.seacMap = properties.seacMap;
  44509. this.loading = true;
  44510. }
  44511. Font.getFontID = function () {
  44512. var ID = 1;
  44513. return function Font_getFontID() {
  44514. return String(ID++);
  44515. };
  44516. }();
  44517. function int16(b0, b1) {
  44518. return (b0 << 8) + b1;
  44519. }
  44520. function signedInt16(b0, b1) {
  44521. var value = (b0 << 8) + b1;
  44522. return value & 1 << 15 ? value - 0x10000 : value;
  44523. }
  44524. function int32(b0, b1, b2, b3) {
  44525. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  44526. }
  44527. function string16(value) {
  44528. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  44529. }
  44530. function safeString16(value) {
  44531. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  44532. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  44533. }
  44534. function isTrueTypeFile(file) {
  44535. var header = file.peekBytes(4);
  44536. return readUint32(header, 0) === 0x00010000;
  44537. }
  44538. function isOpenTypeFile(file) {
  44539. var header = file.peekBytes(4);
  44540. return bytesToString(header) === 'OTTO';
  44541. }
  44542. function isType1File(file) {
  44543. var header = file.peekBytes(2);
  44544. if (header[0] === 0x25 && header[1] === 0x21) {
  44545. return true;
  44546. }
  44547. if (header[0] === 0x80 && header[1] === 0x01) {
  44548. return true;
  44549. }
  44550. return false;
  44551. }
  44552. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  44553. var toFontChar = [], unicode;
  44554. for (var i = 0, ii = encoding.length; i < ii; i++) {
  44555. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  44556. if (unicode !== -1) {
  44557. toFontChar[i] = unicode;
  44558. }
  44559. }
  44560. for (var charCode in differences) {
  44561. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  44562. if (unicode !== -1) {
  44563. toFontChar[+charCode] = unicode;
  44564. }
  44565. }
  44566. return toFontChar;
  44567. }
  44568. function isProblematicUnicodeLocation(code) {
  44569. var i = 0, j = ProblematicCharRanges.length - 1;
  44570. while (i < j) {
  44571. var c = i + j + 1 >> 1;
  44572. if (code < ProblematicCharRanges[c]) {
  44573. j = c - 1;
  44574. } else {
  44575. i = c;
  44576. }
  44577. }
  44578. return !(i & 1);
  44579. }
  44580. function adjustMapping(charCodeToGlyphId, properties) {
  44581. var toUnicode = properties.toUnicode;
  44582. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  44583. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  44584. var newMap = Object.create(null);
  44585. var toFontChar = [];
  44586. var usedFontCharCodes = [];
  44587. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  44588. for (var originalCharCode in charCodeToGlyphId) {
  44589. originalCharCode |= 0;
  44590. var glyphId = charCodeToGlyphId[originalCharCode];
  44591. var fontCharCode = originalCharCode;
  44592. var hasUnicodeValue = false;
  44593. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  44594. hasUnicodeValue = true;
  44595. var unicode = toUnicode.get(fontCharCode);
  44596. if (unicode.length === 1) {
  44597. fontCharCode = unicode.charCodeAt(0);
  44598. }
  44599. }
  44600. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && !hasUnicodeValue) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  44601. do {
  44602. fontCharCode = nextAvailableFontCharCode++;
  44603. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  44604. fontCharCode = 0xF020;
  44605. nextAvailableFontCharCode = fontCharCode + 1;
  44606. }
  44607. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  44608. }
  44609. newMap[fontCharCode] = glyphId;
  44610. toFontChar[originalCharCode] = fontCharCode;
  44611. usedFontCharCodes[fontCharCode] = true;
  44612. }
  44613. return {
  44614. toFontChar: toFontChar,
  44615. charCodeToGlyphId: newMap,
  44616. nextAvailableFontCharCode: nextAvailableFontCharCode
  44617. };
  44618. }
  44619. function getRanges(glyphs, numGlyphs) {
  44620. var codes = [];
  44621. for (var charCode in glyphs) {
  44622. if (glyphs[charCode] >= numGlyphs) {
  44623. continue;
  44624. }
  44625. codes.push({
  44626. fontCharCode: charCode | 0,
  44627. glyphId: glyphs[charCode]
  44628. });
  44629. }
  44630. codes.sort(function fontGetRangesSort(a, b) {
  44631. return a.fontCharCode - b.fontCharCode;
  44632. });
  44633. var ranges = [];
  44634. var length = codes.length;
  44635. for (var n = 0; n < length;) {
  44636. var start = codes[n].fontCharCode;
  44637. var codeIndices = [codes[n].glyphId];
  44638. ++n;
  44639. var end = start;
  44640. while (n < length && end + 1 === codes[n].fontCharCode) {
  44641. codeIndices.push(codes[n].glyphId);
  44642. ++end;
  44643. ++n;
  44644. if (end === 0xFFFF) {
  44645. break;
  44646. }
  44647. }
  44648. ranges.push([
  44649. start,
  44650. end,
  44651. codeIndices
  44652. ]);
  44653. }
  44654. return ranges;
  44655. }
  44656. function createCmapTable(glyphs, numGlyphs) {
  44657. var ranges = getRanges(glyphs, numGlyphs);
  44658. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  44659. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  44660. var i, ii, j, jj;
  44661. for (i = ranges.length - 1; i >= 0; --i) {
  44662. if (ranges[i][0] <= 0xFFFF) {
  44663. break;
  44664. }
  44665. }
  44666. var bmpLength = i + 1;
  44667. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  44668. ranges[i][1] = 0xFFFE;
  44669. }
  44670. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  44671. var segCount = bmpLength + trailingRangesCount;
  44672. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  44673. var startCount = '';
  44674. var endCount = '';
  44675. var idDeltas = '';
  44676. var idRangeOffsets = '';
  44677. var glyphsIds = '';
  44678. var bias = 0;
  44679. var range, start, end, codes;
  44680. for (i = 0, ii = bmpLength; i < ii; i++) {
  44681. range = ranges[i];
  44682. start = range[0];
  44683. end = range[1];
  44684. startCount += string16(start);
  44685. endCount += string16(end);
  44686. codes = range[2];
  44687. var contiguous = true;
  44688. for (j = 1, jj = codes.length; j < jj; ++j) {
  44689. if (codes[j] !== codes[j - 1] + 1) {
  44690. contiguous = false;
  44691. break;
  44692. }
  44693. }
  44694. if (!contiguous) {
  44695. var offset = (segCount - i) * 2 + bias * 2;
  44696. bias += end - start + 1;
  44697. idDeltas += string16(0);
  44698. idRangeOffsets += string16(offset);
  44699. for (j = 0, jj = codes.length; j < jj; ++j) {
  44700. glyphsIds += string16(codes[j]);
  44701. }
  44702. } else {
  44703. var startCode = codes[0];
  44704. idDeltas += string16(startCode - start & 0xFFFF);
  44705. idRangeOffsets += string16(0);
  44706. }
  44707. }
  44708. if (trailingRangesCount > 0) {
  44709. endCount += '\xFF\xFF';
  44710. startCount += '\xFF\xFF';
  44711. idDeltas += '\x00\x01';
  44712. idRangeOffsets += '\x00\x00';
  44713. }
  44714. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  44715. var format31012 = '';
  44716. var header31012 = '';
  44717. if (numTables > 1) {
  44718. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  44719. format31012 = '';
  44720. for (i = 0, ii = ranges.length; i < ii; i++) {
  44721. range = ranges[i];
  44722. start = range[0];
  44723. codes = range[2];
  44724. var code = codes[0];
  44725. for (j = 1, jj = codes.length; j < jj; ++j) {
  44726. if (codes[j] !== codes[j - 1] + 1) {
  44727. end = range[0] + j - 1;
  44728. format31012 += string32(start) + string32(end) + string32(code);
  44729. start = end + 1;
  44730. code = codes[j];
  44731. }
  44732. }
  44733. format31012 += string32(start) + string32(range[1]) + string32(code);
  44734. }
  44735. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  44736. }
  44737. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  44738. }
  44739. function validateOS2Table(os2) {
  44740. var stream = new Stream(os2.data);
  44741. var version = stream.getUint16();
  44742. stream.getBytes(60);
  44743. var selection = stream.getUint16();
  44744. if (version < 4 && selection & 0x0300) {
  44745. return false;
  44746. }
  44747. var firstChar = stream.getUint16();
  44748. var lastChar = stream.getUint16();
  44749. if (firstChar > lastChar) {
  44750. return false;
  44751. }
  44752. stream.getBytes(6);
  44753. var usWinAscent = stream.getUint16();
  44754. if (usWinAscent === 0) {
  44755. return false;
  44756. }
  44757. os2.data[8] = os2.data[9] = 0;
  44758. return true;
  44759. }
  44760. function createOS2Table(properties, charstrings, override) {
  44761. override = override || {
  44762. unitsPerEm: 0,
  44763. yMax: 0,
  44764. yMin: 0,
  44765. ascent: 0,
  44766. descent: 0
  44767. };
  44768. var ulUnicodeRange1 = 0;
  44769. var ulUnicodeRange2 = 0;
  44770. var ulUnicodeRange3 = 0;
  44771. var ulUnicodeRange4 = 0;
  44772. var firstCharIndex = null;
  44773. var lastCharIndex = 0;
  44774. if (charstrings) {
  44775. for (var code in charstrings) {
  44776. code |= 0;
  44777. if (firstCharIndex > code || !firstCharIndex) {
  44778. firstCharIndex = code;
  44779. }
  44780. if (lastCharIndex < code) {
  44781. lastCharIndex = code;
  44782. }
  44783. var position = getUnicodeRangeFor(code);
  44784. if (position < 32) {
  44785. ulUnicodeRange1 |= 1 << position;
  44786. } else if (position < 64) {
  44787. ulUnicodeRange2 |= 1 << position - 32;
  44788. } else if (position < 96) {
  44789. ulUnicodeRange3 |= 1 << position - 64;
  44790. } else if (position < 123) {
  44791. ulUnicodeRange4 |= 1 << position - 96;
  44792. } else {
  44793. error('Unicode ranges Bits > 123 are reserved for internal usage');
  44794. }
  44795. }
  44796. } else {
  44797. firstCharIndex = 0;
  44798. lastCharIndex = 255;
  44799. }
  44800. var bbox = properties.bbox || [
  44801. 0,
  44802. 0,
  44803. 0,
  44804. 0
  44805. ];
  44806. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  44807. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  44808. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  44809. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  44810. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  44811. typoDescent = -typoDescent;
  44812. }
  44813. var winAscent = override.yMax || typoAscent;
  44814. var winDescent = -override.yMin || -typoDescent;
  44815. 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' + string32(ulUnicodeRange1) + string32(ulUnicodeRange2) + string32(ulUnicodeRange3) + 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';
  44816. }
  44817. function createPostTable(properties) {
  44818. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  44819. return '\x00\x03\x00\x00' + string32(angle) + '\x00\x00' + '\x00\x00' + string32(properties.fixedPitch) + '\x00\x00\x00\x00' + '\x00\x00\x00\x00' + '\x00\x00\x00\x00' + '\x00\x00\x00\x00';
  44820. }
  44821. function createNameTable(name, proto) {
  44822. if (!proto) {
  44823. proto = [
  44824. [],
  44825. []
  44826. ];
  44827. }
  44828. var strings = [
  44829. proto[0][0] || 'Original licence',
  44830. proto[0][1] || name,
  44831. proto[0][2] || 'Unknown',
  44832. proto[0][3] || 'uniqueID',
  44833. proto[0][4] || name,
  44834. proto[0][5] || 'Version 0.11',
  44835. proto[0][6] || '',
  44836. proto[0][7] || 'Unknown',
  44837. proto[0][8] || 'Unknown',
  44838. proto[0][9] || 'Unknown'
  44839. ];
  44840. var stringsUnicode = [];
  44841. var i, ii, j, jj, str;
  44842. for (i = 0, ii = strings.length; i < ii; i++) {
  44843. str = proto[1][i] || strings[i];
  44844. var strBufUnicode = [];
  44845. for (j = 0, jj = str.length; j < jj; j++) {
  44846. strBufUnicode.push(string16(str.charCodeAt(j)));
  44847. }
  44848. stringsUnicode.push(strBufUnicode.join(''));
  44849. }
  44850. var names = [
  44851. strings,
  44852. stringsUnicode
  44853. ];
  44854. var platforms = [
  44855. '\x00\x01',
  44856. '\x00\x03'
  44857. ];
  44858. var encodings = [
  44859. '\x00\x00',
  44860. '\x00\x01'
  44861. ];
  44862. var languages = [
  44863. '\x00\x00',
  44864. '\x04\x09'
  44865. ];
  44866. var namesRecordCount = strings.length * platforms.length;
  44867. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  44868. var strOffset = 0;
  44869. for (i = 0, ii = platforms.length; i < ii; i++) {
  44870. var strs = names[i];
  44871. for (j = 0, jj = strs.length; j < jj; j++) {
  44872. str = strs[j];
  44873. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  44874. nameTable += nameRecord;
  44875. strOffset += str.length;
  44876. }
  44877. }
  44878. nameTable += strings.join('') + stringsUnicode.join('');
  44879. return nameTable;
  44880. }
  44881. Font.prototype = {
  44882. name: null,
  44883. font: null,
  44884. mimetype: null,
  44885. encoding: null,
  44886. get renderer() {
  44887. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  44888. return shadow(this, 'renderer', renderer);
  44889. },
  44890. exportData: function Font_exportData() {
  44891. var data = {};
  44892. for (var i in this) {
  44893. if (this.hasOwnProperty(i)) {
  44894. data[i] = this[i];
  44895. }
  44896. }
  44897. return data;
  44898. },
  44899. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  44900. function readTableEntry(file) {
  44901. var tag = bytesToString(file.getBytes(4));
  44902. var checksum = file.getInt32() >>> 0;
  44903. var offset = file.getInt32() >>> 0;
  44904. var length = file.getInt32() >>> 0;
  44905. var previousPosition = file.pos;
  44906. file.pos = file.start ? file.start : 0;
  44907. file.skip(offset);
  44908. var data = file.getBytes(length);
  44909. file.pos = previousPosition;
  44910. if (tag === 'head') {
  44911. data[8] = data[9] = data[10] = data[11] = 0;
  44912. data[17] |= 0x20;
  44913. }
  44914. return {
  44915. tag: tag,
  44916. checksum: checksum,
  44917. length: length,
  44918. offset: offset,
  44919. data: data
  44920. };
  44921. }
  44922. function readOpenTypeHeader(ttf) {
  44923. return {
  44924. version: bytesToString(ttf.getBytes(4)),
  44925. numTables: ttf.getUint16(),
  44926. searchRange: ttf.getUint16(),
  44927. entrySelector: ttf.getUint16(),
  44928. rangeShift: ttf.getUint16()
  44929. };
  44930. }
  44931. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  44932. if (!cmap) {
  44933. warn('No cmap table available.');
  44934. return {
  44935. platformId: -1,
  44936. encodingId: -1,
  44937. mappings: [],
  44938. hasShortCmap: false
  44939. };
  44940. }
  44941. var segment;
  44942. var start = (font.start ? font.start : 0) + cmap.offset;
  44943. font.pos = start;
  44944. font.getUint16();
  44945. var numTables = font.getUint16();
  44946. var potentialTable;
  44947. var canBreak = false;
  44948. for (var i = 0; i < numTables; i++) {
  44949. var platformId = font.getUint16();
  44950. var encodingId = font.getUint16();
  44951. var offset = font.getInt32() >>> 0;
  44952. var useTable = false;
  44953. if (platformId === 0 && encodingId === 0) {
  44954. useTable = true;
  44955. } else if (platformId === 1 && encodingId === 0) {
  44956. useTable = true;
  44957. } else if (platformId === 3 && encodingId === 1 && (hasEncoding || !potentialTable)) {
  44958. useTable = true;
  44959. if (!isSymbolicFont) {
  44960. canBreak = true;
  44961. }
  44962. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  44963. useTable = true;
  44964. canBreak = true;
  44965. }
  44966. if (useTable) {
  44967. potentialTable = {
  44968. platformId: platformId,
  44969. encodingId: encodingId,
  44970. offset: offset
  44971. };
  44972. }
  44973. if (canBreak) {
  44974. break;
  44975. }
  44976. }
  44977. if (potentialTable) {
  44978. font.pos = start + potentialTable.offset;
  44979. }
  44980. if (!potentialTable || font.peekByte() === -1) {
  44981. warn('Could not find a preferred cmap table.');
  44982. return {
  44983. platformId: -1,
  44984. encodingId: -1,
  44985. mappings: [],
  44986. hasShortCmap: false
  44987. };
  44988. }
  44989. var format = font.getUint16();
  44990. font.getUint16();
  44991. font.getUint16();
  44992. var hasShortCmap = false;
  44993. var mappings = [];
  44994. var j, glyphId;
  44995. if (format === 0) {
  44996. for (j = 0; j < 256; j++) {
  44997. var index = font.getByte();
  44998. if (!index) {
  44999. continue;
  45000. }
  45001. mappings.push({
  45002. charCode: j,
  45003. glyphId: index
  45004. });
  45005. }
  45006. hasShortCmap = true;
  45007. } else if (format === 4) {
  45008. var segCount = font.getUint16() >> 1;
  45009. font.getBytes(6);
  45010. var segIndex, segments = [];
  45011. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45012. segments.push({ end: font.getUint16() });
  45013. }
  45014. font.getUint16();
  45015. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45016. segments[segIndex].start = font.getUint16();
  45017. }
  45018. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45019. segments[segIndex].delta = font.getUint16();
  45020. }
  45021. var offsetsCount = 0;
  45022. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45023. segment = segments[segIndex];
  45024. var rangeOffset = font.getUint16();
  45025. if (!rangeOffset) {
  45026. segment.offsetIndex = -1;
  45027. continue;
  45028. }
  45029. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  45030. segment.offsetIndex = offsetIndex;
  45031. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  45032. }
  45033. var offsets = [];
  45034. for (j = 0; j < offsetsCount; j++) {
  45035. offsets.push(font.getUint16());
  45036. }
  45037. for (segIndex = 0; segIndex < segCount; segIndex++) {
  45038. segment = segments[segIndex];
  45039. start = segment.start;
  45040. var end = segment.end;
  45041. var delta = segment.delta;
  45042. offsetIndex = segment.offsetIndex;
  45043. for (j = start; j <= end; j++) {
  45044. if (j === 0xFFFF) {
  45045. continue;
  45046. }
  45047. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  45048. glyphId = glyphId + delta & 0xFFFF;
  45049. if (glyphId === 0) {
  45050. continue;
  45051. }
  45052. mappings.push({
  45053. charCode: j,
  45054. glyphId: glyphId
  45055. });
  45056. }
  45057. }
  45058. } else if (format === 6) {
  45059. var firstCode = font.getUint16();
  45060. var entryCount = font.getUint16();
  45061. for (j = 0; j < entryCount; j++) {
  45062. glyphId = font.getUint16();
  45063. var charCode = firstCode + j;
  45064. mappings.push({
  45065. charCode: charCode,
  45066. glyphId: glyphId
  45067. });
  45068. }
  45069. } else {
  45070. warn('cmap table has unsupported format: ' + format);
  45071. return {
  45072. platformId: -1,
  45073. encodingId: -1,
  45074. mappings: [],
  45075. hasShortCmap: false
  45076. };
  45077. }
  45078. mappings.sort(function (a, b) {
  45079. return a.charCode - b.charCode;
  45080. });
  45081. for (i = 1; i < mappings.length; i++) {
  45082. if (mappings[i - 1].charCode === mappings[i].charCode) {
  45083. mappings.splice(i, 1);
  45084. i--;
  45085. }
  45086. }
  45087. return {
  45088. platformId: potentialTable.platformId,
  45089. encodingId: potentialTable.encodingId,
  45090. mappings: mappings,
  45091. hasShortCmap: hasShortCmap
  45092. };
  45093. }
  45094. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  45095. if (!header) {
  45096. if (metrics) {
  45097. metrics.data = null;
  45098. }
  45099. return;
  45100. }
  45101. font.pos = (font.start ? font.start : 0) + header.offset;
  45102. font.pos += header.length - 2;
  45103. var numOfMetrics = font.getUint16();
  45104. if (numOfMetrics > numGlyphs) {
  45105. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  45106. numOfMetrics = numGlyphs;
  45107. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  45108. header.data[35] = numOfMetrics & 0x00ff;
  45109. }
  45110. var numOfSidebearings = numGlyphs - numOfMetrics;
  45111. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  45112. if (numMissing > 0) {
  45113. var entries = new Uint8Array(metrics.length + numMissing * 2);
  45114. entries.set(metrics.data);
  45115. metrics.data = entries;
  45116. }
  45117. }
  45118. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  45119. if (sourceEnd - sourceStart <= 12) {
  45120. return 0;
  45121. }
  45122. var glyf = source.subarray(sourceStart, sourceEnd);
  45123. var contoursCount = glyf[0] << 8 | glyf[1];
  45124. if (contoursCount & 0x8000) {
  45125. dest.set(glyf, destStart);
  45126. return glyf.length;
  45127. }
  45128. var i, j = 10, flagsCount = 0;
  45129. for (i = 0; i < contoursCount; i++) {
  45130. var endPoint = glyf[j] << 8 | glyf[j + 1];
  45131. flagsCount = endPoint + 1;
  45132. j += 2;
  45133. }
  45134. var instructionsStart = j;
  45135. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  45136. j += 2 + instructionsLength;
  45137. var instructionsEnd = j;
  45138. var coordinatesLength = 0;
  45139. for (i = 0; i < flagsCount; i++) {
  45140. var flag = glyf[j++];
  45141. if (flag & 0xC0) {
  45142. glyf[j - 1] = flag & 0x3F;
  45143. }
  45144. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  45145. coordinatesLength += xyLength;
  45146. if (flag & 8) {
  45147. var repeat = glyf[j++];
  45148. i += repeat;
  45149. coordinatesLength += repeat * xyLength;
  45150. }
  45151. }
  45152. if (coordinatesLength === 0) {
  45153. return 0;
  45154. }
  45155. var glyphDataLength = j + coordinatesLength;
  45156. if (glyphDataLength > glyf.length) {
  45157. return 0;
  45158. }
  45159. if (!hintsValid && instructionsLength > 0) {
  45160. dest.set(glyf.subarray(0, instructionsStart), destStart);
  45161. dest.set([
  45162. 0,
  45163. 0
  45164. ], destStart + instructionsStart);
  45165. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  45166. glyphDataLength -= instructionsLength;
  45167. if (glyf.length - glyphDataLength > 3) {
  45168. glyphDataLength = glyphDataLength + 3 & ~3;
  45169. }
  45170. return glyphDataLength;
  45171. }
  45172. if (glyf.length - glyphDataLength > 3) {
  45173. glyphDataLength = glyphDataLength + 3 & ~3;
  45174. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  45175. return glyphDataLength;
  45176. }
  45177. dest.set(glyf, destStart);
  45178. return glyf.length;
  45179. }
  45180. function sanitizeHead(head, numGlyphs, locaLength) {
  45181. var data = head.data;
  45182. var version = int32(data[0], data[1], data[2], data[3]);
  45183. if (version >> 16 !== 1) {
  45184. info('Attempting to fix invalid version in head table: ' + version);
  45185. data[0] = 0;
  45186. data[1] = 1;
  45187. data[2] = 0;
  45188. data[3] = 0;
  45189. }
  45190. var indexToLocFormat = int16(data[50], data[51]);
  45191. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  45192. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  45193. var numGlyphsPlusOne = numGlyphs + 1;
  45194. if (locaLength === numGlyphsPlusOne << 1) {
  45195. data[50] = 0;
  45196. data[51] = 0;
  45197. } else if (locaLength === numGlyphsPlusOne << 2) {
  45198. data[50] = 0;
  45199. data[51] = 1;
  45200. } else {
  45201. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  45202. }
  45203. }
  45204. }
  45205. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  45206. var itemSize, itemDecode, itemEncode;
  45207. if (isGlyphLocationsLong) {
  45208. itemSize = 4;
  45209. itemDecode = function fontItemDecodeLong(data, offset) {
  45210. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  45211. };
  45212. itemEncode = function fontItemEncodeLong(data, offset, value) {
  45213. data[offset] = value >>> 24 & 0xFF;
  45214. data[offset + 1] = value >> 16 & 0xFF;
  45215. data[offset + 2] = value >> 8 & 0xFF;
  45216. data[offset + 3] = value & 0xFF;
  45217. };
  45218. } else {
  45219. itemSize = 2;
  45220. itemDecode = function fontItemDecode(data, offset) {
  45221. return data[offset] << 9 | data[offset + 1] << 1;
  45222. };
  45223. itemEncode = function fontItemEncode(data, offset, value) {
  45224. data[offset] = value >> 9 & 0xFF;
  45225. data[offset + 1] = value >> 1 & 0xFF;
  45226. };
  45227. }
  45228. var locaData = loca.data;
  45229. var locaDataSize = itemSize * (1 + numGlyphs);
  45230. if (locaData.length !== locaDataSize) {
  45231. locaData = new Uint8Array(locaDataSize);
  45232. locaData.set(loca.data.subarray(0, locaDataSize));
  45233. loca.data = locaData;
  45234. }
  45235. var oldGlyfData = glyf.data;
  45236. var oldGlyfDataLength = oldGlyfData.length;
  45237. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  45238. var startOffset = itemDecode(locaData, 0);
  45239. var writeOffset = 0;
  45240. var missingGlyphData = Object.create(null);
  45241. itemEncode(locaData, 0, writeOffset);
  45242. var i, j;
  45243. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  45244. var endOffset = itemDecode(locaData, j);
  45245. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  45246. endOffset = oldGlyfDataLength;
  45247. }
  45248. if (endOffset > oldGlyfDataLength) {
  45249. itemEncode(locaData, j, writeOffset);
  45250. startOffset = endOffset;
  45251. continue;
  45252. }
  45253. if (startOffset === endOffset) {
  45254. missingGlyphData[i] = true;
  45255. }
  45256. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  45257. writeOffset += newLength;
  45258. itemEncode(locaData, j, writeOffset);
  45259. startOffset = endOffset;
  45260. }
  45261. if (writeOffset === 0) {
  45262. var simpleGlyph = new Uint8Array([
  45263. 0,
  45264. 1,
  45265. 0,
  45266. 0,
  45267. 0,
  45268. 0,
  45269. 0,
  45270. 0,
  45271. 0,
  45272. 0,
  45273. 0,
  45274. 0,
  45275. 0,
  45276. 0,
  45277. 49,
  45278. 0
  45279. ]);
  45280. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  45281. itemEncode(locaData, j, simpleGlyph.length);
  45282. }
  45283. glyf.data = simpleGlyph;
  45284. return missingGlyphData;
  45285. }
  45286. if (dupFirstEntry) {
  45287. var firstEntryLength = itemDecode(locaData, itemSize);
  45288. if (newGlyfData.length > firstEntryLength + writeOffset) {
  45289. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  45290. } else {
  45291. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  45292. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  45293. }
  45294. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  45295. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  45296. } else {
  45297. glyf.data = newGlyfData.subarray(0, writeOffset);
  45298. }
  45299. return missingGlyphData;
  45300. }
  45301. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  45302. var start = (font.start ? font.start : 0) + post.offset;
  45303. font.pos = start;
  45304. var length = post.length, end = start + length;
  45305. var version = font.getInt32();
  45306. font.getBytes(28);
  45307. var glyphNames;
  45308. var valid = true;
  45309. var i;
  45310. switch (version) {
  45311. case 0x00010000:
  45312. glyphNames = MacStandardGlyphOrdering;
  45313. break;
  45314. case 0x00020000:
  45315. var numGlyphs = font.getUint16();
  45316. if (numGlyphs !== maxpNumGlyphs) {
  45317. valid = false;
  45318. break;
  45319. }
  45320. var glyphNameIndexes = [];
  45321. for (i = 0; i < numGlyphs; ++i) {
  45322. var index = font.getUint16();
  45323. if (index >= 32768) {
  45324. valid = false;
  45325. break;
  45326. }
  45327. glyphNameIndexes.push(index);
  45328. }
  45329. if (!valid) {
  45330. break;
  45331. }
  45332. var customNames = [];
  45333. var strBuf = [];
  45334. while (font.pos < end) {
  45335. var stringLength = font.getByte();
  45336. strBuf.length = stringLength;
  45337. for (i = 0; i < stringLength; ++i) {
  45338. strBuf[i] = String.fromCharCode(font.getByte());
  45339. }
  45340. customNames.push(strBuf.join(''));
  45341. }
  45342. glyphNames = [];
  45343. for (i = 0; i < numGlyphs; ++i) {
  45344. var j = glyphNameIndexes[i];
  45345. if (j < 258) {
  45346. glyphNames.push(MacStandardGlyphOrdering[j]);
  45347. continue;
  45348. }
  45349. glyphNames.push(customNames[j - 258]);
  45350. }
  45351. break;
  45352. case 0x00030000:
  45353. break;
  45354. default:
  45355. warn('Unknown/unsupported post table version ' + version);
  45356. valid = false;
  45357. if (properties.defaultEncoding) {
  45358. glyphNames = properties.defaultEncoding;
  45359. }
  45360. break;
  45361. }
  45362. properties.glyphNames = glyphNames;
  45363. return valid;
  45364. }
  45365. function readNameTable(nameTable) {
  45366. var start = (font.start ? font.start : 0) + nameTable.offset;
  45367. font.pos = start;
  45368. var names = [
  45369. [],
  45370. []
  45371. ];
  45372. var length = nameTable.length, end = start + length;
  45373. var format = font.getUint16();
  45374. var FORMAT_0_HEADER_LENGTH = 6;
  45375. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  45376. return names;
  45377. }
  45378. var numRecords = font.getUint16();
  45379. var stringsStart = font.getUint16();
  45380. var records = [];
  45381. var NAME_RECORD_LENGTH = 12;
  45382. var i, ii;
  45383. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  45384. var r = {
  45385. platform: font.getUint16(),
  45386. encoding: font.getUint16(),
  45387. language: font.getUint16(),
  45388. name: font.getUint16(),
  45389. length: font.getUint16(),
  45390. offset: font.getUint16()
  45391. };
  45392. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  45393. records.push(r);
  45394. }
  45395. }
  45396. for (i = 0, ii = records.length; i < ii; i++) {
  45397. var record = records[i];
  45398. if (record.length <= 0) {
  45399. continue;
  45400. }
  45401. var pos = start + stringsStart + record.offset;
  45402. if (pos + record.length > end) {
  45403. continue;
  45404. }
  45405. font.pos = pos;
  45406. var nameIndex = record.name;
  45407. if (record.encoding) {
  45408. var str = '';
  45409. for (var j = 0, jj = record.length; j < jj; j += 2) {
  45410. str += String.fromCharCode(font.getUint16());
  45411. }
  45412. names[1][nameIndex] = str;
  45413. } else {
  45414. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  45415. }
  45416. }
  45417. return names;
  45418. }
  45419. var TTOpsStackDeltas = [
  45420. 0,
  45421. 0,
  45422. 0,
  45423. 0,
  45424. 0,
  45425. 0,
  45426. 0,
  45427. 0,
  45428. -2,
  45429. -2,
  45430. -2,
  45431. -2,
  45432. 0,
  45433. 0,
  45434. -2,
  45435. -5,
  45436. -1,
  45437. -1,
  45438. -1,
  45439. -1,
  45440. -1,
  45441. -1,
  45442. -1,
  45443. -1,
  45444. 0,
  45445. 0,
  45446. -1,
  45447. 0,
  45448. -1,
  45449. -1,
  45450. -1,
  45451. -1,
  45452. 1,
  45453. -1,
  45454. -999,
  45455. 0,
  45456. 1,
  45457. 0,
  45458. -1,
  45459. -2,
  45460. 0,
  45461. -1,
  45462. -2,
  45463. -1,
  45464. -1,
  45465. 0,
  45466. -1,
  45467. -1,
  45468. 0,
  45469. 0,
  45470. -999,
  45471. -999,
  45472. -1,
  45473. -1,
  45474. -1,
  45475. -1,
  45476. -2,
  45477. -999,
  45478. -2,
  45479. -2,
  45480. -999,
  45481. 0,
  45482. -2,
  45483. -2,
  45484. 0,
  45485. 0,
  45486. -2,
  45487. 0,
  45488. -2,
  45489. 0,
  45490. 0,
  45491. 0,
  45492. -2,
  45493. -1,
  45494. -1,
  45495. 1,
  45496. 1,
  45497. 0,
  45498. 0,
  45499. -1,
  45500. -1,
  45501. -1,
  45502. -1,
  45503. -1,
  45504. -1,
  45505. -1,
  45506. 0,
  45507. 0,
  45508. -1,
  45509. 0,
  45510. -1,
  45511. -1,
  45512. 0,
  45513. -999,
  45514. -1,
  45515. -1,
  45516. -1,
  45517. -1,
  45518. -1,
  45519. -1,
  45520. 0,
  45521. 0,
  45522. 0,
  45523. 0,
  45524. 0,
  45525. 0,
  45526. 0,
  45527. 0,
  45528. 0,
  45529. 0,
  45530. 0,
  45531. 0,
  45532. -2,
  45533. -999,
  45534. -999,
  45535. -999,
  45536. -999,
  45537. -999,
  45538. -1,
  45539. -1,
  45540. -2,
  45541. -2,
  45542. 0,
  45543. 0,
  45544. 0,
  45545. 0,
  45546. -1,
  45547. -1,
  45548. -999,
  45549. -2,
  45550. -2,
  45551. 0,
  45552. 0,
  45553. -1,
  45554. -2,
  45555. -2,
  45556. 0,
  45557. 0,
  45558. 0,
  45559. -1,
  45560. -1,
  45561. -1,
  45562. -2
  45563. ];
  45564. function sanitizeTTProgram(table, ttContext) {
  45565. var data = table.data;
  45566. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  45567. var stack = [];
  45568. var callstack = [];
  45569. var functionsCalled = [];
  45570. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  45571. var inFDEF = false, ifLevel = 0, inELSE = 0;
  45572. for (var ii = data.length; i < ii;) {
  45573. var op = data[i++];
  45574. if (op === 0x40) {
  45575. n = data[i++];
  45576. if (inFDEF || inELSE) {
  45577. i += n;
  45578. } else {
  45579. for (j = 0; j < n; j++) {
  45580. stack.push(data[i++]);
  45581. }
  45582. }
  45583. } else if (op === 0x41) {
  45584. n = data[i++];
  45585. if (inFDEF || inELSE) {
  45586. i += n * 2;
  45587. } else {
  45588. for (j = 0; j < n; j++) {
  45589. b = data[i++];
  45590. stack.push(b << 8 | data[i++]);
  45591. }
  45592. }
  45593. } else if ((op & 0xF8) === 0xB0) {
  45594. n = op - 0xB0 + 1;
  45595. if (inFDEF || inELSE) {
  45596. i += n;
  45597. } else {
  45598. for (j = 0; j < n; j++) {
  45599. stack.push(data[i++]);
  45600. }
  45601. }
  45602. } else if ((op & 0xF8) === 0xB8) {
  45603. n = op - 0xB8 + 1;
  45604. if (inFDEF || inELSE) {
  45605. i += n * 2;
  45606. } else {
  45607. for (j = 0; j < n; j++) {
  45608. b = data[i++];
  45609. stack.push(b << 8 | data[i++]);
  45610. }
  45611. }
  45612. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  45613. if (!inFDEF && !inELSE) {
  45614. funcId = stack[stack.length - 1];
  45615. ttContext.functionsUsed[funcId] = true;
  45616. if (funcId in ttContext.functionsStackDeltas) {
  45617. stack.length += ttContext.functionsStackDeltas[funcId];
  45618. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  45619. callstack.push({
  45620. data: data,
  45621. i: i,
  45622. stackTop: stack.length - 1
  45623. });
  45624. functionsCalled.push(funcId);
  45625. pc = ttContext.functionsDefined[funcId];
  45626. if (!pc) {
  45627. warn('TT: CALL non-existent function');
  45628. ttContext.hintsValid = false;
  45629. return;
  45630. }
  45631. data = pc.data;
  45632. i = pc.i;
  45633. }
  45634. }
  45635. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  45636. if (inFDEF || inELSE) {
  45637. warn('TT: nested FDEFs not allowed');
  45638. tooComplexToFollowFunctions = true;
  45639. }
  45640. inFDEF = true;
  45641. lastDeff = i;
  45642. funcId = stack.pop();
  45643. ttContext.functionsDefined[funcId] = {
  45644. data: data,
  45645. i: i
  45646. };
  45647. } else if (op === 0x2D) {
  45648. if (inFDEF) {
  45649. inFDEF = false;
  45650. lastEndf = i;
  45651. } else {
  45652. pc = callstack.pop();
  45653. if (!pc) {
  45654. warn('TT: ENDF bad stack');
  45655. ttContext.hintsValid = false;
  45656. return;
  45657. }
  45658. funcId = functionsCalled.pop();
  45659. data = pc.data;
  45660. i = pc.i;
  45661. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  45662. }
  45663. } else if (op === 0x89) {
  45664. if (inFDEF || inELSE) {
  45665. warn('TT: nested IDEFs not allowed');
  45666. tooComplexToFollowFunctions = true;
  45667. }
  45668. inFDEF = true;
  45669. lastDeff = i;
  45670. } else if (op === 0x58) {
  45671. ++ifLevel;
  45672. } else if (op === 0x1B) {
  45673. inELSE = ifLevel;
  45674. } else if (op === 0x59) {
  45675. if (inELSE === ifLevel) {
  45676. inELSE = 0;
  45677. }
  45678. --ifLevel;
  45679. } else if (op === 0x1C) {
  45680. if (!inFDEF && !inELSE) {
  45681. var offset = stack[stack.length - 1];
  45682. if (offset > 0) {
  45683. i += offset - 1;
  45684. }
  45685. }
  45686. }
  45687. if (!inFDEF && !inELSE) {
  45688. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  45689. if (op >= 0x71 && op <= 0x75) {
  45690. n = stack.pop();
  45691. if (!isNaN(n)) {
  45692. stackDelta = -n * 2;
  45693. }
  45694. }
  45695. while (stackDelta < 0 && stack.length > 0) {
  45696. stack.pop();
  45697. stackDelta++;
  45698. }
  45699. while (stackDelta > 0) {
  45700. stack.push(NaN);
  45701. stackDelta--;
  45702. }
  45703. }
  45704. }
  45705. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  45706. var content = [data];
  45707. if (i > data.length) {
  45708. content.push(new Uint8Array(i - data.length));
  45709. }
  45710. if (lastDeff > lastEndf) {
  45711. warn('TT: complementing a missing function tail');
  45712. content.push(new Uint8Array([
  45713. 0x22,
  45714. 0x2D
  45715. ]));
  45716. }
  45717. foldTTTable(table, content);
  45718. }
  45719. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  45720. if (ttContext.tooComplexToFollowFunctions) {
  45721. return;
  45722. }
  45723. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  45724. warn('TT: more functions defined than expected');
  45725. ttContext.hintsValid = false;
  45726. return;
  45727. }
  45728. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  45729. if (j > maxFunctionDefs) {
  45730. warn('TT: invalid function id: ' + j);
  45731. ttContext.hintsValid = false;
  45732. return;
  45733. }
  45734. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  45735. warn('TT: undefined function: ' + j);
  45736. ttContext.hintsValid = false;
  45737. return;
  45738. }
  45739. }
  45740. }
  45741. function foldTTTable(table, content) {
  45742. if (content.length > 1) {
  45743. var newLength = 0;
  45744. var j, jj;
  45745. for (j = 0, jj = content.length; j < jj; j++) {
  45746. newLength += content[j].length;
  45747. }
  45748. newLength = newLength + 3 & ~3;
  45749. var result = new Uint8Array(newLength);
  45750. var pos = 0;
  45751. for (j = 0, jj = content.length; j < jj; j++) {
  45752. result.set(content[j], pos);
  45753. pos += content[j].length;
  45754. }
  45755. table.data = result;
  45756. table.length = newLength;
  45757. }
  45758. }
  45759. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  45760. var ttContext = {
  45761. functionsDefined: [],
  45762. functionsUsed: [],
  45763. functionsStackDeltas: [],
  45764. tooComplexToFollowFunctions: false,
  45765. hintsValid: true
  45766. };
  45767. if (fpgm) {
  45768. sanitizeTTProgram(fpgm, ttContext);
  45769. }
  45770. if (prep) {
  45771. sanitizeTTProgram(prep, ttContext);
  45772. }
  45773. if (fpgm) {
  45774. checkInvalidFunctions(ttContext, maxFunctionDefs);
  45775. }
  45776. if (cvt && cvt.length & 1) {
  45777. var cvtData = new Uint8Array(cvt.length + 1);
  45778. cvtData.set(cvt.data);
  45779. cvt.data = cvtData;
  45780. }
  45781. return ttContext.hintsValid;
  45782. }
  45783. font = new Stream(new Uint8Array(font.getBytes()));
  45784. var VALID_TABLES = [
  45785. 'OS/2',
  45786. 'cmap',
  45787. 'head',
  45788. 'hhea',
  45789. 'hmtx',
  45790. 'maxp',
  45791. 'name',
  45792. 'post',
  45793. 'loca',
  45794. 'glyf',
  45795. 'fpgm',
  45796. 'prep',
  45797. 'cvt ',
  45798. 'CFF '
  45799. ];
  45800. var header = readOpenTypeHeader(font);
  45801. var numTables = header.numTables;
  45802. var cff, cffFile;
  45803. var tables = Object.create(null);
  45804. tables['OS/2'] = null;
  45805. tables['cmap'] = null;
  45806. tables['head'] = null;
  45807. tables['hhea'] = null;
  45808. tables['hmtx'] = null;
  45809. tables['maxp'] = null;
  45810. tables['name'] = null;
  45811. tables['post'] = null;
  45812. var table;
  45813. for (var i = 0; i < numTables; i++) {
  45814. table = readTableEntry(font);
  45815. if (VALID_TABLES.indexOf(table.tag) < 0) {
  45816. continue;
  45817. }
  45818. if (table.length === 0) {
  45819. continue;
  45820. }
  45821. tables[table.tag] = table;
  45822. }
  45823. var isTrueType = !tables['CFF '];
  45824. if (!isTrueType) {
  45825. if (header.version === 'OTTO' && !properties.composite || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  45826. cffFile = new Stream(tables['CFF '].data);
  45827. cff = new CFFFont(cffFile, properties);
  45828. adjustWidths(properties);
  45829. return this.convert(name, cff, properties);
  45830. }
  45831. delete tables['glyf'];
  45832. delete tables['loca'];
  45833. delete tables['fpgm'];
  45834. delete tables['prep'];
  45835. delete tables['cvt '];
  45836. this.isOpenType = true;
  45837. } else {
  45838. if (!tables['loca']) {
  45839. error('Required "loca" table is not found');
  45840. }
  45841. if (!tables['glyf']) {
  45842. warn('Required "glyf" table is not found -- trying to recover.');
  45843. tables['glyf'] = {
  45844. tag: 'glyf',
  45845. data: new Uint8Array(0)
  45846. };
  45847. }
  45848. this.isOpenType = false;
  45849. }
  45850. if (!tables['maxp']) {
  45851. error('Required "maxp" table is not found');
  45852. }
  45853. font.pos = (font.start || 0) + tables['maxp'].offset;
  45854. var version = font.getInt32();
  45855. var numGlyphs = font.getUint16();
  45856. var maxFunctionDefs = 0;
  45857. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  45858. font.pos += 8;
  45859. var maxZones = font.getUint16();
  45860. if (maxZones > 2) {
  45861. tables['maxp'].data[14] = 0;
  45862. tables['maxp'].data[15] = 2;
  45863. }
  45864. font.pos += 4;
  45865. maxFunctionDefs = font.getUint16();
  45866. }
  45867. var dupFirstEntry = false;
  45868. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  45869. dupFirstEntry = true;
  45870. numGlyphs++;
  45871. tables['maxp'].data[4] = numGlyphs >> 8;
  45872. tables['maxp'].data[5] = numGlyphs & 255;
  45873. }
  45874. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  45875. if (!hintsValid) {
  45876. delete tables['fpgm'];
  45877. delete tables['prep'];
  45878. delete tables['cvt '];
  45879. }
  45880. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  45881. if (!tables['head']) {
  45882. error('Required "head" table is not found');
  45883. }
  45884. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  45885. var missingGlyphs = Object.create(null);
  45886. if (isTrueType) {
  45887. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  45888. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  45889. }
  45890. if (!tables['hhea']) {
  45891. error('Required "hhea" table is not found');
  45892. }
  45893. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  45894. tables['hhea'].data[10] = 0xFF;
  45895. tables['hhea'].data[11] = 0xFF;
  45896. }
  45897. var metricsOverride = {
  45898. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  45899. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  45900. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  45901. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  45902. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  45903. };
  45904. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  45905. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  45906. if (tables['post']) {
  45907. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  45908. if (!valid) {
  45909. tables['post'] = null;
  45910. }
  45911. }
  45912. var charCodeToGlyphId = [], charCode;
  45913. var toUnicode = properties.toUnicode, widths = properties.widths;
  45914. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  45915. function hasGlyph(glyphId, charCode, widthCode) {
  45916. if (!missingGlyphs[glyphId]) {
  45917. return true;
  45918. }
  45919. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  45920. return true;
  45921. }
  45922. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  45923. return true;
  45924. }
  45925. return false;
  45926. }
  45927. if (properties.composite) {
  45928. var cidToGidMap = properties.cidToGidMap || [];
  45929. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  45930. properties.cMap.forEach(function (charCode, cid) {
  45931. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  45932. var glyphId = -1;
  45933. if (isCidToGidMapEmpty) {
  45934. glyphId = cid;
  45935. } else if (cidToGidMap[cid] !== undefined) {
  45936. glyphId = cidToGidMap[cid];
  45937. }
  45938. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  45939. charCodeToGlyphId[charCode] = glyphId;
  45940. }
  45941. });
  45942. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  45943. charCodeToGlyphId[0] = numGlyphs - 1;
  45944. }
  45945. } else {
  45946. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  45947. var cmapPlatformId = cmapTable.platformId;
  45948. var cmapEncodingId = cmapTable.encodingId;
  45949. var cmapMappings = cmapTable.mappings;
  45950. var cmapMappingsLength = cmapMappings.length;
  45951. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  45952. var baseEncoding = [];
  45953. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  45954. baseEncoding = getEncoding(properties.baseEncodingName);
  45955. }
  45956. var glyphsUnicodeMap = getGlyphsUnicode();
  45957. for (charCode = 0; charCode < 256; charCode++) {
  45958. var glyphName, standardGlyphName;
  45959. if (this.differences && charCode in this.differences) {
  45960. glyphName = this.differences[charCode];
  45961. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  45962. glyphName = baseEncoding[charCode];
  45963. } else {
  45964. glyphName = StandardEncoding[charCode];
  45965. }
  45966. if (!glyphName) {
  45967. continue;
  45968. }
  45969. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  45970. var unicodeOrCharCode, isUnicode = false;
  45971. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  45972. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  45973. isUnicode = true;
  45974. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  45975. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  45976. }
  45977. var found = false;
  45978. for (i = 0; i < cmapMappingsLength; ++i) {
  45979. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  45980. continue;
  45981. }
  45982. var code = isUnicode ? charCode : unicodeOrCharCode;
  45983. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  45984. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  45985. found = true;
  45986. break;
  45987. }
  45988. }
  45989. if (!found && properties.glyphNames) {
  45990. var glyphId = properties.glyphNames.indexOf(glyphName);
  45991. if (glyphId === -1 && standardGlyphName !== glyphName) {
  45992. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  45993. }
  45994. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  45995. charCodeToGlyphId[charCode] = glyphId;
  45996. found = true;
  45997. }
  45998. }
  45999. if (!found) {
  46000. charCodeToGlyphId[charCode] = 0;
  46001. }
  46002. }
  46003. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  46004. for (i = 0; i < cmapMappingsLength; ++i) {
  46005. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  46006. }
  46007. } else {
  46008. for (i = 0; i < cmapMappingsLength; ++i) {
  46009. charCode = cmapMappings[i].charCode & 0xFF;
  46010. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  46011. }
  46012. }
  46013. }
  46014. if (charCodeToGlyphId.length === 0) {
  46015. charCodeToGlyphId[0] = 0;
  46016. }
  46017. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  46018. this.toFontChar = newMapping.toFontChar;
  46019. tables['cmap'] = {
  46020. tag: 'cmap',
  46021. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  46022. };
  46023. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  46024. tables['OS/2'] = {
  46025. tag: 'OS/2',
  46026. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  46027. };
  46028. }
  46029. if (!tables['post']) {
  46030. tables['post'] = {
  46031. tag: 'post',
  46032. data: createPostTable(properties)
  46033. };
  46034. }
  46035. if (!isTrueType) {
  46036. try {
  46037. cffFile = new Stream(tables['CFF '].data);
  46038. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  46039. cff = parser.parse();
  46040. var compiler = new CFFCompiler(cff);
  46041. tables['CFF '].data = compiler.compile();
  46042. } catch (e) {
  46043. warn('Failed to compile font ' + properties.loadedName);
  46044. }
  46045. }
  46046. if (!tables['name']) {
  46047. tables['name'] = {
  46048. tag: 'name',
  46049. data: createNameTable(this.name)
  46050. };
  46051. } else {
  46052. var namePrototype = readNameTable(tables['name']);
  46053. tables['name'].data = createNameTable(name, namePrototype);
  46054. }
  46055. var builder = new OpenTypeFileBuilder(header.version);
  46056. for (var tableTag in tables) {
  46057. builder.addTable(tableTag, tables[tableTag].data);
  46058. }
  46059. return builder.toArray();
  46060. },
  46061. convert: function Font_convert(fontName, font, properties) {
  46062. properties.fixedPitch = false;
  46063. if (properties.builtInEncoding) {
  46064. adjustToUnicode(properties, properties.builtInEncoding);
  46065. }
  46066. var mapping = font.getGlyphMapping(properties);
  46067. var newMapping = adjustMapping(mapping, properties);
  46068. this.toFontChar = newMapping.toFontChar;
  46069. var numGlyphs = font.numGlyphs;
  46070. function getCharCodes(charCodeToGlyphId, glyphId) {
  46071. var charCodes = null;
  46072. for (var charCode in charCodeToGlyphId) {
  46073. if (glyphId === charCodeToGlyphId[charCode]) {
  46074. if (!charCodes) {
  46075. charCodes = [];
  46076. }
  46077. charCodes.push(charCode | 0);
  46078. }
  46079. }
  46080. return charCodes;
  46081. }
  46082. function createCharCode(charCodeToGlyphId, glyphId) {
  46083. for (var charCode in charCodeToGlyphId) {
  46084. if (glyphId === charCodeToGlyphId[charCode]) {
  46085. return charCode | 0;
  46086. }
  46087. }
  46088. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  46089. return newMapping.nextAvailableFontCharCode++;
  46090. }
  46091. var seacs = font.seacs;
  46092. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  46093. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  46094. var charset = font.getCharset();
  46095. var seacMap = Object.create(null);
  46096. for (var glyphId in seacs) {
  46097. glyphId |= 0;
  46098. var seac = seacs[glyphId];
  46099. var baseGlyphName = StandardEncoding[seac[2]];
  46100. var accentGlyphName = StandardEncoding[seac[3]];
  46101. var baseGlyphId = charset.indexOf(baseGlyphName);
  46102. var accentGlyphId = charset.indexOf(accentGlyphName);
  46103. if (baseGlyphId < 0 || accentGlyphId < 0) {
  46104. continue;
  46105. }
  46106. var accentOffset = {
  46107. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  46108. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  46109. };
  46110. var charCodes = getCharCodes(mapping, glyphId);
  46111. if (!charCodes) {
  46112. continue;
  46113. }
  46114. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  46115. var charCode = charCodes[i];
  46116. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  46117. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  46118. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  46119. seacMap[charCode] = {
  46120. baseFontCharCode: baseFontCharCode,
  46121. accentFontCharCode: accentFontCharCode,
  46122. accentOffset: accentOffset
  46123. };
  46124. }
  46125. }
  46126. properties.seacMap = seacMap;
  46127. }
  46128. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  46129. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  46130. builder.addTable('CFF ', font.data);
  46131. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  46132. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  46133. 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');
  46134. 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));
  46135. builder.addTable('hmtx', function fontFieldsHmtx() {
  46136. var charstrings = font.charstrings;
  46137. var cffWidths = font.cff ? font.cff.widths : null;
  46138. var hmtx = '\x00\x00\x00\x00';
  46139. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  46140. var width = 0;
  46141. if (charstrings) {
  46142. var charstring = charstrings[i - 1];
  46143. width = 'width' in charstring ? charstring.width : 0;
  46144. } else if (cffWidths) {
  46145. width = Math.ceil(cffWidths[i] || 0);
  46146. }
  46147. hmtx += string16(width) + string16(0);
  46148. }
  46149. return hmtx;
  46150. }());
  46151. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  46152. builder.addTable('name', createNameTable(fontName));
  46153. builder.addTable('post', createPostTable(properties));
  46154. return builder.toArray();
  46155. },
  46156. get spaceWidth() {
  46157. if ('_shadowWidth' in this) {
  46158. return this._shadowWidth;
  46159. }
  46160. var possibleSpaceReplacements = [
  46161. 'space',
  46162. 'minus',
  46163. 'one',
  46164. 'i',
  46165. 'I'
  46166. ];
  46167. var width;
  46168. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  46169. var glyphName = possibleSpaceReplacements[i];
  46170. if (glyphName in this.widths) {
  46171. width = this.widths[glyphName];
  46172. break;
  46173. }
  46174. var glyphsUnicodeMap = getGlyphsUnicode();
  46175. var glyphUnicode = glyphsUnicodeMap[glyphName];
  46176. var charcode = 0;
  46177. if (this.composite) {
  46178. if (this.cMap.contains(glyphUnicode)) {
  46179. charcode = this.cMap.lookup(glyphUnicode);
  46180. }
  46181. }
  46182. if (!charcode && this.toUnicode) {
  46183. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  46184. }
  46185. if (charcode <= 0) {
  46186. charcode = glyphUnicode;
  46187. }
  46188. width = this.widths[charcode];
  46189. if (width) {
  46190. break;
  46191. }
  46192. }
  46193. width = width || this.defaultWidth;
  46194. this._shadowWidth = width;
  46195. return width;
  46196. },
  46197. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  46198. var fontCharCode, width, operatorListId;
  46199. var widthCode = charcode;
  46200. if (this.cMap && this.cMap.contains(charcode)) {
  46201. widthCode = this.cMap.lookup(charcode);
  46202. }
  46203. width = this.widths[widthCode];
  46204. width = isNum(width) ? width : this.defaultWidth;
  46205. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  46206. var unicode = this.toUnicode.get(charcode) || charcode;
  46207. if (typeof unicode === 'number') {
  46208. unicode = String.fromCharCode(unicode);
  46209. }
  46210. var isInFont = charcode in this.toFontChar;
  46211. fontCharCode = this.toFontChar[charcode] || charcode;
  46212. if (this.missingFile) {
  46213. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  46214. }
  46215. if (this.isType3Font) {
  46216. operatorListId = fontCharCode;
  46217. }
  46218. var accent = null;
  46219. if (this.seacMap && this.seacMap[charcode]) {
  46220. isInFont = true;
  46221. var seac = this.seacMap[charcode];
  46222. fontCharCode = seac.baseFontCharCode;
  46223. accent = {
  46224. fontChar: String.fromCharCode(seac.accentFontCharCode),
  46225. offset: seac.accentOffset
  46226. };
  46227. }
  46228. var fontChar = String.fromCharCode(fontCharCode);
  46229. var glyph = this.glyphCache[charcode];
  46230. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  46231. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  46232. this.glyphCache[charcode] = glyph;
  46233. }
  46234. return glyph;
  46235. },
  46236. charsToGlyphs: function Font_charsToGlyphs(chars) {
  46237. var charsCache = this.charsCache;
  46238. var glyphs, glyph, charcode;
  46239. if (charsCache) {
  46240. glyphs = charsCache[chars];
  46241. if (glyphs) {
  46242. return glyphs;
  46243. }
  46244. }
  46245. if (!charsCache) {
  46246. charsCache = this.charsCache = Object.create(null);
  46247. }
  46248. glyphs = [];
  46249. var charsCacheKey = chars;
  46250. var i = 0, ii;
  46251. if (this.cMap) {
  46252. var c = Object.create(null);
  46253. while (i < chars.length) {
  46254. this.cMap.readCharCode(chars, i, c);
  46255. charcode = c.charcode;
  46256. var length = c.length;
  46257. i += length;
  46258. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  46259. glyph = this.charToGlyph(charcode, isSpace);
  46260. glyphs.push(glyph);
  46261. }
  46262. } else {
  46263. for (i = 0, ii = chars.length; i < ii; ++i) {
  46264. charcode = chars.charCodeAt(i);
  46265. glyph = this.charToGlyph(charcode, charcode === 0x20);
  46266. glyphs.push(glyph);
  46267. }
  46268. }
  46269. return charsCache[charsCacheKey] = glyphs;
  46270. }
  46271. };
  46272. return Font;
  46273. }();
  46274. var ErrorFont = function ErrorFontClosure() {
  46275. function ErrorFont(error) {
  46276. this.error = error;
  46277. this.loadedName = 'g_font_error';
  46278. this.loading = false;
  46279. }
  46280. ErrorFont.prototype = {
  46281. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  46282. return [];
  46283. },
  46284. exportData: function ErrorFont_exportData() {
  46285. return { error: this.error };
  46286. }
  46287. };
  46288. return ErrorFont;
  46289. }();
  46290. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  46291. var charCodeToGlyphId = Object.create(null);
  46292. var glyphId, charCode, baseEncoding;
  46293. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  46294. if (properties.baseEncodingName) {
  46295. baseEncoding = getEncoding(properties.baseEncodingName);
  46296. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  46297. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  46298. if (glyphId >= 0) {
  46299. charCodeToGlyphId[charCode] = glyphId;
  46300. } else {
  46301. charCodeToGlyphId[charCode] = 0;
  46302. }
  46303. }
  46304. } else if (isSymbolicFont) {
  46305. for (charCode in builtInEncoding) {
  46306. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  46307. }
  46308. } else {
  46309. baseEncoding = StandardEncoding;
  46310. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  46311. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  46312. if (glyphId >= 0) {
  46313. charCodeToGlyphId[charCode] = glyphId;
  46314. } else {
  46315. charCodeToGlyphId[charCode] = 0;
  46316. }
  46317. }
  46318. }
  46319. var differences = properties.differences, glyphsUnicodeMap;
  46320. if (differences) {
  46321. for (charCode in differences) {
  46322. var glyphName = differences[charCode];
  46323. glyphId = glyphNames.indexOf(glyphName);
  46324. if (glyphId === -1) {
  46325. if (!glyphsUnicodeMap) {
  46326. glyphsUnicodeMap = getGlyphsUnicode();
  46327. }
  46328. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  46329. if (standardGlyphName !== glyphName) {
  46330. glyphId = glyphNames.indexOf(standardGlyphName);
  46331. }
  46332. }
  46333. if (glyphId >= 0) {
  46334. charCodeToGlyphId[charCode] = glyphId;
  46335. } else {
  46336. charCodeToGlyphId[charCode] = 0;
  46337. }
  46338. }
  46339. }
  46340. return charCodeToGlyphId;
  46341. }
  46342. var Type1Font = function Type1FontClosure() {
  46343. function findBlock(streamBytes, signature, startIndex) {
  46344. var streamBytesLength = streamBytes.length;
  46345. var signatureLength = signature.length;
  46346. var scanLength = streamBytesLength - signatureLength;
  46347. var i = startIndex, j, found = false;
  46348. while (i < scanLength) {
  46349. j = 0;
  46350. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  46351. j++;
  46352. }
  46353. if (j >= signatureLength) {
  46354. i += j;
  46355. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  46356. i++;
  46357. }
  46358. found = true;
  46359. break;
  46360. }
  46361. i++;
  46362. }
  46363. return {
  46364. found: found,
  46365. length: i
  46366. };
  46367. }
  46368. function getHeaderBlock(stream, suggestedLength) {
  46369. var EEXEC_SIGNATURE = [
  46370. 0x65,
  46371. 0x65,
  46372. 0x78,
  46373. 0x65,
  46374. 0x63
  46375. ];
  46376. var streamStartPos = stream.pos;
  46377. var headerBytes, headerBytesLength, block;
  46378. try {
  46379. headerBytes = stream.getBytes(suggestedLength);
  46380. headerBytesLength = headerBytes.length;
  46381. } catch (ex) {
  46382. if (ex instanceof MissingDataException) {
  46383. throw ex;
  46384. }
  46385. }
  46386. if (headerBytesLength === suggestedLength) {
  46387. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  46388. if (block.found && block.length === suggestedLength) {
  46389. return {
  46390. stream: new Stream(headerBytes),
  46391. length: suggestedLength
  46392. };
  46393. }
  46394. }
  46395. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  46396. stream.pos = streamStartPos;
  46397. var SCAN_BLOCK_LENGTH = 2048;
  46398. var actualLength;
  46399. while (true) {
  46400. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  46401. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  46402. if (block.length === 0) {
  46403. break;
  46404. }
  46405. stream.pos += block.length;
  46406. if (block.found) {
  46407. actualLength = stream.pos - streamStartPos;
  46408. break;
  46409. }
  46410. }
  46411. stream.pos = streamStartPos;
  46412. if (actualLength) {
  46413. return {
  46414. stream: new Stream(stream.getBytes(actualLength)),
  46415. length: actualLength
  46416. };
  46417. }
  46418. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  46419. return {
  46420. stream: new Stream(stream.getBytes(suggestedLength)),
  46421. length: suggestedLength
  46422. };
  46423. }
  46424. function getEexecBlock(stream, suggestedLength) {
  46425. var eexecBytes = stream.getBytes();
  46426. return {
  46427. stream: new Stream(eexecBytes),
  46428. length: eexecBytes.length
  46429. };
  46430. }
  46431. function Type1Font(name, file, properties) {
  46432. var PFB_HEADER_SIZE = 6;
  46433. var headerBlockLength = properties.length1;
  46434. var eexecBlockLength = properties.length2;
  46435. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  46436. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  46437. if (pfbHeaderPresent) {
  46438. file.skip(PFB_HEADER_SIZE);
  46439. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  46440. }
  46441. var headerBlock = getHeaderBlock(file, headerBlockLength);
  46442. headerBlockLength = headerBlock.length;
  46443. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  46444. headerBlockParser.extractFontHeader(properties);
  46445. if (pfbHeaderPresent) {
  46446. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  46447. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  46448. }
  46449. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  46450. eexecBlockLength = eexecBlock.length;
  46451. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  46452. var data = eexecBlockParser.extractFontProgram();
  46453. for (var info in data.properties) {
  46454. properties[info] = data.properties[info];
  46455. }
  46456. var charstrings = data.charstrings;
  46457. var type2Charstrings = this.getType2Charstrings(charstrings);
  46458. var subrs = this.getType2Subrs(data.subrs);
  46459. this.charstrings = charstrings;
  46460. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  46461. this.seacs = this.getSeacs(data.charstrings);
  46462. }
  46463. Type1Font.prototype = {
  46464. get numGlyphs() {
  46465. return this.charstrings.length + 1;
  46466. },
  46467. getCharset: function Type1Font_getCharset() {
  46468. var charset = ['.notdef'];
  46469. var charstrings = this.charstrings;
  46470. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  46471. charset.push(charstrings[glyphId].glyphName);
  46472. }
  46473. return charset;
  46474. },
  46475. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  46476. var charstrings = this.charstrings;
  46477. var glyphNames = ['.notdef'], glyphId;
  46478. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  46479. glyphNames.push(charstrings[glyphId].glyphName);
  46480. }
  46481. var encoding = properties.builtInEncoding;
  46482. if (encoding) {
  46483. var builtInEncoding = Object.create(null);
  46484. for (var charCode in encoding) {
  46485. glyphId = glyphNames.indexOf(encoding[charCode]);
  46486. if (glyphId >= 0) {
  46487. builtInEncoding[charCode] = glyphId;
  46488. }
  46489. }
  46490. }
  46491. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  46492. },
  46493. getSeacs: function Type1Font_getSeacs(charstrings) {
  46494. var i, ii;
  46495. var seacMap = [];
  46496. for (i = 0, ii = charstrings.length; i < ii; i++) {
  46497. var charstring = charstrings[i];
  46498. if (charstring.seac) {
  46499. seacMap[i + 1] = charstring.seac;
  46500. }
  46501. }
  46502. return seacMap;
  46503. },
  46504. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  46505. var type2Charstrings = [];
  46506. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  46507. type2Charstrings.push(type1Charstrings[i].charstring);
  46508. }
  46509. return type2Charstrings;
  46510. },
  46511. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  46512. var bias = 0;
  46513. var count = type1Subrs.length;
  46514. if (count < 1133) {
  46515. bias = 107;
  46516. } else if (count < 33769) {
  46517. bias = 1131;
  46518. } else {
  46519. bias = 32768;
  46520. }
  46521. var type2Subrs = [];
  46522. var i;
  46523. for (i = 0; i < bias; i++) {
  46524. type2Subrs.push([0x0B]);
  46525. }
  46526. for (i = 0; i < count; i++) {
  46527. type2Subrs.push(type1Subrs[i]);
  46528. }
  46529. return type2Subrs;
  46530. },
  46531. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  46532. var cff = new CFF();
  46533. cff.header = new CFFHeader(1, 0, 4, 4);
  46534. cff.names = [name];
  46535. var topDict = new CFFTopDict();
  46536. topDict.setByName('version', 391);
  46537. topDict.setByName('Notice', 392);
  46538. topDict.setByName('FullName', 393);
  46539. topDict.setByName('FamilyName', 394);
  46540. topDict.setByName('Weight', 395);
  46541. topDict.setByName('Encoding', null);
  46542. topDict.setByName('FontMatrix', properties.fontMatrix);
  46543. topDict.setByName('FontBBox', properties.bbox);
  46544. topDict.setByName('charset', null);
  46545. topDict.setByName('CharStrings', null);
  46546. topDict.setByName('Private', null);
  46547. cff.topDict = topDict;
  46548. var strings = new CFFStrings();
  46549. strings.add('Version 0.11');
  46550. strings.add('See original notice');
  46551. strings.add(name);
  46552. strings.add(name);
  46553. strings.add('Medium');
  46554. cff.strings = strings;
  46555. cff.globalSubrIndex = new CFFIndex();
  46556. var count = glyphs.length;
  46557. var charsetArray = [0];
  46558. var i, ii;
  46559. for (i = 0; i < count; i++) {
  46560. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  46561. if (index === -1) {
  46562. index = 0;
  46563. }
  46564. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  46565. }
  46566. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  46567. var charStringsIndex = new CFFIndex();
  46568. charStringsIndex.add([
  46569. 0x8B,
  46570. 0x0E
  46571. ]);
  46572. for (i = 0; i < count; i++) {
  46573. var glyph = glyphs[i];
  46574. if (glyph.length === 0) {
  46575. charStringsIndex.add([
  46576. 0x8B,
  46577. 0x0E
  46578. ]);
  46579. continue;
  46580. }
  46581. charStringsIndex.add(glyph);
  46582. }
  46583. cff.charStrings = charStringsIndex;
  46584. var privateDict = new CFFPrivateDict();
  46585. privateDict.setByName('Subrs', null);
  46586. var fields = [
  46587. 'BlueValues',
  46588. 'OtherBlues',
  46589. 'FamilyBlues',
  46590. 'FamilyOtherBlues',
  46591. 'StemSnapH',
  46592. 'StemSnapV',
  46593. 'BlueShift',
  46594. 'BlueFuzz',
  46595. 'BlueScale',
  46596. 'LanguageGroup',
  46597. 'ExpansionFactor',
  46598. 'ForceBold',
  46599. 'StdHW',
  46600. 'StdVW'
  46601. ];
  46602. for (i = 0, ii = fields.length; i < ii; i++) {
  46603. var field = fields[i];
  46604. if (!(field in properties.privateData)) {
  46605. continue;
  46606. }
  46607. var value = properties.privateData[field];
  46608. if (isArray(value)) {
  46609. for (var j = value.length - 1; j > 0; j--) {
  46610. value[j] -= value[j - 1];
  46611. }
  46612. }
  46613. privateDict.setByName(field, value);
  46614. }
  46615. cff.topDict.privateDict = privateDict;
  46616. var subrIndex = new CFFIndex();
  46617. for (i = 0, ii = subrs.length; i < ii; i++) {
  46618. subrIndex.add(subrs[i]);
  46619. }
  46620. privateDict.subrsIndex = subrIndex;
  46621. var compiler = new CFFCompiler(cff);
  46622. return compiler.compile();
  46623. }
  46624. };
  46625. return Type1Font;
  46626. }();
  46627. var CFFFont = function CFFFontClosure() {
  46628. function CFFFont(file, properties) {
  46629. this.properties = properties;
  46630. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  46631. this.cff = parser.parse();
  46632. var compiler = new CFFCompiler(this.cff);
  46633. this.seacs = this.cff.seacs;
  46634. try {
  46635. this.data = compiler.compile();
  46636. } catch (e) {
  46637. warn('Failed to compile font ' + properties.loadedName);
  46638. this.data = file;
  46639. }
  46640. }
  46641. CFFFont.prototype = {
  46642. get numGlyphs() {
  46643. return this.cff.charStrings.count;
  46644. },
  46645. getCharset: function CFFFont_getCharset() {
  46646. return this.cff.charset.charset;
  46647. },
  46648. getGlyphMapping: function CFFFont_getGlyphMapping() {
  46649. var cff = this.cff;
  46650. var properties = this.properties;
  46651. var charsets = cff.charset.charset;
  46652. var charCodeToGlyphId;
  46653. var glyphId;
  46654. if (properties.composite) {
  46655. charCodeToGlyphId = Object.create(null);
  46656. if (cff.isCIDFont) {
  46657. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  46658. var cid = charsets[glyphId];
  46659. var charCode = properties.cMap.charCodeOf(cid);
  46660. charCodeToGlyphId[charCode] = glyphId;
  46661. }
  46662. } else {
  46663. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  46664. charCodeToGlyphId[glyphId] = glyphId;
  46665. }
  46666. }
  46667. return charCodeToGlyphId;
  46668. }
  46669. var encoding = cff.encoding ? cff.encoding.encoding : null;
  46670. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  46671. return charCodeToGlyphId;
  46672. }
  46673. };
  46674. return CFFFont;
  46675. }();
  46676. (function checkSeacSupport() {
  46677. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  46678. SEAC_ANALYSIS_ENABLED = true;
  46679. }
  46680. }());
  46681. (function checkChromeWindows() {
  46682. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  46683. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  46684. }
  46685. }());
  46686. exports.ErrorFont = ErrorFont;
  46687. exports.Font = Font;
  46688. exports.FontFlags = FontFlags;
  46689. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  46690. exports.ToUnicodeMap = ToUnicodeMap;
  46691. exports.getFontType = getFontType;
  46692. /***/ }),
  46693. /* 34 */
  46694. /***/ (function(module, exports, __w_pdfjs_require__) {
  46695. "use strict";
  46696. var sharedUtil = __w_pdfjs_require__(0);
  46697. var corePrimitives = __w_pdfjs_require__(1);
  46698. var coreColorSpace = __w_pdfjs_require__(4);
  46699. var coreStream = __w_pdfjs_require__(2);
  46700. var coreJpx = __w_pdfjs_require__(18);
  46701. var ImageKind = sharedUtil.ImageKind;
  46702. var assert = sharedUtil.assert;
  46703. var error = sharedUtil.error;
  46704. var info = sharedUtil.info;
  46705. var isArray = sharedUtil.isArray;
  46706. var warn = sharedUtil.warn;
  46707. var Name = corePrimitives.Name;
  46708. var isStream = corePrimitives.isStream;
  46709. var ColorSpace = coreColorSpace.ColorSpace;
  46710. var DecodeStream = coreStream.DecodeStream;
  46711. var JpegStream = coreStream.JpegStream;
  46712. var JpxImage = coreJpx.JpxImage;
  46713. var PDFImage = function PDFImageClosure() {
  46714. function handleImageData(image, nativeDecoder) {
  46715. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  46716. return nativeDecoder.decode(image);
  46717. }
  46718. return Promise.resolve(image);
  46719. }
  46720. function decodeAndClamp(value, addend, coefficient, max) {
  46721. value = addend + value * coefficient;
  46722. return value < 0 ? 0 : value > max ? max : value;
  46723. }
  46724. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  46725. var length = w2 * h2;
  46726. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  46727. var xRatio = w1 / w2;
  46728. var yRatio = h1 / h2;
  46729. var i, j, py, newIndex = 0, oldIndex;
  46730. var xScaled = new Uint16Array(w2);
  46731. var w1Scanline = w1;
  46732. for (i = 0; i < w2; i++) {
  46733. xScaled[i] = Math.floor(i * xRatio);
  46734. }
  46735. for (i = 0; i < h2; i++) {
  46736. py = Math.floor(i * yRatio) * w1Scanline;
  46737. for (j = 0; j < w2; j++) {
  46738. oldIndex = py + xScaled[j];
  46739. dest[newIndex++] = src[oldIndex];
  46740. }
  46741. }
  46742. return dest;
  46743. }
  46744. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  46745. this.image = image;
  46746. var dict = image.dict;
  46747. if (dict.has('Filter')) {
  46748. var filter = dict.get('Filter').name;
  46749. if (filter === 'JPXDecode') {
  46750. var jpxImage = new JpxImage();
  46751. jpxImage.parseImageProperties(image.stream);
  46752. image.stream.reset();
  46753. image.bitsPerComponent = jpxImage.bitsPerComponent;
  46754. image.numComps = jpxImage.componentsCount;
  46755. } else if (filter === 'JBIG2Decode') {
  46756. image.bitsPerComponent = 1;
  46757. image.numComps = 1;
  46758. }
  46759. }
  46760. this.width = dict.get('Width', 'W');
  46761. this.height = dict.get('Height', 'H');
  46762. if (this.width < 1 || this.height < 1) {
  46763. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  46764. }
  46765. this.interpolate = dict.get('Interpolate', 'I') || false;
  46766. this.imageMask = dict.get('ImageMask', 'IM') || false;
  46767. this.matte = dict.get('Matte') || false;
  46768. var bitsPerComponent = image.bitsPerComponent;
  46769. if (!bitsPerComponent) {
  46770. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  46771. if (!bitsPerComponent) {
  46772. if (this.imageMask) {
  46773. bitsPerComponent = 1;
  46774. } else {
  46775. error('Bits per component missing in image: ' + this.imageMask);
  46776. }
  46777. }
  46778. }
  46779. this.bpc = bitsPerComponent;
  46780. if (!this.imageMask) {
  46781. var colorSpace = dict.get('ColorSpace', 'CS');
  46782. if (!colorSpace) {
  46783. info('JPX images (which do not require color spaces)');
  46784. switch (image.numComps) {
  46785. case 1:
  46786. colorSpace = Name.get('DeviceGray');
  46787. break;
  46788. case 3:
  46789. colorSpace = Name.get('DeviceRGB');
  46790. break;
  46791. case 4:
  46792. colorSpace = Name.get('DeviceCMYK');
  46793. break;
  46794. default:
  46795. error('JPX images with ' + this.numComps + ' color components not supported.');
  46796. }
  46797. }
  46798. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  46799. this.numComps = this.colorSpace.numComps;
  46800. }
  46801. this.decode = dict.getArray('Decode', 'D');
  46802. this.needsDecode = false;
  46803. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  46804. this.needsDecode = true;
  46805. var max = (1 << bitsPerComponent) - 1;
  46806. this.decodeCoefficients = [];
  46807. this.decodeAddends = [];
  46808. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  46809. var dmin = this.decode[i];
  46810. var dmax = this.decode[i + 1];
  46811. this.decodeCoefficients[j] = dmax - dmin;
  46812. this.decodeAddends[j] = max * dmin;
  46813. }
  46814. }
  46815. if (smask) {
  46816. this.smask = new PDFImage(xref, res, smask, false);
  46817. } else if (mask) {
  46818. if (isStream(mask)) {
  46819. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  46820. if (!imageMask) {
  46821. warn('Ignoring /Mask in image without /ImageMask.');
  46822. } else {
  46823. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  46824. }
  46825. } else {
  46826. this.mask = mask;
  46827. }
  46828. }
  46829. }
  46830. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  46831. var imagePromise = handleImageData(image, nativeDecoder);
  46832. var smaskPromise;
  46833. var maskPromise;
  46834. var smask = image.dict.get('SMask');
  46835. var mask = image.dict.get('Mask');
  46836. if (smask) {
  46837. smaskPromise = handleImageData(smask, nativeDecoder);
  46838. maskPromise = Promise.resolve(null);
  46839. } else {
  46840. smaskPromise = Promise.resolve(null);
  46841. if (mask) {
  46842. if (isStream(mask)) {
  46843. maskPromise = handleImageData(mask, nativeDecoder);
  46844. } else if (isArray(mask)) {
  46845. maskPromise = Promise.resolve(mask);
  46846. } else {
  46847. warn('Unsupported mask format.');
  46848. maskPromise = Promise.resolve(null);
  46849. }
  46850. } else {
  46851. maskPromise = Promise.resolve(null);
  46852. }
  46853. }
  46854. return Promise.all([
  46855. imagePromise,
  46856. smaskPromise,
  46857. maskPromise
  46858. ]).then(function (results) {
  46859. var imageData = results[0];
  46860. var smaskData = results[1];
  46861. var maskData = results[2];
  46862. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  46863. });
  46864. };
  46865. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  46866. var computedLength = (width + 7 >> 3) * height;
  46867. var actualLength = imgArray.byteLength;
  46868. var haveFullData = computedLength === actualLength;
  46869. var data, i;
  46870. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  46871. data = imgArray;
  46872. } else if (!inverseDecode) {
  46873. data = new Uint8Array(actualLength);
  46874. data.set(imgArray);
  46875. } else {
  46876. data = new Uint8Array(computedLength);
  46877. data.set(imgArray);
  46878. for (i = actualLength; i < computedLength; i++) {
  46879. data[i] = 0xff;
  46880. }
  46881. }
  46882. if (inverseDecode) {
  46883. for (i = 0; i < actualLength; i++) {
  46884. data[i] = ~data[i];
  46885. }
  46886. }
  46887. return {
  46888. data: data,
  46889. width: width,
  46890. height: height
  46891. };
  46892. };
  46893. PDFImage.prototype = {
  46894. get drawWidth() {
  46895. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  46896. },
  46897. get drawHeight() {
  46898. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  46899. },
  46900. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  46901. var bpc = this.bpc;
  46902. var numComps = this.numComps;
  46903. var decodeAddends = this.decodeAddends;
  46904. var decodeCoefficients = this.decodeCoefficients;
  46905. var max = (1 << bpc) - 1;
  46906. var i, ii;
  46907. if (bpc === 1) {
  46908. for (i = 0, ii = buffer.length; i < ii; i++) {
  46909. buffer[i] = +!buffer[i];
  46910. }
  46911. return;
  46912. }
  46913. var index = 0;
  46914. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  46915. for (var j = 0; j < numComps; j++) {
  46916. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  46917. index++;
  46918. }
  46919. }
  46920. },
  46921. getComponents: function PDFImage_getComponents(buffer) {
  46922. var bpc = this.bpc;
  46923. if (bpc === 8) {
  46924. return buffer;
  46925. }
  46926. var width = this.width;
  46927. var height = this.height;
  46928. var numComps = this.numComps;
  46929. var length = width * height * numComps;
  46930. var bufferPos = 0;
  46931. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  46932. var rowComps = width * numComps;
  46933. var max = (1 << bpc) - 1;
  46934. var i = 0, ii, buf;
  46935. if (bpc === 1) {
  46936. var mask, loop1End, loop2End;
  46937. for (var j = 0; j < height; j++) {
  46938. loop1End = i + (rowComps & ~7);
  46939. loop2End = i + rowComps;
  46940. while (i < loop1End) {
  46941. buf = buffer[bufferPos++];
  46942. output[i] = buf >> 7 & 1;
  46943. output[i + 1] = buf >> 6 & 1;
  46944. output[i + 2] = buf >> 5 & 1;
  46945. output[i + 3] = buf >> 4 & 1;
  46946. output[i + 4] = buf >> 3 & 1;
  46947. output[i + 5] = buf >> 2 & 1;
  46948. output[i + 6] = buf >> 1 & 1;
  46949. output[i + 7] = buf & 1;
  46950. i += 8;
  46951. }
  46952. if (i < loop2End) {
  46953. buf = buffer[bufferPos++];
  46954. mask = 128;
  46955. while (i < loop2End) {
  46956. output[i++] = +!!(buf & mask);
  46957. mask >>= 1;
  46958. }
  46959. }
  46960. }
  46961. } else {
  46962. var bits = 0;
  46963. buf = 0;
  46964. for (i = 0, ii = length; i < ii; ++i) {
  46965. if (i % rowComps === 0) {
  46966. buf = 0;
  46967. bits = 0;
  46968. }
  46969. while (bits < bpc) {
  46970. buf = buf << 8 | buffer[bufferPos++];
  46971. bits += 8;
  46972. }
  46973. var remainingBits = bits - bpc;
  46974. var value = buf >> remainingBits;
  46975. output[i] = value < 0 ? 0 : value > max ? max : value;
  46976. buf = buf & (1 << remainingBits) - 1;
  46977. bits = remainingBits;
  46978. }
  46979. }
  46980. return output;
  46981. },
  46982. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  46983. var smask = this.smask;
  46984. var mask = this.mask;
  46985. var alphaBuf, sw, sh, i, ii, j;
  46986. if (smask) {
  46987. sw = smask.width;
  46988. sh = smask.height;
  46989. alphaBuf = new Uint8Array(sw * sh);
  46990. smask.fillGrayBuffer(alphaBuf);
  46991. if (sw !== width || sh !== height) {
  46992. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  46993. }
  46994. } else if (mask) {
  46995. if (mask instanceof PDFImage) {
  46996. sw = mask.width;
  46997. sh = mask.height;
  46998. alphaBuf = new Uint8Array(sw * sh);
  46999. mask.numComps = 1;
  47000. mask.fillGrayBuffer(alphaBuf);
  47001. for (i = 0, ii = sw * sh; i < ii; ++i) {
  47002. alphaBuf[i] = 255 - alphaBuf[i];
  47003. }
  47004. if (sw !== width || sh !== height) {
  47005. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  47006. }
  47007. } else if (isArray(mask)) {
  47008. alphaBuf = new Uint8Array(width * height);
  47009. var numComps = this.numComps;
  47010. for (i = 0, ii = width * height; i < ii; ++i) {
  47011. var opacity = 0;
  47012. var imageOffset = i * numComps;
  47013. for (j = 0; j < numComps; ++j) {
  47014. var color = image[imageOffset + j];
  47015. var maskOffset = j * 2;
  47016. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  47017. opacity = 255;
  47018. break;
  47019. }
  47020. }
  47021. alphaBuf[i] = opacity;
  47022. }
  47023. } else {
  47024. error('Unknown mask format.');
  47025. }
  47026. }
  47027. if (alphaBuf) {
  47028. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  47029. rgbaBuf[j] = alphaBuf[i];
  47030. }
  47031. } else {
  47032. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  47033. rgbaBuf[j] = 255;
  47034. }
  47035. }
  47036. },
  47037. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  47038. var matte = this.smask && this.smask.matte;
  47039. if (!matte) {
  47040. return;
  47041. }
  47042. var matteRgb = this.colorSpace.getRgb(matte, 0);
  47043. var matteR = matteRgb[0];
  47044. var matteG = matteRgb[1];
  47045. var matteB = matteRgb[2];
  47046. var length = width * height * 4;
  47047. var r, g, b;
  47048. for (var i = 0; i < length; i += 4) {
  47049. var alpha = buffer[i + 3];
  47050. if (alpha === 0) {
  47051. buffer[i] = 255;
  47052. buffer[i + 1] = 255;
  47053. buffer[i + 2] = 255;
  47054. continue;
  47055. }
  47056. var k = 255 / alpha;
  47057. r = (buffer[i] - matteR) * k + matteR;
  47058. g = (buffer[i + 1] - matteG) * k + matteG;
  47059. b = (buffer[i + 2] - matteB) * k + matteB;
  47060. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  47061. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  47062. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  47063. }
  47064. },
  47065. createImageData: function PDFImage_createImageData(forceRGBA) {
  47066. var drawWidth = this.drawWidth;
  47067. var drawHeight = this.drawHeight;
  47068. var imgData = {
  47069. width: drawWidth,
  47070. height: drawHeight
  47071. };
  47072. var numComps = this.numComps;
  47073. var originalWidth = this.width;
  47074. var originalHeight = this.height;
  47075. var bpc = this.bpc;
  47076. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  47077. var imgArray;
  47078. if (!forceRGBA) {
  47079. var kind;
  47080. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  47081. kind = ImageKind.GRAYSCALE_1BPP;
  47082. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  47083. kind = ImageKind.RGB_24BPP;
  47084. }
  47085. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  47086. imgData.kind = kind;
  47087. imgArray = this.getImageBytes(originalHeight * rowBytes);
  47088. if (this.image instanceof DecodeStream) {
  47089. imgData.data = imgArray;
  47090. } else {
  47091. var newArray = new Uint8Array(imgArray.length);
  47092. newArray.set(imgArray);
  47093. imgData.data = newArray;
  47094. }
  47095. if (this.needsDecode) {
  47096. assert(kind === ImageKind.GRAYSCALE_1BPP);
  47097. var buffer = imgData.data;
  47098. for (var i = 0, ii = buffer.length; i < ii; i++) {
  47099. buffer[i] ^= 0xff;
  47100. }
  47101. }
  47102. return imgData;
  47103. }
  47104. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  47105. imgData.kind = ImageKind.RGB_24BPP;
  47106. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  47107. return imgData;
  47108. }
  47109. }
  47110. imgArray = this.getImageBytes(originalHeight * rowBytes);
  47111. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  47112. var comps = this.getComponents(imgArray);
  47113. var alpha01, maybeUndoPreblend;
  47114. if (!forceRGBA && !this.smask && !this.mask) {
  47115. imgData.kind = ImageKind.RGB_24BPP;
  47116. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  47117. alpha01 = 0;
  47118. maybeUndoPreblend = false;
  47119. } else {
  47120. imgData.kind = ImageKind.RGBA_32BPP;
  47121. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  47122. alpha01 = 1;
  47123. maybeUndoPreblend = true;
  47124. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  47125. }
  47126. if (this.needsDecode) {
  47127. this.decodeBuffer(comps);
  47128. }
  47129. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  47130. if (maybeUndoPreblend) {
  47131. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  47132. }
  47133. return imgData;
  47134. },
  47135. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  47136. var numComps = this.numComps;
  47137. if (numComps !== 1) {
  47138. error('Reading gray scale from a color image: ' + numComps);
  47139. }
  47140. var width = this.width;
  47141. var height = this.height;
  47142. var bpc = this.bpc;
  47143. var rowBytes = width * numComps * bpc + 7 >> 3;
  47144. var imgArray = this.getImageBytes(height * rowBytes);
  47145. var comps = this.getComponents(imgArray);
  47146. var i, length;
  47147. if (bpc === 1) {
  47148. length = width * height;
  47149. if (this.needsDecode) {
  47150. for (i = 0; i < length; ++i) {
  47151. buffer[i] = comps[i] - 1 & 255;
  47152. }
  47153. } else {
  47154. for (i = 0; i < length; ++i) {
  47155. buffer[i] = -comps[i] & 255;
  47156. }
  47157. }
  47158. return;
  47159. }
  47160. if (this.needsDecode) {
  47161. this.decodeBuffer(comps);
  47162. }
  47163. length = width * height;
  47164. var scale = 255 / ((1 << bpc) - 1);
  47165. for (i = 0; i < length; ++i) {
  47166. buffer[i] = scale * comps[i] | 0;
  47167. }
  47168. },
  47169. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  47170. this.image.reset();
  47171. this.image.drawWidth = drawWidth || this.width;
  47172. this.image.drawHeight = drawHeight || this.height;
  47173. this.image.forceRGB = !!forceRGB;
  47174. return this.image.getBytes(length);
  47175. }
  47176. };
  47177. return PDFImage;
  47178. }();
  47179. exports.PDFImage = PDFImage;
  47180. /***/ }),
  47181. /* 35 */
  47182. /***/ (function(module, exports, __w_pdfjs_require__) {
  47183. "use strict";
  47184. var sharedUtil = __w_pdfjs_require__(0);
  47185. var coreArithmeticDecoder = __w_pdfjs_require__(13);
  47186. var error = sharedUtil.error;
  47187. var log2 = sharedUtil.log2;
  47188. var readInt8 = sharedUtil.readInt8;
  47189. var readUint16 = sharedUtil.readUint16;
  47190. var readUint32 = sharedUtil.readUint32;
  47191. var shadow = sharedUtil.shadow;
  47192. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  47193. var Jbig2Image = function Jbig2ImageClosure() {
  47194. function ContextCache() {
  47195. }
  47196. ContextCache.prototype = {
  47197. getContexts: function (id) {
  47198. if (id in this) {
  47199. return this[id];
  47200. }
  47201. return this[id] = new Int8Array(1 << 16);
  47202. }
  47203. };
  47204. function DecodingContext(data, start, end) {
  47205. this.data = data;
  47206. this.start = start;
  47207. this.end = end;
  47208. }
  47209. DecodingContext.prototype = {
  47210. get decoder() {
  47211. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  47212. return shadow(this, 'decoder', decoder);
  47213. },
  47214. get contextCache() {
  47215. var cache = new ContextCache();
  47216. return shadow(this, 'contextCache', cache);
  47217. }
  47218. };
  47219. function decodeInteger(contextCache, procedure, decoder) {
  47220. var contexts = contextCache.getContexts(procedure);
  47221. var prev = 1;
  47222. function readBits(length) {
  47223. var v = 0;
  47224. for (var i = 0; i < length; i++) {
  47225. var bit = decoder.readBit(contexts, prev);
  47226. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  47227. v = v << 1 | bit;
  47228. }
  47229. return v >>> 0;
  47230. }
  47231. var sign = readBits(1);
  47232. 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);
  47233. return sign === 0 ? value : value > 0 ? -value : null;
  47234. }
  47235. function decodeIAID(contextCache, decoder, codeLength) {
  47236. var contexts = contextCache.getContexts('IAID');
  47237. var prev = 1;
  47238. for (var i = 0; i < codeLength; i++) {
  47239. var bit = decoder.readBit(contexts, prev);
  47240. prev = prev << 1 | bit;
  47241. }
  47242. if (codeLength < 31) {
  47243. return prev & (1 << codeLength) - 1;
  47244. }
  47245. return prev & 0x7FFFFFFF;
  47246. }
  47247. var SegmentTypes = [
  47248. 'SymbolDictionary',
  47249. null,
  47250. null,
  47251. null,
  47252. 'IntermediateTextRegion',
  47253. null,
  47254. 'ImmediateTextRegion',
  47255. 'ImmediateLosslessTextRegion',
  47256. null,
  47257. null,
  47258. null,
  47259. null,
  47260. null,
  47261. null,
  47262. null,
  47263. null,
  47264. 'patternDictionary',
  47265. null,
  47266. null,
  47267. null,
  47268. 'IntermediateHalftoneRegion',
  47269. null,
  47270. 'ImmediateHalftoneRegion',
  47271. 'ImmediateLosslessHalftoneRegion',
  47272. null,
  47273. null,
  47274. null,
  47275. null,
  47276. null,
  47277. null,
  47278. null,
  47279. null,
  47280. null,
  47281. null,
  47282. null,
  47283. null,
  47284. 'IntermediateGenericRegion',
  47285. null,
  47286. 'ImmediateGenericRegion',
  47287. 'ImmediateLosslessGenericRegion',
  47288. 'IntermediateGenericRefinementRegion',
  47289. null,
  47290. 'ImmediateGenericRefinementRegion',
  47291. 'ImmediateLosslessGenericRefinementRegion',
  47292. null,
  47293. null,
  47294. null,
  47295. null,
  47296. 'PageInformation',
  47297. 'EndOfPage',
  47298. 'EndOfStripe',
  47299. 'EndOfFile',
  47300. 'Profiles',
  47301. 'Tables',
  47302. null,
  47303. null,
  47304. null,
  47305. null,
  47306. null,
  47307. null,
  47308. null,
  47309. null,
  47310. 'Extension'
  47311. ];
  47312. var CodingTemplates = [
  47313. [
  47314. {
  47315. x: -1,
  47316. y: -2
  47317. },
  47318. {
  47319. x: 0,
  47320. y: -2
  47321. },
  47322. {
  47323. x: 1,
  47324. y: -2
  47325. },
  47326. {
  47327. x: -2,
  47328. y: -1
  47329. },
  47330. {
  47331. x: -1,
  47332. y: -1
  47333. },
  47334. {
  47335. x: 0,
  47336. y: -1
  47337. },
  47338. {
  47339. x: 1,
  47340. y: -1
  47341. },
  47342. {
  47343. x: 2,
  47344. y: -1
  47345. },
  47346. {
  47347. x: -4,
  47348. y: 0
  47349. },
  47350. {
  47351. x: -3,
  47352. y: 0
  47353. },
  47354. {
  47355. x: -2,
  47356. y: 0
  47357. },
  47358. {
  47359. x: -1,
  47360. y: 0
  47361. }
  47362. ],
  47363. [
  47364. {
  47365. x: -1,
  47366. y: -2
  47367. },
  47368. {
  47369. x: 0,
  47370. y: -2
  47371. },
  47372. {
  47373. x: 1,
  47374. y: -2
  47375. },
  47376. {
  47377. x: 2,
  47378. y: -2
  47379. },
  47380. {
  47381. x: -2,
  47382. y: -1
  47383. },
  47384. {
  47385. x: -1,
  47386. y: -1
  47387. },
  47388. {
  47389. x: 0,
  47390. y: -1
  47391. },
  47392. {
  47393. x: 1,
  47394. y: -1
  47395. },
  47396. {
  47397. x: 2,
  47398. y: -1
  47399. },
  47400. {
  47401. x: -3,
  47402. y: 0
  47403. },
  47404. {
  47405. x: -2,
  47406. y: 0
  47407. },
  47408. {
  47409. x: -1,
  47410. y: 0
  47411. }
  47412. ],
  47413. [
  47414. {
  47415. x: -1,
  47416. y: -2
  47417. },
  47418. {
  47419. x: 0,
  47420. y: -2
  47421. },
  47422. {
  47423. x: 1,
  47424. y: -2
  47425. },
  47426. {
  47427. x: -2,
  47428. y: -1
  47429. },
  47430. {
  47431. x: -1,
  47432. y: -1
  47433. },
  47434. {
  47435. x: 0,
  47436. y: -1
  47437. },
  47438. {
  47439. x: 1,
  47440. y: -1
  47441. },
  47442. {
  47443. x: -2,
  47444. y: 0
  47445. },
  47446. {
  47447. x: -1,
  47448. y: 0
  47449. }
  47450. ],
  47451. [
  47452. {
  47453. x: -3,
  47454. y: -1
  47455. },
  47456. {
  47457. x: -2,
  47458. y: -1
  47459. },
  47460. {
  47461. x: -1,
  47462. y: -1
  47463. },
  47464. {
  47465. x: 0,
  47466. y: -1
  47467. },
  47468. {
  47469. x: 1,
  47470. y: -1
  47471. },
  47472. {
  47473. x: -4,
  47474. y: 0
  47475. },
  47476. {
  47477. x: -3,
  47478. y: 0
  47479. },
  47480. {
  47481. x: -2,
  47482. y: 0
  47483. },
  47484. {
  47485. x: -1,
  47486. y: 0
  47487. }
  47488. ]
  47489. ];
  47490. var RefinementTemplates = [
  47491. {
  47492. coding: [
  47493. {
  47494. x: 0,
  47495. y: -1
  47496. },
  47497. {
  47498. x: 1,
  47499. y: -1
  47500. },
  47501. {
  47502. x: -1,
  47503. y: 0
  47504. }
  47505. ],
  47506. reference: [
  47507. {
  47508. x: 0,
  47509. y: -1
  47510. },
  47511. {
  47512. x: 1,
  47513. y: -1
  47514. },
  47515. {
  47516. x: -1,
  47517. y: 0
  47518. },
  47519. {
  47520. x: 0,
  47521. y: 0
  47522. },
  47523. {
  47524. x: 1,
  47525. y: 0
  47526. },
  47527. {
  47528. x: -1,
  47529. y: 1
  47530. },
  47531. {
  47532. x: 0,
  47533. y: 1
  47534. },
  47535. {
  47536. x: 1,
  47537. y: 1
  47538. }
  47539. ]
  47540. },
  47541. {
  47542. coding: [
  47543. {
  47544. x: -1,
  47545. y: -1
  47546. },
  47547. {
  47548. x: 0,
  47549. y: -1
  47550. },
  47551. {
  47552. x: 1,
  47553. y: -1
  47554. },
  47555. {
  47556. x: -1,
  47557. y: 0
  47558. }
  47559. ],
  47560. reference: [
  47561. {
  47562. x: 0,
  47563. y: -1
  47564. },
  47565. {
  47566. x: -1,
  47567. y: 0
  47568. },
  47569. {
  47570. x: 0,
  47571. y: 0
  47572. },
  47573. {
  47574. x: 1,
  47575. y: 0
  47576. },
  47577. {
  47578. x: 0,
  47579. y: 1
  47580. },
  47581. {
  47582. x: 1,
  47583. y: 1
  47584. }
  47585. ]
  47586. }
  47587. ];
  47588. var ReusedContexts = [
  47589. 0x9B25,
  47590. 0x0795,
  47591. 0x00E5,
  47592. 0x0195
  47593. ];
  47594. var RefinementReusedContexts = [
  47595. 0x0020,
  47596. 0x0008
  47597. ];
  47598. function decodeBitmapTemplate0(width, height, decodingContext) {
  47599. var decoder = decodingContext.decoder;
  47600. var contexts = decodingContext.contextCache.getContexts('GB');
  47601. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  47602. var OLD_PIXEL_MASK = 0x7BF7;
  47603. for (i = 0; i < height; i++) {
  47604. row = bitmap[i] = new Uint8Array(width);
  47605. row1 = i < 1 ? row : bitmap[i - 1];
  47606. row2 = i < 2 ? row : bitmap[i - 2];
  47607. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  47608. for (j = 0; j < width; j++) {
  47609. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  47610. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  47611. }
  47612. }
  47613. return bitmap;
  47614. }
  47615. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  47616. if (mmr) {
  47617. error('JBIG2 error: MMR encoding is not supported');
  47618. }
  47619. 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) {
  47620. return decodeBitmapTemplate0(width, height, decodingContext);
  47621. }
  47622. var useskip = !!skip;
  47623. var template = CodingTemplates[templateIndex].concat(at);
  47624. template.sort(function (a, b) {
  47625. return a.y - b.y || a.x - b.x;
  47626. });
  47627. var templateLength = template.length;
  47628. var templateX = new Int8Array(templateLength);
  47629. var templateY = new Int8Array(templateLength);
  47630. var changingTemplateEntries = [];
  47631. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  47632. var c, k;
  47633. for (k = 0; k < templateLength; k++) {
  47634. templateX[k] = template[k].x;
  47635. templateY[k] = template[k].y;
  47636. minX = Math.min(minX, template[k].x);
  47637. maxX = Math.max(maxX, template[k].x);
  47638. minY = Math.min(minY, template[k].y);
  47639. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  47640. reuseMask |= 1 << templateLength - 1 - k;
  47641. } else {
  47642. changingTemplateEntries.push(k);
  47643. }
  47644. }
  47645. var changingEntriesLength = changingTemplateEntries.length;
  47646. var changingTemplateX = new Int8Array(changingEntriesLength);
  47647. var changingTemplateY = new Int8Array(changingEntriesLength);
  47648. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  47649. for (c = 0; c < changingEntriesLength; c++) {
  47650. k = changingTemplateEntries[c];
  47651. changingTemplateX[c] = template[k].x;
  47652. changingTemplateY[c] = template[k].y;
  47653. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  47654. }
  47655. var sbb_left = -minX;
  47656. var sbb_top = -minY;
  47657. var sbb_right = width - maxX;
  47658. var pseudoPixelContext = ReusedContexts[templateIndex];
  47659. var row = new Uint8Array(width);
  47660. var bitmap = [];
  47661. var decoder = decodingContext.decoder;
  47662. var contexts = decodingContext.contextCache.getContexts('GB');
  47663. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  47664. for (var i = 0; i < height; i++) {
  47665. if (prediction) {
  47666. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  47667. ltp ^= sltp;
  47668. if (ltp) {
  47669. bitmap.push(row);
  47670. continue;
  47671. }
  47672. }
  47673. row = new Uint8Array(row);
  47674. bitmap.push(row);
  47675. for (j = 0; j < width; j++) {
  47676. if (useskip && skip[i][j]) {
  47677. row[j] = 0;
  47678. continue;
  47679. }
  47680. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  47681. contextLabel = contextLabel << 1 & reuseMask;
  47682. for (k = 0; k < changingEntriesLength; k++) {
  47683. i0 = i + changingTemplateY[k];
  47684. j0 = j + changingTemplateX[k];
  47685. bit = bitmap[i0][j0];
  47686. if (bit) {
  47687. bit = changingTemplateBit[k];
  47688. contextLabel |= bit;
  47689. }
  47690. }
  47691. } else {
  47692. contextLabel = 0;
  47693. shift = templateLength - 1;
  47694. for (k = 0; k < templateLength; k++, shift--) {
  47695. j0 = j + templateX[k];
  47696. if (j0 >= 0 && j0 < width) {
  47697. i0 = i + templateY[k];
  47698. if (i0 >= 0) {
  47699. bit = bitmap[i0][j0];
  47700. if (bit) {
  47701. contextLabel |= bit << shift;
  47702. }
  47703. }
  47704. }
  47705. }
  47706. }
  47707. var pixel = decoder.readBit(contexts, contextLabel);
  47708. row[j] = pixel;
  47709. }
  47710. }
  47711. return bitmap;
  47712. }
  47713. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  47714. var codingTemplate = RefinementTemplates[templateIndex].coding;
  47715. if (templateIndex === 0) {
  47716. codingTemplate = codingTemplate.concat([at[0]]);
  47717. }
  47718. var codingTemplateLength = codingTemplate.length;
  47719. var codingTemplateX = new Int32Array(codingTemplateLength);
  47720. var codingTemplateY = new Int32Array(codingTemplateLength);
  47721. var k;
  47722. for (k = 0; k < codingTemplateLength; k++) {
  47723. codingTemplateX[k] = codingTemplate[k].x;
  47724. codingTemplateY[k] = codingTemplate[k].y;
  47725. }
  47726. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  47727. if (templateIndex === 0) {
  47728. referenceTemplate = referenceTemplate.concat([at[1]]);
  47729. }
  47730. var referenceTemplateLength = referenceTemplate.length;
  47731. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  47732. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  47733. for (k = 0; k < referenceTemplateLength; k++) {
  47734. referenceTemplateX[k] = referenceTemplate[k].x;
  47735. referenceTemplateY[k] = referenceTemplate[k].y;
  47736. }
  47737. var referenceWidth = referenceBitmap[0].length;
  47738. var referenceHeight = referenceBitmap.length;
  47739. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  47740. var bitmap = [];
  47741. var decoder = decodingContext.decoder;
  47742. var contexts = decodingContext.contextCache.getContexts('GR');
  47743. var ltp = 0;
  47744. for (var i = 0; i < height; i++) {
  47745. if (prediction) {
  47746. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  47747. ltp ^= sltp;
  47748. if (ltp) {
  47749. error('JBIG2 error: prediction is not supported');
  47750. }
  47751. }
  47752. var row = new Uint8Array(width);
  47753. bitmap.push(row);
  47754. for (var j = 0; j < width; j++) {
  47755. var i0, j0;
  47756. var contextLabel = 0;
  47757. for (k = 0; k < codingTemplateLength; k++) {
  47758. i0 = i + codingTemplateY[k];
  47759. j0 = j + codingTemplateX[k];
  47760. if (i0 < 0 || j0 < 0 || j0 >= width) {
  47761. contextLabel <<= 1;
  47762. } else {
  47763. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  47764. }
  47765. }
  47766. for (k = 0; k < referenceTemplateLength; k++) {
  47767. i0 = i + referenceTemplateY[k] + offsetY;
  47768. j0 = j + referenceTemplateX[k] + offsetX;
  47769. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  47770. contextLabel <<= 1;
  47771. } else {
  47772. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  47773. }
  47774. }
  47775. var pixel = decoder.readBit(contexts, contextLabel);
  47776. row[j] = pixel;
  47777. }
  47778. }
  47779. return bitmap;
  47780. }
  47781. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  47782. if (huffman) {
  47783. error('JBIG2 error: huffman is not supported');
  47784. }
  47785. var newSymbols = [];
  47786. var currentHeight = 0;
  47787. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  47788. var decoder = decodingContext.decoder;
  47789. var contextCache = decodingContext.contextCache;
  47790. while (newSymbols.length < numberOfNewSymbols) {
  47791. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  47792. currentHeight += deltaHeight;
  47793. var currentWidth = 0;
  47794. while (true) {
  47795. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  47796. if (deltaWidth === null) {
  47797. break;
  47798. }
  47799. currentWidth += deltaWidth;
  47800. var bitmap;
  47801. if (refinement) {
  47802. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  47803. if (numberOfInstances > 1) {
  47804. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  47805. } else {
  47806. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  47807. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  47808. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  47809. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  47810. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  47811. }
  47812. } else {
  47813. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  47814. }
  47815. newSymbols.push(bitmap);
  47816. }
  47817. }
  47818. var exportedSymbols = [];
  47819. var flags = [], currentFlag = false;
  47820. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  47821. while (flags.length < totalSymbolsLength) {
  47822. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  47823. while (runLength--) {
  47824. flags.push(currentFlag);
  47825. }
  47826. currentFlag = !currentFlag;
  47827. }
  47828. for (var i = 0, ii = symbols.length; i < ii; i++) {
  47829. if (flags[i]) {
  47830. exportedSymbols.push(symbols[i]);
  47831. }
  47832. }
  47833. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  47834. if (flags[i]) {
  47835. exportedSymbols.push(newSymbols[j]);
  47836. }
  47837. }
  47838. return exportedSymbols;
  47839. }
  47840. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  47841. if (huffman) {
  47842. error('JBIG2 error: huffman is not supported');
  47843. }
  47844. var bitmap = [];
  47845. var i, row;
  47846. for (i = 0; i < height; i++) {
  47847. row = new Uint8Array(width);
  47848. if (defaultPixelValue) {
  47849. for (var j = 0; j < width; j++) {
  47850. row[j] = defaultPixelValue;
  47851. }
  47852. }
  47853. bitmap.push(row);
  47854. }
  47855. var decoder = decodingContext.decoder;
  47856. var contextCache = decodingContext.contextCache;
  47857. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  47858. var firstS = 0;
  47859. i = 0;
  47860. while (i < numberOfSymbolInstances) {
  47861. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  47862. stripT += deltaT;
  47863. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  47864. firstS += deltaFirstS;
  47865. var currentS = firstS;
  47866. do {
  47867. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  47868. var t = stripSize * stripT + currentT;
  47869. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  47870. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  47871. var symbolBitmap = inputSymbols[symbolId];
  47872. var symbolWidth = symbolBitmap[0].length;
  47873. var symbolHeight = symbolBitmap.length;
  47874. if (applyRefinement) {
  47875. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  47876. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  47877. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  47878. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  47879. symbolWidth += rdw;
  47880. symbolHeight += rdh;
  47881. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  47882. }
  47883. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  47884. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  47885. var s2, t2, symbolRow;
  47886. if (transposed) {
  47887. for (s2 = 0; s2 < symbolHeight; s2++) {
  47888. row = bitmap[offsetS + s2];
  47889. if (!row) {
  47890. continue;
  47891. }
  47892. symbolRow = symbolBitmap[s2];
  47893. var maxWidth = Math.min(width - offsetT, symbolWidth);
  47894. switch (combinationOperator) {
  47895. case 0:
  47896. for (t2 = 0; t2 < maxWidth; t2++) {
  47897. row[offsetT + t2] |= symbolRow[t2];
  47898. }
  47899. break;
  47900. case 2:
  47901. for (t2 = 0; t2 < maxWidth; t2++) {
  47902. row[offsetT + t2] ^= symbolRow[t2];
  47903. }
  47904. break;
  47905. default:
  47906. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47907. }
  47908. }
  47909. currentS += symbolHeight - 1;
  47910. } else {
  47911. for (t2 = 0; t2 < symbolHeight; t2++) {
  47912. row = bitmap[offsetT + t2];
  47913. if (!row) {
  47914. continue;
  47915. }
  47916. symbolRow = symbolBitmap[t2];
  47917. switch (combinationOperator) {
  47918. case 0:
  47919. for (s2 = 0; s2 < symbolWidth; s2++) {
  47920. row[offsetS + s2] |= symbolRow[s2];
  47921. }
  47922. break;
  47923. case 2:
  47924. for (s2 = 0; s2 < symbolWidth; s2++) {
  47925. row[offsetS + s2] ^= symbolRow[s2];
  47926. }
  47927. break;
  47928. default:
  47929. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  47930. }
  47931. }
  47932. currentS += symbolWidth - 1;
  47933. }
  47934. i++;
  47935. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  47936. if (deltaS === null) {
  47937. break;
  47938. }
  47939. currentS += deltaS + dsOffset;
  47940. } while (true);
  47941. }
  47942. return bitmap;
  47943. }
  47944. function readSegmentHeader(data, start) {
  47945. var segmentHeader = {};
  47946. segmentHeader.number = readUint32(data, start);
  47947. var flags = data[start + 4];
  47948. var segmentType = flags & 0x3F;
  47949. if (!SegmentTypes[segmentType]) {
  47950. error('JBIG2 error: invalid segment type: ' + segmentType);
  47951. }
  47952. segmentHeader.type = segmentType;
  47953. segmentHeader.typeName = SegmentTypes[segmentType];
  47954. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  47955. var pageAssociationFieldSize = !!(flags & 0x40);
  47956. var referredFlags = data[start + 5];
  47957. var referredToCount = referredFlags >> 5 & 7;
  47958. var retainBits = [referredFlags & 31];
  47959. var position = start + 6;
  47960. if (referredFlags === 7) {
  47961. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  47962. position += 3;
  47963. var bytes = referredToCount + 7 >> 3;
  47964. retainBits[0] = data[position++];
  47965. while (--bytes > 0) {
  47966. retainBits.push(data[position++]);
  47967. }
  47968. } else if (referredFlags === 5 || referredFlags === 6) {
  47969. error('JBIG2 error: invalid referred-to flags');
  47970. }
  47971. segmentHeader.retainBits = retainBits;
  47972. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  47973. var referredTo = [];
  47974. var i, ii;
  47975. for (i = 0; i < referredToCount; i++) {
  47976. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  47977. referredTo.push(number);
  47978. position += referredToSegmentNumberSize;
  47979. }
  47980. segmentHeader.referredTo = referredTo;
  47981. if (!pageAssociationFieldSize) {
  47982. segmentHeader.pageAssociation = data[position++];
  47983. } else {
  47984. segmentHeader.pageAssociation = readUint32(data, position);
  47985. position += 4;
  47986. }
  47987. segmentHeader.length = readUint32(data, position);
  47988. position += 4;
  47989. if (segmentHeader.length === 0xFFFFFFFF) {
  47990. if (segmentType === 38) {
  47991. var genericRegionInfo = readRegionSegmentInformation(data, position);
  47992. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  47993. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  47994. var searchPatternLength = 6;
  47995. var searchPattern = new Uint8Array(searchPatternLength);
  47996. if (!genericRegionMmr) {
  47997. searchPattern[0] = 0xFF;
  47998. searchPattern[1] = 0xAC;
  47999. }
  48000. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  48001. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  48002. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  48003. searchPattern[5] = genericRegionInfo.height & 0xFF;
  48004. for (i = position, ii = data.length; i < ii; i++) {
  48005. var j = 0;
  48006. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  48007. j++;
  48008. }
  48009. if (j === searchPatternLength) {
  48010. segmentHeader.length = i + searchPatternLength;
  48011. break;
  48012. }
  48013. }
  48014. if (segmentHeader.length === 0xFFFFFFFF) {
  48015. error('JBIG2 error: segment end was not found');
  48016. }
  48017. } else {
  48018. error('JBIG2 error: invalid unknown segment length');
  48019. }
  48020. }
  48021. segmentHeader.headerEnd = position;
  48022. return segmentHeader;
  48023. }
  48024. function readSegments(header, data, start, end) {
  48025. var segments = [];
  48026. var position = start;
  48027. while (position < end) {
  48028. var segmentHeader = readSegmentHeader(data, position);
  48029. position = segmentHeader.headerEnd;
  48030. var segment = {
  48031. header: segmentHeader,
  48032. data: data
  48033. };
  48034. if (!header.randomAccess) {
  48035. segment.start = position;
  48036. position += segmentHeader.length;
  48037. segment.end = position;
  48038. }
  48039. segments.push(segment);
  48040. if (segmentHeader.type === 51) {
  48041. break;
  48042. }
  48043. }
  48044. if (header.randomAccess) {
  48045. for (var i = 0, ii = segments.length; i < ii; i++) {
  48046. segments[i].start = position;
  48047. position += segments[i].header.length;
  48048. segments[i].end = position;
  48049. }
  48050. }
  48051. return segments;
  48052. }
  48053. function readRegionSegmentInformation(data, start) {
  48054. return {
  48055. width: readUint32(data, start),
  48056. height: readUint32(data, start + 4),
  48057. x: readUint32(data, start + 8),
  48058. y: readUint32(data, start + 12),
  48059. combinationOperator: data[start + 16] & 7
  48060. };
  48061. }
  48062. var RegionSegmentInformationFieldLength = 17;
  48063. function processSegment(segment, visitor) {
  48064. var header = segment.header;
  48065. var data = segment.data, position = segment.start, end = segment.end;
  48066. var args, at, i, atLength;
  48067. switch (header.type) {
  48068. case 0:
  48069. var dictionary = {};
  48070. var dictionaryFlags = readUint16(data, position);
  48071. dictionary.huffman = !!(dictionaryFlags & 1);
  48072. dictionary.refinement = !!(dictionaryFlags & 2);
  48073. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  48074. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  48075. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  48076. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  48077. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  48078. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  48079. dictionary.template = dictionaryFlags >> 10 & 3;
  48080. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  48081. position += 2;
  48082. if (!dictionary.huffman) {
  48083. atLength = dictionary.template === 0 ? 4 : 1;
  48084. at = [];
  48085. for (i = 0; i < atLength; i++) {
  48086. at.push({
  48087. x: readInt8(data, position),
  48088. y: readInt8(data, position + 1)
  48089. });
  48090. position += 2;
  48091. }
  48092. dictionary.at = at;
  48093. }
  48094. if (dictionary.refinement && !dictionary.refinementTemplate) {
  48095. at = [];
  48096. for (i = 0; i < 2; i++) {
  48097. at.push({
  48098. x: readInt8(data, position),
  48099. y: readInt8(data, position + 1)
  48100. });
  48101. position += 2;
  48102. }
  48103. dictionary.refinementAt = at;
  48104. }
  48105. dictionary.numberOfExportedSymbols = readUint32(data, position);
  48106. position += 4;
  48107. dictionary.numberOfNewSymbols = readUint32(data, position);
  48108. position += 4;
  48109. args = [
  48110. dictionary,
  48111. header.number,
  48112. header.referredTo,
  48113. data,
  48114. position,
  48115. end
  48116. ];
  48117. break;
  48118. case 6:
  48119. case 7:
  48120. var textRegion = {};
  48121. textRegion.info = readRegionSegmentInformation(data, position);
  48122. position += RegionSegmentInformationFieldLength;
  48123. var textRegionSegmentFlags = readUint16(data, position);
  48124. position += 2;
  48125. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  48126. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  48127. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  48128. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  48129. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  48130. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  48131. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  48132. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  48133. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  48134. if (textRegion.huffman) {
  48135. var textRegionHuffmanFlags = readUint16(data, position);
  48136. position += 2;
  48137. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  48138. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  48139. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  48140. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  48141. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  48142. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  48143. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  48144. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  48145. }
  48146. if (textRegion.refinement && !textRegion.refinementTemplate) {
  48147. at = [];
  48148. for (i = 0; i < 2; i++) {
  48149. at.push({
  48150. x: readInt8(data, position),
  48151. y: readInt8(data, position + 1)
  48152. });
  48153. position += 2;
  48154. }
  48155. textRegion.refinementAt = at;
  48156. }
  48157. textRegion.numberOfSymbolInstances = readUint32(data, position);
  48158. position += 4;
  48159. if (textRegion.huffman) {
  48160. error('JBIG2 error: huffman is not supported');
  48161. }
  48162. args = [
  48163. textRegion,
  48164. header.referredTo,
  48165. data,
  48166. position,
  48167. end
  48168. ];
  48169. break;
  48170. case 38:
  48171. case 39:
  48172. var genericRegion = {};
  48173. genericRegion.info = readRegionSegmentInformation(data, position);
  48174. position += RegionSegmentInformationFieldLength;
  48175. var genericRegionSegmentFlags = data[position++];
  48176. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  48177. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  48178. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  48179. if (!genericRegion.mmr) {
  48180. atLength = genericRegion.template === 0 ? 4 : 1;
  48181. at = [];
  48182. for (i = 0; i < atLength; i++) {
  48183. at.push({
  48184. x: readInt8(data, position),
  48185. y: readInt8(data, position + 1)
  48186. });
  48187. position += 2;
  48188. }
  48189. genericRegion.at = at;
  48190. }
  48191. args = [
  48192. genericRegion,
  48193. data,
  48194. position,
  48195. end
  48196. ];
  48197. break;
  48198. case 48:
  48199. var pageInfo = {
  48200. width: readUint32(data, position),
  48201. height: readUint32(data, position + 4),
  48202. resolutionX: readUint32(data, position + 8),
  48203. resolutionY: readUint32(data, position + 12)
  48204. };
  48205. if (pageInfo.height === 0xFFFFFFFF) {
  48206. delete pageInfo.height;
  48207. }
  48208. var pageSegmentFlags = data[position + 16];
  48209. readUint16(data, position + 17);
  48210. pageInfo.lossless = !!(pageSegmentFlags & 1);
  48211. pageInfo.refinement = !!(pageSegmentFlags & 2);
  48212. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  48213. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  48214. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  48215. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  48216. args = [pageInfo];
  48217. break;
  48218. case 49:
  48219. break;
  48220. case 50:
  48221. break;
  48222. case 51:
  48223. break;
  48224. case 62:
  48225. break;
  48226. default:
  48227. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  48228. }
  48229. var callbackName = 'on' + header.typeName;
  48230. if (callbackName in visitor) {
  48231. visitor[callbackName].apply(visitor, args);
  48232. }
  48233. }
  48234. function processSegments(segments, visitor) {
  48235. for (var i = 0, ii = segments.length; i < ii; i++) {
  48236. processSegment(segments[i], visitor);
  48237. }
  48238. }
  48239. function parseJbig2(data, start, end) {
  48240. var position = start;
  48241. 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) {
  48242. error('JBIG2 error: invalid header');
  48243. }
  48244. var header = {};
  48245. position += 8;
  48246. var flags = data[position++];
  48247. header.randomAccess = !(flags & 1);
  48248. if (!(flags & 2)) {
  48249. header.numberOfPages = readUint32(data, position);
  48250. position += 4;
  48251. }
  48252. readSegments(header, data, position, end);
  48253. error('Not implemented');
  48254. }
  48255. function parseJbig2Chunks(chunks) {
  48256. var visitor = new SimpleSegmentVisitor();
  48257. for (var i = 0, ii = chunks.length; i < ii; i++) {
  48258. var chunk = chunks[i];
  48259. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  48260. processSegments(segments, visitor);
  48261. }
  48262. return visitor.buffer;
  48263. }
  48264. function SimpleSegmentVisitor() {
  48265. }
  48266. SimpleSegmentVisitor.prototype = {
  48267. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  48268. this.currentPageInfo = info;
  48269. var rowSize = info.width + 7 >> 3;
  48270. var buffer = new Uint8Array(rowSize * info.height);
  48271. if (info.defaultPixelValue) {
  48272. for (var i = 0, ii = buffer.length; i < ii; i++) {
  48273. buffer[i] = 0xFF;
  48274. }
  48275. }
  48276. this.buffer = buffer;
  48277. },
  48278. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  48279. var pageInfo = this.currentPageInfo;
  48280. var width = regionInfo.width, height = regionInfo.height;
  48281. var rowSize = pageInfo.width + 7 >> 3;
  48282. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  48283. var buffer = this.buffer;
  48284. var mask0 = 128 >> (regionInfo.x & 7);
  48285. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  48286. var i, j, mask, offset;
  48287. switch (combinationOperator) {
  48288. case 0:
  48289. for (i = 0; i < height; i++) {
  48290. mask = mask0;
  48291. offset = offset0;
  48292. for (j = 0; j < width; j++) {
  48293. if (bitmap[i][j]) {
  48294. buffer[offset] |= mask;
  48295. }
  48296. mask >>= 1;
  48297. if (!mask) {
  48298. mask = 128;
  48299. offset++;
  48300. }
  48301. }
  48302. offset0 += rowSize;
  48303. }
  48304. break;
  48305. case 2:
  48306. for (i = 0; i < height; i++) {
  48307. mask = mask0;
  48308. offset = offset0;
  48309. for (j = 0; j < width; j++) {
  48310. if (bitmap[i][j]) {
  48311. buffer[offset] ^= mask;
  48312. }
  48313. mask >>= 1;
  48314. if (!mask) {
  48315. mask = 128;
  48316. offset++;
  48317. }
  48318. }
  48319. offset0 += rowSize;
  48320. }
  48321. break;
  48322. default:
  48323. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  48324. }
  48325. },
  48326. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  48327. var regionInfo = region.info;
  48328. var decodingContext = new DecodingContext(data, start, end);
  48329. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  48330. this.drawBitmap(regionInfo, bitmap);
  48331. },
  48332. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  48333. this.onImmediateGenericRegion.apply(this, arguments);
  48334. },
  48335. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  48336. var huffmanTables;
  48337. if (dictionary.huffman) {
  48338. error('JBIG2 error: huffman is not supported');
  48339. }
  48340. var symbols = this.symbols;
  48341. if (!symbols) {
  48342. this.symbols = symbols = {};
  48343. }
  48344. var inputSymbols = [];
  48345. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  48346. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  48347. }
  48348. var decodingContext = new DecodingContext(data, start, end);
  48349. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  48350. },
  48351. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  48352. var regionInfo = region.info;
  48353. var huffmanTables;
  48354. var symbols = this.symbols;
  48355. var inputSymbols = [];
  48356. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  48357. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  48358. }
  48359. var symbolCodeLength = log2(inputSymbols.length);
  48360. var decodingContext = new DecodingContext(data, start, end);
  48361. 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);
  48362. this.drawBitmap(regionInfo, bitmap);
  48363. },
  48364. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  48365. this.onImmediateTextRegion.apply(this, arguments);
  48366. }
  48367. };
  48368. function Jbig2Image() {
  48369. }
  48370. Jbig2Image.prototype = {
  48371. parseChunks: function Jbig2Image_parseChunks(chunks) {
  48372. return parseJbig2Chunks(chunks);
  48373. }
  48374. };
  48375. return Jbig2Image;
  48376. }();
  48377. exports.Jbig2Image = Jbig2Image;
  48378. /***/ }),
  48379. /* 36 */
  48380. /***/ (function(module, exports, __w_pdfjs_require__) {
  48381. "use strict";
  48382. var sharedUtil = __w_pdfjs_require__(0);
  48383. var error = sharedUtil.error;
  48384. var JpegImage = function JpegImageClosure() {
  48385. var dctZigZag = new Uint8Array([
  48386. 0,
  48387. 1,
  48388. 8,
  48389. 16,
  48390. 9,
  48391. 2,
  48392. 3,
  48393. 10,
  48394. 17,
  48395. 24,
  48396. 32,
  48397. 25,
  48398. 18,
  48399. 11,
  48400. 4,
  48401. 5,
  48402. 12,
  48403. 19,
  48404. 26,
  48405. 33,
  48406. 40,
  48407. 48,
  48408. 41,
  48409. 34,
  48410. 27,
  48411. 20,
  48412. 13,
  48413. 6,
  48414. 7,
  48415. 14,
  48416. 21,
  48417. 28,
  48418. 35,
  48419. 42,
  48420. 49,
  48421. 56,
  48422. 57,
  48423. 50,
  48424. 43,
  48425. 36,
  48426. 29,
  48427. 22,
  48428. 15,
  48429. 23,
  48430. 30,
  48431. 37,
  48432. 44,
  48433. 51,
  48434. 58,
  48435. 59,
  48436. 52,
  48437. 45,
  48438. 38,
  48439. 31,
  48440. 39,
  48441. 46,
  48442. 53,
  48443. 60,
  48444. 61,
  48445. 54,
  48446. 47,
  48447. 55,
  48448. 62,
  48449. 63
  48450. ]);
  48451. var dctCos1 = 4017;
  48452. var dctSin1 = 799;
  48453. var dctCos3 = 3406;
  48454. var dctSin3 = 2276;
  48455. var dctCos6 = 1567;
  48456. var dctSin6 = 3784;
  48457. var dctSqrt2 = 5793;
  48458. var dctSqrt1d2 = 2896;
  48459. function JpegImage() {
  48460. this.decodeTransform = null;
  48461. this.colorTransform = -1;
  48462. }
  48463. function buildHuffmanTable(codeLengths, values) {
  48464. var k = 0, code = [], i, j, length = 16;
  48465. while (length > 0 && !codeLengths[length - 1]) {
  48466. length--;
  48467. }
  48468. code.push({
  48469. children: [],
  48470. index: 0
  48471. });
  48472. var p = code[0], q;
  48473. for (i = 0; i < length; i++) {
  48474. for (j = 0; j < codeLengths[i]; j++) {
  48475. p = code.pop();
  48476. p.children[p.index] = values[k];
  48477. while (p.index > 0) {
  48478. p = code.pop();
  48479. }
  48480. p.index++;
  48481. code.push(p);
  48482. while (code.length <= i) {
  48483. code.push(q = {
  48484. children: [],
  48485. index: 0
  48486. });
  48487. p.children[p.index] = q.children;
  48488. p = q;
  48489. }
  48490. k++;
  48491. }
  48492. if (i + 1 < length) {
  48493. code.push(q = {
  48494. children: [],
  48495. index: 0
  48496. });
  48497. p.children[p.index] = q.children;
  48498. p = q;
  48499. }
  48500. }
  48501. return code[0].children;
  48502. }
  48503. function getBlockBufferOffset(component, row, col) {
  48504. return 64 * ((component.blocksPerLine + 1) * row + col);
  48505. }
  48506. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  48507. var mcusPerLine = frame.mcusPerLine;
  48508. var progressive = frame.progressive;
  48509. var startOffset = offset, bitsData = 0, bitsCount = 0;
  48510. function readBit() {
  48511. if (bitsCount > 0) {
  48512. bitsCount--;
  48513. return bitsData >> bitsCount & 1;
  48514. }
  48515. bitsData = data[offset++];
  48516. if (bitsData === 0xFF) {
  48517. var nextByte = data[offset++];
  48518. if (nextByte) {
  48519. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  48520. }
  48521. }
  48522. bitsCount = 7;
  48523. return bitsData >>> 7;
  48524. }
  48525. function decodeHuffman(tree) {
  48526. var node = tree;
  48527. while (true) {
  48528. node = node[readBit()];
  48529. if (typeof node === 'number') {
  48530. return node;
  48531. }
  48532. if (typeof node !== 'object') {
  48533. error('JPEG error: invalid huffman sequence');
  48534. }
  48535. }
  48536. }
  48537. function receive(length) {
  48538. var n = 0;
  48539. while (length > 0) {
  48540. n = n << 1 | readBit();
  48541. length--;
  48542. }
  48543. return n;
  48544. }
  48545. function receiveAndExtend(length) {
  48546. if (length === 1) {
  48547. return readBit() === 1 ? 1 : -1;
  48548. }
  48549. var n = receive(length);
  48550. if (n >= 1 << length - 1) {
  48551. return n;
  48552. }
  48553. return n + (-1 << length) + 1;
  48554. }
  48555. function decodeBaseline(component, offset) {
  48556. var t = decodeHuffman(component.huffmanTableDC);
  48557. var diff = t === 0 ? 0 : receiveAndExtend(t);
  48558. component.blockData[offset] = component.pred += diff;
  48559. var k = 1;
  48560. while (k < 64) {
  48561. var rs = decodeHuffman(component.huffmanTableAC);
  48562. var s = rs & 15, r = rs >> 4;
  48563. if (s === 0) {
  48564. if (r < 15) {
  48565. break;
  48566. }
  48567. k += 16;
  48568. continue;
  48569. }
  48570. k += r;
  48571. var z = dctZigZag[k];
  48572. component.blockData[offset + z] = receiveAndExtend(s);
  48573. k++;
  48574. }
  48575. }
  48576. function decodeDCFirst(component, offset) {
  48577. var t = decodeHuffman(component.huffmanTableDC);
  48578. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  48579. component.blockData[offset] = component.pred += diff;
  48580. }
  48581. function decodeDCSuccessive(component, offset) {
  48582. component.blockData[offset] |= readBit() << successive;
  48583. }
  48584. var eobrun = 0;
  48585. function decodeACFirst(component, offset) {
  48586. if (eobrun > 0) {
  48587. eobrun--;
  48588. return;
  48589. }
  48590. var k = spectralStart, e = spectralEnd;
  48591. while (k <= e) {
  48592. var rs = decodeHuffman(component.huffmanTableAC);
  48593. var s = rs & 15, r = rs >> 4;
  48594. if (s === 0) {
  48595. if (r < 15) {
  48596. eobrun = receive(r) + (1 << r) - 1;
  48597. break;
  48598. }
  48599. k += 16;
  48600. continue;
  48601. }
  48602. k += r;
  48603. var z = dctZigZag[k];
  48604. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  48605. k++;
  48606. }
  48607. }
  48608. var successiveACState = 0, successiveACNextValue;
  48609. function decodeACSuccessive(component, offset) {
  48610. var k = spectralStart;
  48611. var e = spectralEnd;
  48612. var r = 0;
  48613. var s;
  48614. var rs;
  48615. while (k <= e) {
  48616. var z = dctZigZag[k];
  48617. switch (successiveACState) {
  48618. case 0:
  48619. rs = decodeHuffman(component.huffmanTableAC);
  48620. s = rs & 15;
  48621. r = rs >> 4;
  48622. if (s === 0) {
  48623. if (r < 15) {
  48624. eobrun = receive(r) + (1 << r);
  48625. successiveACState = 4;
  48626. } else {
  48627. r = 16;
  48628. successiveACState = 1;
  48629. }
  48630. } else {
  48631. if (s !== 1) {
  48632. error('JPEG error: invalid ACn encoding');
  48633. }
  48634. successiveACNextValue = receiveAndExtend(s);
  48635. successiveACState = r ? 2 : 3;
  48636. }
  48637. continue;
  48638. case 1:
  48639. case 2:
  48640. if (component.blockData[offset + z]) {
  48641. component.blockData[offset + z] += readBit() << successive;
  48642. } else {
  48643. r--;
  48644. if (r === 0) {
  48645. successiveACState = successiveACState === 2 ? 3 : 0;
  48646. }
  48647. }
  48648. break;
  48649. case 3:
  48650. if (component.blockData[offset + z]) {
  48651. component.blockData[offset + z] += readBit() << successive;
  48652. } else {
  48653. component.blockData[offset + z] = successiveACNextValue << successive;
  48654. successiveACState = 0;
  48655. }
  48656. break;
  48657. case 4:
  48658. if (component.blockData[offset + z]) {
  48659. component.blockData[offset + z] += readBit() << successive;
  48660. }
  48661. break;
  48662. }
  48663. k++;
  48664. }
  48665. if (successiveACState === 4) {
  48666. eobrun--;
  48667. if (eobrun === 0) {
  48668. successiveACState = 0;
  48669. }
  48670. }
  48671. }
  48672. function decodeMcu(component, decode, mcu, row, col) {
  48673. var mcuRow = mcu / mcusPerLine | 0;
  48674. var mcuCol = mcu % mcusPerLine;
  48675. var blockRow = mcuRow * component.v + row;
  48676. var blockCol = mcuCol * component.h + col;
  48677. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48678. decode(component, offset);
  48679. }
  48680. function decodeBlock(component, decode, mcu) {
  48681. var blockRow = mcu / component.blocksPerLine | 0;
  48682. var blockCol = mcu % component.blocksPerLine;
  48683. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48684. decode(component, offset);
  48685. }
  48686. var componentsLength = components.length;
  48687. var component, i, j, k, n;
  48688. var decodeFn;
  48689. if (progressive) {
  48690. if (spectralStart === 0) {
  48691. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  48692. } else {
  48693. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  48694. }
  48695. } else {
  48696. decodeFn = decodeBaseline;
  48697. }
  48698. var mcu = 0, marker;
  48699. var mcuExpected;
  48700. if (componentsLength === 1) {
  48701. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  48702. } else {
  48703. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  48704. }
  48705. if (!resetInterval) {
  48706. resetInterval = mcuExpected;
  48707. }
  48708. var h, v;
  48709. while (mcu < mcuExpected) {
  48710. for (i = 0; i < componentsLength; i++) {
  48711. components[i].pred = 0;
  48712. }
  48713. eobrun = 0;
  48714. if (componentsLength === 1) {
  48715. component = components[0];
  48716. for (n = 0; n < resetInterval; n++) {
  48717. decodeBlock(component, decodeFn, mcu);
  48718. mcu++;
  48719. }
  48720. } else {
  48721. for (n = 0; n < resetInterval; n++) {
  48722. for (i = 0; i < componentsLength; i++) {
  48723. component = components[i];
  48724. h = component.h;
  48725. v = component.v;
  48726. for (j = 0; j < v; j++) {
  48727. for (k = 0; k < h; k++) {
  48728. decodeMcu(component, decodeFn, mcu, j, k);
  48729. }
  48730. }
  48731. }
  48732. mcu++;
  48733. }
  48734. }
  48735. bitsCount = 0;
  48736. marker = data[offset] << 8 | data[offset + 1];
  48737. while (data[offset] === 0x00 && offset < data.length - 1) {
  48738. offset++;
  48739. marker = data[offset] << 8 | data[offset + 1];
  48740. }
  48741. if (marker <= 0xFF00) {
  48742. error('JPEG error: marker was not found');
  48743. }
  48744. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  48745. offset += 2;
  48746. } else {
  48747. break;
  48748. }
  48749. }
  48750. return offset - startOffset;
  48751. }
  48752. function quantizeAndInverse(component, blockBufferOffset, p) {
  48753. var qt = component.quantizationTable, blockData = component.blockData;
  48754. var v0, v1, v2, v3, v4, v5, v6, v7;
  48755. var p0, p1, p2, p3, p4, p5, p6, p7;
  48756. var t;
  48757. if (!qt) {
  48758. error('JPEG error: missing required Quantization Table.');
  48759. }
  48760. for (var row = 0; row < 64; row += 8) {
  48761. p0 = blockData[blockBufferOffset + row];
  48762. p1 = blockData[blockBufferOffset + row + 1];
  48763. p2 = blockData[blockBufferOffset + row + 2];
  48764. p3 = blockData[blockBufferOffset + row + 3];
  48765. p4 = blockData[blockBufferOffset + row + 4];
  48766. p5 = blockData[blockBufferOffset + row + 5];
  48767. p6 = blockData[blockBufferOffset + row + 6];
  48768. p7 = blockData[blockBufferOffset + row + 7];
  48769. p0 *= qt[row];
  48770. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  48771. t = dctSqrt2 * p0 + 512 >> 10;
  48772. p[row] = t;
  48773. p[row + 1] = t;
  48774. p[row + 2] = t;
  48775. p[row + 3] = t;
  48776. p[row + 4] = t;
  48777. p[row + 5] = t;
  48778. p[row + 6] = t;
  48779. p[row + 7] = t;
  48780. continue;
  48781. }
  48782. p1 *= qt[row + 1];
  48783. p2 *= qt[row + 2];
  48784. p3 *= qt[row + 3];
  48785. p4 *= qt[row + 4];
  48786. p5 *= qt[row + 5];
  48787. p6 *= qt[row + 6];
  48788. p7 *= qt[row + 7];
  48789. v0 = dctSqrt2 * p0 + 128 >> 8;
  48790. v1 = dctSqrt2 * p4 + 128 >> 8;
  48791. v2 = p2;
  48792. v3 = p6;
  48793. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  48794. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  48795. v5 = p3 << 4;
  48796. v6 = p5 << 4;
  48797. v0 = v0 + v1 + 1 >> 1;
  48798. v1 = v0 - v1;
  48799. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  48800. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  48801. v3 = t;
  48802. v4 = v4 + v6 + 1 >> 1;
  48803. v6 = v4 - v6;
  48804. v7 = v7 + v5 + 1 >> 1;
  48805. v5 = v7 - v5;
  48806. v0 = v0 + v3 + 1 >> 1;
  48807. v3 = v0 - v3;
  48808. v1 = v1 + v2 + 1 >> 1;
  48809. v2 = v1 - v2;
  48810. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  48811. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  48812. v7 = t;
  48813. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  48814. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  48815. v6 = t;
  48816. p[row] = v0 + v7;
  48817. p[row + 7] = v0 - v7;
  48818. p[row + 1] = v1 + v6;
  48819. p[row + 6] = v1 - v6;
  48820. p[row + 2] = v2 + v5;
  48821. p[row + 5] = v2 - v5;
  48822. p[row + 3] = v3 + v4;
  48823. p[row + 4] = v3 - v4;
  48824. }
  48825. for (var col = 0; col < 8; ++col) {
  48826. p0 = p[col];
  48827. p1 = p[col + 8];
  48828. p2 = p[col + 16];
  48829. p3 = p[col + 24];
  48830. p4 = p[col + 32];
  48831. p5 = p[col + 40];
  48832. p6 = p[col + 48];
  48833. p7 = p[col + 56];
  48834. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  48835. t = dctSqrt2 * p0 + 8192 >> 14;
  48836. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  48837. blockData[blockBufferOffset + col] = t;
  48838. blockData[blockBufferOffset + col + 8] = t;
  48839. blockData[blockBufferOffset + col + 16] = t;
  48840. blockData[blockBufferOffset + col + 24] = t;
  48841. blockData[blockBufferOffset + col + 32] = t;
  48842. blockData[blockBufferOffset + col + 40] = t;
  48843. blockData[blockBufferOffset + col + 48] = t;
  48844. blockData[blockBufferOffset + col + 56] = t;
  48845. continue;
  48846. }
  48847. v0 = dctSqrt2 * p0 + 2048 >> 12;
  48848. v1 = dctSqrt2 * p4 + 2048 >> 12;
  48849. v2 = p2;
  48850. v3 = p6;
  48851. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  48852. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  48853. v5 = p3;
  48854. v6 = p5;
  48855. v0 = (v0 + v1 + 1 >> 1) + 4112;
  48856. v1 = v0 - v1;
  48857. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  48858. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  48859. v3 = t;
  48860. v4 = v4 + v6 + 1 >> 1;
  48861. v6 = v4 - v6;
  48862. v7 = v7 + v5 + 1 >> 1;
  48863. v5 = v7 - v5;
  48864. v0 = v0 + v3 + 1 >> 1;
  48865. v3 = v0 - v3;
  48866. v1 = v1 + v2 + 1 >> 1;
  48867. v2 = v1 - v2;
  48868. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  48869. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  48870. v7 = t;
  48871. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  48872. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  48873. v6 = t;
  48874. p0 = v0 + v7;
  48875. p7 = v0 - v7;
  48876. p1 = v1 + v6;
  48877. p6 = v1 - v6;
  48878. p2 = v2 + v5;
  48879. p5 = v2 - v5;
  48880. p3 = v3 + v4;
  48881. p4 = v3 - v4;
  48882. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  48883. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  48884. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  48885. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  48886. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  48887. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  48888. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  48889. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  48890. blockData[blockBufferOffset + col] = p0;
  48891. blockData[blockBufferOffset + col + 8] = p1;
  48892. blockData[blockBufferOffset + col + 16] = p2;
  48893. blockData[blockBufferOffset + col + 24] = p3;
  48894. blockData[blockBufferOffset + col + 32] = p4;
  48895. blockData[blockBufferOffset + col + 40] = p5;
  48896. blockData[blockBufferOffset + col + 48] = p6;
  48897. blockData[blockBufferOffset + col + 56] = p7;
  48898. }
  48899. }
  48900. function buildComponentData(frame, component) {
  48901. var blocksPerLine = component.blocksPerLine;
  48902. var blocksPerColumn = component.blocksPerColumn;
  48903. var computationBuffer = new Int16Array(64);
  48904. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  48905. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  48906. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  48907. quantizeAndInverse(component, offset, computationBuffer);
  48908. }
  48909. }
  48910. return component.blockData;
  48911. }
  48912. function clamp0to255(a) {
  48913. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  48914. }
  48915. JpegImage.prototype = {
  48916. parse: function parse(data) {
  48917. function readUint16() {
  48918. var value = data[offset] << 8 | data[offset + 1];
  48919. offset += 2;
  48920. return value;
  48921. }
  48922. function readDataBlock() {
  48923. var length = readUint16();
  48924. var array = data.subarray(offset, offset + length - 2);
  48925. offset += array.length;
  48926. return array;
  48927. }
  48928. function prepareComponents(frame) {
  48929. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  48930. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  48931. for (var i = 0; i < frame.components.length; i++) {
  48932. component = frame.components[i];
  48933. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  48934. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  48935. var blocksPerLineForMcu = mcusPerLine * component.h;
  48936. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  48937. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  48938. component.blockData = new Int16Array(blocksBufferSize);
  48939. component.blocksPerLine = blocksPerLine;
  48940. component.blocksPerColumn = blocksPerColumn;
  48941. }
  48942. frame.mcusPerLine = mcusPerLine;
  48943. frame.mcusPerColumn = mcusPerColumn;
  48944. }
  48945. var offset = 0;
  48946. var jfif = null;
  48947. var adobe = null;
  48948. var frame, resetInterval;
  48949. var quantizationTables = [];
  48950. var huffmanTablesAC = [], huffmanTablesDC = [];
  48951. var fileMarker = readUint16();
  48952. if (fileMarker !== 0xFFD8) {
  48953. error('JPEG error: SOI not found');
  48954. }
  48955. fileMarker = readUint16();
  48956. while (fileMarker !== 0xFFD9) {
  48957. var i, j, l;
  48958. switch (fileMarker) {
  48959. case 0xFFE0:
  48960. case 0xFFE1:
  48961. case 0xFFE2:
  48962. case 0xFFE3:
  48963. case 0xFFE4:
  48964. case 0xFFE5:
  48965. case 0xFFE6:
  48966. case 0xFFE7:
  48967. case 0xFFE8:
  48968. case 0xFFE9:
  48969. case 0xFFEA:
  48970. case 0xFFEB:
  48971. case 0xFFEC:
  48972. case 0xFFED:
  48973. case 0xFFEE:
  48974. case 0xFFEF:
  48975. case 0xFFFE:
  48976. var appData = readDataBlock();
  48977. if (fileMarker === 0xFFE0) {
  48978. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  48979. jfif = {
  48980. version: {
  48981. major: appData[5],
  48982. minor: appData[6]
  48983. },
  48984. densityUnits: appData[7],
  48985. xDensity: appData[8] << 8 | appData[9],
  48986. yDensity: appData[10] << 8 | appData[11],
  48987. thumbWidth: appData[12],
  48988. thumbHeight: appData[13],
  48989. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  48990. };
  48991. }
  48992. }
  48993. if (fileMarker === 0xFFEE) {
  48994. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  48995. adobe = {
  48996. version: appData[5] << 8 | appData[6],
  48997. flags0: appData[7] << 8 | appData[8],
  48998. flags1: appData[9] << 8 | appData[10],
  48999. transformCode: appData[11]
  49000. };
  49001. }
  49002. }
  49003. break;
  49004. case 0xFFDB:
  49005. var quantizationTablesLength = readUint16();
  49006. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  49007. var z;
  49008. while (offset < quantizationTablesEnd) {
  49009. var quantizationTableSpec = data[offset++];
  49010. var tableData = new Uint16Array(64);
  49011. if (quantizationTableSpec >> 4 === 0) {
  49012. for (j = 0; j < 64; j++) {
  49013. z = dctZigZag[j];
  49014. tableData[z] = data[offset++];
  49015. }
  49016. } else if (quantizationTableSpec >> 4 === 1) {
  49017. for (j = 0; j < 64; j++) {
  49018. z = dctZigZag[j];
  49019. tableData[z] = readUint16();
  49020. }
  49021. } else {
  49022. error('JPEG error: DQT - invalid table spec');
  49023. }
  49024. quantizationTables[quantizationTableSpec & 15] = tableData;
  49025. }
  49026. break;
  49027. case 0xFFC0:
  49028. case 0xFFC1:
  49029. case 0xFFC2:
  49030. if (frame) {
  49031. error('JPEG error: Only single frame JPEGs supported');
  49032. }
  49033. readUint16();
  49034. frame = {};
  49035. frame.extended = fileMarker === 0xFFC1;
  49036. frame.progressive = fileMarker === 0xFFC2;
  49037. frame.precision = data[offset++];
  49038. frame.scanLines = readUint16();
  49039. frame.samplesPerLine = readUint16();
  49040. frame.components = [];
  49041. frame.componentIds = {};
  49042. var componentsCount = data[offset++], componentId;
  49043. var maxH = 0, maxV = 0;
  49044. for (i = 0; i < componentsCount; i++) {
  49045. componentId = data[offset];
  49046. var h = data[offset + 1] >> 4;
  49047. var v = data[offset + 1] & 15;
  49048. if (maxH < h) {
  49049. maxH = h;
  49050. }
  49051. if (maxV < v) {
  49052. maxV = v;
  49053. }
  49054. var qId = data[offset + 2];
  49055. l = frame.components.push({
  49056. h: h,
  49057. v: v,
  49058. quantizationId: qId,
  49059. quantizationTable: null
  49060. });
  49061. frame.componentIds[componentId] = l - 1;
  49062. offset += 3;
  49063. }
  49064. frame.maxH = maxH;
  49065. frame.maxV = maxV;
  49066. prepareComponents(frame);
  49067. break;
  49068. case 0xFFC4:
  49069. var huffmanLength = readUint16();
  49070. for (i = 2; i < huffmanLength;) {
  49071. var huffmanTableSpec = data[offset++];
  49072. var codeLengths = new Uint8Array(16);
  49073. var codeLengthSum = 0;
  49074. for (j = 0; j < 16; j++, offset++) {
  49075. codeLengthSum += codeLengths[j] = data[offset];
  49076. }
  49077. var huffmanValues = new Uint8Array(codeLengthSum);
  49078. for (j = 0; j < codeLengthSum; j++, offset++) {
  49079. huffmanValues[j] = data[offset];
  49080. }
  49081. i += 17 + codeLengthSum;
  49082. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  49083. }
  49084. break;
  49085. case 0xFFDD:
  49086. readUint16();
  49087. resetInterval = readUint16();
  49088. break;
  49089. case 0xFFDA:
  49090. readUint16();
  49091. var selectorsCount = data[offset++];
  49092. var components = [], component;
  49093. for (i = 0; i < selectorsCount; i++) {
  49094. var componentIndex = frame.componentIds[data[offset++]];
  49095. component = frame.components[componentIndex];
  49096. var tableSpec = data[offset++];
  49097. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  49098. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  49099. components.push(component);
  49100. }
  49101. var spectralStart = data[offset++];
  49102. var spectralEnd = data[offset++];
  49103. var successiveApproximation = data[offset++];
  49104. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  49105. offset += processed;
  49106. break;
  49107. case 0xFFFF:
  49108. if (data[offset] !== 0xFF) {
  49109. offset--;
  49110. }
  49111. break;
  49112. default:
  49113. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  49114. offset -= 3;
  49115. break;
  49116. }
  49117. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  49118. }
  49119. fileMarker = readUint16();
  49120. }
  49121. this.width = frame.samplesPerLine;
  49122. this.height = frame.scanLines;
  49123. this.jfif = jfif;
  49124. this.adobe = adobe;
  49125. this.components = [];
  49126. for (i = 0; i < frame.components.length; i++) {
  49127. component = frame.components[i];
  49128. var quantizationTable = quantizationTables[component.quantizationId];
  49129. if (quantizationTable) {
  49130. component.quantizationTable = quantizationTable;
  49131. }
  49132. this.components.push({
  49133. output: buildComponentData(frame, component),
  49134. scaleX: component.h / frame.maxH,
  49135. scaleY: component.v / frame.maxV,
  49136. blocksPerLine: component.blocksPerLine,
  49137. blocksPerColumn: component.blocksPerColumn
  49138. });
  49139. }
  49140. this.numComponents = this.components.length;
  49141. },
  49142. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  49143. var scaleX = this.width / width, scaleY = this.height / height;
  49144. var component, componentScaleX, componentScaleY, blocksPerScanline;
  49145. var x, y, i, j, k;
  49146. var index;
  49147. var offset = 0;
  49148. var output;
  49149. var numComponents = this.components.length;
  49150. var dataLength = width * height * numComponents;
  49151. var data = new Uint8Array(dataLength);
  49152. var xScaleBlockOffset = new Uint32Array(width);
  49153. var mask3LSB = 0xfffffff8;
  49154. for (i = 0; i < numComponents; i++) {
  49155. component = this.components[i];
  49156. componentScaleX = component.scaleX * scaleX;
  49157. componentScaleY = component.scaleY * scaleY;
  49158. offset = i;
  49159. output = component.output;
  49160. blocksPerScanline = component.blocksPerLine + 1 << 3;
  49161. for (x = 0; x < width; x++) {
  49162. j = 0 | x * componentScaleX;
  49163. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  49164. }
  49165. for (y = 0; y < height; y++) {
  49166. j = 0 | y * componentScaleY;
  49167. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  49168. for (x = 0; x < width; x++) {
  49169. data[offset] = output[index + xScaleBlockOffset[x]];
  49170. offset += numComponents;
  49171. }
  49172. }
  49173. }
  49174. var transform = this.decodeTransform;
  49175. if (transform) {
  49176. for (i = 0; i < dataLength;) {
  49177. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  49178. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  49179. }
  49180. }
  49181. }
  49182. return data;
  49183. },
  49184. _isColorConversionNeeded: function isColorConversionNeeded() {
  49185. if (this.adobe && this.adobe.transformCode) {
  49186. return true;
  49187. } else if (this.numComponents === 3) {
  49188. if (!this.adobe && this.colorTransform === 0) {
  49189. return false;
  49190. }
  49191. return true;
  49192. }
  49193. if (!this.adobe && this.colorTransform === 1) {
  49194. return true;
  49195. }
  49196. return false;
  49197. },
  49198. _convertYccToRgb: function convertYccToRgb(data) {
  49199. var Y, Cb, Cr;
  49200. for (var i = 0, length = data.length; i < length; i += 3) {
  49201. Y = data[i];
  49202. Cb = data[i + 1];
  49203. Cr = data[i + 2];
  49204. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  49205. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  49206. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  49207. }
  49208. return data;
  49209. },
  49210. _convertYcckToRgb: function convertYcckToRgb(data) {
  49211. var Y, Cb, Cr, k;
  49212. var offset = 0;
  49213. for (var i = 0, length = data.length; i < length; i += 4) {
  49214. Y = data[i];
  49215. Cb = data[i + 1];
  49216. Cr = data[i + 2];
  49217. k = data[i + 3];
  49218. var r = -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);
  49219. var g = 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);
  49220. var b = -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);
  49221. data[offset++] = clamp0to255(r);
  49222. data[offset++] = clamp0to255(g);
  49223. data[offset++] = clamp0to255(b);
  49224. }
  49225. return data;
  49226. },
  49227. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  49228. var Y, Cb, Cr;
  49229. for (var i = 0, length = data.length; i < length; i += 4) {
  49230. Y = data[i];
  49231. Cb = data[i + 1];
  49232. Cr = data[i + 2];
  49233. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  49234. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  49235. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  49236. }
  49237. return data;
  49238. },
  49239. _convertCmykToRgb: function convertCmykToRgb(data) {
  49240. var c, m, y, k;
  49241. var offset = 0;
  49242. var min = -255 * 255 * 255;
  49243. var scale = 1 / 255 / 255;
  49244. for (var i = 0, length = data.length; i < length; i += 4) {
  49245. c = data[i];
  49246. m = data[i + 1];
  49247. y = data[i + 2];
  49248. k = data[i + 3];
  49249. var r = c * (-4.387332384609988 * c + 54.48615194189176 * m + 18.82290502165302 * y + 212.25662451639585 * k - 72734.4411664936) + m * (1.7149763477362134 * m - 5.6096736904047315 * y - 17.873870861415444 * k - 1401.7366389350734) + y * (-2.5217340131683033 * y - 21.248923337353073 * k + 4465.541406466231) - k * (21.86122147463605 * k + 48317.86113160301);
  49250. var g = c * (8.841041422036149 * c + 60.118027045597366 * m + 6.871425592049007 * y + 31.159100130055922 * k - 20220.756542821975) + m * (-15.310361306967817 * m + 17.575251261109482 * y + 131.35250912493976 * k - 48691.05921601825) + y * (4.444339102852739 * y + 9.8632861493405 * k - 6341.191035517494) - k * (20.737325471181034 * k + 47890.15695978492);
  49251. var b = c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k - 3616.812083916688) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 28620.90484698408) + y * (0.03296041114873217 * y + 115.60384449646641 * k - 49363.43385999684) - k * (22.33816807309886 * k + 45932.16563550634);
  49252. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  49253. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  49254. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  49255. }
  49256. return data;
  49257. },
  49258. getData: function getData(width, height, forceRGBoutput) {
  49259. if (this.numComponents > 4) {
  49260. error('JPEG error: Unsupported color mode');
  49261. }
  49262. var data = this._getLinearizedBlockData(width, height);
  49263. if (this.numComponents === 1 && forceRGBoutput) {
  49264. var dataLength = data.length;
  49265. var rgbData = new Uint8Array(dataLength * 3);
  49266. var offset = 0;
  49267. for (var i = 0; i < dataLength; i++) {
  49268. var grayColor = data[i];
  49269. rgbData[offset++] = grayColor;
  49270. rgbData[offset++] = grayColor;
  49271. rgbData[offset++] = grayColor;
  49272. }
  49273. return rgbData;
  49274. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  49275. return this._convertYccToRgb(data);
  49276. } else if (this.numComponents === 4) {
  49277. if (this._isColorConversionNeeded()) {
  49278. if (forceRGBoutput) {
  49279. return this._convertYcckToRgb(data);
  49280. }
  49281. return this._convertYcckToCmyk(data);
  49282. } else if (forceRGBoutput) {
  49283. return this._convertCmykToRgb(data);
  49284. }
  49285. }
  49286. return data;
  49287. }
  49288. };
  49289. return JpegImage;
  49290. }();
  49291. exports.JpegImage = JpegImage;
  49292. /***/ }),
  49293. /* 37 */
  49294. /***/ (function(module, exports, __w_pdfjs_require__) {
  49295. "use strict";
  49296. var sharedUtil = __w_pdfjs_require__(0);
  49297. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  49298. var getMetrics = getLookupTableFactory(function (t) {
  49299. t['Courier'] = 600;
  49300. t['Courier-Bold'] = 600;
  49301. t['Courier-BoldOblique'] = 600;
  49302. t['Courier-Oblique'] = 600;
  49303. t['Helvetica'] = getLookupTableFactory(function (t) {
  49304. t['space'] = 278;
  49305. t['exclam'] = 278;
  49306. t['quotedbl'] = 355;
  49307. t['numbersign'] = 556;
  49308. t['dollar'] = 556;
  49309. t['percent'] = 889;
  49310. t['ampersand'] = 667;
  49311. t['quoteright'] = 222;
  49312. t['parenleft'] = 333;
  49313. t['parenright'] = 333;
  49314. t['asterisk'] = 389;
  49315. t['plus'] = 584;
  49316. t['comma'] = 278;
  49317. t['hyphen'] = 333;
  49318. t['period'] = 278;
  49319. t['slash'] = 278;
  49320. t['zero'] = 556;
  49321. t['one'] = 556;
  49322. t['two'] = 556;
  49323. t['three'] = 556;
  49324. t['four'] = 556;
  49325. t['five'] = 556;
  49326. t['six'] = 556;
  49327. t['seven'] = 556;
  49328. t['eight'] = 556;
  49329. t['nine'] = 556;
  49330. t['colon'] = 278;
  49331. t['semicolon'] = 278;
  49332. t['less'] = 584;
  49333. t['equal'] = 584;
  49334. t['greater'] = 584;
  49335. t['question'] = 556;
  49336. t['at'] = 1015;
  49337. t['A'] = 667;
  49338. t['B'] = 667;
  49339. t['C'] = 722;
  49340. t['D'] = 722;
  49341. t['E'] = 667;
  49342. t['F'] = 611;
  49343. t['G'] = 778;
  49344. t['H'] = 722;
  49345. t['I'] = 278;
  49346. t['J'] = 500;
  49347. t['K'] = 667;
  49348. t['L'] = 556;
  49349. t['M'] = 833;
  49350. t['N'] = 722;
  49351. t['O'] = 778;
  49352. t['P'] = 667;
  49353. t['Q'] = 778;
  49354. t['R'] = 722;
  49355. t['S'] = 667;
  49356. t['T'] = 611;
  49357. t['U'] = 722;
  49358. t['V'] = 667;
  49359. t['W'] = 944;
  49360. t['X'] = 667;
  49361. t['Y'] = 667;
  49362. t['Z'] = 611;
  49363. t['bracketleft'] = 278;
  49364. t['backslash'] = 278;
  49365. t['bracketright'] = 278;
  49366. t['asciicircum'] = 469;
  49367. t['underscore'] = 556;
  49368. t['quoteleft'] = 222;
  49369. t['a'] = 556;
  49370. t['b'] = 556;
  49371. t['c'] = 500;
  49372. t['d'] = 556;
  49373. t['e'] = 556;
  49374. t['f'] = 278;
  49375. t['g'] = 556;
  49376. t['h'] = 556;
  49377. t['i'] = 222;
  49378. t['j'] = 222;
  49379. t['k'] = 500;
  49380. t['l'] = 222;
  49381. t['m'] = 833;
  49382. t['n'] = 556;
  49383. t['o'] = 556;
  49384. t['p'] = 556;
  49385. t['q'] = 556;
  49386. t['r'] = 333;
  49387. t['s'] = 500;
  49388. t['t'] = 278;
  49389. t['u'] = 556;
  49390. t['v'] = 500;
  49391. t['w'] = 722;
  49392. t['x'] = 500;
  49393. t['y'] = 500;
  49394. t['z'] = 500;
  49395. t['braceleft'] = 334;
  49396. t['bar'] = 260;
  49397. t['braceright'] = 334;
  49398. t['asciitilde'] = 584;
  49399. t['exclamdown'] = 333;
  49400. t['cent'] = 556;
  49401. t['sterling'] = 556;
  49402. t['fraction'] = 167;
  49403. t['yen'] = 556;
  49404. t['florin'] = 556;
  49405. t['section'] = 556;
  49406. t['currency'] = 556;
  49407. t['quotesingle'] = 191;
  49408. t['quotedblleft'] = 333;
  49409. t['guillemotleft'] = 556;
  49410. t['guilsinglleft'] = 333;
  49411. t['guilsinglright'] = 333;
  49412. t['fi'] = 500;
  49413. t['fl'] = 500;
  49414. t['endash'] = 556;
  49415. t['dagger'] = 556;
  49416. t['daggerdbl'] = 556;
  49417. t['periodcentered'] = 278;
  49418. t['paragraph'] = 537;
  49419. t['bullet'] = 350;
  49420. t['quotesinglbase'] = 222;
  49421. t['quotedblbase'] = 333;
  49422. t['quotedblright'] = 333;
  49423. t['guillemotright'] = 556;
  49424. t['ellipsis'] = 1000;
  49425. t['perthousand'] = 1000;
  49426. t['questiondown'] = 611;
  49427. t['grave'] = 333;
  49428. t['acute'] = 333;
  49429. t['circumflex'] = 333;
  49430. t['tilde'] = 333;
  49431. t['macron'] = 333;
  49432. t['breve'] = 333;
  49433. t['dotaccent'] = 333;
  49434. t['dieresis'] = 333;
  49435. t['ring'] = 333;
  49436. t['cedilla'] = 333;
  49437. t['hungarumlaut'] = 333;
  49438. t['ogonek'] = 333;
  49439. t['caron'] = 333;
  49440. t['emdash'] = 1000;
  49441. t['AE'] = 1000;
  49442. t['ordfeminine'] = 370;
  49443. t['Lslash'] = 556;
  49444. t['Oslash'] = 778;
  49445. t['OE'] = 1000;
  49446. t['ordmasculine'] = 365;
  49447. t['ae'] = 889;
  49448. t['dotlessi'] = 278;
  49449. t['lslash'] = 222;
  49450. t['oslash'] = 611;
  49451. t['oe'] = 944;
  49452. t['germandbls'] = 611;
  49453. t['Idieresis'] = 278;
  49454. t['eacute'] = 556;
  49455. t['abreve'] = 556;
  49456. t['uhungarumlaut'] = 556;
  49457. t['ecaron'] = 556;
  49458. t['Ydieresis'] = 667;
  49459. t['divide'] = 584;
  49460. t['Yacute'] = 667;
  49461. t['Acircumflex'] = 667;
  49462. t['aacute'] = 556;
  49463. t['Ucircumflex'] = 722;
  49464. t['yacute'] = 500;
  49465. t['scommaaccent'] = 500;
  49466. t['ecircumflex'] = 556;
  49467. t['Uring'] = 722;
  49468. t['Udieresis'] = 722;
  49469. t['aogonek'] = 556;
  49470. t['Uacute'] = 722;
  49471. t['uogonek'] = 556;
  49472. t['Edieresis'] = 667;
  49473. t['Dcroat'] = 722;
  49474. t['commaaccent'] = 250;
  49475. t['copyright'] = 737;
  49476. t['Emacron'] = 667;
  49477. t['ccaron'] = 500;
  49478. t['aring'] = 556;
  49479. t['Ncommaaccent'] = 722;
  49480. t['lacute'] = 222;
  49481. t['agrave'] = 556;
  49482. t['Tcommaaccent'] = 611;
  49483. t['Cacute'] = 722;
  49484. t['atilde'] = 556;
  49485. t['Edotaccent'] = 667;
  49486. t['scaron'] = 500;
  49487. t['scedilla'] = 500;
  49488. t['iacute'] = 278;
  49489. t['lozenge'] = 471;
  49490. t['Rcaron'] = 722;
  49491. t['Gcommaaccent'] = 778;
  49492. t['ucircumflex'] = 556;
  49493. t['acircumflex'] = 556;
  49494. t['Amacron'] = 667;
  49495. t['rcaron'] = 333;
  49496. t['ccedilla'] = 500;
  49497. t['Zdotaccent'] = 611;
  49498. t['Thorn'] = 667;
  49499. t['Omacron'] = 778;
  49500. t['Racute'] = 722;
  49501. t['Sacute'] = 667;
  49502. t['dcaron'] = 643;
  49503. t['Umacron'] = 722;
  49504. t['uring'] = 556;
  49505. t['threesuperior'] = 333;
  49506. t['Ograve'] = 778;
  49507. t['Agrave'] = 667;
  49508. t['Abreve'] = 667;
  49509. t['multiply'] = 584;
  49510. t['uacute'] = 556;
  49511. t['Tcaron'] = 611;
  49512. t['partialdiff'] = 476;
  49513. t['ydieresis'] = 500;
  49514. t['Nacute'] = 722;
  49515. t['icircumflex'] = 278;
  49516. t['Ecircumflex'] = 667;
  49517. t['adieresis'] = 556;
  49518. t['edieresis'] = 556;
  49519. t['cacute'] = 500;
  49520. t['nacute'] = 556;
  49521. t['umacron'] = 556;
  49522. t['Ncaron'] = 722;
  49523. t['Iacute'] = 278;
  49524. t['plusminus'] = 584;
  49525. t['brokenbar'] = 260;
  49526. t['registered'] = 737;
  49527. t['Gbreve'] = 778;
  49528. t['Idotaccent'] = 278;
  49529. t['summation'] = 600;
  49530. t['Egrave'] = 667;
  49531. t['racute'] = 333;
  49532. t['omacron'] = 556;
  49533. t['Zacute'] = 611;
  49534. t['Zcaron'] = 611;
  49535. t['greaterequal'] = 549;
  49536. t['Eth'] = 722;
  49537. t['Ccedilla'] = 722;
  49538. t['lcommaaccent'] = 222;
  49539. t['tcaron'] = 317;
  49540. t['eogonek'] = 556;
  49541. t['Uogonek'] = 722;
  49542. t['Aacute'] = 667;
  49543. t['Adieresis'] = 667;
  49544. t['egrave'] = 556;
  49545. t['zacute'] = 500;
  49546. t['iogonek'] = 222;
  49547. t['Oacute'] = 778;
  49548. t['oacute'] = 556;
  49549. t['amacron'] = 556;
  49550. t['sacute'] = 500;
  49551. t['idieresis'] = 278;
  49552. t['Ocircumflex'] = 778;
  49553. t['Ugrave'] = 722;
  49554. t['Delta'] = 612;
  49555. t['thorn'] = 556;
  49556. t['twosuperior'] = 333;
  49557. t['Odieresis'] = 778;
  49558. t['mu'] = 556;
  49559. t['igrave'] = 278;
  49560. t['ohungarumlaut'] = 556;
  49561. t['Eogonek'] = 667;
  49562. t['dcroat'] = 556;
  49563. t['threequarters'] = 834;
  49564. t['Scedilla'] = 667;
  49565. t['lcaron'] = 299;
  49566. t['Kcommaaccent'] = 667;
  49567. t['Lacute'] = 556;
  49568. t['trademark'] = 1000;
  49569. t['edotaccent'] = 556;
  49570. t['Igrave'] = 278;
  49571. t['Imacron'] = 278;
  49572. t['Lcaron'] = 556;
  49573. t['onehalf'] = 834;
  49574. t['lessequal'] = 549;
  49575. t['ocircumflex'] = 556;
  49576. t['ntilde'] = 556;
  49577. t['Uhungarumlaut'] = 722;
  49578. t['Eacute'] = 667;
  49579. t['emacron'] = 556;
  49580. t['gbreve'] = 556;
  49581. t['onequarter'] = 834;
  49582. t['Scaron'] = 667;
  49583. t['Scommaaccent'] = 667;
  49584. t['Ohungarumlaut'] = 778;
  49585. t['degree'] = 400;
  49586. t['ograve'] = 556;
  49587. t['Ccaron'] = 722;
  49588. t['ugrave'] = 556;
  49589. t['radical'] = 453;
  49590. t['Dcaron'] = 722;
  49591. t['rcommaaccent'] = 333;
  49592. t['Ntilde'] = 722;
  49593. t['otilde'] = 556;
  49594. t['Rcommaaccent'] = 722;
  49595. t['Lcommaaccent'] = 556;
  49596. t['Atilde'] = 667;
  49597. t['Aogonek'] = 667;
  49598. t['Aring'] = 667;
  49599. t['Otilde'] = 778;
  49600. t['zdotaccent'] = 500;
  49601. t['Ecaron'] = 667;
  49602. t['Iogonek'] = 278;
  49603. t['kcommaaccent'] = 500;
  49604. t['minus'] = 584;
  49605. t['Icircumflex'] = 278;
  49606. t['ncaron'] = 556;
  49607. t['tcommaaccent'] = 278;
  49608. t['logicalnot'] = 584;
  49609. t['odieresis'] = 556;
  49610. t['udieresis'] = 556;
  49611. t['notequal'] = 549;
  49612. t['gcommaaccent'] = 556;
  49613. t['eth'] = 556;
  49614. t['zcaron'] = 500;
  49615. t['ncommaaccent'] = 556;
  49616. t['onesuperior'] = 333;
  49617. t['imacron'] = 278;
  49618. t['Euro'] = 556;
  49619. });
  49620. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  49621. t['space'] = 278;
  49622. t['exclam'] = 333;
  49623. t['quotedbl'] = 474;
  49624. t['numbersign'] = 556;
  49625. t['dollar'] = 556;
  49626. t['percent'] = 889;
  49627. t['ampersand'] = 722;
  49628. t['quoteright'] = 278;
  49629. t['parenleft'] = 333;
  49630. t['parenright'] = 333;
  49631. t['asterisk'] = 389;
  49632. t['plus'] = 584;
  49633. t['comma'] = 278;
  49634. t['hyphen'] = 333;
  49635. t['period'] = 278;
  49636. t['slash'] = 278;
  49637. t['zero'] = 556;
  49638. t['one'] = 556;
  49639. t['two'] = 556;
  49640. t['three'] = 556;
  49641. t['four'] = 556;
  49642. t['five'] = 556;
  49643. t['six'] = 556;
  49644. t['seven'] = 556;
  49645. t['eight'] = 556;
  49646. t['nine'] = 556;
  49647. t['colon'] = 333;
  49648. t['semicolon'] = 333;
  49649. t['less'] = 584;
  49650. t['equal'] = 584;
  49651. t['greater'] = 584;
  49652. t['question'] = 611;
  49653. t['at'] = 975;
  49654. t['A'] = 722;
  49655. t['B'] = 722;
  49656. t['C'] = 722;
  49657. t['D'] = 722;
  49658. t['E'] = 667;
  49659. t['F'] = 611;
  49660. t['G'] = 778;
  49661. t['H'] = 722;
  49662. t['I'] = 278;
  49663. t['J'] = 556;
  49664. t['K'] = 722;
  49665. t['L'] = 611;
  49666. t['M'] = 833;
  49667. t['N'] = 722;
  49668. t['O'] = 778;
  49669. t['P'] = 667;
  49670. t['Q'] = 778;
  49671. t['R'] = 722;
  49672. t['S'] = 667;
  49673. t['T'] = 611;
  49674. t['U'] = 722;
  49675. t['V'] = 667;
  49676. t['W'] = 944;
  49677. t['X'] = 667;
  49678. t['Y'] = 667;
  49679. t['Z'] = 611;
  49680. t['bracketleft'] = 333;
  49681. t['backslash'] = 278;
  49682. t['bracketright'] = 333;
  49683. t['asciicircum'] = 584;
  49684. t['underscore'] = 556;
  49685. t['quoteleft'] = 278;
  49686. t['a'] = 556;
  49687. t['b'] = 611;
  49688. t['c'] = 556;
  49689. t['d'] = 611;
  49690. t['e'] = 556;
  49691. t['f'] = 333;
  49692. t['g'] = 611;
  49693. t['h'] = 611;
  49694. t['i'] = 278;
  49695. t['j'] = 278;
  49696. t['k'] = 556;
  49697. t['l'] = 278;
  49698. t['m'] = 889;
  49699. t['n'] = 611;
  49700. t['o'] = 611;
  49701. t['p'] = 611;
  49702. t['q'] = 611;
  49703. t['r'] = 389;
  49704. t['s'] = 556;
  49705. t['t'] = 333;
  49706. t['u'] = 611;
  49707. t['v'] = 556;
  49708. t['w'] = 778;
  49709. t['x'] = 556;
  49710. t['y'] = 556;
  49711. t['z'] = 500;
  49712. t['braceleft'] = 389;
  49713. t['bar'] = 280;
  49714. t['braceright'] = 389;
  49715. t['asciitilde'] = 584;
  49716. t['exclamdown'] = 333;
  49717. t['cent'] = 556;
  49718. t['sterling'] = 556;
  49719. t['fraction'] = 167;
  49720. t['yen'] = 556;
  49721. t['florin'] = 556;
  49722. t['section'] = 556;
  49723. t['currency'] = 556;
  49724. t['quotesingle'] = 238;
  49725. t['quotedblleft'] = 500;
  49726. t['guillemotleft'] = 556;
  49727. t['guilsinglleft'] = 333;
  49728. t['guilsinglright'] = 333;
  49729. t['fi'] = 611;
  49730. t['fl'] = 611;
  49731. t['endash'] = 556;
  49732. t['dagger'] = 556;
  49733. t['daggerdbl'] = 556;
  49734. t['periodcentered'] = 278;
  49735. t['paragraph'] = 556;
  49736. t['bullet'] = 350;
  49737. t['quotesinglbase'] = 278;
  49738. t['quotedblbase'] = 500;
  49739. t['quotedblright'] = 500;
  49740. t['guillemotright'] = 556;
  49741. t['ellipsis'] = 1000;
  49742. t['perthousand'] = 1000;
  49743. t['questiondown'] = 611;
  49744. t['grave'] = 333;
  49745. t['acute'] = 333;
  49746. t['circumflex'] = 333;
  49747. t['tilde'] = 333;
  49748. t['macron'] = 333;
  49749. t['breve'] = 333;
  49750. t['dotaccent'] = 333;
  49751. t['dieresis'] = 333;
  49752. t['ring'] = 333;
  49753. t['cedilla'] = 333;
  49754. t['hungarumlaut'] = 333;
  49755. t['ogonek'] = 333;
  49756. t['caron'] = 333;
  49757. t['emdash'] = 1000;
  49758. t['AE'] = 1000;
  49759. t['ordfeminine'] = 370;
  49760. t['Lslash'] = 611;
  49761. t['Oslash'] = 778;
  49762. t['OE'] = 1000;
  49763. t['ordmasculine'] = 365;
  49764. t['ae'] = 889;
  49765. t['dotlessi'] = 278;
  49766. t['lslash'] = 278;
  49767. t['oslash'] = 611;
  49768. t['oe'] = 944;
  49769. t['germandbls'] = 611;
  49770. t['Idieresis'] = 278;
  49771. t['eacute'] = 556;
  49772. t['abreve'] = 556;
  49773. t['uhungarumlaut'] = 611;
  49774. t['ecaron'] = 556;
  49775. t['Ydieresis'] = 667;
  49776. t['divide'] = 584;
  49777. t['Yacute'] = 667;
  49778. t['Acircumflex'] = 722;
  49779. t['aacute'] = 556;
  49780. t['Ucircumflex'] = 722;
  49781. t['yacute'] = 556;
  49782. t['scommaaccent'] = 556;
  49783. t['ecircumflex'] = 556;
  49784. t['Uring'] = 722;
  49785. t['Udieresis'] = 722;
  49786. t['aogonek'] = 556;
  49787. t['Uacute'] = 722;
  49788. t['uogonek'] = 611;
  49789. t['Edieresis'] = 667;
  49790. t['Dcroat'] = 722;
  49791. t['commaaccent'] = 250;
  49792. t['copyright'] = 737;
  49793. t['Emacron'] = 667;
  49794. t['ccaron'] = 556;
  49795. t['aring'] = 556;
  49796. t['Ncommaaccent'] = 722;
  49797. t['lacute'] = 278;
  49798. t['agrave'] = 556;
  49799. t['Tcommaaccent'] = 611;
  49800. t['Cacute'] = 722;
  49801. t['atilde'] = 556;
  49802. t['Edotaccent'] = 667;
  49803. t['scaron'] = 556;
  49804. t['scedilla'] = 556;
  49805. t['iacute'] = 278;
  49806. t['lozenge'] = 494;
  49807. t['Rcaron'] = 722;
  49808. t['Gcommaaccent'] = 778;
  49809. t['ucircumflex'] = 611;
  49810. t['acircumflex'] = 556;
  49811. t['Amacron'] = 722;
  49812. t['rcaron'] = 389;
  49813. t['ccedilla'] = 556;
  49814. t['Zdotaccent'] = 611;
  49815. t['Thorn'] = 667;
  49816. t['Omacron'] = 778;
  49817. t['Racute'] = 722;
  49818. t['Sacute'] = 667;
  49819. t['dcaron'] = 743;
  49820. t['Umacron'] = 722;
  49821. t['uring'] = 611;
  49822. t['threesuperior'] = 333;
  49823. t['Ograve'] = 778;
  49824. t['Agrave'] = 722;
  49825. t['Abreve'] = 722;
  49826. t['multiply'] = 584;
  49827. t['uacute'] = 611;
  49828. t['Tcaron'] = 611;
  49829. t['partialdiff'] = 494;
  49830. t['ydieresis'] = 556;
  49831. t['Nacute'] = 722;
  49832. t['icircumflex'] = 278;
  49833. t['Ecircumflex'] = 667;
  49834. t['adieresis'] = 556;
  49835. t['edieresis'] = 556;
  49836. t['cacute'] = 556;
  49837. t['nacute'] = 611;
  49838. t['umacron'] = 611;
  49839. t['Ncaron'] = 722;
  49840. t['Iacute'] = 278;
  49841. t['plusminus'] = 584;
  49842. t['brokenbar'] = 280;
  49843. t['registered'] = 737;
  49844. t['Gbreve'] = 778;
  49845. t['Idotaccent'] = 278;
  49846. t['summation'] = 600;
  49847. t['Egrave'] = 667;
  49848. t['racute'] = 389;
  49849. t['omacron'] = 611;
  49850. t['Zacute'] = 611;
  49851. t['Zcaron'] = 611;
  49852. t['greaterequal'] = 549;
  49853. t['Eth'] = 722;
  49854. t['Ccedilla'] = 722;
  49855. t['lcommaaccent'] = 278;
  49856. t['tcaron'] = 389;
  49857. t['eogonek'] = 556;
  49858. t['Uogonek'] = 722;
  49859. t['Aacute'] = 722;
  49860. t['Adieresis'] = 722;
  49861. t['egrave'] = 556;
  49862. t['zacute'] = 500;
  49863. t['iogonek'] = 278;
  49864. t['Oacute'] = 778;
  49865. t['oacute'] = 611;
  49866. t['amacron'] = 556;
  49867. t['sacute'] = 556;
  49868. t['idieresis'] = 278;
  49869. t['Ocircumflex'] = 778;
  49870. t['Ugrave'] = 722;
  49871. t['Delta'] = 612;
  49872. t['thorn'] = 611;
  49873. t['twosuperior'] = 333;
  49874. t['Odieresis'] = 778;
  49875. t['mu'] = 611;
  49876. t['igrave'] = 278;
  49877. t['ohungarumlaut'] = 611;
  49878. t['Eogonek'] = 667;
  49879. t['dcroat'] = 611;
  49880. t['threequarters'] = 834;
  49881. t['Scedilla'] = 667;
  49882. t['lcaron'] = 400;
  49883. t['Kcommaaccent'] = 722;
  49884. t['Lacute'] = 611;
  49885. t['trademark'] = 1000;
  49886. t['edotaccent'] = 556;
  49887. t['Igrave'] = 278;
  49888. t['Imacron'] = 278;
  49889. t['Lcaron'] = 611;
  49890. t['onehalf'] = 834;
  49891. t['lessequal'] = 549;
  49892. t['ocircumflex'] = 611;
  49893. t['ntilde'] = 611;
  49894. t['Uhungarumlaut'] = 722;
  49895. t['Eacute'] = 667;
  49896. t['emacron'] = 556;
  49897. t['gbreve'] = 611;
  49898. t['onequarter'] = 834;
  49899. t['Scaron'] = 667;
  49900. t['Scommaaccent'] = 667;
  49901. t['Ohungarumlaut'] = 778;
  49902. t['degree'] = 400;
  49903. t['ograve'] = 611;
  49904. t['Ccaron'] = 722;
  49905. t['ugrave'] = 611;
  49906. t['radical'] = 549;
  49907. t['Dcaron'] = 722;
  49908. t['rcommaaccent'] = 389;
  49909. t['Ntilde'] = 722;
  49910. t['otilde'] = 611;
  49911. t['Rcommaaccent'] = 722;
  49912. t['Lcommaaccent'] = 611;
  49913. t['Atilde'] = 722;
  49914. t['Aogonek'] = 722;
  49915. t['Aring'] = 722;
  49916. t['Otilde'] = 778;
  49917. t['zdotaccent'] = 500;
  49918. t['Ecaron'] = 667;
  49919. t['Iogonek'] = 278;
  49920. t['kcommaaccent'] = 556;
  49921. t['minus'] = 584;
  49922. t['Icircumflex'] = 278;
  49923. t['ncaron'] = 611;
  49924. t['tcommaaccent'] = 333;
  49925. t['logicalnot'] = 584;
  49926. t['odieresis'] = 611;
  49927. t['udieresis'] = 611;
  49928. t['notequal'] = 549;
  49929. t['gcommaaccent'] = 611;
  49930. t['eth'] = 611;
  49931. t['zcaron'] = 500;
  49932. t['ncommaaccent'] = 611;
  49933. t['onesuperior'] = 333;
  49934. t['imacron'] = 278;
  49935. t['Euro'] = 556;
  49936. });
  49937. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  49938. t['space'] = 278;
  49939. t['exclam'] = 333;
  49940. t['quotedbl'] = 474;
  49941. t['numbersign'] = 556;
  49942. t['dollar'] = 556;
  49943. t['percent'] = 889;
  49944. t['ampersand'] = 722;
  49945. t['quoteright'] = 278;
  49946. t['parenleft'] = 333;
  49947. t['parenright'] = 333;
  49948. t['asterisk'] = 389;
  49949. t['plus'] = 584;
  49950. t['comma'] = 278;
  49951. t['hyphen'] = 333;
  49952. t['period'] = 278;
  49953. t['slash'] = 278;
  49954. t['zero'] = 556;
  49955. t['one'] = 556;
  49956. t['two'] = 556;
  49957. t['three'] = 556;
  49958. t['four'] = 556;
  49959. t['five'] = 556;
  49960. t['six'] = 556;
  49961. t['seven'] = 556;
  49962. t['eight'] = 556;
  49963. t['nine'] = 556;
  49964. t['colon'] = 333;
  49965. t['semicolon'] = 333;
  49966. t['less'] = 584;
  49967. t['equal'] = 584;
  49968. t['greater'] = 584;
  49969. t['question'] = 611;
  49970. t['at'] = 975;
  49971. t['A'] = 722;
  49972. t['B'] = 722;
  49973. t['C'] = 722;
  49974. t['D'] = 722;
  49975. t['E'] = 667;
  49976. t['F'] = 611;
  49977. t['G'] = 778;
  49978. t['H'] = 722;
  49979. t['I'] = 278;
  49980. t['J'] = 556;
  49981. t['K'] = 722;
  49982. t['L'] = 611;
  49983. t['M'] = 833;
  49984. t['N'] = 722;
  49985. t['O'] = 778;
  49986. t['P'] = 667;
  49987. t['Q'] = 778;
  49988. t['R'] = 722;
  49989. t['S'] = 667;
  49990. t['T'] = 611;
  49991. t['U'] = 722;
  49992. t['V'] = 667;
  49993. t['W'] = 944;
  49994. t['X'] = 667;
  49995. t['Y'] = 667;
  49996. t['Z'] = 611;
  49997. t['bracketleft'] = 333;
  49998. t['backslash'] = 278;
  49999. t['bracketright'] = 333;
  50000. t['asciicircum'] = 584;
  50001. t['underscore'] = 556;
  50002. t['quoteleft'] = 278;
  50003. t['a'] = 556;
  50004. t['b'] = 611;
  50005. t['c'] = 556;
  50006. t['d'] = 611;
  50007. t['e'] = 556;
  50008. t['f'] = 333;
  50009. t['g'] = 611;
  50010. t['h'] = 611;
  50011. t['i'] = 278;
  50012. t['j'] = 278;
  50013. t['k'] = 556;
  50014. t['l'] = 278;
  50015. t['m'] = 889;
  50016. t['n'] = 611;
  50017. t['o'] = 611;
  50018. t['p'] = 611;
  50019. t['q'] = 611;
  50020. t['r'] = 389;
  50021. t['s'] = 556;
  50022. t['t'] = 333;
  50023. t['u'] = 611;
  50024. t['v'] = 556;
  50025. t['w'] = 778;
  50026. t['x'] = 556;
  50027. t['y'] = 556;
  50028. t['z'] = 500;
  50029. t['braceleft'] = 389;
  50030. t['bar'] = 280;
  50031. t['braceright'] = 389;
  50032. t['asciitilde'] = 584;
  50033. t['exclamdown'] = 333;
  50034. t['cent'] = 556;
  50035. t['sterling'] = 556;
  50036. t['fraction'] = 167;
  50037. t['yen'] = 556;
  50038. t['florin'] = 556;
  50039. t['section'] = 556;
  50040. t['currency'] = 556;
  50041. t['quotesingle'] = 238;
  50042. t['quotedblleft'] = 500;
  50043. t['guillemotleft'] = 556;
  50044. t['guilsinglleft'] = 333;
  50045. t['guilsinglright'] = 333;
  50046. t['fi'] = 611;
  50047. t['fl'] = 611;
  50048. t['endash'] = 556;
  50049. t['dagger'] = 556;
  50050. t['daggerdbl'] = 556;
  50051. t['periodcentered'] = 278;
  50052. t['paragraph'] = 556;
  50053. t['bullet'] = 350;
  50054. t['quotesinglbase'] = 278;
  50055. t['quotedblbase'] = 500;
  50056. t['quotedblright'] = 500;
  50057. t['guillemotright'] = 556;
  50058. t['ellipsis'] = 1000;
  50059. t['perthousand'] = 1000;
  50060. t['questiondown'] = 611;
  50061. t['grave'] = 333;
  50062. t['acute'] = 333;
  50063. t['circumflex'] = 333;
  50064. t['tilde'] = 333;
  50065. t['macron'] = 333;
  50066. t['breve'] = 333;
  50067. t['dotaccent'] = 333;
  50068. t['dieresis'] = 333;
  50069. t['ring'] = 333;
  50070. t['cedilla'] = 333;
  50071. t['hungarumlaut'] = 333;
  50072. t['ogonek'] = 333;
  50073. t['caron'] = 333;
  50074. t['emdash'] = 1000;
  50075. t['AE'] = 1000;
  50076. t['ordfeminine'] = 370;
  50077. t['Lslash'] = 611;
  50078. t['Oslash'] = 778;
  50079. t['OE'] = 1000;
  50080. t['ordmasculine'] = 365;
  50081. t['ae'] = 889;
  50082. t['dotlessi'] = 278;
  50083. t['lslash'] = 278;
  50084. t['oslash'] = 611;
  50085. t['oe'] = 944;
  50086. t['germandbls'] = 611;
  50087. t['Idieresis'] = 278;
  50088. t['eacute'] = 556;
  50089. t['abreve'] = 556;
  50090. t['uhungarumlaut'] = 611;
  50091. t['ecaron'] = 556;
  50092. t['Ydieresis'] = 667;
  50093. t['divide'] = 584;
  50094. t['Yacute'] = 667;
  50095. t['Acircumflex'] = 722;
  50096. t['aacute'] = 556;
  50097. t['Ucircumflex'] = 722;
  50098. t['yacute'] = 556;
  50099. t['scommaaccent'] = 556;
  50100. t['ecircumflex'] = 556;
  50101. t['Uring'] = 722;
  50102. t['Udieresis'] = 722;
  50103. t['aogonek'] = 556;
  50104. t['Uacute'] = 722;
  50105. t['uogonek'] = 611;
  50106. t['Edieresis'] = 667;
  50107. t['Dcroat'] = 722;
  50108. t['commaaccent'] = 250;
  50109. t['copyright'] = 737;
  50110. t['Emacron'] = 667;
  50111. t['ccaron'] = 556;
  50112. t['aring'] = 556;
  50113. t['Ncommaaccent'] = 722;
  50114. t['lacute'] = 278;
  50115. t['agrave'] = 556;
  50116. t['Tcommaaccent'] = 611;
  50117. t['Cacute'] = 722;
  50118. t['atilde'] = 556;
  50119. t['Edotaccent'] = 667;
  50120. t['scaron'] = 556;
  50121. t['scedilla'] = 556;
  50122. t['iacute'] = 278;
  50123. t['lozenge'] = 494;
  50124. t['Rcaron'] = 722;
  50125. t['Gcommaaccent'] = 778;
  50126. t['ucircumflex'] = 611;
  50127. t['acircumflex'] = 556;
  50128. t['Amacron'] = 722;
  50129. t['rcaron'] = 389;
  50130. t['ccedilla'] = 556;
  50131. t['Zdotaccent'] = 611;
  50132. t['Thorn'] = 667;
  50133. t['Omacron'] = 778;
  50134. t['Racute'] = 722;
  50135. t['Sacute'] = 667;
  50136. t['dcaron'] = 743;
  50137. t['Umacron'] = 722;
  50138. t['uring'] = 611;
  50139. t['threesuperior'] = 333;
  50140. t['Ograve'] = 778;
  50141. t['Agrave'] = 722;
  50142. t['Abreve'] = 722;
  50143. t['multiply'] = 584;
  50144. t['uacute'] = 611;
  50145. t['Tcaron'] = 611;
  50146. t['partialdiff'] = 494;
  50147. t['ydieresis'] = 556;
  50148. t['Nacute'] = 722;
  50149. t['icircumflex'] = 278;
  50150. t['Ecircumflex'] = 667;
  50151. t['adieresis'] = 556;
  50152. t['edieresis'] = 556;
  50153. t['cacute'] = 556;
  50154. t['nacute'] = 611;
  50155. t['umacron'] = 611;
  50156. t['Ncaron'] = 722;
  50157. t['Iacute'] = 278;
  50158. t['plusminus'] = 584;
  50159. t['brokenbar'] = 280;
  50160. t['registered'] = 737;
  50161. t['Gbreve'] = 778;
  50162. t['Idotaccent'] = 278;
  50163. t['summation'] = 600;
  50164. t['Egrave'] = 667;
  50165. t['racute'] = 389;
  50166. t['omacron'] = 611;
  50167. t['Zacute'] = 611;
  50168. t['Zcaron'] = 611;
  50169. t['greaterequal'] = 549;
  50170. t['Eth'] = 722;
  50171. t['Ccedilla'] = 722;
  50172. t['lcommaaccent'] = 278;
  50173. t['tcaron'] = 389;
  50174. t['eogonek'] = 556;
  50175. t['Uogonek'] = 722;
  50176. t['Aacute'] = 722;
  50177. t['Adieresis'] = 722;
  50178. t['egrave'] = 556;
  50179. t['zacute'] = 500;
  50180. t['iogonek'] = 278;
  50181. t['Oacute'] = 778;
  50182. t['oacute'] = 611;
  50183. t['amacron'] = 556;
  50184. t['sacute'] = 556;
  50185. t['idieresis'] = 278;
  50186. t['Ocircumflex'] = 778;
  50187. t['Ugrave'] = 722;
  50188. t['Delta'] = 612;
  50189. t['thorn'] = 611;
  50190. t['twosuperior'] = 333;
  50191. t['Odieresis'] = 778;
  50192. t['mu'] = 611;
  50193. t['igrave'] = 278;
  50194. t['ohungarumlaut'] = 611;
  50195. t['Eogonek'] = 667;
  50196. t['dcroat'] = 611;
  50197. t['threequarters'] = 834;
  50198. t['Scedilla'] = 667;
  50199. t['lcaron'] = 400;
  50200. t['Kcommaaccent'] = 722;
  50201. t['Lacute'] = 611;
  50202. t['trademark'] = 1000;
  50203. t['edotaccent'] = 556;
  50204. t['Igrave'] = 278;
  50205. t['Imacron'] = 278;
  50206. t['Lcaron'] = 611;
  50207. t['onehalf'] = 834;
  50208. t['lessequal'] = 549;
  50209. t['ocircumflex'] = 611;
  50210. t['ntilde'] = 611;
  50211. t['Uhungarumlaut'] = 722;
  50212. t['Eacute'] = 667;
  50213. t['emacron'] = 556;
  50214. t['gbreve'] = 611;
  50215. t['onequarter'] = 834;
  50216. t['Scaron'] = 667;
  50217. t['Scommaaccent'] = 667;
  50218. t['Ohungarumlaut'] = 778;
  50219. t['degree'] = 400;
  50220. t['ograve'] = 611;
  50221. t['Ccaron'] = 722;
  50222. t['ugrave'] = 611;
  50223. t['radical'] = 549;
  50224. t['Dcaron'] = 722;
  50225. t['rcommaaccent'] = 389;
  50226. t['Ntilde'] = 722;
  50227. t['otilde'] = 611;
  50228. t['Rcommaaccent'] = 722;
  50229. t['Lcommaaccent'] = 611;
  50230. t['Atilde'] = 722;
  50231. t['Aogonek'] = 722;
  50232. t['Aring'] = 722;
  50233. t['Otilde'] = 778;
  50234. t['zdotaccent'] = 500;
  50235. t['Ecaron'] = 667;
  50236. t['Iogonek'] = 278;
  50237. t['kcommaaccent'] = 556;
  50238. t['minus'] = 584;
  50239. t['Icircumflex'] = 278;
  50240. t['ncaron'] = 611;
  50241. t['tcommaaccent'] = 333;
  50242. t['logicalnot'] = 584;
  50243. t['odieresis'] = 611;
  50244. t['udieresis'] = 611;
  50245. t['notequal'] = 549;
  50246. t['gcommaaccent'] = 611;
  50247. t['eth'] = 611;
  50248. t['zcaron'] = 500;
  50249. t['ncommaaccent'] = 611;
  50250. t['onesuperior'] = 333;
  50251. t['imacron'] = 278;
  50252. t['Euro'] = 556;
  50253. });
  50254. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  50255. t['space'] = 278;
  50256. t['exclam'] = 278;
  50257. t['quotedbl'] = 355;
  50258. t['numbersign'] = 556;
  50259. t['dollar'] = 556;
  50260. t['percent'] = 889;
  50261. t['ampersand'] = 667;
  50262. t['quoteright'] = 222;
  50263. t['parenleft'] = 333;
  50264. t['parenright'] = 333;
  50265. t['asterisk'] = 389;
  50266. t['plus'] = 584;
  50267. t['comma'] = 278;
  50268. t['hyphen'] = 333;
  50269. t['period'] = 278;
  50270. t['slash'] = 278;
  50271. t['zero'] = 556;
  50272. t['one'] = 556;
  50273. t['two'] = 556;
  50274. t['three'] = 556;
  50275. t['four'] = 556;
  50276. t['five'] = 556;
  50277. t['six'] = 556;
  50278. t['seven'] = 556;
  50279. t['eight'] = 556;
  50280. t['nine'] = 556;
  50281. t['colon'] = 278;
  50282. t['semicolon'] = 278;
  50283. t['less'] = 584;
  50284. t['equal'] = 584;
  50285. t['greater'] = 584;
  50286. t['question'] = 556;
  50287. t['at'] = 1015;
  50288. t['A'] = 667;
  50289. t['B'] = 667;
  50290. t['C'] = 722;
  50291. t['D'] = 722;
  50292. t['E'] = 667;
  50293. t['F'] = 611;
  50294. t['G'] = 778;
  50295. t['H'] = 722;
  50296. t['I'] = 278;
  50297. t['J'] = 500;
  50298. t['K'] = 667;
  50299. t['L'] = 556;
  50300. t['M'] = 833;
  50301. t['N'] = 722;
  50302. t['O'] = 778;
  50303. t['P'] = 667;
  50304. t['Q'] = 778;
  50305. t['R'] = 722;
  50306. t['S'] = 667;
  50307. t['T'] = 611;
  50308. t['U'] = 722;
  50309. t['V'] = 667;
  50310. t['W'] = 944;
  50311. t['X'] = 667;
  50312. t['Y'] = 667;
  50313. t['Z'] = 611;
  50314. t['bracketleft'] = 278;
  50315. t['backslash'] = 278;
  50316. t['bracketright'] = 278;
  50317. t['asciicircum'] = 469;
  50318. t['underscore'] = 556;
  50319. t['quoteleft'] = 222;
  50320. t['a'] = 556;
  50321. t['b'] = 556;
  50322. t['c'] = 500;
  50323. t['d'] = 556;
  50324. t['e'] = 556;
  50325. t['f'] = 278;
  50326. t['g'] = 556;
  50327. t['h'] = 556;
  50328. t['i'] = 222;
  50329. t['j'] = 222;
  50330. t['k'] = 500;
  50331. t['l'] = 222;
  50332. t['m'] = 833;
  50333. t['n'] = 556;
  50334. t['o'] = 556;
  50335. t['p'] = 556;
  50336. t['q'] = 556;
  50337. t['r'] = 333;
  50338. t['s'] = 500;
  50339. t['t'] = 278;
  50340. t['u'] = 556;
  50341. t['v'] = 500;
  50342. t['w'] = 722;
  50343. t['x'] = 500;
  50344. t['y'] = 500;
  50345. t['z'] = 500;
  50346. t['braceleft'] = 334;
  50347. t['bar'] = 260;
  50348. t['braceright'] = 334;
  50349. t['asciitilde'] = 584;
  50350. t['exclamdown'] = 333;
  50351. t['cent'] = 556;
  50352. t['sterling'] = 556;
  50353. t['fraction'] = 167;
  50354. t['yen'] = 556;
  50355. t['florin'] = 556;
  50356. t['section'] = 556;
  50357. t['currency'] = 556;
  50358. t['quotesingle'] = 191;
  50359. t['quotedblleft'] = 333;
  50360. t['guillemotleft'] = 556;
  50361. t['guilsinglleft'] = 333;
  50362. t['guilsinglright'] = 333;
  50363. t['fi'] = 500;
  50364. t['fl'] = 500;
  50365. t['endash'] = 556;
  50366. t['dagger'] = 556;
  50367. t['daggerdbl'] = 556;
  50368. t['periodcentered'] = 278;
  50369. t['paragraph'] = 537;
  50370. t['bullet'] = 350;
  50371. t['quotesinglbase'] = 222;
  50372. t['quotedblbase'] = 333;
  50373. t['quotedblright'] = 333;
  50374. t['guillemotright'] = 556;
  50375. t['ellipsis'] = 1000;
  50376. t['perthousand'] = 1000;
  50377. t['questiondown'] = 611;
  50378. t['grave'] = 333;
  50379. t['acute'] = 333;
  50380. t['circumflex'] = 333;
  50381. t['tilde'] = 333;
  50382. t['macron'] = 333;
  50383. t['breve'] = 333;
  50384. t['dotaccent'] = 333;
  50385. t['dieresis'] = 333;
  50386. t['ring'] = 333;
  50387. t['cedilla'] = 333;
  50388. t['hungarumlaut'] = 333;
  50389. t['ogonek'] = 333;
  50390. t['caron'] = 333;
  50391. t['emdash'] = 1000;
  50392. t['AE'] = 1000;
  50393. t['ordfeminine'] = 370;
  50394. t['Lslash'] = 556;
  50395. t['Oslash'] = 778;
  50396. t['OE'] = 1000;
  50397. t['ordmasculine'] = 365;
  50398. t['ae'] = 889;
  50399. t['dotlessi'] = 278;
  50400. t['lslash'] = 222;
  50401. t['oslash'] = 611;
  50402. t['oe'] = 944;
  50403. t['germandbls'] = 611;
  50404. t['Idieresis'] = 278;
  50405. t['eacute'] = 556;
  50406. t['abreve'] = 556;
  50407. t['uhungarumlaut'] = 556;
  50408. t['ecaron'] = 556;
  50409. t['Ydieresis'] = 667;
  50410. t['divide'] = 584;
  50411. t['Yacute'] = 667;
  50412. t['Acircumflex'] = 667;
  50413. t['aacute'] = 556;
  50414. t['Ucircumflex'] = 722;
  50415. t['yacute'] = 500;
  50416. t['scommaaccent'] = 500;
  50417. t['ecircumflex'] = 556;
  50418. t['Uring'] = 722;
  50419. t['Udieresis'] = 722;
  50420. t['aogonek'] = 556;
  50421. t['Uacute'] = 722;
  50422. t['uogonek'] = 556;
  50423. t['Edieresis'] = 667;
  50424. t['Dcroat'] = 722;
  50425. t['commaaccent'] = 250;
  50426. t['copyright'] = 737;
  50427. t['Emacron'] = 667;
  50428. t['ccaron'] = 500;
  50429. t['aring'] = 556;
  50430. t['Ncommaaccent'] = 722;
  50431. t['lacute'] = 222;
  50432. t['agrave'] = 556;
  50433. t['Tcommaaccent'] = 611;
  50434. t['Cacute'] = 722;
  50435. t['atilde'] = 556;
  50436. t['Edotaccent'] = 667;
  50437. t['scaron'] = 500;
  50438. t['scedilla'] = 500;
  50439. t['iacute'] = 278;
  50440. t['lozenge'] = 471;
  50441. t['Rcaron'] = 722;
  50442. t['Gcommaaccent'] = 778;
  50443. t['ucircumflex'] = 556;
  50444. t['acircumflex'] = 556;
  50445. t['Amacron'] = 667;
  50446. t['rcaron'] = 333;
  50447. t['ccedilla'] = 500;
  50448. t['Zdotaccent'] = 611;
  50449. t['Thorn'] = 667;
  50450. t['Omacron'] = 778;
  50451. t['Racute'] = 722;
  50452. t['Sacute'] = 667;
  50453. t['dcaron'] = 643;
  50454. t['Umacron'] = 722;
  50455. t['uring'] = 556;
  50456. t['threesuperior'] = 333;
  50457. t['Ograve'] = 778;
  50458. t['Agrave'] = 667;
  50459. t['Abreve'] = 667;
  50460. t['multiply'] = 584;
  50461. t['uacute'] = 556;
  50462. t['Tcaron'] = 611;
  50463. t['partialdiff'] = 476;
  50464. t['ydieresis'] = 500;
  50465. t['Nacute'] = 722;
  50466. t['icircumflex'] = 278;
  50467. t['Ecircumflex'] = 667;
  50468. t['adieresis'] = 556;
  50469. t['edieresis'] = 556;
  50470. t['cacute'] = 500;
  50471. t['nacute'] = 556;
  50472. t['umacron'] = 556;
  50473. t['Ncaron'] = 722;
  50474. t['Iacute'] = 278;
  50475. t['plusminus'] = 584;
  50476. t['brokenbar'] = 260;
  50477. t['registered'] = 737;
  50478. t['Gbreve'] = 778;
  50479. t['Idotaccent'] = 278;
  50480. t['summation'] = 600;
  50481. t['Egrave'] = 667;
  50482. t['racute'] = 333;
  50483. t['omacron'] = 556;
  50484. t['Zacute'] = 611;
  50485. t['Zcaron'] = 611;
  50486. t['greaterequal'] = 549;
  50487. t['Eth'] = 722;
  50488. t['Ccedilla'] = 722;
  50489. t['lcommaaccent'] = 222;
  50490. t['tcaron'] = 317;
  50491. t['eogonek'] = 556;
  50492. t['Uogonek'] = 722;
  50493. t['Aacute'] = 667;
  50494. t['Adieresis'] = 667;
  50495. t['egrave'] = 556;
  50496. t['zacute'] = 500;
  50497. t['iogonek'] = 222;
  50498. t['Oacute'] = 778;
  50499. t['oacute'] = 556;
  50500. t['amacron'] = 556;
  50501. t['sacute'] = 500;
  50502. t['idieresis'] = 278;
  50503. t['Ocircumflex'] = 778;
  50504. t['Ugrave'] = 722;
  50505. t['Delta'] = 612;
  50506. t['thorn'] = 556;
  50507. t['twosuperior'] = 333;
  50508. t['Odieresis'] = 778;
  50509. t['mu'] = 556;
  50510. t['igrave'] = 278;
  50511. t['ohungarumlaut'] = 556;
  50512. t['Eogonek'] = 667;
  50513. t['dcroat'] = 556;
  50514. t['threequarters'] = 834;
  50515. t['Scedilla'] = 667;
  50516. t['lcaron'] = 299;
  50517. t['Kcommaaccent'] = 667;
  50518. t['Lacute'] = 556;
  50519. t['trademark'] = 1000;
  50520. t['edotaccent'] = 556;
  50521. t['Igrave'] = 278;
  50522. t['Imacron'] = 278;
  50523. t['Lcaron'] = 556;
  50524. t['onehalf'] = 834;
  50525. t['lessequal'] = 549;
  50526. t['ocircumflex'] = 556;
  50527. t['ntilde'] = 556;
  50528. t['Uhungarumlaut'] = 722;
  50529. t['Eacute'] = 667;
  50530. t['emacron'] = 556;
  50531. t['gbreve'] = 556;
  50532. t['onequarter'] = 834;
  50533. t['Scaron'] = 667;
  50534. t['Scommaaccent'] = 667;
  50535. t['Ohungarumlaut'] = 778;
  50536. t['degree'] = 400;
  50537. t['ograve'] = 556;
  50538. t['Ccaron'] = 722;
  50539. t['ugrave'] = 556;
  50540. t['radical'] = 453;
  50541. t['Dcaron'] = 722;
  50542. t['rcommaaccent'] = 333;
  50543. t['Ntilde'] = 722;
  50544. t['otilde'] = 556;
  50545. t['Rcommaaccent'] = 722;
  50546. t['Lcommaaccent'] = 556;
  50547. t['Atilde'] = 667;
  50548. t['Aogonek'] = 667;
  50549. t['Aring'] = 667;
  50550. t['Otilde'] = 778;
  50551. t['zdotaccent'] = 500;
  50552. t['Ecaron'] = 667;
  50553. t['Iogonek'] = 278;
  50554. t['kcommaaccent'] = 500;
  50555. t['minus'] = 584;
  50556. t['Icircumflex'] = 278;
  50557. t['ncaron'] = 556;
  50558. t['tcommaaccent'] = 278;
  50559. t['logicalnot'] = 584;
  50560. t['odieresis'] = 556;
  50561. t['udieresis'] = 556;
  50562. t['notequal'] = 549;
  50563. t['gcommaaccent'] = 556;
  50564. t['eth'] = 556;
  50565. t['zcaron'] = 500;
  50566. t['ncommaaccent'] = 556;
  50567. t['onesuperior'] = 333;
  50568. t['imacron'] = 278;
  50569. t['Euro'] = 556;
  50570. });
  50571. t['Symbol'] = getLookupTableFactory(function (t) {
  50572. t['space'] = 250;
  50573. t['exclam'] = 333;
  50574. t['universal'] = 713;
  50575. t['numbersign'] = 500;
  50576. t['existential'] = 549;
  50577. t['percent'] = 833;
  50578. t['ampersand'] = 778;
  50579. t['suchthat'] = 439;
  50580. t['parenleft'] = 333;
  50581. t['parenright'] = 333;
  50582. t['asteriskmath'] = 500;
  50583. t['plus'] = 549;
  50584. t['comma'] = 250;
  50585. t['minus'] = 549;
  50586. t['period'] = 250;
  50587. t['slash'] = 278;
  50588. t['zero'] = 500;
  50589. t['one'] = 500;
  50590. t['two'] = 500;
  50591. t['three'] = 500;
  50592. t['four'] = 500;
  50593. t['five'] = 500;
  50594. t['six'] = 500;
  50595. t['seven'] = 500;
  50596. t['eight'] = 500;
  50597. t['nine'] = 500;
  50598. t['colon'] = 278;
  50599. t['semicolon'] = 278;
  50600. t['less'] = 549;
  50601. t['equal'] = 549;
  50602. t['greater'] = 549;
  50603. t['question'] = 444;
  50604. t['congruent'] = 549;
  50605. t['Alpha'] = 722;
  50606. t['Beta'] = 667;
  50607. t['Chi'] = 722;
  50608. t['Delta'] = 612;
  50609. t['Epsilon'] = 611;
  50610. t['Phi'] = 763;
  50611. t['Gamma'] = 603;
  50612. t['Eta'] = 722;
  50613. t['Iota'] = 333;
  50614. t['theta1'] = 631;
  50615. t['Kappa'] = 722;
  50616. t['Lambda'] = 686;
  50617. t['Mu'] = 889;
  50618. t['Nu'] = 722;
  50619. t['Omicron'] = 722;
  50620. t['Pi'] = 768;
  50621. t['Theta'] = 741;
  50622. t['Rho'] = 556;
  50623. t['Sigma'] = 592;
  50624. t['Tau'] = 611;
  50625. t['Upsilon'] = 690;
  50626. t['sigma1'] = 439;
  50627. t['Omega'] = 768;
  50628. t['Xi'] = 645;
  50629. t['Psi'] = 795;
  50630. t['Zeta'] = 611;
  50631. t['bracketleft'] = 333;
  50632. t['therefore'] = 863;
  50633. t['bracketright'] = 333;
  50634. t['perpendicular'] = 658;
  50635. t['underscore'] = 500;
  50636. t['radicalex'] = 500;
  50637. t['alpha'] = 631;
  50638. t['beta'] = 549;
  50639. t['chi'] = 549;
  50640. t['delta'] = 494;
  50641. t['epsilon'] = 439;
  50642. t['phi'] = 521;
  50643. t['gamma'] = 411;
  50644. t['eta'] = 603;
  50645. t['iota'] = 329;
  50646. t['phi1'] = 603;
  50647. t['kappa'] = 549;
  50648. t['lambda'] = 549;
  50649. t['mu'] = 576;
  50650. t['nu'] = 521;
  50651. t['omicron'] = 549;
  50652. t['pi'] = 549;
  50653. t['theta'] = 521;
  50654. t['rho'] = 549;
  50655. t['sigma'] = 603;
  50656. t['tau'] = 439;
  50657. t['upsilon'] = 576;
  50658. t['omega1'] = 713;
  50659. t['omega'] = 686;
  50660. t['xi'] = 493;
  50661. t['psi'] = 686;
  50662. t['zeta'] = 494;
  50663. t['braceleft'] = 480;
  50664. t['bar'] = 200;
  50665. t['braceright'] = 480;
  50666. t['similar'] = 549;
  50667. t['Euro'] = 750;
  50668. t['Upsilon1'] = 620;
  50669. t['minute'] = 247;
  50670. t['lessequal'] = 549;
  50671. t['fraction'] = 167;
  50672. t['infinity'] = 713;
  50673. t['florin'] = 500;
  50674. t['club'] = 753;
  50675. t['diamond'] = 753;
  50676. t['heart'] = 753;
  50677. t['spade'] = 753;
  50678. t['arrowboth'] = 1042;
  50679. t['arrowleft'] = 987;
  50680. t['arrowup'] = 603;
  50681. t['arrowright'] = 987;
  50682. t['arrowdown'] = 603;
  50683. t['degree'] = 400;
  50684. t['plusminus'] = 549;
  50685. t['second'] = 411;
  50686. t['greaterequal'] = 549;
  50687. t['multiply'] = 549;
  50688. t['proportional'] = 713;
  50689. t['partialdiff'] = 494;
  50690. t['bullet'] = 460;
  50691. t['divide'] = 549;
  50692. t['notequal'] = 549;
  50693. t['equivalence'] = 549;
  50694. t['approxequal'] = 549;
  50695. t['ellipsis'] = 1000;
  50696. t['arrowvertex'] = 603;
  50697. t['arrowhorizex'] = 1000;
  50698. t['carriagereturn'] = 658;
  50699. t['aleph'] = 823;
  50700. t['Ifraktur'] = 686;
  50701. t['Rfraktur'] = 795;
  50702. t['weierstrass'] = 987;
  50703. t['circlemultiply'] = 768;
  50704. t['circleplus'] = 768;
  50705. t['emptyset'] = 823;
  50706. t['intersection'] = 768;
  50707. t['union'] = 768;
  50708. t['propersuperset'] = 713;
  50709. t['reflexsuperset'] = 713;
  50710. t['notsubset'] = 713;
  50711. t['propersubset'] = 713;
  50712. t['reflexsubset'] = 713;
  50713. t['element'] = 713;
  50714. t['notelement'] = 713;
  50715. t['angle'] = 768;
  50716. t['gradient'] = 713;
  50717. t['registerserif'] = 790;
  50718. t['copyrightserif'] = 790;
  50719. t['trademarkserif'] = 890;
  50720. t['product'] = 823;
  50721. t['radical'] = 549;
  50722. t['dotmath'] = 250;
  50723. t['logicalnot'] = 713;
  50724. t['logicaland'] = 603;
  50725. t['logicalor'] = 603;
  50726. t['arrowdblboth'] = 1042;
  50727. t['arrowdblleft'] = 987;
  50728. t['arrowdblup'] = 603;
  50729. t['arrowdblright'] = 987;
  50730. t['arrowdbldown'] = 603;
  50731. t['lozenge'] = 494;
  50732. t['angleleft'] = 329;
  50733. t['registersans'] = 790;
  50734. t['copyrightsans'] = 790;
  50735. t['trademarksans'] = 786;
  50736. t['summation'] = 713;
  50737. t['parenlefttp'] = 384;
  50738. t['parenleftex'] = 384;
  50739. t['parenleftbt'] = 384;
  50740. t['bracketlefttp'] = 384;
  50741. t['bracketleftex'] = 384;
  50742. t['bracketleftbt'] = 384;
  50743. t['bracelefttp'] = 494;
  50744. t['braceleftmid'] = 494;
  50745. t['braceleftbt'] = 494;
  50746. t['braceex'] = 494;
  50747. t['angleright'] = 329;
  50748. t['integral'] = 274;
  50749. t['integraltp'] = 686;
  50750. t['integralex'] = 686;
  50751. t['integralbt'] = 686;
  50752. t['parenrighttp'] = 384;
  50753. t['parenrightex'] = 384;
  50754. t['parenrightbt'] = 384;
  50755. t['bracketrighttp'] = 384;
  50756. t['bracketrightex'] = 384;
  50757. t['bracketrightbt'] = 384;
  50758. t['bracerighttp'] = 494;
  50759. t['bracerightmid'] = 494;
  50760. t['bracerightbt'] = 494;
  50761. t['apple'] = 790;
  50762. });
  50763. t['Times-Roman'] = getLookupTableFactory(function (t) {
  50764. t['space'] = 250;
  50765. t['exclam'] = 333;
  50766. t['quotedbl'] = 408;
  50767. t['numbersign'] = 500;
  50768. t['dollar'] = 500;
  50769. t['percent'] = 833;
  50770. t['ampersand'] = 778;
  50771. t['quoteright'] = 333;
  50772. t['parenleft'] = 333;
  50773. t['parenright'] = 333;
  50774. t['asterisk'] = 500;
  50775. t['plus'] = 564;
  50776. t['comma'] = 250;
  50777. t['hyphen'] = 333;
  50778. t['period'] = 250;
  50779. t['slash'] = 278;
  50780. t['zero'] = 500;
  50781. t['one'] = 500;
  50782. t['two'] = 500;
  50783. t['three'] = 500;
  50784. t['four'] = 500;
  50785. t['five'] = 500;
  50786. t['six'] = 500;
  50787. t['seven'] = 500;
  50788. t['eight'] = 500;
  50789. t['nine'] = 500;
  50790. t['colon'] = 278;
  50791. t['semicolon'] = 278;
  50792. t['less'] = 564;
  50793. t['equal'] = 564;
  50794. t['greater'] = 564;
  50795. t['question'] = 444;
  50796. t['at'] = 921;
  50797. t['A'] = 722;
  50798. t['B'] = 667;
  50799. t['C'] = 667;
  50800. t['D'] = 722;
  50801. t['E'] = 611;
  50802. t['F'] = 556;
  50803. t['G'] = 722;
  50804. t['H'] = 722;
  50805. t['I'] = 333;
  50806. t['J'] = 389;
  50807. t['K'] = 722;
  50808. t['L'] = 611;
  50809. t['M'] = 889;
  50810. t['N'] = 722;
  50811. t['O'] = 722;
  50812. t['P'] = 556;
  50813. t['Q'] = 722;
  50814. t['R'] = 667;
  50815. t['S'] = 556;
  50816. t['T'] = 611;
  50817. t['U'] = 722;
  50818. t['V'] = 722;
  50819. t['W'] = 944;
  50820. t['X'] = 722;
  50821. t['Y'] = 722;
  50822. t['Z'] = 611;
  50823. t['bracketleft'] = 333;
  50824. t['backslash'] = 278;
  50825. t['bracketright'] = 333;
  50826. t['asciicircum'] = 469;
  50827. t['underscore'] = 500;
  50828. t['quoteleft'] = 333;
  50829. t['a'] = 444;
  50830. t['b'] = 500;
  50831. t['c'] = 444;
  50832. t['d'] = 500;
  50833. t['e'] = 444;
  50834. t['f'] = 333;
  50835. t['g'] = 500;
  50836. t['h'] = 500;
  50837. t['i'] = 278;
  50838. t['j'] = 278;
  50839. t['k'] = 500;
  50840. t['l'] = 278;
  50841. t['m'] = 778;
  50842. t['n'] = 500;
  50843. t['o'] = 500;
  50844. t['p'] = 500;
  50845. t['q'] = 500;
  50846. t['r'] = 333;
  50847. t['s'] = 389;
  50848. t['t'] = 278;
  50849. t['u'] = 500;
  50850. t['v'] = 500;
  50851. t['w'] = 722;
  50852. t['x'] = 500;
  50853. t['y'] = 500;
  50854. t['z'] = 444;
  50855. t['braceleft'] = 480;
  50856. t['bar'] = 200;
  50857. t['braceright'] = 480;
  50858. t['asciitilde'] = 541;
  50859. t['exclamdown'] = 333;
  50860. t['cent'] = 500;
  50861. t['sterling'] = 500;
  50862. t['fraction'] = 167;
  50863. t['yen'] = 500;
  50864. t['florin'] = 500;
  50865. t['section'] = 500;
  50866. t['currency'] = 500;
  50867. t['quotesingle'] = 180;
  50868. t['quotedblleft'] = 444;
  50869. t['guillemotleft'] = 500;
  50870. t['guilsinglleft'] = 333;
  50871. t['guilsinglright'] = 333;
  50872. t['fi'] = 556;
  50873. t['fl'] = 556;
  50874. t['endash'] = 500;
  50875. t['dagger'] = 500;
  50876. t['daggerdbl'] = 500;
  50877. t['periodcentered'] = 250;
  50878. t['paragraph'] = 453;
  50879. t['bullet'] = 350;
  50880. t['quotesinglbase'] = 333;
  50881. t['quotedblbase'] = 444;
  50882. t['quotedblright'] = 444;
  50883. t['guillemotright'] = 500;
  50884. t['ellipsis'] = 1000;
  50885. t['perthousand'] = 1000;
  50886. t['questiondown'] = 444;
  50887. t['grave'] = 333;
  50888. t['acute'] = 333;
  50889. t['circumflex'] = 333;
  50890. t['tilde'] = 333;
  50891. t['macron'] = 333;
  50892. t['breve'] = 333;
  50893. t['dotaccent'] = 333;
  50894. t['dieresis'] = 333;
  50895. t['ring'] = 333;
  50896. t['cedilla'] = 333;
  50897. t['hungarumlaut'] = 333;
  50898. t['ogonek'] = 333;
  50899. t['caron'] = 333;
  50900. t['emdash'] = 1000;
  50901. t['AE'] = 889;
  50902. t['ordfeminine'] = 276;
  50903. t['Lslash'] = 611;
  50904. t['Oslash'] = 722;
  50905. t['OE'] = 889;
  50906. t['ordmasculine'] = 310;
  50907. t['ae'] = 667;
  50908. t['dotlessi'] = 278;
  50909. t['lslash'] = 278;
  50910. t['oslash'] = 500;
  50911. t['oe'] = 722;
  50912. t['germandbls'] = 500;
  50913. t['Idieresis'] = 333;
  50914. t['eacute'] = 444;
  50915. t['abreve'] = 444;
  50916. t['uhungarumlaut'] = 500;
  50917. t['ecaron'] = 444;
  50918. t['Ydieresis'] = 722;
  50919. t['divide'] = 564;
  50920. t['Yacute'] = 722;
  50921. t['Acircumflex'] = 722;
  50922. t['aacute'] = 444;
  50923. t['Ucircumflex'] = 722;
  50924. t['yacute'] = 500;
  50925. t['scommaaccent'] = 389;
  50926. t['ecircumflex'] = 444;
  50927. t['Uring'] = 722;
  50928. t['Udieresis'] = 722;
  50929. t['aogonek'] = 444;
  50930. t['Uacute'] = 722;
  50931. t['uogonek'] = 500;
  50932. t['Edieresis'] = 611;
  50933. t['Dcroat'] = 722;
  50934. t['commaaccent'] = 250;
  50935. t['copyright'] = 760;
  50936. t['Emacron'] = 611;
  50937. t['ccaron'] = 444;
  50938. t['aring'] = 444;
  50939. t['Ncommaaccent'] = 722;
  50940. t['lacute'] = 278;
  50941. t['agrave'] = 444;
  50942. t['Tcommaaccent'] = 611;
  50943. t['Cacute'] = 667;
  50944. t['atilde'] = 444;
  50945. t['Edotaccent'] = 611;
  50946. t['scaron'] = 389;
  50947. t['scedilla'] = 389;
  50948. t['iacute'] = 278;
  50949. t['lozenge'] = 471;
  50950. t['Rcaron'] = 667;
  50951. t['Gcommaaccent'] = 722;
  50952. t['ucircumflex'] = 500;
  50953. t['acircumflex'] = 444;
  50954. t['Amacron'] = 722;
  50955. t['rcaron'] = 333;
  50956. t['ccedilla'] = 444;
  50957. t['Zdotaccent'] = 611;
  50958. t['Thorn'] = 556;
  50959. t['Omacron'] = 722;
  50960. t['Racute'] = 667;
  50961. t['Sacute'] = 556;
  50962. t['dcaron'] = 588;
  50963. t['Umacron'] = 722;
  50964. t['uring'] = 500;
  50965. t['threesuperior'] = 300;
  50966. t['Ograve'] = 722;
  50967. t['Agrave'] = 722;
  50968. t['Abreve'] = 722;
  50969. t['multiply'] = 564;
  50970. t['uacute'] = 500;
  50971. t['Tcaron'] = 611;
  50972. t['partialdiff'] = 476;
  50973. t['ydieresis'] = 500;
  50974. t['Nacute'] = 722;
  50975. t['icircumflex'] = 278;
  50976. t['Ecircumflex'] = 611;
  50977. t['adieresis'] = 444;
  50978. t['edieresis'] = 444;
  50979. t['cacute'] = 444;
  50980. t['nacute'] = 500;
  50981. t['umacron'] = 500;
  50982. t['Ncaron'] = 722;
  50983. t['Iacute'] = 333;
  50984. t['plusminus'] = 564;
  50985. t['brokenbar'] = 200;
  50986. t['registered'] = 760;
  50987. t['Gbreve'] = 722;
  50988. t['Idotaccent'] = 333;
  50989. t['summation'] = 600;
  50990. t['Egrave'] = 611;
  50991. t['racute'] = 333;
  50992. t['omacron'] = 500;
  50993. t['Zacute'] = 611;
  50994. t['Zcaron'] = 611;
  50995. t['greaterequal'] = 549;
  50996. t['Eth'] = 722;
  50997. t['Ccedilla'] = 667;
  50998. t['lcommaaccent'] = 278;
  50999. t['tcaron'] = 326;
  51000. t['eogonek'] = 444;
  51001. t['Uogonek'] = 722;
  51002. t['Aacute'] = 722;
  51003. t['Adieresis'] = 722;
  51004. t['egrave'] = 444;
  51005. t['zacute'] = 444;
  51006. t['iogonek'] = 278;
  51007. t['Oacute'] = 722;
  51008. t['oacute'] = 500;
  51009. t['amacron'] = 444;
  51010. t['sacute'] = 389;
  51011. t['idieresis'] = 278;
  51012. t['Ocircumflex'] = 722;
  51013. t['Ugrave'] = 722;
  51014. t['Delta'] = 612;
  51015. t['thorn'] = 500;
  51016. t['twosuperior'] = 300;
  51017. t['Odieresis'] = 722;
  51018. t['mu'] = 500;
  51019. t['igrave'] = 278;
  51020. t['ohungarumlaut'] = 500;
  51021. t['Eogonek'] = 611;
  51022. t['dcroat'] = 500;
  51023. t['threequarters'] = 750;
  51024. t['Scedilla'] = 556;
  51025. t['lcaron'] = 344;
  51026. t['Kcommaaccent'] = 722;
  51027. t['Lacute'] = 611;
  51028. t['trademark'] = 980;
  51029. t['edotaccent'] = 444;
  51030. t['Igrave'] = 333;
  51031. t['Imacron'] = 333;
  51032. t['Lcaron'] = 611;
  51033. t['onehalf'] = 750;
  51034. t['lessequal'] = 549;
  51035. t['ocircumflex'] = 500;
  51036. t['ntilde'] = 500;
  51037. t['Uhungarumlaut'] = 722;
  51038. t['Eacute'] = 611;
  51039. t['emacron'] = 444;
  51040. t['gbreve'] = 500;
  51041. t['onequarter'] = 750;
  51042. t['Scaron'] = 556;
  51043. t['Scommaaccent'] = 556;
  51044. t['Ohungarumlaut'] = 722;
  51045. t['degree'] = 400;
  51046. t['ograve'] = 500;
  51047. t['Ccaron'] = 667;
  51048. t['ugrave'] = 500;
  51049. t['radical'] = 453;
  51050. t['Dcaron'] = 722;
  51051. t['rcommaaccent'] = 333;
  51052. t['Ntilde'] = 722;
  51053. t['otilde'] = 500;
  51054. t['Rcommaaccent'] = 667;
  51055. t['Lcommaaccent'] = 611;
  51056. t['Atilde'] = 722;
  51057. t['Aogonek'] = 722;
  51058. t['Aring'] = 722;
  51059. t['Otilde'] = 722;
  51060. t['zdotaccent'] = 444;
  51061. t['Ecaron'] = 611;
  51062. t['Iogonek'] = 333;
  51063. t['kcommaaccent'] = 500;
  51064. t['minus'] = 564;
  51065. t['Icircumflex'] = 333;
  51066. t['ncaron'] = 500;
  51067. t['tcommaaccent'] = 278;
  51068. t['logicalnot'] = 564;
  51069. t['odieresis'] = 500;
  51070. t['udieresis'] = 500;
  51071. t['notequal'] = 549;
  51072. t['gcommaaccent'] = 500;
  51073. t['eth'] = 500;
  51074. t['zcaron'] = 444;
  51075. t['ncommaaccent'] = 500;
  51076. t['onesuperior'] = 300;
  51077. t['imacron'] = 278;
  51078. t['Euro'] = 500;
  51079. });
  51080. t['Times-Bold'] = getLookupTableFactory(function (t) {
  51081. t['space'] = 250;
  51082. t['exclam'] = 333;
  51083. t['quotedbl'] = 555;
  51084. t['numbersign'] = 500;
  51085. t['dollar'] = 500;
  51086. t['percent'] = 1000;
  51087. t['ampersand'] = 833;
  51088. t['quoteright'] = 333;
  51089. t['parenleft'] = 333;
  51090. t['parenright'] = 333;
  51091. t['asterisk'] = 500;
  51092. t['plus'] = 570;
  51093. t['comma'] = 250;
  51094. t['hyphen'] = 333;
  51095. t['period'] = 250;
  51096. t['slash'] = 278;
  51097. t['zero'] = 500;
  51098. t['one'] = 500;
  51099. t['two'] = 500;
  51100. t['three'] = 500;
  51101. t['four'] = 500;
  51102. t['five'] = 500;
  51103. t['six'] = 500;
  51104. t['seven'] = 500;
  51105. t['eight'] = 500;
  51106. t['nine'] = 500;
  51107. t['colon'] = 333;
  51108. t['semicolon'] = 333;
  51109. t['less'] = 570;
  51110. t['equal'] = 570;
  51111. t['greater'] = 570;
  51112. t['question'] = 500;
  51113. t['at'] = 930;
  51114. t['A'] = 722;
  51115. t['B'] = 667;
  51116. t['C'] = 722;
  51117. t['D'] = 722;
  51118. t['E'] = 667;
  51119. t['F'] = 611;
  51120. t['G'] = 778;
  51121. t['H'] = 778;
  51122. t['I'] = 389;
  51123. t['J'] = 500;
  51124. t['K'] = 778;
  51125. t['L'] = 667;
  51126. t['M'] = 944;
  51127. t['N'] = 722;
  51128. t['O'] = 778;
  51129. t['P'] = 611;
  51130. t['Q'] = 778;
  51131. t['R'] = 722;
  51132. t['S'] = 556;
  51133. t['T'] = 667;
  51134. t['U'] = 722;
  51135. t['V'] = 722;
  51136. t['W'] = 1000;
  51137. t['X'] = 722;
  51138. t['Y'] = 722;
  51139. t['Z'] = 667;
  51140. t['bracketleft'] = 333;
  51141. t['backslash'] = 278;
  51142. t['bracketright'] = 333;
  51143. t['asciicircum'] = 581;
  51144. t['underscore'] = 500;
  51145. t['quoteleft'] = 333;
  51146. t['a'] = 500;
  51147. t['b'] = 556;
  51148. t['c'] = 444;
  51149. t['d'] = 556;
  51150. t['e'] = 444;
  51151. t['f'] = 333;
  51152. t['g'] = 500;
  51153. t['h'] = 556;
  51154. t['i'] = 278;
  51155. t['j'] = 333;
  51156. t['k'] = 556;
  51157. t['l'] = 278;
  51158. t['m'] = 833;
  51159. t['n'] = 556;
  51160. t['o'] = 500;
  51161. t['p'] = 556;
  51162. t['q'] = 556;
  51163. t['r'] = 444;
  51164. t['s'] = 389;
  51165. t['t'] = 333;
  51166. t['u'] = 556;
  51167. t['v'] = 500;
  51168. t['w'] = 722;
  51169. t['x'] = 500;
  51170. t['y'] = 500;
  51171. t['z'] = 444;
  51172. t['braceleft'] = 394;
  51173. t['bar'] = 220;
  51174. t['braceright'] = 394;
  51175. t['asciitilde'] = 520;
  51176. t['exclamdown'] = 333;
  51177. t['cent'] = 500;
  51178. t['sterling'] = 500;
  51179. t['fraction'] = 167;
  51180. t['yen'] = 500;
  51181. t['florin'] = 500;
  51182. t['section'] = 500;
  51183. t['currency'] = 500;
  51184. t['quotesingle'] = 278;
  51185. t['quotedblleft'] = 500;
  51186. t['guillemotleft'] = 500;
  51187. t['guilsinglleft'] = 333;
  51188. t['guilsinglright'] = 333;
  51189. t['fi'] = 556;
  51190. t['fl'] = 556;
  51191. t['endash'] = 500;
  51192. t['dagger'] = 500;
  51193. t['daggerdbl'] = 500;
  51194. t['periodcentered'] = 250;
  51195. t['paragraph'] = 540;
  51196. t['bullet'] = 350;
  51197. t['quotesinglbase'] = 333;
  51198. t['quotedblbase'] = 500;
  51199. t['quotedblright'] = 500;
  51200. t['guillemotright'] = 500;
  51201. t['ellipsis'] = 1000;
  51202. t['perthousand'] = 1000;
  51203. t['questiondown'] = 500;
  51204. t['grave'] = 333;
  51205. t['acute'] = 333;
  51206. t['circumflex'] = 333;
  51207. t['tilde'] = 333;
  51208. t['macron'] = 333;
  51209. t['breve'] = 333;
  51210. t['dotaccent'] = 333;
  51211. t['dieresis'] = 333;
  51212. t['ring'] = 333;
  51213. t['cedilla'] = 333;
  51214. t['hungarumlaut'] = 333;
  51215. t['ogonek'] = 333;
  51216. t['caron'] = 333;
  51217. t['emdash'] = 1000;
  51218. t['AE'] = 1000;
  51219. t['ordfeminine'] = 300;
  51220. t['Lslash'] = 667;
  51221. t['Oslash'] = 778;
  51222. t['OE'] = 1000;
  51223. t['ordmasculine'] = 330;
  51224. t['ae'] = 722;
  51225. t['dotlessi'] = 278;
  51226. t['lslash'] = 278;
  51227. t['oslash'] = 500;
  51228. t['oe'] = 722;
  51229. t['germandbls'] = 556;
  51230. t['Idieresis'] = 389;
  51231. t['eacute'] = 444;
  51232. t['abreve'] = 500;
  51233. t['uhungarumlaut'] = 556;
  51234. t['ecaron'] = 444;
  51235. t['Ydieresis'] = 722;
  51236. t['divide'] = 570;
  51237. t['Yacute'] = 722;
  51238. t['Acircumflex'] = 722;
  51239. t['aacute'] = 500;
  51240. t['Ucircumflex'] = 722;
  51241. t['yacute'] = 500;
  51242. t['scommaaccent'] = 389;
  51243. t['ecircumflex'] = 444;
  51244. t['Uring'] = 722;
  51245. t['Udieresis'] = 722;
  51246. t['aogonek'] = 500;
  51247. t['Uacute'] = 722;
  51248. t['uogonek'] = 556;
  51249. t['Edieresis'] = 667;
  51250. t['Dcroat'] = 722;
  51251. t['commaaccent'] = 250;
  51252. t['copyright'] = 747;
  51253. t['Emacron'] = 667;
  51254. t['ccaron'] = 444;
  51255. t['aring'] = 500;
  51256. t['Ncommaaccent'] = 722;
  51257. t['lacute'] = 278;
  51258. t['agrave'] = 500;
  51259. t['Tcommaaccent'] = 667;
  51260. t['Cacute'] = 722;
  51261. t['atilde'] = 500;
  51262. t['Edotaccent'] = 667;
  51263. t['scaron'] = 389;
  51264. t['scedilla'] = 389;
  51265. t['iacute'] = 278;
  51266. t['lozenge'] = 494;
  51267. t['Rcaron'] = 722;
  51268. t['Gcommaaccent'] = 778;
  51269. t['ucircumflex'] = 556;
  51270. t['acircumflex'] = 500;
  51271. t['Amacron'] = 722;
  51272. t['rcaron'] = 444;
  51273. t['ccedilla'] = 444;
  51274. t['Zdotaccent'] = 667;
  51275. t['Thorn'] = 611;
  51276. t['Omacron'] = 778;
  51277. t['Racute'] = 722;
  51278. t['Sacute'] = 556;
  51279. t['dcaron'] = 672;
  51280. t['Umacron'] = 722;
  51281. t['uring'] = 556;
  51282. t['threesuperior'] = 300;
  51283. t['Ograve'] = 778;
  51284. t['Agrave'] = 722;
  51285. t['Abreve'] = 722;
  51286. t['multiply'] = 570;
  51287. t['uacute'] = 556;
  51288. t['Tcaron'] = 667;
  51289. t['partialdiff'] = 494;
  51290. t['ydieresis'] = 500;
  51291. t['Nacute'] = 722;
  51292. t['icircumflex'] = 278;
  51293. t['Ecircumflex'] = 667;
  51294. t['adieresis'] = 500;
  51295. t['edieresis'] = 444;
  51296. t['cacute'] = 444;
  51297. t['nacute'] = 556;
  51298. t['umacron'] = 556;
  51299. t['Ncaron'] = 722;
  51300. t['Iacute'] = 389;
  51301. t['plusminus'] = 570;
  51302. t['brokenbar'] = 220;
  51303. t['registered'] = 747;
  51304. t['Gbreve'] = 778;
  51305. t['Idotaccent'] = 389;
  51306. t['summation'] = 600;
  51307. t['Egrave'] = 667;
  51308. t['racute'] = 444;
  51309. t['omacron'] = 500;
  51310. t['Zacute'] = 667;
  51311. t['Zcaron'] = 667;
  51312. t['greaterequal'] = 549;
  51313. t['Eth'] = 722;
  51314. t['Ccedilla'] = 722;
  51315. t['lcommaaccent'] = 278;
  51316. t['tcaron'] = 416;
  51317. t['eogonek'] = 444;
  51318. t['Uogonek'] = 722;
  51319. t['Aacute'] = 722;
  51320. t['Adieresis'] = 722;
  51321. t['egrave'] = 444;
  51322. t['zacute'] = 444;
  51323. t['iogonek'] = 278;
  51324. t['Oacute'] = 778;
  51325. t['oacute'] = 500;
  51326. t['amacron'] = 500;
  51327. t['sacute'] = 389;
  51328. t['idieresis'] = 278;
  51329. t['Ocircumflex'] = 778;
  51330. t['Ugrave'] = 722;
  51331. t['Delta'] = 612;
  51332. t['thorn'] = 556;
  51333. t['twosuperior'] = 300;
  51334. t['Odieresis'] = 778;
  51335. t['mu'] = 556;
  51336. t['igrave'] = 278;
  51337. t['ohungarumlaut'] = 500;
  51338. t['Eogonek'] = 667;
  51339. t['dcroat'] = 556;
  51340. t['threequarters'] = 750;
  51341. t['Scedilla'] = 556;
  51342. t['lcaron'] = 394;
  51343. t['Kcommaaccent'] = 778;
  51344. t['Lacute'] = 667;
  51345. t['trademark'] = 1000;
  51346. t['edotaccent'] = 444;
  51347. t['Igrave'] = 389;
  51348. t['Imacron'] = 389;
  51349. t['Lcaron'] = 667;
  51350. t['onehalf'] = 750;
  51351. t['lessequal'] = 549;
  51352. t['ocircumflex'] = 500;
  51353. t['ntilde'] = 556;
  51354. t['Uhungarumlaut'] = 722;
  51355. t['Eacute'] = 667;
  51356. t['emacron'] = 444;
  51357. t['gbreve'] = 500;
  51358. t['onequarter'] = 750;
  51359. t['Scaron'] = 556;
  51360. t['Scommaaccent'] = 556;
  51361. t['Ohungarumlaut'] = 778;
  51362. t['degree'] = 400;
  51363. t['ograve'] = 500;
  51364. t['Ccaron'] = 722;
  51365. t['ugrave'] = 556;
  51366. t['radical'] = 549;
  51367. t['Dcaron'] = 722;
  51368. t['rcommaaccent'] = 444;
  51369. t['Ntilde'] = 722;
  51370. t['otilde'] = 500;
  51371. t['Rcommaaccent'] = 722;
  51372. t['Lcommaaccent'] = 667;
  51373. t['Atilde'] = 722;
  51374. t['Aogonek'] = 722;
  51375. t['Aring'] = 722;
  51376. t['Otilde'] = 778;
  51377. t['zdotaccent'] = 444;
  51378. t['Ecaron'] = 667;
  51379. t['Iogonek'] = 389;
  51380. t['kcommaaccent'] = 556;
  51381. t['minus'] = 570;
  51382. t['Icircumflex'] = 389;
  51383. t['ncaron'] = 556;
  51384. t['tcommaaccent'] = 333;
  51385. t['logicalnot'] = 570;
  51386. t['odieresis'] = 500;
  51387. t['udieresis'] = 556;
  51388. t['notequal'] = 549;
  51389. t['gcommaaccent'] = 500;
  51390. t['eth'] = 500;
  51391. t['zcaron'] = 444;
  51392. t['ncommaaccent'] = 556;
  51393. t['onesuperior'] = 300;
  51394. t['imacron'] = 278;
  51395. t['Euro'] = 500;
  51396. });
  51397. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  51398. t['space'] = 250;
  51399. t['exclam'] = 389;
  51400. t['quotedbl'] = 555;
  51401. t['numbersign'] = 500;
  51402. t['dollar'] = 500;
  51403. t['percent'] = 833;
  51404. t['ampersand'] = 778;
  51405. t['quoteright'] = 333;
  51406. t['parenleft'] = 333;
  51407. t['parenright'] = 333;
  51408. t['asterisk'] = 500;
  51409. t['plus'] = 570;
  51410. t['comma'] = 250;
  51411. t['hyphen'] = 333;
  51412. t['period'] = 250;
  51413. t['slash'] = 278;
  51414. t['zero'] = 500;
  51415. t['one'] = 500;
  51416. t['two'] = 500;
  51417. t['three'] = 500;
  51418. t['four'] = 500;
  51419. t['five'] = 500;
  51420. t['six'] = 500;
  51421. t['seven'] = 500;
  51422. t['eight'] = 500;
  51423. t['nine'] = 500;
  51424. t['colon'] = 333;
  51425. t['semicolon'] = 333;
  51426. t['less'] = 570;
  51427. t['equal'] = 570;
  51428. t['greater'] = 570;
  51429. t['question'] = 500;
  51430. t['at'] = 832;
  51431. t['A'] = 667;
  51432. t['B'] = 667;
  51433. t['C'] = 667;
  51434. t['D'] = 722;
  51435. t['E'] = 667;
  51436. t['F'] = 667;
  51437. t['G'] = 722;
  51438. t['H'] = 778;
  51439. t['I'] = 389;
  51440. t['J'] = 500;
  51441. t['K'] = 667;
  51442. t['L'] = 611;
  51443. t['M'] = 889;
  51444. t['N'] = 722;
  51445. t['O'] = 722;
  51446. t['P'] = 611;
  51447. t['Q'] = 722;
  51448. t['R'] = 667;
  51449. t['S'] = 556;
  51450. t['T'] = 611;
  51451. t['U'] = 722;
  51452. t['V'] = 667;
  51453. t['W'] = 889;
  51454. t['X'] = 667;
  51455. t['Y'] = 611;
  51456. t['Z'] = 611;
  51457. t['bracketleft'] = 333;
  51458. t['backslash'] = 278;
  51459. t['bracketright'] = 333;
  51460. t['asciicircum'] = 570;
  51461. t['underscore'] = 500;
  51462. t['quoteleft'] = 333;
  51463. t['a'] = 500;
  51464. t['b'] = 500;
  51465. t['c'] = 444;
  51466. t['d'] = 500;
  51467. t['e'] = 444;
  51468. t['f'] = 333;
  51469. t['g'] = 500;
  51470. t['h'] = 556;
  51471. t['i'] = 278;
  51472. t['j'] = 278;
  51473. t['k'] = 500;
  51474. t['l'] = 278;
  51475. t['m'] = 778;
  51476. t['n'] = 556;
  51477. t['o'] = 500;
  51478. t['p'] = 500;
  51479. t['q'] = 500;
  51480. t['r'] = 389;
  51481. t['s'] = 389;
  51482. t['t'] = 278;
  51483. t['u'] = 556;
  51484. t['v'] = 444;
  51485. t['w'] = 667;
  51486. t['x'] = 500;
  51487. t['y'] = 444;
  51488. t['z'] = 389;
  51489. t['braceleft'] = 348;
  51490. t['bar'] = 220;
  51491. t['braceright'] = 348;
  51492. t['asciitilde'] = 570;
  51493. t['exclamdown'] = 389;
  51494. t['cent'] = 500;
  51495. t['sterling'] = 500;
  51496. t['fraction'] = 167;
  51497. t['yen'] = 500;
  51498. t['florin'] = 500;
  51499. t['section'] = 500;
  51500. t['currency'] = 500;
  51501. t['quotesingle'] = 278;
  51502. t['quotedblleft'] = 500;
  51503. t['guillemotleft'] = 500;
  51504. t['guilsinglleft'] = 333;
  51505. t['guilsinglright'] = 333;
  51506. t['fi'] = 556;
  51507. t['fl'] = 556;
  51508. t['endash'] = 500;
  51509. t['dagger'] = 500;
  51510. t['daggerdbl'] = 500;
  51511. t['periodcentered'] = 250;
  51512. t['paragraph'] = 500;
  51513. t['bullet'] = 350;
  51514. t['quotesinglbase'] = 333;
  51515. t['quotedblbase'] = 500;
  51516. t['quotedblright'] = 500;
  51517. t['guillemotright'] = 500;
  51518. t['ellipsis'] = 1000;
  51519. t['perthousand'] = 1000;
  51520. t['questiondown'] = 500;
  51521. t['grave'] = 333;
  51522. t['acute'] = 333;
  51523. t['circumflex'] = 333;
  51524. t['tilde'] = 333;
  51525. t['macron'] = 333;
  51526. t['breve'] = 333;
  51527. t['dotaccent'] = 333;
  51528. t['dieresis'] = 333;
  51529. t['ring'] = 333;
  51530. t['cedilla'] = 333;
  51531. t['hungarumlaut'] = 333;
  51532. t['ogonek'] = 333;
  51533. t['caron'] = 333;
  51534. t['emdash'] = 1000;
  51535. t['AE'] = 944;
  51536. t['ordfeminine'] = 266;
  51537. t['Lslash'] = 611;
  51538. t['Oslash'] = 722;
  51539. t['OE'] = 944;
  51540. t['ordmasculine'] = 300;
  51541. t['ae'] = 722;
  51542. t['dotlessi'] = 278;
  51543. t['lslash'] = 278;
  51544. t['oslash'] = 500;
  51545. t['oe'] = 722;
  51546. t['germandbls'] = 500;
  51547. t['Idieresis'] = 389;
  51548. t['eacute'] = 444;
  51549. t['abreve'] = 500;
  51550. t['uhungarumlaut'] = 556;
  51551. t['ecaron'] = 444;
  51552. t['Ydieresis'] = 611;
  51553. t['divide'] = 570;
  51554. t['Yacute'] = 611;
  51555. t['Acircumflex'] = 667;
  51556. t['aacute'] = 500;
  51557. t['Ucircumflex'] = 722;
  51558. t['yacute'] = 444;
  51559. t['scommaaccent'] = 389;
  51560. t['ecircumflex'] = 444;
  51561. t['Uring'] = 722;
  51562. t['Udieresis'] = 722;
  51563. t['aogonek'] = 500;
  51564. t['Uacute'] = 722;
  51565. t['uogonek'] = 556;
  51566. t['Edieresis'] = 667;
  51567. t['Dcroat'] = 722;
  51568. t['commaaccent'] = 250;
  51569. t['copyright'] = 747;
  51570. t['Emacron'] = 667;
  51571. t['ccaron'] = 444;
  51572. t['aring'] = 500;
  51573. t['Ncommaaccent'] = 722;
  51574. t['lacute'] = 278;
  51575. t['agrave'] = 500;
  51576. t['Tcommaaccent'] = 611;
  51577. t['Cacute'] = 667;
  51578. t['atilde'] = 500;
  51579. t['Edotaccent'] = 667;
  51580. t['scaron'] = 389;
  51581. t['scedilla'] = 389;
  51582. t['iacute'] = 278;
  51583. t['lozenge'] = 494;
  51584. t['Rcaron'] = 667;
  51585. t['Gcommaaccent'] = 722;
  51586. t['ucircumflex'] = 556;
  51587. t['acircumflex'] = 500;
  51588. t['Amacron'] = 667;
  51589. t['rcaron'] = 389;
  51590. t['ccedilla'] = 444;
  51591. t['Zdotaccent'] = 611;
  51592. t['Thorn'] = 611;
  51593. t['Omacron'] = 722;
  51594. t['Racute'] = 667;
  51595. t['Sacute'] = 556;
  51596. t['dcaron'] = 608;
  51597. t['Umacron'] = 722;
  51598. t['uring'] = 556;
  51599. t['threesuperior'] = 300;
  51600. t['Ograve'] = 722;
  51601. t['Agrave'] = 667;
  51602. t['Abreve'] = 667;
  51603. t['multiply'] = 570;
  51604. t['uacute'] = 556;
  51605. t['Tcaron'] = 611;
  51606. t['partialdiff'] = 494;
  51607. t['ydieresis'] = 444;
  51608. t['Nacute'] = 722;
  51609. t['icircumflex'] = 278;
  51610. t['Ecircumflex'] = 667;
  51611. t['adieresis'] = 500;
  51612. t['edieresis'] = 444;
  51613. t['cacute'] = 444;
  51614. t['nacute'] = 556;
  51615. t['umacron'] = 556;
  51616. t['Ncaron'] = 722;
  51617. t['Iacute'] = 389;
  51618. t['plusminus'] = 570;
  51619. t['brokenbar'] = 220;
  51620. t['registered'] = 747;
  51621. t['Gbreve'] = 722;
  51622. t['Idotaccent'] = 389;
  51623. t['summation'] = 600;
  51624. t['Egrave'] = 667;
  51625. t['racute'] = 389;
  51626. t['omacron'] = 500;
  51627. t['Zacute'] = 611;
  51628. t['Zcaron'] = 611;
  51629. t['greaterequal'] = 549;
  51630. t['Eth'] = 722;
  51631. t['Ccedilla'] = 667;
  51632. t['lcommaaccent'] = 278;
  51633. t['tcaron'] = 366;
  51634. t['eogonek'] = 444;
  51635. t['Uogonek'] = 722;
  51636. t['Aacute'] = 667;
  51637. t['Adieresis'] = 667;
  51638. t['egrave'] = 444;
  51639. t['zacute'] = 389;
  51640. t['iogonek'] = 278;
  51641. t['Oacute'] = 722;
  51642. t['oacute'] = 500;
  51643. t['amacron'] = 500;
  51644. t['sacute'] = 389;
  51645. t['idieresis'] = 278;
  51646. t['Ocircumflex'] = 722;
  51647. t['Ugrave'] = 722;
  51648. t['Delta'] = 612;
  51649. t['thorn'] = 500;
  51650. t['twosuperior'] = 300;
  51651. t['Odieresis'] = 722;
  51652. t['mu'] = 576;
  51653. t['igrave'] = 278;
  51654. t['ohungarumlaut'] = 500;
  51655. t['Eogonek'] = 667;
  51656. t['dcroat'] = 500;
  51657. t['threequarters'] = 750;
  51658. t['Scedilla'] = 556;
  51659. t['lcaron'] = 382;
  51660. t['Kcommaaccent'] = 667;
  51661. t['Lacute'] = 611;
  51662. t['trademark'] = 1000;
  51663. t['edotaccent'] = 444;
  51664. t['Igrave'] = 389;
  51665. t['Imacron'] = 389;
  51666. t['Lcaron'] = 611;
  51667. t['onehalf'] = 750;
  51668. t['lessequal'] = 549;
  51669. t['ocircumflex'] = 500;
  51670. t['ntilde'] = 556;
  51671. t['Uhungarumlaut'] = 722;
  51672. t['Eacute'] = 667;
  51673. t['emacron'] = 444;
  51674. t['gbreve'] = 500;
  51675. t['onequarter'] = 750;
  51676. t['Scaron'] = 556;
  51677. t['Scommaaccent'] = 556;
  51678. t['Ohungarumlaut'] = 722;
  51679. t['degree'] = 400;
  51680. t['ograve'] = 500;
  51681. t['Ccaron'] = 667;
  51682. t['ugrave'] = 556;
  51683. t['radical'] = 549;
  51684. t['Dcaron'] = 722;
  51685. t['rcommaaccent'] = 389;
  51686. t['Ntilde'] = 722;
  51687. t['otilde'] = 500;
  51688. t['Rcommaaccent'] = 667;
  51689. t['Lcommaaccent'] = 611;
  51690. t['Atilde'] = 667;
  51691. t['Aogonek'] = 667;
  51692. t['Aring'] = 667;
  51693. t['Otilde'] = 722;
  51694. t['zdotaccent'] = 389;
  51695. t['Ecaron'] = 667;
  51696. t['Iogonek'] = 389;
  51697. t['kcommaaccent'] = 500;
  51698. t['minus'] = 606;
  51699. t['Icircumflex'] = 389;
  51700. t['ncaron'] = 556;
  51701. t['tcommaaccent'] = 278;
  51702. t['logicalnot'] = 606;
  51703. t['odieresis'] = 500;
  51704. t['udieresis'] = 556;
  51705. t['notequal'] = 549;
  51706. t['gcommaaccent'] = 500;
  51707. t['eth'] = 500;
  51708. t['zcaron'] = 389;
  51709. t['ncommaaccent'] = 556;
  51710. t['onesuperior'] = 300;
  51711. t['imacron'] = 278;
  51712. t['Euro'] = 500;
  51713. });
  51714. t['Times-Italic'] = getLookupTableFactory(function (t) {
  51715. t['space'] = 250;
  51716. t['exclam'] = 333;
  51717. t['quotedbl'] = 420;
  51718. t['numbersign'] = 500;
  51719. t['dollar'] = 500;
  51720. t['percent'] = 833;
  51721. t['ampersand'] = 778;
  51722. t['quoteright'] = 333;
  51723. t['parenleft'] = 333;
  51724. t['parenright'] = 333;
  51725. t['asterisk'] = 500;
  51726. t['plus'] = 675;
  51727. t['comma'] = 250;
  51728. t['hyphen'] = 333;
  51729. t['period'] = 250;
  51730. t['slash'] = 278;
  51731. t['zero'] = 500;
  51732. t['one'] = 500;
  51733. t['two'] = 500;
  51734. t['three'] = 500;
  51735. t['four'] = 500;
  51736. t['five'] = 500;
  51737. t['six'] = 500;
  51738. t['seven'] = 500;
  51739. t['eight'] = 500;
  51740. t['nine'] = 500;
  51741. t['colon'] = 333;
  51742. t['semicolon'] = 333;
  51743. t['less'] = 675;
  51744. t['equal'] = 675;
  51745. t['greater'] = 675;
  51746. t['question'] = 500;
  51747. t['at'] = 920;
  51748. t['A'] = 611;
  51749. t['B'] = 611;
  51750. t['C'] = 667;
  51751. t['D'] = 722;
  51752. t['E'] = 611;
  51753. t['F'] = 611;
  51754. t['G'] = 722;
  51755. t['H'] = 722;
  51756. t['I'] = 333;
  51757. t['J'] = 444;
  51758. t['K'] = 667;
  51759. t['L'] = 556;
  51760. t['M'] = 833;
  51761. t['N'] = 667;
  51762. t['O'] = 722;
  51763. t['P'] = 611;
  51764. t['Q'] = 722;
  51765. t['R'] = 611;
  51766. t['S'] = 500;
  51767. t['T'] = 556;
  51768. t['U'] = 722;
  51769. t['V'] = 611;
  51770. t['W'] = 833;
  51771. t['X'] = 611;
  51772. t['Y'] = 556;
  51773. t['Z'] = 556;
  51774. t['bracketleft'] = 389;
  51775. t['backslash'] = 278;
  51776. t['bracketright'] = 389;
  51777. t['asciicircum'] = 422;
  51778. t['underscore'] = 500;
  51779. t['quoteleft'] = 333;
  51780. t['a'] = 500;
  51781. t['b'] = 500;
  51782. t['c'] = 444;
  51783. t['d'] = 500;
  51784. t['e'] = 444;
  51785. t['f'] = 278;
  51786. t['g'] = 500;
  51787. t['h'] = 500;
  51788. t['i'] = 278;
  51789. t['j'] = 278;
  51790. t['k'] = 444;
  51791. t['l'] = 278;
  51792. t['m'] = 722;
  51793. t['n'] = 500;
  51794. t['o'] = 500;
  51795. t['p'] = 500;
  51796. t['q'] = 500;
  51797. t['r'] = 389;
  51798. t['s'] = 389;
  51799. t['t'] = 278;
  51800. t['u'] = 500;
  51801. t['v'] = 444;
  51802. t['w'] = 667;
  51803. t['x'] = 444;
  51804. t['y'] = 444;
  51805. t['z'] = 389;
  51806. t['braceleft'] = 400;
  51807. t['bar'] = 275;
  51808. t['braceright'] = 400;
  51809. t['asciitilde'] = 541;
  51810. t['exclamdown'] = 389;
  51811. t['cent'] = 500;
  51812. t['sterling'] = 500;
  51813. t['fraction'] = 167;
  51814. t['yen'] = 500;
  51815. t['florin'] = 500;
  51816. t['section'] = 500;
  51817. t['currency'] = 500;
  51818. t['quotesingle'] = 214;
  51819. t['quotedblleft'] = 556;
  51820. t['guillemotleft'] = 500;
  51821. t['guilsinglleft'] = 333;
  51822. t['guilsinglright'] = 333;
  51823. t['fi'] = 500;
  51824. t['fl'] = 500;
  51825. t['endash'] = 500;
  51826. t['dagger'] = 500;
  51827. t['daggerdbl'] = 500;
  51828. t['periodcentered'] = 250;
  51829. t['paragraph'] = 523;
  51830. t['bullet'] = 350;
  51831. t['quotesinglbase'] = 333;
  51832. t['quotedblbase'] = 556;
  51833. t['quotedblright'] = 556;
  51834. t['guillemotright'] = 500;
  51835. t['ellipsis'] = 889;
  51836. t['perthousand'] = 1000;
  51837. t['questiondown'] = 500;
  51838. t['grave'] = 333;
  51839. t['acute'] = 333;
  51840. t['circumflex'] = 333;
  51841. t['tilde'] = 333;
  51842. t['macron'] = 333;
  51843. t['breve'] = 333;
  51844. t['dotaccent'] = 333;
  51845. t['dieresis'] = 333;
  51846. t['ring'] = 333;
  51847. t['cedilla'] = 333;
  51848. t['hungarumlaut'] = 333;
  51849. t['ogonek'] = 333;
  51850. t['caron'] = 333;
  51851. t['emdash'] = 889;
  51852. t['AE'] = 889;
  51853. t['ordfeminine'] = 276;
  51854. t['Lslash'] = 556;
  51855. t['Oslash'] = 722;
  51856. t['OE'] = 944;
  51857. t['ordmasculine'] = 310;
  51858. t['ae'] = 667;
  51859. t['dotlessi'] = 278;
  51860. t['lslash'] = 278;
  51861. t['oslash'] = 500;
  51862. t['oe'] = 667;
  51863. t['germandbls'] = 500;
  51864. t['Idieresis'] = 333;
  51865. t['eacute'] = 444;
  51866. t['abreve'] = 500;
  51867. t['uhungarumlaut'] = 500;
  51868. t['ecaron'] = 444;
  51869. t['Ydieresis'] = 556;
  51870. t['divide'] = 675;
  51871. t['Yacute'] = 556;
  51872. t['Acircumflex'] = 611;
  51873. t['aacute'] = 500;
  51874. t['Ucircumflex'] = 722;
  51875. t['yacute'] = 444;
  51876. t['scommaaccent'] = 389;
  51877. t['ecircumflex'] = 444;
  51878. t['Uring'] = 722;
  51879. t['Udieresis'] = 722;
  51880. t['aogonek'] = 500;
  51881. t['Uacute'] = 722;
  51882. t['uogonek'] = 500;
  51883. t['Edieresis'] = 611;
  51884. t['Dcroat'] = 722;
  51885. t['commaaccent'] = 250;
  51886. t['copyright'] = 760;
  51887. t['Emacron'] = 611;
  51888. t['ccaron'] = 444;
  51889. t['aring'] = 500;
  51890. t['Ncommaaccent'] = 667;
  51891. t['lacute'] = 278;
  51892. t['agrave'] = 500;
  51893. t['Tcommaaccent'] = 556;
  51894. t['Cacute'] = 667;
  51895. t['atilde'] = 500;
  51896. t['Edotaccent'] = 611;
  51897. t['scaron'] = 389;
  51898. t['scedilla'] = 389;
  51899. t['iacute'] = 278;
  51900. t['lozenge'] = 471;
  51901. t['Rcaron'] = 611;
  51902. t['Gcommaaccent'] = 722;
  51903. t['ucircumflex'] = 500;
  51904. t['acircumflex'] = 500;
  51905. t['Amacron'] = 611;
  51906. t['rcaron'] = 389;
  51907. t['ccedilla'] = 444;
  51908. t['Zdotaccent'] = 556;
  51909. t['Thorn'] = 611;
  51910. t['Omacron'] = 722;
  51911. t['Racute'] = 611;
  51912. t['Sacute'] = 500;
  51913. t['dcaron'] = 544;
  51914. t['Umacron'] = 722;
  51915. t['uring'] = 500;
  51916. t['threesuperior'] = 300;
  51917. t['Ograve'] = 722;
  51918. t['Agrave'] = 611;
  51919. t['Abreve'] = 611;
  51920. t['multiply'] = 675;
  51921. t['uacute'] = 500;
  51922. t['Tcaron'] = 556;
  51923. t['partialdiff'] = 476;
  51924. t['ydieresis'] = 444;
  51925. t['Nacute'] = 667;
  51926. t['icircumflex'] = 278;
  51927. t['Ecircumflex'] = 611;
  51928. t['adieresis'] = 500;
  51929. t['edieresis'] = 444;
  51930. t['cacute'] = 444;
  51931. t['nacute'] = 500;
  51932. t['umacron'] = 500;
  51933. t['Ncaron'] = 667;
  51934. t['Iacute'] = 333;
  51935. t['plusminus'] = 675;
  51936. t['brokenbar'] = 275;
  51937. t['registered'] = 760;
  51938. t['Gbreve'] = 722;
  51939. t['Idotaccent'] = 333;
  51940. t['summation'] = 600;
  51941. t['Egrave'] = 611;
  51942. t['racute'] = 389;
  51943. t['omacron'] = 500;
  51944. t['Zacute'] = 556;
  51945. t['Zcaron'] = 556;
  51946. t['greaterequal'] = 549;
  51947. t['Eth'] = 722;
  51948. t['Ccedilla'] = 667;
  51949. t['lcommaaccent'] = 278;
  51950. t['tcaron'] = 300;
  51951. t['eogonek'] = 444;
  51952. t['Uogonek'] = 722;
  51953. t['Aacute'] = 611;
  51954. t['Adieresis'] = 611;
  51955. t['egrave'] = 444;
  51956. t['zacute'] = 389;
  51957. t['iogonek'] = 278;
  51958. t['Oacute'] = 722;
  51959. t['oacute'] = 500;
  51960. t['amacron'] = 500;
  51961. t['sacute'] = 389;
  51962. t['idieresis'] = 278;
  51963. t['Ocircumflex'] = 722;
  51964. t['Ugrave'] = 722;
  51965. t['Delta'] = 612;
  51966. t['thorn'] = 500;
  51967. t['twosuperior'] = 300;
  51968. t['Odieresis'] = 722;
  51969. t['mu'] = 500;
  51970. t['igrave'] = 278;
  51971. t['ohungarumlaut'] = 500;
  51972. t['Eogonek'] = 611;
  51973. t['dcroat'] = 500;
  51974. t['threequarters'] = 750;
  51975. t['Scedilla'] = 500;
  51976. t['lcaron'] = 300;
  51977. t['Kcommaaccent'] = 667;
  51978. t['Lacute'] = 556;
  51979. t['trademark'] = 980;
  51980. t['edotaccent'] = 444;
  51981. t['Igrave'] = 333;
  51982. t['Imacron'] = 333;
  51983. t['Lcaron'] = 611;
  51984. t['onehalf'] = 750;
  51985. t['lessequal'] = 549;
  51986. t['ocircumflex'] = 500;
  51987. t['ntilde'] = 500;
  51988. t['Uhungarumlaut'] = 722;
  51989. t['Eacute'] = 611;
  51990. t['emacron'] = 444;
  51991. t['gbreve'] = 500;
  51992. t['onequarter'] = 750;
  51993. t['Scaron'] = 500;
  51994. t['Scommaaccent'] = 500;
  51995. t['Ohungarumlaut'] = 722;
  51996. t['degree'] = 400;
  51997. t['ograve'] = 500;
  51998. t['Ccaron'] = 667;
  51999. t['ugrave'] = 500;
  52000. t['radical'] = 453;
  52001. t['Dcaron'] = 722;
  52002. t['rcommaaccent'] = 389;
  52003. t['Ntilde'] = 667;
  52004. t['otilde'] = 500;
  52005. t['Rcommaaccent'] = 611;
  52006. t['Lcommaaccent'] = 556;
  52007. t['Atilde'] = 611;
  52008. t['Aogonek'] = 611;
  52009. t['Aring'] = 611;
  52010. t['Otilde'] = 722;
  52011. t['zdotaccent'] = 389;
  52012. t['Ecaron'] = 611;
  52013. t['Iogonek'] = 333;
  52014. t['kcommaaccent'] = 444;
  52015. t['minus'] = 675;
  52016. t['Icircumflex'] = 333;
  52017. t['ncaron'] = 500;
  52018. t['tcommaaccent'] = 278;
  52019. t['logicalnot'] = 675;
  52020. t['odieresis'] = 500;
  52021. t['udieresis'] = 500;
  52022. t['notequal'] = 549;
  52023. t['gcommaaccent'] = 500;
  52024. t['eth'] = 500;
  52025. t['zcaron'] = 389;
  52026. t['ncommaaccent'] = 500;
  52027. t['onesuperior'] = 300;
  52028. t['imacron'] = 278;
  52029. t['Euro'] = 500;
  52030. });
  52031. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  52032. t['space'] = 278;
  52033. t['a1'] = 974;
  52034. t['a2'] = 961;
  52035. t['a202'] = 974;
  52036. t['a3'] = 980;
  52037. t['a4'] = 719;
  52038. t['a5'] = 789;
  52039. t['a119'] = 790;
  52040. t['a118'] = 791;
  52041. t['a117'] = 690;
  52042. t['a11'] = 960;
  52043. t['a12'] = 939;
  52044. t['a13'] = 549;
  52045. t['a14'] = 855;
  52046. t['a15'] = 911;
  52047. t['a16'] = 933;
  52048. t['a105'] = 911;
  52049. t['a17'] = 945;
  52050. t['a18'] = 974;
  52051. t['a19'] = 755;
  52052. t['a20'] = 846;
  52053. t['a21'] = 762;
  52054. t['a22'] = 761;
  52055. t['a23'] = 571;
  52056. t['a24'] = 677;
  52057. t['a25'] = 763;
  52058. t['a26'] = 760;
  52059. t['a27'] = 759;
  52060. t['a28'] = 754;
  52061. t['a6'] = 494;
  52062. t['a7'] = 552;
  52063. t['a8'] = 537;
  52064. t['a9'] = 577;
  52065. t['a10'] = 692;
  52066. t['a29'] = 786;
  52067. t['a30'] = 788;
  52068. t['a31'] = 788;
  52069. t['a32'] = 790;
  52070. t['a33'] = 793;
  52071. t['a34'] = 794;
  52072. t['a35'] = 816;
  52073. t['a36'] = 823;
  52074. t['a37'] = 789;
  52075. t['a38'] = 841;
  52076. t['a39'] = 823;
  52077. t['a40'] = 833;
  52078. t['a41'] = 816;
  52079. t['a42'] = 831;
  52080. t['a43'] = 923;
  52081. t['a44'] = 744;
  52082. t['a45'] = 723;
  52083. t['a46'] = 749;
  52084. t['a47'] = 790;
  52085. t['a48'] = 792;
  52086. t['a49'] = 695;
  52087. t['a50'] = 776;
  52088. t['a51'] = 768;
  52089. t['a52'] = 792;
  52090. t['a53'] = 759;
  52091. t['a54'] = 707;
  52092. t['a55'] = 708;
  52093. t['a56'] = 682;
  52094. t['a57'] = 701;
  52095. t['a58'] = 826;
  52096. t['a59'] = 815;
  52097. t['a60'] = 789;
  52098. t['a61'] = 789;
  52099. t['a62'] = 707;
  52100. t['a63'] = 687;
  52101. t['a64'] = 696;
  52102. t['a65'] = 689;
  52103. t['a66'] = 786;
  52104. t['a67'] = 787;
  52105. t['a68'] = 713;
  52106. t['a69'] = 791;
  52107. t['a70'] = 785;
  52108. t['a71'] = 791;
  52109. t['a72'] = 873;
  52110. t['a73'] = 761;
  52111. t['a74'] = 762;
  52112. t['a203'] = 762;
  52113. t['a75'] = 759;
  52114. t['a204'] = 759;
  52115. t['a76'] = 892;
  52116. t['a77'] = 892;
  52117. t['a78'] = 788;
  52118. t['a79'] = 784;
  52119. t['a81'] = 438;
  52120. t['a82'] = 138;
  52121. t['a83'] = 277;
  52122. t['a84'] = 415;
  52123. t['a97'] = 392;
  52124. t['a98'] = 392;
  52125. t['a99'] = 668;
  52126. t['a100'] = 668;
  52127. t['a89'] = 390;
  52128. t['a90'] = 390;
  52129. t['a93'] = 317;
  52130. t['a94'] = 317;
  52131. t['a91'] = 276;
  52132. t['a92'] = 276;
  52133. t['a205'] = 509;
  52134. t['a85'] = 509;
  52135. t['a206'] = 410;
  52136. t['a86'] = 410;
  52137. t['a87'] = 234;
  52138. t['a88'] = 234;
  52139. t['a95'] = 334;
  52140. t['a96'] = 334;
  52141. t['a101'] = 732;
  52142. t['a102'] = 544;
  52143. t['a103'] = 544;
  52144. t['a104'] = 910;
  52145. t['a106'] = 667;
  52146. t['a107'] = 760;
  52147. t['a108'] = 760;
  52148. t['a112'] = 776;
  52149. t['a111'] = 595;
  52150. t['a110'] = 694;
  52151. t['a109'] = 626;
  52152. t['a120'] = 788;
  52153. t['a121'] = 788;
  52154. t['a122'] = 788;
  52155. t['a123'] = 788;
  52156. t['a124'] = 788;
  52157. t['a125'] = 788;
  52158. t['a126'] = 788;
  52159. t['a127'] = 788;
  52160. t['a128'] = 788;
  52161. t['a129'] = 788;
  52162. t['a130'] = 788;
  52163. t['a131'] = 788;
  52164. t['a132'] = 788;
  52165. t['a133'] = 788;
  52166. t['a134'] = 788;
  52167. t['a135'] = 788;
  52168. t['a136'] = 788;
  52169. t['a137'] = 788;
  52170. t['a138'] = 788;
  52171. t['a139'] = 788;
  52172. t['a140'] = 788;
  52173. t['a141'] = 788;
  52174. t['a142'] = 788;
  52175. t['a143'] = 788;
  52176. t['a144'] = 788;
  52177. t['a145'] = 788;
  52178. t['a146'] = 788;
  52179. t['a147'] = 788;
  52180. t['a148'] = 788;
  52181. t['a149'] = 788;
  52182. t['a150'] = 788;
  52183. t['a151'] = 788;
  52184. t['a152'] = 788;
  52185. t['a153'] = 788;
  52186. t['a154'] = 788;
  52187. t['a155'] = 788;
  52188. t['a156'] = 788;
  52189. t['a157'] = 788;
  52190. t['a158'] = 788;
  52191. t['a159'] = 788;
  52192. t['a160'] = 894;
  52193. t['a161'] = 838;
  52194. t['a163'] = 1016;
  52195. t['a164'] = 458;
  52196. t['a196'] = 748;
  52197. t['a165'] = 924;
  52198. t['a192'] = 748;
  52199. t['a166'] = 918;
  52200. t['a167'] = 927;
  52201. t['a168'] = 928;
  52202. t['a169'] = 928;
  52203. t['a170'] = 834;
  52204. t['a171'] = 873;
  52205. t['a172'] = 828;
  52206. t['a173'] = 924;
  52207. t['a162'] = 924;
  52208. t['a174'] = 917;
  52209. t['a175'] = 930;
  52210. t['a176'] = 931;
  52211. t['a177'] = 463;
  52212. t['a178'] = 883;
  52213. t['a179'] = 836;
  52214. t['a193'] = 836;
  52215. t['a180'] = 867;
  52216. t['a199'] = 867;
  52217. t['a181'] = 696;
  52218. t['a200'] = 696;
  52219. t['a182'] = 874;
  52220. t['a201'] = 874;
  52221. t['a183'] = 760;
  52222. t['a184'] = 946;
  52223. t['a197'] = 771;
  52224. t['a185'] = 865;
  52225. t['a194'] = 771;
  52226. t['a198'] = 888;
  52227. t['a186'] = 967;
  52228. t['a195'] = 888;
  52229. t['a187'] = 831;
  52230. t['a188'] = 873;
  52231. t['a189'] = 927;
  52232. t['a190'] = 970;
  52233. t['a191'] = 918;
  52234. });
  52235. });
  52236. exports.getMetrics = getMetrics;
  52237. /***/ }),
  52238. /* 38 */
  52239. /***/ (function(module, exports, __w_pdfjs_require__) {
  52240. "use strict";
  52241. var sharedUtil = __w_pdfjs_require__(0);
  52242. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  52243. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  52244. var MASK_HIGH = 0xffff0000;
  52245. var MASK_LOW = 0xffff;
  52246. function MurmurHash3_64(seed) {
  52247. var SEED = 0xc3d2e1f0;
  52248. this.h1 = seed ? seed & 0xffffffff : SEED;
  52249. this.h2 = seed ? seed & 0xffffffff : SEED;
  52250. }
  52251. var alwaysUseUint32ArrayView = false;
  52252. try {
  52253. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  52254. } catch (e) {
  52255. alwaysUseUint32ArrayView = true;
  52256. }
  52257. MurmurHash3_64.prototype = {
  52258. update: function MurmurHash3_64_update(input) {
  52259. var useUint32ArrayView = alwaysUseUint32ArrayView;
  52260. var i;
  52261. if (typeof input === 'string') {
  52262. var data = new Uint8Array(input.length * 2);
  52263. var length = 0;
  52264. for (i = 0; i < input.length; i++) {
  52265. var code = input.charCodeAt(i);
  52266. if (code <= 0xff) {
  52267. data[length++] = code;
  52268. } else {
  52269. data[length++] = code >>> 8;
  52270. data[length++] = code & 0xff;
  52271. }
  52272. }
  52273. } else if (input instanceof Uint8Array) {
  52274. data = input;
  52275. length = data.length;
  52276. } else if (typeof input === 'object' && 'length' in input) {
  52277. data = input;
  52278. length = data.length;
  52279. useUint32ArrayView = true;
  52280. } else {
  52281. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  52282. }
  52283. var blockCounts = length >> 2;
  52284. var tailLength = length - blockCounts * 4;
  52285. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  52286. var k1 = 0;
  52287. var k2 = 0;
  52288. var h1 = this.h1;
  52289. var h2 = this.h2;
  52290. var C1 = 0xcc9e2d51;
  52291. var C2 = 0x1b873593;
  52292. var C1_LOW = C1 & MASK_LOW;
  52293. var C2_LOW = C2 & MASK_LOW;
  52294. for (i = 0; i < blockCounts; i++) {
  52295. if (i & 1) {
  52296. k1 = dataUint32[i];
  52297. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  52298. k1 = k1 << 15 | k1 >>> 17;
  52299. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  52300. h1 ^= k1;
  52301. h1 = h1 << 13 | h1 >>> 19;
  52302. h1 = h1 * 5 + 0xe6546b64;
  52303. } else {
  52304. k2 = dataUint32[i];
  52305. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  52306. k2 = k2 << 15 | k2 >>> 17;
  52307. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  52308. h2 ^= k2;
  52309. h2 = h2 << 13 | h2 >>> 19;
  52310. h2 = h2 * 5 + 0xe6546b64;
  52311. }
  52312. }
  52313. k1 = 0;
  52314. switch (tailLength) {
  52315. case 3:
  52316. k1 ^= data[blockCounts * 4 + 2] << 16;
  52317. case 2:
  52318. k1 ^= data[blockCounts * 4 + 1] << 8;
  52319. case 1:
  52320. k1 ^= data[blockCounts * 4];
  52321. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  52322. k1 = k1 << 15 | k1 >>> 17;
  52323. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  52324. if (blockCounts & 1) {
  52325. h1 ^= k1;
  52326. } else {
  52327. h2 ^= k1;
  52328. }
  52329. }
  52330. this.h1 = h1;
  52331. this.h2 = h2;
  52332. return this;
  52333. },
  52334. hexdigest: function MurmurHash3_64_hexdigest() {
  52335. var h1 = this.h1;
  52336. var h2 = this.h2;
  52337. h1 ^= h2 >>> 1;
  52338. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  52339. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  52340. h1 ^= h2 >>> 1;
  52341. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  52342. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  52343. h1 ^= h2 >>> 1;
  52344. for (var i = 0, arr = [
  52345. h1,
  52346. h2
  52347. ], str = ''; i < arr.length; i++) {
  52348. var hex = (arr[i] >>> 0).toString(16);
  52349. while (hex.length < 8) {
  52350. hex = '0' + hex;
  52351. }
  52352. str += hex;
  52353. }
  52354. return str;
  52355. }
  52356. };
  52357. return MurmurHash3_64;
  52358. }();
  52359. exports.MurmurHash3_64 = MurmurHash3_64;
  52360. /***/ }),
  52361. /* 39 */
  52362. /***/ (function(module, exports, __w_pdfjs_require__) {
  52363. "use strict";
  52364. var sharedUtil = __w_pdfjs_require__(0);
  52365. var coreWorker = __w_pdfjs_require__(22);
  52366. var OK_RESPONSE = 200;
  52367. var PARTIAL_CONTENT_RESPONSE = 206;
  52368. function NetworkManager(url, args) {
  52369. this.url = url;
  52370. args = args || {};
  52371. this.isHttp = /^https?:/i.test(url);
  52372. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  52373. this.withCredentials = args.withCredentials || false;
  52374. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  52375. return new XMLHttpRequest();
  52376. };
  52377. this.currXhrId = 0;
  52378. this.pendingRequests = Object.create(null);
  52379. this.loadedRequests = Object.create(null);
  52380. }
  52381. function getArrayBuffer(xhr) {
  52382. var data = xhr.response;
  52383. if (typeof data !== 'string') {
  52384. return data;
  52385. }
  52386. var length = data.length;
  52387. var array = new Uint8Array(length);
  52388. for (var i = 0; i < length; i++) {
  52389. array[i] = data.charCodeAt(i) & 0xFF;
  52390. }
  52391. return array.buffer;
  52392. }
  52393. var supportsMozChunked = function supportsMozChunkedClosure() {
  52394. try {
  52395. var x = new XMLHttpRequest();
  52396. x.open('GET', 'https://example.com');
  52397. x.responseType = 'moz-chunked-arraybuffer';
  52398. return x.responseType === 'moz-chunked-arraybuffer';
  52399. } catch (e) {
  52400. return false;
  52401. }
  52402. }();
  52403. NetworkManager.prototype = {
  52404. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  52405. var args = {
  52406. begin: begin,
  52407. end: end
  52408. };
  52409. for (var prop in listeners) {
  52410. args[prop] = listeners[prop];
  52411. }
  52412. return this.request(args);
  52413. },
  52414. requestFull: function NetworkManager_requestFull(listeners) {
  52415. return this.request(listeners);
  52416. },
  52417. request: function NetworkManager_request(args) {
  52418. var xhr = this.getXhr();
  52419. var xhrId = this.currXhrId++;
  52420. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  52421. xhr.open('GET', this.url);
  52422. xhr.withCredentials = this.withCredentials;
  52423. for (var property in this.httpHeaders) {
  52424. var value = this.httpHeaders[property];
  52425. if (typeof value === 'undefined') {
  52426. continue;
  52427. }
  52428. xhr.setRequestHeader(property, value);
  52429. }
  52430. if (this.isHttp && 'begin' in args && 'end' in args) {
  52431. var rangeStr = args.begin + '-' + (args.end - 1);
  52432. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  52433. pendingRequest.expectedStatus = 206;
  52434. } else {
  52435. pendingRequest.expectedStatus = 200;
  52436. }
  52437. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  52438. if (useMozChunkedLoading) {
  52439. xhr.responseType = 'moz-chunked-arraybuffer';
  52440. pendingRequest.onProgressiveData = args.onProgressiveData;
  52441. pendingRequest.mozChunked = true;
  52442. } else {
  52443. xhr.responseType = 'arraybuffer';
  52444. }
  52445. if (args.onError) {
  52446. xhr.onerror = function (evt) {
  52447. args.onError(xhr.status);
  52448. };
  52449. }
  52450. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  52451. xhr.onprogress = this.onProgress.bind(this, xhrId);
  52452. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  52453. pendingRequest.onDone = args.onDone;
  52454. pendingRequest.onError = args.onError;
  52455. pendingRequest.onProgress = args.onProgress;
  52456. xhr.send(null);
  52457. return xhrId;
  52458. },
  52459. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  52460. var pendingRequest = this.pendingRequests[xhrId];
  52461. if (!pendingRequest) {
  52462. return;
  52463. }
  52464. if (pendingRequest.mozChunked) {
  52465. var chunk = getArrayBuffer(pendingRequest.xhr);
  52466. pendingRequest.onProgressiveData(chunk);
  52467. }
  52468. var onProgress = pendingRequest.onProgress;
  52469. if (onProgress) {
  52470. onProgress(evt);
  52471. }
  52472. },
  52473. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  52474. var pendingRequest = this.pendingRequests[xhrId];
  52475. if (!pendingRequest) {
  52476. return;
  52477. }
  52478. var xhr = pendingRequest.xhr;
  52479. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  52480. pendingRequest.onHeadersReceived();
  52481. delete pendingRequest.onHeadersReceived;
  52482. }
  52483. if (xhr.readyState !== 4) {
  52484. return;
  52485. }
  52486. if (!(xhrId in this.pendingRequests)) {
  52487. return;
  52488. }
  52489. delete this.pendingRequests[xhrId];
  52490. if (xhr.status === 0 && this.isHttp) {
  52491. if (pendingRequest.onError) {
  52492. pendingRequest.onError(xhr.status);
  52493. }
  52494. return;
  52495. }
  52496. var xhrStatus = xhr.status || OK_RESPONSE;
  52497. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  52498. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  52499. if (pendingRequest.onError) {
  52500. pendingRequest.onError(xhr.status);
  52501. }
  52502. return;
  52503. }
  52504. this.loadedRequests[xhrId] = true;
  52505. var chunk = getArrayBuffer(xhr);
  52506. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  52507. var rangeHeader = xhr.getResponseHeader('Content-Range');
  52508. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  52509. var begin = parseInt(matches[1], 10);
  52510. pendingRequest.onDone({
  52511. begin: begin,
  52512. chunk: chunk
  52513. });
  52514. } else if (pendingRequest.onProgressiveData) {
  52515. pendingRequest.onDone(null);
  52516. } else if (chunk) {
  52517. pendingRequest.onDone({
  52518. begin: 0,
  52519. chunk: chunk
  52520. });
  52521. } else if (pendingRequest.onError) {
  52522. pendingRequest.onError(xhr.status);
  52523. }
  52524. },
  52525. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  52526. for (var xhrId in this.pendingRequests) {
  52527. return true;
  52528. }
  52529. return false;
  52530. },
  52531. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  52532. return this.pendingRequests[xhrId].xhr;
  52533. },
  52534. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  52535. return !!this.pendingRequests[xhrId].onProgressiveData;
  52536. },
  52537. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  52538. return xhrId in this.pendingRequests;
  52539. },
  52540. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  52541. return xhrId in this.loadedRequests;
  52542. },
  52543. abortAllRequests: function NetworkManager_abortAllRequests() {
  52544. for (var xhrId in this.pendingRequests) {
  52545. this.abortRequest(xhrId | 0);
  52546. }
  52547. },
  52548. abortRequest: function NetworkManager_abortRequest(xhrId) {
  52549. var xhr = this.pendingRequests[xhrId].xhr;
  52550. delete this.pendingRequests[xhrId];
  52551. xhr.abort();
  52552. }
  52553. };
  52554. var assert = sharedUtil.assert;
  52555. var createPromiseCapability = sharedUtil.createPromiseCapability;
  52556. var isInt = sharedUtil.isInt;
  52557. var MissingPDFException = sharedUtil.MissingPDFException;
  52558. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  52559. function PDFNetworkStream(options) {
  52560. this._options = options;
  52561. var source = options.source;
  52562. this._manager = new NetworkManager(source.url, {
  52563. httpHeaders: source.httpHeaders,
  52564. withCredentials: source.withCredentials
  52565. });
  52566. this._rangeChunkSize = source.rangeChunkSize;
  52567. this._fullRequestReader = null;
  52568. this._rangeRequestReaders = [];
  52569. }
  52570. PDFNetworkStream.prototype = {
  52571. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  52572. var i = this._rangeRequestReaders.indexOf(reader);
  52573. if (i >= 0) {
  52574. this._rangeRequestReaders.splice(i, 1);
  52575. }
  52576. },
  52577. getFullReader: function PDFNetworkStream_getFullReader() {
  52578. assert(!this._fullRequestReader);
  52579. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  52580. return this._fullRequestReader;
  52581. },
  52582. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  52583. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  52584. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  52585. this._rangeRequestReaders.push(reader);
  52586. return reader;
  52587. },
  52588. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  52589. if (this._fullRequestReader) {
  52590. this._fullRequestReader.cancel(reason);
  52591. }
  52592. var readers = this._rangeRequestReaders.slice(0);
  52593. readers.forEach(function (reader) {
  52594. reader.cancel(reason);
  52595. });
  52596. }
  52597. };
  52598. function PDFNetworkStreamFullRequestReader(manager, options) {
  52599. this._manager = manager;
  52600. var source = options.source;
  52601. var args = {
  52602. onHeadersReceived: this._onHeadersReceived.bind(this),
  52603. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  52604. onDone: this._onDone.bind(this),
  52605. onError: this._onError.bind(this),
  52606. onProgress: this._onProgress.bind(this)
  52607. };
  52608. this._url = source.url;
  52609. this._fullRequestId = manager.requestFull(args);
  52610. this._headersReceivedCapability = createPromiseCapability();
  52611. this._disableRange = options.disableRange || false;
  52612. this._contentLength = source.length;
  52613. this._rangeChunkSize = source.rangeChunkSize;
  52614. if (!this._rangeChunkSize && !this._disableRange) {
  52615. this._disableRange = true;
  52616. }
  52617. this._isStreamingSupported = false;
  52618. this._isRangeSupported = false;
  52619. this._cachedChunks = [];
  52620. this._requests = [];
  52621. this._done = false;
  52622. this._storedError = undefined;
  52623. this.onProgress = null;
  52624. }
  52625. PDFNetworkStreamFullRequestReader.prototype = {
  52626. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  52627. if (this._disableRange) {
  52628. return false;
  52629. }
  52630. var networkManager = this._manager;
  52631. if (!networkManager.isHttp) {
  52632. return false;
  52633. }
  52634. var fullRequestXhrId = this._fullRequestId;
  52635. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  52636. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  52637. return false;
  52638. }
  52639. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  52640. if (contentEncoding !== 'identity') {
  52641. return false;
  52642. }
  52643. var length = fullRequestXhr.getResponseHeader('Content-Length');
  52644. length = parseInt(length, 10);
  52645. if (!isInt(length)) {
  52646. return false;
  52647. }
  52648. this._contentLength = length;
  52649. if (length <= 2 * this._rangeChunkSize) {
  52650. return false;
  52651. }
  52652. return true;
  52653. },
  52654. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  52655. if (this._validateRangeRequestCapabilities()) {
  52656. this._isRangeSupported = true;
  52657. }
  52658. var networkManager = this._manager;
  52659. var fullRequestXhrId = this._fullRequestId;
  52660. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  52661. this._isStreamingSupported = true;
  52662. } else if (this._isRangeSupported) {
  52663. networkManager.abortRequest(fullRequestXhrId);
  52664. }
  52665. this._headersReceivedCapability.resolve();
  52666. },
  52667. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  52668. if (this._requests.length > 0) {
  52669. var requestCapability = this._requests.shift();
  52670. requestCapability.resolve({
  52671. value: chunk,
  52672. done: false
  52673. });
  52674. } else {
  52675. this._cachedChunks.push(chunk);
  52676. }
  52677. },
  52678. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  52679. if (args) {
  52680. this._onProgressiveData(args.chunk);
  52681. }
  52682. this._done = true;
  52683. if (this._cachedChunks.length > 0) {
  52684. return;
  52685. }
  52686. this._requests.forEach(function (requestCapability) {
  52687. requestCapability.resolve({
  52688. value: undefined,
  52689. done: true
  52690. });
  52691. });
  52692. this._requests = [];
  52693. },
  52694. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  52695. var url = this._url;
  52696. var exception;
  52697. if (status === 404 || status === 0 && /^file:/.test(url)) {
  52698. exception = new MissingPDFException('Missing PDF "' + url + '".');
  52699. } else {
  52700. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  52701. }
  52702. this._storedError = exception;
  52703. this._headersReceivedCapability.reject(exception);
  52704. this._requests.forEach(function (requestCapability) {
  52705. requestCapability.reject(exception);
  52706. });
  52707. this._requests = [];
  52708. this._cachedChunks = [];
  52709. },
  52710. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  52711. if (this.onProgress) {
  52712. this.onProgress({
  52713. loaded: data.loaded,
  52714. total: data.lengthComputable ? data.total : this._contentLength
  52715. });
  52716. }
  52717. },
  52718. get isRangeSupported() {
  52719. return this._isRangeSupported;
  52720. },
  52721. get isStreamingSupported() {
  52722. return this._isStreamingSupported;
  52723. },
  52724. get contentLength() {
  52725. return this._contentLength;
  52726. },
  52727. get headersReady() {
  52728. return this._headersReceivedCapability.promise;
  52729. },
  52730. read: function PDFNetworkStreamFullRequestReader_read() {
  52731. if (this._storedError) {
  52732. return Promise.reject(this._storedError);
  52733. }
  52734. if (this._cachedChunks.length > 0) {
  52735. var chunk = this._cachedChunks.shift();
  52736. return Promise.resolve(chunk);
  52737. }
  52738. if (this._done) {
  52739. return Promise.resolve({
  52740. value: undefined,
  52741. done: true
  52742. });
  52743. }
  52744. var requestCapability = createPromiseCapability();
  52745. this._requests.push(requestCapability);
  52746. return requestCapability.promise;
  52747. },
  52748. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  52749. this._done = true;
  52750. this._headersReceivedCapability.reject(reason);
  52751. this._requests.forEach(function (requestCapability) {
  52752. requestCapability.resolve({
  52753. value: undefined,
  52754. done: true
  52755. });
  52756. });
  52757. this._requests = [];
  52758. if (this._manager.isPendingRequest(this._fullRequestId)) {
  52759. this._manager.abortRequest(this._fullRequestId);
  52760. }
  52761. this._fullRequestReader = null;
  52762. }
  52763. };
  52764. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  52765. this._manager = manager;
  52766. var args = {
  52767. onDone: this._onDone.bind(this),
  52768. onProgress: this._onProgress.bind(this)
  52769. };
  52770. this._requestId = manager.requestRange(begin, end, args);
  52771. this._requests = [];
  52772. this._queuedChunk = null;
  52773. this._done = false;
  52774. this.onProgress = null;
  52775. this.onClosed = null;
  52776. }
  52777. PDFNetworkStreamRangeRequestReader.prototype = {
  52778. _close: function PDFNetworkStreamRangeRequestReader_close() {
  52779. if (this.onClosed) {
  52780. this.onClosed(this);
  52781. }
  52782. },
  52783. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  52784. var chunk = data.chunk;
  52785. if (this._requests.length > 0) {
  52786. var requestCapability = this._requests.shift();
  52787. requestCapability.resolve({
  52788. value: chunk,
  52789. done: false
  52790. });
  52791. } else {
  52792. this._queuedChunk = chunk;
  52793. }
  52794. this._done = true;
  52795. this._requests.forEach(function (requestCapability) {
  52796. requestCapability.resolve({
  52797. value: undefined,
  52798. done: true
  52799. });
  52800. });
  52801. this._requests = [];
  52802. this._close();
  52803. },
  52804. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  52805. if (!this.isStreamingSupported && this.onProgress) {
  52806. this.onProgress({ loaded: evt.loaded });
  52807. }
  52808. },
  52809. get isStreamingSupported() {
  52810. return false;
  52811. },
  52812. read: function PDFNetworkStreamRangeRequestReader_read() {
  52813. if (this._queuedChunk !== null) {
  52814. var chunk = this._queuedChunk;
  52815. this._queuedChunk = null;
  52816. return Promise.resolve({
  52817. value: chunk,
  52818. done: false
  52819. });
  52820. }
  52821. if (this._done) {
  52822. return Promise.resolve({
  52823. value: undefined,
  52824. done: true
  52825. });
  52826. }
  52827. var requestCapability = createPromiseCapability();
  52828. this._requests.push(requestCapability);
  52829. return requestCapability.promise;
  52830. },
  52831. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  52832. this._done = true;
  52833. this._requests.forEach(function (requestCapability) {
  52834. requestCapability.resolve({
  52835. value: undefined,
  52836. done: true
  52837. });
  52838. });
  52839. this._requests = [];
  52840. if (this._manager.isPendingRequest(this._requestId)) {
  52841. this._manager.abortRequest(this._requestId);
  52842. }
  52843. this._close();
  52844. }
  52845. };
  52846. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  52847. exports.PDFNetworkStream = PDFNetworkStream;
  52848. exports.NetworkManager = NetworkManager;
  52849. /***/ }),
  52850. /* 40 */
  52851. /***/ (function(module, exports, __w_pdfjs_require__) {
  52852. "use strict";
  52853. var sharedUtil = __w_pdfjs_require__(0);
  52854. var corePrimitives = __w_pdfjs_require__(1);
  52855. var coreFunction = __w_pdfjs_require__(7);
  52856. var coreColorSpace = __w_pdfjs_require__(4);
  52857. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  52858. var MissingDataException = sharedUtil.MissingDataException;
  52859. var Util = sharedUtil.Util;
  52860. var assert = sharedUtil.assert;
  52861. var error = sharedUtil.error;
  52862. var info = sharedUtil.info;
  52863. var warn = sharedUtil.warn;
  52864. var isStream = corePrimitives.isStream;
  52865. var PDFFunction = coreFunction.PDFFunction;
  52866. var ColorSpace = coreColorSpace.ColorSpace;
  52867. var ShadingType = {
  52868. FUNCTION_BASED: 1,
  52869. AXIAL: 2,
  52870. RADIAL: 3,
  52871. FREE_FORM_MESH: 4,
  52872. LATTICE_FORM_MESH: 5,
  52873. COONS_PATCH_MESH: 6,
  52874. TENSOR_PATCH_MESH: 7
  52875. };
  52876. var Pattern = function PatternClosure() {
  52877. function Pattern() {
  52878. error('should not call Pattern constructor');
  52879. }
  52880. Pattern.prototype = {
  52881. getPattern: function Pattern_getPattern(ctx) {
  52882. error('Should not call Pattern.getStyle: ' + ctx);
  52883. }
  52884. };
  52885. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  52886. var dict = isStream(shading) ? shading.dict : shading;
  52887. var type = dict.get('ShadingType');
  52888. try {
  52889. switch (type) {
  52890. case ShadingType.AXIAL:
  52891. case ShadingType.RADIAL:
  52892. return new Shadings.RadialAxial(dict, matrix, xref, res);
  52893. case ShadingType.FREE_FORM_MESH:
  52894. case ShadingType.LATTICE_FORM_MESH:
  52895. case ShadingType.COONS_PATCH_MESH:
  52896. case ShadingType.TENSOR_PATCH_MESH:
  52897. return new Shadings.Mesh(shading, matrix, xref, res);
  52898. default:
  52899. throw new Error('Unsupported ShadingType: ' + type);
  52900. }
  52901. } catch (ex) {
  52902. if (ex instanceof MissingDataException) {
  52903. throw ex;
  52904. }
  52905. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  52906. warn(ex);
  52907. return new Shadings.Dummy();
  52908. }
  52909. };
  52910. return Pattern;
  52911. }();
  52912. var Shadings = {};
  52913. Shadings.SMALL_NUMBER = 1e-6;
  52914. Shadings.RadialAxial = function RadialAxialClosure() {
  52915. function RadialAxial(dict, matrix, xref, res) {
  52916. this.matrix = matrix;
  52917. this.coordsArr = dict.getArray('Coords');
  52918. this.shadingType = dict.get('ShadingType');
  52919. this.type = 'Pattern';
  52920. var cs = dict.get('ColorSpace', 'CS');
  52921. cs = ColorSpace.parse(cs, xref, res);
  52922. this.cs = cs;
  52923. var t0 = 0.0, t1 = 1.0;
  52924. if (dict.has('Domain')) {
  52925. var domainArr = dict.getArray('Domain');
  52926. t0 = domainArr[0];
  52927. t1 = domainArr[1];
  52928. }
  52929. var extendStart = false, extendEnd = false;
  52930. if (dict.has('Extend')) {
  52931. var extendArr = dict.getArray('Extend');
  52932. extendStart = extendArr[0];
  52933. extendEnd = extendArr[1];
  52934. }
  52935. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  52936. var x1 = this.coordsArr[0];
  52937. var y1 = this.coordsArr[1];
  52938. var r1 = this.coordsArr[2];
  52939. var x2 = this.coordsArr[3];
  52940. var y2 = this.coordsArr[4];
  52941. var r2 = this.coordsArr[5];
  52942. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  52943. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  52944. warn('Unsupported radial gradient.');
  52945. }
  52946. }
  52947. this.extendStart = extendStart;
  52948. this.extendEnd = extendEnd;
  52949. var fnObj = dict.get('Function');
  52950. var fn = PDFFunction.parseArray(xref, fnObj);
  52951. var diff = t1 - t0;
  52952. var step = diff / 10;
  52953. var colorStops = this.colorStops = [];
  52954. if (t0 >= t1 || step <= 0) {
  52955. info('Bad shading domain.');
  52956. return;
  52957. }
  52958. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  52959. var rgbColor;
  52960. for (var i = t0; i <= t1; i += step) {
  52961. ratio[0] = i;
  52962. fn(ratio, 0, color, 0);
  52963. rgbColor = cs.getRgb(color, 0);
  52964. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52965. colorStops.push([
  52966. (i - t0) / diff,
  52967. cssColor
  52968. ]);
  52969. }
  52970. var background = 'transparent';
  52971. if (dict.has('Background')) {
  52972. rgbColor = cs.getRgb(dict.get('Background'), 0);
  52973. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  52974. }
  52975. if (!extendStart) {
  52976. colorStops.unshift([
  52977. 0,
  52978. background
  52979. ]);
  52980. colorStops[1][0] += Shadings.SMALL_NUMBER;
  52981. }
  52982. if (!extendEnd) {
  52983. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  52984. colorStops.push([
  52985. 1,
  52986. background
  52987. ]);
  52988. }
  52989. this.colorStops = colorStops;
  52990. }
  52991. RadialAxial.prototype = {
  52992. getIR: function RadialAxial_getIR() {
  52993. var coordsArr = this.coordsArr;
  52994. var shadingType = this.shadingType;
  52995. var type, p0, p1, r0, r1;
  52996. if (shadingType === ShadingType.AXIAL) {
  52997. p0 = [
  52998. coordsArr[0],
  52999. coordsArr[1]
  53000. ];
  53001. p1 = [
  53002. coordsArr[2],
  53003. coordsArr[3]
  53004. ];
  53005. r0 = null;
  53006. r1 = null;
  53007. type = 'axial';
  53008. } else if (shadingType === ShadingType.RADIAL) {
  53009. p0 = [
  53010. coordsArr[0],
  53011. coordsArr[1]
  53012. ];
  53013. p1 = [
  53014. coordsArr[3],
  53015. coordsArr[4]
  53016. ];
  53017. r0 = coordsArr[2];
  53018. r1 = coordsArr[5];
  53019. type = 'radial';
  53020. } else {
  53021. error('getPattern type unknown: ' + shadingType);
  53022. }
  53023. var matrix = this.matrix;
  53024. if (matrix) {
  53025. p0 = Util.applyTransform(p0, matrix);
  53026. p1 = Util.applyTransform(p1, matrix);
  53027. if (shadingType === ShadingType.RADIAL) {
  53028. var scale = Util.singularValueDecompose2dScale(matrix);
  53029. r0 *= scale[0];
  53030. r1 *= scale[1];
  53031. }
  53032. }
  53033. return [
  53034. 'RadialAxial',
  53035. type,
  53036. this.colorStops,
  53037. p0,
  53038. p1,
  53039. r0,
  53040. r1
  53041. ];
  53042. }
  53043. };
  53044. return RadialAxial;
  53045. }();
  53046. Shadings.Mesh = function MeshClosure() {
  53047. function MeshStreamReader(stream, context) {
  53048. this.stream = stream;
  53049. this.context = context;
  53050. this.buffer = 0;
  53051. this.bufferLength = 0;
  53052. var numComps = context.numComps;
  53053. this.tmpCompsBuf = new Float32Array(numComps);
  53054. var csNumComps = context.colorSpace.numComps;
  53055. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  53056. }
  53057. MeshStreamReader.prototype = {
  53058. get hasData() {
  53059. if (this.stream.end) {
  53060. return this.stream.pos < this.stream.end;
  53061. }
  53062. if (this.bufferLength > 0) {
  53063. return true;
  53064. }
  53065. var nextByte = this.stream.getByte();
  53066. if (nextByte < 0) {
  53067. return false;
  53068. }
  53069. this.buffer = nextByte;
  53070. this.bufferLength = 8;
  53071. return true;
  53072. },
  53073. readBits: function MeshStreamReader_readBits(n) {
  53074. var buffer = this.buffer;
  53075. var bufferLength = this.bufferLength;
  53076. if (n === 32) {
  53077. if (bufferLength === 0) {
  53078. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  53079. }
  53080. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  53081. var nextByte = this.stream.getByte();
  53082. this.buffer = nextByte & (1 << bufferLength) - 1;
  53083. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  53084. }
  53085. if (n === 8 && bufferLength === 0) {
  53086. return this.stream.getByte();
  53087. }
  53088. while (bufferLength < n) {
  53089. buffer = buffer << 8 | this.stream.getByte();
  53090. bufferLength += 8;
  53091. }
  53092. bufferLength -= n;
  53093. this.bufferLength = bufferLength;
  53094. this.buffer = buffer & (1 << bufferLength) - 1;
  53095. return buffer >> bufferLength;
  53096. },
  53097. align: function MeshStreamReader_align() {
  53098. this.buffer = 0;
  53099. this.bufferLength = 0;
  53100. },
  53101. readFlag: function MeshStreamReader_readFlag() {
  53102. return this.readBits(this.context.bitsPerFlag);
  53103. },
  53104. readCoordinate: function MeshStreamReader_readCoordinate() {
  53105. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  53106. var xi = this.readBits(bitsPerCoordinate);
  53107. var yi = this.readBits(bitsPerCoordinate);
  53108. var decode = this.context.decode;
  53109. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  53110. return [
  53111. xi * scale * (decode[1] - decode[0]) + decode[0],
  53112. yi * scale * (decode[3] - decode[2]) + decode[2]
  53113. ];
  53114. },
  53115. readComponents: function MeshStreamReader_readComponents() {
  53116. var numComps = this.context.numComps;
  53117. var bitsPerComponent = this.context.bitsPerComponent;
  53118. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  53119. var decode = this.context.decode;
  53120. var components = this.tmpCompsBuf;
  53121. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  53122. var ci = this.readBits(bitsPerComponent);
  53123. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  53124. }
  53125. var color = this.tmpCsCompsBuf;
  53126. if (this.context.colorFn) {
  53127. this.context.colorFn(components, 0, color, 0);
  53128. }
  53129. return this.context.colorSpace.getRgb(color, 0);
  53130. }
  53131. };
  53132. function decodeType4Shading(mesh, reader) {
  53133. var coords = mesh.coords;
  53134. var colors = mesh.colors;
  53135. var operators = [];
  53136. var ps = [];
  53137. var verticesLeft = 0;
  53138. while (reader.hasData) {
  53139. var f = reader.readFlag();
  53140. var coord = reader.readCoordinate();
  53141. var color = reader.readComponents();
  53142. if (verticesLeft === 0) {
  53143. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  53144. switch (f) {
  53145. case 0:
  53146. verticesLeft = 3;
  53147. break;
  53148. case 1:
  53149. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  53150. verticesLeft = 1;
  53151. break;
  53152. case 2:
  53153. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  53154. verticesLeft = 1;
  53155. break;
  53156. }
  53157. operators.push(f);
  53158. }
  53159. ps.push(coords.length);
  53160. coords.push(coord);
  53161. colors.push(color);
  53162. verticesLeft--;
  53163. reader.align();
  53164. }
  53165. mesh.figures.push({
  53166. type: 'triangles',
  53167. coords: new Int32Array(ps),
  53168. colors: new Int32Array(ps)
  53169. });
  53170. }
  53171. function decodeType5Shading(mesh, reader, verticesPerRow) {
  53172. var coords = mesh.coords;
  53173. var colors = mesh.colors;
  53174. var ps = [];
  53175. while (reader.hasData) {
  53176. var coord = reader.readCoordinate();
  53177. var color = reader.readComponents();
  53178. ps.push(coords.length);
  53179. coords.push(coord);
  53180. colors.push(color);
  53181. }
  53182. mesh.figures.push({
  53183. type: 'lattice',
  53184. coords: new Int32Array(ps),
  53185. colors: new Int32Array(ps),
  53186. verticesPerRow: verticesPerRow
  53187. });
  53188. }
  53189. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  53190. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  53191. var TRIANGLE_DENSITY = 20;
  53192. var getB = function getBClosure() {
  53193. function buildB(count) {
  53194. var lut = [];
  53195. for (var i = 0; i <= count; i++) {
  53196. var t = i / count, t_ = 1 - t;
  53197. lut.push(new Float32Array([
  53198. t_ * t_ * t_,
  53199. 3 * t * t_ * t_,
  53200. 3 * t * t * t_,
  53201. t * t * t
  53202. ]));
  53203. }
  53204. return lut;
  53205. }
  53206. var cache = [];
  53207. return function getB(count) {
  53208. if (!cache[count]) {
  53209. cache[count] = buildB(count);
  53210. }
  53211. return cache[count];
  53212. };
  53213. }();
  53214. function buildFigureFromPatch(mesh, index) {
  53215. var figure = mesh.figures[index];
  53216. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  53217. var coords = mesh.coords, colors = mesh.colors;
  53218. var pi = figure.coords;
  53219. var ci = figure.colors;
  53220. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  53221. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  53222. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  53223. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  53224. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  53225. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  53226. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  53227. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  53228. var verticesPerRow = splitXBy + 1;
  53229. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  53230. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  53231. var k = 0;
  53232. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  53233. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  53234. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  53235. for (var row = 0; row <= splitYBy; row++) {
  53236. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  53237. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  53238. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  53239. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  53240. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  53241. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  53242. for (var col = 0; col <= splitXBy; col++, k++) {
  53243. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  53244. continue;
  53245. }
  53246. var x = 0, y = 0;
  53247. var q = 0;
  53248. for (var i = 0; i <= 3; i++) {
  53249. for (var j = 0; j <= 3; j++, q++) {
  53250. var m = bRow[row][i] * bCol[col][j];
  53251. x += coords[pi[q]][0] * m;
  53252. y += coords[pi[q]][1] * m;
  53253. }
  53254. }
  53255. figureCoords[k] = coords.length;
  53256. coords.push([
  53257. x,
  53258. y
  53259. ]);
  53260. figureColors[k] = colors.length;
  53261. var newColor = new Uint8Array(3);
  53262. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  53263. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  53264. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  53265. colors.push(newColor);
  53266. }
  53267. }
  53268. figureCoords[0] = pi[0];
  53269. figureColors[0] = ci[0];
  53270. figureCoords[splitXBy] = pi[3];
  53271. figureColors[splitXBy] = ci[1];
  53272. figureCoords[verticesPerRow * splitYBy] = pi[12];
  53273. figureColors[verticesPerRow * splitYBy] = ci[2];
  53274. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  53275. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  53276. mesh.figures[index] = {
  53277. type: 'lattice',
  53278. coords: figureCoords,
  53279. colors: figureColors,
  53280. verticesPerRow: verticesPerRow
  53281. };
  53282. }
  53283. function decodeType6Shading(mesh, reader) {
  53284. var coords = mesh.coords;
  53285. var colors = mesh.colors;
  53286. var ps = new Int32Array(16);
  53287. var cs = new Int32Array(4);
  53288. while (reader.hasData) {
  53289. var f = reader.readFlag();
  53290. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  53291. var i, ii;
  53292. var pi = coords.length;
  53293. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  53294. coords.push(reader.readCoordinate());
  53295. }
  53296. var ci = colors.length;
  53297. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  53298. colors.push(reader.readComponents());
  53299. }
  53300. var tmp1, tmp2, tmp3, tmp4;
  53301. switch (f) {
  53302. case 0:
  53303. ps[12] = pi + 3;
  53304. ps[13] = pi + 4;
  53305. ps[14] = pi + 5;
  53306. ps[15] = pi + 6;
  53307. ps[8] = pi + 2;
  53308. ps[11] = pi + 7;
  53309. ps[4] = pi + 1;
  53310. ps[7] = pi + 8;
  53311. ps[0] = pi;
  53312. ps[1] = pi + 11;
  53313. ps[2] = pi + 10;
  53314. ps[3] = pi + 9;
  53315. cs[2] = ci + 1;
  53316. cs[3] = ci + 2;
  53317. cs[0] = ci;
  53318. cs[1] = ci + 3;
  53319. break;
  53320. case 1:
  53321. tmp1 = ps[12];
  53322. tmp2 = ps[13];
  53323. tmp3 = ps[14];
  53324. tmp4 = ps[15];
  53325. ps[12] = tmp4;
  53326. ps[13] = pi + 0;
  53327. ps[14] = pi + 1;
  53328. ps[15] = pi + 2;
  53329. ps[8] = tmp3;
  53330. ps[11] = pi + 3;
  53331. ps[4] = tmp2;
  53332. ps[7] = pi + 4;
  53333. ps[0] = tmp1;
  53334. ps[1] = pi + 7;
  53335. ps[2] = pi + 6;
  53336. ps[3] = pi + 5;
  53337. tmp1 = cs[2];
  53338. tmp2 = cs[3];
  53339. cs[2] = tmp2;
  53340. cs[3] = ci;
  53341. cs[0] = tmp1;
  53342. cs[1] = ci + 1;
  53343. break;
  53344. case 2:
  53345. tmp1 = ps[15];
  53346. tmp2 = ps[11];
  53347. ps[12] = ps[3];
  53348. ps[13] = pi + 0;
  53349. ps[14] = pi + 1;
  53350. ps[15] = pi + 2;
  53351. ps[8] = ps[7];
  53352. ps[11] = pi + 3;
  53353. ps[4] = tmp2;
  53354. ps[7] = pi + 4;
  53355. ps[0] = tmp1;
  53356. ps[1] = pi + 7;
  53357. ps[2] = pi + 6;
  53358. ps[3] = pi + 5;
  53359. tmp1 = cs[3];
  53360. cs[2] = cs[1];
  53361. cs[3] = ci;
  53362. cs[0] = tmp1;
  53363. cs[1] = ci + 1;
  53364. break;
  53365. case 3:
  53366. ps[12] = ps[0];
  53367. ps[13] = pi + 0;
  53368. ps[14] = pi + 1;
  53369. ps[15] = pi + 2;
  53370. ps[8] = ps[1];
  53371. ps[11] = pi + 3;
  53372. ps[4] = ps[2];
  53373. ps[7] = pi + 4;
  53374. ps[0] = ps[3];
  53375. ps[1] = pi + 7;
  53376. ps[2] = pi + 6;
  53377. ps[3] = pi + 5;
  53378. cs[2] = cs[0];
  53379. cs[3] = ci;
  53380. cs[0] = cs[1];
  53381. cs[1] = ci + 1;
  53382. break;
  53383. }
  53384. ps[5] = coords.length;
  53385. coords.push([
  53386. (-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,
  53387. (-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
  53388. ]);
  53389. ps[6] = coords.length;
  53390. coords.push([
  53391. (-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,
  53392. (-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
  53393. ]);
  53394. ps[9] = coords.length;
  53395. coords.push([
  53396. (-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,
  53397. (-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
  53398. ]);
  53399. ps[10] = coords.length;
  53400. coords.push([
  53401. (-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,
  53402. (-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
  53403. ]);
  53404. mesh.figures.push({
  53405. type: 'patch',
  53406. coords: new Int32Array(ps),
  53407. colors: new Int32Array(cs)
  53408. });
  53409. }
  53410. }
  53411. function decodeType7Shading(mesh, reader) {
  53412. var coords = mesh.coords;
  53413. var colors = mesh.colors;
  53414. var ps = new Int32Array(16);
  53415. var cs = new Int32Array(4);
  53416. while (reader.hasData) {
  53417. var f = reader.readFlag();
  53418. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  53419. var i, ii;
  53420. var pi = coords.length;
  53421. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  53422. coords.push(reader.readCoordinate());
  53423. }
  53424. var ci = colors.length;
  53425. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  53426. colors.push(reader.readComponents());
  53427. }
  53428. var tmp1, tmp2, tmp3, tmp4;
  53429. switch (f) {
  53430. case 0:
  53431. ps[12] = pi + 3;
  53432. ps[13] = pi + 4;
  53433. ps[14] = pi + 5;
  53434. ps[15] = pi + 6;
  53435. ps[8] = pi + 2;
  53436. ps[9] = pi + 13;
  53437. ps[10] = pi + 14;
  53438. ps[11] = pi + 7;
  53439. ps[4] = pi + 1;
  53440. ps[5] = pi + 12;
  53441. ps[6] = pi + 15;
  53442. ps[7] = pi + 8;
  53443. ps[0] = pi;
  53444. ps[1] = pi + 11;
  53445. ps[2] = pi + 10;
  53446. ps[3] = pi + 9;
  53447. cs[2] = ci + 1;
  53448. cs[3] = ci + 2;
  53449. cs[0] = ci;
  53450. cs[1] = ci + 3;
  53451. break;
  53452. case 1:
  53453. tmp1 = ps[12];
  53454. tmp2 = ps[13];
  53455. tmp3 = ps[14];
  53456. tmp4 = ps[15];
  53457. ps[12] = tmp4;
  53458. ps[13] = pi + 0;
  53459. ps[14] = pi + 1;
  53460. ps[15] = pi + 2;
  53461. ps[8] = tmp3;
  53462. ps[9] = pi + 9;
  53463. ps[10] = pi + 10;
  53464. ps[11] = pi + 3;
  53465. ps[4] = tmp2;
  53466. ps[5] = pi + 8;
  53467. ps[6] = pi + 11;
  53468. ps[7] = pi + 4;
  53469. ps[0] = tmp1;
  53470. ps[1] = pi + 7;
  53471. ps[2] = pi + 6;
  53472. ps[3] = pi + 5;
  53473. tmp1 = cs[2];
  53474. tmp2 = cs[3];
  53475. cs[2] = tmp2;
  53476. cs[3] = ci;
  53477. cs[0] = tmp1;
  53478. cs[1] = ci + 1;
  53479. break;
  53480. case 2:
  53481. tmp1 = ps[15];
  53482. tmp2 = ps[11];
  53483. ps[12] = ps[3];
  53484. ps[13] = pi + 0;
  53485. ps[14] = pi + 1;
  53486. ps[15] = pi + 2;
  53487. ps[8] = ps[7];
  53488. ps[9] = pi + 9;
  53489. ps[10] = pi + 10;
  53490. ps[11] = pi + 3;
  53491. ps[4] = tmp2;
  53492. ps[5] = pi + 8;
  53493. ps[6] = pi + 11;
  53494. ps[7] = pi + 4;
  53495. ps[0] = tmp1;
  53496. ps[1] = pi + 7;
  53497. ps[2] = pi + 6;
  53498. ps[3] = pi + 5;
  53499. tmp1 = cs[3];
  53500. cs[2] = cs[1];
  53501. cs[3] = ci;
  53502. cs[0] = tmp1;
  53503. cs[1] = ci + 1;
  53504. break;
  53505. case 3:
  53506. ps[12] = ps[0];
  53507. ps[13] = pi + 0;
  53508. ps[14] = pi + 1;
  53509. ps[15] = pi + 2;
  53510. ps[8] = ps[1];
  53511. ps[9] = pi + 9;
  53512. ps[10] = pi + 10;
  53513. ps[11] = pi + 3;
  53514. ps[4] = ps[2];
  53515. ps[5] = pi + 8;
  53516. ps[6] = pi + 11;
  53517. ps[7] = pi + 4;
  53518. ps[0] = ps[3];
  53519. ps[1] = pi + 7;
  53520. ps[2] = pi + 6;
  53521. ps[3] = pi + 5;
  53522. cs[2] = cs[0];
  53523. cs[3] = ci;
  53524. cs[0] = cs[1];
  53525. cs[1] = ci + 1;
  53526. break;
  53527. }
  53528. mesh.figures.push({
  53529. type: 'patch',
  53530. coords: new Int32Array(ps),
  53531. colors: new Int32Array(cs)
  53532. });
  53533. }
  53534. }
  53535. function updateBounds(mesh) {
  53536. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  53537. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  53538. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  53539. minX = minX > x ? x : minX;
  53540. minY = minY > y ? y : minY;
  53541. maxX = maxX < x ? x : maxX;
  53542. maxY = maxY < y ? y : maxY;
  53543. }
  53544. mesh.bounds = [
  53545. minX,
  53546. minY,
  53547. maxX,
  53548. maxY
  53549. ];
  53550. }
  53551. function packData(mesh) {
  53552. var i, ii, j, jj;
  53553. var coords = mesh.coords;
  53554. var coordsPacked = new Float32Array(coords.length * 2);
  53555. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  53556. var xy = coords[i];
  53557. coordsPacked[j++] = xy[0];
  53558. coordsPacked[j++] = xy[1];
  53559. }
  53560. mesh.coords = coordsPacked;
  53561. var colors = mesh.colors;
  53562. var colorsPacked = new Uint8Array(colors.length * 3);
  53563. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  53564. var c = colors[i];
  53565. colorsPacked[j++] = c[0];
  53566. colorsPacked[j++] = c[1];
  53567. colorsPacked[j++] = c[2];
  53568. }
  53569. mesh.colors = colorsPacked;
  53570. var figures = mesh.figures;
  53571. for (i = 0, ii = figures.length; i < ii; i++) {
  53572. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  53573. for (j = 0, jj = ps.length; j < jj; j++) {
  53574. ps[j] *= 2;
  53575. cs[j] *= 3;
  53576. }
  53577. }
  53578. }
  53579. function Mesh(stream, matrix, xref, res) {
  53580. assert(isStream(stream), 'Mesh data is not a stream');
  53581. var dict = stream.dict;
  53582. this.matrix = matrix;
  53583. this.shadingType = dict.get('ShadingType');
  53584. this.type = 'Pattern';
  53585. this.bbox = dict.getArray('BBox');
  53586. var cs = dict.get('ColorSpace', 'CS');
  53587. cs = ColorSpace.parse(cs, xref, res);
  53588. this.cs = cs;
  53589. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  53590. var fnObj = dict.get('Function');
  53591. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  53592. this.coords = [];
  53593. this.colors = [];
  53594. this.figures = [];
  53595. var decodeContext = {
  53596. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  53597. bitsPerComponent: dict.get('BitsPerComponent'),
  53598. bitsPerFlag: dict.get('BitsPerFlag'),
  53599. decode: dict.getArray('Decode'),
  53600. colorFn: fn,
  53601. colorSpace: cs,
  53602. numComps: fn ? 1 : cs.numComps
  53603. };
  53604. var reader = new MeshStreamReader(stream, decodeContext);
  53605. var patchMesh = false;
  53606. switch (this.shadingType) {
  53607. case ShadingType.FREE_FORM_MESH:
  53608. decodeType4Shading(this, reader);
  53609. break;
  53610. case ShadingType.LATTICE_FORM_MESH:
  53611. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  53612. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  53613. decodeType5Shading(this, reader, verticesPerRow);
  53614. break;
  53615. case ShadingType.COONS_PATCH_MESH:
  53616. decodeType6Shading(this, reader);
  53617. patchMesh = true;
  53618. break;
  53619. case ShadingType.TENSOR_PATCH_MESH:
  53620. decodeType7Shading(this, reader);
  53621. patchMesh = true;
  53622. break;
  53623. default:
  53624. error('Unsupported mesh type.');
  53625. break;
  53626. }
  53627. if (patchMesh) {
  53628. updateBounds(this);
  53629. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  53630. buildFigureFromPatch(this, i);
  53631. }
  53632. }
  53633. updateBounds(this);
  53634. packData(this);
  53635. }
  53636. Mesh.prototype = {
  53637. getIR: function Mesh_getIR() {
  53638. return [
  53639. 'Mesh',
  53640. this.shadingType,
  53641. this.coords,
  53642. this.colors,
  53643. this.figures,
  53644. this.bounds,
  53645. this.matrix,
  53646. this.bbox,
  53647. this.background
  53648. ];
  53649. }
  53650. };
  53651. return Mesh;
  53652. }();
  53653. Shadings.Dummy = function DummyClosure() {
  53654. function Dummy() {
  53655. this.type = 'Pattern';
  53656. }
  53657. Dummy.prototype = {
  53658. getIR: function Dummy_getIR() {
  53659. return ['Dummy'];
  53660. }
  53661. };
  53662. return Dummy;
  53663. }();
  53664. function getTilingPatternIR(operatorList, dict, args) {
  53665. var matrix = dict.getArray('Matrix');
  53666. var bbox = dict.getArray('BBox');
  53667. var xstep = dict.get('XStep');
  53668. var ystep = dict.get('YStep');
  53669. var paintType = dict.get('PaintType');
  53670. var tilingType = dict.get('TilingType');
  53671. return [
  53672. 'TilingPattern',
  53673. args,
  53674. operatorList,
  53675. matrix,
  53676. bbox,
  53677. xstep,
  53678. ystep,
  53679. paintType,
  53680. tilingType
  53681. ];
  53682. }
  53683. exports.Pattern = Pattern;
  53684. exports.getTilingPatternIR = getTilingPatternIR;
  53685. /***/ }),
  53686. /* 41 */
  53687. /***/ (function(module, exports, __w_pdfjs_require__) {
  53688. "use strict";
  53689. var sharedUtil = __w_pdfjs_require__(0);
  53690. var coreStream = __w_pdfjs_require__(2);
  53691. var coreChunkedStream = __w_pdfjs_require__(15);
  53692. var coreDocument = __w_pdfjs_require__(31);
  53693. var warn = sharedUtil.warn;
  53694. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  53695. var shadow = sharedUtil.shadow;
  53696. var NotImplementedException = sharedUtil.NotImplementedException;
  53697. var MissingDataException = sharedUtil.MissingDataException;
  53698. var createPromiseCapability = sharedUtil.createPromiseCapability;
  53699. var Util = sharedUtil.Util;
  53700. var Stream = coreStream.Stream;
  53701. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  53702. var PDFDocument = coreDocument.PDFDocument;
  53703. var BasePdfManager = function BasePdfManagerClosure() {
  53704. function BasePdfManager() {
  53705. throw new Error('Cannot initialize BaseManagerManager');
  53706. }
  53707. BasePdfManager.prototype = {
  53708. get docId() {
  53709. return this._docId;
  53710. },
  53711. get password() {
  53712. return this._password;
  53713. },
  53714. get docBaseUrl() {
  53715. var docBaseUrl = null;
  53716. if (this._docBaseUrl) {
  53717. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  53718. if (absoluteUrl) {
  53719. docBaseUrl = absoluteUrl.href;
  53720. } else {
  53721. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  53722. }
  53723. }
  53724. return shadow(this, 'docBaseUrl', docBaseUrl);
  53725. },
  53726. onLoadedStream: function BasePdfManager_onLoadedStream() {
  53727. throw new NotImplementedException();
  53728. },
  53729. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  53730. return this.ensure(this.pdfDocument, prop, args);
  53731. },
  53732. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  53733. return this.ensure(this.pdfDocument.xref, prop, args);
  53734. },
  53735. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  53736. return this.ensure(this.pdfDocument.catalog, prop, args);
  53737. },
  53738. getPage: function BasePdfManager_getPage(pageIndex) {
  53739. return this.pdfDocument.getPage(pageIndex);
  53740. },
  53741. cleanup: function BasePdfManager_cleanup() {
  53742. return this.pdfDocument.cleanup();
  53743. },
  53744. ensure: function BasePdfManager_ensure(obj, prop, args) {
  53745. return new NotImplementedException();
  53746. },
  53747. requestRange: function BasePdfManager_requestRange(begin, end) {
  53748. return new NotImplementedException();
  53749. },
  53750. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  53751. return new NotImplementedException();
  53752. },
  53753. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  53754. return new NotImplementedException();
  53755. },
  53756. updatePassword: function BasePdfManager_updatePassword(password) {
  53757. this._password = password;
  53758. },
  53759. terminate: function BasePdfManager_terminate() {
  53760. return new NotImplementedException();
  53761. }
  53762. };
  53763. return BasePdfManager;
  53764. }();
  53765. var LocalPdfManager = function LocalPdfManagerClosure() {
  53766. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  53767. this._docId = docId;
  53768. this._password = password;
  53769. this._docBaseUrl = docBaseUrl;
  53770. this.evaluatorOptions = evaluatorOptions;
  53771. var stream = new Stream(data);
  53772. this.pdfDocument = new PDFDocument(this, stream);
  53773. this._loadedStreamCapability = createPromiseCapability();
  53774. this._loadedStreamCapability.resolve(stream);
  53775. }
  53776. Util.inherit(LocalPdfManager, BasePdfManager, {
  53777. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  53778. return new Promise(function (resolve, reject) {
  53779. try {
  53780. var value = obj[prop];
  53781. var result;
  53782. if (typeof value === 'function') {
  53783. result = value.apply(obj, args);
  53784. } else {
  53785. result = value;
  53786. }
  53787. resolve(result);
  53788. } catch (e) {
  53789. reject(e);
  53790. }
  53791. });
  53792. },
  53793. requestRange: function LocalPdfManager_requestRange(begin, end) {
  53794. return Promise.resolve();
  53795. },
  53796. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  53797. },
  53798. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  53799. return this._loadedStreamCapability.promise;
  53800. },
  53801. terminate: function LocalPdfManager_terminate() {
  53802. }
  53803. });
  53804. return LocalPdfManager;
  53805. }();
  53806. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  53807. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  53808. this._docId = docId;
  53809. this._password = args.password;
  53810. this._docBaseUrl = docBaseUrl;
  53811. this.msgHandler = args.msgHandler;
  53812. this.evaluatorOptions = evaluatorOptions;
  53813. var params = {
  53814. msgHandler: args.msgHandler,
  53815. url: args.url,
  53816. length: args.length,
  53817. disableAutoFetch: args.disableAutoFetch,
  53818. rangeChunkSize: args.rangeChunkSize
  53819. };
  53820. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  53821. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream());
  53822. }
  53823. Util.inherit(NetworkPdfManager, BasePdfManager, {
  53824. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  53825. var pdfManager = this;
  53826. return new Promise(function (resolve, reject) {
  53827. function ensureHelper() {
  53828. try {
  53829. var result;
  53830. var value = obj[prop];
  53831. if (typeof value === 'function') {
  53832. result = value.apply(obj, args);
  53833. } else {
  53834. result = value;
  53835. }
  53836. resolve(result);
  53837. } catch (e) {
  53838. if (!(e instanceof MissingDataException)) {
  53839. reject(e);
  53840. return;
  53841. }
  53842. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  53843. }
  53844. }
  53845. ensureHelper();
  53846. });
  53847. },
  53848. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  53849. return this.streamManager.requestRange(begin, end);
  53850. },
  53851. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  53852. this.streamManager.requestAllChunks();
  53853. },
  53854. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  53855. this.streamManager.onReceiveData({ chunk: chunk });
  53856. },
  53857. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  53858. return this.streamManager.onLoadedStream();
  53859. },
  53860. terminate: function NetworkPdfManager_terminate() {
  53861. this.streamManager.abort();
  53862. }
  53863. });
  53864. return NetworkPdfManager;
  53865. }();
  53866. exports.LocalPdfManager = LocalPdfManager;
  53867. exports.NetworkPdfManager = NetworkPdfManager;
  53868. /***/ }),
  53869. /* 42 */
  53870. /***/ (function(module, exports, __w_pdfjs_require__) {
  53871. "use strict";
  53872. var sharedUtil = __w_pdfjs_require__(0);
  53873. var corePrimitives = __w_pdfjs_require__(1);
  53874. var error = sharedUtil.error;
  53875. var isSpace = sharedUtil.isSpace;
  53876. var EOF = corePrimitives.EOF;
  53877. var PostScriptParser = function PostScriptParserClosure() {
  53878. function PostScriptParser(lexer) {
  53879. this.lexer = lexer;
  53880. this.operators = [];
  53881. this.token = null;
  53882. this.prev = null;
  53883. }
  53884. PostScriptParser.prototype = {
  53885. nextToken: function PostScriptParser_nextToken() {
  53886. this.prev = this.token;
  53887. this.token = this.lexer.getToken();
  53888. },
  53889. accept: function PostScriptParser_accept(type) {
  53890. if (this.token.type === type) {
  53891. this.nextToken();
  53892. return true;
  53893. }
  53894. return false;
  53895. },
  53896. expect: function PostScriptParser_expect(type) {
  53897. if (this.accept(type)) {
  53898. return true;
  53899. }
  53900. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  53901. },
  53902. parse: function PostScriptParser_parse() {
  53903. this.nextToken();
  53904. this.expect(PostScriptTokenTypes.LBRACE);
  53905. this.parseBlock();
  53906. this.expect(PostScriptTokenTypes.RBRACE);
  53907. return this.operators;
  53908. },
  53909. parseBlock: function PostScriptParser_parseBlock() {
  53910. while (true) {
  53911. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  53912. this.operators.push(this.prev.value);
  53913. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  53914. this.operators.push(this.prev.value);
  53915. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53916. this.parseCondition();
  53917. } else {
  53918. return;
  53919. }
  53920. }
  53921. },
  53922. parseCondition: function PostScriptParser_parseCondition() {
  53923. var conditionLocation = this.operators.length;
  53924. this.operators.push(null, null);
  53925. this.parseBlock();
  53926. this.expect(PostScriptTokenTypes.RBRACE);
  53927. if (this.accept(PostScriptTokenTypes.IF)) {
  53928. this.operators[conditionLocation] = this.operators.length;
  53929. this.operators[conditionLocation + 1] = 'jz';
  53930. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  53931. var jumpLocation = this.operators.length;
  53932. this.operators.push(null, null);
  53933. var endOfTrue = this.operators.length;
  53934. this.parseBlock();
  53935. this.expect(PostScriptTokenTypes.RBRACE);
  53936. this.expect(PostScriptTokenTypes.IFELSE);
  53937. this.operators[jumpLocation] = this.operators.length;
  53938. this.operators[jumpLocation + 1] = 'j';
  53939. this.operators[conditionLocation] = endOfTrue;
  53940. this.operators[conditionLocation + 1] = 'jz';
  53941. } else {
  53942. error('PS Function: error parsing conditional.');
  53943. }
  53944. }
  53945. };
  53946. return PostScriptParser;
  53947. }();
  53948. var PostScriptTokenTypes = {
  53949. LBRACE: 0,
  53950. RBRACE: 1,
  53951. NUMBER: 2,
  53952. OPERATOR: 3,
  53953. IF: 4,
  53954. IFELSE: 5
  53955. };
  53956. var PostScriptToken = function PostScriptTokenClosure() {
  53957. function PostScriptToken(type, value) {
  53958. this.type = type;
  53959. this.value = value;
  53960. }
  53961. var opCache = Object.create(null);
  53962. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  53963. var opValue = opCache[op];
  53964. if (opValue) {
  53965. return opValue;
  53966. }
  53967. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  53968. };
  53969. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  53970. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  53971. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  53972. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  53973. return PostScriptToken;
  53974. }();
  53975. var PostScriptLexer = function PostScriptLexerClosure() {
  53976. function PostScriptLexer(stream) {
  53977. this.stream = stream;
  53978. this.nextChar();
  53979. this.strBuf = [];
  53980. }
  53981. PostScriptLexer.prototype = {
  53982. nextChar: function PostScriptLexer_nextChar() {
  53983. return this.currentChar = this.stream.getByte();
  53984. },
  53985. getToken: function PostScriptLexer_getToken() {
  53986. var comment = false;
  53987. var ch = this.currentChar;
  53988. while (true) {
  53989. if (ch < 0) {
  53990. return EOF;
  53991. }
  53992. if (comment) {
  53993. if (ch === 0x0A || ch === 0x0D) {
  53994. comment = false;
  53995. }
  53996. } else if (ch === 0x25) {
  53997. comment = true;
  53998. } else if (!isSpace(ch)) {
  53999. break;
  54000. }
  54001. ch = this.nextChar();
  54002. }
  54003. switch (ch | 0) {
  54004. case 0x30:
  54005. case 0x31:
  54006. case 0x32:
  54007. case 0x33:
  54008. case 0x34:
  54009. case 0x35:
  54010. case 0x36:
  54011. case 0x37:
  54012. case 0x38:
  54013. case 0x39:
  54014. case 0x2B:
  54015. case 0x2D:
  54016. case 0x2E:
  54017. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  54018. case 0x7B:
  54019. this.nextChar();
  54020. return PostScriptToken.LBRACE;
  54021. case 0x7D:
  54022. this.nextChar();
  54023. return PostScriptToken.RBRACE;
  54024. }
  54025. var strBuf = this.strBuf;
  54026. strBuf.length = 0;
  54027. strBuf[0] = String.fromCharCode(ch);
  54028. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  54029. strBuf.push(String.fromCharCode(ch));
  54030. }
  54031. var str = strBuf.join('');
  54032. switch (str.toLowerCase()) {
  54033. case 'if':
  54034. return PostScriptToken.IF;
  54035. case 'ifelse':
  54036. return PostScriptToken.IFELSE;
  54037. default:
  54038. return PostScriptToken.getOperator(str);
  54039. }
  54040. },
  54041. getNumber: function PostScriptLexer_getNumber() {
  54042. var ch = this.currentChar;
  54043. var strBuf = this.strBuf;
  54044. strBuf.length = 0;
  54045. strBuf[0] = String.fromCharCode(ch);
  54046. while ((ch = this.nextChar()) >= 0) {
  54047. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  54048. strBuf.push(String.fromCharCode(ch));
  54049. } else {
  54050. break;
  54051. }
  54052. }
  54053. var value = parseFloat(strBuf.join(''));
  54054. if (isNaN(value)) {
  54055. error('Invalid floating point number: ' + value);
  54056. }
  54057. return value;
  54058. }
  54059. };
  54060. return PostScriptLexer;
  54061. }();
  54062. exports.PostScriptLexer = PostScriptLexer;
  54063. exports.PostScriptParser = PostScriptParser;
  54064. /***/ }),
  54065. /* 43 */
  54066. /***/ (function(module, exports, __w_pdfjs_require__) {
  54067. "use strict";
  54068. var sharedUtil = __w_pdfjs_require__(0);
  54069. var coreStream = __w_pdfjs_require__(2);
  54070. var coreEncodings = __w_pdfjs_require__(5);
  54071. var warn = sharedUtil.warn;
  54072. var isSpace = sharedUtil.isSpace;
  54073. var Stream = coreStream.Stream;
  54074. var getEncoding = coreEncodings.getEncoding;
  54075. var HINTING_ENABLED = false;
  54076. var Type1CharString = function Type1CharStringClosure() {
  54077. var COMMAND_MAP = {
  54078. 'hstem': [1],
  54079. 'vstem': [3],
  54080. 'vmoveto': [4],
  54081. 'rlineto': [5],
  54082. 'hlineto': [6],
  54083. 'vlineto': [7],
  54084. 'rrcurveto': [8],
  54085. 'callsubr': [10],
  54086. 'flex': [
  54087. 12,
  54088. 35
  54089. ],
  54090. 'drop': [
  54091. 12,
  54092. 18
  54093. ],
  54094. 'endchar': [14],
  54095. 'rmoveto': [21],
  54096. 'hmoveto': [22],
  54097. 'vhcurveto': [30],
  54098. 'hvcurveto': [31]
  54099. };
  54100. function Type1CharString() {
  54101. this.width = 0;
  54102. this.lsb = 0;
  54103. this.flexing = false;
  54104. this.output = [];
  54105. this.stack = [];
  54106. }
  54107. Type1CharString.prototype = {
  54108. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  54109. var count = encoded.length;
  54110. var error = false;
  54111. var wx, sbx, subrNumber;
  54112. for (var i = 0; i < count; i++) {
  54113. var value = encoded[i];
  54114. if (value < 32) {
  54115. if (value === 12) {
  54116. value = (value << 8) + encoded[++i];
  54117. }
  54118. switch (value) {
  54119. case 1:
  54120. if (!HINTING_ENABLED) {
  54121. this.stack = [];
  54122. break;
  54123. }
  54124. error = this.executeCommand(2, COMMAND_MAP.hstem);
  54125. break;
  54126. case 3:
  54127. if (!HINTING_ENABLED) {
  54128. this.stack = [];
  54129. break;
  54130. }
  54131. error = this.executeCommand(2, COMMAND_MAP.vstem);
  54132. break;
  54133. case 4:
  54134. if (this.flexing) {
  54135. if (this.stack.length < 1) {
  54136. error = true;
  54137. break;
  54138. }
  54139. var dy = this.stack.pop();
  54140. this.stack.push(0, dy);
  54141. break;
  54142. }
  54143. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  54144. break;
  54145. case 5:
  54146. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  54147. break;
  54148. case 6:
  54149. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  54150. break;
  54151. case 7:
  54152. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  54153. break;
  54154. case 8:
  54155. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  54156. break;
  54157. case 9:
  54158. this.stack = [];
  54159. break;
  54160. case 10:
  54161. if (this.stack.length < 1) {
  54162. error = true;
  54163. break;
  54164. }
  54165. subrNumber = this.stack.pop();
  54166. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  54167. break;
  54168. case 11:
  54169. return error;
  54170. case 13:
  54171. if (this.stack.length < 2) {
  54172. error = true;
  54173. break;
  54174. }
  54175. wx = this.stack.pop();
  54176. sbx = this.stack.pop();
  54177. this.lsb = sbx;
  54178. this.width = wx;
  54179. this.stack.push(wx, sbx);
  54180. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  54181. break;
  54182. case 14:
  54183. this.output.push(COMMAND_MAP.endchar[0]);
  54184. break;
  54185. case 21:
  54186. if (this.flexing) {
  54187. break;
  54188. }
  54189. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  54190. break;
  54191. case 22:
  54192. if (this.flexing) {
  54193. this.stack.push(0);
  54194. break;
  54195. }
  54196. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  54197. break;
  54198. case 30:
  54199. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  54200. break;
  54201. case 31:
  54202. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  54203. break;
  54204. case (12 << 8) + 0:
  54205. this.stack = [];
  54206. break;
  54207. case (12 << 8) + 1:
  54208. if (!HINTING_ENABLED) {
  54209. this.stack = [];
  54210. break;
  54211. }
  54212. error = this.executeCommand(2, COMMAND_MAP.vstem);
  54213. break;
  54214. case (12 << 8) + 2:
  54215. if (!HINTING_ENABLED) {
  54216. this.stack = [];
  54217. break;
  54218. }
  54219. error = this.executeCommand(2, COMMAND_MAP.hstem);
  54220. break;
  54221. case (12 << 8) + 6:
  54222. if (seacAnalysisEnabled) {
  54223. this.seac = this.stack.splice(-4, 4);
  54224. error = this.executeCommand(0, COMMAND_MAP.endchar);
  54225. } else {
  54226. error = this.executeCommand(4, COMMAND_MAP.endchar);
  54227. }
  54228. break;
  54229. case (12 << 8) + 7:
  54230. if (this.stack.length < 4) {
  54231. error = true;
  54232. break;
  54233. }
  54234. this.stack.pop();
  54235. wx = this.stack.pop();
  54236. var sby = this.stack.pop();
  54237. sbx = this.stack.pop();
  54238. this.lsb = sbx;
  54239. this.width = wx;
  54240. this.stack.push(wx, sbx, sby);
  54241. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  54242. break;
  54243. case (12 << 8) + 12:
  54244. if (this.stack.length < 2) {
  54245. error = true;
  54246. break;
  54247. }
  54248. var num2 = this.stack.pop();
  54249. var num1 = this.stack.pop();
  54250. this.stack.push(num1 / num2);
  54251. break;
  54252. case (12 << 8) + 16:
  54253. if (this.stack.length < 2) {
  54254. error = true;
  54255. break;
  54256. }
  54257. subrNumber = this.stack.pop();
  54258. var numArgs = this.stack.pop();
  54259. if (subrNumber === 0 && numArgs === 3) {
  54260. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  54261. 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]);
  54262. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  54263. this.flexing = false;
  54264. this.stack.push(flexArgs[15], flexArgs[16]);
  54265. } else if (subrNumber === 1 && numArgs === 0) {
  54266. this.flexing = true;
  54267. }
  54268. break;
  54269. case (12 << 8) + 17:
  54270. break;
  54271. case (12 << 8) + 33:
  54272. this.stack = [];
  54273. break;
  54274. default:
  54275. warn('Unknown type 1 charstring command of "' + value + '"');
  54276. break;
  54277. }
  54278. if (error) {
  54279. break;
  54280. }
  54281. continue;
  54282. } else if (value <= 246) {
  54283. value = value - 139;
  54284. } else if (value <= 250) {
  54285. value = (value - 247) * 256 + encoded[++i] + 108;
  54286. } else if (value <= 254) {
  54287. value = -((value - 251) * 256) - encoded[++i] - 108;
  54288. } else {
  54289. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  54290. }
  54291. this.stack.push(value);
  54292. }
  54293. return error;
  54294. },
  54295. executeCommand: function (howManyArgs, command, keepStack) {
  54296. var stackLength = this.stack.length;
  54297. if (howManyArgs > stackLength) {
  54298. return true;
  54299. }
  54300. var start = stackLength - howManyArgs;
  54301. for (var i = start; i < stackLength; i++) {
  54302. var value = this.stack[i];
  54303. if (value === (value | 0)) {
  54304. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  54305. } else {
  54306. value = 65536 * value | 0;
  54307. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  54308. }
  54309. }
  54310. this.output.push.apply(this.output, command);
  54311. if (keepStack) {
  54312. this.stack.splice(start, howManyArgs);
  54313. } else {
  54314. this.stack.length = 0;
  54315. }
  54316. return false;
  54317. }
  54318. };
  54319. return Type1CharString;
  54320. }();
  54321. var Type1Parser = function Type1ParserClosure() {
  54322. var EEXEC_ENCRYPT_KEY = 55665;
  54323. var CHAR_STRS_ENCRYPT_KEY = 4330;
  54324. function isHexDigit(code) {
  54325. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  54326. }
  54327. function decrypt(data, key, discardNumber) {
  54328. if (discardNumber >= data.length) {
  54329. return new Uint8Array(0);
  54330. }
  54331. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  54332. for (i = 0; i < discardNumber; i++) {
  54333. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  54334. }
  54335. var count = data.length - discardNumber;
  54336. var decrypted = new Uint8Array(count);
  54337. for (i = discardNumber, j = 0; j < count; i++, j++) {
  54338. var value = data[i];
  54339. decrypted[j] = value ^ r >> 8;
  54340. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  54341. }
  54342. return decrypted;
  54343. }
  54344. function decryptAscii(data, key, discardNumber) {
  54345. var r = key | 0, c1 = 52845, c2 = 22719;
  54346. var count = data.length, maybeLength = count >>> 1;
  54347. var decrypted = new Uint8Array(maybeLength);
  54348. var i, j;
  54349. for (i = 0, j = 0; i < count; i++) {
  54350. var digit1 = data[i];
  54351. if (!isHexDigit(digit1)) {
  54352. continue;
  54353. }
  54354. i++;
  54355. var digit2;
  54356. while (i < count && !isHexDigit(digit2 = data[i])) {
  54357. i++;
  54358. }
  54359. if (i < count) {
  54360. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  54361. decrypted[j++] = value ^ r >> 8;
  54362. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  54363. }
  54364. }
  54365. return Array.prototype.slice.call(decrypted, discardNumber, j);
  54366. }
  54367. function isSpecial(c) {
  54368. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  54369. }
  54370. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  54371. if (encrypted) {
  54372. var data = stream.getBytes();
  54373. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  54374. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  54375. }
  54376. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  54377. this.stream = stream;
  54378. this.nextChar();
  54379. }
  54380. Type1Parser.prototype = {
  54381. readNumberArray: function Type1Parser_readNumberArray() {
  54382. this.getToken();
  54383. var array = [];
  54384. while (true) {
  54385. var token = this.getToken();
  54386. if (token === null || token === ']' || token === '}') {
  54387. break;
  54388. }
  54389. array.push(parseFloat(token || 0));
  54390. }
  54391. return array;
  54392. },
  54393. readNumber: function Type1Parser_readNumber() {
  54394. var token = this.getToken();
  54395. return parseFloat(token || 0);
  54396. },
  54397. readInt: function Type1Parser_readInt() {
  54398. var token = this.getToken();
  54399. return parseInt(token || 0, 10) | 0;
  54400. },
  54401. readBoolean: function Type1Parser_readBoolean() {
  54402. var token = this.getToken();
  54403. return token === 'true' ? 1 : 0;
  54404. },
  54405. nextChar: function Type1_nextChar() {
  54406. return this.currentChar = this.stream.getByte();
  54407. },
  54408. getToken: function Type1Parser_getToken() {
  54409. var comment = false;
  54410. var ch = this.currentChar;
  54411. while (true) {
  54412. if (ch === -1) {
  54413. return null;
  54414. }
  54415. if (comment) {
  54416. if (ch === 0x0A || ch === 0x0D) {
  54417. comment = false;
  54418. }
  54419. } else if (ch === 0x25) {
  54420. comment = true;
  54421. } else if (!isSpace(ch)) {
  54422. break;
  54423. }
  54424. ch = this.nextChar();
  54425. }
  54426. if (isSpecial(ch)) {
  54427. this.nextChar();
  54428. return String.fromCharCode(ch);
  54429. }
  54430. var token = '';
  54431. do {
  54432. token += String.fromCharCode(ch);
  54433. ch = this.nextChar();
  54434. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  54435. return token;
  54436. },
  54437. extractFontProgram: function Type1Parser_extractFontProgram() {
  54438. var stream = this.stream;
  54439. var subrs = [], charstrings = [];
  54440. var privateData = Object.create(null);
  54441. privateData['lenIV'] = 4;
  54442. var program = {
  54443. subrs: [],
  54444. charstrings: [],
  54445. properties: { 'privateData': privateData }
  54446. };
  54447. var token, length, data, lenIV, encoded;
  54448. while ((token = this.getToken()) !== null) {
  54449. if (token !== '/') {
  54450. continue;
  54451. }
  54452. token = this.getToken();
  54453. switch (token) {
  54454. case 'CharStrings':
  54455. this.getToken();
  54456. this.getToken();
  54457. this.getToken();
  54458. this.getToken();
  54459. while (true) {
  54460. token = this.getToken();
  54461. if (token === null || token === 'end') {
  54462. break;
  54463. }
  54464. if (token !== '/') {
  54465. continue;
  54466. }
  54467. var glyph = this.getToken();
  54468. length = this.readInt();
  54469. this.getToken();
  54470. data = stream.makeSubStream(stream.pos, length);
  54471. lenIV = program.properties.privateData['lenIV'];
  54472. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  54473. stream.skip(length);
  54474. this.nextChar();
  54475. token = this.getToken();
  54476. if (token === 'noaccess') {
  54477. this.getToken();
  54478. }
  54479. charstrings.push({
  54480. glyph: glyph,
  54481. encoded: encoded
  54482. });
  54483. }
  54484. break;
  54485. case 'Subrs':
  54486. this.readInt();
  54487. this.getToken();
  54488. while ((token = this.getToken()) === 'dup') {
  54489. var index = this.readInt();
  54490. length = this.readInt();
  54491. this.getToken();
  54492. data = stream.makeSubStream(stream.pos, length);
  54493. lenIV = program.properties.privateData['lenIV'];
  54494. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  54495. stream.skip(length);
  54496. this.nextChar();
  54497. token = this.getToken();
  54498. if (token === 'noaccess') {
  54499. this.getToken();
  54500. }
  54501. subrs[index] = encoded;
  54502. }
  54503. break;
  54504. case 'BlueValues':
  54505. case 'OtherBlues':
  54506. case 'FamilyBlues':
  54507. case 'FamilyOtherBlues':
  54508. var blueArray = this.readNumberArray();
  54509. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  54510. program.properties.privateData[token] = blueArray;
  54511. }
  54512. break;
  54513. case 'StemSnapH':
  54514. case 'StemSnapV':
  54515. program.properties.privateData[token] = this.readNumberArray();
  54516. break;
  54517. case 'StdHW':
  54518. case 'StdVW':
  54519. program.properties.privateData[token] = this.readNumberArray()[0];
  54520. break;
  54521. case 'BlueShift':
  54522. case 'lenIV':
  54523. case 'BlueFuzz':
  54524. case 'BlueScale':
  54525. case 'LanguageGroup':
  54526. case 'ExpansionFactor':
  54527. program.properties.privateData[token] = this.readNumber();
  54528. break;
  54529. case 'ForceBold':
  54530. program.properties.privateData[token] = this.readBoolean();
  54531. break;
  54532. }
  54533. }
  54534. for (var i = 0; i < charstrings.length; i++) {
  54535. glyph = charstrings[i].glyph;
  54536. encoded = charstrings[i].encoded;
  54537. var charString = new Type1CharString();
  54538. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  54539. var output = charString.output;
  54540. if (error) {
  54541. output = [14];
  54542. }
  54543. program.charstrings.push({
  54544. glyphName: glyph,
  54545. charstring: output,
  54546. width: charString.width,
  54547. lsb: charString.lsb,
  54548. seac: charString.seac
  54549. });
  54550. }
  54551. return program;
  54552. },
  54553. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  54554. var token;
  54555. while ((token = this.getToken()) !== null) {
  54556. if (token !== '/') {
  54557. continue;
  54558. }
  54559. token = this.getToken();
  54560. switch (token) {
  54561. case 'FontMatrix':
  54562. var matrix = this.readNumberArray();
  54563. properties.fontMatrix = matrix;
  54564. break;
  54565. case 'Encoding':
  54566. var encodingArg = this.getToken();
  54567. var encoding;
  54568. if (!/^\d+$/.test(encodingArg)) {
  54569. encoding = getEncoding(encodingArg);
  54570. } else {
  54571. encoding = [];
  54572. var size = parseInt(encodingArg, 10) | 0;
  54573. this.getToken();
  54574. for (var j = 0; j < size; j++) {
  54575. token = this.getToken();
  54576. while (token !== 'dup' && token !== 'def') {
  54577. token = this.getToken();
  54578. if (token === null) {
  54579. return;
  54580. }
  54581. }
  54582. if (token === 'def') {
  54583. break;
  54584. }
  54585. var index = this.readInt();
  54586. this.getToken();
  54587. var glyph = this.getToken();
  54588. encoding[index] = glyph;
  54589. this.getToken();
  54590. }
  54591. }
  54592. properties.builtInEncoding = encoding;
  54593. break;
  54594. case 'FontBBox':
  54595. var fontBBox = this.readNumberArray();
  54596. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  54597. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  54598. properties.ascentScaled = true;
  54599. break;
  54600. }
  54601. }
  54602. }
  54603. };
  54604. return Type1Parser;
  54605. }();
  54606. exports.Type1Parser = Type1Parser;
  54607. /***/ }),
  54608. /* 44 */
  54609. /***/ (function(module, exports, __w_pdfjs_require__) {
  54610. "use strict";
  54611. var sharedUtil = __w_pdfjs_require__(0);
  54612. var displayDOMUtils = __w_pdfjs_require__(3);
  54613. var displayPatternHelper = __w_pdfjs_require__(46);
  54614. var displayWebGL = __w_pdfjs_require__(24);
  54615. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  54616. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  54617. var ImageKind = sharedUtil.ImageKind;
  54618. var OPS = sharedUtil.OPS;
  54619. var TextRenderingMode = sharedUtil.TextRenderingMode;
  54620. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  54621. var Util = sharedUtil.Util;
  54622. var assert = sharedUtil.assert;
  54623. var info = sharedUtil.info;
  54624. var isNum = sharedUtil.isNum;
  54625. var isArray = sharedUtil.isArray;
  54626. var isLittleEndian = sharedUtil.isLittleEndian;
  54627. var error = sharedUtil.error;
  54628. var shadow = sharedUtil.shadow;
  54629. var warn = sharedUtil.warn;
  54630. var TilingPattern = displayPatternHelper.TilingPattern;
  54631. var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
  54632. var WebGLUtils = displayWebGL.WebGLUtils;
  54633. var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
  54634. var MIN_FONT_SIZE = 16;
  54635. var MAX_FONT_SIZE = 100;
  54636. var MAX_GROUP_SIZE = 4096;
  54637. var MIN_WIDTH_FACTOR = 0.65;
  54638. var COMPILE_TYPE3_GLYPHS = true;
  54639. var MAX_SIZE_TO_COMPILE = 1000;
  54640. var FULL_CHUNK_HEIGHT = 16;
  54641. var HasCanvasTypedArraysCached = {
  54642. get value() {
  54643. return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
  54644. }
  54645. };
  54646. var IsLittleEndianCached = {
  54647. get value() {
  54648. return shadow(IsLittleEndianCached, 'value', isLittleEndian());
  54649. }
  54650. };
  54651. function addContextCurrentTransform(ctx) {
  54652. if (!ctx.mozCurrentTransform) {
  54653. ctx._originalSave = ctx.save;
  54654. ctx._originalRestore = ctx.restore;
  54655. ctx._originalRotate = ctx.rotate;
  54656. ctx._originalScale = ctx.scale;
  54657. ctx._originalTranslate = ctx.translate;
  54658. ctx._originalTransform = ctx.transform;
  54659. ctx._originalSetTransform = ctx.setTransform;
  54660. ctx._transformMatrix = ctx._transformMatrix || [
  54661. 1,
  54662. 0,
  54663. 0,
  54664. 1,
  54665. 0,
  54666. 0
  54667. ];
  54668. ctx._transformStack = [];
  54669. Object.defineProperty(ctx, 'mozCurrentTransform', {
  54670. get: function getCurrentTransform() {
  54671. return this._transformMatrix;
  54672. }
  54673. });
  54674. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  54675. get: function getCurrentTransformInverse() {
  54676. var m = this._transformMatrix;
  54677. var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
  54678. var ad_bc = a * d - b * c;
  54679. var bc_ad = b * c - a * d;
  54680. return [
  54681. d / ad_bc,
  54682. b / bc_ad,
  54683. c / bc_ad,
  54684. a / ad_bc,
  54685. (d * e - c * f) / bc_ad,
  54686. (b * e - a * f) / ad_bc
  54687. ];
  54688. }
  54689. });
  54690. ctx.save = function ctxSave() {
  54691. var old = this._transformMatrix;
  54692. this._transformStack.push(old);
  54693. this._transformMatrix = old.slice(0, 6);
  54694. this._originalSave();
  54695. };
  54696. ctx.restore = function ctxRestore() {
  54697. var prev = this._transformStack.pop();
  54698. if (prev) {
  54699. this._transformMatrix = prev;
  54700. this._originalRestore();
  54701. }
  54702. };
  54703. ctx.translate = function ctxTranslate(x, y) {
  54704. var m = this._transformMatrix;
  54705. m[4] = m[0] * x + m[2] * y + m[4];
  54706. m[5] = m[1] * x + m[3] * y + m[5];
  54707. this._originalTranslate(x, y);
  54708. };
  54709. ctx.scale = function ctxScale(x, y) {
  54710. var m = this._transformMatrix;
  54711. m[0] = m[0] * x;
  54712. m[1] = m[1] * x;
  54713. m[2] = m[2] * y;
  54714. m[3] = m[3] * y;
  54715. this._originalScale(x, y);
  54716. };
  54717. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  54718. var m = this._transformMatrix;
  54719. this._transformMatrix = [
  54720. m[0] * a + m[2] * b,
  54721. m[1] * a + m[3] * b,
  54722. m[0] * c + m[2] * d,
  54723. m[1] * c + m[3] * d,
  54724. m[0] * e + m[2] * f + m[4],
  54725. m[1] * e + m[3] * f + m[5]
  54726. ];
  54727. ctx._originalTransform(a, b, c, d, e, f);
  54728. };
  54729. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  54730. this._transformMatrix = [
  54731. a,
  54732. b,
  54733. c,
  54734. d,
  54735. e,
  54736. f
  54737. ];
  54738. ctx._originalSetTransform(a, b, c, d, e, f);
  54739. };
  54740. ctx.rotate = function ctxRotate(angle) {
  54741. var cosValue = Math.cos(angle);
  54742. var sinValue = Math.sin(angle);
  54743. var m = this._transformMatrix;
  54744. this._transformMatrix = [
  54745. m[0] * cosValue + m[2] * sinValue,
  54746. m[1] * cosValue + m[3] * sinValue,
  54747. m[0] * -sinValue + m[2] * cosValue,
  54748. m[1] * -sinValue + m[3] * cosValue,
  54749. m[4],
  54750. m[5]
  54751. ];
  54752. this._originalRotate(angle);
  54753. };
  54754. }
  54755. }
  54756. var CachedCanvases = function CachedCanvasesClosure() {
  54757. function CachedCanvases(canvasFactory) {
  54758. this.canvasFactory = canvasFactory;
  54759. this.cache = Object.create(null);
  54760. }
  54761. CachedCanvases.prototype = {
  54762. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  54763. var canvasEntry;
  54764. if (this.cache[id] !== undefined) {
  54765. canvasEntry = this.cache[id];
  54766. this.canvasFactory.reset(canvasEntry, width, height);
  54767. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  54768. } else {
  54769. canvasEntry = this.canvasFactory.create(width, height);
  54770. this.cache[id] = canvasEntry;
  54771. }
  54772. if (trackTransform) {
  54773. addContextCurrentTransform(canvasEntry.context);
  54774. }
  54775. return canvasEntry;
  54776. },
  54777. clear: function () {
  54778. for (var id in this.cache) {
  54779. var canvasEntry = this.cache[id];
  54780. this.canvasFactory.destroy(canvasEntry);
  54781. delete this.cache[id];
  54782. }
  54783. }
  54784. };
  54785. return CachedCanvases;
  54786. }();
  54787. function compileType3Glyph(imgData) {
  54788. var POINT_TO_PROCESS_LIMIT = 1000;
  54789. var width = imgData.width, height = imgData.height;
  54790. var i, j, j0, width1 = width + 1;
  54791. var points = new Uint8Array(width1 * (height + 1));
  54792. var POINT_TYPES = new Uint8Array([
  54793. 0,
  54794. 2,
  54795. 4,
  54796. 0,
  54797. 1,
  54798. 0,
  54799. 5,
  54800. 4,
  54801. 8,
  54802. 10,
  54803. 0,
  54804. 8,
  54805. 0,
  54806. 2,
  54807. 1,
  54808. 0
  54809. ]);
  54810. var lineSize = width + 7 & ~7, data0 = imgData.data;
  54811. var data = new Uint8Array(lineSize * height), pos = 0, ii;
  54812. for (i = 0, ii = data0.length; i < ii; i++) {
  54813. var mask = 128, elem = data0[i];
  54814. while (mask > 0) {
  54815. data[pos++] = elem & mask ? 0 : 255;
  54816. mask >>= 1;
  54817. }
  54818. }
  54819. var count = 0;
  54820. pos = 0;
  54821. if (data[pos] !== 0) {
  54822. points[0] = 1;
  54823. ++count;
  54824. }
  54825. for (j = 1; j < width; j++) {
  54826. if (data[pos] !== data[pos + 1]) {
  54827. points[j] = data[pos] ? 2 : 1;
  54828. ++count;
  54829. }
  54830. pos++;
  54831. }
  54832. if (data[pos] !== 0) {
  54833. points[j] = 2;
  54834. ++count;
  54835. }
  54836. for (i = 1; i < height; i++) {
  54837. pos = i * lineSize;
  54838. j0 = i * width1;
  54839. if (data[pos - lineSize] !== data[pos]) {
  54840. points[j0] = data[pos] ? 1 : 8;
  54841. ++count;
  54842. }
  54843. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  54844. for (j = 1; j < width; j++) {
  54845. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  54846. if (POINT_TYPES[sum]) {
  54847. points[j0 + j] = POINT_TYPES[sum];
  54848. ++count;
  54849. }
  54850. pos++;
  54851. }
  54852. if (data[pos - lineSize] !== data[pos]) {
  54853. points[j0 + j] = data[pos] ? 2 : 4;
  54854. ++count;
  54855. }
  54856. if (count > POINT_TO_PROCESS_LIMIT) {
  54857. return null;
  54858. }
  54859. }
  54860. pos = lineSize * (height - 1);
  54861. j0 = i * width1;
  54862. if (data[pos] !== 0) {
  54863. points[j0] = 8;
  54864. ++count;
  54865. }
  54866. for (j = 1; j < width; j++) {
  54867. if (data[pos] !== data[pos + 1]) {
  54868. points[j0 + j] = data[pos] ? 4 : 8;
  54869. ++count;
  54870. }
  54871. pos++;
  54872. }
  54873. if (data[pos] !== 0) {
  54874. points[j0 + j] = 4;
  54875. ++count;
  54876. }
  54877. if (count > POINT_TO_PROCESS_LIMIT) {
  54878. return null;
  54879. }
  54880. var steps = new Int32Array([
  54881. 0,
  54882. width1,
  54883. -1,
  54884. 0,
  54885. -width1,
  54886. 0,
  54887. 0,
  54888. 0,
  54889. 1
  54890. ]);
  54891. var outlines = [];
  54892. for (i = 0; count && i <= height; i++) {
  54893. var p = i * width1;
  54894. var end = p + width;
  54895. while (p < end && !points[p]) {
  54896. p++;
  54897. }
  54898. if (p === end) {
  54899. continue;
  54900. }
  54901. var coords = [
  54902. p % width1,
  54903. i
  54904. ];
  54905. var type = points[p], p0 = p, pp;
  54906. do {
  54907. var step = steps[type];
  54908. do {
  54909. p += step;
  54910. } while (!points[p]);
  54911. pp = points[p];
  54912. if (pp !== 5 && pp !== 10) {
  54913. type = pp;
  54914. points[p] = 0;
  54915. } else {
  54916. type = pp & 0x33 * type >> 4;
  54917. points[p] &= type >> 2 | type << 2;
  54918. }
  54919. coords.push(p % width1);
  54920. coords.push(p / width1 | 0);
  54921. --count;
  54922. } while (p0 !== p);
  54923. outlines.push(coords);
  54924. --i;
  54925. }
  54926. var drawOutline = function (c) {
  54927. c.save();
  54928. c.scale(1 / width, -1 / height);
  54929. c.translate(0, -height);
  54930. c.beginPath();
  54931. for (var i = 0, ii = outlines.length; i < ii; i++) {
  54932. var o = outlines[i];
  54933. c.moveTo(o[0], o[1]);
  54934. for (var j = 2, jj = o.length; j < jj; j += 2) {
  54935. c.lineTo(o[j], o[j + 1]);
  54936. }
  54937. }
  54938. c.fill();
  54939. c.beginPath();
  54940. c.restore();
  54941. };
  54942. return drawOutline;
  54943. }
  54944. var CanvasExtraState = function CanvasExtraStateClosure() {
  54945. function CanvasExtraState(old) {
  54946. this.alphaIsShape = false;
  54947. this.fontSize = 0;
  54948. this.fontSizeScale = 1;
  54949. this.textMatrix = IDENTITY_MATRIX;
  54950. this.textMatrixScale = 1;
  54951. this.fontMatrix = FONT_IDENTITY_MATRIX;
  54952. this.leading = 0;
  54953. this.x = 0;
  54954. this.y = 0;
  54955. this.lineX = 0;
  54956. this.lineY = 0;
  54957. this.charSpacing = 0;
  54958. this.wordSpacing = 0;
  54959. this.textHScale = 1;
  54960. this.textRenderingMode = TextRenderingMode.FILL;
  54961. this.textRise = 0;
  54962. this.fillColor = '#000000';
  54963. this.strokeColor = '#000000';
  54964. this.patternFill = false;
  54965. this.fillAlpha = 1;
  54966. this.strokeAlpha = 1;
  54967. this.lineWidth = 1;
  54968. this.activeSMask = null;
  54969. this.resumeSMaskCtx = null;
  54970. this.old = old;
  54971. }
  54972. CanvasExtraState.prototype = {
  54973. clone: function CanvasExtraState_clone() {
  54974. return Object.create(this);
  54975. },
  54976. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  54977. this.x = x;
  54978. this.y = y;
  54979. }
  54980. };
  54981. return CanvasExtraState;
  54982. }();
  54983. var CanvasGraphics = function CanvasGraphicsClosure() {
  54984. var EXECUTION_TIME = 15;
  54985. var EXECUTION_STEPS = 10;
  54986. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, imageLayer) {
  54987. this.ctx = canvasCtx;
  54988. this.current = new CanvasExtraState();
  54989. this.stateStack = [];
  54990. this.pendingClip = null;
  54991. this.pendingEOFill = false;
  54992. this.res = null;
  54993. this.xobjs = null;
  54994. this.commonObjs = commonObjs;
  54995. this.objs = objs;
  54996. this.canvasFactory = canvasFactory;
  54997. this.imageLayer = imageLayer;
  54998. this.groupStack = [];
  54999. this.processingType3 = null;
  55000. this.baseTransform = null;
  55001. this.baseTransformStack = [];
  55002. this.groupLevel = 0;
  55003. this.smaskStack = [];
  55004. this.smaskCounter = 0;
  55005. this.tempSMask = null;
  55006. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  55007. if (canvasCtx) {
  55008. addContextCurrentTransform(canvasCtx);
  55009. }
  55010. this.cachedGetSinglePixelWidth = null;
  55011. }
  55012. function putBinaryImageData(ctx, imgData) {
  55013. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  55014. ctx.putImageData(imgData, 0, 0);
  55015. return;
  55016. }
  55017. var height = imgData.height, width = imgData.width;
  55018. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  55019. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  55020. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  55021. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  55022. var srcPos = 0, destPos;
  55023. var src = imgData.data;
  55024. var dest = chunkImgData.data;
  55025. var i, j, thisChunkHeight, elemsInThisChunk;
  55026. if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
  55027. var srcLength = src.byteLength;
  55028. var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
  55029. var dest32DataLength = dest32.length;
  55030. var fullSrcDiff = width + 7 >> 3;
  55031. var white = 0xFFFFFFFF;
  55032. var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
  55033. for (i = 0; i < totalChunks; i++) {
  55034. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  55035. destPos = 0;
  55036. for (j = 0; j < thisChunkHeight; j++) {
  55037. var srcDiff = srcLength - srcPos;
  55038. var k = 0;
  55039. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  55040. var kEndUnrolled = kEnd & ~7;
  55041. var mask = 0;
  55042. var srcByte = 0;
  55043. for (; k < kEndUnrolled; k += 8) {
  55044. srcByte = src[srcPos++];
  55045. dest32[destPos++] = srcByte & 128 ? white : black;
  55046. dest32[destPos++] = srcByte & 64 ? white : black;
  55047. dest32[destPos++] = srcByte & 32 ? white : black;
  55048. dest32[destPos++] = srcByte & 16 ? white : black;
  55049. dest32[destPos++] = srcByte & 8 ? white : black;
  55050. dest32[destPos++] = srcByte & 4 ? white : black;
  55051. dest32[destPos++] = srcByte & 2 ? white : black;
  55052. dest32[destPos++] = srcByte & 1 ? white : black;
  55053. }
  55054. for (; k < kEnd; k++) {
  55055. if (mask === 0) {
  55056. srcByte = src[srcPos++];
  55057. mask = 128;
  55058. }
  55059. dest32[destPos++] = srcByte & mask ? white : black;
  55060. mask >>= 1;
  55061. }
  55062. }
  55063. while (destPos < dest32DataLength) {
  55064. dest32[destPos++] = 0;
  55065. }
  55066. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  55067. }
  55068. } else if (imgData.kind === ImageKind.RGBA_32BPP) {
  55069. j = 0;
  55070. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  55071. for (i = 0; i < fullChunks; i++) {
  55072. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  55073. srcPos += elemsInThisChunk;
  55074. ctx.putImageData(chunkImgData, 0, j);
  55075. j += FULL_CHUNK_HEIGHT;
  55076. }
  55077. if (i < totalChunks) {
  55078. elemsInThisChunk = width * partialChunkHeight * 4;
  55079. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  55080. ctx.putImageData(chunkImgData, 0, j);
  55081. }
  55082. } else if (imgData.kind === ImageKind.RGB_24BPP) {
  55083. thisChunkHeight = FULL_CHUNK_HEIGHT;
  55084. elemsInThisChunk = width * thisChunkHeight;
  55085. for (i = 0; i < totalChunks; i++) {
  55086. if (i >= fullChunks) {
  55087. thisChunkHeight = partialChunkHeight;
  55088. elemsInThisChunk = width * thisChunkHeight;
  55089. }
  55090. destPos = 0;
  55091. for (j = elemsInThisChunk; j--;) {
  55092. dest[destPos++] = src[srcPos++];
  55093. dest[destPos++] = src[srcPos++];
  55094. dest[destPos++] = src[srcPos++];
  55095. dest[destPos++] = 255;
  55096. }
  55097. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  55098. }
  55099. } else {
  55100. error('bad image kind: ' + imgData.kind);
  55101. }
  55102. }
  55103. function putBinaryImageMask(ctx, imgData) {
  55104. var height = imgData.height, width = imgData.width;
  55105. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  55106. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  55107. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  55108. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  55109. var srcPos = 0;
  55110. var src = imgData.data;
  55111. var dest = chunkImgData.data;
  55112. for (var i = 0; i < totalChunks; i++) {
  55113. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  55114. var destPos = 3;
  55115. for (var j = 0; j < thisChunkHeight; j++) {
  55116. var mask = 0;
  55117. for (var k = 0; k < width; k++) {
  55118. if (!mask) {
  55119. var elem = src[srcPos++];
  55120. mask = 128;
  55121. }
  55122. dest[destPos] = elem & mask ? 0 : 255;
  55123. destPos += 4;
  55124. mask >>= 1;
  55125. }
  55126. }
  55127. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  55128. }
  55129. }
  55130. function copyCtxState(sourceCtx, destCtx) {
  55131. var properties = [
  55132. 'strokeStyle',
  55133. 'fillStyle',
  55134. 'fillRule',
  55135. 'globalAlpha',
  55136. 'lineWidth',
  55137. 'lineCap',
  55138. 'lineJoin',
  55139. 'miterLimit',
  55140. 'globalCompositeOperation',
  55141. 'font'
  55142. ];
  55143. for (var i = 0, ii = properties.length; i < ii; i++) {
  55144. var property = properties[i];
  55145. if (sourceCtx[property] !== undefined) {
  55146. destCtx[property] = sourceCtx[property];
  55147. }
  55148. }
  55149. if (sourceCtx.setLineDash !== undefined) {
  55150. destCtx.setLineDash(sourceCtx.getLineDash());
  55151. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  55152. }
  55153. }
  55154. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  55155. var length = bytes.length;
  55156. for (var i = 3; i < length; i += 4) {
  55157. var alpha = bytes[i];
  55158. if (alpha === 0) {
  55159. bytes[i - 3] = r0;
  55160. bytes[i - 2] = g0;
  55161. bytes[i - 1] = b0;
  55162. } else if (alpha < 255) {
  55163. var alpha_ = 255 - alpha;
  55164. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  55165. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  55166. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  55167. }
  55168. }
  55169. }
  55170. function composeSMaskAlpha(maskData, layerData, transferMap) {
  55171. var length = maskData.length;
  55172. var scale = 1 / 255;
  55173. for (var i = 3; i < length; i += 4) {
  55174. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  55175. layerData[i] = layerData[i] * alpha * scale | 0;
  55176. }
  55177. }
  55178. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  55179. var length = maskData.length;
  55180. for (var i = 3; i < length; i += 4) {
  55181. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  55182. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  55183. }
  55184. }
  55185. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  55186. var hasBackdrop = !!backdrop;
  55187. var r0 = hasBackdrop ? backdrop[0] : 0;
  55188. var g0 = hasBackdrop ? backdrop[1] : 0;
  55189. var b0 = hasBackdrop ? backdrop[2] : 0;
  55190. var composeFn;
  55191. if (subtype === 'Luminosity') {
  55192. composeFn = composeSMaskLuminosity;
  55193. } else {
  55194. composeFn = composeSMaskAlpha;
  55195. }
  55196. var PIXELS_TO_PROCESS = 1048576;
  55197. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  55198. for (var row = 0; row < height; row += chunkSize) {
  55199. var chunkHeight = Math.min(chunkSize, height - row);
  55200. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  55201. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  55202. if (hasBackdrop) {
  55203. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  55204. }
  55205. composeFn(maskData.data, layerData.data, transferMap);
  55206. maskCtx.putImageData(layerData, 0, row);
  55207. }
  55208. }
  55209. function composeSMask(ctx, smask, layerCtx) {
  55210. var mask = smask.canvas;
  55211. var maskCtx = smask.context;
  55212. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  55213. var backdrop = smask.backdrop || null;
  55214. if (!smask.transferMap && WebGLUtils.isEnabled) {
  55215. var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  55216. subtype: smask.subtype,
  55217. backdrop: backdrop
  55218. });
  55219. ctx.setTransform(1, 0, 0, 1, 0, 0);
  55220. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  55221. return;
  55222. }
  55223. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  55224. ctx.drawImage(mask, 0, 0);
  55225. }
  55226. var LINE_CAP_STYLES = [
  55227. 'butt',
  55228. 'round',
  55229. 'square'
  55230. ];
  55231. var LINE_JOIN_STYLES = [
  55232. 'miter',
  55233. 'round',
  55234. 'bevel'
  55235. ];
  55236. var NORMAL_CLIP = {};
  55237. var EO_CLIP = {};
  55238. CanvasGraphics.prototype = {
  55239. beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
  55240. var width = this.ctx.canvas.width;
  55241. var height = this.ctx.canvas.height;
  55242. this.ctx.save();
  55243. this.ctx.fillStyle = 'rgb(255, 255, 255)';
  55244. this.ctx.fillRect(0, 0, width, height);
  55245. this.ctx.restore();
  55246. if (transparency) {
  55247. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  55248. this.compositeCtx = this.ctx;
  55249. this.transparentCanvas = transparentCanvas.canvas;
  55250. this.ctx = transparentCanvas.context;
  55251. this.ctx.save();
  55252. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  55253. }
  55254. this.ctx.save();
  55255. if (transform) {
  55256. this.ctx.transform.apply(this.ctx, transform);
  55257. }
  55258. this.ctx.transform.apply(this.ctx, viewport.transform);
  55259. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  55260. if (this.imageLayer) {
  55261. this.imageLayer.beginLayout();
  55262. }
  55263. },
  55264. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  55265. var argsArray = operatorList.argsArray;
  55266. var fnArray = operatorList.fnArray;
  55267. var i = executionStartIdx || 0;
  55268. var argsArrayLen = argsArray.length;
  55269. if (argsArrayLen === i) {
  55270. return i;
  55271. }
  55272. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  55273. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  55274. var steps = 0;
  55275. var commonObjs = this.commonObjs;
  55276. var objs = this.objs;
  55277. var fnId;
  55278. while (true) {
  55279. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  55280. stepper.breakIt(i, continueCallback);
  55281. return i;
  55282. }
  55283. fnId = fnArray[i];
  55284. if (fnId !== OPS.dependency) {
  55285. this[fnId].apply(this, argsArray[i]);
  55286. } else {
  55287. var deps = argsArray[i];
  55288. for (var n = 0, nn = deps.length; n < nn; n++) {
  55289. var depObjId = deps[n];
  55290. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  55291. var objsPool = common ? commonObjs : objs;
  55292. if (!objsPool.isResolved(depObjId)) {
  55293. objsPool.get(depObjId, continueCallback);
  55294. return i;
  55295. }
  55296. }
  55297. }
  55298. i++;
  55299. if (i === argsArrayLen) {
  55300. return i;
  55301. }
  55302. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  55303. if (Date.now() > endTime) {
  55304. continueCallback();
  55305. return i;
  55306. }
  55307. steps = 0;
  55308. }
  55309. }
  55310. },
  55311. endDrawing: function CanvasGraphics_endDrawing() {
  55312. if (this.current.activeSMask !== null) {
  55313. this.endSMaskGroup();
  55314. }
  55315. this.ctx.restore();
  55316. if (this.transparentCanvas) {
  55317. this.ctx = this.compositeCtx;
  55318. this.ctx.save();
  55319. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  55320. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  55321. this.ctx.restore();
  55322. this.transparentCanvas = null;
  55323. }
  55324. this.cachedCanvases.clear();
  55325. WebGLUtils.clear();
  55326. if (this.imageLayer) {
  55327. this.imageLayer.endLayout();
  55328. }
  55329. },
  55330. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  55331. this.current.lineWidth = width;
  55332. this.ctx.lineWidth = width;
  55333. },
  55334. setLineCap: function CanvasGraphics_setLineCap(style) {
  55335. this.ctx.lineCap = LINE_CAP_STYLES[style];
  55336. },
  55337. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  55338. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  55339. },
  55340. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  55341. this.ctx.miterLimit = limit;
  55342. },
  55343. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  55344. var ctx = this.ctx;
  55345. if (ctx.setLineDash !== undefined) {
  55346. ctx.setLineDash(dashArray);
  55347. ctx.lineDashOffset = dashPhase;
  55348. }
  55349. },
  55350. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
  55351. },
  55352. setFlatness: function CanvasGraphics_setFlatness(flatness) {
  55353. },
  55354. setGState: function CanvasGraphics_setGState(states) {
  55355. for (var i = 0, ii = states.length; i < ii; i++) {
  55356. var state = states[i];
  55357. var key = state[0];
  55358. var value = state[1];
  55359. switch (key) {
  55360. case 'LW':
  55361. this.setLineWidth(value);
  55362. break;
  55363. case 'LC':
  55364. this.setLineCap(value);
  55365. break;
  55366. case 'LJ':
  55367. this.setLineJoin(value);
  55368. break;
  55369. case 'ML':
  55370. this.setMiterLimit(value);
  55371. break;
  55372. case 'D':
  55373. this.setDash(value[0], value[1]);
  55374. break;
  55375. case 'RI':
  55376. this.setRenderingIntent(value);
  55377. break;
  55378. case 'FL':
  55379. this.setFlatness(value);
  55380. break;
  55381. case 'Font':
  55382. this.setFont(value[0], value[1]);
  55383. break;
  55384. case 'CA':
  55385. this.current.strokeAlpha = state[1];
  55386. break;
  55387. case 'ca':
  55388. this.current.fillAlpha = state[1];
  55389. this.ctx.globalAlpha = state[1];
  55390. break;
  55391. case 'BM':
  55392. if (value && value.name && value.name !== 'Normal') {
  55393. var mode = value.name.replace(/([A-Z])/g, function (c) {
  55394. return '-' + c.toLowerCase();
  55395. }).substring(1);
  55396. this.ctx.globalCompositeOperation = mode;
  55397. if (this.ctx.globalCompositeOperation !== mode) {
  55398. warn('globalCompositeOperation "' + mode + '" is not supported');
  55399. }
  55400. } else {
  55401. this.ctx.globalCompositeOperation = 'source-over';
  55402. }
  55403. break;
  55404. case 'SMask':
  55405. if (this.current.activeSMask) {
  55406. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  55407. this.suspendSMaskGroup();
  55408. } else {
  55409. this.endSMaskGroup();
  55410. }
  55411. }
  55412. this.current.activeSMask = value ? this.tempSMask : null;
  55413. if (this.current.activeSMask) {
  55414. this.beginSMaskGroup();
  55415. }
  55416. this.tempSMask = null;
  55417. break;
  55418. }
  55419. }
  55420. },
  55421. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  55422. var activeSMask = this.current.activeSMask;
  55423. var drawnWidth = activeSMask.canvas.width;
  55424. var drawnHeight = activeSMask.canvas.height;
  55425. var cacheId = 'smaskGroupAt' + this.groupLevel;
  55426. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  55427. var currentCtx = this.ctx;
  55428. var currentTransform = currentCtx.mozCurrentTransform;
  55429. this.ctx.save();
  55430. var groupCtx = scratchCanvas.context;
  55431. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  55432. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  55433. groupCtx.transform.apply(groupCtx, currentTransform);
  55434. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  55435. copyCtxState(currentCtx, groupCtx);
  55436. this.ctx = groupCtx;
  55437. this.setGState([
  55438. [
  55439. 'BM',
  55440. 'Normal'
  55441. ],
  55442. [
  55443. 'ca',
  55444. 1
  55445. ],
  55446. [
  55447. 'CA',
  55448. 1
  55449. ]
  55450. ]);
  55451. this.groupStack.push(currentCtx);
  55452. this.groupLevel++;
  55453. },
  55454. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  55455. var groupCtx = this.ctx;
  55456. this.groupLevel--;
  55457. this.ctx = this.groupStack.pop();
  55458. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  55459. this.ctx.restore();
  55460. this.ctx.save();
  55461. copyCtxState(groupCtx, this.ctx);
  55462. this.current.resumeSMaskCtx = groupCtx;
  55463. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  55464. this.ctx.transform.apply(this.ctx, deltaTransform);
  55465. groupCtx.save();
  55466. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  55467. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  55468. groupCtx.restore();
  55469. },
  55470. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  55471. var groupCtx = this.current.resumeSMaskCtx;
  55472. var currentCtx = this.ctx;
  55473. this.ctx = groupCtx;
  55474. this.groupStack.push(currentCtx);
  55475. this.groupLevel++;
  55476. },
  55477. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  55478. var groupCtx = this.ctx;
  55479. this.groupLevel--;
  55480. this.ctx = this.groupStack.pop();
  55481. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  55482. this.ctx.restore();
  55483. copyCtxState(groupCtx, this.ctx);
  55484. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  55485. this.ctx.transform.apply(this.ctx, deltaTransform);
  55486. },
  55487. save: function CanvasGraphics_save() {
  55488. this.ctx.save();
  55489. var old = this.current;
  55490. this.stateStack.push(old);
  55491. this.current = old.clone();
  55492. this.current.resumeSMaskCtx = null;
  55493. },
  55494. restore: function CanvasGraphics_restore() {
  55495. if (this.current.resumeSMaskCtx) {
  55496. this.resumeSMaskGroup();
  55497. }
  55498. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  55499. this.endSMaskGroup();
  55500. }
  55501. if (this.stateStack.length !== 0) {
  55502. this.current = this.stateStack.pop();
  55503. this.ctx.restore();
  55504. this.pendingClip = null;
  55505. this.cachedGetSinglePixelWidth = null;
  55506. }
  55507. },
  55508. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  55509. this.ctx.transform(a, b, c, d, e, f);
  55510. this.cachedGetSinglePixelWidth = null;
  55511. },
  55512. constructPath: function CanvasGraphics_constructPath(ops, args) {
  55513. var ctx = this.ctx;
  55514. var current = this.current;
  55515. var x = current.x, y = current.y;
  55516. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  55517. switch (ops[i] | 0) {
  55518. case OPS.rectangle:
  55519. x = args[j++];
  55520. y = args[j++];
  55521. var width = args[j++];
  55522. var height = args[j++];
  55523. if (width === 0) {
  55524. width = this.getSinglePixelWidth();
  55525. }
  55526. if (height === 0) {
  55527. height = this.getSinglePixelWidth();
  55528. }
  55529. var xw = x + width;
  55530. var yh = y + height;
  55531. this.ctx.moveTo(x, y);
  55532. this.ctx.lineTo(xw, y);
  55533. this.ctx.lineTo(xw, yh);
  55534. this.ctx.lineTo(x, yh);
  55535. this.ctx.lineTo(x, y);
  55536. this.ctx.closePath();
  55537. break;
  55538. case OPS.moveTo:
  55539. x = args[j++];
  55540. y = args[j++];
  55541. ctx.moveTo(x, y);
  55542. break;
  55543. case OPS.lineTo:
  55544. x = args[j++];
  55545. y = args[j++];
  55546. ctx.lineTo(x, y);
  55547. break;
  55548. case OPS.curveTo:
  55549. x = args[j + 4];
  55550. y = args[j + 5];
  55551. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  55552. j += 6;
  55553. break;
  55554. case OPS.curveTo2:
  55555. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  55556. x = args[j + 2];
  55557. y = args[j + 3];
  55558. j += 4;
  55559. break;
  55560. case OPS.curveTo3:
  55561. x = args[j + 2];
  55562. y = args[j + 3];
  55563. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  55564. j += 4;
  55565. break;
  55566. case OPS.closePath:
  55567. ctx.closePath();
  55568. break;
  55569. }
  55570. }
  55571. current.setCurrentPoint(x, y);
  55572. },
  55573. closePath: function CanvasGraphics_closePath() {
  55574. this.ctx.closePath();
  55575. },
  55576. stroke: function CanvasGraphics_stroke(consumePath) {
  55577. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  55578. var ctx = this.ctx;
  55579. var strokeColor = this.current.strokeColor;
  55580. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  55581. ctx.globalAlpha = this.current.strokeAlpha;
  55582. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  55583. ctx.save();
  55584. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  55585. ctx.stroke();
  55586. ctx.restore();
  55587. } else {
  55588. ctx.stroke();
  55589. }
  55590. if (consumePath) {
  55591. this.consumePath();
  55592. }
  55593. ctx.globalAlpha = this.current.fillAlpha;
  55594. },
  55595. closeStroke: function CanvasGraphics_closeStroke() {
  55596. this.closePath();
  55597. this.stroke();
  55598. },
  55599. fill: function CanvasGraphics_fill(consumePath) {
  55600. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  55601. var ctx = this.ctx;
  55602. var fillColor = this.current.fillColor;
  55603. var isPatternFill = this.current.patternFill;
  55604. var needRestore = false;
  55605. if (isPatternFill) {
  55606. ctx.save();
  55607. if (this.baseTransform) {
  55608. ctx.setTransform.apply(ctx, this.baseTransform);
  55609. }
  55610. ctx.fillStyle = fillColor.getPattern(ctx, this);
  55611. needRestore = true;
  55612. }
  55613. if (this.pendingEOFill) {
  55614. ctx.fill('evenodd');
  55615. this.pendingEOFill = false;
  55616. } else {
  55617. ctx.fill();
  55618. }
  55619. if (needRestore) {
  55620. ctx.restore();
  55621. }
  55622. if (consumePath) {
  55623. this.consumePath();
  55624. }
  55625. },
  55626. eoFill: function CanvasGraphics_eoFill() {
  55627. this.pendingEOFill = true;
  55628. this.fill();
  55629. },
  55630. fillStroke: function CanvasGraphics_fillStroke() {
  55631. this.fill(false);
  55632. this.stroke(false);
  55633. this.consumePath();
  55634. },
  55635. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  55636. this.pendingEOFill = true;
  55637. this.fillStroke();
  55638. },
  55639. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  55640. this.closePath();
  55641. this.fillStroke();
  55642. },
  55643. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  55644. this.pendingEOFill = true;
  55645. this.closePath();
  55646. this.fillStroke();
  55647. },
  55648. endPath: function CanvasGraphics_endPath() {
  55649. this.consumePath();
  55650. },
  55651. clip: function CanvasGraphics_clip() {
  55652. this.pendingClip = NORMAL_CLIP;
  55653. },
  55654. eoClip: function CanvasGraphics_eoClip() {
  55655. this.pendingClip = EO_CLIP;
  55656. },
  55657. beginText: function CanvasGraphics_beginText() {
  55658. this.current.textMatrix = IDENTITY_MATRIX;
  55659. this.current.textMatrixScale = 1;
  55660. this.current.x = this.current.lineX = 0;
  55661. this.current.y = this.current.lineY = 0;
  55662. },
  55663. endText: function CanvasGraphics_endText() {
  55664. var paths = this.pendingTextPaths;
  55665. var ctx = this.ctx;
  55666. if (paths === undefined) {
  55667. ctx.beginPath();
  55668. return;
  55669. }
  55670. ctx.save();
  55671. ctx.beginPath();
  55672. for (var i = 0; i < paths.length; i++) {
  55673. var path = paths[i];
  55674. ctx.setTransform.apply(ctx, path.transform);
  55675. ctx.translate(path.x, path.y);
  55676. path.addToPath(ctx, path.fontSize);
  55677. }
  55678. ctx.restore();
  55679. ctx.clip();
  55680. ctx.beginPath();
  55681. delete this.pendingTextPaths;
  55682. },
  55683. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  55684. this.current.charSpacing = spacing;
  55685. },
  55686. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  55687. this.current.wordSpacing = spacing;
  55688. },
  55689. setHScale: function CanvasGraphics_setHScale(scale) {
  55690. this.current.textHScale = scale / 100;
  55691. },
  55692. setLeading: function CanvasGraphics_setLeading(leading) {
  55693. this.current.leading = -leading;
  55694. },
  55695. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  55696. var fontObj = this.commonObjs.get(fontRefName);
  55697. var current = this.current;
  55698. if (!fontObj) {
  55699. error('Can\'t find font for ' + fontRefName);
  55700. }
  55701. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  55702. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  55703. warn('Invalid font matrix for font ' + fontRefName);
  55704. }
  55705. if (size < 0) {
  55706. size = -size;
  55707. current.fontDirection = -1;
  55708. } else {
  55709. current.fontDirection = 1;
  55710. }
  55711. this.current.font = fontObj;
  55712. this.current.fontSize = size;
  55713. if (fontObj.isType3Font) {
  55714. return;
  55715. }
  55716. var name = fontObj.loadedName || 'sans-serif';
  55717. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  55718. var italic = fontObj.italic ? 'italic' : 'normal';
  55719. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  55720. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  55721. this.current.fontSizeScale = size / browserFontSize;
  55722. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  55723. this.ctx.font = rule;
  55724. },
  55725. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  55726. this.current.textRenderingMode = mode;
  55727. },
  55728. setTextRise: function CanvasGraphics_setTextRise(rise) {
  55729. this.current.textRise = rise;
  55730. },
  55731. moveText: function CanvasGraphics_moveText(x, y) {
  55732. this.current.x = this.current.lineX += x;
  55733. this.current.y = this.current.lineY += y;
  55734. },
  55735. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  55736. this.setLeading(-y);
  55737. this.moveText(x, y);
  55738. },
  55739. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  55740. this.current.textMatrix = [
  55741. a,
  55742. b,
  55743. c,
  55744. d,
  55745. e,
  55746. f
  55747. ];
  55748. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  55749. this.current.x = this.current.lineX = 0;
  55750. this.current.y = this.current.lineY = 0;
  55751. },
  55752. nextLine: function CanvasGraphics_nextLine() {
  55753. this.moveText(0, this.current.leading);
  55754. },
  55755. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  55756. var ctx = this.ctx;
  55757. var current = this.current;
  55758. var font = current.font;
  55759. var textRenderingMode = current.textRenderingMode;
  55760. var fontSize = current.fontSize / current.fontSizeScale;
  55761. var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  55762. var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  55763. var addToPath;
  55764. if (font.disableFontFace || isAddToPathSet) {
  55765. addToPath = font.getPathGenerator(this.commonObjs, character);
  55766. }
  55767. if (font.disableFontFace) {
  55768. ctx.save();
  55769. ctx.translate(x, y);
  55770. ctx.beginPath();
  55771. addToPath(ctx, fontSize);
  55772. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55773. ctx.fill();
  55774. }
  55775. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55776. ctx.stroke();
  55777. }
  55778. ctx.restore();
  55779. } else {
  55780. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55781. ctx.fillText(character, x, y);
  55782. }
  55783. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55784. ctx.strokeText(character, x, y);
  55785. }
  55786. }
  55787. if (isAddToPathSet) {
  55788. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  55789. paths.push({
  55790. transform: ctx.mozCurrentTransform,
  55791. x: x,
  55792. y: y,
  55793. fontSize: fontSize,
  55794. addToPath: addToPath
  55795. });
  55796. }
  55797. },
  55798. get isFontSubpixelAAEnabled() {
  55799. var ctx = this.canvasFactory.create(10, 10).context;
  55800. ctx.scale(1.5, 1);
  55801. ctx.fillText('I', 0, 10);
  55802. var data = ctx.getImageData(0, 0, 10, 10).data;
  55803. var enabled = false;
  55804. for (var i = 3; i < data.length; i += 4) {
  55805. if (data[i] > 0 && data[i] < 255) {
  55806. enabled = true;
  55807. break;
  55808. }
  55809. }
  55810. return shadow(this, 'isFontSubpixelAAEnabled', enabled);
  55811. },
  55812. showText: function CanvasGraphics_showText(glyphs) {
  55813. var current = this.current;
  55814. var font = current.font;
  55815. if (font.isType3Font) {
  55816. return this.showType3Text(glyphs);
  55817. }
  55818. var fontSize = current.fontSize;
  55819. if (fontSize === 0) {
  55820. return;
  55821. }
  55822. var ctx = this.ctx;
  55823. var fontSizeScale = current.fontSizeScale;
  55824. var charSpacing = current.charSpacing;
  55825. var wordSpacing = current.wordSpacing;
  55826. var fontDirection = current.fontDirection;
  55827. var textHScale = current.textHScale * fontDirection;
  55828. var glyphsLength = glyphs.length;
  55829. var vertical = font.vertical;
  55830. var spacingDir = vertical ? 1 : -1;
  55831. var defaultVMetrics = font.defaultVMetrics;
  55832. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  55833. var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
  55834. ctx.save();
  55835. ctx.transform.apply(ctx, current.textMatrix);
  55836. ctx.translate(current.x, current.y + current.textRise);
  55837. if (current.patternFill) {
  55838. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  55839. }
  55840. if (fontDirection > 0) {
  55841. ctx.scale(textHScale, -1);
  55842. } else {
  55843. ctx.scale(textHScale, 1);
  55844. }
  55845. var lineWidth = current.lineWidth;
  55846. var scale = current.textMatrixScale;
  55847. if (scale === 0 || lineWidth === 0) {
  55848. var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  55849. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  55850. this.cachedGetSinglePixelWidth = null;
  55851. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  55852. }
  55853. } else {
  55854. lineWidth /= scale;
  55855. }
  55856. if (fontSizeScale !== 1.0) {
  55857. ctx.scale(fontSizeScale, fontSizeScale);
  55858. lineWidth /= fontSizeScale;
  55859. }
  55860. ctx.lineWidth = lineWidth;
  55861. var x = 0, i;
  55862. for (i = 0; i < glyphsLength; ++i) {
  55863. var glyph = glyphs[i];
  55864. if (isNum(glyph)) {
  55865. x += spacingDir * glyph * fontSize / 1000;
  55866. continue;
  55867. }
  55868. var restoreNeeded = false;
  55869. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55870. var character = glyph.fontChar;
  55871. var accent = glyph.accent;
  55872. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  55873. var width = glyph.width;
  55874. if (vertical) {
  55875. var vmetric, vx, vy;
  55876. vmetric = glyph.vmetric || defaultVMetrics;
  55877. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  55878. vx = -vx * widthAdvanceScale;
  55879. vy = vmetric[2] * widthAdvanceScale;
  55880. width = vmetric ? -vmetric[0] : width;
  55881. scaledX = vx / fontSizeScale;
  55882. scaledY = (x + vy) / fontSizeScale;
  55883. } else {
  55884. scaledX = x / fontSizeScale;
  55885. scaledY = 0;
  55886. }
  55887. if (font.remeasure && width > 0) {
  55888. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  55889. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  55890. var characterScaleX = width / measuredWidth;
  55891. restoreNeeded = true;
  55892. ctx.save();
  55893. ctx.scale(characterScaleX, 1);
  55894. scaledX /= characterScaleX;
  55895. } else if (width !== measuredWidth) {
  55896. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  55897. }
  55898. }
  55899. if (glyph.isInFont || font.missingFile) {
  55900. if (simpleFillText && !accent) {
  55901. ctx.fillText(character, scaledX, scaledY);
  55902. } else {
  55903. this.paintChar(character, scaledX, scaledY);
  55904. if (accent) {
  55905. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  55906. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  55907. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  55908. }
  55909. }
  55910. }
  55911. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  55912. x += charWidth;
  55913. if (restoreNeeded) {
  55914. ctx.restore();
  55915. }
  55916. }
  55917. if (vertical) {
  55918. current.y -= x * textHScale;
  55919. } else {
  55920. current.x += x * textHScale;
  55921. }
  55922. ctx.restore();
  55923. },
  55924. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  55925. var ctx = this.ctx;
  55926. var current = this.current;
  55927. var font = current.font;
  55928. var fontSize = current.fontSize;
  55929. var fontDirection = current.fontDirection;
  55930. var spacingDir = font.vertical ? 1 : -1;
  55931. var charSpacing = current.charSpacing;
  55932. var wordSpacing = current.wordSpacing;
  55933. var textHScale = current.textHScale * fontDirection;
  55934. var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
  55935. var glyphsLength = glyphs.length;
  55936. var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
  55937. var i, glyph, width, spacingLength;
  55938. if (isTextInvisible || fontSize === 0) {
  55939. return;
  55940. }
  55941. this.cachedGetSinglePixelWidth = null;
  55942. ctx.save();
  55943. ctx.transform.apply(ctx, current.textMatrix);
  55944. ctx.translate(current.x, current.y);
  55945. ctx.scale(textHScale, fontDirection);
  55946. for (i = 0; i < glyphsLength; ++i) {
  55947. glyph = glyphs[i];
  55948. if (isNum(glyph)) {
  55949. spacingLength = spacingDir * glyph * fontSize / 1000;
  55950. this.ctx.translate(spacingLength, 0);
  55951. current.x += spacingLength * textHScale;
  55952. continue;
  55953. }
  55954. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  55955. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  55956. if (!operatorList) {
  55957. warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
  55958. continue;
  55959. }
  55960. this.processingType3 = glyph;
  55961. this.save();
  55962. ctx.scale(fontSize, fontSize);
  55963. ctx.transform.apply(ctx, fontMatrix);
  55964. this.executeOperatorList(operatorList);
  55965. this.restore();
  55966. var transformed = Util.applyTransform([
  55967. glyph.width,
  55968. 0
  55969. ], fontMatrix);
  55970. width = transformed[0] * fontSize + spacing;
  55971. ctx.translate(width, 0);
  55972. current.x += width * textHScale;
  55973. }
  55974. ctx.restore();
  55975. this.processingType3 = null;
  55976. },
  55977. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
  55978. },
  55979. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  55980. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  55981. this.clip();
  55982. this.endPath();
  55983. },
  55984. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  55985. var pattern;
  55986. if (IR[0] === 'TilingPattern') {
  55987. var color = IR[1];
  55988. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  55989. var self = this;
  55990. var canvasGraphicsFactory = {
  55991. createCanvasGraphics: function (ctx) {
  55992. return new CanvasGraphics(ctx, self.commonObjs, self.objs, self.canvasFactory);
  55993. }
  55994. };
  55995. pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  55996. } else {
  55997. pattern = getShadingPatternFromIR(IR);
  55998. }
  55999. return pattern;
  56000. },
  56001. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  56002. this.current.strokeColor = this.getColorN_Pattern(arguments);
  56003. },
  56004. setFillColorN: function CanvasGraphics_setFillColorN() {
  56005. this.current.fillColor = this.getColorN_Pattern(arguments);
  56006. this.current.patternFill = true;
  56007. },
  56008. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  56009. var color = Util.makeCssRgb(r, g, b);
  56010. this.ctx.strokeStyle = color;
  56011. this.current.strokeColor = color;
  56012. },
  56013. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  56014. var color = Util.makeCssRgb(r, g, b);
  56015. this.ctx.fillStyle = color;
  56016. this.current.fillColor = color;
  56017. this.current.patternFill = false;
  56018. },
  56019. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  56020. var ctx = this.ctx;
  56021. this.save();
  56022. var pattern = getShadingPatternFromIR(patternIR);
  56023. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  56024. var inv = ctx.mozCurrentTransformInverse;
  56025. if (inv) {
  56026. var canvas = ctx.canvas;
  56027. var width = canvas.width;
  56028. var height = canvas.height;
  56029. var bl = Util.applyTransform([
  56030. 0,
  56031. 0
  56032. ], inv);
  56033. var br = Util.applyTransform([
  56034. 0,
  56035. height
  56036. ], inv);
  56037. var ul = Util.applyTransform([
  56038. width,
  56039. 0
  56040. ], inv);
  56041. var ur = Util.applyTransform([
  56042. width,
  56043. height
  56044. ], inv);
  56045. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  56046. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  56047. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  56048. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  56049. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  56050. } else {
  56051. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  56052. }
  56053. this.restore();
  56054. },
  56055. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  56056. error('Should not call beginInlineImage');
  56057. },
  56058. beginImageData: function CanvasGraphics_beginImageData() {
  56059. error('Should not call beginImageData');
  56060. },
  56061. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  56062. this.save();
  56063. this.baseTransformStack.push(this.baseTransform);
  56064. if (isArray(matrix) && matrix.length === 6) {
  56065. this.transform.apply(this, matrix);
  56066. }
  56067. this.baseTransform = this.ctx.mozCurrentTransform;
  56068. if (isArray(bbox) && bbox.length === 4) {
  56069. var width = bbox[2] - bbox[0];
  56070. var height = bbox[3] - bbox[1];
  56071. this.ctx.rect(bbox[0], bbox[1], width, height);
  56072. this.clip();
  56073. this.endPath();
  56074. }
  56075. },
  56076. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  56077. this.restore();
  56078. this.baseTransform = this.baseTransformStack.pop();
  56079. },
  56080. beginGroup: function CanvasGraphics_beginGroup(group) {
  56081. this.save();
  56082. var currentCtx = this.ctx;
  56083. if (!group.isolated) {
  56084. info('TODO: Support non-isolated groups.');
  56085. }
  56086. if (group.knockout) {
  56087. warn('Knockout groups not supported.');
  56088. }
  56089. var currentTransform = currentCtx.mozCurrentTransform;
  56090. if (group.matrix) {
  56091. currentCtx.transform.apply(currentCtx, group.matrix);
  56092. }
  56093. assert(group.bbox, 'Bounding box is required.');
  56094. var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  56095. var canvasBounds = [
  56096. 0,
  56097. 0,
  56098. currentCtx.canvas.width,
  56099. currentCtx.canvas.height
  56100. ];
  56101. bounds = Util.intersect(bounds, canvasBounds) || [
  56102. 0,
  56103. 0,
  56104. 0,
  56105. 0
  56106. ];
  56107. var offsetX = Math.floor(bounds[0]);
  56108. var offsetY = Math.floor(bounds[1]);
  56109. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  56110. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  56111. var scaleX = 1, scaleY = 1;
  56112. if (drawnWidth > MAX_GROUP_SIZE) {
  56113. scaleX = drawnWidth / MAX_GROUP_SIZE;
  56114. drawnWidth = MAX_GROUP_SIZE;
  56115. }
  56116. if (drawnHeight > MAX_GROUP_SIZE) {
  56117. scaleY = drawnHeight / MAX_GROUP_SIZE;
  56118. drawnHeight = MAX_GROUP_SIZE;
  56119. }
  56120. var cacheId = 'groupAt' + this.groupLevel;
  56121. if (group.smask) {
  56122. cacheId += '_smask_' + this.smaskCounter++ % 2;
  56123. }
  56124. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  56125. var groupCtx = scratchCanvas.context;
  56126. groupCtx.scale(1 / scaleX, 1 / scaleY);
  56127. groupCtx.translate(-offsetX, -offsetY);
  56128. groupCtx.transform.apply(groupCtx, currentTransform);
  56129. if (group.smask) {
  56130. this.smaskStack.push({
  56131. canvas: scratchCanvas.canvas,
  56132. context: groupCtx,
  56133. offsetX: offsetX,
  56134. offsetY: offsetY,
  56135. scaleX: scaleX,
  56136. scaleY: scaleY,
  56137. subtype: group.smask.subtype,
  56138. backdrop: group.smask.backdrop,
  56139. transferMap: group.smask.transferMap || null,
  56140. startTransformInverse: null
  56141. });
  56142. } else {
  56143. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  56144. currentCtx.translate(offsetX, offsetY);
  56145. currentCtx.scale(scaleX, scaleY);
  56146. }
  56147. copyCtxState(currentCtx, groupCtx);
  56148. this.ctx = groupCtx;
  56149. this.setGState([
  56150. [
  56151. 'BM',
  56152. 'Normal'
  56153. ],
  56154. [
  56155. 'ca',
  56156. 1
  56157. ],
  56158. [
  56159. 'CA',
  56160. 1
  56161. ]
  56162. ]);
  56163. this.groupStack.push(currentCtx);
  56164. this.groupLevel++;
  56165. this.current.activeSMask = null;
  56166. },
  56167. endGroup: function CanvasGraphics_endGroup(group) {
  56168. this.groupLevel--;
  56169. var groupCtx = this.ctx;
  56170. this.ctx = this.groupStack.pop();
  56171. if (this.ctx.imageSmoothingEnabled !== undefined) {
  56172. this.ctx.imageSmoothingEnabled = false;
  56173. } else {
  56174. this.ctx.mozImageSmoothingEnabled = false;
  56175. }
  56176. if (group.smask) {
  56177. this.tempSMask = this.smaskStack.pop();
  56178. } else {
  56179. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  56180. }
  56181. this.restore();
  56182. },
  56183. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  56184. this.save();
  56185. this.current = new CanvasExtraState();
  56186. if (this.baseTransform) {
  56187. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  56188. }
  56189. },
  56190. endAnnotations: function CanvasGraphics_endAnnotations() {
  56191. this.restore();
  56192. },
  56193. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  56194. this.save();
  56195. if (isArray(rect) && rect.length === 4) {
  56196. var width = rect[2] - rect[0];
  56197. var height = rect[3] - rect[1];
  56198. this.ctx.rect(rect[0], rect[1], width, height);
  56199. this.clip();
  56200. this.endPath();
  56201. }
  56202. this.transform.apply(this, transform);
  56203. this.transform.apply(this, matrix);
  56204. },
  56205. endAnnotation: function CanvasGraphics_endAnnotation() {
  56206. this.restore();
  56207. },
  56208. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  56209. var domImage = this.objs.get(objId);
  56210. if (!domImage) {
  56211. warn('Dependent image isn\'t ready yet');
  56212. return;
  56213. }
  56214. this.save();
  56215. var ctx = this.ctx;
  56216. ctx.scale(1 / w, -1 / h);
  56217. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  56218. if (this.imageLayer) {
  56219. var currentTransform = ctx.mozCurrentTransformInverse;
  56220. var position = this.getCanvasPosition(0, 0);
  56221. this.imageLayer.appendImage({
  56222. objId: objId,
  56223. left: position[0],
  56224. top: position[1],
  56225. width: w / currentTransform[0],
  56226. height: h / currentTransform[3]
  56227. });
  56228. }
  56229. this.restore();
  56230. },
  56231. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  56232. var ctx = this.ctx;
  56233. var width = img.width, height = img.height;
  56234. var fillColor = this.current.fillColor;
  56235. var isPatternFill = this.current.patternFill;
  56236. var glyph = this.processingType3;
  56237. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  56238. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  56239. glyph.compiled = compileType3Glyph({
  56240. data: img.data,
  56241. width: width,
  56242. height: height
  56243. });
  56244. } else {
  56245. glyph.compiled = null;
  56246. }
  56247. }
  56248. if (glyph && glyph.compiled) {
  56249. glyph.compiled(ctx);
  56250. return;
  56251. }
  56252. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  56253. var maskCtx = maskCanvas.context;
  56254. maskCtx.save();
  56255. putBinaryImageMask(maskCtx, img);
  56256. maskCtx.globalCompositeOperation = 'source-in';
  56257. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  56258. maskCtx.fillRect(0, 0, width, height);
  56259. maskCtx.restore();
  56260. this.paintInlineImageXObject(maskCanvas.canvas);
  56261. },
  56262. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  56263. var width = imgData.width;
  56264. var height = imgData.height;
  56265. var fillColor = this.current.fillColor;
  56266. var isPatternFill = this.current.patternFill;
  56267. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  56268. var maskCtx = maskCanvas.context;
  56269. maskCtx.save();
  56270. putBinaryImageMask(maskCtx, imgData);
  56271. maskCtx.globalCompositeOperation = 'source-in';
  56272. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  56273. maskCtx.fillRect(0, 0, width, height);
  56274. maskCtx.restore();
  56275. var ctx = this.ctx;
  56276. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  56277. ctx.save();
  56278. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  56279. ctx.scale(1, -1);
  56280. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  56281. ctx.restore();
  56282. }
  56283. },
  56284. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  56285. var ctx = this.ctx;
  56286. var fillColor = this.current.fillColor;
  56287. var isPatternFill = this.current.patternFill;
  56288. for (var i = 0, ii = images.length; i < ii; i++) {
  56289. var image = images[i];
  56290. var width = image.width, height = image.height;
  56291. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  56292. var maskCtx = maskCanvas.context;
  56293. maskCtx.save();
  56294. putBinaryImageMask(maskCtx, image);
  56295. maskCtx.globalCompositeOperation = 'source-in';
  56296. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  56297. maskCtx.fillRect(0, 0, width, height);
  56298. maskCtx.restore();
  56299. ctx.save();
  56300. ctx.transform.apply(ctx, image.transform);
  56301. ctx.scale(1, -1);
  56302. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  56303. ctx.restore();
  56304. }
  56305. },
  56306. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  56307. var imgData = this.objs.get(objId);
  56308. if (!imgData) {
  56309. warn('Dependent image isn\'t ready yet');
  56310. return;
  56311. }
  56312. this.paintInlineImageXObject(imgData);
  56313. },
  56314. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  56315. var imgData = this.objs.get(objId);
  56316. if (!imgData) {
  56317. warn('Dependent image isn\'t ready yet');
  56318. return;
  56319. }
  56320. var width = imgData.width;
  56321. var height = imgData.height;
  56322. var map = [];
  56323. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  56324. map.push({
  56325. transform: [
  56326. scaleX,
  56327. 0,
  56328. 0,
  56329. scaleY,
  56330. positions[i],
  56331. positions[i + 1]
  56332. ],
  56333. x: 0,
  56334. y: 0,
  56335. w: width,
  56336. h: height
  56337. });
  56338. }
  56339. this.paintInlineImageXObjectGroup(imgData, map);
  56340. },
  56341. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  56342. var width = imgData.width;
  56343. var height = imgData.height;
  56344. var ctx = this.ctx;
  56345. this.save();
  56346. ctx.scale(1 / width, -1 / height);
  56347. var currentTransform = ctx.mozCurrentTransformInverse;
  56348. var a = currentTransform[0], b = currentTransform[1];
  56349. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  56350. var c = currentTransform[2], d = currentTransform[3];
  56351. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  56352. var imgToPaint, tmpCanvas;
  56353. if (imgData instanceof HTMLElement || !imgData.data) {
  56354. imgToPaint = imgData;
  56355. } else {
  56356. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  56357. var tmpCtx = tmpCanvas.context;
  56358. putBinaryImageData(tmpCtx, imgData);
  56359. imgToPaint = tmpCanvas.canvas;
  56360. }
  56361. var paintWidth = width, paintHeight = height;
  56362. var tmpCanvasId = 'prescale1';
  56363. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  56364. var newWidth = paintWidth, newHeight = paintHeight;
  56365. if (widthScale > 2 && paintWidth > 1) {
  56366. newWidth = Math.ceil(paintWidth / 2);
  56367. widthScale /= paintWidth / newWidth;
  56368. }
  56369. if (heightScale > 2 && paintHeight > 1) {
  56370. newHeight = Math.ceil(paintHeight / 2);
  56371. heightScale /= paintHeight / newHeight;
  56372. }
  56373. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  56374. tmpCtx = tmpCanvas.context;
  56375. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  56376. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  56377. imgToPaint = tmpCanvas.canvas;
  56378. paintWidth = newWidth;
  56379. paintHeight = newHeight;
  56380. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  56381. }
  56382. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  56383. if (this.imageLayer) {
  56384. var position = this.getCanvasPosition(0, -height);
  56385. this.imageLayer.appendImage({
  56386. imgData: imgData,
  56387. left: position[0],
  56388. top: position[1],
  56389. width: width / currentTransform[0],
  56390. height: height / currentTransform[3]
  56391. });
  56392. }
  56393. this.restore();
  56394. },
  56395. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  56396. var ctx = this.ctx;
  56397. var w = imgData.width;
  56398. var h = imgData.height;
  56399. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  56400. var tmpCtx = tmpCanvas.context;
  56401. putBinaryImageData(tmpCtx, imgData);
  56402. for (var i = 0, ii = map.length; i < ii; i++) {
  56403. var entry = map[i];
  56404. ctx.save();
  56405. ctx.transform.apply(ctx, entry.transform);
  56406. ctx.scale(1, -1);
  56407. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  56408. if (this.imageLayer) {
  56409. var position = this.getCanvasPosition(entry.x, entry.y);
  56410. this.imageLayer.appendImage({
  56411. imgData: imgData,
  56412. left: position[0],
  56413. top: position[1],
  56414. width: w,
  56415. height: h
  56416. });
  56417. }
  56418. ctx.restore();
  56419. }
  56420. },
  56421. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  56422. this.ctx.fillRect(0, 0, 1, 1);
  56423. },
  56424. paintXObject: function CanvasGraphics_paintXObject() {
  56425. warn('Unsupported \'paintXObject\' command.');
  56426. },
  56427. markPoint: function CanvasGraphics_markPoint(tag) {
  56428. },
  56429. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
  56430. },
  56431. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  56432. },
  56433. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  56434. },
  56435. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  56436. },
  56437. beginCompat: function CanvasGraphics_beginCompat() {
  56438. },
  56439. endCompat: function CanvasGraphics_endCompat() {
  56440. },
  56441. consumePath: function CanvasGraphics_consumePath() {
  56442. var ctx = this.ctx;
  56443. if (this.pendingClip) {
  56444. if (this.pendingClip === EO_CLIP) {
  56445. ctx.clip('evenodd');
  56446. } else {
  56447. ctx.clip();
  56448. }
  56449. this.pendingClip = null;
  56450. }
  56451. ctx.beginPath();
  56452. },
  56453. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  56454. if (this.cachedGetSinglePixelWidth === null) {
  56455. this.ctx.save();
  56456. var inverse = this.ctx.mozCurrentTransformInverse;
  56457. this.ctx.restore();
  56458. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  56459. }
  56460. return this.cachedGetSinglePixelWidth;
  56461. },
  56462. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  56463. var transform = this.ctx.mozCurrentTransform;
  56464. return [
  56465. transform[0] * x + transform[2] * y + transform[4],
  56466. transform[1] * x + transform[3] * y + transform[5]
  56467. ];
  56468. }
  56469. };
  56470. for (var op in OPS) {
  56471. CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
  56472. }
  56473. return CanvasGraphics;
  56474. }();
  56475. exports.CanvasGraphics = CanvasGraphics;
  56476. /***/ }),
  56477. /* 45 */
  56478. /***/ (function(module, exports, __w_pdfjs_require__) {
  56479. "use strict";
  56480. var sharedUtil = __w_pdfjs_require__(0);
  56481. var assert = sharedUtil.assert;
  56482. var bytesToString = sharedUtil.bytesToString;
  56483. var string32 = sharedUtil.string32;
  56484. var shadow = sharedUtil.shadow;
  56485. var warn = sharedUtil.warn;
  56486. function FontLoader(docId) {
  56487. this.docId = docId;
  56488. this.styleElement = null;
  56489. this.nativeFontFaces = [];
  56490. this.loadTestFontId = 0;
  56491. this.loadingContext = {
  56492. requests: [],
  56493. nextRequestId: 0
  56494. };
  56495. }
  56496. FontLoader.prototype = {
  56497. insertRule: function fontLoaderInsertRule(rule) {
  56498. var styleElement = this.styleElement;
  56499. if (!styleElement) {
  56500. styleElement = this.styleElement = document.createElement('style');
  56501. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  56502. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  56503. }
  56504. var styleSheet = styleElement.sheet;
  56505. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  56506. },
  56507. clear: function fontLoaderClear() {
  56508. if (this.styleElement) {
  56509. this.styleElement.remove();
  56510. this.styleElement = null;
  56511. }
  56512. this.nativeFontFaces.forEach(function (nativeFontFace) {
  56513. document.fonts.delete(nativeFontFace);
  56514. });
  56515. this.nativeFontFaces.length = 0;
  56516. }
  56517. };
  56518. var getLoadTestFont = function () {
  56519. return atob('T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQ' + 'AABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwA' + 'AAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbm' + 'FtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAA' + 'AADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6A' + 'ABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAA' + 'MQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAA' + 'AAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAA' + 'AAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQ' + 'AAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMA' + 'AQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAA' + 'EAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAA' + 'AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAA' + 'AAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgc' + 'A/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWF' + 'hYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQA' + 'AAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAg' + 'ABAAAAAAAAAAAD6AAAAAAAAA==');
  56520. };
  56521. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  56522. get: function () {
  56523. return shadow(this, 'loadTestFont', getLoadTestFont());
  56524. },
  56525. configurable: true
  56526. });
  56527. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  56528. this.nativeFontFaces.push(nativeFontFace);
  56529. document.fonts.add(nativeFontFace);
  56530. };
  56531. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  56532. var rules = [];
  56533. var fontsToLoad = [];
  56534. var fontLoadPromises = [];
  56535. var getNativeFontPromise = function (nativeFontFace) {
  56536. return nativeFontFace.loaded.catch(function (e) {
  56537. warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
  56538. });
  56539. };
  56540. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  56541. for (var i = 0, ii = fonts.length; i < ii; i++) {
  56542. var font = fonts[i];
  56543. if (font.attached || font.loading === false) {
  56544. continue;
  56545. }
  56546. font.attached = true;
  56547. if (isFontLoadingAPISupported) {
  56548. var nativeFontFace = font.createNativeFontFace();
  56549. if (nativeFontFace) {
  56550. this.addNativeFontFace(nativeFontFace);
  56551. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  56552. }
  56553. } else {
  56554. var rule = font.createFontFaceRule();
  56555. if (rule) {
  56556. this.insertRule(rule);
  56557. rules.push(rule);
  56558. fontsToLoad.push(font);
  56559. }
  56560. }
  56561. }
  56562. var request = this.queueLoadingCallback(callback);
  56563. if (isFontLoadingAPISupported) {
  56564. Promise.all(fontLoadPromises).then(function () {
  56565. request.complete();
  56566. });
  56567. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  56568. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  56569. } else {
  56570. request.complete();
  56571. }
  56572. };
  56573. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  56574. function LoadLoader_completeRequest() {
  56575. assert(!request.end, 'completeRequest() cannot be called twice');
  56576. request.end = Date.now();
  56577. while (context.requests.length > 0 && context.requests[0].end) {
  56578. var otherRequest = context.requests.shift();
  56579. setTimeout(otherRequest.callback, 0);
  56580. }
  56581. }
  56582. var context = this.loadingContext;
  56583. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  56584. var request = {
  56585. id: requestId,
  56586. complete: LoadLoader_completeRequest,
  56587. callback: callback,
  56588. started: Date.now()
  56589. };
  56590. context.requests.push(request);
  56591. return request;
  56592. };
  56593. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  56594. function int32(data, offset) {
  56595. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  56596. }
  56597. function spliceString(s, offset, remove, insert) {
  56598. var chunk1 = s.substr(0, offset);
  56599. var chunk2 = s.substr(offset + remove);
  56600. return chunk1 + insert + chunk2;
  56601. }
  56602. var i, ii;
  56603. var canvas = document.createElement('canvas');
  56604. canvas.width = 1;
  56605. canvas.height = 1;
  56606. var ctx = canvas.getContext('2d');
  56607. var called = 0;
  56608. function isFontReady(name, callback) {
  56609. called++;
  56610. if (called > 30) {
  56611. warn('Load test font never loaded.');
  56612. callback();
  56613. return;
  56614. }
  56615. ctx.font = '30px ' + name;
  56616. ctx.fillText('.', 0, 20);
  56617. var imageData = ctx.getImageData(0, 0, 1, 1);
  56618. if (imageData.data[3] > 0) {
  56619. callback();
  56620. return;
  56621. }
  56622. setTimeout(isFontReady.bind(null, name, callback));
  56623. }
  56624. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  56625. var data = this.loadTestFont;
  56626. var COMMENT_OFFSET = 976;
  56627. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  56628. var CFF_CHECKSUM_OFFSET = 16;
  56629. var XXXX_VALUE = 0x58585858;
  56630. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  56631. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  56632. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  56633. }
  56634. if (i < loadTestFontId.length) {
  56635. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  56636. }
  56637. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
  56638. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  56639. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  56640. this.insertRule(rule);
  56641. var names = [];
  56642. for (i = 0, ii = fonts.length; i < ii; i++) {
  56643. names.push(fonts[i].loadedName);
  56644. }
  56645. names.push(loadTestFontId);
  56646. var div = document.createElement('div');
  56647. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  56648. for (i = 0, ii = names.length; i < ii; ++i) {
  56649. var span = document.createElement('span');
  56650. span.textContent = 'Hi';
  56651. span.style.fontFamily = names[i];
  56652. div.appendChild(span);
  56653. }
  56654. document.body.appendChild(div);
  56655. isFontReady(loadTestFontId, function () {
  56656. document.body.removeChild(div);
  56657. request.complete();
  56658. });
  56659. };
  56660. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  56661. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  56662. if (typeof navigator === 'undefined') {
  56663. return true;
  56664. }
  56665. var supported = false;
  56666. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  56667. if (m && m[1] >= 14) {
  56668. supported = true;
  56669. }
  56670. return supported;
  56671. };
  56672. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  56673. get: function () {
  56674. return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  56675. },
  56676. enumerable: true,
  56677. configurable: true
  56678. });
  56679. var IsEvalSupportedCached = {
  56680. get value() {
  56681. return shadow(this, 'value', sharedUtil.isEvalSupported());
  56682. }
  56683. };
  56684. var FontFaceObject = function FontFaceObjectClosure() {
  56685. function FontFaceObject(translatedData, options) {
  56686. this.compiledGlyphs = Object.create(null);
  56687. for (var i in translatedData) {
  56688. this[i] = translatedData[i];
  56689. }
  56690. this.options = options;
  56691. }
  56692. FontFaceObject.prototype = {
  56693. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  56694. if (!this.data) {
  56695. return null;
  56696. }
  56697. if (this.options.disableFontFace) {
  56698. this.disableFontFace = true;
  56699. return null;
  56700. }
  56701. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  56702. if (this.options.fontRegistry) {
  56703. this.options.fontRegistry.registerFont(this);
  56704. }
  56705. return nativeFontFace;
  56706. },
  56707. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  56708. if (!this.data) {
  56709. return null;
  56710. }
  56711. if (this.options.disableFontFace) {
  56712. this.disableFontFace = true;
  56713. return null;
  56714. }
  56715. var data = bytesToString(new Uint8Array(this.data));
  56716. var fontName = this.loadedName;
  56717. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  56718. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  56719. if (this.options.fontRegistry) {
  56720. this.options.fontRegistry.registerFont(this, url);
  56721. }
  56722. return rule;
  56723. },
  56724. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  56725. if (!(character in this.compiledGlyphs)) {
  56726. var cmds = objs.get(this.loadedName + '_path_' + character);
  56727. var current, i, len;
  56728. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  56729. var args, js = '';
  56730. for (i = 0, len = cmds.length; i < len; i++) {
  56731. current = cmds[i];
  56732. if (current.args !== undefined) {
  56733. args = current.args.join(',');
  56734. } else {
  56735. args = '';
  56736. }
  56737. js += 'c.' + current.cmd + '(' + args + ');\n';
  56738. }
  56739. this.compiledGlyphs[character] = new Function('c', 'size', js);
  56740. } else {
  56741. this.compiledGlyphs[character] = function (c, size) {
  56742. for (i = 0, len = cmds.length; i < len; i++) {
  56743. current = cmds[i];
  56744. if (current.cmd === 'scale') {
  56745. current.args = [
  56746. size,
  56747. -size
  56748. ];
  56749. }
  56750. c[current.cmd].apply(c, current.args);
  56751. }
  56752. };
  56753. }
  56754. }
  56755. return this.compiledGlyphs[character];
  56756. }
  56757. };
  56758. return FontFaceObject;
  56759. }();
  56760. exports.FontFaceObject = FontFaceObject;
  56761. exports.FontLoader = FontLoader;
  56762. /***/ }),
  56763. /* 46 */
  56764. /***/ (function(module, exports, __w_pdfjs_require__) {
  56765. "use strict";
  56766. var sharedUtil = __w_pdfjs_require__(0);
  56767. var displayWebGL = __w_pdfjs_require__(24);
  56768. var Util = sharedUtil.Util;
  56769. var info = sharedUtil.info;
  56770. var isArray = sharedUtil.isArray;
  56771. var error = sharedUtil.error;
  56772. var WebGLUtils = displayWebGL.WebGLUtils;
  56773. var ShadingIRs = {};
  56774. ShadingIRs.RadialAxial = {
  56775. fromIR: function RadialAxial_fromIR(raw) {
  56776. var type = raw[1];
  56777. var colorStops = raw[2];
  56778. var p0 = raw[3];
  56779. var p1 = raw[4];
  56780. var r0 = raw[5];
  56781. var r1 = raw[6];
  56782. return {
  56783. type: 'Pattern',
  56784. getPattern: function RadialAxial_getPattern(ctx) {
  56785. var grad;
  56786. if (type === 'axial') {
  56787. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  56788. } else if (type === 'radial') {
  56789. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  56790. }
  56791. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  56792. var c = colorStops[i];
  56793. grad.addColorStop(c[0], c[1]);
  56794. }
  56795. return grad;
  56796. }
  56797. };
  56798. }
  56799. };
  56800. var createMeshCanvas = function createMeshCanvasClosure() {
  56801. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  56802. var coords = context.coords, colors = context.colors;
  56803. var bytes = data.data, rowSize = data.width * 4;
  56804. var tmp;
  56805. if (coords[p1 + 1] > coords[p2 + 1]) {
  56806. tmp = p1;
  56807. p1 = p2;
  56808. p2 = tmp;
  56809. tmp = c1;
  56810. c1 = c2;
  56811. c2 = tmp;
  56812. }
  56813. if (coords[p2 + 1] > coords[p3 + 1]) {
  56814. tmp = p2;
  56815. p2 = p3;
  56816. p3 = tmp;
  56817. tmp = c2;
  56818. c2 = c3;
  56819. c3 = tmp;
  56820. }
  56821. if (coords[p1 + 1] > coords[p2 + 1]) {
  56822. tmp = p1;
  56823. p1 = p2;
  56824. p2 = tmp;
  56825. tmp = c1;
  56826. c1 = c2;
  56827. c2 = tmp;
  56828. }
  56829. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  56830. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  56831. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  56832. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  56833. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  56834. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  56835. if (y1 >= y3) {
  56836. return;
  56837. }
  56838. var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
  56839. var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
  56840. var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
  56841. var minY = Math.round(y1), maxY = Math.round(y3);
  56842. var xa, car, cag, cab;
  56843. var xb, cbr, cbg, cbb;
  56844. var k;
  56845. for (var y = minY; y <= maxY; y++) {
  56846. if (y < y2) {
  56847. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  56848. xa = x1 - (x1 - x2) * k;
  56849. car = c1r - (c1r - c2r) * k;
  56850. cag = c1g - (c1g - c2g) * k;
  56851. cab = c1b - (c1b - c2b) * k;
  56852. } else {
  56853. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  56854. xa = x2 - (x2 - x3) * k;
  56855. car = c2r - (c2r - c3r) * k;
  56856. cag = c2g - (c2g - c3g) * k;
  56857. cab = c2b - (c2b - c3b) * k;
  56858. }
  56859. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  56860. xb = x1 - (x1 - x3) * k;
  56861. cbr = c1r - (c1r - c3r) * k;
  56862. cbg = c1g - (c1g - c3g) * k;
  56863. cbb = c1b - (c1b - c3b) * k;
  56864. var x1_ = Math.round(Math.min(xa, xb));
  56865. var x2_ = Math.round(Math.max(xa, xb));
  56866. var j = rowSize * y + x1_ * 4;
  56867. for (var x = x1_; x <= x2_; x++) {
  56868. k = (xa - x) / (xa - xb);
  56869. k = k < 0 ? 0 : k > 1 ? 1 : k;
  56870. bytes[j++] = car - (car - cbr) * k | 0;
  56871. bytes[j++] = cag - (cag - cbg) * k | 0;
  56872. bytes[j++] = cab - (cab - cbb) * k | 0;
  56873. bytes[j++] = 255;
  56874. }
  56875. }
  56876. }
  56877. function drawFigure(data, figure, context) {
  56878. var ps = figure.coords;
  56879. var cs = figure.colors;
  56880. var i, ii;
  56881. switch (figure.type) {
  56882. case 'lattice':
  56883. var verticesPerRow = figure.verticesPerRow;
  56884. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  56885. var cols = verticesPerRow - 1;
  56886. for (i = 0; i < rows; i++) {
  56887. var q = i * verticesPerRow;
  56888. for (var j = 0; j < cols; j++, q++) {
  56889. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  56890. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  56891. }
  56892. }
  56893. break;
  56894. case 'triangles':
  56895. for (i = 0, ii = ps.length; i < ii; i += 3) {
  56896. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  56897. }
  56898. break;
  56899. default:
  56900. error('illigal figure');
  56901. break;
  56902. }
  56903. }
  56904. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  56905. var EXPECTED_SCALE = 1.1;
  56906. var MAX_PATTERN_SIZE = 3000;
  56907. var BORDER_SIZE = 2;
  56908. var offsetX = Math.floor(bounds[0]);
  56909. var offsetY = Math.floor(bounds[1]);
  56910. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  56911. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  56912. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56913. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  56914. var scaleX = boundsWidth / width;
  56915. var scaleY = boundsHeight / height;
  56916. var context = {
  56917. coords: coords,
  56918. colors: colors,
  56919. offsetX: -offsetX,
  56920. offsetY: -offsetY,
  56921. scaleX: 1 / scaleX,
  56922. scaleY: 1 / scaleY
  56923. };
  56924. var paddedWidth = width + BORDER_SIZE * 2;
  56925. var paddedHeight = height + BORDER_SIZE * 2;
  56926. var canvas, tmpCanvas, i, ii;
  56927. if (WebGLUtils.isEnabled) {
  56928. canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  56929. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56930. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  56931. canvas = tmpCanvas.canvas;
  56932. } else {
  56933. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  56934. var tmpCtx = tmpCanvas.context;
  56935. var data = tmpCtx.createImageData(width, height);
  56936. if (backgroundColor) {
  56937. var bytes = data.data;
  56938. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  56939. bytes[i] = backgroundColor[0];
  56940. bytes[i + 1] = backgroundColor[1];
  56941. bytes[i + 2] = backgroundColor[2];
  56942. bytes[i + 3] = 255;
  56943. }
  56944. }
  56945. for (i = 0; i < figures.length; i++) {
  56946. drawFigure(data, figures[i], context);
  56947. }
  56948. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  56949. canvas = tmpCanvas.canvas;
  56950. }
  56951. return {
  56952. canvas: canvas,
  56953. offsetX: offsetX - BORDER_SIZE * scaleX,
  56954. offsetY: offsetY - BORDER_SIZE * scaleY,
  56955. scaleX: scaleX,
  56956. scaleY: scaleY
  56957. };
  56958. }
  56959. return createMeshCanvas;
  56960. }();
  56961. ShadingIRs.Mesh = {
  56962. fromIR: function Mesh_fromIR(raw) {
  56963. var coords = raw[2];
  56964. var colors = raw[3];
  56965. var figures = raw[4];
  56966. var bounds = raw[5];
  56967. var matrix = raw[6];
  56968. var background = raw[8];
  56969. return {
  56970. type: 'Pattern',
  56971. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  56972. var scale;
  56973. if (shadingFill) {
  56974. scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  56975. } else {
  56976. scale = Util.singularValueDecompose2dScale(owner.baseTransform);
  56977. if (matrix) {
  56978. var matrixScale = Util.singularValueDecompose2dScale(matrix);
  56979. scale = [
  56980. scale[0] * matrixScale[0],
  56981. scale[1] * matrixScale[1]
  56982. ];
  56983. }
  56984. }
  56985. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  56986. if (!shadingFill) {
  56987. ctx.setTransform.apply(ctx, owner.baseTransform);
  56988. if (matrix) {
  56989. ctx.transform.apply(ctx, matrix);
  56990. }
  56991. }
  56992. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  56993. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  56994. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  56995. }
  56996. };
  56997. }
  56998. };
  56999. ShadingIRs.Dummy = {
  57000. fromIR: function Dummy_fromIR() {
  57001. return {
  57002. type: 'Pattern',
  57003. getPattern: function Dummy_fromIR_getPattern() {
  57004. return 'hotpink';
  57005. }
  57006. };
  57007. }
  57008. };
  57009. function getShadingPatternFromIR(raw) {
  57010. var shadingIR = ShadingIRs[raw[0]];
  57011. if (!shadingIR) {
  57012. error('Unknown IR type: ' + raw[0]);
  57013. }
  57014. return shadingIR.fromIR(raw);
  57015. }
  57016. var TilingPattern = function TilingPatternClosure() {
  57017. var PaintType = {
  57018. COLORED: 1,
  57019. UNCOLORED: 2
  57020. };
  57021. var MAX_PATTERN_SIZE = 3000;
  57022. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  57023. this.operatorList = IR[2];
  57024. this.matrix = IR[3] || [
  57025. 1,
  57026. 0,
  57027. 0,
  57028. 1,
  57029. 0,
  57030. 0
  57031. ];
  57032. this.bbox = IR[4];
  57033. this.xstep = IR[5];
  57034. this.ystep = IR[6];
  57035. this.paintType = IR[7];
  57036. this.tilingType = IR[8];
  57037. this.color = color;
  57038. this.canvasGraphicsFactory = canvasGraphicsFactory;
  57039. this.baseTransform = baseTransform;
  57040. this.type = 'Pattern';
  57041. this.ctx = ctx;
  57042. }
  57043. TilingPattern.prototype = {
  57044. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  57045. var operatorList = this.operatorList;
  57046. var bbox = this.bbox;
  57047. var xstep = this.xstep;
  57048. var ystep = this.ystep;
  57049. var paintType = this.paintType;
  57050. var tilingType = this.tilingType;
  57051. var color = this.color;
  57052. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  57053. info('TilingType: ' + tilingType);
  57054. var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
  57055. var topLeft = [
  57056. x0,
  57057. y0
  57058. ];
  57059. var botRight = [
  57060. x0 + xstep,
  57061. y0 + ystep
  57062. ];
  57063. var width = botRight[0] - topLeft[0];
  57064. var height = botRight[1] - topLeft[1];
  57065. var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
  57066. var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
  57067. var combinedScale = [
  57068. matrixScale[0] * curMatrixScale[0],
  57069. matrixScale[1] * curMatrixScale[1]
  57070. ];
  57071. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  57072. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  57073. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  57074. var tmpCtx = tmpCanvas.context;
  57075. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  57076. graphics.groupLevel = owner.groupLevel;
  57077. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  57078. this.setScale(width, height, xstep, ystep);
  57079. this.transformToScale(graphics);
  57080. var tmpTranslate = [
  57081. 1,
  57082. 0,
  57083. 0,
  57084. 1,
  57085. -topLeft[0],
  57086. -topLeft[1]
  57087. ];
  57088. graphics.transform.apply(graphics, tmpTranslate);
  57089. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  57090. graphics.executeOperatorList(operatorList);
  57091. return tmpCanvas.canvas;
  57092. },
  57093. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  57094. this.scale = [
  57095. width / xstep,
  57096. height / ystep
  57097. ];
  57098. },
  57099. transformToScale: function TilingPattern_transformToScale(graphics) {
  57100. var scale = this.scale;
  57101. var tmpScale = [
  57102. scale[0],
  57103. 0,
  57104. 0,
  57105. scale[1],
  57106. 0,
  57107. 0
  57108. ];
  57109. graphics.transform.apply(graphics, tmpScale);
  57110. },
  57111. scaleToContext: function TilingPattern_scaleToContext() {
  57112. var scale = this.scale;
  57113. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  57114. },
  57115. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  57116. if (bbox && isArray(bbox) && bbox.length === 4) {
  57117. var bboxWidth = x1 - x0;
  57118. var bboxHeight = y1 - y0;
  57119. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  57120. graphics.clip();
  57121. graphics.endPath();
  57122. }
  57123. },
  57124. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  57125. switch (paintType) {
  57126. case PaintType.COLORED:
  57127. var ctx = this.ctx;
  57128. context.fillStyle = ctx.fillStyle;
  57129. context.strokeStyle = ctx.strokeStyle;
  57130. break;
  57131. case PaintType.UNCOLORED:
  57132. var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
  57133. context.fillStyle = cssColor;
  57134. context.strokeStyle = cssColor;
  57135. break;
  57136. default:
  57137. error('Unsupported paint type: ' + paintType);
  57138. }
  57139. },
  57140. getPattern: function TilingPattern_getPattern(ctx, owner) {
  57141. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  57142. ctx = this.ctx;
  57143. ctx.setTransform.apply(ctx, this.baseTransform);
  57144. ctx.transform.apply(ctx, this.matrix);
  57145. this.scaleToContext();
  57146. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  57147. }
  57148. };
  57149. return TilingPattern;
  57150. }();
  57151. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  57152. exports.TilingPattern = TilingPattern;
  57153. /***/ }),
  57154. /* 47 */
  57155. /***/ (function(module, exports, __w_pdfjs_require__) {
  57156. "use strict";
  57157. var pdfjsVersion = '1.7.314';
  57158. var pdfjsBuild = '912c952d';
  57159. var pdfjsSharedUtil = __w_pdfjs_require__(0);
  57160. var pdfjsDisplayGlobal = __w_pdfjs_require__(25);
  57161. var pdfjsDisplayAPI = __w_pdfjs_require__(10);
  57162. var pdfjsDisplayTextLayer = __w_pdfjs_require__(12);
  57163. var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(9);
  57164. var pdfjsDisplayDOMUtils = __w_pdfjs_require__(3);
  57165. var pdfjsDisplaySVG = __w_pdfjs_require__(11);
  57166. exports.PDFJS = pdfjsDisplayGlobal.PDFJS;
  57167. exports.build = pdfjsDisplayAPI.build;
  57168. exports.version = pdfjsDisplayAPI.version;
  57169. exports.getDocument = pdfjsDisplayAPI.getDocument;
  57170. exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;
  57171. exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;
  57172. exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;
  57173. exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;
  57174. exports.CustomStyle = pdfjsDisplayDOMUtils.CustomStyle;
  57175. exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability;
  57176. exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
  57177. exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
  57178. exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
  57179. exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
  57180. exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException;
  57181. exports.OPS = pdfjsSharedUtil.OPS;
  57182. exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  57183. exports.isValidUrl = pdfjsDisplayDOMUtils.isValidUrl;
  57184. exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
  57185. exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
  57186. exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
  57187. exports.shadow = pdfjsSharedUtil.shadow;
  57188. exports.createBlob = pdfjsSharedUtil.createBlob;
  57189. exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl;
  57190. exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes;
  57191. /***/ })
  57192. /******/ ]);
  57193. });