pdf.combined.js 1.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986
  1. /* Copyright 2012 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 (root, factory) {
  16. 'use strict';
  17. if (typeof define === 'function' && define.amd) {
  18. define('pdfjs-dist/build/pdf.combined', ['exports'], factory);
  19. } else if (typeof exports !== 'undefined') {
  20. factory(exports);
  21. } else {
  22. factory(root['pdfjsDistBuildPdfCombined'] = {});
  23. }
  24. }(this, function (exports) {
  25. 'use strict';
  26. var pdfjsVersion = '1.6.365';
  27. var pdfjsBuild = 'fa6b9b7';
  28. var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  29. var pdfjsLibs = {};
  30. (function pdfjsWrapper() {
  31. (function (root, factory) {
  32. factory(root.pdfjsCoreArithmeticDecoder = {});
  33. }(this, function (exports) {
  34. var ArithmeticDecoder = function ArithmeticDecoderClosure() {
  35. var QeTable = [
  36. {
  37. qe: 0x5601,
  38. nmps: 1,
  39. nlps: 1,
  40. switchFlag: 1
  41. },
  42. {
  43. qe: 0x3401,
  44. nmps: 2,
  45. nlps: 6,
  46. switchFlag: 0
  47. },
  48. {
  49. qe: 0x1801,
  50. nmps: 3,
  51. nlps: 9,
  52. switchFlag: 0
  53. },
  54. {
  55. qe: 0x0AC1,
  56. nmps: 4,
  57. nlps: 12,
  58. switchFlag: 0
  59. },
  60. {
  61. qe: 0x0521,
  62. nmps: 5,
  63. nlps: 29,
  64. switchFlag: 0
  65. },
  66. {
  67. qe: 0x0221,
  68. nmps: 38,
  69. nlps: 33,
  70. switchFlag: 0
  71. },
  72. {
  73. qe: 0x5601,
  74. nmps: 7,
  75. nlps: 6,
  76. switchFlag: 1
  77. },
  78. {
  79. qe: 0x5401,
  80. nmps: 8,
  81. nlps: 14,
  82. switchFlag: 0
  83. },
  84. {
  85. qe: 0x4801,
  86. nmps: 9,
  87. nlps: 14,
  88. switchFlag: 0
  89. },
  90. {
  91. qe: 0x3801,
  92. nmps: 10,
  93. nlps: 14,
  94. switchFlag: 0
  95. },
  96. {
  97. qe: 0x3001,
  98. nmps: 11,
  99. nlps: 17,
  100. switchFlag: 0
  101. },
  102. {
  103. qe: 0x2401,
  104. nmps: 12,
  105. nlps: 18,
  106. switchFlag: 0
  107. },
  108. {
  109. qe: 0x1C01,
  110. nmps: 13,
  111. nlps: 20,
  112. switchFlag: 0
  113. },
  114. {
  115. qe: 0x1601,
  116. nmps: 29,
  117. nlps: 21,
  118. switchFlag: 0
  119. },
  120. {
  121. qe: 0x5601,
  122. nmps: 15,
  123. nlps: 14,
  124. switchFlag: 1
  125. },
  126. {
  127. qe: 0x5401,
  128. nmps: 16,
  129. nlps: 14,
  130. switchFlag: 0
  131. },
  132. {
  133. qe: 0x5101,
  134. nmps: 17,
  135. nlps: 15,
  136. switchFlag: 0
  137. },
  138. {
  139. qe: 0x4801,
  140. nmps: 18,
  141. nlps: 16,
  142. switchFlag: 0
  143. },
  144. {
  145. qe: 0x3801,
  146. nmps: 19,
  147. nlps: 17,
  148. switchFlag: 0
  149. },
  150. {
  151. qe: 0x3401,
  152. nmps: 20,
  153. nlps: 18,
  154. switchFlag: 0
  155. },
  156. {
  157. qe: 0x3001,
  158. nmps: 21,
  159. nlps: 19,
  160. switchFlag: 0
  161. },
  162. {
  163. qe: 0x2801,
  164. nmps: 22,
  165. nlps: 19,
  166. switchFlag: 0
  167. },
  168. {
  169. qe: 0x2401,
  170. nmps: 23,
  171. nlps: 20,
  172. switchFlag: 0
  173. },
  174. {
  175. qe: 0x2201,
  176. nmps: 24,
  177. nlps: 21,
  178. switchFlag: 0
  179. },
  180. {
  181. qe: 0x1C01,
  182. nmps: 25,
  183. nlps: 22,
  184. switchFlag: 0
  185. },
  186. {
  187. qe: 0x1801,
  188. nmps: 26,
  189. nlps: 23,
  190. switchFlag: 0
  191. },
  192. {
  193. qe: 0x1601,
  194. nmps: 27,
  195. nlps: 24,
  196. switchFlag: 0
  197. },
  198. {
  199. qe: 0x1401,
  200. nmps: 28,
  201. nlps: 25,
  202. switchFlag: 0
  203. },
  204. {
  205. qe: 0x1201,
  206. nmps: 29,
  207. nlps: 26,
  208. switchFlag: 0
  209. },
  210. {
  211. qe: 0x1101,
  212. nmps: 30,
  213. nlps: 27,
  214. switchFlag: 0
  215. },
  216. {
  217. qe: 0x0AC1,
  218. nmps: 31,
  219. nlps: 28,
  220. switchFlag: 0
  221. },
  222. {
  223. qe: 0x09C1,
  224. nmps: 32,
  225. nlps: 29,
  226. switchFlag: 0
  227. },
  228. {
  229. qe: 0x08A1,
  230. nmps: 33,
  231. nlps: 30,
  232. switchFlag: 0
  233. },
  234. {
  235. qe: 0x0521,
  236. nmps: 34,
  237. nlps: 31,
  238. switchFlag: 0
  239. },
  240. {
  241. qe: 0x0441,
  242. nmps: 35,
  243. nlps: 32,
  244. switchFlag: 0
  245. },
  246. {
  247. qe: 0x02A1,
  248. nmps: 36,
  249. nlps: 33,
  250. switchFlag: 0
  251. },
  252. {
  253. qe: 0x0221,
  254. nmps: 37,
  255. nlps: 34,
  256. switchFlag: 0
  257. },
  258. {
  259. qe: 0x0141,
  260. nmps: 38,
  261. nlps: 35,
  262. switchFlag: 0
  263. },
  264. {
  265. qe: 0x0111,
  266. nmps: 39,
  267. nlps: 36,
  268. switchFlag: 0
  269. },
  270. {
  271. qe: 0x0085,
  272. nmps: 40,
  273. nlps: 37,
  274. switchFlag: 0
  275. },
  276. {
  277. qe: 0x0049,
  278. nmps: 41,
  279. nlps: 38,
  280. switchFlag: 0
  281. },
  282. {
  283. qe: 0x0025,
  284. nmps: 42,
  285. nlps: 39,
  286. switchFlag: 0
  287. },
  288. {
  289. qe: 0x0015,
  290. nmps: 43,
  291. nlps: 40,
  292. switchFlag: 0
  293. },
  294. {
  295. qe: 0x0009,
  296. nmps: 44,
  297. nlps: 41,
  298. switchFlag: 0
  299. },
  300. {
  301. qe: 0x0005,
  302. nmps: 45,
  303. nlps: 42,
  304. switchFlag: 0
  305. },
  306. {
  307. qe: 0x0001,
  308. nmps: 45,
  309. nlps: 43,
  310. switchFlag: 0
  311. },
  312. {
  313. qe: 0x5601,
  314. nmps: 46,
  315. nlps: 46,
  316. switchFlag: 0
  317. }
  318. ];
  319. function ArithmeticDecoder(data, start, end) {
  320. this.data = data;
  321. this.bp = start;
  322. this.dataEnd = end;
  323. this.chigh = data[start];
  324. this.clow = 0;
  325. this.byteIn();
  326. this.chigh = this.chigh << 7 & 0xFFFF | this.clow >> 9 & 0x7F;
  327. this.clow = this.clow << 7 & 0xFFFF;
  328. this.ct -= 7;
  329. this.a = 0x8000;
  330. }
  331. ArithmeticDecoder.prototype = {
  332. byteIn: function ArithmeticDecoder_byteIn() {
  333. var data = this.data;
  334. var bp = this.bp;
  335. if (data[bp] === 0xFF) {
  336. var b1 = data[bp + 1];
  337. if (b1 > 0x8F) {
  338. this.clow += 0xFF00;
  339. this.ct = 8;
  340. } else {
  341. bp++;
  342. this.clow += data[bp] << 9;
  343. this.ct = 7;
  344. this.bp = bp;
  345. }
  346. } else {
  347. bp++;
  348. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xFF00;
  349. this.ct = 8;
  350. this.bp = bp;
  351. }
  352. if (this.clow > 0xFFFF) {
  353. this.chigh += this.clow >> 16;
  354. this.clow &= 0xFFFF;
  355. }
  356. },
  357. readBit: function ArithmeticDecoder_readBit(contexts, pos) {
  358. var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1;
  359. var qeTableIcx = QeTable[cx_index];
  360. var qeIcx = qeTableIcx.qe;
  361. var d;
  362. var a = this.a - qeIcx;
  363. if (this.chigh < qeIcx) {
  364. if (a < qeIcx) {
  365. a = qeIcx;
  366. d = cx_mps;
  367. cx_index = qeTableIcx.nmps;
  368. } else {
  369. a = qeIcx;
  370. d = 1 ^ cx_mps;
  371. if (qeTableIcx.switchFlag === 1) {
  372. cx_mps = d;
  373. }
  374. cx_index = qeTableIcx.nlps;
  375. }
  376. } else {
  377. this.chigh -= qeIcx;
  378. if ((a & 0x8000) !== 0) {
  379. this.a = a;
  380. return cx_mps;
  381. }
  382. if (a < qeIcx) {
  383. d = 1 ^ cx_mps;
  384. if (qeTableIcx.switchFlag === 1) {
  385. cx_mps = d;
  386. }
  387. cx_index = qeTableIcx.nlps;
  388. } else {
  389. d = cx_mps;
  390. cx_index = qeTableIcx.nmps;
  391. }
  392. }
  393. do {
  394. if (this.ct === 0) {
  395. this.byteIn();
  396. }
  397. a <<= 1;
  398. this.chigh = this.chigh << 1 & 0xFFFF | this.clow >> 15 & 1;
  399. this.clow = this.clow << 1 & 0xFFFF;
  400. this.ct--;
  401. } while ((a & 0x8000) === 0);
  402. this.a = a;
  403. contexts[pos] = cx_index << 1 | cx_mps;
  404. return d;
  405. }
  406. };
  407. return ArithmeticDecoder;
  408. }();
  409. exports.ArithmeticDecoder = ArithmeticDecoder;
  410. }));
  411. (function (root, factory) {
  412. factory(root.pdfjsCoreCharsets = {});
  413. }(this, function (exports) {
  414. var ISOAdobeCharset = [
  415. '.notdef',
  416. 'space',
  417. 'exclam',
  418. 'quotedbl',
  419. 'numbersign',
  420. 'dollar',
  421. 'percent',
  422. 'ampersand',
  423. 'quoteright',
  424. 'parenleft',
  425. 'parenright',
  426. 'asterisk',
  427. 'plus',
  428. 'comma',
  429. 'hyphen',
  430. 'period',
  431. 'slash',
  432. 'zero',
  433. 'one',
  434. 'two',
  435. 'three',
  436. 'four',
  437. 'five',
  438. 'six',
  439. 'seven',
  440. 'eight',
  441. 'nine',
  442. 'colon',
  443. 'semicolon',
  444. 'less',
  445. 'equal',
  446. 'greater',
  447. 'question',
  448. 'at',
  449. 'A',
  450. 'B',
  451. 'C',
  452. 'D',
  453. 'E',
  454. 'F',
  455. 'G',
  456. 'H',
  457. 'I',
  458. 'J',
  459. 'K',
  460. 'L',
  461. 'M',
  462. 'N',
  463. 'O',
  464. 'P',
  465. 'Q',
  466. 'R',
  467. 'S',
  468. 'T',
  469. 'U',
  470. 'V',
  471. 'W',
  472. 'X',
  473. 'Y',
  474. 'Z',
  475. 'bracketleft',
  476. 'backslash',
  477. 'bracketright',
  478. 'asciicircum',
  479. 'underscore',
  480. 'quoteleft',
  481. 'a',
  482. 'b',
  483. 'c',
  484. 'd',
  485. 'e',
  486. 'f',
  487. 'g',
  488. 'h',
  489. 'i',
  490. 'j',
  491. 'k',
  492. 'l',
  493. 'm',
  494. 'n',
  495. 'o',
  496. 'p',
  497. 'q',
  498. 'r',
  499. 's',
  500. 't',
  501. 'u',
  502. 'v',
  503. 'w',
  504. 'x',
  505. 'y',
  506. 'z',
  507. 'braceleft',
  508. 'bar',
  509. 'braceright',
  510. 'asciitilde',
  511. 'exclamdown',
  512. 'cent',
  513. 'sterling',
  514. 'fraction',
  515. 'yen',
  516. 'florin',
  517. 'section',
  518. 'currency',
  519. 'quotesingle',
  520. 'quotedblleft',
  521. 'guillemotleft',
  522. 'guilsinglleft',
  523. 'guilsinglright',
  524. 'fi',
  525. 'fl',
  526. 'endash',
  527. 'dagger',
  528. 'daggerdbl',
  529. 'periodcentered',
  530. 'paragraph',
  531. 'bullet',
  532. 'quotesinglbase',
  533. 'quotedblbase',
  534. 'quotedblright',
  535. 'guillemotright',
  536. 'ellipsis',
  537. 'perthousand',
  538. 'questiondown',
  539. 'grave',
  540. 'acute',
  541. 'circumflex',
  542. 'tilde',
  543. 'macron',
  544. 'breve',
  545. 'dotaccent',
  546. 'dieresis',
  547. 'ring',
  548. 'cedilla',
  549. 'hungarumlaut',
  550. 'ogonek',
  551. 'caron',
  552. 'emdash',
  553. 'AE',
  554. 'ordfeminine',
  555. 'Lslash',
  556. 'Oslash',
  557. 'OE',
  558. 'ordmasculine',
  559. 'ae',
  560. 'dotlessi',
  561. 'lslash',
  562. 'oslash',
  563. 'oe',
  564. 'germandbls',
  565. 'onesuperior',
  566. 'logicalnot',
  567. 'mu',
  568. 'trademark',
  569. 'Eth',
  570. 'onehalf',
  571. 'plusminus',
  572. 'Thorn',
  573. 'onequarter',
  574. 'divide',
  575. 'brokenbar',
  576. 'degree',
  577. 'thorn',
  578. 'threequarters',
  579. 'twosuperior',
  580. 'registered',
  581. 'minus',
  582. 'eth',
  583. 'multiply',
  584. 'threesuperior',
  585. 'copyright',
  586. 'Aacute',
  587. 'Acircumflex',
  588. 'Adieresis',
  589. 'Agrave',
  590. 'Aring',
  591. 'Atilde',
  592. 'Ccedilla',
  593. 'Eacute',
  594. 'Ecircumflex',
  595. 'Edieresis',
  596. 'Egrave',
  597. 'Iacute',
  598. 'Icircumflex',
  599. 'Idieresis',
  600. 'Igrave',
  601. 'Ntilde',
  602. 'Oacute',
  603. 'Ocircumflex',
  604. 'Odieresis',
  605. 'Ograve',
  606. 'Otilde',
  607. 'Scaron',
  608. 'Uacute',
  609. 'Ucircumflex',
  610. 'Udieresis',
  611. 'Ugrave',
  612. 'Yacute',
  613. 'Ydieresis',
  614. 'Zcaron',
  615. 'aacute',
  616. 'acircumflex',
  617. 'adieresis',
  618. 'agrave',
  619. 'aring',
  620. 'atilde',
  621. 'ccedilla',
  622. 'eacute',
  623. 'ecircumflex',
  624. 'edieresis',
  625. 'egrave',
  626. 'iacute',
  627. 'icircumflex',
  628. 'idieresis',
  629. 'igrave',
  630. 'ntilde',
  631. 'oacute',
  632. 'ocircumflex',
  633. 'odieresis',
  634. 'ograve',
  635. 'otilde',
  636. 'scaron',
  637. 'uacute',
  638. 'ucircumflex',
  639. 'udieresis',
  640. 'ugrave',
  641. 'yacute',
  642. 'ydieresis',
  643. 'zcaron'
  644. ];
  645. var ExpertCharset = [
  646. '.notdef',
  647. 'space',
  648. 'exclamsmall',
  649. 'Hungarumlautsmall',
  650. 'dollaroldstyle',
  651. 'dollarsuperior',
  652. 'ampersandsmall',
  653. 'Acutesmall',
  654. 'parenleftsuperior',
  655. 'parenrightsuperior',
  656. 'twodotenleader',
  657. 'onedotenleader',
  658. 'comma',
  659. 'hyphen',
  660. 'period',
  661. 'fraction',
  662. 'zerooldstyle',
  663. 'oneoldstyle',
  664. 'twooldstyle',
  665. 'threeoldstyle',
  666. 'fouroldstyle',
  667. 'fiveoldstyle',
  668. 'sixoldstyle',
  669. 'sevenoldstyle',
  670. 'eightoldstyle',
  671. 'nineoldstyle',
  672. 'colon',
  673. 'semicolon',
  674. 'commasuperior',
  675. 'threequartersemdash',
  676. 'periodsuperior',
  677. 'questionsmall',
  678. 'asuperior',
  679. 'bsuperior',
  680. 'centsuperior',
  681. 'dsuperior',
  682. 'esuperior',
  683. 'isuperior',
  684. 'lsuperior',
  685. 'msuperior',
  686. 'nsuperior',
  687. 'osuperior',
  688. 'rsuperior',
  689. 'ssuperior',
  690. 'tsuperior',
  691. 'ff',
  692. 'fi',
  693. 'fl',
  694. 'ffi',
  695. 'ffl',
  696. 'parenleftinferior',
  697. 'parenrightinferior',
  698. 'Circumflexsmall',
  699. 'hyphensuperior',
  700. 'Gravesmall',
  701. 'Asmall',
  702. 'Bsmall',
  703. 'Csmall',
  704. 'Dsmall',
  705. 'Esmall',
  706. 'Fsmall',
  707. 'Gsmall',
  708. 'Hsmall',
  709. 'Ismall',
  710. 'Jsmall',
  711. 'Ksmall',
  712. 'Lsmall',
  713. 'Msmall',
  714. 'Nsmall',
  715. 'Osmall',
  716. 'Psmall',
  717. 'Qsmall',
  718. 'Rsmall',
  719. 'Ssmall',
  720. 'Tsmall',
  721. 'Usmall',
  722. 'Vsmall',
  723. 'Wsmall',
  724. 'Xsmall',
  725. 'Ysmall',
  726. 'Zsmall',
  727. 'colonmonetary',
  728. 'onefitted',
  729. 'rupiah',
  730. 'Tildesmall',
  731. 'exclamdownsmall',
  732. 'centoldstyle',
  733. 'Lslashsmall',
  734. 'Scaronsmall',
  735. 'Zcaronsmall',
  736. 'Dieresissmall',
  737. 'Brevesmall',
  738. 'Caronsmall',
  739. 'Dotaccentsmall',
  740. 'Macronsmall',
  741. 'figuredash',
  742. 'hypheninferior',
  743. 'Ogoneksmall',
  744. 'Ringsmall',
  745. 'Cedillasmall',
  746. 'onequarter',
  747. 'onehalf',
  748. 'threequarters',
  749. 'questiondownsmall',
  750. 'oneeighth',
  751. 'threeeighths',
  752. 'fiveeighths',
  753. 'seveneighths',
  754. 'onethird',
  755. 'twothirds',
  756. 'zerosuperior',
  757. 'onesuperior',
  758. 'twosuperior',
  759. 'threesuperior',
  760. 'foursuperior',
  761. 'fivesuperior',
  762. 'sixsuperior',
  763. 'sevensuperior',
  764. 'eightsuperior',
  765. 'ninesuperior',
  766. 'zeroinferior',
  767. 'oneinferior',
  768. 'twoinferior',
  769. 'threeinferior',
  770. 'fourinferior',
  771. 'fiveinferior',
  772. 'sixinferior',
  773. 'seveninferior',
  774. 'eightinferior',
  775. 'nineinferior',
  776. 'centinferior',
  777. 'dollarinferior',
  778. 'periodinferior',
  779. 'commainferior',
  780. 'Agravesmall',
  781. 'Aacutesmall',
  782. 'Acircumflexsmall',
  783. 'Atildesmall',
  784. 'Adieresissmall',
  785. 'Aringsmall',
  786. 'AEsmall',
  787. 'Ccedillasmall',
  788. 'Egravesmall',
  789. 'Eacutesmall',
  790. 'Ecircumflexsmall',
  791. 'Edieresissmall',
  792. 'Igravesmall',
  793. 'Iacutesmall',
  794. 'Icircumflexsmall',
  795. 'Idieresissmall',
  796. 'Ethsmall',
  797. 'Ntildesmall',
  798. 'Ogravesmall',
  799. 'Oacutesmall',
  800. 'Ocircumflexsmall',
  801. 'Otildesmall',
  802. 'Odieresissmall',
  803. 'OEsmall',
  804. 'Oslashsmall',
  805. 'Ugravesmall',
  806. 'Uacutesmall',
  807. 'Ucircumflexsmall',
  808. 'Udieresissmall',
  809. 'Yacutesmall',
  810. 'Thornsmall',
  811. 'Ydieresissmall'
  812. ];
  813. var ExpertSubsetCharset = [
  814. '.notdef',
  815. 'space',
  816. 'dollaroldstyle',
  817. 'dollarsuperior',
  818. 'parenleftsuperior',
  819. 'parenrightsuperior',
  820. 'twodotenleader',
  821. 'onedotenleader',
  822. 'comma',
  823. 'hyphen',
  824. 'period',
  825. 'fraction',
  826. 'zerooldstyle',
  827. 'oneoldstyle',
  828. 'twooldstyle',
  829. 'threeoldstyle',
  830. 'fouroldstyle',
  831. 'fiveoldstyle',
  832. 'sixoldstyle',
  833. 'sevenoldstyle',
  834. 'eightoldstyle',
  835. 'nineoldstyle',
  836. 'colon',
  837. 'semicolon',
  838. 'commasuperior',
  839. 'threequartersemdash',
  840. 'periodsuperior',
  841. 'asuperior',
  842. 'bsuperior',
  843. 'centsuperior',
  844. 'dsuperior',
  845. 'esuperior',
  846. 'isuperior',
  847. 'lsuperior',
  848. 'msuperior',
  849. 'nsuperior',
  850. 'osuperior',
  851. 'rsuperior',
  852. 'ssuperior',
  853. 'tsuperior',
  854. 'ff',
  855. 'fi',
  856. 'fl',
  857. 'ffi',
  858. 'ffl',
  859. 'parenleftinferior',
  860. 'parenrightinferior',
  861. 'hyphensuperior',
  862. 'colonmonetary',
  863. 'onefitted',
  864. 'rupiah',
  865. 'centoldstyle',
  866. 'figuredash',
  867. 'hypheninferior',
  868. 'onequarter',
  869. 'onehalf',
  870. 'threequarters',
  871. 'oneeighth',
  872. 'threeeighths',
  873. 'fiveeighths',
  874. 'seveneighths',
  875. 'onethird',
  876. 'twothirds',
  877. 'zerosuperior',
  878. 'onesuperior',
  879. 'twosuperior',
  880. 'threesuperior',
  881. 'foursuperior',
  882. 'fivesuperior',
  883. 'sixsuperior',
  884. 'sevensuperior',
  885. 'eightsuperior',
  886. 'ninesuperior',
  887. 'zeroinferior',
  888. 'oneinferior',
  889. 'twoinferior',
  890. 'threeinferior',
  891. 'fourinferior',
  892. 'fiveinferior',
  893. 'sixinferior',
  894. 'seveninferior',
  895. 'eightinferior',
  896. 'nineinferior',
  897. 'centinferior',
  898. 'dollarinferior',
  899. 'periodinferior',
  900. 'commainferior'
  901. ];
  902. exports.ISOAdobeCharset = ISOAdobeCharset;
  903. exports.ExpertCharset = ExpertCharset;
  904. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  905. }));
  906. (function (root, factory) {
  907. factory(root.pdfjsCoreEncodings = {});
  908. }(this, function (exports) {
  909. var ExpertEncoding = [
  910. '',
  911. '',
  912. '',
  913. '',
  914. '',
  915. '',
  916. '',
  917. '',
  918. '',
  919. '',
  920. '',
  921. '',
  922. '',
  923. '',
  924. '',
  925. '',
  926. '',
  927. '',
  928. '',
  929. '',
  930. '',
  931. '',
  932. '',
  933. '',
  934. '',
  935. '',
  936. '',
  937. '',
  938. '',
  939. '',
  940. '',
  941. '',
  942. 'space',
  943. 'exclamsmall',
  944. 'Hungarumlautsmall',
  945. '',
  946. 'dollaroldstyle',
  947. 'dollarsuperior',
  948. 'ampersandsmall',
  949. 'Acutesmall',
  950. 'parenleftsuperior',
  951. 'parenrightsuperior',
  952. 'twodotenleader',
  953. 'onedotenleader',
  954. 'comma',
  955. 'hyphen',
  956. 'period',
  957. 'fraction',
  958. 'zerooldstyle',
  959. 'oneoldstyle',
  960. 'twooldstyle',
  961. 'threeoldstyle',
  962. 'fouroldstyle',
  963. 'fiveoldstyle',
  964. 'sixoldstyle',
  965. 'sevenoldstyle',
  966. 'eightoldstyle',
  967. 'nineoldstyle',
  968. 'colon',
  969. 'semicolon',
  970. 'commasuperior',
  971. 'threequartersemdash',
  972. 'periodsuperior',
  973. 'questionsmall',
  974. '',
  975. 'asuperior',
  976. 'bsuperior',
  977. 'centsuperior',
  978. 'dsuperior',
  979. 'esuperior',
  980. '',
  981. '',
  982. 'isuperior',
  983. '',
  984. '',
  985. 'lsuperior',
  986. 'msuperior',
  987. 'nsuperior',
  988. 'osuperior',
  989. '',
  990. '',
  991. 'rsuperior',
  992. 'ssuperior',
  993. 'tsuperior',
  994. '',
  995. 'ff',
  996. 'fi',
  997. 'fl',
  998. 'ffi',
  999. 'ffl',
  1000. 'parenleftinferior',
  1001. '',
  1002. 'parenrightinferior',
  1003. 'Circumflexsmall',
  1004. 'hyphensuperior',
  1005. 'Gravesmall',
  1006. 'Asmall',
  1007. 'Bsmall',
  1008. 'Csmall',
  1009. 'Dsmall',
  1010. 'Esmall',
  1011. 'Fsmall',
  1012. 'Gsmall',
  1013. 'Hsmall',
  1014. 'Ismall',
  1015. 'Jsmall',
  1016. 'Ksmall',
  1017. 'Lsmall',
  1018. 'Msmall',
  1019. 'Nsmall',
  1020. 'Osmall',
  1021. 'Psmall',
  1022. 'Qsmall',
  1023. 'Rsmall',
  1024. 'Ssmall',
  1025. 'Tsmall',
  1026. 'Usmall',
  1027. 'Vsmall',
  1028. 'Wsmall',
  1029. 'Xsmall',
  1030. 'Ysmall',
  1031. 'Zsmall',
  1032. 'colonmonetary',
  1033. 'onefitted',
  1034. 'rupiah',
  1035. 'Tildesmall',
  1036. '',
  1037. '',
  1038. '',
  1039. '',
  1040. '',
  1041. '',
  1042. '',
  1043. '',
  1044. '',
  1045. '',
  1046. '',
  1047. '',
  1048. '',
  1049. '',
  1050. '',
  1051. '',
  1052. '',
  1053. '',
  1054. '',
  1055. '',
  1056. '',
  1057. '',
  1058. '',
  1059. '',
  1060. '',
  1061. '',
  1062. '',
  1063. '',
  1064. '',
  1065. '',
  1066. '',
  1067. '',
  1068. '',
  1069. '',
  1070. 'exclamdownsmall',
  1071. 'centoldstyle',
  1072. 'Lslashsmall',
  1073. '',
  1074. '',
  1075. 'Scaronsmall',
  1076. 'Zcaronsmall',
  1077. 'Dieresissmall',
  1078. 'Brevesmall',
  1079. 'Caronsmall',
  1080. '',
  1081. 'Dotaccentsmall',
  1082. '',
  1083. '',
  1084. 'Macronsmall',
  1085. '',
  1086. '',
  1087. 'figuredash',
  1088. 'hypheninferior',
  1089. '',
  1090. '',
  1091. 'Ogoneksmall',
  1092. 'Ringsmall',
  1093. 'Cedillasmall',
  1094. '',
  1095. '',
  1096. '',
  1097. 'onequarter',
  1098. 'onehalf',
  1099. 'threequarters',
  1100. 'questiondownsmall',
  1101. 'oneeighth',
  1102. 'threeeighths',
  1103. 'fiveeighths',
  1104. 'seveneighths',
  1105. 'onethird',
  1106. 'twothirds',
  1107. '',
  1108. '',
  1109. 'zerosuperior',
  1110. 'onesuperior',
  1111. 'twosuperior',
  1112. 'threesuperior',
  1113. 'foursuperior',
  1114. 'fivesuperior',
  1115. 'sixsuperior',
  1116. 'sevensuperior',
  1117. 'eightsuperior',
  1118. 'ninesuperior',
  1119. 'zeroinferior',
  1120. 'oneinferior',
  1121. 'twoinferior',
  1122. 'threeinferior',
  1123. 'fourinferior',
  1124. 'fiveinferior',
  1125. 'sixinferior',
  1126. 'seveninferior',
  1127. 'eightinferior',
  1128. 'nineinferior',
  1129. 'centinferior',
  1130. 'dollarinferior',
  1131. 'periodinferior',
  1132. 'commainferior',
  1133. 'Agravesmall',
  1134. 'Aacutesmall',
  1135. 'Acircumflexsmall',
  1136. 'Atildesmall',
  1137. 'Adieresissmall',
  1138. 'Aringsmall',
  1139. 'AEsmall',
  1140. 'Ccedillasmall',
  1141. 'Egravesmall',
  1142. 'Eacutesmall',
  1143. 'Ecircumflexsmall',
  1144. 'Edieresissmall',
  1145. 'Igravesmall',
  1146. 'Iacutesmall',
  1147. 'Icircumflexsmall',
  1148. 'Idieresissmall',
  1149. 'Ethsmall',
  1150. 'Ntildesmall',
  1151. 'Ogravesmall',
  1152. 'Oacutesmall',
  1153. 'Ocircumflexsmall',
  1154. 'Otildesmall',
  1155. 'Odieresissmall',
  1156. 'OEsmall',
  1157. 'Oslashsmall',
  1158. 'Ugravesmall',
  1159. 'Uacutesmall',
  1160. 'Ucircumflexsmall',
  1161. 'Udieresissmall',
  1162. 'Yacutesmall',
  1163. 'Thornsmall',
  1164. 'Ydieresissmall'
  1165. ];
  1166. var MacExpertEncoding = [
  1167. '',
  1168. '',
  1169. '',
  1170. '',
  1171. '',
  1172. '',
  1173. '',
  1174. '',
  1175. '',
  1176. '',
  1177. '',
  1178. '',
  1179. '',
  1180. '',
  1181. '',
  1182. '',
  1183. '',
  1184. '',
  1185. '',
  1186. '',
  1187. '',
  1188. '',
  1189. '',
  1190. '',
  1191. '',
  1192. '',
  1193. '',
  1194. '',
  1195. '',
  1196. '',
  1197. '',
  1198. '',
  1199. 'space',
  1200. 'exclamsmall',
  1201. 'Hungarumlautsmall',
  1202. 'centoldstyle',
  1203. 'dollaroldstyle',
  1204. 'dollarsuperior',
  1205. 'ampersandsmall',
  1206. 'Acutesmall',
  1207. 'parenleftsuperior',
  1208. 'parenrightsuperior',
  1209. 'twodotenleader',
  1210. 'onedotenleader',
  1211. 'comma',
  1212. 'hyphen',
  1213. 'period',
  1214. 'fraction',
  1215. 'zerooldstyle',
  1216. 'oneoldstyle',
  1217. 'twooldstyle',
  1218. 'threeoldstyle',
  1219. 'fouroldstyle',
  1220. 'fiveoldstyle',
  1221. 'sixoldstyle',
  1222. 'sevenoldstyle',
  1223. 'eightoldstyle',
  1224. 'nineoldstyle',
  1225. 'colon',
  1226. 'semicolon',
  1227. '',
  1228. 'threequartersemdash',
  1229. '',
  1230. 'questionsmall',
  1231. '',
  1232. '',
  1233. '',
  1234. '',
  1235. 'Ethsmall',
  1236. '',
  1237. '',
  1238. 'onequarter',
  1239. 'onehalf',
  1240. 'threequarters',
  1241. 'oneeighth',
  1242. 'threeeighths',
  1243. 'fiveeighths',
  1244. 'seveneighths',
  1245. 'onethird',
  1246. 'twothirds',
  1247. '',
  1248. '',
  1249. '',
  1250. '',
  1251. '',
  1252. '',
  1253. 'ff',
  1254. 'fi',
  1255. 'fl',
  1256. 'ffi',
  1257. 'ffl',
  1258. 'parenleftinferior',
  1259. '',
  1260. 'parenrightinferior',
  1261. 'Circumflexsmall',
  1262. 'hypheninferior',
  1263. 'Gravesmall',
  1264. 'Asmall',
  1265. 'Bsmall',
  1266. 'Csmall',
  1267. 'Dsmall',
  1268. 'Esmall',
  1269. 'Fsmall',
  1270. 'Gsmall',
  1271. 'Hsmall',
  1272. 'Ismall',
  1273. 'Jsmall',
  1274. 'Ksmall',
  1275. 'Lsmall',
  1276. 'Msmall',
  1277. 'Nsmall',
  1278. 'Osmall',
  1279. 'Psmall',
  1280. 'Qsmall',
  1281. 'Rsmall',
  1282. 'Ssmall',
  1283. 'Tsmall',
  1284. 'Usmall',
  1285. 'Vsmall',
  1286. 'Wsmall',
  1287. 'Xsmall',
  1288. 'Ysmall',
  1289. 'Zsmall',
  1290. 'colonmonetary',
  1291. 'onefitted',
  1292. 'rupiah',
  1293. 'Tildesmall',
  1294. '',
  1295. '',
  1296. 'asuperior',
  1297. 'centsuperior',
  1298. '',
  1299. '',
  1300. '',
  1301. '',
  1302. 'Aacutesmall',
  1303. 'Agravesmall',
  1304. 'Acircumflexsmall',
  1305. 'Adieresissmall',
  1306. 'Atildesmall',
  1307. 'Aringsmall',
  1308. 'Ccedillasmall',
  1309. 'Eacutesmall',
  1310. 'Egravesmall',
  1311. 'Ecircumflexsmall',
  1312. 'Edieresissmall',
  1313. 'Iacutesmall',
  1314. 'Igravesmall',
  1315. 'Icircumflexsmall',
  1316. 'Idieresissmall',
  1317. 'Ntildesmall',
  1318. 'Oacutesmall',
  1319. 'Ogravesmall',
  1320. 'Ocircumflexsmall',
  1321. 'Odieresissmall',
  1322. 'Otildesmall',
  1323. 'Uacutesmall',
  1324. 'Ugravesmall',
  1325. 'Ucircumflexsmall',
  1326. 'Udieresissmall',
  1327. '',
  1328. 'eightsuperior',
  1329. 'fourinferior',
  1330. 'threeinferior',
  1331. 'sixinferior',
  1332. 'eightinferior',
  1333. 'seveninferior',
  1334. 'Scaronsmall',
  1335. '',
  1336. 'centinferior',
  1337. 'twoinferior',
  1338. '',
  1339. 'Dieresissmall',
  1340. '',
  1341. 'Caronsmall',
  1342. 'osuperior',
  1343. 'fiveinferior',
  1344. '',
  1345. 'commainferior',
  1346. 'periodinferior',
  1347. 'Yacutesmall',
  1348. '',
  1349. 'dollarinferior',
  1350. '',
  1351. 'Thornsmall',
  1352. '',
  1353. 'nineinferior',
  1354. 'zeroinferior',
  1355. 'Zcaronsmall',
  1356. 'AEsmall',
  1357. 'Oslashsmall',
  1358. 'questiondownsmall',
  1359. 'oneinferior',
  1360. 'Lslashsmall',
  1361. '',
  1362. '',
  1363. '',
  1364. '',
  1365. '',
  1366. '',
  1367. 'Cedillasmall',
  1368. '',
  1369. '',
  1370. '',
  1371. '',
  1372. '',
  1373. 'OEsmall',
  1374. 'figuredash',
  1375. 'hyphensuperior',
  1376. '',
  1377. '',
  1378. '',
  1379. '',
  1380. 'exclamdownsmall',
  1381. '',
  1382. 'Ydieresissmall',
  1383. '',
  1384. 'onesuperior',
  1385. 'twosuperior',
  1386. 'threesuperior',
  1387. 'foursuperior',
  1388. 'fivesuperior',
  1389. 'sixsuperior',
  1390. 'sevensuperior',
  1391. 'ninesuperior',
  1392. 'zerosuperior',
  1393. '',
  1394. 'esuperior',
  1395. 'rsuperior',
  1396. 'tsuperior',
  1397. '',
  1398. '',
  1399. 'isuperior',
  1400. 'ssuperior',
  1401. 'dsuperior',
  1402. '',
  1403. '',
  1404. '',
  1405. '',
  1406. '',
  1407. 'lsuperior',
  1408. 'Ogoneksmall',
  1409. 'Brevesmall',
  1410. 'Macronsmall',
  1411. 'bsuperior',
  1412. 'nsuperior',
  1413. 'msuperior',
  1414. 'commasuperior',
  1415. 'periodsuperior',
  1416. 'Dotaccentsmall',
  1417. 'Ringsmall'
  1418. ];
  1419. var MacRomanEncoding = [
  1420. '',
  1421. '',
  1422. '',
  1423. '',
  1424. '',
  1425. '',
  1426. '',
  1427. '',
  1428. '',
  1429. '',
  1430. '',
  1431. '',
  1432. '',
  1433. '',
  1434. '',
  1435. '',
  1436. '',
  1437. '',
  1438. '',
  1439. '',
  1440. '',
  1441. '',
  1442. '',
  1443. '',
  1444. '',
  1445. '',
  1446. '',
  1447. '',
  1448. '',
  1449. '',
  1450. '',
  1451. '',
  1452. 'space',
  1453. 'exclam',
  1454. 'quotedbl',
  1455. 'numbersign',
  1456. 'dollar',
  1457. 'percent',
  1458. 'ampersand',
  1459. 'quotesingle',
  1460. 'parenleft',
  1461. 'parenright',
  1462. 'asterisk',
  1463. 'plus',
  1464. 'comma',
  1465. 'hyphen',
  1466. 'period',
  1467. 'slash',
  1468. 'zero',
  1469. 'one',
  1470. 'two',
  1471. 'three',
  1472. 'four',
  1473. 'five',
  1474. 'six',
  1475. 'seven',
  1476. 'eight',
  1477. 'nine',
  1478. 'colon',
  1479. 'semicolon',
  1480. 'less',
  1481. 'equal',
  1482. 'greater',
  1483. 'question',
  1484. 'at',
  1485. 'A',
  1486. 'B',
  1487. 'C',
  1488. 'D',
  1489. 'E',
  1490. 'F',
  1491. 'G',
  1492. 'H',
  1493. 'I',
  1494. 'J',
  1495. 'K',
  1496. 'L',
  1497. 'M',
  1498. 'N',
  1499. 'O',
  1500. 'P',
  1501. 'Q',
  1502. 'R',
  1503. 'S',
  1504. 'T',
  1505. 'U',
  1506. 'V',
  1507. 'W',
  1508. 'X',
  1509. 'Y',
  1510. 'Z',
  1511. 'bracketleft',
  1512. 'backslash',
  1513. 'bracketright',
  1514. 'asciicircum',
  1515. 'underscore',
  1516. 'grave',
  1517. 'a',
  1518. 'b',
  1519. 'c',
  1520. 'd',
  1521. 'e',
  1522. 'f',
  1523. 'g',
  1524. 'h',
  1525. 'i',
  1526. 'j',
  1527. 'k',
  1528. 'l',
  1529. 'm',
  1530. 'n',
  1531. 'o',
  1532. 'p',
  1533. 'q',
  1534. 'r',
  1535. 's',
  1536. 't',
  1537. 'u',
  1538. 'v',
  1539. 'w',
  1540. 'x',
  1541. 'y',
  1542. 'z',
  1543. 'braceleft',
  1544. 'bar',
  1545. 'braceright',
  1546. 'asciitilde',
  1547. '',
  1548. 'Adieresis',
  1549. 'Aring',
  1550. 'Ccedilla',
  1551. 'Eacute',
  1552. 'Ntilde',
  1553. 'Odieresis',
  1554. 'Udieresis',
  1555. 'aacute',
  1556. 'agrave',
  1557. 'acircumflex',
  1558. 'adieresis',
  1559. 'atilde',
  1560. 'aring',
  1561. 'ccedilla',
  1562. 'eacute',
  1563. 'egrave',
  1564. 'ecircumflex',
  1565. 'edieresis',
  1566. 'iacute',
  1567. 'igrave',
  1568. 'icircumflex',
  1569. 'idieresis',
  1570. 'ntilde',
  1571. 'oacute',
  1572. 'ograve',
  1573. 'ocircumflex',
  1574. 'odieresis',
  1575. 'otilde',
  1576. 'uacute',
  1577. 'ugrave',
  1578. 'ucircumflex',
  1579. 'udieresis',
  1580. 'dagger',
  1581. 'degree',
  1582. 'cent',
  1583. 'sterling',
  1584. 'section',
  1585. 'bullet',
  1586. 'paragraph',
  1587. 'germandbls',
  1588. 'registered',
  1589. 'copyright',
  1590. 'trademark',
  1591. 'acute',
  1592. 'dieresis',
  1593. 'notequal',
  1594. 'AE',
  1595. 'Oslash',
  1596. 'infinity',
  1597. 'plusminus',
  1598. 'lessequal',
  1599. 'greaterequal',
  1600. 'yen',
  1601. 'mu',
  1602. 'partialdiff',
  1603. 'summation',
  1604. 'product',
  1605. 'pi',
  1606. 'integral',
  1607. 'ordfeminine',
  1608. 'ordmasculine',
  1609. 'Omega',
  1610. 'ae',
  1611. 'oslash',
  1612. 'questiondown',
  1613. 'exclamdown',
  1614. 'logicalnot',
  1615. 'radical',
  1616. 'florin',
  1617. 'approxequal',
  1618. 'Delta',
  1619. 'guillemotleft',
  1620. 'guillemotright',
  1621. 'ellipsis',
  1622. 'space',
  1623. 'Agrave',
  1624. 'Atilde',
  1625. 'Otilde',
  1626. 'OE',
  1627. 'oe',
  1628. 'endash',
  1629. 'emdash',
  1630. 'quotedblleft',
  1631. 'quotedblright',
  1632. 'quoteleft',
  1633. 'quoteright',
  1634. 'divide',
  1635. 'lozenge',
  1636. 'ydieresis',
  1637. 'Ydieresis',
  1638. 'fraction',
  1639. 'currency',
  1640. 'guilsinglleft',
  1641. 'guilsinglright',
  1642. 'fi',
  1643. 'fl',
  1644. 'daggerdbl',
  1645. 'periodcentered',
  1646. 'quotesinglbase',
  1647. 'quotedblbase',
  1648. 'perthousand',
  1649. 'Acircumflex',
  1650. 'Ecircumflex',
  1651. 'Aacute',
  1652. 'Edieresis',
  1653. 'Egrave',
  1654. 'Iacute',
  1655. 'Icircumflex',
  1656. 'Idieresis',
  1657. 'Igrave',
  1658. 'Oacute',
  1659. 'Ocircumflex',
  1660. 'apple',
  1661. 'Ograve',
  1662. 'Uacute',
  1663. 'Ucircumflex',
  1664. 'Ugrave',
  1665. 'dotlessi',
  1666. 'circumflex',
  1667. 'tilde',
  1668. 'macron',
  1669. 'breve',
  1670. 'dotaccent',
  1671. 'ring',
  1672. 'cedilla',
  1673. 'hungarumlaut',
  1674. 'ogonek',
  1675. 'caron'
  1676. ];
  1677. var StandardEncoding = [
  1678. '',
  1679. '',
  1680. '',
  1681. '',
  1682. '',
  1683. '',
  1684. '',
  1685. '',
  1686. '',
  1687. '',
  1688. '',
  1689. '',
  1690. '',
  1691. '',
  1692. '',
  1693. '',
  1694. '',
  1695. '',
  1696. '',
  1697. '',
  1698. '',
  1699. '',
  1700. '',
  1701. '',
  1702. '',
  1703. '',
  1704. '',
  1705. '',
  1706. '',
  1707. '',
  1708. '',
  1709. '',
  1710. 'space',
  1711. 'exclam',
  1712. 'quotedbl',
  1713. 'numbersign',
  1714. 'dollar',
  1715. 'percent',
  1716. 'ampersand',
  1717. 'quoteright',
  1718. 'parenleft',
  1719. 'parenright',
  1720. 'asterisk',
  1721. 'plus',
  1722. 'comma',
  1723. 'hyphen',
  1724. 'period',
  1725. 'slash',
  1726. 'zero',
  1727. 'one',
  1728. 'two',
  1729. 'three',
  1730. 'four',
  1731. 'five',
  1732. 'six',
  1733. 'seven',
  1734. 'eight',
  1735. 'nine',
  1736. 'colon',
  1737. 'semicolon',
  1738. 'less',
  1739. 'equal',
  1740. 'greater',
  1741. 'question',
  1742. 'at',
  1743. 'A',
  1744. 'B',
  1745. 'C',
  1746. 'D',
  1747. 'E',
  1748. 'F',
  1749. 'G',
  1750. 'H',
  1751. 'I',
  1752. 'J',
  1753. 'K',
  1754. 'L',
  1755. 'M',
  1756. 'N',
  1757. 'O',
  1758. 'P',
  1759. 'Q',
  1760. 'R',
  1761. 'S',
  1762. 'T',
  1763. 'U',
  1764. 'V',
  1765. 'W',
  1766. 'X',
  1767. 'Y',
  1768. 'Z',
  1769. 'bracketleft',
  1770. 'backslash',
  1771. 'bracketright',
  1772. 'asciicircum',
  1773. 'underscore',
  1774. 'quoteleft',
  1775. 'a',
  1776. 'b',
  1777. 'c',
  1778. 'd',
  1779. 'e',
  1780. 'f',
  1781. 'g',
  1782. 'h',
  1783. 'i',
  1784. 'j',
  1785. 'k',
  1786. 'l',
  1787. 'm',
  1788. 'n',
  1789. 'o',
  1790. 'p',
  1791. 'q',
  1792. 'r',
  1793. 's',
  1794. 't',
  1795. 'u',
  1796. 'v',
  1797. 'w',
  1798. 'x',
  1799. 'y',
  1800. 'z',
  1801. 'braceleft',
  1802. 'bar',
  1803. 'braceright',
  1804. 'asciitilde',
  1805. '',
  1806. '',
  1807. '',
  1808. '',
  1809. '',
  1810. '',
  1811. '',
  1812. '',
  1813. '',
  1814. '',
  1815. '',
  1816. '',
  1817. '',
  1818. '',
  1819. '',
  1820. '',
  1821. '',
  1822. '',
  1823. '',
  1824. '',
  1825. '',
  1826. '',
  1827. '',
  1828. '',
  1829. '',
  1830. '',
  1831. '',
  1832. '',
  1833. '',
  1834. '',
  1835. '',
  1836. '',
  1837. '',
  1838. '',
  1839. 'exclamdown',
  1840. 'cent',
  1841. 'sterling',
  1842. 'fraction',
  1843. 'yen',
  1844. 'florin',
  1845. 'section',
  1846. 'currency',
  1847. 'quotesingle',
  1848. 'quotedblleft',
  1849. 'guillemotleft',
  1850. 'guilsinglleft',
  1851. 'guilsinglright',
  1852. 'fi',
  1853. 'fl',
  1854. '',
  1855. 'endash',
  1856. 'dagger',
  1857. 'daggerdbl',
  1858. 'periodcentered',
  1859. '',
  1860. 'paragraph',
  1861. 'bullet',
  1862. 'quotesinglbase',
  1863. 'quotedblbase',
  1864. 'quotedblright',
  1865. 'guillemotright',
  1866. 'ellipsis',
  1867. 'perthousand',
  1868. '',
  1869. 'questiondown',
  1870. '',
  1871. 'grave',
  1872. 'acute',
  1873. 'circumflex',
  1874. 'tilde',
  1875. 'macron',
  1876. 'breve',
  1877. 'dotaccent',
  1878. 'dieresis',
  1879. '',
  1880. 'ring',
  1881. 'cedilla',
  1882. '',
  1883. 'hungarumlaut',
  1884. 'ogonek',
  1885. 'caron',
  1886. 'emdash',
  1887. '',
  1888. '',
  1889. '',
  1890. '',
  1891. '',
  1892. '',
  1893. '',
  1894. '',
  1895. '',
  1896. '',
  1897. '',
  1898. '',
  1899. '',
  1900. '',
  1901. '',
  1902. '',
  1903. 'AE',
  1904. '',
  1905. 'ordfeminine',
  1906. '',
  1907. '',
  1908. '',
  1909. '',
  1910. 'Lslash',
  1911. 'Oslash',
  1912. 'OE',
  1913. 'ordmasculine',
  1914. '',
  1915. '',
  1916. '',
  1917. '',
  1918. '',
  1919. 'ae',
  1920. '',
  1921. '',
  1922. '',
  1923. 'dotlessi',
  1924. '',
  1925. '',
  1926. 'lslash',
  1927. 'oslash',
  1928. 'oe',
  1929. 'germandbls'
  1930. ];
  1931. var WinAnsiEncoding = [
  1932. '',
  1933. '',
  1934. '',
  1935. '',
  1936. '',
  1937. '',
  1938. '',
  1939. '',
  1940. '',
  1941. '',
  1942. '',
  1943. '',
  1944. '',
  1945. '',
  1946. '',
  1947. '',
  1948. '',
  1949. '',
  1950. '',
  1951. '',
  1952. '',
  1953. '',
  1954. '',
  1955. '',
  1956. '',
  1957. '',
  1958. '',
  1959. '',
  1960. '',
  1961. '',
  1962. '',
  1963. '',
  1964. 'space',
  1965. 'exclam',
  1966. 'quotedbl',
  1967. 'numbersign',
  1968. 'dollar',
  1969. 'percent',
  1970. 'ampersand',
  1971. 'quotesingle',
  1972. 'parenleft',
  1973. 'parenright',
  1974. 'asterisk',
  1975. 'plus',
  1976. 'comma',
  1977. 'hyphen',
  1978. 'period',
  1979. 'slash',
  1980. 'zero',
  1981. 'one',
  1982. 'two',
  1983. 'three',
  1984. 'four',
  1985. 'five',
  1986. 'six',
  1987. 'seven',
  1988. 'eight',
  1989. 'nine',
  1990. 'colon',
  1991. 'semicolon',
  1992. 'less',
  1993. 'equal',
  1994. 'greater',
  1995. 'question',
  1996. 'at',
  1997. 'A',
  1998. 'B',
  1999. 'C',
  2000. 'D',
  2001. 'E',
  2002. 'F',
  2003. 'G',
  2004. 'H',
  2005. 'I',
  2006. 'J',
  2007. 'K',
  2008. 'L',
  2009. 'M',
  2010. 'N',
  2011. 'O',
  2012. 'P',
  2013. 'Q',
  2014. 'R',
  2015. 'S',
  2016. 'T',
  2017. 'U',
  2018. 'V',
  2019. 'W',
  2020. 'X',
  2021. 'Y',
  2022. 'Z',
  2023. 'bracketleft',
  2024. 'backslash',
  2025. 'bracketright',
  2026. 'asciicircum',
  2027. 'underscore',
  2028. 'grave',
  2029. 'a',
  2030. 'b',
  2031. 'c',
  2032. 'd',
  2033. 'e',
  2034. 'f',
  2035. 'g',
  2036. 'h',
  2037. 'i',
  2038. 'j',
  2039. 'k',
  2040. 'l',
  2041. 'm',
  2042. 'n',
  2043. 'o',
  2044. 'p',
  2045. 'q',
  2046. 'r',
  2047. 's',
  2048. 't',
  2049. 'u',
  2050. 'v',
  2051. 'w',
  2052. 'x',
  2053. 'y',
  2054. 'z',
  2055. 'braceleft',
  2056. 'bar',
  2057. 'braceright',
  2058. 'asciitilde',
  2059. 'bullet',
  2060. 'Euro',
  2061. 'bullet',
  2062. 'quotesinglbase',
  2063. 'florin',
  2064. 'quotedblbase',
  2065. 'ellipsis',
  2066. 'dagger',
  2067. 'daggerdbl',
  2068. 'circumflex',
  2069. 'perthousand',
  2070. 'Scaron',
  2071. 'guilsinglleft',
  2072. 'OE',
  2073. 'bullet',
  2074. 'Zcaron',
  2075. 'bullet',
  2076. 'bullet',
  2077. 'quoteleft',
  2078. 'quoteright',
  2079. 'quotedblleft',
  2080. 'quotedblright',
  2081. 'bullet',
  2082. 'endash',
  2083. 'emdash',
  2084. 'tilde',
  2085. 'trademark',
  2086. 'scaron',
  2087. 'guilsinglright',
  2088. 'oe',
  2089. 'bullet',
  2090. 'zcaron',
  2091. 'Ydieresis',
  2092. 'space',
  2093. 'exclamdown',
  2094. 'cent',
  2095. 'sterling',
  2096. 'currency',
  2097. 'yen',
  2098. 'brokenbar',
  2099. 'section',
  2100. 'dieresis',
  2101. 'copyright',
  2102. 'ordfeminine',
  2103. 'guillemotleft',
  2104. 'logicalnot',
  2105. 'hyphen',
  2106. 'registered',
  2107. 'macron',
  2108. 'degree',
  2109. 'plusminus',
  2110. 'twosuperior',
  2111. 'threesuperior',
  2112. 'acute',
  2113. 'mu',
  2114. 'paragraph',
  2115. 'periodcentered',
  2116. 'cedilla',
  2117. 'onesuperior',
  2118. 'ordmasculine',
  2119. 'guillemotright',
  2120. 'onequarter',
  2121. 'onehalf',
  2122. 'threequarters',
  2123. 'questiondown',
  2124. 'Agrave',
  2125. 'Aacute',
  2126. 'Acircumflex',
  2127. 'Atilde',
  2128. 'Adieresis',
  2129. 'Aring',
  2130. 'AE',
  2131. 'Ccedilla',
  2132. 'Egrave',
  2133. 'Eacute',
  2134. 'Ecircumflex',
  2135. 'Edieresis',
  2136. 'Igrave',
  2137. 'Iacute',
  2138. 'Icircumflex',
  2139. 'Idieresis',
  2140. 'Eth',
  2141. 'Ntilde',
  2142. 'Ograve',
  2143. 'Oacute',
  2144. 'Ocircumflex',
  2145. 'Otilde',
  2146. 'Odieresis',
  2147. 'multiply',
  2148. 'Oslash',
  2149. 'Ugrave',
  2150. 'Uacute',
  2151. 'Ucircumflex',
  2152. 'Udieresis',
  2153. 'Yacute',
  2154. 'Thorn',
  2155. 'germandbls',
  2156. 'agrave',
  2157. 'aacute',
  2158. 'acircumflex',
  2159. 'atilde',
  2160. 'adieresis',
  2161. 'aring',
  2162. 'ae',
  2163. 'ccedilla',
  2164. 'egrave',
  2165. 'eacute',
  2166. 'ecircumflex',
  2167. 'edieresis',
  2168. 'igrave',
  2169. 'iacute',
  2170. 'icircumflex',
  2171. 'idieresis',
  2172. 'eth',
  2173. 'ntilde',
  2174. 'ograve',
  2175. 'oacute',
  2176. 'ocircumflex',
  2177. 'otilde',
  2178. 'odieresis',
  2179. 'divide',
  2180. 'oslash',
  2181. 'ugrave',
  2182. 'uacute',
  2183. 'ucircumflex',
  2184. 'udieresis',
  2185. 'yacute',
  2186. 'thorn',
  2187. 'ydieresis'
  2188. ];
  2189. var SymbolSetEncoding = [
  2190. '',
  2191. '',
  2192. '',
  2193. '',
  2194. '',
  2195. '',
  2196. '',
  2197. '',
  2198. '',
  2199. '',
  2200. '',
  2201. '',
  2202. '',
  2203. '',
  2204. '',
  2205. '',
  2206. '',
  2207. '',
  2208. '',
  2209. '',
  2210. '',
  2211. '',
  2212. '',
  2213. '',
  2214. '',
  2215. '',
  2216. '',
  2217. '',
  2218. '',
  2219. '',
  2220. '',
  2221. '',
  2222. 'space',
  2223. 'exclam',
  2224. 'universal',
  2225. 'numbersign',
  2226. 'existential',
  2227. 'percent',
  2228. 'ampersand',
  2229. 'suchthat',
  2230. 'parenleft',
  2231. 'parenright',
  2232. 'asteriskmath',
  2233. 'plus',
  2234. 'comma',
  2235. 'minus',
  2236. 'period',
  2237. 'slash',
  2238. 'zero',
  2239. 'one',
  2240. 'two',
  2241. 'three',
  2242. 'four',
  2243. 'five',
  2244. 'six',
  2245. 'seven',
  2246. 'eight',
  2247. 'nine',
  2248. 'colon',
  2249. 'semicolon',
  2250. 'less',
  2251. 'equal',
  2252. 'greater',
  2253. 'question',
  2254. 'congruent',
  2255. 'Alpha',
  2256. 'Beta',
  2257. 'Chi',
  2258. 'Delta',
  2259. 'Epsilon',
  2260. 'Phi',
  2261. 'Gamma',
  2262. 'Eta',
  2263. 'Iota',
  2264. 'theta1',
  2265. 'Kappa',
  2266. 'Lambda',
  2267. 'Mu',
  2268. 'Nu',
  2269. 'Omicron',
  2270. 'Pi',
  2271. 'Theta',
  2272. 'Rho',
  2273. 'Sigma',
  2274. 'Tau',
  2275. 'Upsilon',
  2276. 'sigma1',
  2277. 'Omega',
  2278. 'Xi',
  2279. 'Psi',
  2280. 'Zeta',
  2281. 'bracketleft',
  2282. 'therefore',
  2283. 'bracketright',
  2284. 'perpendicular',
  2285. 'underscore',
  2286. 'radicalex',
  2287. 'alpha',
  2288. 'beta',
  2289. 'chi',
  2290. 'delta',
  2291. 'epsilon',
  2292. 'phi',
  2293. 'gamma',
  2294. 'eta',
  2295. 'iota',
  2296. 'phi1',
  2297. 'kappa',
  2298. 'lambda',
  2299. 'mu',
  2300. 'nu',
  2301. 'omicron',
  2302. 'pi',
  2303. 'theta',
  2304. 'rho',
  2305. 'sigma',
  2306. 'tau',
  2307. 'upsilon',
  2308. 'omega1',
  2309. 'omega',
  2310. 'xi',
  2311. 'psi',
  2312. 'zeta',
  2313. 'braceleft',
  2314. 'bar',
  2315. 'braceright',
  2316. 'similar',
  2317. '',
  2318. '',
  2319. '',
  2320. '',
  2321. '',
  2322. '',
  2323. '',
  2324. '',
  2325. '',
  2326. '',
  2327. '',
  2328. '',
  2329. '',
  2330. '',
  2331. '',
  2332. '',
  2333. '',
  2334. '',
  2335. '',
  2336. '',
  2337. '',
  2338. '',
  2339. '',
  2340. '',
  2341. '',
  2342. '',
  2343. '',
  2344. '',
  2345. '',
  2346. '',
  2347. '',
  2348. '',
  2349. '',
  2350. 'Euro',
  2351. 'Upsilon1',
  2352. 'minute',
  2353. 'lessequal',
  2354. 'fraction',
  2355. 'infinity',
  2356. 'florin',
  2357. 'club',
  2358. 'diamond',
  2359. 'heart',
  2360. 'spade',
  2361. 'arrowboth',
  2362. 'arrowleft',
  2363. 'arrowup',
  2364. 'arrowright',
  2365. 'arrowdown',
  2366. 'degree',
  2367. 'plusminus',
  2368. 'second',
  2369. 'greaterequal',
  2370. 'multiply',
  2371. 'proportional',
  2372. 'partialdiff',
  2373. 'bullet',
  2374. 'divide',
  2375. 'notequal',
  2376. 'equivalence',
  2377. 'approxequal',
  2378. 'ellipsis',
  2379. 'arrowvertex',
  2380. 'arrowhorizex',
  2381. 'carriagereturn',
  2382. 'aleph',
  2383. 'Ifraktur',
  2384. 'Rfraktur',
  2385. 'weierstrass',
  2386. 'circlemultiply',
  2387. 'circleplus',
  2388. 'emptyset',
  2389. 'intersection',
  2390. 'union',
  2391. 'propersuperset',
  2392. 'reflexsuperset',
  2393. 'notsubset',
  2394. 'propersubset',
  2395. 'reflexsubset',
  2396. 'element',
  2397. 'notelement',
  2398. 'angle',
  2399. 'gradient',
  2400. 'registerserif',
  2401. 'copyrightserif',
  2402. 'trademarkserif',
  2403. 'product',
  2404. 'radical',
  2405. 'dotmath',
  2406. 'logicalnot',
  2407. 'logicaland',
  2408. 'logicalor',
  2409. 'arrowdblboth',
  2410. 'arrowdblleft',
  2411. 'arrowdblup',
  2412. 'arrowdblright',
  2413. 'arrowdbldown',
  2414. 'lozenge',
  2415. 'angleleft',
  2416. 'registersans',
  2417. 'copyrightsans',
  2418. 'trademarksans',
  2419. 'summation',
  2420. 'parenlefttp',
  2421. 'parenleftex',
  2422. 'parenleftbt',
  2423. 'bracketlefttp',
  2424. 'bracketleftex',
  2425. 'bracketleftbt',
  2426. 'bracelefttp',
  2427. 'braceleftmid',
  2428. 'braceleftbt',
  2429. 'braceex',
  2430. '',
  2431. 'angleright',
  2432. 'integral',
  2433. 'integraltp',
  2434. 'integralex',
  2435. 'integralbt',
  2436. 'parenrighttp',
  2437. 'parenrightex',
  2438. 'parenrightbt',
  2439. 'bracketrighttp',
  2440. 'bracketrightex',
  2441. 'bracketrightbt',
  2442. 'bracerighttp',
  2443. 'bracerightmid',
  2444. 'bracerightbt'
  2445. ];
  2446. var ZapfDingbatsEncoding = [
  2447. '',
  2448. '',
  2449. '',
  2450. '',
  2451. '',
  2452. '',
  2453. '',
  2454. '',
  2455. '',
  2456. '',
  2457. '',
  2458. '',
  2459. '',
  2460. '',
  2461. '',
  2462. '',
  2463. '',
  2464. '',
  2465. '',
  2466. '',
  2467. '',
  2468. '',
  2469. '',
  2470. '',
  2471. '',
  2472. '',
  2473. '',
  2474. '',
  2475. '',
  2476. '',
  2477. '',
  2478. '',
  2479. 'space',
  2480. 'a1',
  2481. 'a2',
  2482. 'a202',
  2483. 'a3',
  2484. 'a4',
  2485. 'a5',
  2486. 'a119',
  2487. 'a118',
  2488. 'a117',
  2489. 'a11',
  2490. 'a12',
  2491. 'a13',
  2492. 'a14',
  2493. 'a15',
  2494. 'a16',
  2495. 'a105',
  2496. 'a17',
  2497. 'a18',
  2498. 'a19',
  2499. 'a20',
  2500. 'a21',
  2501. 'a22',
  2502. 'a23',
  2503. 'a24',
  2504. 'a25',
  2505. 'a26',
  2506. 'a27',
  2507. 'a28',
  2508. 'a6',
  2509. 'a7',
  2510. 'a8',
  2511. 'a9',
  2512. 'a10',
  2513. 'a29',
  2514. 'a30',
  2515. 'a31',
  2516. 'a32',
  2517. 'a33',
  2518. 'a34',
  2519. 'a35',
  2520. 'a36',
  2521. 'a37',
  2522. 'a38',
  2523. 'a39',
  2524. 'a40',
  2525. 'a41',
  2526. 'a42',
  2527. 'a43',
  2528. 'a44',
  2529. 'a45',
  2530. 'a46',
  2531. 'a47',
  2532. 'a48',
  2533. 'a49',
  2534. 'a50',
  2535. 'a51',
  2536. 'a52',
  2537. 'a53',
  2538. 'a54',
  2539. 'a55',
  2540. 'a56',
  2541. 'a57',
  2542. 'a58',
  2543. 'a59',
  2544. 'a60',
  2545. 'a61',
  2546. 'a62',
  2547. 'a63',
  2548. 'a64',
  2549. 'a65',
  2550. 'a66',
  2551. 'a67',
  2552. 'a68',
  2553. 'a69',
  2554. 'a70',
  2555. 'a71',
  2556. 'a72',
  2557. 'a73',
  2558. 'a74',
  2559. 'a203',
  2560. 'a75',
  2561. 'a204',
  2562. 'a76',
  2563. 'a77',
  2564. 'a78',
  2565. 'a79',
  2566. 'a81',
  2567. 'a82',
  2568. 'a83',
  2569. 'a84',
  2570. 'a97',
  2571. 'a98',
  2572. 'a99',
  2573. 'a100',
  2574. '',
  2575. 'a89',
  2576. 'a90',
  2577. 'a93',
  2578. 'a94',
  2579. 'a91',
  2580. 'a92',
  2581. 'a205',
  2582. 'a85',
  2583. 'a206',
  2584. 'a86',
  2585. 'a87',
  2586. 'a88',
  2587. 'a95',
  2588. 'a96',
  2589. '',
  2590. '',
  2591. '',
  2592. '',
  2593. '',
  2594. '',
  2595. '',
  2596. '',
  2597. '',
  2598. '',
  2599. '',
  2600. '',
  2601. '',
  2602. '',
  2603. '',
  2604. '',
  2605. '',
  2606. '',
  2607. '',
  2608. 'a101',
  2609. 'a102',
  2610. 'a103',
  2611. 'a104',
  2612. 'a106',
  2613. 'a107',
  2614. 'a108',
  2615. 'a112',
  2616. 'a111',
  2617. 'a110',
  2618. 'a109',
  2619. 'a120',
  2620. 'a121',
  2621. 'a122',
  2622. 'a123',
  2623. 'a124',
  2624. 'a125',
  2625. 'a126',
  2626. 'a127',
  2627. 'a128',
  2628. 'a129',
  2629. 'a130',
  2630. 'a131',
  2631. 'a132',
  2632. 'a133',
  2633. 'a134',
  2634. 'a135',
  2635. 'a136',
  2636. 'a137',
  2637. 'a138',
  2638. 'a139',
  2639. 'a140',
  2640. 'a141',
  2641. 'a142',
  2642. 'a143',
  2643. 'a144',
  2644. 'a145',
  2645. 'a146',
  2646. 'a147',
  2647. 'a148',
  2648. 'a149',
  2649. 'a150',
  2650. 'a151',
  2651. 'a152',
  2652. 'a153',
  2653. 'a154',
  2654. 'a155',
  2655. 'a156',
  2656. 'a157',
  2657. 'a158',
  2658. 'a159',
  2659. 'a160',
  2660. 'a161',
  2661. 'a163',
  2662. 'a164',
  2663. 'a196',
  2664. 'a165',
  2665. 'a192',
  2666. 'a166',
  2667. 'a167',
  2668. 'a168',
  2669. 'a169',
  2670. 'a170',
  2671. 'a171',
  2672. 'a172',
  2673. 'a173',
  2674. 'a162',
  2675. 'a174',
  2676. 'a175',
  2677. 'a176',
  2678. 'a177',
  2679. 'a178',
  2680. 'a179',
  2681. 'a193',
  2682. 'a180',
  2683. 'a199',
  2684. 'a181',
  2685. 'a200',
  2686. 'a182',
  2687. '',
  2688. 'a201',
  2689. 'a183',
  2690. 'a184',
  2691. 'a197',
  2692. 'a185',
  2693. 'a194',
  2694. 'a198',
  2695. 'a186',
  2696. 'a195',
  2697. 'a187',
  2698. 'a188',
  2699. 'a189',
  2700. 'a190',
  2701. 'a191'
  2702. ];
  2703. function getEncoding(encodingName) {
  2704. switch (encodingName) {
  2705. case 'WinAnsiEncoding':
  2706. return WinAnsiEncoding;
  2707. case 'StandardEncoding':
  2708. return StandardEncoding;
  2709. case 'MacRomanEncoding':
  2710. return MacRomanEncoding;
  2711. case 'SymbolSetEncoding':
  2712. return SymbolSetEncoding;
  2713. case 'ZapfDingbatsEncoding':
  2714. return ZapfDingbatsEncoding;
  2715. case 'ExpertEncoding':
  2716. return ExpertEncoding;
  2717. case 'MacExpertEncoding':
  2718. return MacExpertEncoding;
  2719. default:
  2720. return null;
  2721. }
  2722. }
  2723. exports.WinAnsiEncoding = WinAnsiEncoding;
  2724. exports.StandardEncoding = StandardEncoding;
  2725. exports.MacRomanEncoding = MacRomanEncoding;
  2726. exports.SymbolSetEncoding = SymbolSetEncoding;
  2727. exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
  2728. exports.ExpertEncoding = ExpertEncoding;
  2729. exports.getEncoding = getEncoding;
  2730. }));
  2731. (function (root, factory) {
  2732. factory(root.pdfjsSharedUtil = {});
  2733. }(this, function (exports) {
  2734. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  2735. var FONT_IDENTITY_MATRIX = [
  2736. 0.001,
  2737. 0,
  2738. 0,
  2739. 0.001,
  2740. 0,
  2741. 0
  2742. ];
  2743. var TextRenderingMode = {
  2744. FILL: 0,
  2745. STROKE: 1,
  2746. FILL_STROKE: 2,
  2747. INVISIBLE: 3,
  2748. FILL_ADD_TO_PATH: 4,
  2749. STROKE_ADD_TO_PATH: 5,
  2750. FILL_STROKE_ADD_TO_PATH: 6,
  2751. ADD_TO_PATH: 7,
  2752. FILL_STROKE_MASK: 3,
  2753. ADD_TO_PATH_FLAG: 4
  2754. };
  2755. var ImageKind = {
  2756. GRAYSCALE_1BPP: 1,
  2757. RGB_24BPP: 2,
  2758. RGBA_32BPP: 3
  2759. };
  2760. var AnnotationType = {
  2761. TEXT: 1,
  2762. LINK: 2,
  2763. FREETEXT: 3,
  2764. LINE: 4,
  2765. SQUARE: 5,
  2766. CIRCLE: 6,
  2767. POLYGON: 7,
  2768. POLYLINE: 8,
  2769. HIGHLIGHT: 9,
  2770. UNDERLINE: 10,
  2771. SQUIGGLY: 11,
  2772. STRIKEOUT: 12,
  2773. STAMP: 13,
  2774. CARET: 14,
  2775. INK: 15,
  2776. POPUP: 16,
  2777. FILEATTACHMENT: 17,
  2778. SOUND: 18,
  2779. MOVIE: 19,
  2780. WIDGET: 20,
  2781. SCREEN: 21,
  2782. PRINTERMARK: 22,
  2783. TRAPNET: 23,
  2784. WATERMARK: 24,
  2785. THREED: 25,
  2786. REDACT: 26
  2787. };
  2788. var AnnotationFlag = {
  2789. INVISIBLE: 0x01,
  2790. HIDDEN: 0x02,
  2791. PRINT: 0x04,
  2792. NOZOOM: 0x08,
  2793. NOROTATE: 0x10,
  2794. NOVIEW: 0x20,
  2795. READONLY: 0x40,
  2796. LOCKED: 0x80,
  2797. TOGGLENOVIEW: 0x100,
  2798. LOCKEDCONTENTS: 0x200
  2799. };
  2800. var AnnotationFieldFlag = {
  2801. READONLY: 0x0000001,
  2802. REQUIRED: 0x0000002,
  2803. NOEXPORT: 0x0000004,
  2804. MULTILINE: 0x0001000,
  2805. PASSWORD: 0x0002000,
  2806. NOTOGGLETOOFF: 0x0004000,
  2807. RADIO: 0x0008000,
  2808. PUSHBUTTON: 0x0010000,
  2809. COMBO: 0x0020000,
  2810. EDIT: 0x0040000,
  2811. SORT: 0x0080000,
  2812. FILESELECT: 0x0100000,
  2813. MULTISELECT: 0x0200000,
  2814. DONOTSPELLCHECK: 0x0400000,
  2815. DONOTSCROLL: 0x0800000,
  2816. COMB: 0x1000000,
  2817. RICHTEXT: 0x2000000,
  2818. RADIOSINUNISON: 0x2000000,
  2819. COMMITONSELCHANGE: 0x4000000
  2820. };
  2821. var AnnotationBorderStyleType = {
  2822. SOLID: 1,
  2823. DASHED: 2,
  2824. BEVELED: 3,
  2825. INSET: 4,
  2826. UNDERLINE: 5
  2827. };
  2828. var StreamType = {
  2829. UNKNOWN: 0,
  2830. FLATE: 1,
  2831. LZW: 2,
  2832. DCT: 3,
  2833. JPX: 4,
  2834. JBIG: 5,
  2835. A85: 6,
  2836. AHX: 7,
  2837. CCF: 8,
  2838. RL: 9
  2839. };
  2840. var FontType = {
  2841. UNKNOWN: 0,
  2842. TYPE1: 1,
  2843. TYPE1C: 2,
  2844. CIDFONTTYPE0: 3,
  2845. CIDFONTTYPE0C: 4,
  2846. TRUETYPE: 5,
  2847. CIDFONTTYPE2: 6,
  2848. TYPE3: 7,
  2849. OPENTYPE: 8,
  2850. TYPE0: 9,
  2851. MMTYPE1: 10
  2852. };
  2853. var VERBOSITY_LEVELS = {
  2854. errors: 0,
  2855. warnings: 1,
  2856. infos: 5
  2857. };
  2858. var OPS = {
  2859. dependency: 1,
  2860. setLineWidth: 2,
  2861. setLineCap: 3,
  2862. setLineJoin: 4,
  2863. setMiterLimit: 5,
  2864. setDash: 6,
  2865. setRenderingIntent: 7,
  2866. setFlatness: 8,
  2867. setGState: 9,
  2868. save: 10,
  2869. restore: 11,
  2870. transform: 12,
  2871. moveTo: 13,
  2872. lineTo: 14,
  2873. curveTo: 15,
  2874. curveTo2: 16,
  2875. curveTo3: 17,
  2876. closePath: 18,
  2877. rectangle: 19,
  2878. stroke: 20,
  2879. closeStroke: 21,
  2880. fill: 22,
  2881. eoFill: 23,
  2882. fillStroke: 24,
  2883. eoFillStroke: 25,
  2884. closeFillStroke: 26,
  2885. closeEOFillStroke: 27,
  2886. endPath: 28,
  2887. clip: 29,
  2888. eoClip: 30,
  2889. beginText: 31,
  2890. endText: 32,
  2891. setCharSpacing: 33,
  2892. setWordSpacing: 34,
  2893. setHScale: 35,
  2894. setLeading: 36,
  2895. setFont: 37,
  2896. setTextRenderingMode: 38,
  2897. setTextRise: 39,
  2898. moveText: 40,
  2899. setLeadingMoveText: 41,
  2900. setTextMatrix: 42,
  2901. nextLine: 43,
  2902. showText: 44,
  2903. showSpacedText: 45,
  2904. nextLineShowText: 46,
  2905. nextLineSetSpacingShowText: 47,
  2906. setCharWidth: 48,
  2907. setCharWidthAndBounds: 49,
  2908. setStrokeColorSpace: 50,
  2909. setFillColorSpace: 51,
  2910. setStrokeColor: 52,
  2911. setStrokeColorN: 53,
  2912. setFillColor: 54,
  2913. setFillColorN: 55,
  2914. setStrokeGray: 56,
  2915. setFillGray: 57,
  2916. setStrokeRGBColor: 58,
  2917. setFillRGBColor: 59,
  2918. setStrokeCMYKColor: 60,
  2919. setFillCMYKColor: 61,
  2920. shadingFill: 62,
  2921. beginInlineImage: 63,
  2922. beginImageData: 64,
  2923. endInlineImage: 65,
  2924. paintXObject: 66,
  2925. markPoint: 67,
  2926. markPointProps: 68,
  2927. beginMarkedContent: 69,
  2928. beginMarkedContentProps: 70,
  2929. endMarkedContent: 71,
  2930. beginCompat: 72,
  2931. endCompat: 73,
  2932. paintFormXObjectBegin: 74,
  2933. paintFormXObjectEnd: 75,
  2934. beginGroup: 76,
  2935. endGroup: 77,
  2936. beginAnnotations: 78,
  2937. endAnnotations: 79,
  2938. beginAnnotation: 80,
  2939. endAnnotation: 81,
  2940. paintJpegXObject: 82,
  2941. paintImageMaskXObject: 83,
  2942. paintImageMaskXObjectGroup: 84,
  2943. paintImageXObject: 85,
  2944. paintInlineImageXObject: 86,
  2945. paintInlineImageXObjectGroup: 87,
  2946. paintImageXObjectRepeat: 88,
  2947. paintImageMaskXObjectRepeat: 89,
  2948. paintSolidColorImageMask: 90,
  2949. constructPath: 91
  2950. };
  2951. var verbosity = VERBOSITY_LEVELS.warnings;
  2952. function setVerbosityLevel(level) {
  2953. verbosity = level;
  2954. }
  2955. function getVerbosityLevel() {
  2956. return verbosity;
  2957. }
  2958. function info(msg) {
  2959. if (verbosity >= VERBOSITY_LEVELS.infos) {
  2960. console.log('Info: ' + msg);
  2961. }
  2962. }
  2963. function warn(msg) {
  2964. if (verbosity >= VERBOSITY_LEVELS.warnings) {
  2965. console.log('Warning: ' + msg);
  2966. }
  2967. }
  2968. function deprecated(details) {
  2969. console.log('Deprecated API usage: ' + details);
  2970. }
  2971. function error(msg) {
  2972. if (verbosity >= VERBOSITY_LEVELS.errors) {
  2973. console.log('Error: ' + msg);
  2974. console.log(backtrace());
  2975. }
  2976. throw new Error(msg);
  2977. }
  2978. function backtrace() {
  2979. try {
  2980. throw new Error();
  2981. } catch (e) {
  2982. return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
  2983. }
  2984. }
  2985. function assert(cond, msg) {
  2986. if (!cond) {
  2987. error(msg);
  2988. }
  2989. }
  2990. var UNSUPPORTED_FEATURES = {
  2991. unknown: 'unknown',
  2992. forms: 'forms',
  2993. javaScript: 'javaScript',
  2994. smask: 'smask',
  2995. shadingPattern: 'shadingPattern',
  2996. font: 'font'
  2997. };
  2998. function isSameOrigin(baseUrl, otherUrl) {
  2999. try {
  3000. var base = new URL(baseUrl);
  3001. if (!base.origin || base.origin === 'null') {
  3002. return false;
  3003. }
  3004. } catch (e) {
  3005. return false;
  3006. }
  3007. var other = new URL(otherUrl, base);
  3008. return base.origin === other.origin;
  3009. }
  3010. function isValidProtocol(url) {
  3011. if (!url) {
  3012. return false;
  3013. }
  3014. switch (url.protocol) {
  3015. case 'http:':
  3016. case 'https:':
  3017. case 'ftp:':
  3018. case 'mailto:':
  3019. case 'tel:':
  3020. return true;
  3021. default:
  3022. return false;
  3023. }
  3024. }
  3025. function createValidAbsoluteUrl(url, baseUrl) {
  3026. if (!url) {
  3027. return null;
  3028. }
  3029. try {
  3030. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  3031. if (isValidProtocol(absoluteUrl)) {
  3032. return absoluteUrl;
  3033. }
  3034. } catch (ex) {
  3035. }
  3036. return null;
  3037. }
  3038. function shadow(obj, prop, value) {
  3039. Object.defineProperty(obj, prop, {
  3040. value: value,
  3041. enumerable: true,
  3042. configurable: true,
  3043. writable: false
  3044. });
  3045. return value;
  3046. }
  3047. function getLookupTableFactory(initializer) {
  3048. var lookup;
  3049. return function () {
  3050. if (initializer) {
  3051. lookup = Object.create(null);
  3052. initializer(lookup);
  3053. initializer = null;
  3054. }
  3055. return lookup;
  3056. };
  3057. }
  3058. var PasswordResponses = {
  3059. NEED_PASSWORD: 1,
  3060. INCORRECT_PASSWORD: 2
  3061. };
  3062. var PasswordException = function PasswordExceptionClosure() {
  3063. function PasswordException(msg, code) {
  3064. this.name = 'PasswordException';
  3065. this.message = msg;
  3066. this.code = code;
  3067. }
  3068. PasswordException.prototype = new Error();
  3069. PasswordException.constructor = PasswordException;
  3070. return PasswordException;
  3071. }();
  3072. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  3073. function UnknownErrorException(msg, details) {
  3074. this.name = 'UnknownErrorException';
  3075. this.message = msg;
  3076. this.details = details;
  3077. }
  3078. UnknownErrorException.prototype = new Error();
  3079. UnknownErrorException.constructor = UnknownErrorException;
  3080. return UnknownErrorException;
  3081. }();
  3082. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  3083. function InvalidPDFException(msg) {
  3084. this.name = 'InvalidPDFException';
  3085. this.message = msg;
  3086. }
  3087. InvalidPDFException.prototype = new Error();
  3088. InvalidPDFException.constructor = InvalidPDFException;
  3089. return InvalidPDFException;
  3090. }();
  3091. var MissingPDFException = function MissingPDFExceptionClosure() {
  3092. function MissingPDFException(msg) {
  3093. this.name = 'MissingPDFException';
  3094. this.message = msg;
  3095. }
  3096. MissingPDFException.prototype = new Error();
  3097. MissingPDFException.constructor = MissingPDFException;
  3098. return MissingPDFException;
  3099. }();
  3100. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  3101. function UnexpectedResponseException(msg, status) {
  3102. this.name = 'UnexpectedResponseException';
  3103. this.message = msg;
  3104. this.status = status;
  3105. }
  3106. UnexpectedResponseException.prototype = new Error();
  3107. UnexpectedResponseException.constructor = UnexpectedResponseException;
  3108. return UnexpectedResponseException;
  3109. }();
  3110. var NotImplementedException = function NotImplementedExceptionClosure() {
  3111. function NotImplementedException(msg) {
  3112. this.message = msg;
  3113. }
  3114. NotImplementedException.prototype = new Error();
  3115. NotImplementedException.prototype.name = 'NotImplementedException';
  3116. NotImplementedException.constructor = NotImplementedException;
  3117. return NotImplementedException;
  3118. }();
  3119. var MissingDataException = function MissingDataExceptionClosure() {
  3120. function MissingDataException(begin, end) {
  3121. this.begin = begin;
  3122. this.end = end;
  3123. this.message = 'Missing data [' + begin + ', ' + end + ')';
  3124. }
  3125. MissingDataException.prototype = new Error();
  3126. MissingDataException.prototype.name = 'MissingDataException';
  3127. MissingDataException.constructor = MissingDataException;
  3128. return MissingDataException;
  3129. }();
  3130. var XRefParseException = function XRefParseExceptionClosure() {
  3131. function XRefParseException(msg) {
  3132. this.message = msg;
  3133. }
  3134. XRefParseException.prototype = new Error();
  3135. XRefParseException.prototype.name = 'XRefParseException';
  3136. XRefParseException.constructor = XRefParseException;
  3137. return XRefParseException;
  3138. }();
  3139. var NullCharactersRegExp = /\x00/g;
  3140. function removeNullCharacters(str) {
  3141. if (typeof str !== 'string') {
  3142. warn('The argument for removeNullCharacters must be a string.');
  3143. return str;
  3144. }
  3145. return str.replace(NullCharactersRegExp, '');
  3146. }
  3147. function bytesToString(bytes) {
  3148. assert(bytes !== null && typeof bytes === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  3149. var length = bytes.length;
  3150. var MAX_ARGUMENT_COUNT = 8192;
  3151. if (length < MAX_ARGUMENT_COUNT) {
  3152. return String.fromCharCode.apply(null, bytes);
  3153. }
  3154. var strBuf = [];
  3155. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  3156. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  3157. var chunk = bytes.subarray(i, chunkEnd);
  3158. strBuf.push(String.fromCharCode.apply(null, chunk));
  3159. }
  3160. return strBuf.join('');
  3161. }
  3162. function stringToBytes(str) {
  3163. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  3164. var length = str.length;
  3165. var bytes = new Uint8Array(length);
  3166. for (var i = 0; i < length; ++i) {
  3167. bytes[i] = str.charCodeAt(i) & 0xFF;
  3168. }
  3169. return bytes;
  3170. }
  3171. function arrayByteLength(arr) {
  3172. if (arr.length !== undefined) {
  3173. return arr.length;
  3174. }
  3175. assert(arr.byteLength !== undefined);
  3176. return arr.byteLength;
  3177. }
  3178. function arraysToBytes(arr) {
  3179. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  3180. return arr[0];
  3181. }
  3182. var resultLength = 0;
  3183. var i, ii = arr.length;
  3184. var item, itemLength;
  3185. for (i = 0; i < ii; i++) {
  3186. item = arr[i];
  3187. itemLength = arrayByteLength(item);
  3188. resultLength += itemLength;
  3189. }
  3190. var pos = 0;
  3191. var data = new Uint8Array(resultLength);
  3192. for (i = 0; i < ii; i++) {
  3193. item = arr[i];
  3194. if (!(item instanceof Uint8Array)) {
  3195. if (typeof item === 'string') {
  3196. item = stringToBytes(item);
  3197. } else {
  3198. item = new Uint8Array(item);
  3199. }
  3200. }
  3201. itemLength = item.byteLength;
  3202. data.set(item, pos);
  3203. pos += itemLength;
  3204. }
  3205. return data;
  3206. }
  3207. function string32(value) {
  3208. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  3209. }
  3210. function log2(x) {
  3211. var n = 1, i = 0;
  3212. while (x > n) {
  3213. n <<= 1;
  3214. i++;
  3215. }
  3216. return i;
  3217. }
  3218. function readInt8(data, start) {
  3219. return data[start] << 24 >> 24;
  3220. }
  3221. function readUint16(data, offset) {
  3222. return data[offset] << 8 | data[offset + 1];
  3223. }
  3224. function readUint32(data, offset) {
  3225. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  3226. }
  3227. function isLittleEndian() {
  3228. var buffer8 = new Uint8Array(2);
  3229. buffer8[0] = 1;
  3230. var buffer16 = new Uint16Array(buffer8.buffer);
  3231. return buffer16[0] === 1;
  3232. }
  3233. function isEvalSupported() {
  3234. try {
  3235. new Function('');
  3236. return true;
  3237. } catch (e) {
  3238. return false;
  3239. }
  3240. }
  3241. var Uint32ArrayView = function Uint32ArrayViewClosure() {
  3242. function Uint32ArrayView(buffer, length) {
  3243. this.buffer = buffer;
  3244. this.byteLength = buffer.length;
  3245. this.length = length === undefined ? this.byteLength >> 2 : length;
  3246. ensureUint32ArrayViewProps(this.length);
  3247. }
  3248. Uint32ArrayView.prototype = Object.create(null);
  3249. var uint32ArrayViewSetters = 0;
  3250. function createUint32ArrayProp(index) {
  3251. return {
  3252. get: function () {
  3253. var buffer = this.buffer, offset = index << 2;
  3254. return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0;
  3255. },
  3256. set: function (value) {
  3257. var buffer = this.buffer, offset = index << 2;
  3258. buffer[offset] = value & 255;
  3259. buffer[offset + 1] = value >> 8 & 255;
  3260. buffer[offset + 2] = value >> 16 & 255;
  3261. buffer[offset + 3] = value >>> 24 & 255;
  3262. }
  3263. };
  3264. }
  3265. function ensureUint32ArrayViewProps(length) {
  3266. while (uint32ArrayViewSetters < length) {
  3267. Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters));
  3268. uint32ArrayViewSetters++;
  3269. }
  3270. }
  3271. return Uint32ArrayView;
  3272. }();
  3273. exports.Uint32ArrayView = Uint32ArrayView;
  3274. var IDENTITY_MATRIX = [
  3275. 1,
  3276. 0,
  3277. 0,
  3278. 1,
  3279. 0,
  3280. 0
  3281. ];
  3282. var Util = function UtilClosure() {
  3283. function Util() {
  3284. }
  3285. var rgbBuf = [
  3286. 'rgb(',
  3287. 0,
  3288. ',',
  3289. 0,
  3290. ',',
  3291. 0,
  3292. ')'
  3293. ];
  3294. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  3295. rgbBuf[1] = r;
  3296. rgbBuf[3] = g;
  3297. rgbBuf[5] = b;
  3298. return rgbBuf.join('');
  3299. };
  3300. Util.transform = function Util_transform(m1, m2) {
  3301. return [
  3302. m1[0] * m2[0] + m1[2] * m2[1],
  3303. m1[1] * m2[0] + m1[3] * m2[1],
  3304. m1[0] * m2[2] + m1[2] * m2[3],
  3305. m1[1] * m2[2] + m1[3] * m2[3],
  3306. m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
  3307. m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
  3308. ];
  3309. };
  3310. Util.applyTransform = function Util_applyTransform(p, m) {
  3311. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  3312. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  3313. return [
  3314. xt,
  3315. yt
  3316. ];
  3317. };
  3318. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  3319. var d = m[0] * m[3] - m[1] * m[2];
  3320. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  3321. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  3322. return [
  3323. xt,
  3324. yt
  3325. ];
  3326. };
  3327. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  3328. var p1 = Util.applyTransform(r, m);
  3329. var p2 = Util.applyTransform(r.slice(2, 4), m);
  3330. var p3 = Util.applyTransform([
  3331. r[0],
  3332. r[3]
  3333. ], m);
  3334. var p4 = Util.applyTransform([
  3335. r[2],
  3336. r[1]
  3337. ], m);
  3338. return [
  3339. Math.min(p1[0], p2[0], p3[0], p4[0]),
  3340. Math.min(p1[1], p2[1], p3[1], p4[1]),
  3341. Math.max(p1[0], p2[0], p3[0], p4[0]),
  3342. Math.max(p1[1], p2[1], p3[1], p4[1])
  3343. ];
  3344. };
  3345. Util.inverseTransform = function Util_inverseTransform(m) {
  3346. var d = m[0] * m[3] - m[1] * m[2];
  3347. return [
  3348. m[3] / d,
  3349. -m[1] / d,
  3350. -m[2] / d,
  3351. m[0] / d,
  3352. (m[2] * m[5] - m[4] * m[3]) / d,
  3353. (m[4] * m[1] - m[5] * m[0]) / d
  3354. ];
  3355. };
  3356. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  3357. return [
  3358. m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
  3359. m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
  3360. m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
  3361. ];
  3362. };
  3363. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  3364. var transpose = [
  3365. m[0],
  3366. m[2],
  3367. m[1],
  3368. m[3]
  3369. ];
  3370. var a = m[0] * transpose[0] + m[1] * transpose[2];
  3371. var b = m[0] * transpose[1] + m[1] * transpose[3];
  3372. var c = m[2] * transpose[0] + m[3] * transpose[2];
  3373. var d = m[2] * transpose[1] + m[3] * transpose[3];
  3374. var first = (a + d) / 2;
  3375. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  3376. var sx = first + second || 1;
  3377. var sy = first - second || 1;
  3378. return [
  3379. Math.sqrt(sx),
  3380. Math.sqrt(sy)
  3381. ];
  3382. };
  3383. Util.normalizeRect = function Util_normalizeRect(rect) {
  3384. var r = rect.slice(0);
  3385. if (rect[0] > rect[2]) {
  3386. r[0] = rect[2];
  3387. r[2] = rect[0];
  3388. }
  3389. if (rect[1] > rect[3]) {
  3390. r[1] = rect[3];
  3391. r[3] = rect[1];
  3392. }
  3393. return r;
  3394. };
  3395. Util.intersect = function Util_intersect(rect1, rect2) {
  3396. function compare(a, b) {
  3397. return a - b;
  3398. }
  3399. var orderedX = [
  3400. rect1[0],
  3401. rect1[2],
  3402. rect2[0],
  3403. rect2[2]
  3404. ].sort(compare), orderedY = [
  3405. rect1[1],
  3406. rect1[3],
  3407. rect2[1],
  3408. rect2[3]
  3409. ].sort(compare), result = [];
  3410. rect1 = Util.normalizeRect(rect1);
  3411. rect2 = Util.normalizeRect(rect2);
  3412. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  3413. result[0] = orderedX[1];
  3414. result[2] = orderedX[2];
  3415. } else {
  3416. return false;
  3417. }
  3418. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  3419. result[1] = orderedY[1];
  3420. result[3] = orderedY[2];
  3421. } else {
  3422. return false;
  3423. }
  3424. return result;
  3425. };
  3426. Util.sign = function Util_sign(num) {
  3427. return num < 0 ? -1 : 1;
  3428. };
  3429. var ROMAN_NUMBER_MAP = [
  3430. '',
  3431. 'C',
  3432. 'CC',
  3433. 'CCC',
  3434. 'CD',
  3435. 'D',
  3436. 'DC',
  3437. 'DCC',
  3438. 'DCCC',
  3439. 'CM',
  3440. '',
  3441. 'X',
  3442. 'XX',
  3443. 'XXX',
  3444. 'XL',
  3445. 'L',
  3446. 'LX',
  3447. 'LXX',
  3448. 'LXXX',
  3449. 'XC',
  3450. '',
  3451. 'I',
  3452. 'II',
  3453. 'III',
  3454. 'IV',
  3455. 'V',
  3456. 'VI',
  3457. 'VII',
  3458. 'VIII',
  3459. 'IX'
  3460. ];
  3461. Util.toRoman = function Util_toRoman(number, lowerCase) {
  3462. assert(isInt(number) && number > 0, 'The number should be a positive integer.');
  3463. var pos, romanBuf = [];
  3464. while (number >= 1000) {
  3465. number -= 1000;
  3466. romanBuf.push('M');
  3467. }
  3468. pos = number / 100 | 0;
  3469. number %= 100;
  3470. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  3471. pos = number / 10 | 0;
  3472. number %= 10;
  3473. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  3474. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  3475. var romanStr = romanBuf.join('');
  3476. return lowerCase ? romanStr.toLowerCase() : romanStr;
  3477. };
  3478. Util.appendToArray = function Util_appendToArray(arr1, arr2) {
  3479. Array.prototype.push.apply(arr1, arr2);
  3480. };
  3481. Util.prependToArray = function Util_prependToArray(arr1, arr2) {
  3482. Array.prototype.unshift.apply(arr1, arr2);
  3483. };
  3484. Util.extendObj = function extendObj(obj1, obj2) {
  3485. for (var key in obj2) {
  3486. obj1[key] = obj2[key];
  3487. }
  3488. };
  3489. Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
  3490. while (dict && !dict.has(name)) {
  3491. dict = dict.get('Parent');
  3492. }
  3493. if (!dict) {
  3494. return null;
  3495. }
  3496. return getArray ? dict.getArray(name) : dict.get(name);
  3497. };
  3498. Util.inherit = function Util_inherit(sub, base, prototype) {
  3499. sub.prototype = Object.create(base.prototype);
  3500. sub.prototype.constructor = sub;
  3501. for (var prop in prototype) {
  3502. sub.prototype[prop] = prototype[prop];
  3503. }
  3504. };
  3505. Util.loadScript = function Util_loadScript(src, callback) {
  3506. var script = document.createElement('script');
  3507. var loaded = false;
  3508. script.setAttribute('src', src);
  3509. if (callback) {
  3510. script.onload = function () {
  3511. if (!loaded) {
  3512. callback();
  3513. }
  3514. loaded = true;
  3515. };
  3516. }
  3517. document.getElementsByTagName('head')[0].appendChild(script);
  3518. };
  3519. return Util;
  3520. }();
  3521. var PageViewport = function PageViewportClosure() {
  3522. function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
  3523. this.viewBox = viewBox;
  3524. this.scale = scale;
  3525. this.rotation = rotation;
  3526. this.offsetX = offsetX;
  3527. this.offsetY = offsetY;
  3528. var centerX = (viewBox[2] + viewBox[0]) / 2;
  3529. var centerY = (viewBox[3] + viewBox[1]) / 2;
  3530. var rotateA, rotateB, rotateC, rotateD;
  3531. rotation = rotation % 360;
  3532. rotation = rotation < 0 ? rotation + 360 : rotation;
  3533. switch (rotation) {
  3534. case 180:
  3535. rotateA = -1;
  3536. rotateB = 0;
  3537. rotateC = 0;
  3538. rotateD = 1;
  3539. break;
  3540. case 90:
  3541. rotateA = 0;
  3542. rotateB = 1;
  3543. rotateC = 1;
  3544. rotateD = 0;
  3545. break;
  3546. case 270:
  3547. rotateA = 0;
  3548. rotateB = -1;
  3549. rotateC = -1;
  3550. rotateD = 0;
  3551. break;
  3552. default:
  3553. rotateA = 1;
  3554. rotateB = 0;
  3555. rotateC = 0;
  3556. rotateD = -1;
  3557. break;
  3558. }
  3559. if (dontFlip) {
  3560. rotateC = -rotateC;
  3561. rotateD = -rotateD;
  3562. }
  3563. var offsetCanvasX, offsetCanvasY;
  3564. var width, height;
  3565. if (rotateA === 0) {
  3566. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  3567. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  3568. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  3569. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  3570. } else {
  3571. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  3572. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  3573. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  3574. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  3575. }
  3576. this.transform = [
  3577. rotateA * scale,
  3578. rotateB * scale,
  3579. rotateC * scale,
  3580. rotateD * scale,
  3581. offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
  3582. offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
  3583. ];
  3584. this.width = width;
  3585. this.height = height;
  3586. this.fontScale = scale;
  3587. }
  3588. PageViewport.prototype = {
  3589. clone: function PageViewPort_clone(args) {
  3590. args = args || {};
  3591. var scale = 'scale' in args ? args.scale : this.scale;
  3592. var rotation = 'rotation' in args ? args.rotation : this.rotation;
  3593. return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
  3594. },
  3595. convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
  3596. return Util.applyTransform([
  3597. x,
  3598. y
  3599. ], this.transform);
  3600. },
  3601. convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
  3602. var tl = Util.applyTransform([
  3603. rect[0],
  3604. rect[1]
  3605. ], this.transform);
  3606. var br = Util.applyTransform([
  3607. rect[2],
  3608. rect[3]
  3609. ], this.transform);
  3610. return [
  3611. tl[0],
  3612. tl[1],
  3613. br[0],
  3614. br[1]
  3615. ];
  3616. },
  3617. convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
  3618. return Util.applyInverseTransform([
  3619. x,
  3620. y
  3621. ], this.transform);
  3622. }
  3623. };
  3624. return PageViewport;
  3625. }();
  3626. var PDFStringTranslateTable = [
  3627. 0,
  3628. 0,
  3629. 0,
  3630. 0,
  3631. 0,
  3632. 0,
  3633. 0,
  3634. 0,
  3635. 0,
  3636. 0,
  3637. 0,
  3638. 0,
  3639. 0,
  3640. 0,
  3641. 0,
  3642. 0,
  3643. 0,
  3644. 0,
  3645. 0,
  3646. 0,
  3647. 0,
  3648. 0,
  3649. 0,
  3650. 0,
  3651. 0x2D8,
  3652. 0x2C7,
  3653. 0x2C6,
  3654. 0x2D9,
  3655. 0x2DD,
  3656. 0x2DB,
  3657. 0x2DA,
  3658. 0x2DC,
  3659. 0,
  3660. 0,
  3661. 0,
  3662. 0,
  3663. 0,
  3664. 0,
  3665. 0,
  3666. 0,
  3667. 0,
  3668. 0,
  3669. 0,
  3670. 0,
  3671. 0,
  3672. 0,
  3673. 0,
  3674. 0,
  3675. 0,
  3676. 0,
  3677. 0,
  3678. 0,
  3679. 0,
  3680. 0,
  3681. 0,
  3682. 0,
  3683. 0,
  3684. 0,
  3685. 0,
  3686. 0,
  3687. 0,
  3688. 0,
  3689. 0,
  3690. 0,
  3691. 0,
  3692. 0,
  3693. 0,
  3694. 0,
  3695. 0,
  3696. 0,
  3697. 0,
  3698. 0,
  3699. 0,
  3700. 0,
  3701. 0,
  3702. 0,
  3703. 0,
  3704. 0,
  3705. 0,
  3706. 0,
  3707. 0,
  3708. 0,
  3709. 0,
  3710. 0,
  3711. 0,
  3712. 0,
  3713. 0,
  3714. 0,
  3715. 0,
  3716. 0,
  3717. 0,
  3718. 0,
  3719. 0,
  3720. 0,
  3721. 0,
  3722. 0,
  3723. 0,
  3724. 0,
  3725. 0,
  3726. 0,
  3727. 0,
  3728. 0,
  3729. 0,
  3730. 0,
  3731. 0,
  3732. 0,
  3733. 0,
  3734. 0,
  3735. 0,
  3736. 0,
  3737. 0,
  3738. 0,
  3739. 0,
  3740. 0,
  3741. 0,
  3742. 0,
  3743. 0,
  3744. 0,
  3745. 0,
  3746. 0,
  3747. 0,
  3748. 0,
  3749. 0,
  3750. 0,
  3751. 0,
  3752. 0,
  3753. 0,
  3754. 0,
  3755. 0x2022,
  3756. 0x2020,
  3757. 0x2021,
  3758. 0x2026,
  3759. 0x2014,
  3760. 0x2013,
  3761. 0x192,
  3762. 0x2044,
  3763. 0x2039,
  3764. 0x203A,
  3765. 0x2212,
  3766. 0x2030,
  3767. 0x201E,
  3768. 0x201C,
  3769. 0x201D,
  3770. 0x2018,
  3771. 0x2019,
  3772. 0x201A,
  3773. 0x2122,
  3774. 0xFB01,
  3775. 0xFB02,
  3776. 0x141,
  3777. 0x152,
  3778. 0x160,
  3779. 0x178,
  3780. 0x17D,
  3781. 0x131,
  3782. 0x142,
  3783. 0x153,
  3784. 0x161,
  3785. 0x17E,
  3786. 0,
  3787. 0x20AC
  3788. ];
  3789. function stringToPDFString(str) {
  3790. var i, n = str.length, strBuf = [];
  3791. if (str[0] === '\xFE' && str[1] === '\xFF') {
  3792. for (i = 2; i < n; i += 2) {
  3793. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  3794. }
  3795. } else {
  3796. for (i = 0; i < n; ++i) {
  3797. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  3798. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  3799. }
  3800. }
  3801. return strBuf.join('');
  3802. }
  3803. function stringToUTF8String(str) {
  3804. return decodeURIComponent(escape(str));
  3805. }
  3806. function utf8StringToString(str) {
  3807. return unescape(encodeURIComponent(str));
  3808. }
  3809. function isEmptyObj(obj) {
  3810. for (var key in obj) {
  3811. return false;
  3812. }
  3813. return true;
  3814. }
  3815. function isBool(v) {
  3816. return typeof v === 'boolean';
  3817. }
  3818. function isInt(v) {
  3819. return typeof v === 'number' && (v | 0) === v;
  3820. }
  3821. function isNum(v) {
  3822. return typeof v === 'number';
  3823. }
  3824. function isString(v) {
  3825. return typeof v === 'string';
  3826. }
  3827. function isArray(v) {
  3828. return v instanceof Array;
  3829. }
  3830. function isArrayBuffer(v) {
  3831. return typeof v === 'object' && v !== null && v.byteLength !== undefined;
  3832. }
  3833. function isSpace(ch) {
  3834. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  3835. }
  3836. function createPromiseCapability() {
  3837. var capability = {};
  3838. capability.promise = new Promise(function (resolve, reject) {
  3839. capability.resolve = resolve;
  3840. capability.reject = reject;
  3841. });
  3842. return capability;
  3843. }
  3844. (function PromiseClosure() {
  3845. if (globalScope.Promise) {
  3846. if (typeof globalScope.Promise.all !== 'function') {
  3847. globalScope.Promise.all = function (iterable) {
  3848. var count = 0, results = [], resolve, reject;
  3849. var promise = new globalScope.Promise(function (resolve_, reject_) {
  3850. resolve = resolve_;
  3851. reject = reject_;
  3852. });
  3853. iterable.forEach(function (p, i) {
  3854. count++;
  3855. p.then(function (result) {
  3856. results[i] = result;
  3857. count--;
  3858. if (count === 0) {
  3859. resolve(results);
  3860. }
  3861. }, reject);
  3862. });
  3863. if (count === 0) {
  3864. resolve(results);
  3865. }
  3866. return promise;
  3867. };
  3868. }
  3869. if (typeof globalScope.Promise.resolve !== 'function') {
  3870. globalScope.Promise.resolve = function (value) {
  3871. return new globalScope.Promise(function (resolve) {
  3872. resolve(value);
  3873. });
  3874. };
  3875. }
  3876. if (typeof globalScope.Promise.reject !== 'function') {
  3877. globalScope.Promise.reject = function (reason) {
  3878. return new globalScope.Promise(function (resolve, reject) {
  3879. reject(reason);
  3880. });
  3881. };
  3882. }
  3883. if (typeof globalScope.Promise.prototype.catch !== 'function') {
  3884. globalScope.Promise.prototype.catch = function (onReject) {
  3885. return globalScope.Promise.prototype.then(undefined, onReject);
  3886. };
  3887. }
  3888. return;
  3889. }
  3890. var STATUS_PENDING = 0;
  3891. var STATUS_RESOLVED = 1;
  3892. var STATUS_REJECTED = 2;
  3893. var REJECTION_TIMEOUT = 500;
  3894. var HandlerManager = {
  3895. handlers: [],
  3896. running: false,
  3897. unhandledRejections: [],
  3898. pendingRejectionCheck: false,
  3899. scheduleHandlers: function scheduleHandlers(promise) {
  3900. if (promise._status === STATUS_PENDING) {
  3901. return;
  3902. }
  3903. this.handlers = this.handlers.concat(promise._handlers);
  3904. promise._handlers = [];
  3905. if (this.running) {
  3906. return;
  3907. }
  3908. this.running = true;
  3909. setTimeout(this.runHandlers.bind(this), 0);
  3910. },
  3911. runHandlers: function runHandlers() {
  3912. var RUN_TIMEOUT = 1;
  3913. var timeoutAt = Date.now() + RUN_TIMEOUT;
  3914. while (this.handlers.length > 0) {
  3915. var handler = this.handlers.shift();
  3916. var nextStatus = handler.thisPromise._status;
  3917. var nextValue = handler.thisPromise._value;
  3918. try {
  3919. if (nextStatus === STATUS_RESOLVED) {
  3920. if (typeof handler.onResolve === 'function') {
  3921. nextValue = handler.onResolve(nextValue);
  3922. }
  3923. } else if (typeof handler.onReject === 'function') {
  3924. nextValue = handler.onReject(nextValue);
  3925. nextStatus = STATUS_RESOLVED;
  3926. if (handler.thisPromise._unhandledRejection) {
  3927. this.removeUnhandeledRejection(handler.thisPromise);
  3928. }
  3929. }
  3930. } catch (ex) {
  3931. nextStatus = STATUS_REJECTED;
  3932. nextValue = ex;
  3933. }
  3934. handler.nextPromise._updateStatus(nextStatus, nextValue);
  3935. if (Date.now() >= timeoutAt) {
  3936. break;
  3937. }
  3938. }
  3939. if (this.handlers.length > 0) {
  3940. setTimeout(this.runHandlers.bind(this), 0);
  3941. return;
  3942. }
  3943. this.running = false;
  3944. },
  3945. addUnhandledRejection: function addUnhandledRejection(promise) {
  3946. this.unhandledRejections.push({
  3947. promise: promise,
  3948. time: Date.now()
  3949. });
  3950. this.scheduleRejectionCheck();
  3951. },
  3952. removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
  3953. promise._unhandledRejection = false;
  3954. for (var i = 0; i < this.unhandledRejections.length; i++) {
  3955. if (this.unhandledRejections[i].promise === promise) {
  3956. this.unhandledRejections.splice(i);
  3957. i--;
  3958. }
  3959. }
  3960. },
  3961. scheduleRejectionCheck: function scheduleRejectionCheck() {
  3962. if (this.pendingRejectionCheck) {
  3963. return;
  3964. }
  3965. this.pendingRejectionCheck = true;
  3966. setTimeout(function rejectionCheck() {
  3967. this.pendingRejectionCheck = false;
  3968. var now = Date.now();
  3969. for (var i = 0; i < this.unhandledRejections.length; i++) {
  3970. if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
  3971. var unhandled = this.unhandledRejections[i].promise._value;
  3972. var msg = 'Unhandled rejection: ' + unhandled;
  3973. if (unhandled.stack) {
  3974. msg += '\n' + unhandled.stack;
  3975. }
  3976. warn(msg);
  3977. this.unhandledRejections.splice(i);
  3978. i--;
  3979. }
  3980. }
  3981. if (this.unhandledRejections.length) {
  3982. this.scheduleRejectionCheck();
  3983. }
  3984. }.bind(this), REJECTION_TIMEOUT);
  3985. }
  3986. };
  3987. var Promise = function Promise(resolver) {
  3988. this._status = STATUS_PENDING;
  3989. this._handlers = [];
  3990. try {
  3991. resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
  3992. } catch (e) {
  3993. this._reject(e);
  3994. }
  3995. };
  3996. Promise.all = function Promise_all(promises) {
  3997. var resolveAll, rejectAll;
  3998. var deferred = new Promise(function (resolve, reject) {
  3999. resolveAll = resolve;
  4000. rejectAll = reject;
  4001. });
  4002. var unresolved = promises.length;
  4003. var results = [];
  4004. if (unresolved === 0) {
  4005. resolveAll(results);
  4006. return deferred;
  4007. }
  4008. function reject(reason) {
  4009. if (deferred._status === STATUS_REJECTED) {
  4010. return;
  4011. }
  4012. results = [];
  4013. rejectAll(reason);
  4014. }
  4015. for (var i = 0, ii = promises.length; i < ii; ++i) {
  4016. var promise = promises[i];
  4017. var resolve = function (i) {
  4018. return function (value) {
  4019. if (deferred._status === STATUS_REJECTED) {
  4020. return;
  4021. }
  4022. results[i] = value;
  4023. unresolved--;
  4024. if (unresolved === 0) {
  4025. resolveAll(results);
  4026. }
  4027. };
  4028. }(i);
  4029. if (Promise.isPromise(promise)) {
  4030. promise.then(resolve, reject);
  4031. } else {
  4032. resolve(promise);
  4033. }
  4034. }
  4035. return deferred;
  4036. };
  4037. Promise.isPromise = function Promise_isPromise(value) {
  4038. return value && typeof value.then === 'function';
  4039. };
  4040. Promise.resolve = function Promise_resolve(value) {
  4041. return new Promise(function (resolve) {
  4042. resolve(value);
  4043. });
  4044. };
  4045. Promise.reject = function Promise_reject(reason) {
  4046. return new Promise(function (resolve, reject) {
  4047. reject(reason);
  4048. });
  4049. };
  4050. Promise.prototype = {
  4051. _status: null,
  4052. _value: null,
  4053. _handlers: null,
  4054. _unhandledRejection: null,
  4055. _updateStatus: function Promise__updateStatus(status, value) {
  4056. if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) {
  4057. return;
  4058. }
  4059. if (status === STATUS_RESOLVED && Promise.isPromise(value)) {
  4060. value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED));
  4061. return;
  4062. }
  4063. this._status = status;
  4064. this._value = value;
  4065. if (status === STATUS_REJECTED && this._handlers.length === 0) {
  4066. this._unhandledRejection = true;
  4067. HandlerManager.addUnhandledRejection(this);
  4068. }
  4069. HandlerManager.scheduleHandlers(this);
  4070. },
  4071. _resolve: function Promise_resolve(value) {
  4072. this._updateStatus(STATUS_RESOLVED, value);
  4073. },
  4074. _reject: function Promise_reject(reason) {
  4075. this._updateStatus(STATUS_REJECTED, reason);
  4076. },
  4077. then: function Promise_then(onResolve, onReject) {
  4078. var nextPromise = new Promise(function (resolve, reject) {
  4079. this.resolve = resolve;
  4080. this.reject = reject;
  4081. });
  4082. this._handlers.push({
  4083. thisPromise: this,
  4084. onResolve: onResolve,
  4085. onReject: onReject,
  4086. nextPromise: nextPromise
  4087. });
  4088. HandlerManager.scheduleHandlers(this);
  4089. return nextPromise;
  4090. },
  4091. catch: function Promise_catch(onReject) {
  4092. return this.then(undefined, onReject);
  4093. }
  4094. };
  4095. globalScope.Promise = Promise;
  4096. }());
  4097. (function WeakMapClosure() {
  4098. if (globalScope.WeakMap) {
  4099. return;
  4100. }
  4101. var id = 0;
  4102. function WeakMap() {
  4103. this.id = '$weakmap' + id++;
  4104. }
  4105. WeakMap.prototype = {
  4106. has: function (obj) {
  4107. return !!Object.getOwnPropertyDescriptor(obj, this.id);
  4108. },
  4109. get: function (obj, defaultValue) {
  4110. return this.has(obj) ? obj[this.id] : defaultValue;
  4111. },
  4112. set: function (obj, value) {
  4113. Object.defineProperty(obj, this.id, {
  4114. value: value,
  4115. enumerable: false,
  4116. configurable: true
  4117. });
  4118. },
  4119. delete: function (obj) {
  4120. delete obj[this.id];
  4121. }
  4122. };
  4123. globalScope.WeakMap = WeakMap;
  4124. }());
  4125. var StatTimer = function StatTimerClosure() {
  4126. function rpad(str, pad, length) {
  4127. while (str.length < length) {
  4128. str += pad;
  4129. }
  4130. return str;
  4131. }
  4132. function StatTimer() {
  4133. this.started = Object.create(null);
  4134. this.times = [];
  4135. this.enabled = true;
  4136. }
  4137. StatTimer.prototype = {
  4138. time: function StatTimer_time(name) {
  4139. if (!this.enabled) {
  4140. return;
  4141. }
  4142. if (name in this.started) {
  4143. warn('Timer is already running for ' + name);
  4144. }
  4145. this.started[name] = Date.now();
  4146. },
  4147. timeEnd: function StatTimer_timeEnd(name) {
  4148. if (!this.enabled) {
  4149. return;
  4150. }
  4151. if (!(name in this.started)) {
  4152. warn('Timer has not been started for ' + name);
  4153. }
  4154. this.times.push({
  4155. 'name': name,
  4156. 'start': this.started[name],
  4157. 'end': Date.now()
  4158. });
  4159. delete this.started[name];
  4160. },
  4161. toString: function StatTimer_toString() {
  4162. var i, ii;
  4163. var times = this.times;
  4164. var out = '';
  4165. var longest = 0;
  4166. for (i = 0, ii = times.length; i < ii; ++i) {
  4167. var name = times[i]['name'];
  4168. if (name.length > longest) {
  4169. longest = name.length;
  4170. }
  4171. }
  4172. for (i = 0, ii = times.length; i < ii; ++i) {
  4173. var span = times[i];
  4174. var duration = span.end - span.start;
  4175. out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
  4176. }
  4177. return out;
  4178. }
  4179. };
  4180. return StatTimer;
  4181. }();
  4182. var createBlob = function createBlob(data, contentType) {
  4183. if (typeof Blob !== 'undefined') {
  4184. return new Blob([data], { type: contentType });
  4185. }
  4186. warn('The "Blob" constructor is not supported.');
  4187. };
  4188. var createObjectURL = function createObjectURLClosure() {
  4189. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  4190. return function createObjectURL(data, contentType, forceDataSchema) {
  4191. if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
  4192. var blob = createBlob(data, contentType);
  4193. return URL.createObjectURL(blob);
  4194. }
  4195. var buffer = 'data:' + contentType + ';base64,';
  4196. for (var i = 0, ii = data.length; i < ii; i += 3) {
  4197. var b1 = data[i] & 0xFF;
  4198. var b2 = data[i + 1] & 0xFF;
  4199. var b3 = data[i + 2] & 0xFF;
  4200. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  4201. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  4202. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  4203. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  4204. }
  4205. return buffer;
  4206. };
  4207. }();
  4208. function MessageHandler(sourceName, targetName, comObj) {
  4209. this.sourceName = sourceName;
  4210. this.targetName = targetName;
  4211. this.comObj = comObj;
  4212. this.callbackIndex = 1;
  4213. this.postMessageTransfers = true;
  4214. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  4215. var ah = this.actionHandler = Object.create(null);
  4216. this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
  4217. var data = event.data;
  4218. if (data.targetName !== this.sourceName) {
  4219. return;
  4220. }
  4221. if (data.isReply) {
  4222. var callbackId = data.callbackId;
  4223. if (data.callbackId in callbacksCapabilities) {
  4224. var callback = callbacksCapabilities[callbackId];
  4225. delete callbacksCapabilities[callbackId];
  4226. if ('error' in data) {
  4227. callback.reject(data.error);
  4228. } else {
  4229. callback.resolve(data.data);
  4230. }
  4231. } else {
  4232. error('Cannot resolve callback ' + callbackId);
  4233. }
  4234. } else if (data.action in ah) {
  4235. var action = ah[data.action];
  4236. if (data.callbackId) {
  4237. var sourceName = this.sourceName;
  4238. var targetName = data.sourceName;
  4239. Promise.resolve().then(function () {
  4240. return action[0].call(action[1], data.data);
  4241. }).then(function (result) {
  4242. comObj.postMessage({
  4243. sourceName: sourceName,
  4244. targetName: targetName,
  4245. isReply: true,
  4246. callbackId: data.callbackId,
  4247. data: result
  4248. });
  4249. }, function (reason) {
  4250. if (reason instanceof Error) {
  4251. reason = reason + '';
  4252. }
  4253. comObj.postMessage({
  4254. sourceName: sourceName,
  4255. targetName: targetName,
  4256. isReply: true,
  4257. callbackId: data.callbackId,
  4258. error: reason
  4259. });
  4260. });
  4261. } else {
  4262. action[0].call(action[1], data.data);
  4263. }
  4264. } else {
  4265. error('Unknown action from worker: ' + data.action);
  4266. }
  4267. }.bind(this);
  4268. comObj.addEventListener('message', this._onComObjOnMessage);
  4269. }
  4270. MessageHandler.prototype = {
  4271. on: function messageHandlerOn(actionName, handler, scope) {
  4272. var ah = this.actionHandler;
  4273. if (ah[actionName]) {
  4274. error('There is already an actionName called "' + actionName + '"');
  4275. }
  4276. ah[actionName] = [
  4277. handler,
  4278. scope
  4279. ];
  4280. },
  4281. send: function messageHandlerSend(actionName, data, transfers) {
  4282. var message = {
  4283. sourceName: this.sourceName,
  4284. targetName: this.targetName,
  4285. action: actionName,
  4286. data: data
  4287. };
  4288. this.postMessage(message, transfers);
  4289. },
  4290. sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
  4291. var callbackId = this.callbackIndex++;
  4292. var message = {
  4293. sourceName: this.sourceName,
  4294. targetName: this.targetName,
  4295. action: actionName,
  4296. data: data,
  4297. callbackId: callbackId
  4298. };
  4299. var capability = createPromiseCapability();
  4300. this.callbacksCapabilities[callbackId] = capability;
  4301. try {
  4302. this.postMessage(message, transfers);
  4303. } catch (e) {
  4304. capability.reject(e);
  4305. }
  4306. return capability.promise;
  4307. },
  4308. postMessage: function (message, transfers) {
  4309. if (transfers && this.postMessageTransfers) {
  4310. this.comObj.postMessage(message, transfers);
  4311. } else {
  4312. this.comObj.postMessage(message);
  4313. }
  4314. },
  4315. destroy: function () {
  4316. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  4317. }
  4318. };
  4319. function loadJpegStream(id, imageUrl, objs) {
  4320. var img = new Image();
  4321. img.onload = function loadJpegStream_onloadClosure() {
  4322. objs.resolve(id, img);
  4323. };
  4324. img.onerror = function loadJpegStream_onerrorClosure() {
  4325. objs.resolve(id, null);
  4326. warn('Error during JPEG image loading');
  4327. };
  4328. img.src = imageUrl;
  4329. }
  4330. /* Any copyright is dedicated to the Public Domain.
  4331. * http://creativecommons.org/publicdomain/zero/1.0/ */
  4332. (function checkURLConstructor(scope) {
  4333. var hasWorkingUrl = false;
  4334. try {
  4335. if (typeof URL === 'function' && typeof URL.prototype === 'object' && 'origin' in URL.prototype) {
  4336. var u = new URL('b', 'http://a');
  4337. u.pathname = 'c%20d';
  4338. hasWorkingUrl = u.href === 'http://a/c%20d';
  4339. }
  4340. } catch (e) {
  4341. }
  4342. if (hasWorkingUrl) {
  4343. return;
  4344. }
  4345. var relative = Object.create(null);
  4346. relative['ftp'] = 21;
  4347. relative['file'] = 0;
  4348. relative['gopher'] = 70;
  4349. relative['http'] = 80;
  4350. relative['https'] = 443;
  4351. relative['ws'] = 80;
  4352. relative['wss'] = 443;
  4353. var relativePathDotMapping = Object.create(null);
  4354. relativePathDotMapping['%2e'] = '.';
  4355. relativePathDotMapping['.%2e'] = '..';
  4356. relativePathDotMapping['%2e.'] = '..';
  4357. relativePathDotMapping['%2e%2e'] = '..';
  4358. function isRelativeScheme(scheme) {
  4359. return relative[scheme] !== undefined;
  4360. }
  4361. function invalid() {
  4362. clear.call(this);
  4363. this._isInvalid = true;
  4364. }
  4365. function IDNAToASCII(h) {
  4366. if ('' === h) {
  4367. invalid.call(this);
  4368. }
  4369. return h.toLowerCase();
  4370. }
  4371. function percentEscape(c) {
  4372. var unicode = c.charCodeAt(0);
  4373. if (unicode > 0x20 && unicode < 0x7F && [
  4374. 0x22,
  4375. 0x23,
  4376. 0x3C,
  4377. 0x3E,
  4378. 0x3F,
  4379. 0x60
  4380. ].indexOf(unicode) === -1) {
  4381. return c;
  4382. }
  4383. return encodeURIComponent(c);
  4384. }
  4385. function percentEscapeQuery(c) {
  4386. var unicode = c.charCodeAt(0);
  4387. if (unicode > 0x20 && unicode < 0x7F && [
  4388. 0x22,
  4389. 0x23,
  4390. 0x3C,
  4391. 0x3E,
  4392. 0x60
  4393. ].indexOf(unicode) === -1) {
  4394. return c;
  4395. }
  4396. return encodeURIComponent(c);
  4397. }
  4398. var EOF, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  4399. function parse(input, stateOverride, base) {
  4400. function err(message) {
  4401. errors.push(message);
  4402. }
  4403. var state = stateOverride || 'scheme start', cursor = 0, buffer = '', seenAt = false, seenBracket = false, errors = [];
  4404. loop:
  4405. while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  4406. var c = input[cursor];
  4407. switch (state) {
  4408. case 'scheme start':
  4409. if (c && ALPHA.test(c)) {
  4410. buffer += c.toLowerCase();
  4411. state = 'scheme';
  4412. } else if (!stateOverride) {
  4413. buffer = '';
  4414. state = 'no scheme';
  4415. continue;
  4416. } else {
  4417. err('Invalid scheme.');
  4418. break loop;
  4419. }
  4420. break;
  4421. case 'scheme':
  4422. if (c && ALPHANUMERIC.test(c)) {
  4423. buffer += c.toLowerCase();
  4424. } else if (':' === c) {
  4425. this._scheme = buffer;
  4426. buffer = '';
  4427. if (stateOverride) {
  4428. break loop;
  4429. }
  4430. if (isRelativeScheme(this._scheme)) {
  4431. this._isRelative = true;
  4432. }
  4433. if ('file' === this._scheme) {
  4434. state = 'relative';
  4435. } else if (this._isRelative && base && base._scheme === this._scheme) {
  4436. state = 'relative or authority';
  4437. } else if (this._isRelative) {
  4438. state = 'authority first slash';
  4439. } else {
  4440. state = 'scheme data';
  4441. }
  4442. } else if (!stateOverride) {
  4443. buffer = '';
  4444. cursor = 0;
  4445. state = 'no scheme';
  4446. continue;
  4447. } else if (EOF === c) {
  4448. break loop;
  4449. } else {
  4450. err('Code point not allowed in scheme: ' + c);
  4451. break loop;
  4452. }
  4453. break;
  4454. case 'scheme data':
  4455. if ('?' === c) {
  4456. this._query = '?';
  4457. state = 'query';
  4458. } else if ('#' === c) {
  4459. this._fragment = '#';
  4460. state = 'fragment';
  4461. } else {
  4462. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  4463. this._schemeData += percentEscape(c);
  4464. }
  4465. }
  4466. break;
  4467. case 'no scheme':
  4468. if (!base || !isRelativeScheme(base._scheme)) {
  4469. err('Missing scheme.');
  4470. invalid.call(this);
  4471. } else {
  4472. state = 'relative';
  4473. continue;
  4474. }
  4475. break;
  4476. case 'relative or authority':
  4477. if ('/' === c && '/' === input[cursor + 1]) {
  4478. state = 'authority ignore slashes';
  4479. } else {
  4480. err('Expected /, got: ' + c);
  4481. state = 'relative';
  4482. continue;
  4483. }
  4484. break;
  4485. case 'relative':
  4486. this._isRelative = true;
  4487. if ('file' !== this._scheme) {
  4488. this._scheme = base._scheme;
  4489. }
  4490. if (EOF === c) {
  4491. this._host = base._host;
  4492. this._port = base._port;
  4493. this._path = base._path.slice();
  4494. this._query = base._query;
  4495. this._username = base._username;
  4496. this._password = base._password;
  4497. break loop;
  4498. } else if ('/' === c || '\\' === c) {
  4499. if ('\\' === c) {
  4500. err('\\ is an invalid code point.');
  4501. }
  4502. state = 'relative slash';
  4503. } else if ('?' === c) {
  4504. this._host = base._host;
  4505. this._port = base._port;
  4506. this._path = base._path.slice();
  4507. this._query = '?';
  4508. this._username = base._username;
  4509. this._password = base._password;
  4510. state = 'query';
  4511. } else if ('#' === c) {
  4512. this._host = base._host;
  4513. this._port = base._port;
  4514. this._path = base._path.slice();
  4515. this._query = base._query;
  4516. this._fragment = '#';
  4517. this._username = base._username;
  4518. this._password = base._password;
  4519. state = 'fragment';
  4520. } else {
  4521. var nextC = input[cursor + 1];
  4522. var nextNextC = input[cursor + 2];
  4523. if ('file' !== this._scheme || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || EOF !== nextNextC && '/' !== nextNextC && '\\' !== nextNextC && '?' !== nextNextC && '#' !== nextNextC) {
  4524. this._host = base._host;
  4525. this._port = base._port;
  4526. this._username = base._username;
  4527. this._password = base._password;
  4528. this._path = base._path.slice();
  4529. this._path.pop();
  4530. }
  4531. state = 'relative path';
  4532. continue;
  4533. }
  4534. break;
  4535. case 'relative slash':
  4536. if ('/' === c || '\\' === c) {
  4537. if ('\\' === c) {
  4538. err('\\ is an invalid code point.');
  4539. }
  4540. if ('file' === this._scheme) {
  4541. state = 'file host';
  4542. } else {
  4543. state = 'authority ignore slashes';
  4544. }
  4545. } else {
  4546. if ('file' !== this._scheme) {
  4547. this._host = base._host;
  4548. this._port = base._port;
  4549. this._username = base._username;
  4550. this._password = base._password;
  4551. }
  4552. state = 'relative path';
  4553. continue;
  4554. }
  4555. break;
  4556. case 'authority first slash':
  4557. if ('/' === c) {
  4558. state = 'authority second slash';
  4559. } else {
  4560. err('Expected \'/\', got: ' + c);
  4561. state = 'authority ignore slashes';
  4562. continue;
  4563. }
  4564. break;
  4565. case 'authority second slash':
  4566. state = 'authority ignore slashes';
  4567. if ('/' !== c) {
  4568. err('Expected \'/\', got: ' + c);
  4569. continue;
  4570. }
  4571. break;
  4572. case 'authority ignore slashes':
  4573. if ('/' !== c && '\\' !== c) {
  4574. state = 'authority';
  4575. continue;
  4576. } else {
  4577. err('Expected authority, got: ' + c);
  4578. }
  4579. break;
  4580. case 'authority':
  4581. if ('@' === c) {
  4582. if (seenAt) {
  4583. err('@ already seen.');
  4584. buffer += '%40';
  4585. }
  4586. seenAt = true;
  4587. for (var i = 0; i < buffer.length; i++) {
  4588. var cp = buffer[i];
  4589. if ('\t' === cp || '\n' === cp || '\r' === cp) {
  4590. err('Invalid whitespace in authority.');
  4591. continue;
  4592. }
  4593. if (':' === cp && null === this._password) {
  4594. this._password = '';
  4595. continue;
  4596. }
  4597. var tempC = percentEscape(cp);
  4598. if (null !== this._password) {
  4599. this._password += tempC;
  4600. } else {
  4601. this._username += tempC;
  4602. }
  4603. }
  4604. buffer = '';
  4605. } else if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c) {
  4606. cursor -= buffer.length;
  4607. buffer = '';
  4608. state = 'host';
  4609. continue;
  4610. } else {
  4611. buffer += c;
  4612. }
  4613. break;
  4614. case 'file host':
  4615. if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c) {
  4616. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  4617. state = 'relative path';
  4618. } else if (buffer.length === 0) {
  4619. state = 'relative path start';
  4620. } else {
  4621. this._host = IDNAToASCII.call(this, buffer);
  4622. buffer = '';
  4623. state = 'relative path start';
  4624. }
  4625. continue;
  4626. } else if ('\t' === c || '\n' === c || '\r' === c) {
  4627. err('Invalid whitespace in file host.');
  4628. } else {
  4629. buffer += c;
  4630. }
  4631. break;
  4632. case 'host':
  4633. case 'hostname':
  4634. if (':' === c && !seenBracket) {
  4635. this._host = IDNAToASCII.call(this, buffer);
  4636. buffer = '';
  4637. state = 'port';
  4638. if ('hostname' === stateOverride) {
  4639. break loop;
  4640. }
  4641. } else if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c) {
  4642. this._host = IDNAToASCII.call(this, buffer);
  4643. buffer = '';
  4644. state = 'relative path start';
  4645. if (stateOverride) {
  4646. break loop;
  4647. }
  4648. continue;
  4649. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  4650. if ('[' === c) {
  4651. seenBracket = true;
  4652. } else if (']' === c) {
  4653. seenBracket = false;
  4654. }
  4655. buffer += c;
  4656. } else {
  4657. err('Invalid code point in host/hostname: ' + c);
  4658. }
  4659. break;
  4660. case 'port':
  4661. if (/[0-9]/.test(c)) {
  4662. buffer += c;
  4663. } else if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c || stateOverride) {
  4664. if ('' !== buffer) {
  4665. var temp = parseInt(buffer, 10);
  4666. if (temp !== relative[this._scheme]) {
  4667. this._port = temp + '';
  4668. }
  4669. buffer = '';
  4670. }
  4671. if (stateOverride) {
  4672. break loop;
  4673. }
  4674. state = 'relative path start';
  4675. continue;
  4676. } else if ('\t' === c || '\n' === c || '\r' === c) {
  4677. err('Invalid code point in port: ' + c);
  4678. } else {
  4679. invalid.call(this);
  4680. }
  4681. break;
  4682. case 'relative path start':
  4683. if ('\\' === c) {
  4684. err('\'\\\' not allowed in path.');
  4685. }
  4686. state = 'relative path';
  4687. if ('/' !== c && '\\' !== c) {
  4688. continue;
  4689. }
  4690. break;
  4691. case 'relative path':
  4692. if (EOF === c || '/' === c || '\\' === c || !stateOverride && ('?' === c || '#' === c)) {
  4693. if ('\\' === c) {
  4694. err('\\ not allowed in relative path.');
  4695. }
  4696. var tmp;
  4697. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  4698. buffer = tmp;
  4699. }
  4700. if ('..' === buffer) {
  4701. this._path.pop();
  4702. if ('/' !== c && '\\' !== c) {
  4703. this._path.push('');
  4704. }
  4705. } else if ('.' === buffer && '/' !== c && '\\' !== c) {
  4706. this._path.push('');
  4707. } else if ('.' !== buffer) {
  4708. if ('file' === this._scheme && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  4709. buffer = buffer[0] + ':';
  4710. }
  4711. this._path.push(buffer);
  4712. }
  4713. buffer = '';
  4714. if ('?' === c) {
  4715. this._query = '?';
  4716. state = 'query';
  4717. } else if ('#' === c) {
  4718. this._fragment = '#';
  4719. state = 'fragment';
  4720. }
  4721. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  4722. buffer += percentEscape(c);
  4723. }
  4724. break;
  4725. case 'query':
  4726. if (!stateOverride && '#' === c) {
  4727. this._fragment = '#';
  4728. state = 'fragment';
  4729. } else if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  4730. this._query += percentEscapeQuery(c);
  4731. }
  4732. break;
  4733. case 'fragment':
  4734. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  4735. this._fragment += c;
  4736. }
  4737. break;
  4738. }
  4739. cursor++;
  4740. }
  4741. }
  4742. function clear() {
  4743. this._scheme = '';
  4744. this._schemeData = '';
  4745. this._username = '';
  4746. this._password = null;
  4747. this._host = '';
  4748. this._port = '';
  4749. this._path = [];
  4750. this._query = '';
  4751. this._fragment = '';
  4752. this._isInvalid = false;
  4753. this._isRelative = false;
  4754. }
  4755. function JURL(url, base)
  4756. {
  4757. if (base !== undefined && !(base instanceof JURL)) {
  4758. base = new JURL(String(base));
  4759. }
  4760. this._url = url;
  4761. clear.call(this);
  4762. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  4763. parse.call(this, input, null, base);
  4764. }
  4765. JURL.prototype = {
  4766. toString: function () {
  4767. return this.href;
  4768. },
  4769. get href() {
  4770. if (this._isInvalid) {
  4771. return this._url;
  4772. }
  4773. var authority = '';
  4774. if ('' !== this._username || null !== this._password) {
  4775. authority = this._username + (null !== this._password ? ':' + this._password : '') + '@';
  4776. }
  4777. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  4778. },
  4779. set href(href) {
  4780. clear.call(this);
  4781. parse.call(this, href);
  4782. },
  4783. get protocol() {
  4784. return this._scheme + ':';
  4785. },
  4786. set protocol(protocol) {
  4787. if (this._isInvalid) {
  4788. return;
  4789. }
  4790. parse.call(this, protocol + ':', 'scheme start');
  4791. },
  4792. get host() {
  4793. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  4794. },
  4795. set host(host) {
  4796. if (this._isInvalid || !this._isRelative) {
  4797. return;
  4798. }
  4799. parse.call(this, host, 'host');
  4800. },
  4801. get hostname() {
  4802. return this._host;
  4803. },
  4804. set hostname(hostname) {
  4805. if (this._isInvalid || !this._isRelative) {
  4806. return;
  4807. }
  4808. parse.call(this, hostname, 'hostname');
  4809. },
  4810. get port() {
  4811. return this._port;
  4812. },
  4813. set port(port) {
  4814. if (this._isInvalid || !this._isRelative) {
  4815. return;
  4816. }
  4817. parse.call(this, port, 'port');
  4818. },
  4819. get pathname() {
  4820. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  4821. },
  4822. set pathname(pathname) {
  4823. if (this._isInvalid || !this._isRelative) {
  4824. return;
  4825. }
  4826. this._path = [];
  4827. parse.call(this, pathname, 'relative path start');
  4828. },
  4829. get search() {
  4830. return this._isInvalid || !this._query || '?' === this._query ? '' : this._query;
  4831. },
  4832. set search(search) {
  4833. if (this._isInvalid || !this._isRelative) {
  4834. return;
  4835. }
  4836. this._query = '?';
  4837. if ('?' === search[0]) {
  4838. search = search.slice(1);
  4839. }
  4840. parse.call(this, search, 'query');
  4841. },
  4842. get hash() {
  4843. return this._isInvalid || !this._fragment || '#' === this._fragment ? '' : this._fragment;
  4844. },
  4845. set hash(hash) {
  4846. if (this._isInvalid) {
  4847. return;
  4848. }
  4849. this._fragment = '#';
  4850. if ('#' === hash[0]) {
  4851. hash = hash.slice(1);
  4852. }
  4853. parse.call(this, hash, 'fragment');
  4854. },
  4855. get origin() {
  4856. var host;
  4857. if (this._isInvalid || !this._scheme) {
  4858. return '';
  4859. }
  4860. switch (this._scheme) {
  4861. case 'data':
  4862. case 'file':
  4863. case 'javascript':
  4864. case 'mailto':
  4865. return 'null';
  4866. }
  4867. host = this.host;
  4868. if (!host) {
  4869. return '';
  4870. }
  4871. return this._scheme + '://' + host;
  4872. }
  4873. };
  4874. var OriginalURL = scope.URL;
  4875. if (OriginalURL) {
  4876. JURL.createObjectURL = function (blob) {
  4877. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  4878. };
  4879. JURL.revokeObjectURL = function (url) {
  4880. OriginalURL.revokeObjectURL(url);
  4881. };
  4882. }
  4883. scope.URL = JURL;
  4884. }(globalScope));
  4885. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  4886. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  4887. exports.OPS = OPS;
  4888. exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
  4889. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  4890. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  4891. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  4892. exports.AnnotationFlag = AnnotationFlag;
  4893. exports.AnnotationType = AnnotationType;
  4894. exports.FontType = FontType;
  4895. exports.ImageKind = ImageKind;
  4896. exports.InvalidPDFException = InvalidPDFException;
  4897. exports.MessageHandler = MessageHandler;
  4898. exports.MissingDataException = MissingDataException;
  4899. exports.MissingPDFException = MissingPDFException;
  4900. exports.NotImplementedException = NotImplementedException;
  4901. exports.PageViewport = PageViewport;
  4902. exports.PasswordException = PasswordException;
  4903. exports.PasswordResponses = PasswordResponses;
  4904. exports.StatTimer = StatTimer;
  4905. exports.StreamType = StreamType;
  4906. exports.TextRenderingMode = TextRenderingMode;
  4907. exports.UnexpectedResponseException = UnexpectedResponseException;
  4908. exports.UnknownErrorException = UnknownErrorException;
  4909. exports.Util = Util;
  4910. exports.XRefParseException = XRefParseException;
  4911. exports.arrayByteLength = arrayByteLength;
  4912. exports.arraysToBytes = arraysToBytes;
  4913. exports.assert = assert;
  4914. exports.bytesToString = bytesToString;
  4915. exports.createBlob = createBlob;
  4916. exports.createPromiseCapability = createPromiseCapability;
  4917. exports.createObjectURL = createObjectURL;
  4918. exports.deprecated = deprecated;
  4919. exports.error = error;
  4920. exports.getLookupTableFactory = getLookupTableFactory;
  4921. exports.getVerbosityLevel = getVerbosityLevel;
  4922. exports.globalScope = globalScope;
  4923. exports.info = info;
  4924. exports.isArray = isArray;
  4925. exports.isArrayBuffer = isArrayBuffer;
  4926. exports.isBool = isBool;
  4927. exports.isEmptyObj = isEmptyObj;
  4928. exports.isInt = isInt;
  4929. exports.isNum = isNum;
  4930. exports.isString = isString;
  4931. exports.isSpace = isSpace;
  4932. exports.isSameOrigin = isSameOrigin;
  4933. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  4934. exports.isLittleEndian = isLittleEndian;
  4935. exports.isEvalSupported = isEvalSupported;
  4936. exports.loadJpegStream = loadJpegStream;
  4937. exports.log2 = log2;
  4938. exports.readInt8 = readInt8;
  4939. exports.readUint16 = readUint16;
  4940. exports.readUint32 = readUint32;
  4941. exports.removeNullCharacters = removeNullCharacters;
  4942. exports.setVerbosityLevel = setVerbosityLevel;
  4943. exports.shadow = shadow;
  4944. exports.string32 = string32;
  4945. exports.stringToBytes = stringToBytes;
  4946. exports.stringToPDFString = stringToPDFString;
  4947. exports.stringToUTF8String = stringToUTF8String;
  4948. exports.utf8StringToString = utf8StringToString;
  4949. exports.warn = warn;
  4950. }));
  4951. (function (root, factory) {
  4952. factory(root.pdfjsCoreBidi = {}, root.pdfjsSharedUtil);
  4953. }(this, function (exports, sharedUtil) {
  4954. var warn = sharedUtil.warn;
  4955. var baseTypes = [
  4956. 'BN',
  4957. 'BN',
  4958. 'BN',
  4959. 'BN',
  4960. 'BN',
  4961. 'BN',
  4962. 'BN',
  4963. 'BN',
  4964. 'BN',
  4965. 'S',
  4966. 'B',
  4967. 'S',
  4968. 'WS',
  4969. 'B',
  4970. 'BN',
  4971. 'BN',
  4972. 'BN',
  4973. 'BN',
  4974. 'BN',
  4975. 'BN',
  4976. 'BN',
  4977. 'BN',
  4978. 'BN',
  4979. 'BN',
  4980. 'BN',
  4981. 'BN',
  4982. 'BN',
  4983. 'BN',
  4984. 'B',
  4985. 'B',
  4986. 'B',
  4987. 'S',
  4988. 'WS',
  4989. 'ON',
  4990. 'ON',
  4991. 'ET',
  4992. 'ET',
  4993. 'ET',
  4994. 'ON',
  4995. 'ON',
  4996. 'ON',
  4997. 'ON',
  4998. 'ON',
  4999. 'ES',
  5000. 'CS',
  5001. 'ES',
  5002. 'CS',
  5003. 'CS',
  5004. 'EN',
  5005. 'EN',
  5006. 'EN',
  5007. 'EN',
  5008. 'EN',
  5009. 'EN',
  5010. 'EN',
  5011. 'EN',
  5012. 'EN',
  5013. 'EN',
  5014. 'CS',
  5015. 'ON',
  5016. 'ON',
  5017. 'ON',
  5018. 'ON',
  5019. 'ON',
  5020. 'ON',
  5021. 'L',
  5022. 'L',
  5023. 'L',
  5024. 'L',
  5025. 'L',
  5026. 'L',
  5027. 'L',
  5028. 'L',
  5029. 'L',
  5030. 'L',
  5031. 'L',
  5032. 'L',
  5033. 'L',
  5034. 'L',
  5035. 'L',
  5036. 'L',
  5037. 'L',
  5038. 'L',
  5039. 'L',
  5040. 'L',
  5041. 'L',
  5042. 'L',
  5043. 'L',
  5044. 'L',
  5045. 'L',
  5046. 'L',
  5047. 'ON',
  5048. 'ON',
  5049. 'ON',
  5050. 'ON',
  5051. 'ON',
  5052. 'ON',
  5053. 'L',
  5054. 'L',
  5055. 'L',
  5056. 'L',
  5057. 'L',
  5058. 'L',
  5059. 'L',
  5060. 'L',
  5061. 'L',
  5062. 'L',
  5063. 'L',
  5064. 'L',
  5065. 'L',
  5066. 'L',
  5067. 'L',
  5068. 'L',
  5069. 'L',
  5070. 'L',
  5071. 'L',
  5072. 'L',
  5073. 'L',
  5074. 'L',
  5075. 'L',
  5076. 'L',
  5077. 'L',
  5078. 'L',
  5079. 'ON',
  5080. 'ON',
  5081. 'ON',
  5082. 'ON',
  5083. 'BN',
  5084. 'BN',
  5085. 'BN',
  5086. 'BN',
  5087. 'BN',
  5088. 'BN',
  5089. 'B',
  5090. 'BN',
  5091. 'BN',
  5092. 'BN',
  5093. 'BN',
  5094. 'BN',
  5095. 'BN',
  5096. 'BN',
  5097. 'BN',
  5098. 'BN',
  5099. 'BN',
  5100. 'BN',
  5101. 'BN',
  5102. 'BN',
  5103. 'BN',
  5104. 'BN',
  5105. 'BN',
  5106. 'BN',
  5107. 'BN',
  5108. 'BN',
  5109. 'BN',
  5110. 'BN',
  5111. 'BN',
  5112. 'BN',
  5113. 'BN',
  5114. 'BN',
  5115. 'BN',
  5116. 'CS',
  5117. 'ON',
  5118. 'ET',
  5119. 'ET',
  5120. 'ET',
  5121. 'ET',
  5122. 'ON',
  5123. 'ON',
  5124. 'ON',
  5125. 'ON',
  5126. 'L',
  5127. 'ON',
  5128. 'ON',
  5129. 'BN',
  5130. 'ON',
  5131. 'ON',
  5132. 'ET',
  5133. 'ET',
  5134. 'EN',
  5135. 'EN',
  5136. 'ON',
  5137. 'L',
  5138. 'ON',
  5139. 'ON',
  5140. 'ON',
  5141. 'EN',
  5142. 'L',
  5143. 'ON',
  5144. 'ON',
  5145. 'ON',
  5146. 'ON',
  5147. 'ON',
  5148. 'L',
  5149. 'L',
  5150. 'L',
  5151. 'L',
  5152. 'L',
  5153. 'L',
  5154. 'L',
  5155. 'L',
  5156. 'L',
  5157. 'L',
  5158. 'L',
  5159. 'L',
  5160. 'L',
  5161. 'L',
  5162. 'L',
  5163. 'L',
  5164. 'L',
  5165. 'L',
  5166. 'L',
  5167. 'L',
  5168. 'L',
  5169. 'L',
  5170. 'L',
  5171. 'ON',
  5172. 'L',
  5173. 'L',
  5174. 'L',
  5175. 'L',
  5176. 'L',
  5177. 'L',
  5178. 'L',
  5179. 'L',
  5180. 'L',
  5181. 'L',
  5182. 'L',
  5183. 'L',
  5184. 'L',
  5185. 'L',
  5186. 'L',
  5187. 'L',
  5188. 'L',
  5189. 'L',
  5190. 'L',
  5191. 'L',
  5192. 'L',
  5193. 'L',
  5194. 'L',
  5195. 'L',
  5196. 'L',
  5197. 'L',
  5198. 'L',
  5199. 'L',
  5200. 'L',
  5201. 'L',
  5202. 'L',
  5203. 'ON',
  5204. 'L',
  5205. 'L',
  5206. 'L',
  5207. 'L',
  5208. 'L',
  5209. 'L',
  5210. 'L',
  5211. 'L'
  5212. ];
  5213. var arabicTypes = [
  5214. 'AN',
  5215. 'AN',
  5216. 'AN',
  5217. 'AN',
  5218. 'AN',
  5219. 'AN',
  5220. 'ON',
  5221. 'ON',
  5222. 'AL',
  5223. 'ET',
  5224. 'ET',
  5225. 'AL',
  5226. 'CS',
  5227. 'AL',
  5228. 'ON',
  5229. 'ON',
  5230. 'NSM',
  5231. 'NSM',
  5232. 'NSM',
  5233. 'NSM',
  5234. 'NSM',
  5235. 'NSM',
  5236. 'NSM',
  5237. 'NSM',
  5238. 'NSM',
  5239. 'NSM',
  5240. 'NSM',
  5241. 'AL',
  5242. 'AL',
  5243. '',
  5244. 'AL',
  5245. 'AL',
  5246. 'AL',
  5247. 'AL',
  5248. 'AL',
  5249. 'AL',
  5250. 'AL',
  5251. 'AL',
  5252. 'AL',
  5253. 'AL',
  5254. 'AL',
  5255. 'AL',
  5256. 'AL',
  5257. 'AL',
  5258. 'AL',
  5259. 'AL',
  5260. 'AL',
  5261. 'AL',
  5262. 'AL',
  5263. 'AL',
  5264. 'AL',
  5265. 'AL',
  5266. 'AL',
  5267. 'AL',
  5268. 'AL',
  5269. 'AL',
  5270. 'AL',
  5271. 'AL',
  5272. 'AL',
  5273. 'AL',
  5274. 'AL',
  5275. 'AL',
  5276. 'AL',
  5277. 'AL',
  5278. 'AL',
  5279. 'AL',
  5280. 'AL',
  5281. 'AL',
  5282. 'AL',
  5283. 'AL',
  5284. 'AL',
  5285. 'AL',
  5286. 'AL',
  5287. 'AL',
  5288. 'AL',
  5289. 'NSM',
  5290. 'NSM',
  5291. 'NSM',
  5292. 'NSM',
  5293. 'NSM',
  5294. 'NSM',
  5295. 'NSM',
  5296. 'NSM',
  5297. 'NSM',
  5298. 'NSM',
  5299. 'NSM',
  5300. 'NSM',
  5301. 'NSM',
  5302. 'NSM',
  5303. 'NSM',
  5304. 'NSM',
  5305. 'NSM',
  5306. 'NSM',
  5307. 'NSM',
  5308. 'NSM',
  5309. 'NSM',
  5310. 'AN',
  5311. 'AN',
  5312. 'AN',
  5313. 'AN',
  5314. 'AN',
  5315. 'AN',
  5316. 'AN',
  5317. 'AN',
  5318. 'AN',
  5319. 'AN',
  5320. 'ET',
  5321. 'AN',
  5322. 'AN',
  5323. 'AL',
  5324. 'AL',
  5325. 'AL',
  5326. 'NSM',
  5327. 'AL',
  5328. 'AL',
  5329. 'AL',
  5330. 'AL',
  5331. 'AL',
  5332. 'AL',
  5333. 'AL',
  5334. 'AL',
  5335. 'AL',
  5336. 'AL',
  5337. 'AL',
  5338. 'AL',
  5339. 'AL',
  5340. 'AL',
  5341. 'AL',
  5342. 'AL',
  5343. 'AL',
  5344. 'AL',
  5345. 'AL',
  5346. 'AL',
  5347. 'AL',
  5348. 'AL',
  5349. 'AL',
  5350. 'AL',
  5351. 'AL',
  5352. 'AL',
  5353. 'AL',
  5354. 'AL',
  5355. 'AL',
  5356. 'AL',
  5357. 'AL',
  5358. 'AL',
  5359. 'AL',
  5360. 'AL',
  5361. 'AL',
  5362. 'AL',
  5363. 'AL',
  5364. 'AL',
  5365. 'AL',
  5366. 'AL',
  5367. 'AL',
  5368. 'AL',
  5369. 'AL',
  5370. 'AL',
  5371. 'AL',
  5372. 'AL',
  5373. 'AL',
  5374. 'AL',
  5375. 'AL',
  5376. 'AL',
  5377. 'AL',
  5378. 'AL',
  5379. 'AL',
  5380. 'AL',
  5381. 'AL',
  5382. 'AL',
  5383. 'AL',
  5384. 'AL',
  5385. 'AL',
  5386. 'AL',
  5387. 'AL',
  5388. 'AL',
  5389. 'AL',
  5390. 'AL',
  5391. 'AL',
  5392. 'AL',
  5393. 'AL',
  5394. 'AL',
  5395. 'AL',
  5396. 'AL',
  5397. 'AL',
  5398. 'AL',
  5399. 'AL',
  5400. 'AL',
  5401. 'AL',
  5402. 'AL',
  5403. 'AL',
  5404. 'AL',
  5405. 'AL',
  5406. 'AL',
  5407. 'AL',
  5408. 'AL',
  5409. 'AL',
  5410. 'AL',
  5411. 'AL',
  5412. 'AL',
  5413. 'AL',
  5414. 'AL',
  5415. 'AL',
  5416. 'AL',
  5417. 'AL',
  5418. 'AL',
  5419. 'AL',
  5420. 'AL',
  5421. 'AL',
  5422. 'AL',
  5423. 'AL',
  5424. 'AL',
  5425. 'AL',
  5426. 'AL',
  5427. 'AL',
  5428. 'NSM',
  5429. 'NSM',
  5430. 'NSM',
  5431. 'NSM',
  5432. 'NSM',
  5433. 'NSM',
  5434. 'NSM',
  5435. 'AN',
  5436. 'ON',
  5437. 'NSM',
  5438. 'NSM',
  5439. 'NSM',
  5440. 'NSM',
  5441. 'NSM',
  5442. 'NSM',
  5443. 'AL',
  5444. 'AL',
  5445. 'NSM',
  5446. 'NSM',
  5447. 'ON',
  5448. 'NSM',
  5449. 'NSM',
  5450. 'NSM',
  5451. 'NSM',
  5452. 'AL',
  5453. 'AL',
  5454. 'EN',
  5455. 'EN',
  5456. 'EN',
  5457. 'EN',
  5458. 'EN',
  5459. 'EN',
  5460. 'EN',
  5461. 'EN',
  5462. 'EN',
  5463. 'EN',
  5464. 'AL',
  5465. 'AL',
  5466. 'AL',
  5467. 'AL',
  5468. 'AL',
  5469. 'AL'
  5470. ];
  5471. function isOdd(i) {
  5472. return (i & 1) !== 0;
  5473. }
  5474. function isEven(i) {
  5475. return (i & 1) === 0;
  5476. }
  5477. function findUnequal(arr, start, value) {
  5478. for (var j = start, jj = arr.length; j < jj; ++j) {
  5479. if (arr[j] !== value) {
  5480. return j;
  5481. }
  5482. }
  5483. return j;
  5484. }
  5485. function setValues(arr, start, end, value) {
  5486. for (var j = start; j < end; ++j) {
  5487. arr[j] = value;
  5488. }
  5489. }
  5490. function reverseValues(arr, start, end) {
  5491. for (var i = start, j = end - 1; i < j; ++i, --j) {
  5492. var temp = arr[i];
  5493. arr[i] = arr[j];
  5494. arr[j] = temp;
  5495. }
  5496. }
  5497. function createBidiText(str, isLTR, vertical) {
  5498. return {
  5499. str: str,
  5500. dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
  5501. };
  5502. }
  5503. var chars = [];
  5504. var types = [];
  5505. function bidi(str, startLevel, vertical) {
  5506. var isLTR = true;
  5507. var strLength = str.length;
  5508. if (strLength === 0 || vertical) {
  5509. return createBidiText(str, isLTR, vertical);
  5510. }
  5511. chars.length = strLength;
  5512. types.length = strLength;
  5513. var numBidi = 0;
  5514. var i, ii;
  5515. for (i = 0; i < strLength; ++i) {
  5516. chars[i] = str.charAt(i);
  5517. var charCode = str.charCodeAt(i);
  5518. var charType = 'L';
  5519. if (charCode <= 0x00ff) {
  5520. charType = baseTypes[charCode];
  5521. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  5522. charType = 'R';
  5523. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  5524. charType = arabicTypes[charCode & 0xff];
  5525. if (!charType) {
  5526. warn('Bidi: invalid Unicode character ' + charCode.toString(16));
  5527. }
  5528. } else if (0x0700 <= charCode && charCode <= 0x08AC) {
  5529. charType = 'AL';
  5530. }
  5531. if (charType === 'R' || charType === 'AL' || charType === 'AN') {
  5532. numBidi++;
  5533. }
  5534. types[i] = charType;
  5535. }
  5536. if (numBidi === 0) {
  5537. isLTR = true;
  5538. return createBidiText(str, isLTR);
  5539. }
  5540. if (startLevel === -1) {
  5541. if (strLength / numBidi < 0.3) {
  5542. isLTR = true;
  5543. startLevel = 0;
  5544. } else {
  5545. isLTR = false;
  5546. startLevel = 1;
  5547. }
  5548. }
  5549. var levels = [];
  5550. for (i = 0; i < strLength; ++i) {
  5551. levels[i] = startLevel;
  5552. }
  5553. var e = isOdd(startLevel) ? 'R' : 'L';
  5554. var sor = e;
  5555. var eor = sor;
  5556. var lastType = sor;
  5557. for (i = 0; i < strLength; ++i) {
  5558. if (types[i] === 'NSM') {
  5559. types[i] = lastType;
  5560. } else {
  5561. lastType = types[i];
  5562. }
  5563. }
  5564. lastType = sor;
  5565. var t;
  5566. for (i = 0; i < strLength; ++i) {
  5567. t = types[i];
  5568. if (t === 'EN') {
  5569. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  5570. } else if (t === 'R' || t === 'L' || t === 'AL') {
  5571. lastType = t;
  5572. }
  5573. }
  5574. for (i = 0; i < strLength; ++i) {
  5575. t = types[i];
  5576. if (t === 'AL') {
  5577. types[i] = 'R';
  5578. }
  5579. }
  5580. for (i = 1; i < strLength - 1; ++i) {
  5581. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  5582. types[i] = 'EN';
  5583. }
  5584. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  5585. types[i] = types[i - 1];
  5586. }
  5587. }
  5588. for (i = 0; i < strLength; ++i) {
  5589. if (types[i] === 'EN') {
  5590. var j;
  5591. for (j = i - 1; j >= 0; --j) {
  5592. if (types[j] !== 'ET') {
  5593. break;
  5594. }
  5595. types[j] = 'EN';
  5596. }
  5597. for (j = i + 1; j < strLength; ++j) {
  5598. if (types[j] !== 'ET') {
  5599. break;
  5600. }
  5601. types[j] = 'EN';
  5602. }
  5603. }
  5604. }
  5605. for (i = 0; i < strLength; ++i) {
  5606. t = types[i];
  5607. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  5608. types[i] = 'ON';
  5609. }
  5610. }
  5611. lastType = sor;
  5612. for (i = 0; i < strLength; ++i) {
  5613. t = types[i];
  5614. if (t === 'EN') {
  5615. types[i] = lastType === 'L' ? 'L' : 'EN';
  5616. } else if (t === 'R' || t === 'L') {
  5617. lastType = t;
  5618. }
  5619. }
  5620. for (i = 0; i < strLength; ++i) {
  5621. if (types[i] === 'ON') {
  5622. var end = findUnequal(types, i + 1, 'ON');
  5623. var before = sor;
  5624. if (i > 0) {
  5625. before = types[i - 1];
  5626. }
  5627. var after = eor;
  5628. if (end + 1 < strLength) {
  5629. after = types[end + 1];
  5630. }
  5631. if (before !== 'L') {
  5632. before = 'R';
  5633. }
  5634. if (after !== 'L') {
  5635. after = 'R';
  5636. }
  5637. if (before === after) {
  5638. setValues(types, i, end, before);
  5639. }
  5640. i = end - 1;
  5641. }
  5642. }
  5643. for (i = 0; i < strLength; ++i) {
  5644. if (types[i] === 'ON') {
  5645. types[i] = e;
  5646. }
  5647. }
  5648. for (i = 0; i < strLength; ++i) {
  5649. t = types[i];
  5650. if (isEven(levels[i])) {
  5651. if (t === 'R') {
  5652. levels[i] += 1;
  5653. } else if (t === 'AN' || t === 'EN') {
  5654. levels[i] += 2;
  5655. }
  5656. } else {
  5657. if (t === 'L' || t === 'AN' || t === 'EN') {
  5658. levels[i] += 1;
  5659. }
  5660. }
  5661. }
  5662. var highestLevel = -1;
  5663. var lowestOddLevel = 99;
  5664. var level;
  5665. for (i = 0, ii = levels.length; i < ii; ++i) {
  5666. level = levels[i];
  5667. if (highestLevel < level) {
  5668. highestLevel = level;
  5669. }
  5670. if (lowestOddLevel > level && isOdd(level)) {
  5671. lowestOddLevel = level;
  5672. }
  5673. }
  5674. for (level = highestLevel; level >= lowestOddLevel; --level) {
  5675. var start = -1;
  5676. for (i = 0, ii = levels.length; i < ii; ++i) {
  5677. if (levels[i] < level) {
  5678. if (start >= 0) {
  5679. reverseValues(chars, start, i);
  5680. start = -1;
  5681. }
  5682. } else if (start < 0) {
  5683. start = i;
  5684. }
  5685. }
  5686. if (start >= 0) {
  5687. reverseValues(chars, start, levels.length);
  5688. }
  5689. }
  5690. for (i = 0, ii = chars.length; i < ii; ++i) {
  5691. var ch = chars[i];
  5692. if (ch === '<' || ch === '>') {
  5693. chars[i] = '';
  5694. }
  5695. }
  5696. return createBidiText(chars.join(''), isLTR);
  5697. }
  5698. exports.bidi = bidi;
  5699. }));
  5700. (function (root, factory) {
  5701. factory(root.pdfjsCoreCFFParser = {}, root.pdfjsSharedUtil, root.pdfjsCoreCharsets, root.pdfjsCoreEncodings);
  5702. }(this, function (exports, sharedUtil, coreCharsets, coreEncodings) {
  5703. var error = sharedUtil.error;
  5704. var info = sharedUtil.info;
  5705. var bytesToString = sharedUtil.bytesToString;
  5706. var warn = sharedUtil.warn;
  5707. var isArray = sharedUtil.isArray;
  5708. var Util = sharedUtil.Util;
  5709. var stringToBytes = sharedUtil.stringToBytes;
  5710. var assert = sharedUtil.assert;
  5711. var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
  5712. var ExpertCharset = coreCharsets.ExpertCharset;
  5713. var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
  5714. var StandardEncoding = coreEncodings.StandardEncoding;
  5715. var ExpertEncoding = coreEncodings.ExpertEncoding;
  5716. var MAX_SUBR_NESTING = 10;
  5717. var CFFStandardStrings = [
  5718. '.notdef',
  5719. 'space',
  5720. 'exclam',
  5721. 'quotedbl',
  5722. 'numbersign',
  5723. 'dollar',
  5724. 'percent',
  5725. 'ampersand',
  5726. 'quoteright',
  5727. 'parenleft',
  5728. 'parenright',
  5729. 'asterisk',
  5730. 'plus',
  5731. 'comma',
  5732. 'hyphen',
  5733. 'period',
  5734. 'slash',
  5735. 'zero',
  5736. 'one',
  5737. 'two',
  5738. 'three',
  5739. 'four',
  5740. 'five',
  5741. 'six',
  5742. 'seven',
  5743. 'eight',
  5744. 'nine',
  5745. 'colon',
  5746. 'semicolon',
  5747. 'less',
  5748. 'equal',
  5749. 'greater',
  5750. 'question',
  5751. 'at',
  5752. 'A',
  5753. 'B',
  5754. 'C',
  5755. 'D',
  5756. 'E',
  5757. 'F',
  5758. 'G',
  5759. 'H',
  5760. 'I',
  5761. 'J',
  5762. 'K',
  5763. 'L',
  5764. 'M',
  5765. 'N',
  5766. 'O',
  5767. 'P',
  5768. 'Q',
  5769. 'R',
  5770. 'S',
  5771. 'T',
  5772. 'U',
  5773. 'V',
  5774. 'W',
  5775. 'X',
  5776. 'Y',
  5777. 'Z',
  5778. 'bracketleft',
  5779. 'backslash',
  5780. 'bracketright',
  5781. 'asciicircum',
  5782. 'underscore',
  5783. 'quoteleft',
  5784. 'a',
  5785. 'b',
  5786. 'c',
  5787. 'd',
  5788. 'e',
  5789. 'f',
  5790. 'g',
  5791. 'h',
  5792. 'i',
  5793. 'j',
  5794. 'k',
  5795. 'l',
  5796. 'm',
  5797. 'n',
  5798. 'o',
  5799. 'p',
  5800. 'q',
  5801. 'r',
  5802. 's',
  5803. 't',
  5804. 'u',
  5805. 'v',
  5806. 'w',
  5807. 'x',
  5808. 'y',
  5809. 'z',
  5810. 'braceleft',
  5811. 'bar',
  5812. 'braceright',
  5813. 'asciitilde',
  5814. 'exclamdown',
  5815. 'cent',
  5816. 'sterling',
  5817. 'fraction',
  5818. 'yen',
  5819. 'florin',
  5820. 'section',
  5821. 'currency',
  5822. 'quotesingle',
  5823. 'quotedblleft',
  5824. 'guillemotleft',
  5825. 'guilsinglleft',
  5826. 'guilsinglright',
  5827. 'fi',
  5828. 'fl',
  5829. 'endash',
  5830. 'dagger',
  5831. 'daggerdbl',
  5832. 'periodcentered',
  5833. 'paragraph',
  5834. 'bullet',
  5835. 'quotesinglbase',
  5836. 'quotedblbase',
  5837. 'quotedblright',
  5838. 'guillemotright',
  5839. 'ellipsis',
  5840. 'perthousand',
  5841. 'questiondown',
  5842. 'grave',
  5843. 'acute',
  5844. 'circumflex',
  5845. 'tilde',
  5846. 'macron',
  5847. 'breve',
  5848. 'dotaccent',
  5849. 'dieresis',
  5850. 'ring',
  5851. 'cedilla',
  5852. 'hungarumlaut',
  5853. 'ogonek',
  5854. 'caron',
  5855. 'emdash',
  5856. 'AE',
  5857. 'ordfeminine',
  5858. 'Lslash',
  5859. 'Oslash',
  5860. 'OE',
  5861. 'ordmasculine',
  5862. 'ae',
  5863. 'dotlessi',
  5864. 'lslash',
  5865. 'oslash',
  5866. 'oe',
  5867. 'germandbls',
  5868. 'onesuperior',
  5869. 'logicalnot',
  5870. 'mu',
  5871. 'trademark',
  5872. 'Eth',
  5873. 'onehalf',
  5874. 'plusminus',
  5875. 'Thorn',
  5876. 'onequarter',
  5877. 'divide',
  5878. 'brokenbar',
  5879. 'degree',
  5880. 'thorn',
  5881. 'threequarters',
  5882. 'twosuperior',
  5883. 'registered',
  5884. 'minus',
  5885. 'eth',
  5886. 'multiply',
  5887. 'threesuperior',
  5888. 'copyright',
  5889. 'Aacute',
  5890. 'Acircumflex',
  5891. 'Adieresis',
  5892. 'Agrave',
  5893. 'Aring',
  5894. 'Atilde',
  5895. 'Ccedilla',
  5896. 'Eacute',
  5897. 'Ecircumflex',
  5898. 'Edieresis',
  5899. 'Egrave',
  5900. 'Iacute',
  5901. 'Icircumflex',
  5902. 'Idieresis',
  5903. 'Igrave',
  5904. 'Ntilde',
  5905. 'Oacute',
  5906. 'Ocircumflex',
  5907. 'Odieresis',
  5908. 'Ograve',
  5909. 'Otilde',
  5910. 'Scaron',
  5911. 'Uacute',
  5912. 'Ucircumflex',
  5913. 'Udieresis',
  5914. 'Ugrave',
  5915. 'Yacute',
  5916. 'Ydieresis',
  5917. 'Zcaron',
  5918. 'aacute',
  5919. 'acircumflex',
  5920. 'adieresis',
  5921. 'agrave',
  5922. 'aring',
  5923. 'atilde',
  5924. 'ccedilla',
  5925. 'eacute',
  5926. 'ecircumflex',
  5927. 'edieresis',
  5928. 'egrave',
  5929. 'iacute',
  5930. 'icircumflex',
  5931. 'idieresis',
  5932. 'igrave',
  5933. 'ntilde',
  5934. 'oacute',
  5935. 'ocircumflex',
  5936. 'odieresis',
  5937. 'ograve',
  5938. 'otilde',
  5939. 'scaron',
  5940. 'uacute',
  5941. 'ucircumflex',
  5942. 'udieresis',
  5943. 'ugrave',
  5944. 'yacute',
  5945. 'ydieresis',
  5946. 'zcaron',
  5947. 'exclamsmall',
  5948. 'Hungarumlautsmall',
  5949. 'dollaroldstyle',
  5950. 'dollarsuperior',
  5951. 'ampersandsmall',
  5952. 'Acutesmall',
  5953. 'parenleftsuperior',
  5954. 'parenrightsuperior',
  5955. 'twodotenleader',
  5956. 'onedotenleader',
  5957. 'zerooldstyle',
  5958. 'oneoldstyle',
  5959. 'twooldstyle',
  5960. 'threeoldstyle',
  5961. 'fouroldstyle',
  5962. 'fiveoldstyle',
  5963. 'sixoldstyle',
  5964. 'sevenoldstyle',
  5965. 'eightoldstyle',
  5966. 'nineoldstyle',
  5967. 'commasuperior',
  5968. 'threequartersemdash',
  5969. 'periodsuperior',
  5970. 'questionsmall',
  5971. 'asuperior',
  5972. 'bsuperior',
  5973. 'centsuperior',
  5974. 'dsuperior',
  5975. 'esuperior',
  5976. 'isuperior',
  5977. 'lsuperior',
  5978. 'msuperior',
  5979. 'nsuperior',
  5980. 'osuperior',
  5981. 'rsuperior',
  5982. 'ssuperior',
  5983. 'tsuperior',
  5984. 'ff',
  5985. 'ffi',
  5986. 'ffl',
  5987. 'parenleftinferior',
  5988. 'parenrightinferior',
  5989. 'Circumflexsmall',
  5990. 'hyphensuperior',
  5991. 'Gravesmall',
  5992. 'Asmall',
  5993. 'Bsmall',
  5994. 'Csmall',
  5995. 'Dsmall',
  5996. 'Esmall',
  5997. 'Fsmall',
  5998. 'Gsmall',
  5999. 'Hsmall',
  6000. 'Ismall',
  6001. 'Jsmall',
  6002. 'Ksmall',
  6003. 'Lsmall',
  6004. 'Msmall',
  6005. 'Nsmall',
  6006. 'Osmall',
  6007. 'Psmall',
  6008. 'Qsmall',
  6009. 'Rsmall',
  6010. 'Ssmall',
  6011. 'Tsmall',
  6012. 'Usmall',
  6013. 'Vsmall',
  6014. 'Wsmall',
  6015. 'Xsmall',
  6016. 'Ysmall',
  6017. 'Zsmall',
  6018. 'colonmonetary',
  6019. 'onefitted',
  6020. 'rupiah',
  6021. 'Tildesmall',
  6022. 'exclamdownsmall',
  6023. 'centoldstyle',
  6024. 'Lslashsmall',
  6025. 'Scaronsmall',
  6026. 'Zcaronsmall',
  6027. 'Dieresissmall',
  6028. 'Brevesmall',
  6029. 'Caronsmall',
  6030. 'Dotaccentsmall',
  6031. 'Macronsmall',
  6032. 'figuredash',
  6033. 'hypheninferior',
  6034. 'Ogoneksmall',
  6035. 'Ringsmall',
  6036. 'Cedillasmall',
  6037. 'questiondownsmall',
  6038. 'oneeighth',
  6039. 'threeeighths',
  6040. 'fiveeighths',
  6041. 'seveneighths',
  6042. 'onethird',
  6043. 'twothirds',
  6044. 'zerosuperior',
  6045. 'foursuperior',
  6046. 'fivesuperior',
  6047. 'sixsuperior',
  6048. 'sevensuperior',
  6049. 'eightsuperior',
  6050. 'ninesuperior',
  6051. 'zeroinferior',
  6052. 'oneinferior',
  6053. 'twoinferior',
  6054. 'threeinferior',
  6055. 'fourinferior',
  6056. 'fiveinferior',
  6057. 'sixinferior',
  6058. 'seveninferior',
  6059. 'eightinferior',
  6060. 'nineinferior',
  6061. 'centinferior',
  6062. 'dollarinferior',
  6063. 'periodinferior',
  6064. 'commainferior',
  6065. 'Agravesmall',
  6066. 'Aacutesmall',
  6067. 'Acircumflexsmall',
  6068. 'Atildesmall',
  6069. 'Adieresissmall',
  6070. 'Aringsmall',
  6071. 'AEsmall',
  6072. 'Ccedillasmall',
  6073. 'Egravesmall',
  6074. 'Eacutesmall',
  6075. 'Ecircumflexsmall',
  6076. 'Edieresissmall',
  6077. 'Igravesmall',
  6078. 'Iacutesmall',
  6079. 'Icircumflexsmall',
  6080. 'Idieresissmall',
  6081. 'Ethsmall',
  6082. 'Ntildesmall',
  6083. 'Ogravesmall',
  6084. 'Oacutesmall',
  6085. 'Ocircumflexsmall',
  6086. 'Otildesmall',
  6087. 'Odieresissmall',
  6088. 'OEsmall',
  6089. 'Oslashsmall',
  6090. 'Ugravesmall',
  6091. 'Uacutesmall',
  6092. 'Ucircumflexsmall',
  6093. 'Udieresissmall',
  6094. 'Yacutesmall',
  6095. 'Thornsmall',
  6096. 'Ydieresissmall',
  6097. '001.000',
  6098. '001.001',
  6099. '001.002',
  6100. '001.003',
  6101. 'Black',
  6102. 'Bold',
  6103. 'Book',
  6104. 'Light',
  6105. 'Medium',
  6106. 'Regular',
  6107. 'Roman',
  6108. 'Semibold'
  6109. ];
  6110. var CFFParser = function CFFParserClosure() {
  6111. var CharstringValidationData = [
  6112. null,
  6113. {
  6114. id: 'hstem',
  6115. min: 2,
  6116. stackClearing: true,
  6117. stem: true
  6118. },
  6119. null,
  6120. {
  6121. id: 'vstem',
  6122. min: 2,
  6123. stackClearing: true,
  6124. stem: true
  6125. },
  6126. {
  6127. id: 'vmoveto',
  6128. min: 1,
  6129. stackClearing: true
  6130. },
  6131. {
  6132. id: 'rlineto',
  6133. min: 2,
  6134. resetStack: true
  6135. },
  6136. {
  6137. id: 'hlineto',
  6138. min: 1,
  6139. resetStack: true
  6140. },
  6141. {
  6142. id: 'vlineto',
  6143. min: 1,
  6144. resetStack: true
  6145. },
  6146. {
  6147. id: 'rrcurveto',
  6148. min: 6,
  6149. resetStack: true
  6150. },
  6151. null,
  6152. {
  6153. id: 'callsubr',
  6154. min: 1,
  6155. undefStack: true
  6156. },
  6157. {
  6158. id: 'return',
  6159. min: 0,
  6160. undefStack: true
  6161. },
  6162. null,
  6163. null,
  6164. {
  6165. id: 'endchar',
  6166. min: 0,
  6167. stackClearing: true
  6168. },
  6169. null,
  6170. null,
  6171. null,
  6172. {
  6173. id: 'hstemhm',
  6174. min: 2,
  6175. stackClearing: true,
  6176. stem: true
  6177. },
  6178. {
  6179. id: 'hintmask',
  6180. min: 0,
  6181. stackClearing: true
  6182. },
  6183. {
  6184. id: 'cntrmask',
  6185. min: 0,
  6186. stackClearing: true
  6187. },
  6188. {
  6189. id: 'rmoveto',
  6190. min: 2,
  6191. stackClearing: true
  6192. },
  6193. {
  6194. id: 'hmoveto',
  6195. min: 1,
  6196. stackClearing: true
  6197. },
  6198. {
  6199. id: 'vstemhm',
  6200. min: 2,
  6201. stackClearing: true,
  6202. stem: true
  6203. },
  6204. {
  6205. id: 'rcurveline',
  6206. min: 8,
  6207. resetStack: true
  6208. },
  6209. {
  6210. id: 'rlinecurve',
  6211. min: 8,
  6212. resetStack: true
  6213. },
  6214. {
  6215. id: 'vvcurveto',
  6216. min: 4,
  6217. resetStack: true
  6218. },
  6219. {
  6220. id: 'hhcurveto',
  6221. min: 4,
  6222. resetStack: true
  6223. },
  6224. null,
  6225. {
  6226. id: 'callgsubr',
  6227. min: 1,
  6228. undefStack: true
  6229. },
  6230. {
  6231. id: 'vhcurveto',
  6232. min: 4,
  6233. resetStack: true
  6234. },
  6235. {
  6236. id: 'hvcurveto',
  6237. min: 4,
  6238. resetStack: true
  6239. }
  6240. ];
  6241. var CharstringValidationData12 = [
  6242. null,
  6243. null,
  6244. null,
  6245. {
  6246. id: 'and',
  6247. min: 2,
  6248. stackDelta: -1
  6249. },
  6250. {
  6251. id: 'or',
  6252. min: 2,
  6253. stackDelta: -1
  6254. },
  6255. {
  6256. id: 'not',
  6257. min: 1,
  6258. stackDelta: 0
  6259. },
  6260. null,
  6261. null,
  6262. null,
  6263. {
  6264. id: 'abs',
  6265. min: 1,
  6266. stackDelta: 0
  6267. },
  6268. {
  6269. id: 'add',
  6270. min: 2,
  6271. stackDelta: -1,
  6272. stackFn: function stack_div(stack, index) {
  6273. stack[index - 2] = stack[index - 2] + stack[index - 1];
  6274. }
  6275. },
  6276. {
  6277. id: 'sub',
  6278. min: 2,
  6279. stackDelta: -1,
  6280. stackFn: function stack_div(stack, index) {
  6281. stack[index - 2] = stack[index - 2] - stack[index - 1];
  6282. }
  6283. },
  6284. {
  6285. id: 'div',
  6286. min: 2,
  6287. stackDelta: -1,
  6288. stackFn: function stack_div(stack, index) {
  6289. stack[index - 2] = stack[index - 2] / stack[index - 1];
  6290. }
  6291. },
  6292. null,
  6293. {
  6294. id: 'neg',
  6295. min: 1,
  6296. stackDelta: 0,
  6297. stackFn: function stack_div(stack, index) {
  6298. stack[index - 1] = -stack[index - 1];
  6299. }
  6300. },
  6301. {
  6302. id: 'eq',
  6303. min: 2,
  6304. stackDelta: -1
  6305. },
  6306. null,
  6307. null,
  6308. {
  6309. id: 'drop',
  6310. min: 1,
  6311. stackDelta: -1
  6312. },
  6313. null,
  6314. {
  6315. id: 'put',
  6316. min: 2,
  6317. stackDelta: -2
  6318. },
  6319. {
  6320. id: 'get',
  6321. min: 1,
  6322. stackDelta: 0
  6323. },
  6324. {
  6325. id: 'ifelse',
  6326. min: 4,
  6327. stackDelta: -3
  6328. },
  6329. {
  6330. id: 'random',
  6331. min: 0,
  6332. stackDelta: 1
  6333. },
  6334. {
  6335. id: 'mul',
  6336. min: 2,
  6337. stackDelta: -1,
  6338. stackFn: function stack_div(stack, index) {
  6339. stack[index - 2] = stack[index - 2] * stack[index - 1];
  6340. }
  6341. },
  6342. null,
  6343. {
  6344. id: 'sqrt',
  6345. min: 1,
  6346. stackDelta: 0
  6347. },
  6348. {
  6349. id: 'dup',
  6350. min: 1,
  6351. stackDelta: 1
  6352. },
  6353. {
  6354. id: 'exch',
  6355. min: 2,
  6356. stackDelta: 0
  6357. },
  6358. {
  6359. id: 'index',
  6360. min: 2,
  6361. stackDelta: 0
  6362. },
  6363. {
  6364. id: 'roll',
  6365. min: 3,
  6366. stackDelta: -2
  6367. },
  6368. null,
  6369. null,
  6370. null,
  6371. {
  6372. id: 'hflex',
  6373. min: 7,
  6374. resetStack: true
  6375. },
  6376. {
  6377. id: 'flex',
  6378. min: 13,
  6379. resetStack: true
  6380. },
  6381. {
  6382. id: 'hflex1',
  6383. min: 9,
  6384. resetStack: true
  6385. },
  6386. {
  6387. id: 'flex1',
  6388. min: 11,
  6389. resetStack: true
  6390. }
  6391. ];
  6392. function CFFParser(file, properties, seacAnalysisEnabled) {
  6393. this.bytes = file.getBytes();
  6394. this.properties = properties;
  6395. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  6396. }
  6397. CFFParser.prototype = {
  6398. parse: function CFFParser_parse() {
  6399. var properties = this.properties;
  6400. var cff = new CFF();
  6401. this.cff = cff;
  6402. var header = this.parseHeader();
  6403. var nameIndex = this.parseIndex(header.endPos);
  6404. var topDictIndex = this.parseIndex(nameIndex.endPos);
  6405. var stringIndex = this.parseIndex(topDictIndex.endPos);
  6406. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  6407. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  6408. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  6409. cff.header = header.obj;
  6410. cff.names = this.parseNameIndex(nameIndex.obj);
  6411. cff.strings = this.parseStringIndex(stringIndex.obj);
  6412. cff.topDict = topDict;
  6413. cff.globalSubrIndex = globalSubrIndex.obj;
  6414. this.parsePrivateDict(cff.topDict);
  6415. cff.isCIDFont = topDict.hasName('ROS');
  6416. var charStringOffset = topDict.getByName('CharStrings');
  6417. var charStringIndex = this.parseIndex(charStringOffset).obj;
  6418. var fontMatrix = topDict.getByName('FontMatrix');
  6419. if (fontMatrix) {
  6420. properties.fontMatrix = fontMatrix;
  6421. }
  6422. var fontBBox = topDict.getByName('FontBBox');
  6423. if (fontBBox) {
  6424. properties.ascent = fontBBox[3];
  6425. properties.descent = fontBBox[1];
  6426. properties.ascentScaled = true;
  6427. }
  6428. var charset, encoding;
  6429. if (cff.isCIDFont) {
  6430. var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
  6431. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  6432. var dictRaw = fdArrayIndex.get(i);
  6433. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  6434. this.parsePrivateDict(fontDict);
  6435. cff.fdArray.push(fontDict);
  6436. }
  6437. encoding = null;
  6438. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
  6439. cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
  6440. } else {
  6441. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
  6442. encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
  6443. }
  6444. cff.charset = charset;
  6445. cff.encoding = encoding;
  6446. var charStringsAndSeacs = this.parseCharStrings(charStringIndex, topDict.privateDict.subrsIndex, globalSubrIndex.obj, cff.fdSelect, cff.fdArray);
  6447. cff.charStrings = charStringsAndSeacs.charStrings;
  6448. cff.seacs = charStringsAndSeacs.seacs;
  6449. cff.widths = charStringsAndSeacs.widths;
  6450. return cff;
  6451. },
  6452. parseHeader: function CFFParser_parseHeader() {
  6453. var bytes = this.bytes;
  6454. var bytesLength = bytes.length;
  6455. var offset = 0;
  6456. while (offset < bytesLength && bytes[offset] !== 1) {
  6457. ++offset;
  6458. }
  6459. if (offset >= bytesLength) {
  6460. error('Invalid CFF header');
  6461. } else if (offset !== 0) {
  6462. info('cff data is shifted');
  6463. bytes = bytes.subarray(offset);
  6464. this.bytes = bytes;
  6465. }
  6466. var major = bytes[0];
  6467. var minor = bytes[1];
  6468. var hdrSize = bytes[2];
  6469. var offSize = bytes[3];
  6470. var header = new CFFHeader(major, minor, hdrSize, offSize);
  6471. return {
  6472. obj: header,
  6473. endPos: hdrSize
  6474. };
  6475. },
  6476. parseDict: function CFFParser_parseDict(dict) {
  6477. var pos = 0;
  6478. function parseOperand() {
  6479. var value = dict[pos++];
  6480. if (value === 30) {
  6481. return parseFloatOperand();
  6482. } else if (value === 28) {
  6483. value = dict[pos++];
  6484. value = (value << 24 | dict[pos++] << 16) >> 16;
  6485. return value;
  6486. } else if (value === 29) {
  6487. value = dict[pos++];
  6488. value = value << 8 | dict[pos++];
  6489. value = value << 8 | dict[pos++];
  6490. value = value << 8 | dict[pos++];
  6491. return value;
  6492. } else if (value >= 32 && value <= 246) {
  6493. return value - 139;
  6494. } else if (value >= 247 && value <= 250) {
  6495. return (value - 247) * 256 + dict[pos++] + 108;
  6496. } else if (value >= 251 && value <= 254) {
  6497. return -((value - 251) * 256) - dict[pos++] - 108;
  6498. } else {
  6499. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  6500. return NaN;
  6501. }
  6502. }
  6503. function parseFloatOperand() {
  6504. var str = '';
  6505. var eof = 15;
  6506. var lookup = [
  6507. '0',
  6508. '1',
  6509. '2',
  6510. '3',
  6511. '4',
  6512. '5',
  6513. '6',
  6514. '7',
  6515. '8',
  6516. '9',
  6517. '.',
  6518. 'E',
  6519. 'E-',
  6520. null,
  6521. '-'
  6522. ];
  6523. var length = dict.length;
  6524. while (pos < length) {
  6525. var b = dict[pos++];
  6526. var b1 = b >> 4;
  6527. var b2 = b & 15;
  6528. if (b1 === eof) {
  6529. break;
  6530. }
  6531. str += lookup[b1];
  6532. if (b2 === eof) {
  6533. break;
  6534. }
  6535. str += lookup[b2];
  6536. }
  6537. return parseFloat(str);
  6538. }
  6539. var operands = [];
  6540. var entries = [];
  6541. pos = 0;
  6542. var end = dict.length;
  6543. while (pos < end) {
  6544. var b = dict[pos];
  6545. if (b <= 21) {
  6546. if (b === 12) {
  6547. b = b << 8 | dict[++pos];
  6548. }
  6549. entries.push([
  6550. b,
  6551. operands
  6552. ]);
  6553. operands = [];
  6554. ++pos;
  6555. } else {
  6556. operands.push(parseOperand());
  6557. }
  6558. }
  6559. return entries;
  6560. },
  6561. parseIndex: function CFFParser_parseIndex(pos) {
  6562. var cffIndex = new CFFIndex();
  6563. var bytes = this.bytes;
  6564. var count = bytes[pos++] << 8 | bytes[pos++];
  6565. var offsets = [];
  6566. var end = pos;
  6567. var i, ii;
  6568. if (count !== 0) {
  6569. var offsetSize = bytes[pos++];
  6570. var startPos = pos + (count + 1) * offsetSize - 1;
  6571. for (i = 0, ii = count + 1; i < ii; ++i) {
  6572. var offset = 0;
  6573. for (var j = 0; j < offsetSize; ++j) {
  6574. offset <<= 8;
  6575. offset += bytes[pos++];
  6576. }
  6577. offsets.push(startPos + offset);
  6578. }
  6579. end = offsets[count];
  6580. }
  6581. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  6582. var offsetStart = offsets[i];
  6583. var offsetEnd = offsets[i + 1];
  6584. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  6585. }
  6586. return {
  6587. obj: cffIndex,
  6588. endPos: end
  6589. };
  6590. },
  6591. parseNameIndex: function CFFParser_parseNameIndex(index) {
  6592. var names = [];
  6593. for (var i = 0, ii = index.count; i < ii; ++i) {
  6594. var name = index.get(i);
  6595. var length = Math.min(name.length, 127);
  6596. var data = [];
  6597. for (var j = 0; j < length; ++j) {
  6598. var c = name[j];
  6599. if (j === 0 && c === 0) {
  6600. data[j] = c;
  6601. continue;
  6602. }
  6603. 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)
  6604. {
  6605. data[j] = 95;
  6606. continue;
  6607. }
  6608. data[j] = c;
  6609. }
  6610. names.push(bytesToString(data));
  6611. }
  6612. return names;
  6613. },
  6614. parseStringIndex: function CFFParser_parseStringIndex(index) {
  6615. var strings = new CFFStrings();
  6616. for (var i = 0, ii = index.count; i < ii; ++i) {
  6617. var data = index.get(i);
  6618. strings.add(bytesToString(data));
  6619. }
  6620. return strings;
  6621. },
  6622. createDict: function CFFParser_createDict(Type, dict, strings) {
  6623. var cffDict = new Type(strings);
  6624. for (var i = 0, ii = dict.length; i < ii; ++i) {
  6625. var pair = dict[i];
  6626. var key = pair[0];
  6627. var value = pair[1];
  6628. cffDict.setByKey(key, value);
  6629. }
  6630. return cffDict;
  6631. },
  6632. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  6633. if (state.callDepth > MAX_SUBR_NESTING) {
  6634. return false;
  6635. }
  6636. var stackSize = state.stackSize;
  6637. var stack = state.stack;
  6638. var length = data.length;
  6639. for (var j = 0; j < length;) {
  6640. var value = data[j++];
  6641. var validationCommand = null;
  6642. if (value === 12) {
  6643. var q = data[j++];
  6644. if (q === 0) {
  6645. data[j - 2] = 139;
  6646. data[j - 1] = 22;
  6647. stackSize = 0;
  6648. } else {
  6649. validationCommand = CharstringValidationData12[q];
  6650. }
  6651. } else if (value === 28) {
  6652. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  6653. j += 2;
  6654. stackSize++;
  6655. } else if (value === 14) {
  6656. if (stackSize >= 4) {
  6657. stackSize -= 4;
  6658. if (this.seacAnalysisEnabled) {
  6659. state.seac = stack.slice(stackSize, stackSize + 4);
  6660. return false;
  6661. }
  6662. }
  6663. validationCommand = CharstringValidationData[value];
  6664. } else if (value >= 32 && value <= 246) {
  6665. stack[stackSize] = value - 139;
  6666. stackSize++;
  6667. } else if (value >= 247 && value <= 254) {
  6668. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  6669. j++;
  6670. stackSize++;
  6671. } else if (value === 255) {
  6672. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  6673. j += 4;
  6674. stackSize++;
  6675. } else if (value === 19 || value === 20) {
  6676. state.hints += stackSize >> 1;
  6677. j += state.hints + 7 >> 3;
  6678. stackSize %= 2;
  6679. validationCommand = CharstringValidationData[value];
  6680. } else if (value === 10 || value === 29) {
  6681. var subrsIndex;
  6682. if (value === 10) {
  6683. subrsIndex = localSubrIndex;
  6684. } else {
  6685. subrsIndex = globalSubrIndex;
  6686. }
  6687. if (!subrsIndex) {
  6688. validationCommand = CharstringValidationData[value];
  6689. warn('Missing subrsIndex for ' + validationCommand.id);
  6690. return false;
  6691. }
  6692. var bias = 32768;
  6693. if (subrsIndex.count < 1240) {
  6694. bias = 107;
  6695. } else if (subrsIndex.count < 33900) {
  6696. bias = 1131;
  6697. }
  6698. var subrNumber = stack[--stackSize] + bias;
  6699. if (subrNumber < 0 || subrNumber >= subrsIndex.count) {
  6700. validationCommand = CharstringValidationData[value];
  6701. warn('Out of bounds subrIndex for ' + validationCommand.id);
  6702. return false;
  6703. }
  6704. state.stackSize = stackSize;
  6705. state.callDepth++;
  6706. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  6707. if (!valid) {
  6708. return false;
  6709. }
  6710. state.callDepth--;
  6711. stackSize = state.stackSize;
  6712. continue;
  6713. } else if (value === 11) {
  6714. state.stackSize = stackSize;
  6715. return true;
  6716. } else {
  6717. validationCommand = CharstringValidationData[value];
  6718. }
  6719. if (validationCommand) {
  6720. if (validationCommand.stem) {
  6721. state.hints += stackSize >> 1;
  6722. }
  6723. if ('min' in validationCommand) {
  6724. if (!state.undefStack && stackSize < validationCommand.min) {
  6725. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  6726. return false;
  6727. }
  6728. }
  6729. if (state.firstStackClearing && validationCommand.stackClearing) {
  6730. state.firstStackClearing = false;
  6731. stackSize -= validationCommand.min;
  6732. if (stackSize >= 2 && validationCommand.stem) {
  6733. stackSize %= 2;
  6734. } else if (stackSize > 1) {
  6735. warn('Found too many parameters for stack-clearing command');
  6736. }
  6737. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  6738. state.width = stack[stackSize - 1];
  6739. }
  6740. }
  6741. if ('stackDelta' in validationCommand) {
  6742. if ('stackFn' in validationCommand) {
  6743. validationCommand.stackFn(stack, stackSize);
  6744. }
  6745. stackSize += validationCommand.stackDelta;
  6746. } else if (validationCommand.stackClearing) {
  6747. stackSize = 0;
  6748. } else if (validationCommand.resetStack) {
  6749. stackSize = 0;
  6750. state.undefStack = false;
  6751. } else if (validationCommand.undefStack) {
  6752. stackSize = 0;
  6753. state.undefStack = true;
  6754. state.firstStackClearing = false;
  6755. }
  6756. }
  6757. }
  6758. state.stackSize = stackSize;
  6759. return true;
  6760. },
  6761. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  6762. var seacs = [];
  6763. var widths = [];
  6764. var count = charStrings.count;
  6765. for (var i = 0; i < count; i++) {
  6766. var charstring = charStrings.get(i);
  6767. var state = {
  6768. callDepth: 0,
  6769. stackSize: 0,
  6770. stack: [],
  6771. undefStack: true,
  6772. hints: 0,
  6773. firstStackClearing: true,
  6774. seac: null,
  6775. width: null
  6776. };
  6777. var valid = true;
  6778. var localSubrToUse = null;
  6779. if (fdSelect && fdArray.length) {
  6780. var fdIndex = fdSelect.getFDIndex(i);
  6781. if (fdIndex === -1) {
  6782. warn('Glyph index is not in fd select.');
  6783. valid = false;
  6784. }
  6785. if (fdIndex >= fdArray.length) {
  6786. warn('Invalid fd index for glyph index.');
  6787. valid = false;
  6788. }
  6789. if (valid) {
  6790. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  6791. }
  6792. } else if (localSubrIndex) {
  6793. localSubrToUse = localSubrIndex;
  6794. }
  6795. if (valid) {
  6796. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  6797. }
  6798. if (state.width !== null) {
  6799. widths[i] = state.width;
  6800. }
  6801. if (state.seac !== null) {
  6802. seacs[i] = state.seac;
  6803. }
  6804. if (!valid) {
  6805. charStrings.set(i, new Uint8Array([14]));
  6806. }
  6807. }
  6808. return {
  6809. charStrings: charStrings,
  6810. seacs: seacs,
  6811. widths: widths
  6812. };
  6813. },
  6814. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  6815. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  6816. parentDict.setByKey(18, [
  6817. 0,
  6818. 0
  6819. ]);
  6820. parentDict.privateDict = privateDict;
  6821. },
  6822. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  6823. if (!parentDict.hasName('Private')) {
  6824. this.emptyPrivateDictionary(parentDict);
  6825. return;
  6826. }
  6827. var privateOffset = parentDict.getByName('Private');
  6828. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  6829. parentDict.removeByName('Private');
  6830. return;
  6831. }
  6832. var size = privateOffset[0];
  6833. var offset = privateOffset[1];
  6834. if (size === 0 || offset >= this.bytes.length) {
  6835. this.emptyPrivateDictionary(parentDict);
  6836. return;
  6837. }
  6838. var privateDictEnd = offset + size;
  6839. var dictData = this.bytes.subarray(offset, privateDictEnd);
  6840. var dict = this.parseDict(dictData);
  6841. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  6842. parentDict.privateDict = privateDict;
  6843. if (!privateDict.getByName('Subrs')) {
  6844. return;
  6845. }
  6846. var subrsOffset = privateDict.getByName('Subrs');
  6847. var relativeOffset = offset + subrsOffset;
  6848. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  6849. this.emptyPrivateDictionary(parentDict);
  6850. return;
  6851. }
  6852. var subrsIndex = this.parseIndex(relativeOffset);
  6853. privateDict.subrsIndex = subrsIndex.obj;
  6854. },
  6855. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  6856. if (pos === 0) {
  6857. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  6858. } else if (pos === 1) {
  6859. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  6860. } else if (pos === 2) {
  6861. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  6862. }
  6863. var bytes = this.bytes;
  6864. var start = pos;
  6865. var format = bytes[pos++];
  6866. var charset = ['.notdef'];
  6867. var id, count, i;
  6868. length -= 1;
  6869. switch (format) {
  6870. case 0:
  6871. for (i = 0; i < length; i++) {
  6872. id = bytes[pos++] << 8 | bytes[pos++];
  6873. charset.push(cid ? id : strings.get(id));
  6874. }
  6875. break;
  6876. case 1:
  6877. while (charset.length <= length) {
  6878. id = bytes[pos++] << 8 | bytes[pos++];
  6879. count = bytes[pos++];
  6880. for (i = 0; i <= count; i++) {
  6881. charset.push(cid ? id++ : strings.get(id++));
  6882. }
  6883. }
  6884. break;
  6885. case 2:
  6886. while (charset.length <= length) {
  6887. id = bytes[pos++] << 8 | bytes[pos++];
  6888. count = bytes[pos++] << 8 | bytes[pos++];
  6889. for (i = 0; i <= count; i++) {
  6890. charset.push(cid ? id++ : strings.get(id++));
  6891. }
  6892. }
  6893. break;
  6894. default:
  6895. error('Unknown charset format');
  6896. }
  6897. var end = pos;
  6898. var raw = bytes.subarray(start, end);
  6899. return new CFFCharset(false, format, charset, raw);
  6900. },
  6901. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  6902. var encoding = Object.create(null);
  6903. var bytes = this.bytes;
  6904. var predefined = false;
  6905. var hasSupplement = false;
  6906. var format, i, ii;
  6907. var raw = null;
  6908. function readSupplement() {
  6909. var supplementsCount = bytes[pos++];
  6910. for (i = 0; i < supplementsCount; i++) {
  6911. var code = bytes[pos++];
  6912. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  6913. encoding[code] = charset.indexOf(strings.get(sid));
  6914. }
  6915. }
  6916. if (pos === 0 || pos === 1) {
  6917. predefined = true;
  6918. format = pos;
  6919. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  6920. for (i = 0, ii = charset.length; i < ii; i++) {
  6921. var index = baseEncoding.indexOf(charset[i]);
  6922. if (index !== -1) {
  6923. encoding[index] = i;
  6924. }
  6925. }
  6926. } else {
  6927. var dataStart = pos;
  6928. format = bytes[pos++];
  6929. switch (format & 0x7f) {
  6930. case 0:
  6931. var glyphsCount = bytes[pos++];
  6932. for (i = 1; i <= glyphsCount; i++) {
  6933. encoding[bytes[pos++]] = i;
  6934. }
  6935. break;
  6936. case 1:
  6937. var rangesCount = bytes[pos++];
  6938. var gid = 1;
  6939. for (i = 0; i < rangesCount; i++) {
  6940. var start = bytes[pos++];
  6941. var left = bytes[pos++];
  6942. for (var j = start; j <= start + left; j++) {
  6943. encoding[j] = gid++;
  6944. }
  6945. }
  6946. break;
  6947. default:
  6948. error('Unknown encoding format: ' + format + ' in CFF');
  6949. break;
  6950. }
  6951. var dataEnd = pos;
  6952. if (format & 0x80) {
  6953. bytes[dataStart] &= 0x7f;
  6954. readSupplement();
  6955. hasSupplement = true;
  6956. }
  6957. raw = bytes.subarray(dataStart, dataEnd);
  6958. }
  6959. format = format & 0x7f;
  6960. return new CFFEncoding(predefined, format, encoding, raw);
  6961. },
  6962. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  6963. var start = pos;
  6964. var bytes = this.bytes;
  6965. var format = bytes[pos++];
  6966. var fdSelect = [], rawBytes;
  6967. var i, invalidFirstGID = false;
  6968. switch (format) {
  6969. case 0:
  6970. for (i = 0; i < length; ++i) {
  6971. var id = bytes[pos++];
  6972. fdSelect.push(id);
  6973. }
  6974. rawBytes = bytes.subarray(start, pos);
  6975. break;
  6976. case 3:
  6977. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  6978. for (i = 0; i < rangesCount; ++i) {
  6979. var first = bytes[pos++] << 8 | bytes[pos++];
  6980. if (i === 0 && first !== 0) {
  6981. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  6982. invalidFirstGID = true;
  6983. first = 0;
  6984. }
  6985. var fdIndex = bytes[pos++];
  6986. var next = bytes[pos] << 8 | bytes[pos + 1];
  6987. for (var j = first; j < next; ++j) {
  6988. fdSelect.push(fdIndex);
  6989. }
  6990. }
  6991. pos += 2;
  6992. rawBytes = bytes.subarray(start, pos);
  6993. if (invalidFirstGID) {
  6994. rawBytes[3] = rawBytes[4] = 0;
  6995. }
  6996. break;
  6997. default:
  6998. error('parseFDSelect: Unknown format "' + format + '".');
  6999. break;
  7000. }
  7001. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  7002. return new CFFFDSelect(fdSelect, rawBytes);
  7003. }
  7004. };
  7005. return CFFParser;
  7006. }();
  7007. var CFF = function CFFClosure() {
  7008. function CFF() {
  7009. this.header = null;
  7010. this.names = [];
  7011. this.topDict = null;
  7012. this.strings = new CFFStrings();
  7013. this.globalSubrIndex = null;
  7014. this.encoding = null;
  7015. this.charset = null;
  7016. this.charStrings = null;
  7017. this.fdArray = [];
  7018. this.fdSelect = null;
  7019. this.isCIDFont = false;
  7020. }
  7021. return CFF;
  7022. }();
  7023. var CFFHeader = function CFFHeaderClosure() {
  7024. function CFFHeader(major, minor, hdrSize, offSize) {
  7025. this.major = major;
  7026. this.minor = minor;
  7027. this.hdrSize = hdrSize;
  7028. this.offSize = offSize;
  7029. }
  7030. return CFFHeader;
  7031. }();
  7032. var CFFStrings = function CFFStringsClosure() {
  7033. function CFFStrings() {
  7034. this.strings = [];
  7035. }
  7036. CFFStrings.prototype = {
  7037. get: function CFFStrings_get(index) {
  7038. if (index >= 0 && index <= 390) {
  7039. return CFFStandardStrings[index];
  7040. }
  7041. if (index - 391 <= this.strings.length) {
  7042. return this.strings[index - 391];
  7043. }
  7044. return CFFStandardStrings[0];
  7045. },
  7046. add: function CFFStrings_add(value) {
  7047. this.strings.push(value);
  7048. },
  7049. get count() {
  7050. return this.strings.length;
  7051. }
  7052. };
  7053. return CFFStrings;
  7054. }();
  7055. var CFFIndex = function CFFIndexClosure() {
  7056. function CFFIndex() {
  7057. this.objects = [];
  7058. this.length = 0;
  7059. }
  7060. CFFIndex.prototype = {
  7061. add: function CFFIndex_add(data) {
  7062. this.length += data.length;
  7063. this.objects.push(data);
  7064. },
  7065. set: function CFFIndex_set(index, data) {
  7066. this.length += data.length - this.objects[index].length;
  7067. this.objects[index] = data;
  7068. },
  7069. get: function CFFIndex_get(index) {
  7070. return this.objects[index];
  7071. },
  7072. get count() {
  7073. return this.objects.length;
  7074. }
  7075. };
  7076. return CFFIndex;
  7077. }();
  7078. var CFFDict = function CFFDictClosure() {
  7079. function CFFDict(tables, strings) {
  7080. this.keyToNameMap = tables.keyToNameMap;
  7081. this.nameToKeyMap = tables.nameToKeyMap;
  7082. this.defaults = tables.defaults;
  7083. this.types = tables.types;
  7084. this.opcodes = tables.opcodes;
  7085. this.order = tables.order;
  7086. this.strings = strings;
  7087. this.values = Object.create(null);
  7088. }
  7089. CFFDict.prototype = {
  7090. setByKey: function CFFDict_setByKey(key, value) {
  7091. if (!(key in this.keyToNameMap)) {
  7092. return false;
  7093. }
  7094. var valueLength = value.length;
  7095. if (valueLength === 0) {
  7096. return true;
  7097. }
  7098. for (var i = 0; i < valueLength; i++) {
  7099. if (isNaN(value[i])) {
  7100. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  7101. return true;
  7102. }
  7103. }
  7104. var type = this.types[key];
  7105. if (type === 'num' || type === 'sid' || type === 'offset') {
  7106. value = value[0];
  7107. }
  7108. this.values[key] = value;
  7109. return true;
  7110. },
  7111. setByName: function CFFDict_setByName(name, value) {
  7112. if (!(name in this.nameToKeyMap)) {
  7113. error('Invalid dictionary name "' + name + '"');
  7114. }
  7115. this.values[this.nameToKeyMap[name]] = value;
  7116. },
  7117. hasName: function CFFDict_hasName(name) {
  7118. return this.nameToKeyMap[name] in this.values;
  7119. },
  7120. getByName: function CFFDict_getByName(name) {
  7121. if (!(name in this.nameToKeyMap)) {
  7122. error('Invalid dictionary name "' + name + '"');
  7123. }
  7124. var key = this.nameToKeyMap[name];
  7125. if (!(key in this.values)) {
  7126. return this.defaults[key];
  7127. }
  7128. return this.values[key];
  7129. },
  7130. removeByName: function CFFDict_removeByName(name) {
  7131. delete this.values[this.nameToKeyMap[name]];
  7132. }
  7133. };
  7134. CFFDict.createTables = function CFFDict_createTables(layout) {
  7135. var tables = {
  7136. keyToNameMap: {},
  7137. nameToKeyMap: {},
  7138. defaults: {},
  7139. types: {},
  7140. opcodes: {},
  7141. order: []
  7142. };
  7143. for (var i = 0, ii = layout.length; i < ii; ++i) {
  7144. var entry = layout[i];
  7145. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  7146. tables.keyToNameMap[key] = entry[1];
  7147. tables.nameToKeyMap[entry[1]] = key;
  7148. tables.types[key] = entry[2];
  7149. tables.defaults[key] = entry[3];
  7150. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  7151. tables.order.push(key);
  7152. }
  7153. return tables;
  7154. };
  7155. return CFFDict;
  7156. }();
  7157. var CFFTopDict = function CFFTopDictClosure() {
  7158. var layout = [
  7159. [
  7160. [
  7161. 12,
  7162. 30
  7163. ],
  7164. 'ROS',
  7165. [
  7166. 'sid',
  7167. 'sid',
  7168. 'num'
  7169. ],
  7170. null
  7171. ],
  7172. [
  7173. [
  7174. 12,
  7175. 20
  7176. ],
  7177. 'SyntheticBase',
  7178. 'num',
  7179. null
  7180. ],
  7181. [
  7182. 0,
  7183. 'version',
  7184. 'sid',
  7185. null
  7186. ],
  7187. [
  7188. 1,
  7189. 'Notice',
  7190. 'sid',
  7191. null
  7192. ],
  7193. [
  7194. [
  7195. 12,
  7196. 0
  7197. ],
  7198. 'Copyright',
  7199. 'sid',
  7200. null
  7201. ],
  7202. [
  7203. 2,
  7204. 'FullName',
  7205. 'sid',
  7206. null
  7207. ],
  7208. [
  7209. 3,
  7210. 'FamilyName',
  7211. 'sid',
  7212. null
  7213. ],
  7214. [
  7215. 4,
  7216. 'Weight',
  7217. 'sid',
  7218. null
  7219. ],
  7220. [
  7221. [
  7222. 12,
  7223. 1
  7224. ],
  7225. 'isFixedPitch',
  7226. 'num',
  7227. 0
  7228. ],
  7229. [
  7230. [
  7231. 12,
  7232. 2
  7233. ],
  7234. 'ItalicAngle',
  7235. 'num',
  7236. 0
  7237. ],
  7238. [
  7239. [
  7240. 12,
  7241. 3
  7242. ],
  7243. 'UnderlinePosition',
  7244. 'num',
  7245. -100
  7246. ],
  7247. [
  7248. [
  7249. 12,
  7250. 4
  7251. ],
  7252. 'UnderlineThickness',
  7253. 'num',
  7254. 50
  7255. ],
  7256. [
  7257. [
  7258. 12,
  7259. 5
  7260. ],
  7261. 'PaintType',
  7262. 'num',
  7263. 0
  7264. ],
  7265. [
  7266. [
  7267. 12,
  7268. 6
  7269. ],
  7270. 'CharstringType',
  7271. 'num',
  7272. 2
  7273. ],
  7274. [
  7275. [
  7276. 12,
  7277. 7
  7278. ],
  7279. 'FontMatrix',
  7280. [
  7281. 'num',
  7282. 'num',
  7283. 'num',
  7284. 'num',
  7285. 'num',
  7286. 'num'
  7287. ],
  7288. [
  7289. 0.001,
  7290. 0,
  7291. 0,
  7292. 0.001,
  7293. 0,
  7294. 0
  7295. ]
  7296. ],
  7297. [
  7298. 13,
  7299. 'UniqueID',
  7300. 'num',
  7301. null
  7302. ],
  7303. [
  7304. 5,
  7305. 'FontBBox',
  7306. [
  7307. 'num',
  7308. 'num',
  7309. 'num',
  7310. 'num'
  7311. ],
  7312. [
  7313. 0,
  7314. 0,
  7315. 0,
  7316. 0
  7317. ]
  7318. ],
  7319. [
  7320. [
  7321. 12,
  7322. 8
  7323. ],
  7324. 'StrokeWidth',
  7325. 'num',
  7326. 0
  7327. ],
  7328. [
  7329. 14,
  7330. 'XUID',
  7331. 'array',
  7332. null
  7333. ],
  7334. [
  7335. 15,
  7336. 'charset',
  7337. 'offset',
  7338. 0
  7339. ],
  7340. [
  7341. 16,
  7342. 'Encoding',
  7343. 'offset',
  7344. 0
  7345. ],
  7346. [
  7347. 17,
  7348. 'CharStrings',
  7349. 'offset',
  7350. 0
  7351. ],
  7352. [
  7353. 18,
  7354. 'Private',
  7355. [
  7356. 'offset',
  7357. 'offset'
  7358. ],
  7359. null
  7360. ],
  7361. [
  7362. [
  7363. 12,
  7364. 21
  7365. ],
  7366. 'PostScript',
  7367. 'sid',
  7368. null
  7369. ],
  7370. [
  7371. [
  7372. 12,
  7373. 22
  7374. ],
  7375. 'BaseFontName',
  7376. 'sid',
  7377. null
  7378. ],
  7379. [
  7380. [
  7381. 12,
  7382. 23
  7383. ],
  7384. 'BaseFontBlend',
  7385. 'delta',
  7386. null
  7387. ],
  7388. [
  7389. [
  7390. 12,
  7391. 31
  7392. ],
  7393. 'CIDFontVersion',
  7394. 'num',
  7395. 0
  7396. ],
  7397. [
  7398. [
  7399. 12,
  7400. 32
  7401. ],
  7402. 'CIDFontRevision',
  7403. 'num',
  7404. 0
  7405. ],
  7406. [
  7407. [
  7408. 12,
  7409. 33
  7410. ],
  7411. 'CIDFontType',
  7412. 'num',
  7413. 0
  7414. ],
  7415. [
  7416. [
  7417. 12,
  7418. 34
  7419. ],
  7420. 'CIDCount',
  7421. 'num',
  7422. 8720
  7423. ],
  7424. [
  7425. [
  7426. 12,
  7427. 35
  7428. ],
  7429. 'UIDBase',
  7430. 'num',
  7431. null
  7432. ],
  7433. [
  7434. [
  7435. 12,
  7436. 37
  7437. ],
  7438. 'FDSelect',
  7439. 'offset',
  7440. null
  7441. ],
  7442. [
  7443. [
  7444. 12,
  7445. 36
  7446. ],
  7447. 'FDArray',
  7448. 'offset',
  7449. null
  7450. ],
  7451. [
  7452. [
  7453. 12,
  7454. 38
  7455. ],
  7456. 'FontName',
  7457. 'sid',
  7458. null
  7459. ]
  7460. ];
  7461. var tables = null;
  7462. function CFFTopDict(strings) {
  7463. if (tables === null) {
  7464. tables = CFFDict.createTables(layout);
  7465. }
  7466. CFFDict.call(this, tables, strings);
  7467. this.privateDict = null;
  7468. }
  7469. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  7470. return CFFTopDict;
  7471. }();
  7472. var CFFPrivateDict = function CFFPrivateDictClosure() {
  7473. var layout = [
  7474. [
  7475. 6,
  7476. 'BlueValues',
  7477. 'delta',
  7478. null
  7479. ],
  7480. [
  7481. 7,
  7482. 'OtherBlues',
  7483. 'delta',
  7484. null
  7485. ],
  7486. [
  7487. 8,
  7488. 'FamilyBlues',
  7489. 'delta',
  7490. null
  7491. ],
  7492. [
  7493. 9,
  7494. 'FamilyOtherBlues',
  7495. 'delta',
  7496. null
  7497. ],
  7498. [
  7499. [
  7500. 12,
  7501. 9
  7502. ],
  7503. 'BlueScale',
  7504. 'num',
  7505. 0.039625
  7506. ],
  7507. [
  7508. [
  7509. 12,
  7510. 10
  7511. ],
  7512. 'BlueShift',
  7513. 'num',
  7514. 7
  7515. ],
  7516. [
  7517. [
  7518. 12,
  7519. 11
  7520. ],
  7521. 'BlueFuzz',
  7522. 'num',
  7523. 1
  7524. ],
  7525. [
  7526. 10,
  7527. 'StdHW',
  7528. 'num',
  7529. null
  7530. ],
  7531. [
  7532. 11,
  7533. 'StdVW',
  7534. 'num',
  7535. null
  7536. ],
  7537. [
  7538. [
  7539. 12,
  7540. 12
  7541. ],
  7542. 'StemSnapH',
  7543. 'delta',
  7544. null
  7545. ],
  7546. [
  7547. [
  7548. 12,
  7549. 13
  7550. ],
  7551. 'StemSnapV',
  7552. 'delta',
  7553. null
  7554. ],
  7555. [
  7556. [
  7557. 12,
  7558. 14
  7559. ],
  7560. 'ForceBold',
  7561. 'num',
  7562. 0
  7563. ],
  7564. [
  7565. [
  7566. 12,
  7567. 17
  7568. ],
  7569. 'LanguageGroup',
  7570. 'num',
  7571. 0
  7572. ],
  7573. [
  7574. [
  7575. 12,
  7576. 18
  7577. ],
  7578. 'ExpansionFactor',
  7579. 'num',
  7580. 0.06
  7581. ],
  7582. [
  7583. [
  7584. 12,
  7585. 19
  7586. ],
  7587. 'initialRandomSeed',
  7588. 'num',
  7589. 0
  7590. ],
  7591. [
  7592. 20,
  7593. 'defaultWidthX',
  7594. 'num',
  7595. 0
  7596. ],
  7597. [
  7598. 21,
  7599. 'nominalWidthX',
  7600. 'num',
  7601. 0
  7602. ],
  7603. [
  7604. 19,
  7605. 'Subrs',
  7606. 'offset',
  7607. null
  7608. ]
  7609. ];
  7610. var tables = null;
  7611. function CFFPrivateDict(strings) {
  7612. if (tables === null) {
  7613. tables = CFFDict.createTables(layout);
  7614. }
  7615. CFFDict.call(this, tables, strings);
  7616. this.subrsIndex = null;
  7617. }
  7618. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  7619. return CFFPrivateDict;
  7620. }();
  7621. var CFFCharsetPredefinedTypes = {
  7622. ISO_ADOBE: 0,
  7623. EXPERT: 1,
  7624. EXPERT_SUBSET: 2
  7625. };
  7626. var CFFCharset = function CFFCharsetClosure() {
  7627. function CFFCharset(predefined, format, charset, raw) {
  7628. this.predefined = predefined;
  7629. this.format = format;
  7630. this.charset = charset;
  7631. this.raw = raw;
  7632. }
  7633. return CFFCharset;
  7634. }();
  7635. var CFFEncoding = function CFFEncodingClosure() {
  7636. function CFFEncoding(predefined, format, encoding, raw) {
  7637. this.predefined = predefined;
  7638. this.format = format;
  7639. this.encoding = encoding;
  7640. this.raw = raw;
  7641. }
  7642. return CFFEncoding;
  7643. }();
  7644. var CFFFDSelect = function CFFFDSelectClosure() {
  7645. function CFFFDSelect(fdSelect, raw) {
  7646. this.fdSelect = fdSelect;
  7647. this.raw = raw;
  7648. }
  7649. CFFFDSelect.prototype = {
  7650. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  7651. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  7652. return -1;
  7653. }
  7654. return this.fdSelect[glyphIndex];
  7655. }
  7656. };
  7657. return CFFFDSelect;
  7658. }();
  7659. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  7660. function CFFOffsetTracker() {
  7661. this.offsets = Object.create(null);
  7662. }
  7663. CFFOffsetTracker.prototype = {
  7664. isTracking: function CFFOffsetTracker_isTracking(key) {
  7665. return key in this.offsets;
  7666. },
  7667. track: function CFFOffsetTracker_track(key, location) {
  7668. if (key in this.offsets) {
  7669. error('Already tracking location of ' + key);
  7670. }
  7671. this.offsets[key] = location;
  7672. },
  7673. offset: function CFFOffsetTracker_offset(value) {
  7674. for (var key in this.offsets) {
  7675. this.offsets[key] += value;
  7676. }
  7677. },
  7678. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  7679. if (!(key in this.offsets)) {
  7680. error('Not tracking location of ' + key);
  7681. }
  7682. var data = output.data;
  7683. var dataOffset = this.offsets[key];
  7684. var size = 5;
  7685. for (var i = 0, ii = values.length; i < ii; ++i) {
  7686. var offset0 = i * size + dataOffset;
  7687. var offset1 = offset0 + 1;
  7688. var offset2 = offset0 + 2;
  7689. var offset3 = offset0 + 3;
  7690. var offset4 = offset0 + 4;
  7691. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  7692. error('writing to an offset that is not empty');
  7693. }
  7694. var value = values[i];
  7695. data[offset0] = 0x1d;
  7696. data[offset1] = value >> 24 & 0xFF;
  7697. data[offset2] = value >> 16 & 0xFF;
  7698. data[offset3] = value >> 8 & 0xFF;
  7699. data[offset4] = value & 0xFF;
  7700. }
  7701. }
  7702. };
  7703. return CFFOffsetTracker;
  7704. }();
  7705. var CFFCompiler = function CFFCompilerClosure() {
  7706. function CFFCompiler(cff) {
  7707. this.cff = cff;
  7708. }
  7709. CFFCompiler.prototype = {
  7710. compile: function CFFCompiler_compile() {
  7711. var cff = this.cff;
  7712. var output = {
  7713. data: [],
  7714. length: 0,
  7715. add: function CFFCompiler_add(data) {
  7716. this.data = this.data.concat(data);
  7717. this.length = this.data.length;
  7718. }
  7719. };
  7720. var header = this.compileHeader(cff.header);
  7721. output.add(header);
  7722. var nameIndex = this.compileNameIndex(cff.names);
  7723. output.add(nameIndex);
  7724. if (cff.isCIDFont) {
  7725. if (cff.topDict.hasName('FontMatrix')) {
  7726. var base = cff.topDict.getByName('FontMatrix');
  7727. cff.topDict.removeByName('FontMatrix');
  7728. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  7729. var subDict = cff.fdArray[i];
  7730. var matrix = base.slice(0);
  7731. if (subDict.hasName('FontMatrix')) {
  7732. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  7733. }
  7734. subDict.setByName('FontMatrix', matrix);
  7735. }
  7736. }
  7737. }
  7738. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  7739. output.add(compiled.output);
  7740. var topDictTracker = compiled.trackers[0];
  7741. var stringIndex = this.compileStringIndex(cff.strings.strings);
  7742. output.add(stringIndex);
  7743. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  7744. output.add(globalSubrIndex);
  7745. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  7746. if (cff.encoding.predefined) {
  7747. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  7748. } else {
  7749. var encoding = this.compileEncoding(cff.encoding);
  7750. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  7751. output.add(encoding);
  7752. }
  7753. }
  7754. if (cff.charset && cff.topDict.hasName('charset')) {
  7755. if (cff.charset.predefined) {
  7756. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  7757. } else {
  7758. var charset = this.compileCharset(cff.charset);
  7759. topDictTracker.setEntryLocation('charset', [output.length], output);
  7760. output.add(charset);
  7761. }
  7762. }
  7763. var charStrings = this.compileCharStrings(cff.charStrings);
  7764. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  7765. output.add(charStrings);
  7766. if (cff.isCIDFont) {
  7767. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  7768. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  7769. output.add(fdSelect);
  7770. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  7771. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  7772. output.add(compiled.output);
  7773. var fontDictTrackers = compiled.trackers;
  7774. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  7775. }
  7776. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  7777. output.add([0]);
  7778. return output.data;
  7779. },
  7780. encodeNumber: function CFFCompiler_encodeNumber(value) {
  7781. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  7782. return this.encodeInteger(value);
  7783. } else {
  7784. return this.encodeFloat(value);
  7785. }
  7786. },
  7787. encodeFloat: function CFFCompiler_encodeFloat(num) {
  7788. var value = num.toString();
  7789. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  7790. if (m) {
  7791. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  7792. value = (Math.round(num * epsilon) / epsilon).toString();
  7793. }
  7794. var nibbles = '';
  7795. var i, ii;
  7796. for (i = 0, ii = value.length; i < ii; ++i) {
  7797. var a = value[i];
  7798. if (a === 'e') {
  7799. nibbles += value[++i] === '-' ? 'c' : 'b';
  7800. } else if (a === '.') {
  7801. nibbles += 'a';
  7802. } else if (a === '-') {
  7803. nibbles += 'e';
  7804. } else {
  7805. nibbles += a;
  7806. }
  7807. }
  7808. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  7809. var out = [30];
  7810. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  7811. out.push(parseInt(nibbles.substr(i, 2), 16));
  7812. }
  7813. return out;
  7814. },
  7815. encodeInteger: function CFFCompiler_encodeInteger(value) {
  7816. var code;
  7817. if (value >= -107 && value <= 107) {
  7818. code = [value + 139];
  7819. } else if (value >= 108 && value <= 1131) {
  7820. value = value - 108;
  7821. code = [
  7822. (value >> 8) + 247,
  7823. value & 0xFF
  7824. ];
  7825. } else if (value >= -1131 && value <= -108) {
  7826. value = -value - 108;
  7827. code = [
  7828. (value >> 8) + 251,
  7829. value & 0xFF
  7830. ];
  7831. } else if (value >= -32768 && value <= 32767) {
  7832. code = [
  7833. 0x1c,
  7834. value >> 8 & 0xFF,
  7835. value & 0xFF
  7836. ];
  7837. } else {
  7838. code = [
  7839. 0x1d,
  7840. value >> 24 & 0xFF,
  7841. value >> 16 & 0xFF,
  7842. value >> 8 & 0xFF,
  7843. value & 0xFF
  7844. ];
  7845. }
  7846. return code;
  7847. },
  7848. compileHeader: function CFFCompiler_compileHeader(header) {
  7849. return [
  7850. header.major,
  7851. header.minor,
  7852. header.hdrSize,
  7853. header.offSize
  7854. ];
  7855. },
  7856. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  7857. var nameIndex = new CFFIndex();
  7858. for (var i = 0, ii = names.length; i < ii; ++i) {
  7859. nameIndex.add(stringToBytes(names[i]));
  7860. }
  7861. return this.compileIndex(nameIndex);
  7862. },
  7863. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  7864. var fontDictTrackers = [];
  7865. var fdArrayIndex = new CFFIndex();
  7866. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  7867. var fontDict = dicts[i];
  7868. if (removeCidKeys) {
  7869. fontDict.removeByName('CIDFontVersion');
  7870. fontDict.removeByName('CIDFontRevision');
  7871. fontDict.removeByName('CIDFontType');
  7872. fontDict.removeByName('CIDCount');
  7873. fontDict.removeByName('UIDBase');
  7874. }
  7875. var fontDictTracker = new CFFOffsetTracker();
  7876. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  7877. fontDictTrackers.push(fontDictTracker);
  7878. fdArrayIndex.add(fontDictData);
  7879. fontDictTracker.offset(length);
  7880. }
  7881. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  7882. return {
  7883. trackers: fontDictTrackers,
  7884. output: fdArrayIndex
  7885. };
  7886. },
  7887. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  7888. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  7889. var fontDict = dicts[i];
  7890. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  7891. var privateDict = fontDict.privateDict;
  7892. var privateDictTracker = new CFFOffsetTracker();
  7893. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  7894. var outputLength = output.length;
  7895. privateDictTracker.offset(outputLength);
  7896. if (!privateDictData.length) {
  7897. outputLength = 0;
  7898. }
  7899. trackers[i].setEntryLocation('Private', [
  7900. privateDictData.length,
  7901. outputLength
  7902. ], output);
  7903. output.add(privateDictData);
  7904. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  7905. var subrs = this.compileIndex(privateDict.subrsIndex);
  7906. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  7907. output.add(subrs);
  7908. }
  7909. }
  7910. },
  7911. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  7912. var out = [];
  7913. var order = dict.order;
  7914. for (var i = 0; i < order.length; ++i) {
  7915. var key = order[i];
  7916. if (!(key in dict.values)) {
  7917. continue;
  7918. }
  7919. var values = dict.values[key];
  7920. var types = dict.types[key];
  7921. if (!isArray(types)) {
  7922. types = [types];
  7923. }
  7924. if (!isArray(values)) {
  7925. values = [values];
  7926. }
  7927. if (values.length === 0) {
  7928. continue;
  7929. }
  7930. for (var j = 0, jj = types.length; j < jj; ++j) {
  7931. var type = types[j];
  7932. var value = values[j];
  7933. switch (type) {
  7934. case 'num':
  7935. case 'sid':
  7936. out = out.concat(this.encodeNumber(value));
  7937. break;
  7938. case 'offset':
  7939. var name = dict.keyToNameMap[key];
  7940. if (!offsetTracker.isTracking(name)) {
  7941. offsetTracker.track(name, out.length);
  7942. }
  7943. out = out.concat([
  7944. 0x1d,
  7945. 0,
  7946. 0,
  7947. 0,
  7948. 0
  7949. ]);
  7950. break;
  7951. case 'array':
  7952. case 'delta':
  7953. out = out.concat(this.encodeNumber(value));
  7954. for (var k = 1, kk = values.length; k < kk; ++k) {
  7955. out = out.concat(this.encodeNumber(values[k]));
  7956. }
  7957. break;
  7958. default:
  7959. error('Unknown data type of ' + type);
  7960. break;
  7961. }
  7962. }
  7963. out = out.concat(dict.opcodes[key]);
  7964. }
  7965. return out;
  7966. },
  7967. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  7968. var stringIndex = new CFFIndex();
  7969. for (var i = 0, ii = strings.length; i < ii; ++i) {
  7970. stringIndex.add(stringToBytes(strings[i]));
  7971. }
  7972. return this.compileIndex(stringIndex);
  7973. },
  7974. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  7975. var globalSubrIndex = this.cff.globalSubrIndex;
  7976. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  7977. },
  7978. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  7979. return this.compileIndex(charStrings);
  7980. },
  7981. compileCharset: function CFFCompiler_compileCharset(charset) {
  7982. return this.compileTypedArray(charset.raw);
  7983. },
  7984. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  7985. return this.compileTypedArray(encoding.raw);
  7986. },
  7987. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  7988. return this.compileTypedArray(fdSelect);
  7989. },
  7990. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  7991. var out = [];
  7992. for (var i = 0, ii = data.length; i < ii; ++i) {
  7993. out[i] = data[i];
  7994. }
  7995. return out;
  7996. },
  7997. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  7998. trackers = trackers || [];
  7999. var objects = index.objects;
  8000. var count = objects.length;
  8001. if (count === 0) {
  8002. return [
  8003. 0,
  8004. 0,
  8005. 0
  8006. ];
  8007. }
  8008. var data = [
  8009. count >> 8 & 0xFF,
  8010. count & 0xff
  8011. ];
  8012. var lastOffset = 1, i;
  8013. for (i = 0; i < count; ++i) {
  8014. lastOffset += objects[i].length;
  8015. }
  8016. var offsetSize;
  8017. if (lastOffset < 0x100) {
  8018. offsetSize = 1;
  8019. } else if (lastOffset < 0x10000) {
  8020. offsetSize = 2;
  8021. } else if (lastOffset < 0x1000000) {
  8022. offsetSize = 3;
  8023. } else {
  8024. offsetSize = 4;
  8025. }
  8026. data.push(offsetSize);
  8027. var relativeOffset = 1;
  8028. for (i = 0; i < count + 1; i++) {
  8029. if (offsetSize === 1) {
  8030. data.push(relativeOffset & 0xFF);
  8031. } else if (offsetSize === 2) {
  8032. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8033. } else if (offsetSize === 3) {
  8034. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8035. } else {
  8036. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8037. }
  8038. if (objects[i]) {
  8039. relativeOffset += objects[i].length;
  8040. }
  8041. }
  8042. for (i = 0; i < count; i++) {
  8043. if (trackers[i]) {
  8044. trackers[i].offset(data.length);
  8045. }
  8046. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  8047. data.push(objects[i][j]);
  8048. }
  8049. }
  8050. return data;
  8051. }
  8052. };
  8053. return CFFCompiler;
  8054. }();
  8055. exports.CFFStandardStrings = CFFStandardStrings;
  8056. exports.CFFParser = CFFParser;
  8057. exports.CFF = CFF;
  8058. exports.CFFHeader = CFFHeader;
  8059. exports.CFFStrings = CFFStrings;
  8060. exports.CFFIndex = CFFIndex;
  8061. exports.CFFCharset = CFFCharset;
  8062. exports.CFFTopDict = CFFTopDict;
  8063. exports.CFFPrivateDict = CFFPrivateDict;
  8064. exports.CFFCompiler = CFFCompiler;
  8065. }));
  8066. (function (root, factory) {
  8067. factory(root.pdfjsCoreChunkedStream = {}, root.pdfjsSharedUtil);
  8068. }(this, function (exports, sharedUtil) {
  8069. var MissingDataException = sharedUtil.MissingDataException;
  8070. var arrayByteLength = sharedUtil.arrayByteLength;
  8071. var arraysToBytes = sharedUtil.arraysToBytes;
  8072. var assert = sharedUtil.assert;
  8073. var createPromiseCapability = sharedUtil.createPromiseCapability;
  8074. var isInt = sharedUtil.isInt;
  8075. var isEmptyObj = sharedUtil.isEmptyObj;
  8076. var ChunkedStream = function ChunkedStreamClosure() {
  8077. function ChunkedStream(length, chunkSize, manager) {
  8078. this.bytes = new Uint8Array(length);
  8079. this.start = 0;
  8080. this.pos = 0;
  8081. this.end = length;
  8082. this.chunkSize = chunkSize;
  8083. this.loadedChunks = [];
  8084. this.numChunksLoaded = 0;
  8085. this.numChunks = Math.ceil(length / chunkSize);
  8086. this.manager = manager;
  8087. this.progressiveDataLength = 0;
  8088. this.lastSuccessfulEnsureByteChunk = -1;
  8089. }
  8090. ChunkedStream.prototype = {
  8091. getMissingChunks: function ChunkedStream_getMissingChunks() {
  8092. var chunks = [];
  8093. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  8094. if (!this.loadedChunks[chunk]) {
  8095. chunks.push(chunk);
  8096. }
  8097. }
  8098. return chunks;
  8099. },
  8100. getBaseStreams: function ChunkedStream_getBaseStreams() {
  8101. return [this];
  8102. },
  8103. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  8104. return this.numChunksLoaded === this.numChunks;
  8105. },
  8106. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  8107. var end = begin + chunk.byteLength;
  8108. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  8109. var length = this.bytes.length;
  8110. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  8111. this.bytes.set(new Uint8Array(chunk), begin);
  8112. var chunkSize = this.chunkSize;
  8113. var beginChunk = Math.floor(begin / chunkSize);
  8114. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  8115. var curChunk;
  8116. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  8117. if (!this.loadedChunks[curChunk]) {
  8118. this.loadedChunks[curChunk] = true;
  8119. ++this.numChunksLoaded;
  8120. }
  8121. }
  8122. },
  8123. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  8124. var position = this.progressiveDataLength;
  8125. var beginChunk = Math.floor(position / this.chunkSize);
  8126. this.bytes.set(new Uint8Array(data), position);
  8127. position += data.byteLength;
  8128. this.progressiveDataLength = position;
  8129. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  8130. var curChunk;
  8131. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  8132. if (!this.loadedChunks[curChunk]) {
  8133. this.loadedChunks[curChunk] = true;
  8134. ++this.numChunksLoaded;
  8135. }
  8136. }
  8137. },
  8138. ensureByte: function ChunkedStream_ensureByte(pos) {
  8139. var chunk = Math.floor(pos / this.chunkSize);
  8140. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  8141. return;
  8142. }
  8143. if (!this.loadedChunks[chunk]) {
  8144. throw new MissingDataException(pos, pos + 1);
  8145. }
  8146. this.lastSuccessfulEnsureByteChunk = chunk;
  8147. },
  8148. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  8149. if (begin >= end) {
  8150. return;
  8151. }
  8152. if (end <= this.progressiveDataLength) {
  8153. return;
  8154. }
  8155. var chunkSize = this.chunkSize;
  8156. var beginChunk = Math.floor(begin / chunkSize);
  8157. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  8158. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8159. if (!this.loadedChunks[chunk]) {
  8160. throw new MissingDataException(begin, end);
  8161. }
  8162. }
  8163. },
  8164. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  8165. var chunk, numChunks = this.numChunks;
  8166. for (var i = 0; i < numChunks; ++i) {
  8167. chunk = (beginChunk + i) % numChunks;
  8168. if (!this.loadedChunks[chunk]) {
  8169. return chunk;
  8170. }
  8171. }
  8172. return null;
  8173. },
  8174. hasChunk: function ChunkedStream_hasChunk(chunk) {
  8175. return !!this.loadedChunks[chunk];
  8176. },
  8177. get length() {
  8178. return this.end - this.start;
  8179. },
  8180. get isEmpty() {
  8181. return this.length === 0;
  8182. },
  8183. getByte: function ChunkedStream_getByte() {
  8184. var pos = this.pos;
  8185. if (pos >= this.end) {
  8186. return -1;
  8187. }
  8188. this.ensureByte(pos);
  8189. return this.bytes[this.pos++];
  8190. },
  8191. getUint16: function ChunkedStream_getUint16() {
  8192. var b0 = this.getByte();
  8193. var b1 = this.getByte();
  8194. if (b0 === -1 || b1 === -1) {
  8195. return -1;
  8196. }
  8197. return (b0 << 8) + b1;
  8198. },
  8199. getInt32: function ChunkedStream_getInt32() {
  8200. var b0 = this.getByte();
  8201. var b1 = this.getByte();
  8202. var b2 = this.getByte();
  8203. var b3 = this.getByte();
  8204. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  8205. },
  8206. getBytes: function ChunkedStream_getBytes(length) {
  8207. var bytes = this.bytes;
  8208. var pos = this.pos;
  8209. var strEnd = this.end;
  8210. if (!length) {
  8211. this.ensureRange(pos, strEnd);
  8212. return bytes.subarray(pos, strEnd);
  8213. }
  8214. var end = pos + length;
  8215. if (end > strEnd) {
  8216. end = strEnd;
  8217. }
  8218. this.ensureRange(pos, end);
  8219. this.pos = end;
  8220. return bytes.subarray(pos, end);
  8221. },
  8222. peekByte: function ChunkedStream_peekByte() {
  8223. var peekedByte = this.getByte();
  8224. this.pos--;
  8225. return peekedByte;
  8226. },
  8227. peekBytes: function ChunkedStream_peekBytes(length) {
  8228. var bytes = this.getBytes(length);
  8229. this.pos -= bytes.length;
  8230. return bytes;
  8231. },
  8232. getByteRange: function ChunkedStream_getBytes(begin, end) {
  8233. this.ensureRange(begin, end);
  8234. return this.bytes.subarray(begin, end);
  8235. },
  8236. skip: function ChunkedStream_skip(n) {
  8237. if (!n) {
  8238. n = 1;
  8239. }
  8240. this.pos += n;
  8241. },
  8242. reset: function ChunkedStream_reset() {
  8243. this.pos = this.start;
  8244. },
  8245. moveStart: function ChunkedStream_moveStart() {
  8246. this.start = this.pos;
  8247. },
  8248. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  8249. this.ensureRange(start, start + length);
  8250. function ChunkedStreamSubstream() {
  8251. }
  8252. ChunkedStreamSubstream.prototype = Object.create(this);
  8253. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  8254. var chunkSize = this.chunkSize;
  8255. var beginChunk = Math.floor(this.start / chunkSize);
  8256. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  8257. var missingChunks = [];
  8258. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8259. if (!this.loadedChunks[chunk]) {
  8260. missingChunks.push(chunk);
  8261. }
  8262. }
  8263. return missingChunks;
  8264. };
  8265. var subStream = new ChunkedStreamSubstream();
  8266. subStream.pos = subStream.start = start;
  8267. subStream.end = start + length || this.end;
  8268. subStream.dict = dict;
  8269. return subStream;
  8270. },
  8271. isStream: true
  8272. };
  8273. return ChunkedStream;
  8274. }();
  8275. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  8276. function ChunkedStreamManager(pdfNetworkStream, args) {
  8277. var chunkSize = args.rangeChunkSize;
  8278. var length = args.length;
  8279. this.stream = new ChunkedStream(length, chunkSize, this);
  8280. this.length = length;
  8281. this.chunkSize = chunkSize;
  8282. this.pdfNetworkStream = pdfNetworkStream;
  8283. this.url = args.url;
  8284. this.disableAutoFetch = args.disableAutoFetch;
  8285. this.msgHandler = args.msgHandler;
  8286. this.currRequestId = 0;
  8287. this.chunksNeededByRequest = Object.create(null);
  8288. this.requestsByChunk = Object.create(null);
  8289. this.promisesByRequest = Object.create(null);
  8290. this.progressiveDataLength = 0;
  8291. this.aborted = false;
  8292. this._loadedStreamCapability = createPromiseCapability();
  8293. }
  8294. ChunkedStreamManager.prototype = {
  8295. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  8296. return this._loadedStreamCapability.promise;
  8297. },
  8298. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  8299. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  8300. if (!rangeReader.isStreamingSupported) {
  8301. rangeReader.onProgress = this.onProgress.bind(this);
  8302. }
  8303. var chunks = [], loaded = 0;
  8304. var manager = this;
  8305. var promise = new Promise(function (resolve, reject) {
  8306. var readChunk = function (chunk) {
  8307. try {
  8308. if (!chunk.done) {
  8309. var data = chunk.value;
  8310. chunks.push(data);
  8311. loaded += arrayByteLength(data);
  8312. if (rangeReader.isStreamingSupported) {
  8313. manager.onProgress({ loaded: loaded });
  8314. }
  8315. rangeReader.read().then(readChunk, reject);
  8316. return;
  8317. }
  8318. var chunkData = arraysToBytes(chunks);
  8319. chunks = null;
  8320. resolve(chunkData);
  8321. } catch (e) {
  8322. reject(e);
  8323. }
  8324. };
  8325. rangeReader.read().then(readChunk, reject);
  8326. });
  8327. promise.then(function (data) {
  8328. if (this.aborted) {
  8329. return;
  8330. }
  8331. this.onReceiveData({
  8332. chunk: data,
  8333. begin: begin
  8334. });
  8335. }.bind(this));
  8336. },
  8337. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  8338. var missingChunks = this.stream.getMissingChunks();
  8339. this._requestChunks(missingChunks);
  8340. return this._loadedStreamCapability.promise;
  8341. },
  8342. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  8343. var requestId = this.currRequestId++;
  8344. var i, ii;
  8345. var chunksNeeded = Object.create(null);
  8346. this.chunksNeededByRequest[requestId] = chunksNeeded;
  8347. for (i = 0, ii = chunks.length; i < ii; i++) {
  8348. if (!this.stream.hasChunk(chunks[i])) {
  8349. chunksNeeded[chunks[i]] = true;
  8350. }
  8351. }
  8352. if (isEmptyObj(chunksNeeded)) {
  8353. return Promise.resolve();
  8354. }
  8355. var capability = createPromiseCapability();
  8356. this.promisesByRequest[requestId] = capability;
  8357. var chunksToRequest = [];
  8358. for (var chunk in chunksNeeded) {
  8359. chunk = chunk | 0;
  8360. if (!(chunk in this.requestsByChunk)) {
  8361. this.requestsByChunk[chunk] = [];
  8362. chunksToRequest.push(chunk);
  8363. }
  8364. this.requestsByChunk[chunk].push(requestId);
  8365. }
  8366. if (!chunksToRequest.length) {
  8367. return capability.promise;
  8368. }
  8369. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  8370. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  8371. var groupedChunk = groupedChunksToRequest[i];
  8372. var begin = groupedChunk.beginChunk * this.chunkSize;
  8373. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  8374. this.sendRequest(begin, end);
  8375. }
  8376. return capability.promise;
  8377. },
  8378. getStream: function ChunkedStreamManager_getStream() {
  8379. return this.stream;
  8380. },
  8381. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  8382. end = Math.min(end, this.length);
  8383. var beginChunk = this.getBeginChunk(begin);
  8384. var endChunk = this.getEndChunk(end);
  8385. var chunks = [];
  8386. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8387. chunks.push(chunk);
  8388. }
  8389. return this._requestChunks(chunks);
  8390. },
  8391. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  8392. ranges = ranges || [];
  8393. var chunksToRequest = [];
  8394. for (var i = 0; i < ranges.length; i++) {
  8395. var beginChunk = this.getBeginChunk(ranges[i].begin);
  8396. var endChunk = this.getEndChunk(ranges[i].end);
  8397. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8398. if (chunksToRequest.indexOf(chunk) < 0) {
  8399. chunksToRequest.push(chunk);
  8400. }
  8401. }
  8402. }
  8403. chunksToRequest.sort(function (a, b) {
  8404. return a - b;
  8405. });
  8406. return this._requestChunks(chunksToRequest);
  8407. },
  8408. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  8409. var groupedChunks = [];
  8410. var beginChunk = -1;
  8411. var prevChunk = -1;
  8412. for (var i = 0; i < chunks.length; ++i) {
  8413. var chunk = chunks[i];
  8414. if (beginChunk < 0) {
  8415. beginChunk = chunk;
  8416. }
  8417. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  8418. groupedChunks.push({
  8419. beginChunk: beginChunk,
  8420. endChunk: prevChunk + 1
  8421. });
  8422. beginChunk = chunk;
  8423. }
  8424. if (i + 1 === chunks.length) {
  8425. groupedChunks.push({
  8426. beginChunk: beginChunk,
  8427. endChunk: chunk + 1
  8428. });
  8429. }
  8430. prevChunk = chunk;
  8431. }
  8432. return groupedChunks;
  8433. },
  8434. onProgress: function ChunkedStreamManager_onProgress(args) {
  8435. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  8436. this.msgHandler.send('DocProgress', {
  8437. loaded: bytesLoaded,
  8438. total: this.length
  8439. });
  8440. },
  8441. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  8442. var chunk = args.chunk;
  8443. var isProgressive = args.begin === undefined;
  8444. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  8445. var end = begin + chunk.byteLength;
  8446. var beginChunk = Math.floor(begin / this.chunkSize);
  8447. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  8448. if (isProgressive) {
  8449. this.stream.onReceiveProgressiveData(chunk);
  8450. this.progressiveDataLength = end;
  8451. } else {
  8452. this.stream.onReceiveData(begin, chunk);
  8453. }
  8454. if (this.stream.allChunksLoaded()) {
  8455. this._loadedStreamCapability.resolve(this.stream);
  8456. }
  8457. var loadedRequests = [];
  8458. var i, requestId;
  8459. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  8460. var requestIds = this.requestsByChunk[chunk] || [];
  8461. delete this.requestsByChunk[chunk];
  8462. for (i = 0; i < requestIds.length; ++i) {
  8463. requestId = requestIds[i];
  8464. var chunksNeeded = this.chunksNeededByRequest[requestId];
  8465. if (chunk in chunksNeeded) {
  8466. delete chunksNeeded[chunk];
  8467. }
  8468. if (!isEmptyObj(chunksNeeded)) {
  8469. continue;
  8470. }
  8471. loadedRequests.push(requestId);
  8472. }
  8473. }
  8474. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  8475. var nextEmptyChunk;
  8476. if (this.stream.numChunksLoaded === 1) {
  8477. var lastChunk = this.stream.numChunks - 1;
  8478. if (!this.stream.hasChunk(lastChunk)) {
  8479. nextEmptyChunk = lastChunk;
  8480. }
  8481. } else {
  8482. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  8483. }
  8484. if (isInt(nextEmptyChunk)) {
  8485. this._requestChunks([nextEmptyChunk]);
  8486. }
  8487. }
  8488. for (i = 0; i < loadedRequests.length; ++i) {
  8489. requestId = loadedRequests[i];
  8490. var capability = this.promisesByRequest[requestId];
  8491. delete this.promisesByRequest[requestId];
  8492. capability.resolve();
  8493. }
  8494. this.msgHandler.send('DocProgress', {
  8495. loaded: this.stream.numChunksLoaded * this.chunkSize,
  8496. total: this.length
  8497. });
  8498. },
  8499. onError: function ChunkedStreamManager_onError(err) {
  8500. this._loadedStreamCapability.reject(err);
  8501. },
  8502. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  8503. var chunk = Math.floor(begin / this.chunkSize);
  8504. return chunk;
  8505. },
  8506. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  8507. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  8508. return chunk;
  8509. },
  8510. abort: function ChunkedStreamManager_abort() {
  8511. this.aborted = true;
  8512. if (this.pdfNetworkStream) {
  8513. this.pdfNetworkStream.cancelAllRequests('abort');
  8514. }
  8515. for (var requestId in this.promisesByRequest) {
  8516. var capability = this.promisesByRequest[requestId];
  8517. capability.reject(new Error('Request was aborted'));
  8518. }
  8519. }
  8520. };
  8521. return ChunkedStreamManager;
  8522. }();
  8523. exports.ChunkedStream = ChunkedStream;
  8524. exports.ChunkedStreamManager = ChunkedStreamManager;
  8525. }));
  8526. (function (root, factory) {
  8527. factory(root.pdfjsCoreGlyphList = {}, root.pdfjsSharedUtil);
  8528. }(this, function (exports, sharedUtil) {
  8529. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  8530. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  8531. t['A'] = 0x0041;
  8532. t['AE'] = 0x00C6;
  8533. t['AEacute'] = 0x01FC;
  8534. t['AEmacron'] = 0x01E2;
  8535. t['AEsmall'] = 0xF7E6;
  8536. t['Aacute'] = 0x00C1;
  8537. t['Aacutesmall'] = 0xF7E1;
  8538. t['Abreve'] = 0x0102;
  8539. t['Abreveacute'] = 0x1EAE;
  8540. t['Abrevecyrillic'] = 0x04D0;
  8541. t['Abrevedotbelow'] = 0x1EB6;
  8542. t['Abrevegrave'] = 0x1EB0;
  8543. t['Abrevehookabove'] = 0x1EB2;
  8544. t['Abrevetilde'] = 0x1EB4;
  8545. t['Acaron'] = 0x01CD;
  8546. t['Acircle'] = 0x24B6;
  8547. t['Acircumflex'] = 0x00C2;
  8548. t['Acircumflexacute'] = 0x1EA4;
  8549. t['Acircumflexdotbelow'] = 0x1EAC;
  8550. t['Acircumflexgrave'] = 0x1EA6;
  8551. t['Acircumflexhookabove'] = 0x1EA8;
  8552. t['Acircumflexsmall'] = 0xF7E2;
  8553. t['Acircumflextilde'] = 0x1EAA;
  8554. t['Acute'] = 0xF6C9;
  8555. t['Acutesmall'] = 0xF7B4;
  8556. t['Acyrillic'] = 0x0410;
  8557. t['Adblgrave'] = 0x0200;
  8558. t['Adieresis'] = 0x00C4;
  8559. t['Adieresiscyrillic'] = 0x04D2;
  8560. t['Adieresismacron'] = 0x01DE;
  8561. t['Adieresissmall'] = 0xF7E4;
  8562. t['Adotbelow'] = 0x1EA0;
  8563. t['Adotmacron'] = 0x01E0;
  8564. t['Agrave'] = 0x00C0;
  8565. t['Agravesmall'] = 0xF7E0;
  8566. t['Ahookabove'] = 0x1EA2;
  8567. t['Aiecyrillic'] = 0x04D4;
  8568. t['Ainvertedbreve'] = 0x0202;
  8569. t['Alpha'] = 0x0391;
  8570. t['Alphatonos'] = 0x0386;
  8571. t['Amacron'] = 0x0100;
  8572. t['Amonospace'] = 0xFF21;
  8573. t['Aogonek'] = 0x0104;
  8574. t['Aring'] = 0x00C5;
  8575. t['Aringacute'] = 0x01FA;
  8576. t['Aringbelow'] = 0x1E00;
  8577. t['Aringsmall'] = 0xF7E5;
  8578. t['Asmall'] = 0xF761;
  8579. t['Atilde'] = 0x00C3;
  8580. t['Atildesmall'] = 0xF7E3;
  8581. t['Aybarmenian'] = 0x0531;
  8582. t['B'] = 0x0042;
  8583. t['Bcircle'] = 0x24B7;
  8584. t['Bdotaccent'] = 0x1E02;
  8585. t['Bdotbelow'] = 0x1E04;
  8586. t['Becyrillic'] = 0x0411;
  8587. t['Benarmenian'] = 0x0532;
  8588. t['Beta'] = 0x0392;
  8589. t['Bhook'] = 0x0181;
  8590. t['Blinebelow'] = 0x1E06;
  8591. t['Bmonospace'] = 0xFF22;
  8592. t['Brevesmall'] = 0xF6F4;
  8593. t['Bsmall'] = 0xF762;
  8594. t['Btopbar'] = 0x0182;
  8595. t['C'] = 0x0043;
  8596. t['Caarmenian'] = 0x053E;
  8597. t['Cacute'] = 0x0106;
  8598. t['Caron'] = 0xF6CA;
  8599. t['Caronsmall'] = 0xF6F5;
  8600. t['Ccaron'] = 0x010C;
  8601. t['Ccedilla'] = 0x00C7;
  8602. t['Ccedillaacute'] = 0x1E08;
  8603. t['Ccedillasmall'] = 0xF7E7;
  8604. t['Ccircle'] = 0x24B8;
  8605. t['Ccircumflex'] = 0x0108;
  8606. t['Cdot'] = 0x010A;
  8607. t['Cdotaccent'] = 0x010A;
  8608. t['Cedillasmall'] = 0xF7B8;
  8609. t['Chaarmenian'] = 0x0549;
  8610. t['Cheabkhasiancyrillic'] = 0x04BC;
  8611. t['Checyrillic'] = 0x0427;
  8612. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  8613. t['Chedescendercyrillic'] = 0x04B6;
  8614. t['Chedieresiscyrillic'] = 0x04F4;
  8615. t['Cheharmenian'] = 0x0543;
  8616. t['Chekhakassiancyrillic'] = 0x04CB;
  8617. t['Cheverticalstrokecyrillic'] = 0x04B8;
  8618. t['Chi'] = 0x03A7;
  8619. t['Chook'] = 0x0187;
  8620. t['Circumflexsmall'] = 0xF6F6;
  8621. t['Cmonospace'] = 0xFF23;
  8622. t['Coarmenian'] = 0x0551;
  8623. t['Csmall'] = 0xF763;
  8624. t['D'] = 0x0044;
  8625. t['DZ'] = 0x01F1;
  8626. t['DZcaron'] = 0x01C4;
  8627. t['Daarmenian'] = 0x0534;
  8628. t['Dafrican'] = 0x0189;
  8629. t['Dcaron'] = 0x010E;
  8630. t['Dcedilla'] = 0x1E10;
  8631. t['Dcircle'] = 0x24B9;
  8632. t['Dcircumflexbelow'] = 0x1E12;
  8633. t['Dcroat'] = 0x0110;
  8634. t['Ddotaccent'] = 0x1E0A;
  8635. t['Ddotbelow'] = 0x1E0C;
  8636. t['Decyrillic'] = 0x0414;
  8637. t['Deicoptic'] = 0x03EE;
  8638. t['Delta'] = 0x2206;
  8639. t['Deltagreek'] = 0x0394;
  8640. t['Dhook'] = 0x018A;
  8641. t['Dieresis'] = 0xF6CB;
  8642. t['DieresisAcute'] = 0xF6CC;
  8643. t['DieresisGrave'] = 0xF6CD;
  8644. t['Dieresissmall'] = 0xF7A8;
  8645. t['Digammagreek'] = 0x03DC;
  8646. t['Djecyrillic'] = 0x0402;
  8647. t['Dlinebelow'] = 0x1E0E;
  8648. t['Dmonospace'] = 0xFF24;
  8649. t['Dotaccentsmall'] = 0xF6F7;
  8650. t['Dslash'] = 0x0110;
  8651. t['Dsmall'] = 0xF764;
  8652. t['Dtopbar'] = 0x018B;
  8653. t['Dz'] = 0x01F2;
  8654. t['Dzcaron'] = 0x01C5;
  8655. t['Dzeabkhasiancyrillic'] = 0x04E0;
  8656. t['Dzecyrillic'] = 0x0405;
  8657. t['Dzhecyrillic'] = 0x040F;
  8658. t['E'] = 0x0045;
  8659. t['Eacute'] = 0x00C9;
  8660. t['Eacutesmall'] = 0xF7E9;
  8661. t['Ebreve'] = 0x0114;
  8662. t['Ecaron'] = 0x011A;
  8663. t['Ecedillabreve'] = 0x1E1C;
  8664. t['Echarmenian'] = 0x0535;
  8665. t['Ecircle'] = 0x24BA;
  8666. t['Ecircumflex'] = 0x00CA;
  8667. t['Ecircumflexacute'] = 0x1EBE;
  8668. t['Ecircumflexbelow'] = 0x1E18;
  8669. t['Ecircumflexdotbelow'] = 0x1EC6;
  8670. t['Ecircumflexgrave'] = 0x1EC0;
  8671. t['Ecircumflexhookabove'] = 0x1EC2;
  8672. t['Ecircumflexsmall'] = 0xF7EA;
  8673. t['Ecircumflextilde'] = 0x1EC4;
  8674. t['Ecyrillic'] = 0x0404;
  8675. t['Edblgrave'] = 0x0204;
  8676. t['Edieresis'] = 0x00CB;
  8677. t['Edieresissmall'] = 0xF7EB;
  8678. t['Edot'] = 0x0116;
  8679. t['Edotaccent'] = 0x0116;
  8680. t['Edotbelow'] = 0x1EB8;
  8681. t['Efcyrillic'] = 0x0424;
  8682. t['Egrave'] = 0x00C8;
  8683. t['Egravesmall'] = 0xF7E8;
  8684. t['Eharmenian'] = 0x0537;
  8685. t['Ehookabove'] = 0x1EBA;
  8686. t['Eightroman'] = 0x2167;
  8687. t['Einvertedbreve'] = 0x0206;
  8688. t['Eiotifiedcyrillic'] = 0x0464;
  8689. t['Elcyrillic'] = 0x041B;
  8690. t['Elevenroman'] = 0x216A;
  8691. t['Emacron'] = 0x0112;
  8692. t['Emacronacute'] = 0x1E16;
  8693. t['Emacrongrave'] = 0x1E14;
  8694. t['Emcyrillic'] = 0x041C;
  8695. t['Emonospace'] = 0xFF25;
  8696. t['Encyrillic'] = 0x041D;
  8697. t['Endescendercyrillic'] = 0x04A2;
  8698. t['Eng'] = 0x014A;
  8699. t['Enghecyrillic'] = 0x04A4;
  8700. t['Enhookcyrillic'] = 0x04C7;
  8701. t['Eogonek'] = 0x0118;
  8702. t['Eopen'] = 0x0190;
  8703. t['Epsilon'] = 0x0395;
  8704. t['Epsilontonos'] = 0x0388;
  8705. t['Ercyrillic'] = 0x0420;
  8706. t['Ereversed'] = 0x018E;
  8707. t['Ereversedcyrillic'] = 0x042D;
  8708. t['Escyrillic'] = 0x0421;
  8709. t['Esdescendercyrillic'] = 0x04AA;
  8710. t['Esh'] = 0x01A9;
  8711. t['Esmall'] = 0xF765;
  8712. t['Eta'] = 0x0397;
  8713. t['Etarmenian'] = 0x0538;
  8714. t['Etatonos'] = 0x0389;
  8715. t['Eth'] = 0x00D0;
  8716. t['Ethsmall'] = 0xF7F0;
  8717. t['Etilde'] = 0x1EBC;
  8718. t['Etildebelow'] = 0x1E1A;
  8719. t['Euro'] = 0x20AC;
  8720. t['Ezh'] = 0x01B7;
  8721. t['Ezhcaron'] = 0x01EE;
  8722. t['Ezhreversed'] = 0x01B8;
  8723. t['F'] = 0x0046;
  8724. t['Fcircle'] = 0x24BB;
  8725. t['Fdotaccent'] = 0x1E1E;
  8726. t['Feharmenian'] = 0x0556;
  8727. t['Feicoptic'] = 0x03E4;
  8728. t['Fhook'] = 0x0191;
  8729. t['Fitacyrillic'] = 0x0472;
  8730. t['Fiveroman'] = 0x2164;
  8731. t['Fmonospace'] = 0xFF26;
  8732. t['Fourroman'] = 0x2163;
  8733. t['Fsmall'] = 0xF766;
  8734. t['G'] = 0x0047;
  8735. t['GBsquare'] = 0x3387;
  8736. t['Gacute'] = 0x01F4;
  8737. t['Gamma'] = 0x0393;
  8738. t['Gammaafrican'] = 0x0194;
  8739. t['Gangiacoptic'] = 0x03EA;
  8740. t['Gbreve'] = 0x011E;
  8741. t['Gcaron'] = 0x01E6;
  8742. t['Gcedilla'] = 0x0122;
  8743. t['Gcircle'] = 0x24BC;
  8744. t['Gcircumflex'] = 0x011C;
  8745. t['Gcommaaccent'] = 0x0122;
  8746. t['Gdot'] = 0x0120;
  8747. t['Gdotaccent'] = 0x0120;
  8748. t['Gecyrillic'] = 0x0413;
  8749. t['Ghadarmenian'] = 0x0542;
  8750. t['Ghemiddlehookcyrillic'] = 0x0494;
  8751. t['Ghestrokecyrillic'] = 0x0492;
  8752. t['Gheupturncyrillic'] = 0x0490;
  8753. t['Ghook'] = 0x0193;
  8754. t['Gimarmenian'] = 0x0533;
  8755. t['Gjecyrillic'] = 0x0403;
  8756. t['Gmacron'] = 0x1E20;
  8757. t['Gmonospace'] = 0xFF27;
  8758. t['Grave'] = 0xF6CE;
  8759. t['Gravesmall'] = 0xF760;
  8760. t['Gsmall'] = 0xF767;
  8761. t['Gsmallhook'] = 0x029B;
  8762. t['Gstroke'] = 0x01E4;
  8763. t['H'] = 0x0048;
  8764. t['H18533'] = 0x25CF;
  8765. t['H18543'] = 0x25AA;
  8766. t['H18551'] = 0x25AB;
  8767. t['H22073'] = 0x25A1;
  8768. t['HPsquare'] = 0x33CB;
  8769. t['Haabkhasiancyrillic'] = 0x04A8;
  8770. t['Hadescendercyrillic'] = 0x04B2;
  8771. t['Hardsigncyrillic'] = 0x042A;
  8772. t['Hbar'] = 0x0126;
  8773. t['Hbrevebelow'] = 0x1E2A;
  8774. t['Hcedilla'] = 0x1E28;
  8775. t['Hcircle'] = 0x24BD;
  8776. t['Hcircumflex'] = 0x0124;
  8777. t['Hdieresis'] = 0x1E26;
  8778. t['Hdotaccent'] = 0x1E22;
  8779. t['Hdotbelow'] = 0x1E24;
  8780. t['Hmonospace'] = 0xFF28;
  8781. t['Hoarmenian'] = 0x0540;
  8782. t['Horicoptic'] = 0x03E8;
  8783. t['Hsmall'] = 0xF768;
  8784. t['Hungarumlaut'] = 0xF6CF;
  8785. t['Hungarumlautsmall'] = 0xF6F8;
  8786. t['Hzsquare'] = 0x3390;
  8787. t['I'] = 0x0049;
  8788. t['IAcyrillic'] = 0x042F;
  8789. t['IJ'] = 0x0132;
  8790. t['IUcyrillic'] = 0x042E;
  8791. t['Iacute'] = 0x00CD;
  8792. t['Iacutesmall'] = 0xF7ED;
  8793. t['Ibreve'] = 0x012C;
  8794. t['Icaron'] = 0x01CF;
  8795. t['Icircle'] = 0x24BE;
  8796. t['Icircumflex'] = 0x00CE;
  8797. t['Icircumflexsmall'] = 0xF7EE;
  8798. t['Icyrillic'] = 0x0406;
  8799. t['Idblgrave'] = 0x0208;
  8800. t['Idieresis'] = 0x00CF;
  8801. t['Idieresisacute'] = 0x1E2E;
  8802. t['Idieresiscyrillic'] = 0x04E4;
  8803. t['Idieresissmall'] = 0xF7EF;
  8804. t['Idot'] = 0x0130;
  8805. t['Idotaccent'] = 0x0130;
  8806. t['Idotbelow'] = 0x1ECA;
  8807. t['Iebrevecyrillic'] = 0x04D6;
  8808. t['Iecyrillic'] = 0x0415;
  8809. t['Ifraktur'] = 0x2111;
  8810. t['Igrave'] = 0x00CC;
  8811. t['Igravesmall'] = 0xF7EC;
  8812. t['Ihookabove'] = 0x1EC8;
  8813. t['Iicyrillic'] = 0x0418;
  8814. t['Iinvertedbreve'] = 0x020A;
  8815. t['Iishortcyrillic'] = 0x0419;
  8816. t['Imacron'] = 0x012A;
  8817. t['Imacroncyrillic'] = 0x04E2;
  8818. t['Imonospace'] = 0xFF29;
  8819. t['Iniarmenian'] = 0x053B;
  8820. t['Iocyrillic'] = 0x0401;
  8821. t['Iogonek'] = 0x012E;
  8822. t['Iota'] = 0x0399;
  8823. t['Iotaafrican'] = 0x0196;
  8824. t['Iotadieresis'] = 0x03AA;
  8825. t['Iotatonos'] = 0x038A;
  8826. t['Ismall'] = 0xF769;
  8827. t['Istroke'] = 0x0197;
  8828. t['Itilde'] = 0x0128;
  8829. t['Itildebelow'] = 0x1E2C;
  8830. t['Izhitsacyrillic'] = 0x0474;
  8831. t['Izhitsadblgravecyrillic'] = 0x0476;
  8832. t['J'] = 0x004A;
  8833. t['Jaarmenian'] = 0x0541;
  8834. t['Jcircle'] = 0x24BF;
  8835. t['Jcircumflex'] = 0x0134;
  8836. t['Jecyrillic'] = 0x0408;
  8837. t['Jheharmenian'] = 0x054B;
  8838. t['Jmonospace'] = 0xFF2A;
  8839. t['Jsmall'] = 0xF76A;
  8840. t['K'] = 0x004B;
  8841. t['KBsquare'] = 0x3385;
  8842. t['KKsquare'] = 0x33CD;
  8843. t['Kabashkircyrillic'] = 0x04A0;
  8844. t['Kacute'] = 0x1E30;
  8845. t['Kacyrillic'] = 0x041A;
  8846. t['Kadescendercyrillic'] = 0x049A;
  8847. t['Kahookcyrillic'] = 0x04C3;
  8848. t['Kappa'] = 0x039A;
  8849. t['Kastrokecyrillic'] = 0x049E;
  8850. t['Kaverticalstrokecyrillic'] = 0x049C;
  8851. t['Kcaron'] = 0x01E8;
  8852. t['Kcedilla'] = 0x0136;
  8853. t['Kcircle'] = 0x24C0;
  8854. t['Kcommaaccent'] = 0x0136;
  8855. t['Kdotbelow'] = 0x1E32;
  8856. t['Keharmenian'] = 0x0554;
  8857. t['Kenarmenian'] = 0x053F;
  8858. t['Khacyrillic'] = 0x0425;
  8859. t['Kheicoptic'] = 0x03E6;
  8860. t['Khook'] = 0x0198;
  8861. t['Kjecyrillic'] = 0x040C;
  8862. t['Klinebelow'] = 0x1E34;
  8863. t['Kmonospace'] = 0xFF2B;
  8864. t['Koppacyrillic'] = 0x0480;
  8865. t['Koppagreek'] = 0x03DE;
  8866. t['Ksicyrillic'] = 0x046E;
  8867. t['Ksmall'] = 0xF76B;
  8868. t['L'] = 0x004C;
  8869. t['LJ'] = 0x01C7;
  8870. t['LL'] = 0xF6BF;
  8871. t['Lacute'] = 0x0139;
  8872. t['Lambda'] = 0x039B;
  8873. t['Lcaron'] = 0x013D;
  8874. t['Lcedilla'] = 0x013B;
  8875. t['Lcircle'] = 0x24C1;
  8876. t['Lcircumflexbelow'] = 0x1E3C;
  8877. t['Lcommaaccent'] = 0x013B;
  8878. t['Ldot'] = 0x013F;
  8879. t['Ldotaccent'] = 0x013F;
  8880. t['Ldotbelow'] = 0x1E36;
  8881. t['Ldotbelowmacron'] = 0x1E38;
  8882. t['Liwnarmenian'] = 0x053C;
  8883. t['Lj'] = 0x01C8;
  8884. t['Ljecyrillic'] = 0x0409;
  8885. t['Llinebelow'] = 0x1E3A;
  8886. t['Lmonospace'] = 0xFF2C;
  8887. t['Lslash'] = 0x0141;
  8888. t['Lslashsmall'] = 0xF6F9;
  8889. t['Lsmall'] = 0xF76C;
  8890. t['M'] = 0x004D;
  8891. t['MBsquare'] = 0x3386;
  8892. t['Macron'] = 0xF6D0;
  8893. t['Macronsmall'] = 0xF7AF;
  8894. t['Macute'] = 0x1E3E;
  8895. t['Mcircle'] = 0x24C2;
  8896. t['Mdotaccent'] = 0x1E40;
  8897. t['Mdotbelow'] = 0x1E42;
  8898. t['Menarmenian'] = 0x0544;
  8899. t['Mmonospace'] = 0xFF2D;
  8900. t['Msmall'] = 0xF76D;
  8901. t['Mturned'] = 0x019C;
  8902. t['Mu'] = 0x039C;
  8903. t['N'] = 0x004E;
  8904. t['NJ'] = 0x01CA;
  8905. t['Nacute'] = 0x0143;
  8906. t['Ncaron'] = 0x0147;
  8907. t['Ncedilla'] = 0x0145;
  8908. t['Ncircle'] = 0x24C3;
  8909. t['Ncircumflexbelow'] = 0x1E4A;
  8910. t['Ncommaaccent'] = 0x0145;
  8911. t['Ndotaccent'] = 0x1E44;
  8912. t['Ndotbelow'] = 0x1E46;
  8913. t['Nhookleft'] = 0x019D;
  8914. t['Nineroman'] = 0x2168;
  8915. t['Nj'] = 0x01CB;
  8916. t['Njecyrillic'] = 0x040A;
  8917. t['Nlinebelow'] = 0x1E48;
  8918. t['Nmonospace'] = 0xFF2E;
  8919. t['Nowarmenian'] = 0x0546;
  8920. t['Nsmall'] = 0xF76E;
  8921. t['Ntilde'] = 0x00D1;
  8922. t['Ntildesmall'] = 0xF7F1;
  8923. t['Nu'] = 0x039D;
  8924. t['O'] = 0x004F;
  8925. t['OE'] = 0x0152;
  8926. t['OEsmall'] = 0xF6FA;
  8927. t['Oacute'] = 0x00D3;
  8928. t['Oacutesmall'] = 0xF7F3;
  8929. t['Obarredcyrillic'] = 0x04E8;
  8930. t['Obarreddieresiscyrillic'] = 0x04EA;
  8931. t['Obreve'] = 0x014E;
  8932. t['Ocaron'] = 0x01D1;
  8933. t['Ocenteredtilde'] = 0x019F;
  8934. t['Ocircle'] = 0x24C4;
  8935. t['Ocircumflex'] = 0x00D4;
  8936. t['Ocircumflexacute'] = 0x1ED0;
  8937. t['Ocircumflexdotbelow'] = 0x1ED8;
  8938. t['Ocircumflexgrave'] = 0x1ED2;
  8939. t['Ocircumflexhookabove'] = 0x1ED4;
  8940. t['Ocircumflexsmall'] = 0xF7F4;
  8941. t['Ocircumflextilde'] = 0x1ED6;
  8942. t['Ocyrillic'] = 0x041E;
  8943. t['Odblacute'] = 0x0150;
  8944. t['Odblgrave'] = 0x020C;
  8945. t['Odieresis'] = 0x00D6;
  8946. t['Odieresiscyrillic'] = 0x04E6;
  8947. t['Odieresissmall'] = 0xF7F6;
  8948. t['Odotbelow'] = 0x1ECC;
  8949. t['Ogoneksmall'] = 0xF6FB;
  8950. t['Ograve'] = 0x00D2;
  8951. t['Ogravesmall'] = 0xF7F2;
  8952. t['Oharmenian'] = 0x0555;
  8953. t['Ohm'] = 0x2126;
  8954. t['Ohookabove'] = 0x1ECE;
  8955. t['Ohorn'] = 0x01A0;
  8956. t['Ohornacute'] = 0x1EDA;
  8957. t['Ohorndotbelow'] = 0x1EE2;
  8958. t['Ohorngrave'] = 0x1EDC;
  8959. t['Ohornhookabove'] = 0x1EDE;
  8960. t['Ohorntilde'] = 0x1EE0;
  8961. t['Ohungarumlaut'] = 0x0150;
  8962. t['Oi'] = 0x01A2;
  8963. t['Oinvertedbreve'] = 0x020E;
  8964. t['Omacron'] = 0x014C;
  8965. t['Omacronacute'] = 0x1E52;
  8966. t['Omacrongrave'] = 0x1E50;
  8967. t['Omega'] = 0x2126;
  8968. t['Omegacyrillic'] = 0x0460;
  8969. t['Omegagreek'] = 0x03A9;
  8970. t['Omegaroundcyrillic'] = 0x047A;
  8971. t['Omegatitlocyrillic'] = 0x047C;
  8972. t['Omegatonos'] = 0x038F;
  8973. t['Omicron'] = 0x039F;
  8974. t['Omicrontonos'] = 0x038C;
  8975. t['Omonospace'] = 0xFF2F;
  8976. t['Oneroman'] = 0x2160;
  8977. t['Oogonek'] = 0x01EA;
  8978. t['Oogonekmacron'] = 0x01EC;
  8979. t['Oopen'] = 0x0186;
  8980. t['Oslash'] = 0x00D8;
  8981. t['Oslashacute'] = 0x01FE;
  8982. t['Oslashsmall'] = 0xF7F8;
  8983. t['Osmall'] = 0xF76F;
  8984. t['Ostrokeacute'] = 0x01FE;
  8985. t['Otcyrillic'] = 0x047E;
  8986. t['Otilde'] = 0x00D5;
  8987. t['Otildeacute'] = 0x1E4C;
  8988. t['Otildedieresis'] = 0x1E4E;
  8989. t['Otildesmall'] = 0xF7F5;
  8990. t['P'] = 0x0050;
  8991. t['Pacute'] = 0x1E54;
  8992. t['Pcircle'] = 0x24C5;
  8993. t['Pdotaccent'] = 0x1E56;
  8994. t['Pecyrillic'] = 0x041F;
  8995. t['Peharmenian'] = 0x054A;
  8996. t['Pemiddlehookcyrillic'] = 0x04A6;
  8997. t['Phi'] = 0x03A6;
  8998. t['Phook'] = 0x01A4;
  8999. t['Pi'] = 0x03A0;
  9000. t['Piwrarmenian'] = 0x0553;
  9001. t['Pmonospace'] = 0xFF30;
  9002. t['Psi'] = 0x03A8;
  9003. t['Psicyrillic'] = 0x0470;
  9004. t['Psmall'] = 0xF770;
  9005. t['Q'] = 0x0051;
  9006. t['Qcircle'] = 0x24C6;
  9007. t['Qmonospace'] = 0xFF31;
  9008. t['Qsmall'] = 0xF771;
  9009. t['R'] = 0x0052;
  9010. t['Raarmenian'] = 0x054C;
  9011. t['Racute'] = 0x0154;
  9012. t['Rcaron'] = 0x0158;
  9013. t['Rcedilla'] = 0x0156;
  9014. t['Rcircle'] = 0x24C7;
  9015. t['Rcommaaccent'] = 0x0156;
  9016. t['Rdblgrave'] = 0x0210;
  9017. t['Rdotaccent'] = 0x1E58;
  9018. t['Rdotbelow'] = 0x1E5A;
  9019. t['Rdotbelowmacron'] = 0x1E5C;
  9020. t['Reharmenian'] = 0x0550;
  9021. t['Rfraktur'] = 0x211C;
  9022. t['Rho'] = 0x03A1;
  9023. t['Ringsmall'] = 0xF6FC;
  9024. t['Rinvertedbreve'] = 0x0212;
  9025. t['Rlinebelow'] = 0x1E5E;
  9026. t['Rmonospace'] = 0xFF32;
  9027. t['Rsmall'] = 0xF772;
  9028. t['Rsmallinverted'] = 0x0281;
  9029. t['Rsmallinvertedsuperior'] = 0x02B6;
  9030. t['S'] = 0x0053;
  9031. t['SF010000'] = 0x250C;
  9032. t['SF020000'] = 0x2514;
  9033. t['SF030000'] = 0x2510;
  9034. t['SF040000'] = 0x2518;
  9035. t['SF050000'] = 0x253C;
  9036. t['SF060000'] = 0x252C;
  9037. t['SF070000'] = 0x2534;
  9038. t['SF080000'] = 0x251C;
  9039. t['SF090000'] = 0x2524;
  9040. t['SF100000'] = 0x2500;
  9041. t['SF110000'] = 0x2502;
  9042. t['SF190000'] = 0x2561;
  9043. t['SF200000'] = 0x2562;
  9044. t['SF210000'] = 0x2556;
  9045. t['SF220000'] = 0x2555;
  9046. t['SF230000'] = 0x2563;
  9047. t['SF240000'] = 0x2551;
  9048. t['SF250000'] = 0x2557;
  9049. t['SF260000'] = 0x255D;
  9050. t['SF270000'] = 0x255C;
  9051. t['SF280000'] = 0x255B;
  9052. t['SF360000'] = 0x255E;
  9053. t['SF370000'] = 0x255F;
  9054. t['SF380000'] = 0x255A;
  9055. t['SF390000'] = 0x2554;
  9056. t['SF400000'] = 0x2569;
  9057. t['SF410000'] = 0x2566;
  9058. t['SF420000'] = 0x2560;
  9059. t['SF430000'] = 0x2550;
  9060. t['SF440000'] = 0x256C;
  9061. t['SF450000'] = 0x2567;
  9062. t['SF460000'] = 0x2568;
  9063. t['SF470000'] = 0x2564;
  9064. t['SF480000'] = 0x2565;
  9065. t['SF490000'] = 0x2559;
  9066. t['SF500000'] = 0x2558;
  9067. t['SF510000'] = 0x2552;
  9068. t['SF520000'] = 0x2553;
  9069. t['SF530000'] = 0x256B;
  9070. t['SF540000'] = 0x256A;
  9071. t['Sacute'] = 0x015A;
  9072. t['Sacutedotaccent'] = 0x1E64;
  9073. t['Sampigreek'] = 0x03E0;
  9074. t['Scaron'] = 0x0160;
  9075. t['Scarondotaccent'] = 0x1E66;
  9076. t['Scaronsmall'] = 0xF6FD;
  9077. t['Scedilla'] = 0x015E;
  9078. t['Schwa'] = 0x018F;
  9079. t['Schwacyrillic'] = 0x04D8;
  9080. t['Schwadieresiscyrillic'] = 0x04DA;
  9081. t['Scircle'] = 0x24C8;
  9082. t['Scircumflex'] = 0x015C;
  9083. t['Scommaaccent'] = 0x0218;
  9084. t['Sdotaccent'] = 0x1E60;
  9085. t['Sdotbelow'] = 0x1E62;
  9086. t['Sdotbelowdotaccent'] = 0x1E68;
  9087. t['Seharmenian'] = 0x054D;
  9088. t['Sevenroman'] = 0x2166;
  9089. t['Shaarmenian'] = 0x0547;
  9090. t['Shacyrillic'] = 0x0428;
  9091. t['Shchacyrillic'] = 0x0429;
  9092. t['Sheicoptic'] = 0x03E2;
  9093. t['Shhacyrillic'] = 0x04BA;
  9094. t['Shimacoptic'] = 0x03EC;
  9095. t['Sigma'] = 0x03A3;
  9096. t['Sixroman'] = 0x2165;
  9097. t['Smonospace'] = 0xFF33;
  9098. t['Softsigncyrillic'] = 0x042C;
  9099. t['Ssmall'] = 0xF773;
  9100. t['Stigmagreek'] = 0x03DA;
  9101. t['T'] = 0x0054;
  9102. t['Tau'] = 0x03A4;
  9103. t['Tbar'] = 0x0166;
  9104. t['Tcaron'] = 0x0164;
  9105. t['Tcedilla'] = 0x0162;
  9106. t['Tcircle'] = 0x24C9;
  9107. t['Tcircumflexbelow'] = 0x1E70;
  9108. t['Tcommaaccent'] = 0x0162;
  9109. t['Tdotaccent'] = 0x1E6A;
  9110. t['Tdotbelow'] = 0x1E6C;
  9111. t['Tecyrillic'] = 0x0422;
  9112. t['Tedescendercyrillic'] = 0x04AC;
  9113. t['Tenroman'] = 0x2169;
  9114. t['Tetsecyrillic'] = 0x04B4;
  9115. t['Theta'] = 0x0398;
  9116. t['Thook'] = 0x01AC;
  9117. t['Thorn'] = 0x00DE;
  9118. t['Thornsmall'] = 0xF7FE;
  9119. t['Threeroman'] = 0x2162;
  9120. t['Tildesmall'] = 0xF6FE;
  9121. t['Tiwnarmenian'] = 0x054F;
  9122. t['Tlinebelow'] = 0x1E6E;
  9123. t['Tmonospace'] = 0xFF34;
  9124. t['Toarmenian'] = 0x0539;
  9125. t['Tonefive'] = 0x01BC;
  9126. t['Tonesix'] = 0x0184;
  9127. t['Tonetwo'] = 0x01A7;
  9128. t['Tretroflexhook'] = 0x01AE;
  9129. t['Tsecyrillic'] = 0x0426;
  9130. t['Tshecyrillic'] = 0x040B;
  9131. t['Tsmall'] = 0xF774;
  9132. t['Twelveroman'] = 0x216B;
  9133. t['Tworoman'] = 0x2161;
  9134. t['U'] = 0x0055;
  9135. t['Uacute'] = 0x00DA;
  9136. t['Uacutesmall'] = 0xF7FA;
  9137. t['Ubreve'] = 0x016C;
  9138. t['Ucaron'] = 0x01D3;
  9139. t['Ucircle'] = 0x24CA;
  9140. t['Ucircumflex'] = 0x00DB;
  9141. t['Ucircumflexbelow'] = 0x1E76;
  9142. t['Ucircumflexsmall'] = 0xF7FB;
  9143. t['Ucyrillic'] = 0x0423;
  9144. t['Udblacute'] = 0x0170;
  9145. t['Udblgrave'] = 0x0214;
  9146. t['Udieresis'] = 0x00DC;
  9147. t['Udieresisacute'] = 0x01D7;
  9148. t['Udieresisbelow'] = 0x1E72;
  9149. t['Udieresiscaron'] = 0x01D9;
  9150. t['Udieresiscyrillic'] = 0x04F0;
  9151. t['Udieresisgrave'] = 0x01DB;
  9152. t['Udieresismacron'] = 0x01D5;
  9153. t['Udieresissmall'] = 0xF7FC;
  9154. t['Udotbelow'] = 0x1EE4;
  9155. t['Ugrave'] = 0x00D9;
  9156. t['Ugravesmall'] = 0xF7F9;
  9157. t['Uhookabove'] = 0x1EE6;
  9158. t['Uhorn'] = 0x01AF;
  9159. t['Uhornacute'] = 0x1EE8;
  9160. t['Uhorndotbelow'] = 0x1EF0;
  9161. t['Uhorngrave'] = 0x1EEA;
  9162. t['Uhornhookabove'] = 0x1EEC;
  9163. t['Uhorntilde'] = 0x1EEE;
  9164. t['Uhungarumlaut'] = 0x0170;
  9165. t['Uhungarumlautcyrillic'] = 0x04F2;
  9166. t['Uinvertedbreve'] = 0x0216;
  9167. t['Ukcyrillic'] = 0x0478;
  9168. t['Umacron'] = 0x016A;
  9169. t['Umacroncyrillic'] = 0x04EE;
  9170. t['Umacrondieresis'] = 0x1E7A;
  9171. t['Umonospace'] = 0xFF35;
  9172. t['Uogonek'] = 0x0172;
  9173. t['Upsilon'] = 0x03A5;
  9174. t['Upsilon1'] = 0x03D2;
  9175. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  9176. t['Upsilonafrican'] = 0x01B1;
  9177. t['Upsilondieresis'] = 0x03AB;
  9178. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  9179. t['Upsilonhooksymbol'] = 0x03D2;
  9180. t['Upsilontonos'] = 0x038E;
  9181. t['Uring'] = 0x016E;
  9182. t['Ushortcyrillic'] = 0x040E;
  9183. t['Usmall'] = 0xF775;
  9184. t['Ustraightcyrillic'] = 0x04AE;
  9185. t['Ustraightstrokecyrillic'] = 0x04B0;
  9186. t['Utilde'] = 0x0168;
  9187. t['Utildeacute'] = 0x1E78;
  9188. t['Utildebelow'] = 0x1E74;
  9189. t['V'] = 0x0056;
  9190. t['Vcircle'] = 0x24CB;
  9191. t['Vdotbelow'] = 0x1E7E;
  9192. t['Vecyrillic'] = 0x0412;
  9193. t['Vewarmenian'] = 0x054E;
  9194. t['Vhook'] = 0x01B2;
  9195. t['Vmonospace'] = 0xFF36;
  9196. t['Voarmenian'] = 0x0548;
  9197. t['Vsmall'] = 0xF776;
  9198. t['Vtilde'] = 0x1E7C;
  9199. t['W'] = 0x0057;
  9200. t['Wacute'] = 0x1E82;
  9201. t['Wcircle'] = 0x24CC;
  9202. t['Wcircumflex'] = 0x0174;
  9203. t['Wdieresis'] = 0x1E84;
  9204. t['Wdotaccent'] = 0x1E86;
  9205. t['Wdotbelow'] = 0x1E88;
  9206. t['Wgrave'] = 0x1E80;
  9207. t['Wmonospace'] = 0xFF37;
  9208. t['Wsmall'] = 0xF777;
  9209. t['X'] = 0x0058;
  9210. t['Xcircle'] = 0x24CD;
  9211. t['Xdieresis'] = 0x1E8C;
  9212. t['Xdotaccent'] = 0x1E8A;
  9213. t['Xeharmenian'] = 0x053D;
  9214. t['Xi'] = 0x039E;
  9215. t['Xmonospace'] = 0xFF38;
  9216. t['Xsmall'] = 0xF778;
  9217. t['Y'] = 0x0059;
  9218. t['Yacute'] = 0x00DD;
  9219. t['Yacutesmall'] = 0xF7FD;
  9220. t['Yatcyrillic'] = 0x0462;
  9221. t['Ycircle'] = 0x24CE;
  9222. t['Ycircumflex'] = 0x0176;
  9223. t['Ydieresis'] = 0x0178;
  9224. t['Ydieresissmall'] = 0xF7FF;
  9225. t['Ydotaccent'] = 0x1E8E;
  9226. t['Ydotbelow'] = 0x1EF4;
  9227. t['Yericyrillic'] = 0x042B;
  9228. t['Yerudieresiscyrillic'] = 0x04F8;
  9229. t['Ygrave'] = 0x1EF2;
  9230. t['Yhook'] = 0x01B3;
  9231. t['Yhookabove'] = 0x1EF6;
  9232. t['Yiarmenian'] = 0x0545;
  9233. t['Yicyrillic'] = 0x0407;
  9234. t['Yiwnarmenian'] = 0x0552;
  9235. t['Ymonospace'] = 0xFF39;
  9236. t['Ysmall'] = 0xF779;
  9237. t['Ytilde'] = 0x1EF8;
  9238. t['Yusbigcyrillic'] = 0x046A;
  9239. t['Yusbigiotifiedcyrillic'] = 0x046C;
  9240. t['Yuslittlecyrillic'] = 0x0466;
  9241. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  9242. t['Z'] = 0x005A;
  9243. t['Zaarmenian'] = 0x0536;
  9244. t['Zacute'] = 0x0179;
  9245. t['Zcaron'] = 0x017D;
  9246. t['Zcaronsmall'] = 0xF6FF;
  9247. t['Zcircle'] = 0x24CF;
  9248. t['Zcircumflex'] = 0x1E90;
  9249. t['Zdot'] = 0x017B;
  9250. t['Zdotaccent'] = 0x017B;
  9251. t['Zdotbelow'] = 0x1E92;
  9252. t['Zecyrillic'] = 0x0417;
  9253. t['Zedescendercyrillic'] = 0x0498;
  9254. t['Zedieresiscyrillic'] = 0x04DE;
  9255. t['Zeta'] = 0x0396;
  9256. t['Zhearmenian'] = 0x053A;
  9257. t['Zhebrevecyrillic'] = 0x04C1;
  9258. t['Zhecyrillic'] = 0x0416;
  9259. t['Zhedescendercyrillic'] = 0x0496;
  9260. t['Zhedieresiscyrillic'] = 0x04DC;
  9261. t['Zlinebelow'] = 0x1E94;
  9262. t['Zmonospace'] = 0xFF3A;
  9263. t['Zsmall'] = 0xF77A;
  9264. t['Zstroke'] = 0x01B5;
  9265. t['a'] = 0x0061;
  9266. t['aabengali'] = 0x0986;
  9267. t['aacute'] = 0x00E1;
  9268. t['aadeva'] = 0x0906;
  9269. t['aagujarati'] = 0x0A86;
  9270. t['aagurmukhi'] = 0x0A06;
  9271. t['aamatragurmukhi'] = 0x0A3E;
  9272. t['aarusquare'] = 0x3303;
  9273. t['aavowelsignbengali'] = 0x09BE;
  9274. t['aavowelsigndeva'] = 0x093E;
  9275. t['aavowelsigngujarati'] = 0x0ABE;
  9276. t['abbreviationmarkarmenian'] = 0x055F;
  9277. t['abbreviationsigndeva'] = 0x0970;
  9278. t['abengali'] = 0x0985;
  9279. t['abopomofo'] = 0x311A;
  9280. t['abreve'] = 0x0103;
  9281. t['abreveacute'] = 0x1EAF;
  9282. t['abrevecyrillic'] = 0x04D1;
  9283. t['abrevedotbelow'] = 0x1EB7;
  9284. t['abrevegrave'] = 0x1EB1;
  9285. t['abrevehookabove'] = 0x1EB3;
  9286. t['abrevetilde'] = 0x1EB5;
  9287. t['acaron'] = 0x01CE;
  9288. t['acircle'] = 0x24D0;
  9289. t['acircumflex'] = 0x00E2;
  9290. t['acircumflexacute'] = 0x1EA5;
  9291. t['acircumflexdotbelow'] = 0x1EAD;
  9292. t['acircumflexgrave'] = 0x1EA7;
  9293. t['acircumflexhookabove'] = 0x1EA9;
  9294. t['acircumflextilde'] = 0x1EAB;
  9295. t['acute'] = 0x00B4;
  9296. t['acutebelowcmb'] = 0x0317;
  9297. t['acutecmb'] = 0x0301;
  9298. t['acutecomb'] = 0x0301;
  9299. t['acutedeva'] = 0x0954;
  9300. t['acutelowmod'] = 0x02CF;
  9301. t['acutetonecmb'] = 0x0341;
  9302. t['acyrillic'] = 0x0430;
  9303. t['adblgrave'] = 0x0201;
  9304. t['addakgurmukhi'] = 0x0A71;
  9305. t['adeva'] = 0x0905;
  9306. t['adieresis'] = 0x00E4;
  9307. t['adieresiscyrillic'] = 0x04D3;
  9308. t['adieresismacron'] = 0x01DF;
  9309. t['adotbelow'] = 0x1EA1;
  9310. t['adotmacron'] = 0x01E1;
  9311. t['ae'] = 0x00E6;
  9312. t['aeacute'] = 0x01FD;
  9313. t['aekorean'] = 0x3150;
  9314. t['aemacron'] = 0x01E3;
  9315. t['afii00208'] = 0x2015;
  9316. t['afii08941'] = 0x20A4;
  9317. t['afii10017'] = 0x0410;
  9318. t['afii10018'] = 0x0411;
  9319. t['afii10019'] = 0x0412;
  9320. t['afii10020'] = 0x0413;
  9321. t['afii10021'] = 0x0414;
  9322. t['afii10022'] = 0x0415;
  9323. t['afii10023'] = 0x0401;
  9324. t['afii10024'] = 0x0416;
  9325. t['afii10025'] = 0x0417;
  9326. t['afii10026'] = 0x0418;
  9327. t['afii10027'] = 0x0419;
  9328. t['afii10028'] = 0x041A;
  9329. t['afii10029'] = 0x041B;
  9330. t['afii10030'] = 0x041C;
  9331. t['afii10031'] = 0x041D;
  9332. t['afii10032'] = 0x041E;
  9333. t['afii10033'] = 0x041F;
  9334. t['afii10034'] = 0x0420;
  9335. t['afii10035'] = 0x0421;
  9336. t['afii10036'] = 0x0422;
  9337. t['afii10037'] = 0x0423;
  9338. t['afii10038'] = 0x0424;
  9339. t['afii10039'] = 0x0425;
  9340. t['afii10040'] = 0x0426;
  9341. t['afii10041'] = 0x0427;
  9342. t['afii10042'] = 0x0428;
  9343. t['afii10043'] = 0x0429;
  9344. t['afii10044'] = 0x042A;
  9345. t['afii10045'] = 0x042B;
  9346. t['afii10046'] = 0x042C;
  9347. t['afii10047'] = 0x042D;
  9348. t['afii10048'] = 0x042E;
  9349. t['afii10049'] = 0x042F;
  9350. t['afii10050'] = 0x0490;
  9351. t['afii10051'] = 0x0402;
  9352. t['afii10052'] = 0x0403;
  9353. t['afii10053'] = 0x0404;
  9354. t['afii10054'] = 0x0405;
  9355. t['afii10055'] = 0x0406;
  9356. t['afii10056'] = 0x0407;
  9357. t['afii10057'] = 0x0408;
  9358. t['afii10058'] = 0x0409;
  9359. t['afii10059'] = 0x040A;
  9360. t['afii10060'] = 0x040B;
  9361. t['afii10061'] = 0x040C;
  9362. t['afii10062'] = 0x040E;
  9363. t['afii10063'] = 0xF6C4;
  9364. t['afii10064'] = 0xF6C5;
  9365. t['afii10065'] = 0x0430;
  9366. t['afii10066'] = 0x0431;
  9367. t['afii10067'] = 0x0432;
  9368. t['afii10068'] = 0x0433;
  9369. t['afii10069'] = 0x0434;
  9370. t['afii10070'] = 0x0435;
  9371. t['afii10071'] = 0x0451;
  9372. t['afii10072'] = 0x0436;
  9373. t['afii10073'] = 0x0437;
  9374. t['afii10074'] = 0x0438;
  9375. t['afii10075'] = 0x0439;
  9376. t['afii10076'] = 0x043A;
  9377. t['afii10077'] = 0x043B;
  9378. t['afii10078'] = 0x043C;
  9379. t['afii10079'] = 0x043D;
  9380. t['afii10080'] = 0x043E;
  9381. t['afii10081'] = 0x043F;
  9382. t['afii10082'] = 0x0440;
  9383. t['afii10083'] = 0x0441;
  9384. t['afii10084'] = 0x0442;
  9385. t['afii10085'] = 0x0443;
  9386. t['afii10086'] = 0x0444;
  9387. t['afii10087'] = 0x0445;
  9388. t['afii10088'] = 0x0446;
  9389. t['afii10089'] = 0x0447;
  9390. t['afii10090'] = 0x0448;
  9391. t['afii10091'] = 0x0449;
  9392. t['afii10092'] = 0x044A;
  9393. t['afii10093'] = 0x044B;
  9394. t['afii10094'] = 0x044C;
  9395. t['afii10095'] = 0x044D;
  9396. t['afii10096'] = 0x044E;
  9397. t['afii10097'] = 0x044F;
  9398. t['afii10098'] = 0x0491;
  9399. t['afii10099'] = 0x0452;
  9400. t['afii10100'] = 0x0453;
  9401. t['afii10101'] = 0x0454;
  9402. t['afii10102'] = 0x0455;
  9403. t['afii10103'] = 0x0456;
  9404. t['afii10104'] = 0x0457;
  9405. t['afii10105'] = 0x0458;
  9406. t['afii10106'] = 0x0459;
  9407. t['afii10107'] = 0x045A;
  9408. t['afii10108'] = 0x045B;
  9409. t['afii10109'] = 0x045C;
  9410. t['afii10110'] = 0x045E;
  9411. t['afii10145'] = 0x040F;
  9412. t['afii10146'] = 0x0462;
  9413. t['afii10147'] = 0x0472;
  9414. t['afii10148'] = 0x0474;
  9415. t['afii10192'] = 0xF6C6;
  9416. t['afii10193'] = 0x045F;
  9417. t['afii10194'] = 0x0463;
  9418. t['afii10195'] = 0x0473;
  9419. t['afii10196'] = 0x0475;
  9420. t['afii10831'] = 0xF6C7;
  9421. t['afii10832'] = 0xF6C8;
  9422. t['afii10846'] = 0x04D9;
  9423. t['afii299'] = 0x200E;
  9424. t['afii300'] = 0x200F;
  9425. t['afii301'] = 0x200D;
  9426. t['afii57381'] = 0x066A;
  9427. t['afii57388'] = 0x060C;
  9428. t['afii57392'] = 0x0660;
  9429. t['afii57393'] = 0x0661;
  9430. t['afii57394'] = 0x0662;
  9431. t['afii57395'] = 0x0663;
  9432. t['afii57396'] = 0x0664;
  9433. t['afii57397'] = 0x0665;
  9434. t['afii57398'] = 0x0666;
  9435. t['afii57399'] = 0x0667;
  9436. t['afii57400'] = 0x0668;
  9437. t['afii57401'] = 0x0669;
  9438. t['afii57403'] = 0x061B;
  9439. t['afii57407'] = 0x061F;
  9440. t['afii57409'] = 0x0621;
  9441. t['afii57410'] = 0x0622;
  9442. t['afii57411'] = 0x0623;
  9443. t['afii57412'] = 0x0624;
  9444. t['afii57413'] = 0x0625;
  9445. t['afii57414'] = 0x0626;
  9446. t['afii57415'] = 0x0627;
  9447. t['afii57416'] = 0x0628;
  9448. t['afii57417'] = 0x0629;
  9449. t['afii57418'] = 0x062A;
  9450. t['afii57419'] = 0x062B;
  9451. t['afii57420'] = 0x062C;
  9452. t['afii57421'] = 0x062D;
  9453. t['afii57422'] = 0x062E;
  9454. t['afii57423'] = 0x062F;
  9455. t['afii57424'] = 0x0630;
  9456. t['afii57425'] = 0x0631;
  9457. t['afii57426'] = 0x0632;
  9458. t['afii57427'] = 0x0633;
  9459. t['afii57428'] = 0x0634;
  9460. t['afii57429'] = 0x0635;
  9461. t['afii57430'] = 0x0636;
  9462. t['afii57431'] = 0x0637;
  9463. t['afii57432'] = 0x0638;
  9464. t['afii57433'] = 0x0639;
  9465. t['afii57434'] = 0x063A;
  9466. t['afii57440'] = 0x0640;
  9467. t['afii57441'] = 0x0641;
  9468. t['afii57442'] = 0x0642;
  9469. t['afii57443'] = 0x0643;
  9470. t['afii57444'] = 0x0644;
  9471. t['afii57445'] = 0x0645;
  9472. t['afii57446'] = 0x0646;
  9473. t['afii57448'] = 0x0648;
  9474. t['afii57449'] = 0x0649;
  9475. t['afii57450'] = 0x064A;
  9476. t['afii57451'] = 0x064B;
  9477. t['afii57452'] = 0x064C;
  9478. t['afii57453'] = 0x064D;
  9479. t['afii57454'] = 0x064E;
  9480. t['afii57455'] = 0x064F;
  9481. t['afii57456'] = 0x0650;
  9482. t['afii57457'] = 0x0651;
  9483. t['afii57458'] = 0x0652;
  9484. t['afii57470'] = 0x0647;
  9485. t['afii57505'] = 0x06A4;
  9486. t['afii57506'] = 0x067E;
  9487. t['afii57507'] = 0x0686;
  9488. t['afii57508'] = 0x0698;
  9489. t['afii57509'] = 0x06AF;
  9490. t['afii57511'] = 0x0679;
  9491. t['afii57512'] = 0x0688;
  9492. t['afii57513'] = 0x0691;
  9493. t['afii57514'] = 0x06BA;
  9494. t['afii57519'] = 0x06D2;
  9495. t['afii57534'] = 0x06D5;
  9496. t['afii57636'] = 0x20AA;
  9497. t['afii57645'] = 0x05BE;
  9498. t['afii57658'] = 0x05C3;
  9499. t['afii57664'] = 0x05D0;
  9500. t['afii57665'] = 0x05D1;
  9501. t['afii57666'] = 0x05D2;
  9502. t['afii57667'] = 0x05D3;
  9503. t['afii57668'] = 0x05D4;
  9504. t['afii57669'] = 0x05D5;
  9505. t['afii57670'] = 0x05D6;
  9506. t['afii57671'] = 0x05D7;
  9507. t['afii57672'] = 0x05D8;
  9508. t['afii57673'] = 0x05D9;
  9509. t['afii57674'] = 0x05DA;
  9510. t['afii57675'] = 0x05DB;
  9511. t['afii57676'] = 0x05DC;
  9512. t['afii57677'] = 0x05DD;
  9513. t['afii57678'] = 0x05DE;
  9514. t['afii57679'] = 0x05DF;
  9515. t['afii57680'] = 0x05E0;
  9516. t['afii57681'] = 0x05E1;
  9517. t['afii57682'] = 0x05E2;
  9518. t['afii57683'] = 0x05E3;
  9519. t['afii57684'] = 0x05E4;
  9520. t['afii57685'] = 0x05E5;
  9521. t['afii57686'] = 0x05E6;
  9522. t['afii57687'] = 0x05E7;
  9523. t['afii57688'] = 0x05E8;
  9524. t['afii57689'] = 0x05E9;
  9525. t['afii57690'] = 0x05EA;
  9526. t['afii57694'] = 0xFB2A;
  9527. t['afii57695'] = 0xFB2B;
  9528. t['afii57700'] = 0xFB4B;
  9529. t['afii57705'] = 0xFB1F;
  9530. t['afii57716'] = 0x05F0;
  9531. t['afii57717'] = 0x05F1;
  9532. t['afii57718'] = 0x05F2;
  9533. t['afii57723'] = 0xFB35;
  9534. t['afii57793'] = 0x05B4;
  9535. t['afii57794'] = 0x05B5;
  9536. t['afii57795'] = 0x05B6;
  9537. t['afii57796'] = 0x05BB;
  9538. t['afii57797'] = 0x05B8;
  9539. t['afii57798'] = 0x05B7;
  9540. t['afii57799'] = 0x05B0;
  9541. t['afii57800'] = 0x05B2;
  9542. t['afii57801'] = 0x05B1;
  9543. t['afii57802'] = 0x05B3;
  9544. t['afii57803'] = 0x05C2;
  9545. t['afii57804'] = 0x05C1;
  9546. t['afii57806'] = 0x05B9;
  9547. t['afii57807'] = 0x05BC;
  9548. t['afii57839'] = 0x05BD;
  9549. t['afii57841'] = 0x05BF;
  9550. t['afii57842'] = 0x05C0;
  9551. t['afii57929'] = 0x02BC;
  9552. t['afii61248'] = 0x2105;
  9553. t['afii61289'] = 0x2113;
  9554. t['afii61352'] = 0x2116;
  9555. t['afii61573'] = 0x202C;
  9556. t['afii61574'] = 0x202D;
  9557. t['afii61575'] = 0x202E;
  9558. t['afii61664'] = 0x200C;
  9559. t['afii63167'] = 0x066D;
  9560. t['afii64937'] = 0x02BD;
  9561. t['agrave'] = 0x00E0;
  9562. t['agujarati'] = 0x0A85;
  9563. t['agurmukhi'] = 0x0A05;
  9564. t['ahiragana'] = 0x3042;
  9565. t['ahookabove'] = 0x1EA3;
  9566. t['aibengali'] = 0x0990;
  9567. t['aibopomofo'] = 0x311E;
  9568. t['aideva'] = 0x0910;
  9569. t['aiecyrillic'] = 0x04D5;
  9570. t['aigujarati'] = 0x0A90;
  9571. t['aigurmukhi'] = 0x0A10;
  9572. t['aimatragurmukhi'] = 0x0A48;
  9573. t['ainarabic'] = 0x0639;
  9574. t['ainfinalarabic'] = 0xFECA;
  9575. t['aininitialarabic'] = 0xFECB;
  9576. t['ainmedialarabic'] = 0xFECC;
  9577. t['ainvertedbreve'] = 0x0203;
  9578. t['aivowelsignbengali'] = 0x09C8;
  9579. t['aivowelsigndeva'] = 0x0948;
  9580. t['aivowelsigngujarati'] = 0x0AC8;
  9581. t['akatakana'] = 0x30A2;
  9582. t['akatakanahalfwidth'] = 0xFF71;
  9583. t['akorean'] = 0x314F;
  9584. t['alef'] = 0x05D0;
  9585. t['alefarabic'] = 0x0627;
  9586. t['alefdageshhebrew'] = 0xFB30;
  9587. t['aleffinalarabic'] = 0xFE8E;
  9588. t['alefhamzaabovearabic'] = 0x0623;
  9589. t['alefhamzaabovefinalarabic'] = 0xFE84;
  9590. t['alefhamzabelowarabic'] = 0x0625;
  9591. t['alefhamzabelowfinalarabic'] = 0xFE88;
  9592. t['alefhebrew'] = 0x05D0;
  9593. t['aleflamedhebrew'] = 0xFB4F;
  9594. t['alefmaddaabovearabic'] = 0x0622;
  9595. t['alefmaddaabovefinalarabic'] = 0xFE82;
  9596. t['alefmaksuraarabic'] = 0x0649;
  9597. t['alefmaksurafinalarabic'] = 0xFEF0;
  9598. t['alefmaksurainitialarabic'] = 0xFEF3;
  9599. t['alefmaksuramedialarabic'] = 0xFEF4;
  9600. t['alefpatahhebrew'] = 0xFB2E;
  9601. t['alefqamatshebrew'] = 0xFB2F;
  9602. t['aleph'] = 0x2135;
  9603. t['allequal'] = 0x224C;
  9604. t['alpha'] = 0x03B1;
  9605. t['alphatonos'] = 0x03AC;
  9606. t['amacron'] = 0x0101;
  9607. t['amonospace'] = 0xFF41;
  9608. t['ampersand'] = 0x0026;
  9609. t['ampersandmonospace'] = 0xFF06;
  9610. t['ampersandsmall'] = 0xF726;
  9611. t['amsquare'] = 0x33C2;
  9612. t['anbopomofo'] = 0x3122;
  9613. t['angbopomofo'] = 0x3124;
  9614. t['angbracketleft'] = 0x3008;
  9615. t['angbracketright'] = 0x3009;
  9616. t['angkhankhuthai'] = 0x0E5A;
  9617. t['angle'] = 0x2220;
  9618. t['anglebracketleft'] = 0x3008;
  9619. t['anglebracketleftvertical'] = 0xFE3F;
  9620. t['anglebracketright'] = 0x3009;
  9621. t['anglebracketrightvertical'] = 0xFE40;
  9622. t['angleleft'] = 0x2329;
  9623. t['angleright'] = 0x232A;
  9624. t['angstrom'] = 0x212B;
  9625. t['anoteleia'] = 0x0387;
  9626. t['anudattadeva'] = 0x0952;
  9627. t['anusvarabengali'] = 0x0982;
  9628. t['anusvaradeva'] = 0x0902;
  9629. t['anusvaragujarati'] = 0x0A82;
  9630. t['aogonek'] = 0x0105;
  9631. t['apaatosquare'] = 0x3300;
  9632. t['aparen'] = 0x249C;
  9633. t['apostrophearmenian'] = 0x055A;
  9634. t['apostrophemod'] = 0x02BC;
  9635. t['apple'] = 0xF8FF;
  9636. t['approaches'] = 0x2250;
  9637. t['approxequal'] = 0x2248;
  9638. t['approxequalorimage'] = 0x2252;
  9639. t['approximatelyequal'] = 0x2245;
  9640. t['araeaekorean'] = 0x318E;
  9641. t['araeakorean'] = 0x318D;
  9642. t['arc'] = 0x2312;
  9643. t['arighthalfring'] = 0x1E9A;
  9644. t['aring'] = 0x00E5;
  9645. t['aringacute'] = 0x01FB;
  9646. t['aringbelow'] = 0x1E01;
  9647. t['arrowboth'] = 0x2194;
  9648. t['arrowdashdown'] = 0x21E3;
  9649. t['arrowdashleft'] = 0x21E0;
  9650. t['arrowdashright'] = 0x21E2;
  9651. t['arrowdashup'] = 0x21E1;
  9652. t['arrowdblboth'] = 0x21D4;
  9653. t['arrowdbldown'] = 0x21D3;
  9654. t['arrowdblleft'] = 0x21D0;
  9655. t['arrowdblright'] = 0x21D2;
  9656. t['arrowdblup'] = 0x21D1;
  9657. t['arrowdown'] = 0x2193;
  9658. t['arrowdownleft'] = 0x2199;
  9659. t['arrowdownright'] = 0x2198;
  9660. t['arrowdownwhite'] = 0x21E9;
  9661. t['arrowheaddownmod'] = 0x02C5;
  9662. t['arrowheadleftmod'] = 0x02C2;
  9663. t['arrowheadrightmod'] = 0x02C3;
  9664. t['arrowheadupmod'] = 0x02C4;
  9665. t['arrowhorizex'] = 0xF8E7;
  9666. t['arrowleft'] = 0x2190;
  9667. t['arrowleftdbl'] = 0x21D0;
  9668. t['arrowleftdblstroke'] = 0x21CD;
  9669. t['arrowleftoverright'] = 0x21C6;
  9670. t['arrowleftwhite'] = 0x21E6;
  9671. t['arrowright'] = 0x2192;
  9672. t['arrowrightdblstroke'] = 0x21CF;
  9673. t['arrowrightheavy'] = 0x279E;
  9674. t['arrowrightoverleft'] = 0x21C4;
  9675. t['arrowrightwhite'] = 0x21E8;
  9676. t['arrowtableft'] = 0x21E4;
  9677. t['arrowtabright'] = 0x21E5;
  9678. t['arrowup'] = 0x2191;
  9679. t['arrowupdn'] = 0x2195;
  9680. t['arrowupdnbse'] = 0x21A8;
  9681. t['arrowupdownbase'] = 0x21A8;
  9682. t['arrowupleft'] = 0x2196;
  9683. t['arrowupleftofdown'] = 0x21C5;
  9684. t['arrowupright'] = 0x2197;
  9685. t['arrowupwhite'] = 0x21E7;
  9686. t['arrowvertex'] = 0xF8E6;
  9687. t['asciicircum'] = 0x005E;
  9688. t['asciicircummonospace'] = 0xFF3E;
  9689. t['asciitilde'] = 0x007E;
  9690. t['asciitildemonospace'] = 0xFF5E;
  9691. t['ascript'] = 0x0251;
  9692. t['ascriptturned'] = 0x0252;
  9693. t['asmallhiragana'] = 0x3041;
  9694. t['asmallkatakana'] = 0x30A1;
  9695. t['asmallkatakanahalfwidth'] = 0xFF67;
  9696. t['asterisk'] = 0x002A;
  9697. t['asteriskaltonearabic'] = 0x066D;
  9698. t['asteriskarabic'] = 0x066D;
  9699. t['asteriskmath'] = 0x2217;
  9700. t['asteriskmonospace'] = 0xFF0A;
  9701. t['asterisksmall'] = 0xFE61;
  9702. t['asterism'] = 0x2042;
  9703. t['asuperior'] = 0xF6E9;
  9704. t['asymptoticallyequal'] = 0x2243;
  9705. t['at'] = 0x0040;
  9706. t['atilde'] = 0x00E3;
  9707. t['atmonospace'] = 0xFF20;
  9708. t['atsmall'] = 0xFE6B;
  9709. t['aturned'] = 0x0250;
  9710. t['aubengali'] = 0x0994;
  9711. t['aubopomofo'] = 0x3120;
  9712. t['audeva'] = 0x0914;
  9713. t['augujarati'] = 0x0A94;
  9714. t['augurmukhi'] = 0x0A14;
  9715. t['aulengthmarkbengali'] = 0x09D7;
  9716. t['aumatragurmukhi'] = 0x0A4C;
  9717. t['auvowelsignbengali'] = 0x09CC;
  9718. t['auvowelsigndeva'] = 0x094C;
  9719. t['auvowelsigngujarati'] = 0x0ACC;
  9720. t['avagrahadeva'] = 0x093D;
  9721. t['aybarmenian'] = 0x0561;
  9722. t['ayin'] = 0x05E2;
  9723. t['ayinaltonehebrew'] = 0xFB20;
  9724. t['ayinhebrew'] = 0x05E2;
  9725. t['b'] = 0x0062;
  9726. t['babengali'] = 0x09AC;
  9727. t['backslash'] = 0x005C;
  9728. t['backslashmonospace'] = 0xFF3C;
  9729. t['badeva'] = 0x092C;
  9730. t['bagujarati'] = 0x0AAC;
  9731. t['bagurmukhi'] = 0x0A2C;
  9732. t['bahiragana'] = 0x3070;
  9733. t['bahtthai'] = 0x0E3F;
  9734. t['bakatakana'] = 0x30D0;
  9735. t['bar'] = 0x007C;
  9736. t['barmonospace'] = 0xFF5C;
  9737. t['bbopomofo'] = 0x3105;
  9738. t['bcircle'] = 0x24D1;
  9739. t['bdotaccent'] = 0x1E03;
  9740. t['bdotbelow'] = 0x1E05;
  9741. t['beamedsixteenthnotes'] = 0x266C;
  9742. t['because'] = 0x2235;
  9743. t['becyrillic'] = 0x0431;
  9744. t['beharabic'] = 0x0628;
  9745. t['behfinalarabic'] = 0xFE90;
  9746. t['behinitialarabic'] = 0xFE91;
  9747. t['behiragana'] = 0x3079;
  9748. t['behmedialarabic'] = 0xFE92;
  9749. t['behmeeminitialarabic'] = 0xFC9F;
  9750. t['behmeemisolatedarabic'] = 0xFC08;
  9751. t['behnoonfinalarabic'] = 0xFC6D;
  9752. t['bekatakana'] = 0x30D9;
  9753. t['benarmenian'] = 0x0562;
  9754. t['bet'] = 0x05D1;
  9755. t['beta'] = 0x03B2;
  9756. t['betasymbolgreek'] = 0x03D0;
  9757. t['betdagesh'] = 0xFB31;
  9758. t['betdageshhebrew'] = 0xFB31;
  9759. t['bethebrew'] = 0x05D1;
  9760. t['betrafehebrew'] = 0xFB4C;
  9761. t['bhabengali'] = 0x09AD;
  9762. t['bhadeva'] = 0x092D;
  9763. t['bhagujarati'] = 0x0AAD;
  9764. t['bhagurmukhi'] = 0x0A2D;
  9765. t['bhook'] = 0x0253;
  9766. t['bihiragana'] = 0x3073;
  9767. t['bikatakana'] = 0x30D3;
  9768. t['bilabialclick'] = 0x0298;
  9769. t['bindigurmukhi'] = 0x0A02;
  9770. t['birusquare'] = 0x3331;
  9771. t['blackcircle'] = 0x25CF;
  9772. t['blackdiamond'] = 0x25C6;
  9773. t['blackdownpointingtriangle'] = 0x25BC;
  9774. t['blackleftpointingpointer'] = 0x25C4;
  9775. t['blackleftpointingtriangle'] = 0x25C0;
  9776. t['blacklenticularbracketleft'] = 0x3010;
  9777. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  9778. t['blacklenticularbracketright'] = 0x3011;
  9779. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  9780. t['blacklowerlefttriangle'] = 0x25E3;
  9781. t['blacklowerrighttriangle'] = 0x25E2;
  9782. t['blackrectangle'] = 0x25AC;
  9783. t['blackrightpointingpointer'] = 0x25BA;
  9784. t['blackrightpointingtriangle'] = 0x25B6;
  9785. t['blacksmallsquare'] = 0x25AA;
  9786. t['blacksmilingface'] = 0x263B;
  9787. t['blacksquare'] = 0x25A0;
  9788. t['blackstar'] = 0x2605;
  9789. t['blackupperlefttriangle'] = 0x25E4;
  9790. t['blackupperrighttriangle'] = 0x25E5;
  9791. t['blackuppointingsmalltriangle'] = 0x25B4;
  9792. t['blackuppointingtriangle'] = 0x25B2;
  9793. t['blank'] = 0x2423;
  9794. t['blinebelow'] = 0x1E07;
  9795. t['block'] = 0x2588;
  9796. t['bmonospace'] = 0xFF42;
  9797. t['bobaimaithai'] = 0x0E1A;
  9798. t['bohiragana'] = 0x307C;
  9799. t['bokatakana'] = 0x30DC;
  9800. t['bparen'] = 0x249D;
  9801. t['bqsquare'] = 0x33C3;
  9802. t['braceex'] = 0xF8F4;
  9803. t['braceleft'] = 0x007B;
  9804. t['braceleftbt'] = 0xF8F3;
  9805. t['braceleftmid'] = 0xF8F2;
  9806. t['braceleftmonospace'] = 0xFF5B;
  9807. t['braceleftsmall'] = 0xFE5B;
  9808. t['bracelefttp'] = 0xF8F1;
  9809. t['braceleftvertical'] = 0xFE37;
  9810. t['braceright'] = 0x007D;
  9811. t['bracerightbt'] = 0xF8FE;
  9812. t['bracerightmid'] = 0xF8FD;
  9813. t['bracerightmonospace'] = 0xFF5D;
  9814. t['bracerightsmall'] = 0xFE5C;
  9815. t['bracerighttp'] = 0xF8FC;
  9816. t['bracerightvertical'] = 0xFE38;
  9817. t['bracketleft'] = 0x005B;
  9818. t['bracketleftbt'] = 0xF8F0;
  9819. t['bracketleftex'] = 0xF8EF;
  9820. t['bracketleftmonospace'] = 0xFF3B;
  9821. t['bracketlefttp'] = 0xF8EE;
  9822. t['bracketright'] = 0x005D;
  9823. t['bracketrightbt'] = 0xF8FB;
  9824. t['bracketrightex'] = 0xF8FA;
  9825. t['bracketrightmonospace'] = 0xFF3D;
  9826. t['bracketrighttp'] = 0xF8F9;
  9827. t['breve'] = 0x02D8;
  9828. t['brevebelowcmb'] = 0x032E;
  9829. t['brevecmb'] = 0x0306;
  9830. t['breveinvertedbelowcmb'] = 0x032F;
  9831. t['breveinvertedcmb'] = 0x0311;
  9832. t['breveinverteddoublecmb'] = 0x0361;
  9833. t['bridgebelowcmb'] = 0x032A;
  9834. t['bridgeinvertedbelowcmb'] = 0x033A;
  9835. t['brokenbar'] = 0x00A6;
  9836. t['bstroke'] = 0x0180;
  9837. t['bsuperior'] = 0xF6EA;
  9838. t['btopbar'] = 0x0183;
  9839. t['buhiragana'] = 0x3076;
  9840. t['bukatakana'] = 0x30D6;
  9841. t['bullet'] = 0x2022;
  9842. t['bulletinverse'] = 0x25D8;
  9843. t['bulletoperator'] = 0x2219;
  9844. t['bullseye'] = 0x25CE;
  9845. t['c'] = 0x0063;
  9846. t['caarmenian'] = 0x056E;
  9847. t['cabengali'] = 0x099A;
  9848. t['cacute'] = 0x0107;
  9849. t['cadeva'] = 0x091A;
  9850. t['cagujarati'] = 0x0A9A;
  9851. t['cagurmukhi'] = 0x0A1A;
  9852. t['calsquare'] = 0x3388;
  9853. t['candrabindubengali'] = 0x0981;
  9854. t['candrabinducmb'] = 0x0310;
  9855. t['candrabindudeva'] = 0x0901;
  9856. t['candrabindugujarati'] = 0x0A81;
  9857. t['capslock'] = 0x21EA;
  9858. t['careof'] = 0x2105;
  9859. t['caron'] = 0x02C7;
  9860. t['caronbelowcmb'] = 0x032C;
  9861. t['caroncmb'] = 0x030C;
  9862. t['carriagereturn'] = 0x21B5;
  9863. t['cbopomofo'] = 0x3118;
  9864. t['ccaron'] = 0x010D;
  9865. t['ccedilla'] = 0x00E7;
  9866. t['ccedillaacute'] = 0x1E09;
  9867. t['ccircle'] = 0x24D2;
  9868. t['ccircumflex'] = 0x0109;
  9869. t['ccurl'] = 0x0255;
  9870. t['cdot'] = 0x010B;
  9871. t['cdotaccent'] = 0x010B;
  9872. t['cdsquare'] = 0x33C5;
  9873. t['cedilla'] = 0x00B8;
  9874. t['cedillacmb'] = 0x0327;
  9875. t['cent'] = 0x00A2;
  9876. t['centigrade'] = 0x2103;
  9877. t['centinferior'] = 0xF6DF;
  9878. t['centmonospace'] = 0xFFE0;
  9879. t['centoldstyle'] = 0xF7A2;
  9880. t['centsuperior'] = 0xF6E0;
  9881. t['chaarmenian'] = 0x0579;
  9882. t['chabengali'] = 0x099B;
  9883. t['chadeva'] = 0x091B;
  9884. t['chagujarati'] = 0x0A9B;
  9885. t['chagurmukhi'] = 0x0A1B;
  9886. t['chbopomofo'] = 0x3114;
  9887. t['cheabkhasiancyrillic'] = 0x04BD;
  9888. t['checkmark'] = 0x2713;
  9889. t['checyrillic'] = 0x0447;
  9890. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  9891. t['chedescendercyrillic'] = 0x04B7;
  9892. t['chedieresiscyrillic'] = 0x04F5;
  9893. t['cheharmenian'] = 0x0573;
  9894. t['chekhakassiancyrillic'] = 0x04CC;
  9895. t['cheverticalstrokecyrillic'] = 0x04B9;
  9896. t['chi'] = 0x03C7;
  9897. t['chieuchacirclekorean'] = 0x3277;
  9898. t['chieuchaparenkorean'] = 0x3217;
  9899. t['chieuchcirclekorean'] = 0x3269;
  9900. t['chieuchkorean'] = 0x314A;
  9901. t['chieuchparenkorean'] = 0x3209;
  9902. t['chochangthai'] = 0x0E0A;
  9903. t['chochanthai'] = 0x0E08;
  9904. t['chochingthai'] = 0x0E09;
  9905. t['chochoethai'] = 0x0E0C;
  9906. t['chook'] = 0x0188;
  9907. t['cieucacirclekorean'] = 0x3276;
  9908. t['cieucaparenkorean'] = 0x3216;
  9909. t['cieuccirclekorean'] = 0x3268;
  9910. t['cieuckorean'] = 0x3148;
  9911. t['cieucparenkorean'] = 0x3208;
  9912. t['cieucuparenkorean'] = 0x321C;
  9913. t['circle'] = 0x25CB;
  9914. t['circlecopyrt'] = 0x00A9;
  9915. t['circlemultiply'] = 0x2297;
  9916. t['circleot'] = 0x2299;
  9917. t['circleplus'] = 0x2295;
  9918. t['circlepostalmark'] = 0x3036;
  9919. t['circlewithlefthalfblack'] = 0x25D0;
  9920. t['circlewithrighthalfblack'] = 0x25D1;
  9921. t['circumflex'] = 0x02C6;
  9922. t['circumflexbelowcmb'] = 0x032D;
  9923. t['circumflexcmb'] = 0x0302;
  9924. t['clear'] = 0x2327;
  9925. t['clickalveolar'] = 0x01C2;
  9926. t['clickdental'] = 0x01C0;
  9927. t['clicklateral'] = 0x01C1;
  9928. t['clickretroflex'] = 0x01C3;
  9929. t['club'] = 0x2663;
  9930. t['clubsuitblack'] = 0x2663;
  9931. t['clubsuitwhite'] = 0x2667;
  9932. t['cmcubedsquare'] = 0x33A4;
  9933. t['cmonospace'] = 0xFF43;
  9934. t['cmsquaredsquare'] = 0x33A0;
  9935. t['coarmenian'] = 0x0581;
  9936. t['colon'] = 0x003A;
  9937. t['colonmonetary'] = 0x20A1;
  9938. t['colonmonospace'] = 0xFF1A;
  9939. t['colonsign'] = 0x20A1;
  9940. t['colonsmall'] = 0xFE55;
  9941. t['colontriangularhalfmod'] = 0x02D1;
  9942. t['colontriangularmod'] = 0x02D0;
  9943. t['comma'] = 0x002C;
  9944. t['commaabovecmb'] = 0x0313;
  9945. t['commaaboverightcmb'] = 0x0315;
  9946. t['commaaccent'] = 0xF6C3;
  9947. t['commaarabic'] = 0x060C;
  9948. t['commaarmenian'] = 0x055D;
  9949. t['commainferior'] = 0xF6E1;
  9950. t['commamonospace'] = 0xFF0C;
  9951. t['commareversedabovecmb'] = 0x0314;
  9952. t['commareversedmod'] = 0x02BD;
  9953. t['commasmall'] = 0xFE50;
  9954. t['commasuperior'] = 0xF6E2;
  9955. t['commaturnedabovecmb'] = 0x0312;
  9956. t['commaturnedmod'] = 0x02BB;
  9957. t['compass'] = 0x263C;
  9958. t['congruent'] = 0x2245;
  9959. t['contourintegral'] = 0x222E;
  9960. t['control'] = 0x2303;
  9961. t['controlACK'] = 0x0006;
  9962. t['controlBEL'] = 0x0007;
  9963. t['controlBS'] = 0x0008;
  9964. t['controlCAN'] = 0x0018;
  9965. t['controlCR'] = 0x000D;
  9966. t['controlDC1'] = 0x0011;
  9967. t['controlDC2'] = 0x0012;
  9968. t['controlDC3'] = 0x0013;
  9969. t['controlDC4'] = 0x0014;
  9970. t['controlDEL'] = 0x007F;
  9971. t['controlDLE'] = 0x0010;
  9972. t['controlEM'] = 0x0019;
  9973. t['controlENQ'] = 0x0005;
  9974. t['controlEOT'] = 0x0004;
  9975. t['controlESC'] = 0x001B;
  9976. t['controlETB'] = 0x0017;
  9977. t['controlETX'] = 0x0003;
  9978. t['controlFF'] = 0x000C;
  9979. t['controlFS'] = 0x001C;
  9980. t['controlGS'] = 0x001D;
  9981. t['controlHT'] = 0x0009;
  9982. t['controlLF'] = 0x000A;
  9983. t['controlNAK'] = 0x0015;
  9984. t['controlRS'] = 0x001E;
  9985. t['controlSI'] = 0x000F;
  9986. t['controlSO'] = 0x000E;
  9987. t['controlSOT'] = 0x0002;
  9988. t['controlSTX'] = 0x0001;
  9989. t['controlSUB'] = 0x001A;
  9990. t['controlSYN'] = 0x0016;
  9991. t['controlUS'] = 0x001F;
  9992. t['controlVT'] = 0x000B;
  9993. t['copyright'] = 0x00A9;
  9994. t['copyrightsans'] = 0xF8E9;
  9995. t['copyrightserif'] = 0xF6D9;
  9996. t['cornerbracketleft'] = 0x300C;
  9997. t['cornerbracketlefthalfwidth'] = 0xFF62;
  9998. t['cornerbracketleftvertical'] = 0xFE41;
  9999. t['cornerbracketright'] = 0x300D;
  10000. t['cornerbracketrighthalfwidth'] = 0xFF63;
  10001. t['cornerbracketrightvertical'] = 0xFE42;
  10002. t['corporationsquare'] = 0x337F;
  10003. t['cosquare'] = 0x33C7;
  10004. t['coverkgsquare'] = 0x33C6;
  10005. t['cparen'] = 0x249E;
  10006. t['cruzeiro'] = 0x20A2;
  10007. t['cstretched'] = 0x0297;
  10008. t['curlyand'] = 0x22CF;
  10009. t['curlyor'] = 0x22CE;
  10010. t['currency'] = 0x00A4;
  10011. t['cyrBreve'] = 0xF6D1;
  10012. t['cyrFlex'] = 0xF6D2;
  10013. t['cyrbreve'] = 0xF6D4;
  10014. t['cyrflex'] = 0xF6D5;
  10015. t['d'] = 0x0064;
  10016. t['daarmenian'] = 0x0564;
  10017. t['dabengali'] = 0x09A6;
  10018. t['dadarabic'] = 0x0636;
  10019. t['dadeva'] = 0x0926;
  10020. t['dadfinalarabic'] = 0xFEBE;
  10021. t['dadinitialarabic'] = 0xFEBF;
  10022. t['dadmedialarabic'] = 0xFEC0;
  10023. t['dagesh'] = 0x05BC;
  10024. t['dageshhebrew'] = 0x05BC;
  10025. t['dagger'] = 0x2020;
  10026. t['daggerdbl'] = 0x2021;
  10027. t['dagujarati'] = 0x0AA6;
  10028. t['dagurmukhi'] = 0x0A26;
  10029. t['dahiragana'] = 0x3060;
  10030. t['dakatakana'] = 0x30C0;
  10031. t['dalarabic'] = 0x062F;
  10032. t['dalet'] = 0x05D3;
  10033. t['daletdagesh'] = 0xFB33;
  10034. t['daletdageshhebrew'] = 0xFB33;
  10035. t['dalethebrew'] = 0x05D3;
  10036. t['dalfinalarabic'] = 0xFEAA;
  10037. t['dammaarabic'] = 0x064F;
  10038. t['dammalowarabic'] = 0x064F;
  10039. t['dammatanaltonearabic'] = 0x064C;
  10040. t['dammatanarabic'] = 0x064C;
  10041. t['danda'] = 0x0964;
  10042. t['dargahebrew'] = 0x05A7;
  10043. t['dargalefthebrew'] = 0x05A7;
  10044. t['dasiapneumatacyrilliccmb'] = 0x0485;
  10045. t['dblGrave'] = 0xF6D3;
  10046. t['dblanglebracketleft'] = 0x300A;
  10047. t['dblanglebracketleftvertical'] = 0xFE3D;
  10048. t['dblanglebracketright'] = 0x300B;
  10049. t['dblanglebracketrightvertical'] = 0xFE3E;
  10050. t['dblarchinvertedbelowcmb'] = 0x032B;
  10051. t['dblarrowleft'] = 0x21D4;
  10052. t['dblarrowright'] = 0x21D2;
  10053. t['dbldanda'] = 0x0965;
  10054. t['dblgrave'] = 0xF6D6;
  10055. t['dblgravecmb'] = 0x030F;
  10056. t['dblintegral'] = 0x222C;
  10057. t['dbllowline'] = 0x2017;
  10058. t['dbllowlinecmb'] = 0x0333;
  10059. t['dbloverlinecmb'] = 0x033F;
  10060. t['dblprimemod'] = 0x02BA;
  10061. t['dblverticalbar'] = 0x2016;
  10062. t['dblverticallineabovecmb'] = 0x030E;
  10063. t['dbopomofo'] = 0x3109;
  10064. t['dbsquare'] = 0x33C8;
  10065. t['dcaron'] = 0x010F;
  10066. t['dcedilla'] = 0x1E11;
  10067. t['dcircle'] = 0x24D3;
  10068. t['dcircumflexbelow'] = 0x1E13;
  10069. t['dcroat'] = 0x0111;
  10070. t['ddabengali'] = 0x09A1;
  10071. t['ddadeva'] = 0x0921;
  10072. t['ddagujarati'] = 0x0AA1;
  10073. t['ddagurmukhi'] = 0x0A21;
  10074. t['ddalarabic'] = 0x0688;
  10075. t['ddalfinalarabic'] = 0xFB89;
  10076. t['dddhadeva'] = 0x095C;
  10077. t['ddhabengali'] = 0x09A2;
  10078. t['ddhadeva'] = 0x0922;
  10079. t['ddhagujarati'] = 0x0AA2;
  10080. t['ddhagurmukhi'] = 0x0A22;
  10081. t['ddotaccent'] = 0x1E0B;
  10082. t['ddotbelow'] = 0x1E0D;
  10083. t['decimalseparatorarabic'] = 0x066B;
  10084. t['decimalseparatorpersian'] = 0x066B;
  10085. t['decyrillic'] = 0x0434;
  10086. t['degree'] = 0x00B0;
  10087. t['dehihebrew'] = 0x05AD;
  10088. t['dehiragana'] = 0x3067;
  10089. t['deicoptic'] = 0x03EF;
  10090. t['dekatakana'] = 0x30C7;
  10091. t['deleteleft'] = 0x232B;
  10092. t['deleteright'] = 0x2326;
  10093. t['delta'] = 0x03B4;
  10094. t['deltaturned'] = 0x018D;
  10095. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  10096. t['dezh'] = 0x02A4;
  10097. t['dhabengali'] = 0x09A7;
  10098. t['dhadeva'] = 0x0927;
  10099. t['dhagujarati'] = 0x0AA7;
  10100. t['dhagurmukhi'] = 0x0A27;
  10101. t['dhook'] = 0x0257;
  10102. t['dialytikatonos'] = 0x0385;
  10103. t['dialytikatonoscmb'] = 0x0344;
  10104. t['diamond'] = 0x2666;
  10105. t['diamondsuitwhite'] = 0x2662;
  10106. t['dieresis'] = 0x00A8;
  10107. t['dieresisacute'] = 0xF6D7;
  10108. t['dieresisbelowcmb'] = 0x0324;
  10109. t['dieresiscmb'] = 0x0308;
  10110. t['dieresisgrave'] = 0xF6D8;
  10111. t['dieresistonos'] = 0x0385;
  10112. t['dihiragana'] = 0x3062;
  10113. t['dikatakana'] = 0x30C2;
  10114. t['dittomark'] = 0x3003;
  10115. t['divide'] = 0x00F7;
  10116. t['divides'] = 0x2223;
  10117. t['divisionslash'] = 0x2215;
  10118. t['djecyrillic'] = 0x0452;
  10119. t['dkshade'] = 0x2593;
  10120. t['dlinebelow'] = 0x1E0F;
  10121. t['dlsquare'] = 0x3397;
  10122. t['dmacron'] = 0x0111;
  10123. t['dmonospace'] = 0xFF44;
  10124. t['dnblock'] = 0x2584;
  10125. t['dochadathai'] = 0x0E0E;
  10126. t['dodekthai'] = 0x0E14;
  10127. t['dohiragana'] = 0x3069;
  10128. t['dokatakana'] = 0x30C9;
  10129. t['dollar'] = 0x0024;
  10130. t['dollarinferior'] = 0xF6E3;
  10131. t['dollarmonospace'] = 0xFF04;
  10132. t['dollaroldstyle'] = 0xF724;
  10133. t['dollarsmall'] = 0xFE69;
  10134. t['dollarsuperior'] = 0xF6E4;
  10135. t['dong'] = 0x20AB;
  10136. t['dorusquare'] = 0x3326;
  10137. t['dotaccent'] = 0x02D9;
  10138. t['dotaccentcmb'] = 0x0307;
  10139. t['dotbelowcmb'] = 0x0323;
  10140. t['dotbelowcomb'] = 0x0323;
  10141. t['dotkatakana'] = 0x30FB;
  10142. t['dotlessi'] = 0x0131;
  10143. t['dotlessj'] = 0xF6BE;
  10144. t['dotlessjstrokehook'] = 0x0284;
  10145. t['dotmath'] = 0x22C5;
  10146. t['dottedcircle'] = 0x25CC;
  10147. t['doubleyodpatah'] = 0xFB1F;
  10148. t['doubleyodpatahhebrew'] = 0xFB1F;
  10149. t['downtackbelowcmb'] = 0x031E;
  10150. t['downtackmod'] = 0x02D5;
  10151. t['dparen'] = 0x249F;
  10152. t['dsuperior'] = 0xF6EB;
  10153. t['dtail'] = 0x0256;
  10154. t['dtopbar'] = 0x018C;
  10155. t['duhiragana'] = 0x3065;
  10156. t['dukatakana'] = 0x30C5;
  10157. t['dz'] = 0x01F3;
  10158. t['dzaltone'] = 0x02A3;
  10159. t['dzcaron'] = 0x01C6;
  10160. t['dzcurl'] = 0x02A5;
  10161. t['dzeabkhasiancyrillic'] = 0x04E1;
  10162. t['dzecyrillic'] = 0x0455;
  10163. t['dzhecyrillic'] = 0x045F;
  10164. t['e'] = 0x0065;
  10165. t['eacute'] = 0x00E9;
  10166. t['earth'] = 0x2641;
  10167. t['ebengali'] = 0x098F;
  10168. t['ebopomofo'] = 0x311C;
  10169. t['ebreve'] = 0x0115;
  10170. t['ecandradeva'] = 0x090D;
  10171. t['ecandragujarati'] = 0x0A8D;
  10172. t['ecandravowelsigndeva'] = 0x0945;
  10173. t['ecandravowelsigngujarati'] = 0x0AC5;
  10174. t['ecaron'] = 0x011B;
  10175. t['ecedillabreve'] = 0x1E1D;
  10176. t['echarmenian'] = 0x0565;
  10177. t['echyiwnarmenian'] = 0x0587;
  10178. t['ecircle'] = 0x24D4;
  10179. t['ecircumflex'] = 0x00EA;
  10180. t['ecircumflexacute'] = 0x1EBF;
  10181. t['ecircumflexbelow'] = 0x1E19;
  10182. t['ecircumflexdotbelow'] = 0x1EC7;
  10183. t['ecircumflexgrave'] = 0x1EC1;
  10184. t['ecircumflexhookabove'] = 0x1EC3;
  10185. t['ecircumflextilde'] = 0x1EC5;
  10186. t['ecyrillic'] = 0x0454;
  10187. t['edblgrave'] = 0x0205;
  10188. t['edeva'] = 0x090F;
  10189. t['edieresis'] = 0x00EB;
  10190. t['edot'] = 0x0117;
  10191. t['edotaccent'] = 0x0117;
  10192. t['edotbelow'] = 0x1EB9;
  10193. t['eegurmukhi'] = 0x0A0F;
  10194. t['eematragurmukhi'] = 0x0A47;
  10195. t['efcyrillic'] = 0x0444;
  10196. t['egrave'] = 0x00E8;
  10197. t['egujarati'] = 0x0A8F;
  10198. t['eharmenian'] = 0x0567;
  10199. t['ehbopomofo'] = 0x311D;
  10200. t['ehiragana'] = 0x3048;
  10201. t['ehookabove'] = 0x1EBB;
  10202. t['eibopomofo'] = 0x311F;
  10203. t['eight'] = 0x0038;
  10204. t['eightarabic'] = 0x0668;
  10205. t['eightbengali'] = 0x09EE;
  10206. t['eightcircle'] = 0x2467;
  10207. t['eightcircleinversesansserif'] = 0x2791;
  10208. t['eightdeva'] = 0x096E;
  10209. t['eighteencircle'] = 0x2471;
  10210. t['eighteenparen'] = 0x2485;
  10211. t['eighteenperiod'] = 0x2499;
  10212. t['eightgujarati'] = 0x0AEE;
  10213. t['eightgurmukhi'] = 0x0A6E;
  10214. t['eighthackarabic'] = 0x0668;
  10215. t['eighthangzhou'] = 0x3028;
  10216. t['eighthnotebeamed'] = 0x266B;
  10217. t['eightideographicparen'] = 0x3227;
  10218. t['eightinferior'] = 0x2088;
  10219. t['eightmonospace'] = 0xFF18;
  10220. t['eightoldstyle'] = 0xF738;
  10221. t['eightparen'] = 0x247B;
  10222. t['eightperiod'] = 0x248F;
  10223. t['eightpersian'] = 0x06F8;
  10224. t['eightroman'] = 0x2177;
  10225. t['eightsuperior'] = 0x2078;
  10226. t['eightthai'] = 0x0E58;
  10227. t['einvertedbreve'] = 0x0207;
  10228. t['eiotifiedcyrillic'] = 0x0465;
  10229. t['ekatakana'] = 0x30A8;
  10230. t['ekatakanahalfwidth'] = 0xFF74;
  10231. t['ekonkargurmukhi'] = 0x0A74;
  10232. t['ekorean'] = 0x3154;
  10233. t['elcyrillic'] = 0x043B;
  10234. t['element'] = 0x2208;
  10235. t['elevencircle'] = 0x246A;
  10236. t['elevenparen'] = 0x247E;
  10237. t['elevenperiod'] = 0x2492;
  10238. t['elevenroman'] = 0x217A;
  10239. t['ellipsis'] = 0x2026;
  10240. t['ellipsisvertical'] = 0x22EE;
  10241. t['emacron'] = 0x0113;
  10242. t['emacronacute'] = 0x1E17;
  10243. t['emacrongrave'] = 0x1E15;
  10244. t['emcyrillic'] = 0x043C;
  10245. t['emdash'] = 0x2014;
  10246. t['emdashvertical'] = 0xFE31;
  10247. t['emonospace'] = 0xFF45;
  10248. t['emphasismarkarmenian'] = 0x055B;
  10249. t['emptyset'] = 0x2205;
  10250. t['enbopomofo'] = 0x3123;
  10251. t['encyrillic'] = 0x043D;
  10252. t['endash'] = 0x2013;
  10253. t['endashvertical'] = 0xFE32;
  10254. t['endescendercyrillic'] = 0x04A3;
  10255. t['eng'] = 0x014B;
  10256. t['engbopomofo'] = 0x3125;
  10257. t['enghecyrillic'] = 0x04A5;
  10258. t['enhookcyrillic'] = 0x04C8;
  10259. t['enspace'] = 0x2002;
  10260. t['eogonek'] = 0x0119;
  10261. t['eokorean'] = 0x3153;
  10262. t['eopen'] = 0x025B;
  10263. t['eopenclosed'] = 0x029A;
  10264. t['eopenreversed'] = 0x025C;
  10265. t['eopenreversedclosed'] = 0x025E;
  10266. t['eopenreversedhook'] = 0x025D;
  10267. t['eparen'] = 0x24A0;
  10268. t['epsilon'] = 0x03B5;
  10269. t['epsilontonos'] = 0x03AD;
  10270. t['equal'] = 0x003D;
  10271. t['equalmonospace'] = 0xFF1D;
  10272. t['equalsmall'] = 0xFE66;
  10273. t['equalsuperior'] = 0x207C;
  10274. t['equivalence'] = 0x2261;
  10275. t['erbopomofo'] = 0x3126;
  10276. t['ercyrillic'] = 0x0440;
  10277. t['ereversed'] = 0x0258;
  10278. t['ereversedcyrillic'] = 0x044D;
  10279. t['escyrillic'] = 0x0441;
  10280. t['esdescendercyrillic'] = 0x04AB;
  10281. t['esh'] = 0x0283;
  10282. t['eshcurl'] = 0x0286;
  10283. t['eshortdeva'] = 0x090E;
  10284. t['eshortvowelsigndeva'] = 0x0946;
  10285. t['eshreversedloop'] = 0x01AA;
  10286. t['eshsquatreversed'] = 0x0285;
  10287. t['esmallhiragana'] = 0x3047;
  10288. t['esmallkatakana'] = 0x30A7;
  10289. t['esmallkatakanahalfwidth'] = 0xFF6A;
  10290. t['estimated'] = 0x212E;
  10291. t['esuperior'] = 0xF6EC;
  10292. t['eta'] = 0x03B7;
  10293. t['etarmenian'] = 0x0568;
  10294. t['etatonos'] = 0x03AE;
  10295. t['eth'] = 0x00F0;
  10296. t['etilde'] = 0x1EBD;
  10297. t['etildebelow'] = 0x1E1B;
  10298. t['etnahtafoukhhebrew'] = 0x0591;
  10299. t['etnahtafoukhlefthebrew'] = 0x0591;
  10300. t['etnahtahebrew'] = 0x0591;
  10301. t['etnahtalefthebrew'] = 0x0591;
  10302. t['eturned'] = 0x01DD;
  10303. t['eukorean'] = 0x3161;
  10304. t['euro'] = 0x20AC;
  10305. t['evowelsignbengali'] = 0x09C7;
  10306. t['evowelsigndeva'] = 0x0947;
  10307. t['evowelsigngujarati'] = 0x0AC7;
  10308. t['exclam'] = 0x0021;
  10309. t['exclamarmenian'] = 0x055C;
  10310. t['exclamdbl'] = 0x203C;
  10311. t['exclamdown'] = 0x00A1;
  10312. t['exclamdownsmall'] = 0xF7A1;
  10313. t['exclammonospace'] = 0xFF01;
  10314. t['exclamsmall'] = 0xF721;
  10315. t['existential'] = 0x2203;
  10316. t['ezh'] = 0x0292;
  10317. t['ezhcaron'] = 0x01EF;
  10318. t['ezhcurl'] = 0x0293;
  10319. t['ezhreversed'] = 0x01B9;
  10320. t['ezhtail'] = 0x01BA;
  10321. t['f'] = 0x0066;
  10322. t['fadeva'] = 0x095E;
  10323. t['fagurmukhi'] = 0x0A5E;
  10324. t['fahrenheit'] = 0x2109;
  10325. t['fathaarabic'] = 0x064E;
  10326. t['fathalowarabic'] = 0x064E;
  10327. t['fathatanarabic'] = 0x064B;
  10328. t['fbopomofo'] = 0x3108;
  10329. t['fcircle'] = 0x24D5;
  10330. t['fdotaccent'] = 0x1E1F;
  10331. t['feharabic'] = 0x0641;
  10332. t['feharmenian'] = 0x0586;
  10333. t['fehfinalarabic'] = 0xFED2;
  10334. t['fehinitialarabic'] = 0xFED3;
  10335. t['fehmedialarabic'] = 0xFED4;
  10336. t['feicoptic'] = 0x03E5;
  10337. t['female'] = 0x2640;
  10338. t['ff'] = 0xFB00;
  10339. t['ffi'] = 0xFB03;
  10340. t['ffl'] = 0xFB04;
  10341. t['fi'] = 0xFB01;
  10342. t['fifteencircle'] = 0x246E;
  10343. t['fifteenparen'] = 0x2482;
  10344. t['fifteenperiod'] = 0x2496;
  10345. t['figuredash'] = 0x2012;
  10346. t['filledbox'] = 0x25A0;
  10347. t['filledrect'] = 0x25AC;
  10348. t['finalkaf'] = 0x05DA;
  10349. t['finalkafdagesh'] = 0xFB3A;
  10350. t['finalkafdageshhebrew'] = 0xFB3A;
  10351. t['finalkafhebrew'] = 0x05DA;
  10352. t['finalmem'] = 0x05DD;
  10353. t['finalmemhebrew'] = 0x05DD;
  10354. t['finalnun'] = 0x05DF;
  10355. t['finalnunhebrew'] = 0x05DF;
  10356. t['finalpe'] = 0x05E3;
  10357. t['finalpehebrew'] = 0x05E3;
  10358. t['finaltsadi'] = 0x05E5;
  10359. t['finaltsadihebrew'] = 0x05E5;
  10360. t['firsttonechinese'] = 0x02C9;
  10361. t['fisheye'] = 0x25C9;
  10362. t['fitacyrillic'] = 0x0473;
  10363. t['five'] = 0x0035;
  10364. t['fivearabic'] = 0x0665;
  10365. t['fivebengali'] = 0x09EB;
  10366. t['fivecircle'] = 0x2464;
  10367. t['fivecircleinversesansserif'] = 0x278E;
  10368. t['fivedeva'] = 0x096B;
  10369. t['fiveeighths'] = 0x215D;
  10370. t['fivegujarati'] = 0x0AEB;
  10371. t['fivegurmukhi'] = 0x0A6B;
  10372. t['fivehackarabic'] = 0x0665;
  10373. t['fivehangzhou'] = 0x3025;
  10374. t['fiveideographicparen'] = 0x3224;
  10375. t['fiveinferior'] = 0x2085;
  10376. t['fivemonospace'] = 0xFF15;
  10377. t['fiveoldstyle'] = 0xF735;
  10378. t['fiveparen'] = 0x2478;
  10379. t['fiveperiod'] = 0x248C;
  10380. t['fivepersian'] = 0x06F5;
  10381. t['fiveroman'] = 0x2174;
  10382. t['fivesuperior'] = 0x2075;
  10383. t['fivethai'] = 0x0E55;
  10384. t['fl'] = 0xFB02;
  10385. t['florin'] = 0x0192;
  10386. t['fmonospace'] = 0xFF46;
  10387. t['fmsquare'] = 0x3399;
  10388. t['fofanthai'] = 0x0E1F;
  10389. t['fofathai'] = 0x0E1D;
  10390. t['fongmanthai'] = 0x0E4F;
  10391. t['forall'] = 0x2200;
  10392. t['four'] = 0x0034;
  10393. t['fourarabic'] = 0x0664;
  10394. t['fourbengali'] = 0x09EA;
  10395. t['fourcircle'] = 0x2463;
  10396. t['fourcircleinversesansserif'] = 0x278D;
  10397. t['fourdeva'] = 0x096A;
  10398. t['fourgujarati'] = 0x0AEA;
  10399. t['fourgurmukhi'] = 0x0A6A;
  10400. t['fourhackarabic'] = 0x0664;
  10401. t['fourhangzhou'] = 0x3024;
  10402. t['fourideographicparen'] = 0x3223;
  10403. t['fourinferior'] = 0x2084;
  10404. t['fourmonospace'] = 0xFF14;
  10405. t['fournumeratorbengali'] = 0x09F7;
  10406. t['fouroldstyle'] = 0xF734;
  10407. t['fourparen'] = 0x2477;
  10408. t['fourperiod'] = 0x248B;
  10409. t['fourpersian'] = 0x06F4;
  10410. t['fourroman'] = 0x2173;
  10411. t['foursuperior'] = 0x2074;
  10412. t['fourteencircle'] = 0x246D;
  10413. t['fourteenparen'] = 0x2481;
  10414. t['fourteenperiod'] = 0x2495;
  10415. t['fourthai'] = 0x0E54;
  10416. t['fourthtonechinese'] = 0x02CB;
  10417. t['fparen'] = 0x24A1;
  10418. t['fraction'] = 0x2044;
  10419. t['franc'] = 0x20A3;
  10420. t['g'] = 0x0067;
  10421. t['gabengali'] = 0x0997;
  10422. t['gacute'] = 0x01F5;
  10423. t['gadeva'] = 0x0917;
  10424. t['gafarabic'] = 0x06AF;
  10425. t['gaffinalarabic'] = 0xFB93;
  10426. t['gafinitialarabic'] = 0xFB94;
  10427. t['gafmedialarabic'] = 0xFB95;
  10428. t['gagujarati'] = 0x0A97;
  10429. t['gagurmukhi'] = 0x0A17;
  10430. t['gahiragana'] = 0x304C;
  10431. t['gakatakana'] = 0x30AC;
  10432. t['gamma'] = 0x03B3;
  10433. t['gammalatinsmall'] = 0x0263;
  10434. t['gammasuperior'] = 0x02E0;
  10435. t['gangiacoptic'] = 0x03EB;
  10436. t['gbopomofo'] = 0x310D;
  10437. t['gbreve'] = 0x011F;
  10438. t['gcaron'] = 0x01E7;
  10439. t['gcedilla'] = 0x0123;
  10440. t['gcircle'] = 0x24D6;
  10441. t['gcircumflex'] = 0x011D;
  10442. t['gcommaaccent'] = 0x0123;
  10443. t['gdot'] = 0x0121;
  10444. t['gdotaccent'] = 0x0121;
  10445. t['gecyrillic'] = 0x0433;
  10446. t['gehiragana'] = 0x3052;
  10447. t['gekatakana'] = 0x30B2;
  10448. t['geometricallyequal'] = 0x2251;
  10449. t['gereshaccenthebrew'] = 0x059C;
  10450. t['gereshhebrew'] = 0x05F3;
  10451. t['gereshmuqdamhebrew'] = 0x059D;
  10452. t['germandbls'] = 0x00DF;
  10453. t['gershayimaccenthebrew'] = 0x059E;
  10454. t['gershayimhebrew'] = 0x05F4;
  10455. t['getamark'] = 0x3013;
  10456. t['ghabengali'] = 0x0998;
  10457. t['ghadarmenian'] = 0x0572;
  10458. t['ghadeva'] = 0x0918;
  10459. t['ghagujarati'] = 0x0A98;
  10460. t['ghagurmukhi'] = 0x0A18;
  10461. t['ghainarabic'] = 0x063A;
  10462. t['ghainfinalarabic'] = 0xFECE;
  10463. t['ghaininitialarabic'] = 0xFECF;
  10464. t['ghainmedialarabic'] = 0xFED0;
  10465. t['ghemiddlehookcyrillic'] = 0x0495;
  10466. t['ghestrokecyrillic'] = 0x0493;
  10467. t['gheupturncyrillic'] = 0x0491;
  10468. t['ghhadeva'] = 0x095A;
  10469. t['ghhagurmukhi'] = 0x0A5A;
  10470. t['ghook'] = 0x0260;
  10471. t['ghzsquare'] = 0x3393;
  10472. t['gihiragana'] = 0x304E;
  10473. t['gikatakana'] = 0x30AE;
  10474. t['gimarmenian'] = 0x0563;
  10475. t['gimel'] = 0x05D2;
  10476. t['gimeldagesh'] = 0xFB32;
  10477. t['gimeldageshhebrew'] = 0xFB32;
  10478. t['gimelhebrew'] = 0x05D2;
  10479. t['gjecyrillic'] = 0x0453;
  10480. t['glottalinvertedstroke'] = 0x01BE;
  10481. t['glottalstop'] = 0x0294;
  10482. t['glottalstopinverted'] = 0x0296;
  10483. t['glottalstopmod'] = 0x02C0;
  10484. t['glottalstopreversed'] = 0x0295;
  10485. t['glottalstopreversedmod'] = 0x02C1;
  10486. t['glottalstopreversedsuperior'] = 0x02E4;
  10487. t['glottalstopstroke'] = 0x02A1;
  10488. t['glottalstopstrokereversed'] = 0x02A2;
  10489. t['gmacron'] = 0x1E21;
  10490. t['gmonospace'] = 0xFF47;
  10491. t['gohiragana'] = 0x3054;
  10492. t['gokatakana'] = 0x30B4;
  10493. t['gparen'] = 0x24A2;
  10494. t['gpasquare'] = 0x33AC;
  10495. t['gradient'] = 0x2207;
  10496. t['grave'] = 0x0060;
  10497. t['gravebelowcmb'] = 0x0316;
  10498. t['gravecmb'] = 0x0300;
  10499. t['gravecomb'] = 0x0300;
  10500. t['gravedeva'] = 0x0953;
  10501. t['gravelowmod'] = 0x02CE;
  10502. t['gravemonospace'] = 0xFF40;
  10503. t['gravetonecmb'] = 0x0340;
  10504. t['greater'] = 0x003E;
  10505. t['greaterequal'] = 0x2265;
  10506. t['greaterequalorless'] = 0x22DB;
  10507. t['greatermonospace'] = 0xFF1E;
  10508. t['greaterorequivalent'] = 0x2273;
  10509. t['greaterorless'] = 0x2277;
  10510. t['greateroverequal'] = 0x2267;
  10511. t['greatersmall'] = 0xFE65;
  10512. t['gscript'] = 0x0261;
  10513. t['gstroke'] = 0x01E5;
  10514. t['guhiragana'] = 0x3050;
  10515. t['guillemotleft'] = 0x00AB;
  10516. t['guillemotright'] = 0x00BB;
  10517. t['guilsinglleft'] = 0x2039;
  10518. t['guilsinglright'] = 0x203A;
  10519. t['gukatakana'] = 0x30B0;
  10520. t['guramusquare'] = 0x3318;
  10521. t['gysquare'] = 0x33C9;
  10522. t['h'] = 0x0068;
  10523. t['haabkhasiancyrillic'] = 0x04A9;
  10524. t['haaltonearabic'] = 0x06C1;
  10525. t['habengali'] = 0x09B9;
  10526. t['hadescendercyrillic'] = 0x04B3;
  10527. t['hadeva'] = 0x0939;
  10528. t['hagujarati'] = 0x0AB9;
  10529. t['hagurmukhi'] = 0x0A39;
  10530. t['haharabic'] = 0x062D;
  10531. t['hahfinalarabic'] = 0xFEA2;
  10532. t['hahinitialarabic'] = 0xFEA3;
  10533. t['hahiragana'] = 0x306F;
  10534. t['hahmedialarabic'] = 0xFEA4;
  10535. t['haitusquare'] = 0x332A;
  10536. t['hakatakana'] = 0x30CF;
  10537. t['hakatakanahalfwidth'] = 0xFF8A;
  10538. t['halantgurmukhi'] = 0x0A4D;
  10539. t['hamzaarabic'] = 0x0621;
  10540. t['hamzalowarabic'] = 0x0621;
  10541. t['hangulfiller'] = 0x3164;
  10542. t['hardsigncyrillic'] = 0x044A;
  10543. t['harpoonleftbarbup'] = 0x21BC;
  10544. t['harpoonrightbarbup'] = 0x21C0;
  10545. t['hasquare'] = 0x33CA;
  10546. t['hatafpatah'] = 0x05B2;
  10547. t['hatafpatah16'] = 0x05B2;
  10548. t['hatafpatah23'] = 0x05B2;
  10549. t['hatafpatah2f'] = 0x05B2;
  10550. t['hatafpatahhebrew'] = 0x05B2;
  10551. t['hatafpatahnarrowhebrew'] = 0x05B2;
  10552. t['hatafpatahquarterhebrew'] = 0x05B2;
  10553. t['hatafpatahwidehebrew'] = 0x05B2;
  10554. t['hatafqamats'] = 0x05B3;
  10555. t['hatafqamats1b'] = 0x05B3;
  10556. t['hatafqamats28'] = 0x05B3;
  10557. t['hatafqamats34'] = 0x05B3;
  10558. t['hatafqamatshebrew'] = 0x05B3;
  10559. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  10560. t['hatafqamatsquarterhebrew'] = 0x05B3;
  10561. t['hatafqamatswidehebrew'] = 0x05B3;
  10562. t['hatafsegol'] = 0x05B1;
  10563. t['hatafsegol17'] = 0x05B1;
  10564. t['hatafsegol24'] = 0x05B1;
  10565. t['hatafsegol30'] = 0x05B1;
  10566. t['hatafsegolhebrew'] = 0x05B1;
  10567. t['hatafsegolnarrowhebrew'] = 0x05B1;
  10568. t['hatafsegolquarterhebrew'] = 0x05B1;
  10569. t['hatafsegolwidehebrew'] = 0x05B1;
  10570. t['hbar'] = 0x0127;
  10571. t['hbopomofo'] = 0x310F;
  10572. t['hbrevebelow'] = 0x1E2B;
  10573. t['hcedilla'] = 0x1E29;
  10574. t['hcircle'] = 0x24D7;
  10575. t['hcircumflex'] = 0x0125;
  10576. t['hdieresis'] = 0x1E27;
  10577. t['hdotaccent'] = 0x1E23;
  10578. t['hdotbelow'] = 0x1E25;
  10579. t['he'] = 0x05D4;
  10580. t['heart'] = 0x2665;
  10581. t['heartsuitblack'] = 0x2665;
  10582. t['heartsuitwhite'] = 0x2661;
  10583. t['hedagesh'] = 0xFB34;
  10584. t['hedageshhebrew'] = 0xFB34;
  10585. t['hehaltonearabic'] = 0x06C1;
  10586. t['heharabic'] = 0x0647;
  10587. t['hehebrew'] = 0x05D4;
  10588. t['hehfinalaltonearabic'] = 0xFBA7;
  10589. t['hehfinalalttwoarabic'] = 0xFEEA;
  10590. t['hehfinalarabic'] = 0xFEEA;
  10591. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  10592. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  10593. t['hehinitialaltonearabic'] = 0xFBA8;
  10594. t['hehinitialarabic'] = 0xFEEB;
  10595. t['hehiragana'] = 0x3078;
  10596. t['hehmedialaltonearabic'] = 0xFBA9;
  10597. t['hehmedialarabic'] = 0xFEEC;
  10598. t['heiseierasquare'] = 0x337B;
  10599. t['hekatakana'] = 0x30D8;
  10600. t['hekatakanahalfwidth'] = 0xFF8D;
  10601. t['hekutaarusquare'] = 0x3336;
  10602. t['henghook'] = 0x0267;
  10603. t['herutusquare'] = 0x3339;
  10604. t['het'] = 0x05D7;
  10605. t['hethebrew'] = 0x05D7;
  10606. t['hhook'] = 0x0266;
  10607. t['hhooksuperior'] = 0x02B1;
  10608. t['hieuhacirclekorean'] = 0x327B;
  10609. t['hieuhaparenkorean'] = 0x321B;
  10610. t['hieuhcirclekorean'] = 0x326D;
  10611. t['hieuhkorean'] = 0x314E;
  10612. t['hieuhparenkorean'] = 0x320D;
  10613. t['hihiragana'] = 0x3072;
  10614. t['hikatakana'] = 0x30D2;
  10615. t['hikatakanahalfwidth'] = 0xFF8B;
  10616. t['hiriq'] = 0x05B4;
  10617. t['hiriq14'] = 0x05B4;
  10618. t['hiriq21'] = 0x05B4;
  10619. t['hiriq2d'] = 0x05B4;
  10620. t['hiriqhebrew'] = 0x05B4;
  10621. t['hiriqnarrowhebrew'] = 0x05B4;
  10622. t['hiriqquarterhebrew'] = 0x05B4;
  10623. t['hiriqwidehebrew'] = 0x05B4;
  10624. t['hlinebelow'] = 0x1E96;
  10625. t['hmonospace'] = 0xFF48;
  10626. t['hoarmenian'] = 0x0570;
  10627. t['hohipthai'] = 0x0E2B;
  10628. t['hohiragana'] = 0x307B;
  10629. t['hokatakana'] = 0x30DB;
  10630. t['hokatakanahalfwidth'] = 0xFF8E;
  10631. t['holam'] = 0x05B9;
  10632. t['holam19'] = 0x05B9;
  10633. t['holam26'] = 0x05B9;
  10634. t['holam32'] = 0x05B9;
  10635. t['holamhebrew'] = 0x05B9;
  10636. t['holamnarrowhebrew'] = 0x05B9;
  10637. t['holamquarterhebrew'] = 0x05B9;
  10638. t['holamwidehebrew'] = 0x05B9;
  10639. t['honokhukthai'] = 0x0E2E;
  10640. t['hookabovecomb'] = 0x0309;
  10641. t['hookcmb'] = 0x0309;
  10642. t['hookpalatalizedbelowcmb'] = 0x0321;
  10643. t['hookretroflexbelowcmb'] = 0x0322;
  10644. t['hoonsquare'] = 0x3342;
  10645. t['horicoptic'] = 0x03E9;
  10646. t['horizontalbar'] = 0x2015;
  10647. t['horncmb'] = 0x031B;
  10648. t['hotsprings'] = 0x2668;
  10649. t['house'] = 0x2302;
  10650. t['hparen'] = 0x24A3;
  10651. t['hsuperior'] = 0x02B0;
  10652. t['hturned'] = 0x0265;
  10653. t['huhiragana'] = 0x3075;
  10654. t['huiitosquare'] = 0x3333;
  10655. t['hukatakana'] = 0x30D5;
  10656. t['hukatakanahalfwidth'] = 0xFF8C;
  10657. t['hungarumlaut'] = 0x02DD;
  10658. t['hungarumlautcmb'] = 0x030B;
  10659. t['hv'] = 0x0195;
  10660. t['hyphen'] = 0x002D;
  10661. t['hypheninferior'] = 0xF6E5;
  10662. t['hyphenmonospace'] = 0xFF0D;
  10663. t['hyphensmall'] = 0xFE63;
  10664. t['hyphensuperior'] = 0xF6E6;
  10665. t['hyphentwo'] = 0x2010;
  10666. t['i'] = 0x0069;
  10667. t['iacute'] = 0x00ED;
  10668. t['iacyrillic'] = 0x044F;
  10669. t['ibengali'] = 0x0987;
  10670. t['ibopomofo'] = 0x3127;
  10671. t['ibreve'] = 0x012D;
  10672. t['icaron'] = 0x01D0;
  10673. t['icircle'] = 0x24D8;
  10674. t['icircumflex'] = 0x00EE;
  10675. t['icyrillic'] = 0x0456;
  10676. t['idblgrave'] = 0x0209;
  10677. t['ideographearthcircle'] = 0x328F;
  10678. t['ideographfirecircle'] = 0x328B;
  10679. t['ideographicallianceparen'] = 0x323F;
  10680. t['ideographiccallparen'] = 0x323A;
  10681. t['ideographiccentrecircle'] = 0x32A5;
  10682. t['ideographicclose'] = 0x3006;
  10683. t['ideographiccomma'] = 0x3001;
  10684. t['ideographiccommaleft'] = 0xFF64;
  10685. t['ideographiccongratulationparen'] = 0x3237;
  10686. t['ideographiccorrectcircle'] = 0x32A3;
  10687. t['ideographicearthparen'] = 0x322F;
  10688. t['ideographicenterpriseparen'] = 0x323D;
  10689. t['ideographicexcellentcircle'] = 0x329D;
  10690. t['ideographicfestivalparen'] = 0x3240;
  10691. t['ideographicfinancialcircle'] = 0x3296;
  10692. t['ideographicfinancialparen'] = 0x3236;
  10693. t['ideographicfireparen'] = 0x322B;
  10694. t['ideographichaveparen'] = 0x3232;
  10695. t['ideographichighcircle'] = 0x32A4;
  10696. t['ideographiciterationmark'] = 0x3005;
  10697. t['ideographiclaborcircle'] = 0x3298;
  10698. t['ideographiclaborparen'] = 0x3238;
  10699. t['ideographicleftcircle'] = 0x32A7;
  10700. t['ideographiclowcircle'] = 0x32A6;
  10701. t['ideographicmedicinecircle'] = 0x32A9;
  10702. t['ideographicmetalparen'] = 0x322E;
  10703. t['ideographicmoonparen'] = 0x322A;
  10704. t['ideographicnameparen'] = 0x3234;
  10705. t['ideographicperiod'] = 0x3002;
  10706. t['ideographicprintcircle'] = 0x329E;
  10707. t['ideographicreachparen'] = 0x3243;
  10708. t['ideographicrepresentparen'] = 0x3239;
  10709. t['ideographicresourceparen'] = 0x323E;
  10710. t['ideographicrightcircle'] = 0x32A8;
  10711. t['ideographicsecretcircle'] = 0x3299;
  10712. t['ideographicselfparen'] = 0x3242;
  10713. t['ideographicsocietyparen'] = 0x3233;
  10714. t['ideographicspace'] = 0x3000;
  10715. t['ideographicspecialparen'] = 0x3235;
  10716. t['ideographicstockparen'] = 0x3231;
  10717. t['ideographicstudyparen'] = 0x323B;
  10718. t['ideographicsunparen'] = 0x3230;
  10719. t['ideographicsuperviseparen'] = 0x323C;
  10720. t['ideographicwaterparen'] = 0x322C;
  10721. t['ideographicwoodparen'] = 0x322D;
  10722. t['ideographiczero'] = 0x3007;
  10723. t['ideographmetalcircle'] = 0x328E;
  10724. t['ideographmooncircle'] = 0x328A;
  10725. t['ideographnamecircle'] = 0x3294;
  10726. t['ideographsuncircle'] = 0x3290;
  10727. t['ideographwatercircle'] = 0x328C;
  10728. t['ideographwoodcircle'] = 0x328D;
  10729. t['ideva'] = 0x0907;
  10730. t['idieresis'] = 0x00EF;
  10731. t['idieresisacute'] = 0x1E2F;
  10732. t['idieresiscyrillic'] = 0x04E5;
  10733. t['idotbelow'] = 0x1ECB;
  10734. t['iebrevecyrillic'] = 0x04D7;
  10735. t['iecyrillic'] = 0x0435;
  10736. t['ieungacirclekorean'] = 0x3275;
  10737. t['ieungaparenkorean'] = 0x3215;
  10738. t['ieungcirclekorean'] = 0x3267;
  10739. t['ieungkorean'] = 0x3147;
  10740. t['ieungparenkorean'] = 0x3207;
  10741. t['igrave'] = 0x00EC;
  10742. t['igujarati'] = 0x0A87;
  10743. t['igurmukhi'] = 0x0A07;
  10744. t['ihiragana'] = 0x3044;
  10745. t['ihookabove'] = 0x1EC9;
  10746. t['iibengali'] = 0x0988;
  10747. t['iicyrillic'] = 0x0438;
  10748. t['iideva'] = 0x0908;
  10749. t['iigujarati'] = 0x0A88;
  10750. t['iigurmukhi'] = 0x0A08;
  10751. t['iimatragurmukhi'] = 0x0A40;
  10752. t['iinvertedbreve'] = 0x020B;
  10753. t['iishortcyrillic'] = 0x0439;
  10754. t['iivowelsignbengali'] = 0x09C0;
  10755. t['iivowelsigndeva'] = 0x0940;
  10756. t['iivowelsigngujarati'] = 0x0AC0;
  10757. t['ij'] = 0x0133;
  10758. t['ikatakana'] = 0x30A4;
  10759. t['ikatakanahalfwidth'] = 0xFF72;
  10760. t['ikorean'] = 0x3163;
  10761. t['ilde'] = 0x02DC;
  10762. t['iluyhebrew'] = 0x05AC;
  10763. t['imacron'] = 0x012B;
  10764. t['imacroncyrillic'] = 0x04E3;
  10765. t['imageorapproximatelyequal'] = 0x2253;
  10766. t['imatragurmukhi'] = 0x0A3F;
  10767. t['imonospace'] = 0xFF49;
  10768. t['increment'] = 0x2206;
  10769. t['infinity'] = 0x221E;
  10770. t['iniarmenian'] = 0x056B;
  10771. t['integral'] = 0x222B;
  10772. t['integralbottom'] = 0x2321;
  10773. t['integralbt'] = 0x2321;
  10774. t['integralex'] = 0xF8F5;
  10775. t['integraltop'] = 0x2320;
  10776. t['integraltp'] = 0x2320;
  10777. t['intersection'] = 0x2229;
  10778. t['intisquare'] = 0x3305;
  10779. t['invbullet'] = 0x25D8;
  10780. t['invcircle'] = 0x25D9;
  10781. t['invsmileface'] = 0x263B;
  10782. t['iocyrillic'] = 0x0451;
  10783. t['iogonek'] = 0x012F;
  10784. t['iota'] = 0x03B9;
  10785. t['iotadieresis'] = 0x03CA;
  10786. t['iotadieresistonos'] = 0x0390;
  10787. t['iotalatin'] = 0x0269;
  10788. t['iotatonos'] = 0x03AF;
  10789. t['iparen'] = 0x24A4;
  10790. t['irigurmukhi'] = 0x0A72;
  10791. t['ismallhiragana'] = 0x3043;
  10792. t['ismallkatakana'] = 0x30A3;
  10793. t['ismallkatakanahalfwidth'] = 0xFF68;
  10794. t['issharbengali'] = 0x09FA;
  10795. t['istroke'] = 0x0268;
  10796. t['isuperior'] = 0xF6ED;
  10797. t['iterationhiragana'] = 0x309D;
  10798. t['iterationkatakana'] = 0x30FD;
  10799. t['itilde'] = 0x0129;
  10800. t['itildebelow'] = 0x1E2D;
  10801. t['iubopomofo'] = 0x3129;
  10802. t['iucyrillic'] = 0x044E;
  10803. t['ivowelsignbengali'] = 0x09BF;
  10804. t['ivowelsigndeva'] = 0x093F;
  10805. t['ivowelsigngujarati'] = 0x0ABF;
  10806. t['izhitsacyrillic'] = 0x0475;
  10807. t['izhitsadblgravecyrillic'] = 0x0477;
  10808. t['j'] = 0x006A;
  10809. t['jaarmenian'] = 0x0571;
  10810. t['jabengali'] = 0x099C;
  10811. t['jadeva'] = 0x091C;
  10812. t['jagujarati'] = 0x0A9C;
  10813. t['jagurmukhi'] = 0x0A1C;
  10814. t['jbopomofo'] = 0x3110;
  10815. t['jcaron'] = 0x01F0;
  10816. t['jcircle'] = 0x24D9;
  10817. t['jcircumflex'] = 0x0135;
  10818. t['jcrossedtail'] = 0x029D;
  10819. t['jdotlessstroke'] = 0x025F;
  10820. t['jecyrillic'] = 0x0458;
  10821. t['jeemarabic'] = 0x062C;
  10822. t['jeemfinalarabic'] = 0xFE9E;
  10823. t['jeeminitialarabic'] = 0xFE9F;
  10824. t['jeemmedialarabic'] = 0xFEA0;
  10825. t['jeharabic'] = 0x0698;
  10826. t['jehfinalarabic'] = 0xFB8B;
  10827. t['jhabengali'] = 0x099D;
  10828. t['jhadeva'] = 0x091D;
  10829. t['jhagujarati'] = 0x0A9D;
  10830. t['jhagurmukhi'] = 0x0A1D;
  10831. t['jheharmenian'] = 0x057B;
  10832. t['jis'] = 0x3004;
  10833. t['jmonospace'] = 0xFF4A;
  10834. t['jparen'] = 0x24A5;
  10835. t['jsuperior'] = 0x02B2;
  10836. t['k'] = 0x006B;
  10837. t['kabashkircyrillic'] = 0x04A1;
  10838. t['kabengali'] = 0x0995;
  10839. t['kacute'] = 0x1E31;
  10840. t['kacyrillic'] = 0x043A;
  10841. t['kadescendercyrillic'] = 0x049B;
  10842. t['kadeva'] = 0x0915;
  10843. t['kaf'] = 0x05DB;
  10844. t['kafarabic'] = 0x0643;
  10845. t['kafdagesh'] = 0xFB3B;
  10846. t['kafdageshhebrew'] = 0xFB3B;
  10847. t['kaffinalarabic'] = 0xFEDA;
  10848. t['kafhebrew'] = 0x05DB;
  10849. t['kafinitialarabic'] = 0xFEDB;
  10850. t['kafmedialarabic'] = 0xFEDC;
  10851. t['kafrafehebrew'] = 0xFB4D;
  10852. t['kagujarati'] = 0x0A95;
  10853. t['kagurmukhi'] = 0x0A15;
  10854. t['kahiragana'] = 0x304B;
  10855. t['kahookcyrillic'] = 0x04C4;
  10856. t['kakatakana'] = 0x30AB;
  10857. t['kakatakanahalfwidth'] = 0xFF76;
  10858. t['kappa'] = 0x03BA;
  10859. t['kappasymbolgreek'] = 0x03F0;
  10860. t['kapyeounmieumkorean'] = 0x3171;
  10861. t['kapyeounphieuphkorean'] = 0x3184;
  10862. t['kapyeounpieupkorean'] = 0x3178;
  10863. t['kapyeounssangpieupkorean'] = 0x3179;
  10864. t['karoriisquare'] = 0x330D;
  10865. t['kashidaautoarabic'] = 0x0640;
  10866. t['kashidaautonosidebearingarabic'] = 0x0640;
  10867. t['kasmallkatakana'] = 0x30F5;
  10868. t['kasquare'] = 0x3384;
  10869. t['kasraarabic'] = 0x0650;
  10870. t['kasratanarabic'] = 0x064D;
  10871. t['kastrokecyrillic'] = 0x049F;
  10872. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  10873. t['kaverticalstrokecyrillic'] = 0x049D;
  10874. t['kbopomofo'] = 0x310E;
  10875. t['kcalsquare'] = 0x3389;
  10876. t['kcaron'] = 0x01E9;
  10877. t['kcedilla'] = 0x0137;
  10878. t['kcircle'] = 0x24DA;
  10879. t['kcommaaccent'] = 0x0137;
  10880. t['kdotbelow'] = 0x1E33;
  10881. t['keharmenian'] = 0x0584;
  10882. t['kehiragana'] = 0x3051;
  10883. t['kekatakana'] = 0x30B1;
  10884. t['kekatakanahalfwidth'] = 0xFF79;
  10885. t['kenarmenian'] = 0x056F;
  10886. t['kesmallkatakana'] = 0x30F6;
  10887. t['kgreenlandic'] = 0x0138;
  10888. t['khabengali'] = 0x0996;
  10889. t['khacyrillic'] = 0x0445;
  10890. t['khadeva'] = 0x0916;
  10891. t['khagujarati'] = 0x0A96;
  10892. t['khagurmukhi'] = 0x0A16;
  10893. t['khaharabic'] = 0x062E;
  10894. t['khahfinalarabic'] = 0xFEA6;
  10895. t['khahinitialarabic'] = 0xFEA7;
  10896. t['khahmedialarabic'] = 0xFEA8;
  10897. t['kheicoptic'] = 0x03E7;
  10898. t['khhadeva'] = 0x0959;
  10899. t['khhagurmukhi'] = 0x0A59;
  10900. t['khieukhacirclekorean'] = 0x3278;
  10901. t['khieukhaparenkorean'] = 0x3218;
  10902. t['khieukhcirclekorean'] = 0x326A;
  10903. t['khieukhkorean'] = 0x314B;
  10904. t['khieukhparenkorean'] = 0x320A;
  10905. t['khokhaithai'] = 0x0E02;
  10906. t['khokhonthai'] = 0x0E05;
  10907. t['khokhuatthai'] = 0x0E03;
  10908. t['khokhwaithai'] = 0x0E04;
  10909. t['khomutthai'] = 0x0E5B;
  10910. t['khook'] = 0x0199;
  10911. t['khorakhangthai'] = 0x0E06;
  10912. t['khzsquare'] = 0x3391;
  10913. t['kihiragana'] = 0x304D;
  10914. t['kikatakana'] = 0x30AD;
  10915. t['kikatakanahalfwidth'] = 0xFF77;
  10916. t['kiroguramusquare'] = 0x3315;
  10917. t['kiromeetorusquare'] = 0x3316;
  10918. t['kirosquare'] = 0x3314;
  10919. t['kiyeokacirclekorean'] = 0x326E;
  10920. t['kiyeokaparenkorean'] = 0x320E;
  10921. t['kiyeokcirclekorean'] = 0x3260;
  10922. t['kiyeokkorean'] = 0x3131;
  10923. t['kiyeokparenkorean'] = 0x3200;
  10924. t['kiyeoksioskorean'] = 0x3133;
  10925. t['kjecyrillic'] = 0x045C;
  10926. t['klinebelow'] = 0x1E35;
  10927. t['klsquare'] = 0x3398;
  10928. t['kmcubedsquare'] = 0x33A6;
  10929. t['kmonospace'] = 0xFF4B;
  10930. t['kmsquaredsquare'] = 0x33A2;
  10931. t['kohiragana'] = 0x3053;
  10932. t['kohmsquare'] = 0x33C0;
  10933. t['kokaithai'] = 0x0E01;
  10934. t['kokatakana'] = 0x30B3;
  10935. t['kokatakanahalfwidth'] = 0xFF7A;
  10936. t['kooposquare'] = 0x331E;
  10937. t['koppacyrillic'] = 0x0481;
  10938. t['koreanstandardsymbol'] = 0x327F;
  10939. t['koroniscmb'] = 0x0343;
  10940. t['kparen'] = 0x24A6;
  10941. t['kpasquare'] = 0x33AA;
  10942. t['ksicyrillic'] = 0x046F;
  10943. t['ktsquare'] = 0x33CF;
  10944. t['kturned'] = 0x029E;
  10945. t['kuhiragana'] = 0x304F;
  10946. t['kukatakana'] = 0x30AF;
  10947. t['kukatakanahalfwidth'] = 0xFF78;
  10948. t['kvsquare'] = 0x33B8;
  10949. t['kwsquare'] = 0x33BE;
  10950. t['l'] = 0x006C;
  10951. t['labengali'] = 0x09B2;
  10952. t['lacute'] = 0x013A;
  10953. t['ladeva'] = 0x0932;
  10954. t['lagujarati'] = 0x0AB2;
  10955. t['lagurmukhi'] = 0x0A32;
  10956. t['lakkhangyaothai'] = 0x0E45;
  10957. t['lamaleffinalarabic'] = 0xFEFC;
  10958. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  10959. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  10960. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  10961. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  10962. t['lamalefisolatedarabic'] = 0xFEFB;
  10963. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  10964. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  10965. t['lamarabic'] = 0x0644;
  10966. t['lambda'] = 0x03BB;
  10967. t['lambdastroke'] = 0x019B;
  10968. t['lamed'] = 0x05DC;
  10969. t['lameddagesh'] = 0xFB3C;
  10970. t['lameddageshhebrew'] = 0xFB3C;
  10971. t['lamedhebrew'] = 0x05DC;
  10972. t['lamfinalarabic'] = 0xFEDE;
  10973. t['lamhahinitialarabic'] = 0xFCCA;
  10974. t['laminitialarabic'] = 0xFEDF;
  10975. t['lamjeeminitialarabic'] = 0xFCC9;
  10976. t['lamkhahinitialarabic'] = 0xFCCB;
  10977. t['lamlamhehisolatedarabic'] = 0xFDF2;
  10978. t['lammedialarabic'] = 0xFEE0;
  10979. t['lammeemhahinitialarabic'] = 0xFD88;
  10980. t['lammeeminitialarabic'] = 0xFCCC;
  10981. t['largecircle'] = 0x25EF;
  10982. t['lbar'] = 0x019A;
  10983. t['lbelt'] = 0x026C;
  10984. t['lbopomofo'] = 0x310C;
  10985. t['lcaron'] = 0x013E;
  10986. t['lcedilla'] = 0x013C;
  10987. t['lcircle'] = 0x24DB;
  10988. t['lcircumflexbelow'] = 0x1E3D;
  10989. t['lcommaaccent'] = 0x013C;
  10990. t['ldot'] = 0x0140;
  10991. t['ldotaccent'] = 0x0140;
  10992. t['ldotbelow'] = 0x1E37;
  10993. t['ldotbelowmacron'] = 0x1E39;
  10994. t['leftangleabovecmb'] = 0x031A;
  10995. t['lefttackbelowcmb'] = 0x0318;
  10996. t['less'] = 0x003C;
  10997. t['lessequal'] = 0x2264;
  10998. t['lessequalorgreater'] = 0x22DA;
  10999. t['lessmonospace'] = 0xFF1C;
  11000. t['lessorequivalent'] = 0x2272;
  11001. t['lessorgreater'] = 0x2276;
  11002. t['lessoverequal'] = 0x2266;
  11003. t['lesssmall'] = 0xFE64;
  11004. t['lezh'] = 0x026E;
  11005. t['lfblock'] = 0x258C;
  11006. t['lhookretroflex'] = 0x026D;
  11007. t['lira'] = 0x20A4;
  11008. t['liwnarmenian'] = 0x056C;
  11009. t['lj'] = 0x01C9;
  11010. t['ljecyrillic'] = 0x0459;
  11011. t['ll'] = 0xF6C0;
  11012. t['lladeva'] = 0x0933;
  11013. t['llagujarati'] = 0x0AB3;
  11014. t['llinebelow'] = 0x1E3B;
  11015. t['llladeva'] = 0x0934;
  11016. t['llvocalicbengali'] = 0x09E1;
  11017. t['llvocalicdeva'] = 0x0961;
  11018. t['llvocalicvowelsignbengali'] = 0x09E3;
  11019. t['llvocalicvowelsigndeva'] = 0x0963;
  11020. t['lmiddletilde'] = 0x026B;
  11021. t['lmonospace'] = 0xFF4C;
  11022. t['lmsquare'] = 0x33D0;
  11023. t['lochulathai'] = 0x0E2C;
  11024. t['logicaland'] = 0x2227;
  11025. t['logicalnot'] = 0x00AC;
  11026. t['logicalnotreversed'] = 0x2310;
  11027. t['logicalor'] = 0x2228;
  11028. t['lolingthai'] = 0x0E25;
  11029. t['longs'] = 0x017F;
  11030. t['lowlinecenterline'] = 0xFE4E;
  11031. t['lowlinecmb'] = 0x0332;
  11032. t['lowlinedashed'] = 0xFE4D;
  11033. t['lozenge'] = 0x25CA;
  11034. t['lparen'] = 0x24A7;
  11035. t['lslash'] = 0x0142;
  11036. t['lsquare'] = 0x2113;
  11037. t['lsuperior'] = 0xF6EE;
  11038. t['ltshade'] = 0x2591;
  11039. t['luthai'] = 0x0E26;
  11040. t['lvocalicbengali'] = 0x098C;
  11041. t['lvocalicdeva'] = 0x090C;
  11042. t['lvocalicvowelsignbengali'] = 0x09E2;
  11043. t['lvocalicvowelsigndeva'] = 0x0962;
  11044. t['lxsquare'] = 0x33D3;
  11045. t['m'] = 0x006D;
  11046. t['mabengali'] = 0x09AE;
  11047. t['macron'] = 0x00AF;
  11048. t['macronbelowcmb'] = 0x0331;
  11049. t['macroncmb'] = 0x0304;
  11050. t['macronlowmod'] = 0x02CD;
  11051. t['macronmonospace'] = 0xFFE3;
  11052. t['macute'] = 0x1E3F;
  11053. t['madeva'] = 0x092E;
  11054. t['magujarati'] = 0x0AAE;
  11055. t['magurmukhi'] = 0x0A2E;
  11056. t['mahapakhhebrew'] = 0x05A4;
  11057. t['mahapakhlefthebrew'] = 0x05A4;
  11058. t['mahiragana'] = 0x307E;
  11059. t['maichattawalowleftthai'] = 0xF895;
  11060. t['maichattawalowrightthai'] = 0xF894;
  11061. t['maichattawathai'] = 0x0E4B;
  11062. t['maichattawaupperleftthai'] = 0xF893;
  11063. t['maieklowleftthai'] = 0xF88C;
  11064. t['maieklowrightthai'] = 0xF88B;
  11065. t['maiekthai'] = 0x0E48;
  11066. t['maiekupperleftthai'] = 0xF88A;
  11067. t['maihanakatleftthai'] = 0xF884;
  11068. t['maihanakatthai'] = 0x0E31;
  11069. t['maitaikhuleftthai'] = 0xF889;
  11070. t['maitaikhuthai'] = 0x0E47;
  11071. t['maitholowleftthai'] = 0xF88F;
  11072. t['maitholowrightthai'] = 0xF88E;
  11073. t['maithothai'] = 0x0E49;
  11074. t['maithoupperleftthai'] = 0xF88D;
  11075. t['maitrilowleftthai'] = 0xF892;
  11076. t['maitrilowrightthai'] = 0xF891;
  11077. t['maitrithai'] = 0x0E4A;
  11078. t['maitriupperleftthai'] = 0xF890;
  11079. t['maiyamokthai'] = 0x0E46;
  11080. t['makatakana'] = 0x30DE;
  11081. t['makatakanahalfwidth'] = 0xFF8F;
  11082. t['male'] = 0x2642;
  11083. t['mansyonsquare'] = 0x3347;
  11084. t['maqafhebrew'] = 0x05BE;
  11085. t['mars'] = 0x2642;
  11086. t['masoracirclehebrew'] = 0x05AF;
  11087. t['masquare'] = 0x3383;
  11088. t['mbopomofo'] = 0x3107;
  11089. t['mbsquare'] = 0x33D4;
  11090. t['mcircle'] = 0x24DC;
  11091. t['mcubedsquare'] = 0x33A5;
  11092. t['mdotaccent'] = 0x1E41;
  11093. t['mdotbelow'] = 0x1E43;
  11094. t['meemarabic'] = 0x0645;
  11095. t['meemfinalarabic'] = 0xFEE2;
  11096. t['meeminitialarabic'] = 0xFEE3;
  11097. t['meemmedialarabic'] = 0xFEE4;
  11098. t['meemmeeminitialarabic'] = 0xFCD1;
  11099. t['meemmeemisolatedarabic'] = 0xFC48;
  11100. t['meetorusquare'] = 0x334D;
  11101. t['mehiragana'] = 0x3081;
  11102. t['meizierasquare'] = 0x337E;
  11103. t['mekatakana'] = 0x30E1;
  11104. t['mekatakanahalfwidth'] = 0xFF92;
  11105. t['mem'] = 0x05DE;
  11106. t['memdagesh'] = 0xFB3E;
  11107. t['memdageshhebrew'] = 0xFB3E;
  11108. t['memhebrew'] = 0x05DE;
  11109. t['menarmenian'] = 0x0574;
  11110. t['merkhahebrew'] = 0x05A5;
  11111. t['merkhakefulahebrew'] = 0x05A6;
  11112. t['merkhakefulalefthebrew'] = 0x05A6;
  11113. t['merkhalefthebrew'] = 0x05A5;
  11114. t['mhook'] = 0x0271;
  11115. t['mhzsquare'] = 0x3392;
  11116. t['middledotkatakanahalfwidth'] = 0xFF65;
  11117. t['middot'] = 0x00B7;
  11118. t['mieumacirclekorean'] = 0x3272;
  11119. t['mieumaparenkorean'] = 0x3212;
  11120. t['mieumcirclekorean'] = 0x3264;
  11121. t['mieumkorean'] = 0x3141;
  11122. t['mieumpansioskorean'] = 0x3170;
  11123. t['mieumparenkorean'] = 0x3204;
  11124. t['mieumpieupkorean'] = 0x316E;
  11125. t['mieumsioskorean'] = 0x316F;
  11126. t['mihiragana'] = 0x307F;
  11127. t['mikatakana'] = 0x30DF;
  11128. t['mikatakanahalfwidth'] = 0xFF90;
  11129. t['minus'] = 0x2212;
  11130. t['minusbelowcmb'] = 0x0320;
  11131. t['minuscircle'] = 0x2296;
  11132. t['minusmod'] = 0x02D7;
  11133. t['minusplus'] = 0x2213;
  11134. t['minute'] = 0x2032;
  11135. t['miribaarusquare'] = 0x334A;
  11136. t['mirisquare'] = 0x3349;
  11137. t['mlonglegturned'] = 0x0270;
  11138. t['mlsquare'] = 0x3396;
  11139. t['mmcubedsquare'] = 0x33A3;
  11140. t['mmonospace'] = 0xFF4D;
  11141. t['mmsquaredsquare'] = 0x339F;
  11142. t['mohiragana'] = 0x3082;
  11143. t['mohmsquare'] = 0x33C1;
  11144. t['mokatakana'] = 0x30E2;
  11145. t['mokatakanahalfwidth'] = 0xFF93;
  11146. t['molsquare'] = 0x33D6;
  11147. t['momathai'] = 0x0E21;
  11148. t['moverssquare'] = 0x33A7;
  11149. t['moverssquaredsquare'] = 0x33A8;
  11150. t['mparen'] = 0x24A8;
  11151. t['mpasquare'] = 0x33AB;
  11152. t['mssquare'] = 0x33B3;
  11153. t['msuperior'] = 0xF6EF;
  11154. t['mturned'] = 0x026F;
  11155. t['mu'] = 0x00B5;
  11156. t['mu1'] = 0x00B5;
  11157. t['muasquare'] = 0x3382;
  11158. t['muchgreater'] = 0x226B;
  11159. t['muchless'] = 0x226A;
  11160. t['mufsquare'] = 0x338C;
  11161. t['mugreek'] = 0x03BC;
  11162. t['mugsquare'] = 0x338D;
  11163. t['muhiragana'] = 0x3080;
  11164. t['mukatakana'] = 0x30E0;
  11165. t['mukatakanahalfwidth'] = 0xFF91;
  11166. t['mulsquare'] = 0x3395;
  11167. t['multiply'] = 0x00D7;
  11168. t['mumsquare'] = 0x339B;
  11169. t['munahhebrew'] = 0x05A3;
  11170. t['munahlefthebrew'] = 0x05A3;
  11171. t['musicalnote'] = 0x266A;
  11172. t['musicalnotedbl'] = 0x266B;
  11173. t['musicflatsign'] = 0x266D;
  11174. t['musicsharpsign'] = 0x266F;
  11175. t['mussquare'] = 0x33B2;
  11176. t['muvsquare'] = 0x33B6;
  11177. t['muwsquare'] = 0x33BC;
  11178. t['mvmegasquare'] = 0x33B9;
  11179. t['mvsquare'] = 0x33B7;
  11180. t['mwmegasquare'] = 0x33BF;
  11181. t['mwsquare'] = 0x33BD;
  11182. t['n'] = 0x006E;
  11183. t['nabengali'] = 0x09A8;
  11184. t['nabla'] = 0x2207;
  11185. t['nacute'] = 0x0144;
  11186. t['nadeva'] = 0x0928;
  11187. t['nagujarati'] = 0x0AA8;
  11188. t['nagurmukhi'] = 0x0A28;
  11189. t['nahiragana'] = 0x306A;
  11190. t['nakatakana'] = 0x30CA;
  11191. t['nakatakanahalfwidth'] = 0xFF85;
  11192. t['napostrophe'] = 0x0149;
  11193. t['nasquare'] = 0x3381;
  11194. t['nbopomofo'] = 0x310B;
  11195. t['nbspace'] = 0x00A0;
  11196. t['ncaron'] = 0x0148;
  11197. t['ncedilla'] = 0x0146;
  11198. t['ncircle'] = 0x24DD;
  11199. t['ncircumflexbelow'] = 0x1E4B;
  11200. t['ncommaaccent'] = 0x0146;
  11201. t['ndotaccent'] = 0x1E45;
  11202. t['ndotbelow'] = 0x1E47;
  11203. t['nehiragana'] = 0x306D;
  11204. t['nekatakana'] = 0x30CD;
  11205. t['nekatakanahalfwidth'] = 0xFF88;
  11206. t['newsheqelsign'] = 0x20AA;
  11207. t['nfsquare'] = 0x338B;
  11208. t['ngabengali'] = 0x0999;
  11209. t['ngadeva'] = 0x0919;
  11210. t['ngagujarati'] = 0x0A99;
  11211. t['ngagurmukhi'] = 0x0A19;
  11212. t['ngonguthai'] = 0x0E07;
  11213. t['nhiragana'] = 0x3093;
  11214. t['nhookleft'] = 0x0272;
  11215. t['nhookretroflex'] = 0x0273;
  11216. t['nieunacirclekorean'] = 0x326F;
  11217. t['nieunaparenkorean'] = 0x320F;
  11218. t['nieuncieuckorean'] = 0x3135;
  11219. t['nieuncirclekorean'] = 0x3261;
  11220. t['nieunhieuhkorean'] = 0x3136;
  11221. t['nieunkorean'] = 0x3134;
  11222. t['nieunpansioskorean'] = 0x3168;
  11223. t['nieunparenkorean'] = 0x3201;
  11224. t['nieunsioskorean'] = 0x3167;
  11225. t['nieuntikeutkorean'] = 0x3166;
  11226. t['nihiragana'] = 0x306B;
  11227. t['nikatakana'] = 0x30CB;
  11228. t['nikatakanahalfwidth'] = 0xFF86;
  11229. t['nikhahitleftthai'] = 0xF899;
  11230. t['nikhahitthai'] = 0x0E4D;
  11231. t['nine'] = 0x0039;
  11232. t['ninearabic'] = 0x0669;
  11233. t['ninebengali'] = 0x09EF;
  11234. t['ninecircle'] = 0x2468;
  11235. t['ninecircleinversesansserif'] = 0x2792;
  11236. t['ninedeva'] = 0x096F;
  11237. t['ninegujarati'] = 0x0AEF;
  11238. t['ninegurmukhi'] = 0x0A6F;
  11239. t['ninehackarabic'] = 0x0669;
  11240. t['ninehangzhou'] = 0x3029;
  11241. t['nineideographicparen'] = 0x3228;
  11242. t['nineinferior'] = 0x2089;
  11243. t['ninemonospace'] = 0xFF19;
  11244. t['nineoldstyle'] = 0xF739;
  11245. t['nineparen'] = 0x247C;
  11246. t['nineperiod'] = 0x2490;
  11247. t['ninepersian'] = 0x06F9;
  11248. t['nineroman'] = 0x2178;
  11249. t['ninesuperior'] = 0x2079;
  11250. t['nineteencircle'] = 0x2472;
  11251. t['nineteenparen'] = 0x2486;
  11252. t['nineteenperiod'] = 0x249A;
  11253. t['ninethai'] = 0x0E59;
  11254. t['nj'] = 0x01CC;
  11255. t['njecyrillic'] = 0x045A;
  11256. t['nkatakana'] = 0x30F3;
  11257. t['nkatakanahalfwidth'] = 0xFF9D;
  11258. t['nlegrightlong'] = 0x019E;
  11259. t['nlinebelow'] = 0x1E49;
  11260. t['nmonospace'] = 0xFF4E;
  11261. t['nmsquare'] = 0x339A;
  11262. t['nnabengali'] = 0x09A3;
  11263. t['nnadeva'] = 0x0923;
  11264. t['nnagujarati'] = 0x0AA3;
  11265. t['nnagurmukhi'] = 0x0A23;
  11266. t['nnnadeva'] = 0x0929;
  11267. t['nohiragana'] = 0x306E;
  11268. t['nokatakana'] = 0x30CE;
  11269. t['nokatakanahalfwidth'] = 0xFF89;
  11270. t['nonbreakingspace'] = 0x00A0;
  11271. t['nonenthai'] = 0x0E13;
  11272. t['nonuthai'] = 0x0E19;
  11273. t['noonarabic'] = 0x0646;
  11274. t['noonfinalarabic'] = 0xFEE6;
  11275. t['noonghunnaarabic'] = 0x06BA;
  11276. t['noonghunnafinalarabic'] = 0xFB9F;
  11277. t['nooninitialarabic'] = 0xFEE7;
  11278. t['noonjeeminitialarabic'] = 0xFCD2;
  11279. t['noonjeemisolatedarabic'] = 0xFC4B;
  11280. t['noonmedialarabic'] = 0xFEE8;
  11281. t['noonmeeminitialarabic'] = 0xFCD5;
  11282. t['noonmeemisolatedarabic'] = 0xFC4E;
  11283. t['noonnoonfinalarabic'] = 0xFC8D;
  11284. t['notcontains'] = 0x220C;
  11285. t['notelement'] = 0x2209;
  11286. t['notelementof'] = 0x2209;
  11287. t['notequal'] = 0x2260;
  11288. t['notgreater'] = 0x226F;
  11289. t['notgreaternorequal'] = 0x2271;
  11290. t['notgreaternorless'] = 0x2279;
  11291. t['notidentical'] = 0x2262;
  11292. t['notless'] = 0x226E;
  11293. t['notlessnorequal'] = 0x2270;
  11294. t['notparallel'] = 0x2226;
  11295. t['notprecedes'] = 0x2280;
  11296. t['notsubset'] = 0x2284;
  11297. t['notsucceeds'] = 0x2281;
  11298. t['notsuperset'] = 0x2285;
  11299. t['nowarmenian'] = 0x0576;
  11300. t['nparen'] = 0x24A9;
  11301. t['nssquare'] = 0x33B1;
  11302. t['nsuperior'] = 0x207F;
  11303. t['ntilde'] = 0x00F1;
  11304. t['nu'] = 0x03BD;
  11305. t['nuhiragana'] = 0x306C;
  11306. t['nukatakana'] = 0x30CC;
  11307. t['nukatakanahalfwidth'] = 0xFF87;
  11308. t['nuktabengali'] = 0x09BC;
  11309. t['nuktadeva'] = 0x093C;
  11310. t['nuktagujarati'] = 0x0ABC;
  11311. t['nuktagurmukhi'] = 0x0A3C;
  11312. t['numbersign'] = 0x0023;
  11313. t['numbersignmonospace'] = 0xFF03;
  11314. t['numbersignsmall'] = 0xFE5F;
  11315. t['numeralsigngreek'] = 0x0374;
  11316. t['numeralsignlowergreek'] = 0x0375;
  11317. t['numero'] = 0x2116;
  11318. t['nun'] = 0x05E0;
  11319. t['nundagesh'] = 0xFB40;
  11320. t['nundageshhebrew'] = 0xFB40;
  11321. t['nunhebrew'] = 0x05E0;
  11322. t['nvsquare'] = 0x33B5;
  11323. t['nwsquare'] = 0x33BB;
  11324. t['nyabengali'] = 0x099E;
  11325. t['nyadeva'] = 0x091E;
  11326. t['nyagujarati'] = 0x0A9E;
  11327. t['nyagurmukhi'] = 0x0A1E;
  11328. t['o'] = 0x006F;
  11329. t['oacute'] = 0x00F3;
  11330. t['oangthai'] = 0x0E2D;
  11331. t['obarred'] = 0x0275;
  11332. t['obarredcyrillic'] = 0x04E9;
  11333. t['obarreddieresiscyrillic'] = 0x04EB;
  11334. t['obengali'] = 0x0993;
  11335. t['obopomofo'] = 0x311B;
  11336. t['obreve'] = 0x014F;
  11337. t['ocandradeva'] = 0x0911;
  11338. t['ocandragujarati'] = 0x0A91;
  11339. t['ocandravowelsigndeva'] = 0x0949;
  11340. t['ocandravowelsigngujarati'] = 0x0AC9;
  11341. t['ocaron'] = 0x01D2;
  11342. t['ocircle'] = 0x24DE;
  11343. t['ocircumflex'] = 0x00F4;
  11344. t['ocircumflexacute'] = 0x1ED1;
  11345. t['ocircumflexdotbelow'] = 0x1ED9;
  11346. t['ocircumflexgrave'] = 0x1ED3;
  11347. t['ocircumflexhookabove'] = 0x1ED5;
  11348. t['ocircumflextilde'] = 0x1ED7;
  11349. t['ocyrillic'] = 0x043E;
  11350. t['odblacute'] = 0x0151;
  11351. t['odblgrave'] = 0x020D;
  11352. t['odeva'] = 0x0913;
  11353. t['odieresis'] = 0x00F6;
  11354. t['odieresiscyrillic'] = 0x04E7;
  11355. t['odotbelow'] = 0x1ECD;
  11356. t['oe'] = 0x0153;
  11357. t['oekorean'] = 0x315A;
  11358. t['ogonek'] = 0x02DB;
  11359. t['ogonekcmb'] = 0x0328;
  11360. t['ograve'] = 0x00F2;
  11361. t['ogujarati'] = 0x0A93;
  11362. t['oharmenian'] = 0x0585;
  11363. t['ohiragana'] = 0x304A;
  11364. t['ohookabove'] = 0x1ECF;
  11365. t['ohorn'] = 0x01A1;
  11366. t['ohornacute'] = 0x1EDB;
  11367. t['ohorndotbelow'] = 0x1EE3;
  11368. t['ohorngrave'] = 0x1EDD;
  11369. t['ohornhookabove'] = 0x1EDF;
  11370. t['ohorntilde'] = 0x1EE1;
  11371. t['ohungarumlaut'] = 0x0151;
  11372. t['oi'] = 0x01A3;
  11373. t['oinvertedbreve'] = 0x020F;
  11374. t['okatakana'] = 0x30AA;
  11375. t['okatakanahalfwidth'] = 0xFF75;
  11376. t['okorean'] = 0x3157;
  11377. t['olehebrew'] = 0x05AB;
  11378. t['omacron'] = 0x014D;
  11379. t['omacronacute'] = 0x1E53;
  11380. t['omacrongrave'] = 0x1E51;
  11381. t['omdeva'] = 0x0950;
  11382. t['omega'] = 0x03C9;
  11383. t['omega1'] = 0x03D6;
  11384. t['omegacyrillic'] = 0x0461;
  11385. t['omegalatinclosed'] = 0x0277;
  11386. t['omegaroundcyrillic'] = 0x047B;
  11387. t['omegatitlocyrillic'] = 0x047D;
  11388. t['omegatonos'] = 0x03CE;
  11389. t['omgujarati'] = 0x0AD0;
  11390. t['omicron'] = 0x03BF;
  11391. t['omicrontonos'] = 0x03CC;
  11392. t['omonospace'] = 0xFF4F;
  11393. t['one'] = 0x0031;
  11394. t['onearabic'] = 0x0661;
  11395. t['onebengali'] = 0x09E7;
  11396. t['onecircle'] = 0x2460;
  11397. t['onecircleinversesansserif'] = 0x278A;
  11398. t['onedeva'] = 0x0967;
  11399. t['onedotenleader'] = 0x2024;
  11400. t['oneeighth'] = 0x215B;
  11401. t['onefitted'] = 0xF6DC;
  11402. t['onegujarati'] = 0x0AE7;
  11403. t['onegurmukhi'] = 0x0A67;
  11404. t['onehackarabic'] = 0x0661;
  11405. t['onehalf'] = 0x00BD;
  11406. t['onehangzhou'] = 0x3021;
  11407. t['oneideographicparen'] = 0x3220;
  11408. t['oneinferior'] = 0x2081;
  11409. t['onemonospace'] = 0xFF11;
  11410. t['onenumeratorbengali'] = 0x09F4;
  11411. t['oneoldstyle'] = 0xF731;
  11412. t['oneparen'] = 0x2474;
  11413. t['oneperiod'] = 0x2488;
  11414. t['onepersian'] = 0x06F1;
  11415. t['onequarter'] = 0x00BC;
  11416. t['oneroman'] = 0x2170;
  11417. t['onesuperior'] = 0x00B9;
  11418. t['onethai'] = 0x0E51;
  11419. t['onethird'] = 0x2153;
  11420. t['oogonek'] = 0x01EB;
  11421. t['oogonekmacron'] = 0x01ED;
  11422. t['oogurmukhi'] = 0x0A13;
  11423. t['oomatragurmukhi'] = 0x0A4B;
  11424. t['oopen'] = 0x0254;
  11425. t['oparen'] = 0x24AA;
  11426. t['openbullet'] = 0x25E6;
  11427. t['option'] = 0x2325;
  11428. t['ordfeminine'] = 0x00AA;
  11429. t['ordmasculine'] = 0x00BA;
  11430. t['orthogonal'] = 0x221F;
  11431. t['oshortdeva'] = 0x0912;
  11432. t['oshortvowelsigndeva'] = 0x094A;
  11433. t['oslash'] = 0x00F8;
  11434. t['oslashacute'] = 0x01FF;
  11435. t['osmallhiragana'] = 0x3049;
  11436. t['osmallkatakana'] = 0x30A9;
  11437. t['osmallkatakanahalfwidth'] = 0xFF6B;
  11438. t['ostrokeacute'] = 0x01FF;
  11439. t['osuperior'] = 0xF6F0;
  11440. t['otcyrillic'] = 0x047F;
  11441. t['otilde'] = 0x00F5;
  11442. t['otildeacute'] = 0x1E4D;
  11443. t['otildedieresis'] = 0x1E4F;
  11444. t['oubopomofo'] = 0x3121;
  11445. t['overline'] = 0x203E;
  11446. t['overlinecenterline'] = 0xFE4A;
  11447. t['overlinecmb'] = 0x0305;
  11448. t['overlinedashed'] = 0xFE49;
  11449. t['overlinedblwavy'] = 0xFE4C;
  11450. t['overlinewavy'] = 0xFE4B;
  11451. t['overscore'] = 0x00AF;
  11452. t['ovowelsignbengali'] = 0x09CB;
  11453. t['ovowelsigndeva'] = 0x094B;
  11454. t['ovowelsigngujarati'] = 0x0ACB;
  11455. t['p'] = 0x0070;
  11456. t['paampssquare'] = 0x3380;
  11457. t['paasentosquare'] = 0x332B;
  11458. t['pabengali'] = 0x09AA;
  11459. t['pacute'] = 0x1E55;
  11460. t['padeva'] = 0x092A;
  11461. t['pagedown'] = 0x21DF;
  11462. t['pageup'] = 0x21DE;
  11463. t['pagujarati'] = 0x0AAA;
  11464. t['pagurmukhi'] = 0x0A2A;
  11465. t['pahiragana'] = 0x3071;
  11466. t['paiyannoithai'] = 0x0E2F;
  11467. t['pakatakana'] = 0x30D1;
  11468. t['palatalizationcyrilliccmb'] = 0x0484;
  11469. t['palochkacyrillic'] = 0x04C0;
  11470. t['pansioskorean'] = 0x317F;
  11471. t['paragraph'] = 0x00B6;
  11472. t['parallel'] = 0x2225;
  11473. t['parenleft'] = 0x0028;
  11474. t['parenleftaltonearabic'] = 0xFD3E;
  11475. t['parenleftbt'] = 0xF8ED;
  11476. t['parenleftex'] = 0xF8EC;
  11477. t['parenleftinferior'] = 0x208D;
  11478. t['parenleftmonospace'] = 0xFF08;
  11479. t['parenleftsmall'] = 0xFE59;
  11480. t['parenleftsuperior'] = 0x207D;
  11481. t['parenlefttp'] = 0xF8EB;
  11482. t['parenleftvertical'] = 0xFE35;
  11483. t['parenright'] = 0x0029;
  11484. t['parenrightaltonearabic'] = 0xFD3F;
  11485. t['parenrightbt'] = 0xF8F8;
  11486. t['parenrightex'] = 0xF8F7;
  11487. t['parenrightinferior'] = 0x208E;
  11488. t['parenrightmonospace'] = 0xFF09;
  11489. t['parenrightsmall'] = 0xFE5A;
  11490. t['parenrightsuperior'] = 0x207E;
  11491. t['parenrighttp'] = 0xF8F6;
  11492. t['parenrightvertical'] = 0xFE36;
  11493. t['partialdiff'] = 0x2202;
  11494. t['paseqhebrew'] = 0x05C0;
  11495. t['pashtahebrew'] = 0x0599;
  11496. t['pasquare'] = 0x33A9;
  11497. t['patah'] = 0x05B7;
  11498. t['patah11'] = 0x05B7;
  11499. t['patah1d'] = 0x05B7;
  11500. t['patah2a'] = 0x05B7;
  11501. t['patahhebrew'] = 0x05B7;
  11502. t['patahnarrowhebrew'] = 0x05B7;
  11503. t['patahquarterhebrew'] = 0x05B7;
  11504. t['patahwidehebrew'] = 0x05B7;
  11505. t['pazerhebrew'] = 0x05A1;
  11506. t['pbopomofo'] = 0x3106;
  11507. t['pcircle'] = 0x24DF;
  11508. t['pdotaccent'] = 0x1E57;
  11509. t['pe'] = 0x05E4;
  11510. t['pecyrillic'] = 0x043F;
  11511. t['pedagesh'] = 0xFB44;
  11512. t['pedageshhebrew'] = 0xFB44;
  11513. t['peezisquare'] = 0x333B;
  11514. t['pefinaldageshhebrew'] = 0xFB43;
  11515. t['peharabic'] = 0x067E;
  11516. t['peharmenian'] = 0x057A;
  11517. t['pehebrew'] = 0x05E4;
  11518. t['pehfinalarabic'] = 0xFB57;
  11519. t['pehinitialarabic'] = 0xFB58;
  11520. t['pehiragana'] = 0x307A;
  11521. t['pehmedialarabic'] = 0xFB59;
  11522. t['pekatakana'] = 0x30DA;
  11523. t['pemiddlehookcyrillic'] = 0x04A7;
  11524. t['perafehebrew'] = 0xFB4E;
  11525. t['percent'] = 0x0025;
  11526. t['percentarabic'] = 0x066A;
  11527. t['percentmonospace'] = 0xFF05;
  11528. t['percentsmall'] = 0xFE6A;
  11529. t['period'] = 0x002E;
  11530. t['periodarmenian'] = 0x0589;
  11531. t['periodcentered'] = 0x00B7;
  11532. t['periodhalfwidth'] = 0xFF61;
  11533. t['periodinferior'] = 0xF6E7;
  11534. t['periodmonospace'] = 0xFF0E;
  11535. t['periodsmall'] = 0xFE52;
  11536. t['periodsuperior'] = 0xF6E8;
  11537. t['perispomenigreekcmb'] = 0x0342;
  11538. t['perpendicular'] = 0x22A5;
  11539. t['perthousand'] = 0x2030;
  11540. t['peseta'] = 0x20A7;
  11541. t['pfsquare'] = 0x338A;
  11542. t['phabengali'] = 0x09AB;
  11543. t['phadeva'] = 0x092B;
  11544. t['phagujarati'] = 0x0AAB;
  11545. t['phagurmukhi'] = 0x0A2B;
  11546. t['phi'] = 0x03C6;
  11547. t['phi1'] = 0x03D5;
  11548. t['phieuphacirclekorean'] = 0x327A;
  11549. t['phieuphaparenkorean'] = 0x321A;
  11550. t['phieuphcirclekorean'] = 0x326C;
  11551. t['phieuphkorean'] = 0x314D;
  11552. t['phieuphparenkorean'] = 0x320C;
  11553. t['philatin'] = 0x0278;
  11554. t['phinthuthai'] = 0x0E3A;
  11555. t['phisymbolgreek'] = 0x03D5;
  11556. t['phook'] = 0x01A5;
  11557. t['phophanthai'] = 0x0E1E;
  11558. t['phophungthai'] = 0x0E1C;
  11559. t['phosamphaothai'] = 0x0E20;
  11560. t['pi'] = 0x03C0;
  11561. t['pieupacirclekorean'] = 0x3273;
  11562. t['pieupaparenkorean'] = 0x3213;
  11563. t['pieupcieuckorean'] = 0x3176;
  11564. t['pieupcirclekorean'] = 0x3265;
  11565. t['pieupkiyeokkorean'] = 0x3172;
  11566. t['pieupkorean'] = 0x3142;
  11567. t['pieupparenkorean'] = 0x3205;
  11568. t['pieupsioskiyeokkorean'] = 0x3174;
  11569. t['pieupsioskorean'] = 0x3144;
  11570. t['pieupsiostikeutkorean'] = 0x3175;
  11571. t['pieupthieuthkorean'] = 0x3177;
  11572. t['pieuptikeutkorean'] = 0x3173;
  11573. t['pihiragana'] = 0x3074;
  11574. t['pikatakana'] = 0x30D4;
  11575. t['pisymbolgreek'] = 0x03D6;
  11576. t['piwrarmenian'] = 0x0583;
  11577. t['plus'] = 0x002B;
  11578. t['plusbelowcmb'] = 0x031F;
  11579. t['pluscircle'] = 0x2295;
  11580. t['plusminus'] = 0x00B1;
  11581. t['plusmod'] = 0x02D6;
  11582. t['plusmonospace'] = 0xFF0B;
  11583. t['plussmall'] = 0xFE62;
  11584. t['plussuperior'] = 0x207A;
  11585. t['pmonospace'] = 0xFF50;
  11586. t['pmsquare'] = 0x33D8;
  11587. t['pohiragana'] = 0x307D;
  11588. t['pointingindexdownwhite'] = 0x261F;
  11589. t['pointingindexleftwhite'] = 0x261C;
  11590. t['pointingindexrightwhite'] = 0x261E;
  11591. t['pointingindexupwhite'] = 0x261D;
  11592. t['pokatakana'] = 0x30DD;
  11593. t['poplathai'] = 0x0E1B;
  11594. t['postalmark'] = 0x3012;
  11595. t['postalmarkface'] = 0x3020;
  11596. t['pparen'] = 0x24AB;
  11597. t['precedes'] = 0x227A;
  11598. t['prescription'] = 0x211E;
  11599. t['primemod'] = 0x02B9;
  11600. t['primereversed'] = 0x2035;
  11601. t['product'] = 0x220F;
  11602. t['projective'] = 0x2305;
  11603. t['prolongedkana'] = 0x30FC;
  11604. t['propellor'] = 0x2318;
  11605. t['propersubset'] = 0x2282;
  11606. t['propersuperset'] = 0x2283;
  11607. t['proportion'] = 0x2237;
  11608. t['proportional'] = 0x221D;
  11609. t['psi'] = 0x03C8;
  11610. t['psicyrillic'] = 0x0471;
  11611. t['psilipneumatacyrilliccmb'] = 0x0486;
  11612. t['pssquare'] = 0x33B0;
  11613. t['puhiragana'] = 0x3077;
  11614. t['pukatakana'] = 0x30D7;
  11615. t['pvsquare'] = 0x33B4;
  11616. t['pwsquare'] = 0x33BA;
  11617. t['q'] = 0x0071;
  11618. t['qadeva'] = 0x0958;
  11619. t['qadmahebrew'] = 0x05A8;
  11620. t['qafarabic'] = 0x0642;
  11621. t['qaffinalarabic'] = 0xFED6;
  11622. t['qafinitialarabic'] = 0xFED7;
  11623. t['qafmedialarabic'] = 0xFED8;
  11624. t['qamats'] = 0x05B8;
  11625. t['qamats10'] = 0x05B8;
  11626. t['qamats1a'] = 0x05B8;
  11627. t['qamats1c'] = 0x05B8;
  11628. t['qamats27'] = 0x05B8;
  11629. t['qamats29'] = 0x05B8;
  11630. t['qamats33'] = 0x05B8;
  11631. t['qamatsde'] = 0x05B8;
  11632. t['qamatshebrew'] = 0x05B8;
  11633. t['qamatsnarrowhebrew'] = 0x05B8;
  11634. t['qamatsqatanhebrew'] = 0x05B8;
  11635. t['qamatsqatannarrowhebrew'] = 0x05B8;
  11636. t['qamatsqatanquarterhebrew'] = 0x05B8;
  11637. t['qamatsqatanwidehebrew'] = 0x05B8;
  11638. t['qamatsquarterhebrew'] = 0x05B8;
  11639. t['qamatswidehebrew'] = 0x05B8;
  11640. t['qarneyparahebrew'] = 0x059F;
  11641. t['qbopomofo'] = 0x3111;
  11642. t['qcircle'] = 0x24E0;
  11643. t['qhook'] = 0x02A0;
  11644. t['qmonospace'] = 0xFF51;
  11645. t['qof'] = 0x05E7;
  11646. t['qofdagesh'] = 0xFB47;
  11647. t['qofdageshhebrew'] = 0xFB47;
  11648. t['qofhebrew'] = 0x05E7;
  11649. t['qparen'] = 0x24AC;
  11650. t['quarternote'] = 0x2669;
  11651. t['qubuts'] = 0x05BB;
  11652. t['qubuts18'] = 0x05BB;
  11653. t['qubuts25'] = 0x05BB;
  11654. t['qubuts31'] = 0x05BB;
  11655. t['qubutshebrew'] = 0x05BB;
  11656. t['qubutsnarrowhebrew'] = 0x05BB;
  11657. t['qubutsquarterhebrew'] = 0x05BB;
  11658. t['qubutswidehebrew'] = 0x05BB;
  11659. t['question'] = 0x003F;
  11660. t['questionarabic'] = 0x061F;
  11661. t['questionarmenian'] = 0x055E;
  11662. t['questiondown'] = 0x00BF;
  11663. t['questiondownsmall'] = 0xF7BF;
  11664. t['questiongreek'] = 0x037E;
  11665. t['questionmonospace'] = 0xFF1F;
  11666. t['questionsmall'] = 0xF73F;
  11667. t['quotedbl'] = 0x0022;
  11668. t['quotedblbase'] = 0x201E;
  11669. t['quotedblleft'] = 0x201C;
  11670. t['quotedblmonospace'] = 0xFF02;
  11671. t['quotedblprime'] = 0x301E;
  11672. t['quotedblprimereversed'] = 0x301D;
  11673. t['quotedblright'] = 0x201D;
  11674. t['quoteleft'] = 0x2018;
  11675. t['quoteleftreversed'] = 0x201B;
  11676. t['quotereversed'] = 0x201B;
  11677. t['quoteright'] = 0x2019;
  11678. t['quoterightn'] = 0x0149;
  11679. t['quotesinglbase'] = 0x201A;
  11680. t['quotesingle'] = 0x0027;
  11681. t['quotesinglemonospace'] = 0xFF07;
  11682. t['r'] = 0x0072;
  11683. t['raarmenian'] = 0x057C;
  11684. t['rabengali'] = 0x09B0;
  11685. t['racute'] = 0x0155;
  11686. t['radeva'] = 0x0930;
  11687. t['radical'] = 0x221A;
  11688. t['radicalex'] = 0xF8E5;
  11689. t['radoverssquare'] = 0x33AE;
  11690. t['radoverssquaredsquare'] = 0x33AF;
  11691. t['radsquare'] = 0x33AD;
  11692. t['rafe'] = 0x05BF;
  11693. t['rafehebrew'] = 0x05BF;
  11694. t['ragujarati'] = 0x0AB0;
  11695. t['ragurmukhi'] = 0x0A30;
  11696. t['rahiragana'] = 0x3089;
  11697. t['rakatakana'] = 0x30E9;
  11698. t['rakatakanahalfwidth'] = 0xFF97;
  11699. t['ralowerdiagonalbengali'] = 0x09F1;
  11700. t['ramiddlediagonalbengali'] = 0x09F0;
  11701. t['ramshorn'] = 0x0264;
  11702. t['ratio'] = 0x2236;
  11703. t['rbopomofo'] = 0x3116;
  11704. t['rcaron'] = 0x0159;
  11705. t['rcedilla'] = 0x0157;
  11706. t['rcircle'] = 0x24E1;
  11707. t['rcommaaccent'] = 0x0157;
  11708. t['rdblgrave'] = 0x0211;
  11709. t['rdotaccent'] = 0x1E59;
  11710. t['rdotbelow'] = 0x1E5B;
  11711. t['rdotbelowmacron'] = 0x1E5D;
  11712. t['referencemark'] = 0x203B;
  11713. t['reflexsubset'] = 0x2286;
  11714. t['reflexsuperset'] = 0x2287;
  11715. t['registered'] = 0x00AE;
  11716. t['registersans'] = 0xF8E8;
  11717. t['registerserif'] = 0xF6DA;
  11718. t['reharabic'] = 0x0631;
  11719. t['reharmenian'] = 0x0580;
  11720. t['rehfinalarabic'] = 0xFEAE;
  11721. t['rehiragana'] = 0x308C;
  11722. t['rekatakana'] = 0x30EC;
  11723. t['rekatakanahalfwidth'] = 0xFF9A;
  11724. t['resh'] = 0x05E8;
  11725. t['reshdageshhebrew'] = 0xFB48;
  11726. t['reshhebrew'] = 0x05E8;
  11727. t['reversedtilde'] = 0x223D;
  11728. t['reviahebrew'] = 0x0597;
  11729. t['reviamugrashhebrew'] = 0x0597;
  11730. t['revlogicalnot'] = 0x2310;
  11731. t['rfishhook'] = 0x027E;
  11732. t['rfishhookreversed'] = 0x027F;
  11733. t['rhabengali'] = 0x09DD;
  11734. t['rhadeva'] = 0x095D;
  11735. t['rho'] = 0x03C1;
  11736. t['rhook'] = 0x027D;
  11737. t['rhookturned'] = 0x027B;
  11738. t['rhookturnedsuperior'] = 0x02B5;
  11739. t['rhosymbolgreek'] = 0x03F1;
  11740. t['rhotichookmod'] = 0x02DE;
  11741. t['rieulacirclekorean'] = 0x3271;
  11742. t['rieulaparenkorean'] = 0x3211;
  11743. t['rieulcirclekorean'] = 0x3263;
  11744. t['rieulhieuhkorean'] = 0x3140;
  11745. t['rieulkiyeokkorean'] = 0x313A;
  11746. t['rieulkiyeoksioskorean'] = 0x3169;
  11747. t['rieulkorean'] = 0x3139;
  11748. t['rieulmieumkorean'] = 0x313B;
  11749. t['rieulpansioskorean'] = 0x316C;
  11750. t['rieulparenkorean'] = 0x3203;
  11751. t['rieulphieuphkorean'] = 0x313F;
  11752. t['rieulpieupkorean'] = 0x313C;
  11753. t['rieulpieupsioskorean'] = 0x316B;
  11754. t['rieulsioskorean'] = 0x313D;
  11755. t['rieulthieuthkorean'] = 0x313E;
  11756. t['rieultikeutkorean'] = 0x316A;
  11757. t['rieulyeorinhieuhkorean'] = 0x316D;
  11758. t['rightangle'] = 0x221F;
  11759. t['righttackbelowcmb'] = 0x0319;
  11760. t['righttriangle'] = 0x22BF;
  11761. t['rihiragana'] = 0x308A;
  11762. t['rikatakana'] = 0x30EA;
  11763. t['rikatakanahalfwidth'] = 0xFF98;
  11764. t['ring'] = 0x02DA;
  11765. t['ringbelowcmb'] = 0x0325;
  11766. t['ringcmb'] = 0x030A;
  11767. t['ringhalfleft'] = 0x02BF;
  11768. t['ringhalfleftarmenian'] = 0x0559;
  11769. t['ringhalfleftbelowcmb'] = 0x031C;
  11770. t['ringhalfleftcentered'] = 0x02D3;
  11771. t['ringhalfright'] = 0x02BE;
  11772. t['ringhalfrightbelowcmb'] = 0x0339;
  11773. t['ringhalfrightcentered'] = 0x02D2;
  11774. t['rinvertedbreve'] = 0x0213;
  11775. t['rittorusquare'] = 0x3351;
  11776. t['rlinebelow'] = 0x1E5F;
  11777. t['rlongleg'] = 0x027C;
  11778. t['rlonglegturned'] = 0x027A;
  11779. t['rmonospace'] = 0xFF52;
  11780. t['rohiragana'] = 0x308D;
  11781. t['rokatakana'] = 0x30ED;
  11782. t['rokatakanahalfwidth'] = 0xFF9B;
  11783. t['roruathai'] = 0x0E23;
  11784. t['rparen'] = 0x24AD;
  11785. t['rrabengali'] = 0x09DC;
  11786. t['rradeva'] = 0x0931;
  11787. t['rragurmukhi'] = 0x0A5C;
  11788. t['rreharabic'] = 0x0691;
  11789. t['rrehfinalarabic'] = 0xFB8D;
  11790. t['rrvocalicbengali'] = 0x09E0;
  11791. t['rrvocalicdeva'] = 0x0960;
  11792. t['rrvocalicgujarati'] = 0x0AE0;
  11793. t['rrvocalicvowelsignbengali'] = 0x09C4;
  11794. t['rrvocalicvowelsigndeva'] = 0x0944;
  11795. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  11796. t['rsuperior'] = 0xF6F1;
  11797. t['rtblock'] = 0x2590;
  11798. t['rturned'] = 0x0279;
  11799. t['rturnedsuperior'] = 0x02B4;
  11800. t['ruhiragana'] = 0x308B;
  11801. t['rukatakana'] = 0x30EB;
  11802. t['rukatakanahalfwidth'] = 0xFF99;
  11803. t['rupeemarkbengali'] = 0x09F2;
  11804. t['rupeesignbengali'] = 0x09F3;
  11805. t['rupiah'] = 0xF6DD;
  11806. t['ruthai'] = 0x0E24;
  11807. t['rvocalicbengali'] = 0x098B;
  11808. t['rvocalicdeva'] = 0x090B;
  11809. t['rvocalicgujarati'] = 0x0A8B;
  11810. t['rvocalicvowelsignbengali'] = 0x09C3;
  11811. t['rvocalicvowelsigndeva'] = 0x0943;
  11812. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  11813. t['s'] = 0x0073;
  11814. t['sabengali'] = 0x09B8;
  11815. t['sacute'] = 0x015B;
  11816. t['sacutedotaccent'] = 0x1E65;
  11817. t['sadarabic'] = 0x0635;
  11818. t['sadeva'] = 0x0938;
  11819. t['sadfinalarabic'] = 0xFEBA;
  11820. t['sadinitialarabic'] = 0xFEBB;
  11821. t['sadmedialarabic'] = 0xFEBC;
  11822. t['sagujarati'] = 0x0AB8;
  11823. t['sagurmukhi'] = 0x0A38;
  11824. t['sahiragana'] = 0x3055;
  11825. t['sakatakana'] = 0x30B5;
  11826. t['sakatakanahalfwidth'] = 0xFF7B;
  11827. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  11828. t['samekh'] = 0x05E1;
  11829. t['samekhdagesh'] = 0xFB41;
  11830. t['samekhdageshhebrew'] = 0xFB41;
  11831. t['samekhhebrew'] = 0x05E1;
  11832. t['saraaathai'] = 0x0E32;
  11833. t['saraaethai'] = 0x0E41;
  11834. t['saraaimaimalaithai'] = 0x0E44;
  11835. t['saraaimaimuanthai'] = 0x0E43;
  11836. t['saraamthai'] = 0x0E33;
  11837. t['saraathai'] = 0x0E30;
  11838. t['saraethai'] = 0x0E40;
  11839. t['saraiileftthai'] = 0xF886;
  11840. t['saraiithai'] = 0x0E35;
  11841. t['saraileftthai'] = 0xF885;
  11842. t['saraithai'] = 0x0E34;
  11843. t['saraothai'] = 0x0E42;
  11844. t['saraueeleftthai'] = 0xF888;
  11845. t['saraueethai'] = 0x0E37;
  11846. t['saraueleftthai'] = 0xF887;
  11847. t['sarauethai'] = 0x0E36;
  11848. t['sarauthai'] = 0x0E38;
  11849. t['sarauuthai'] = 0x0E39;
  11850. t['sbopomofo'] = 0x3119;
  11851. t['scaron'] = 0x0161;
  11852. t['scarondotaccent'] = 0x1E67;
  11853. t['scedilla'] = 0x015F;
  11854. t['schwa'] = 0x0259;
  11855. t['schwacyrillic'] = 0x04D9;
  11856. t['schwadieresiscyrillic'] = 0x04DB;
  11857. t['schwahook'] = 0x025A;
  11858. t['scircle'] = 0x24E2;
  11859. t['scircumflex'] = 0x015D;
  11860. t['scommaaccent'] = 0x0219;
  11861. t['sdotaccent'] = 0x1E61;
  11862. t['sdotbelow'] = 0x1E63;
  11863. t['sdotbelowdotaccent'] = 0x1E69;
  11864. t['seagullbelowcmb'] = 0x033C;
  11865. t['second'] = 0x2033;
  11866. t['secondtonechinese'] = 0x02CA;
  11867. t['section'] = 0x00A7;
  11868. t['seenarabic'] = 0x0633;
  11869. t['seenfinalarabic'] = 0xFEB2;
  11870. t['seeninitialarabic'] = 0xFEB3;
  11871. t['seenmedialarabic'] = 0xFEB4;
  11872. t['segol'] = 0x05B6;
  11873. t['segol13'] = 0x05B6;
  11874. t['segol1f'] = 0x05B6;
  11875. t['segol2c'] = 0x05B6;
  11876. t['segolhebrew'] = 0x05B6;
  11877. t['segolnarrowhebrew'] = 0x05B6;
  11878. t['segolquarterhebrew'] = 0x05B6;
  11879. t['segoltahebrew'] = 0x0592;
  11880. t['segolwidehebrew'] = 0x05B6;
  11881. t['seharmenian'] = 0x057D;
  11882. t['sehiragana'] = 0x305B;
  11883. t['sekatakana'] = 0x30BB;
  11884. t['sekatakanahalfwidth'] = 0xFF7E;
  11885. t['semicolon'] = 0x003B;
  11886. t['semicolonarabic'] = 0x061B;
  11887. t['semicolonmonospace'] = 0xFF1B;
  11888. t['semicolonsmall'] = 0xFE54;
  11889. t['semivoicedmarkkana'] = 0x309C;
  11890. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  11891. t['sentisquare'] = 0x3322;
  11892. t['sentosquare'] = 0x3323;
  11893. t['seven'] = 0x0037;
  11894. t['sevenarabic'] = 0x0667;
  11895. t['sevenbengali'] = 0x09ED;
  11896. t['sevencircle'] = 0x2466;
  11897. t['sevencircleinversesansserif'] = 0x2790;
  11898. t['sevendeva'] = 0x096D;
  11899. t['seveneighths'] = 0x215E;
  11900. t['sevengujarati'] = 0x0AED;
  11901. t['sevengurmukhi'] = 0x0A6D;
  11902. t['sevenhackarabic'] = 0x0667;
  11903. t['sevenhangzhou'] = 0x3027;
  11904. t['sevenideographicparen'] = 0x3226;
  11905. t['seveninferior'] = 0x2087;
  11906. t['sevenmonospace'] = 0xFF17;
  11907. t['sevenoldstyle'] = 0xF737;
  11908. t['sevenparen'] = 0x247A;
  11909. t['sevenperiod'] = 0x248E;
  11910. t['sevenpersian'] = 0x06F7;
  11911. t['sevenroman'] = 0x2176;
  11912. t['sevensuperior'] = 0x2077;
  11913. t['seventeencircle'] = 0x2470;
  11914. t['seventeenparen'] = 0x2484;
  11915. t['seventeenperiod'] = 0x2498;
  11916. t['seventhai'] = 0x0E57;
  11917. t['sfthyphen'] = 0x00AD;
  11918. t['shaarmenian'] = 0x0577;
  11919. t['shabengali'] = 0x09B6;
  11920. t['shacyrillic'] = 0x0448;
  11921. t['shaddaarabic'] = 0x0651;
  11922. t['shaddadammaarabic'] = 0xFC61;
  11923. t['shaddadammatanarabic'] = 0xFC5E;
  11924. t['shaddafathaarabic'] = 0xFC60;
  11925. t['shaddakasraarabic'] = 0xFC62;
  11926. t['shaddakasratanarabic'] = 0xFC5F;
  11927. t['shade'] = 0x2592;
  11928. t['shadedark'] = 0x2593;
  11929. t['shadelight'] = 0x2591;
  11930. t['shademedium'] = 0x2592;
  11931. t['shadeva'] = 0x0936;
  11932. t['shagujarati'] = 0x0AB6;
  11933. t['shagurmukhi'] = 0x0A36;
  11934. t['shalshelethebrew'] = 0x0593;
  11935. t['shbopomofo'] = 0x3115;
  11936. t['shchacyrillic'] = 0x0449;
  11937. t['sheenarabic'] = 0x0634;
  11938. t['sheenfinalarabic'] = 0xFEB6;
  11939. t['sheeninitialarabic'] = 0xFEB7;
  11940. t['sheenmedialarabic'] = 0xFEB8;
  11941. t['sheicoptic'] = 0x03E3;
  11942. t['sheqel'] = 0x20AA;
  11943. t['sheqelhebrew'] = 0x20AA;
  11944. t['sheva'] = 0x05B0;
  11945. t['sheva115'] = 0x05B0;
  11946. t['sheva15'] = 0x05B0;
  11947. t['sheva22'] = 0x05B0;
  11948. t['sheva2e'] = 0x05B0;
  11949. t['shevahebrew'] = 0x05B0;
  11950. t['shevanarrowhebrew'] = 0x05B0;
  11951. t['shevaquarterhebrew'] = 0x05B0;
  11952. t['shevawidehebrew'] = 0x05B0;
  11953. t['shhacyrillic'] = 0x04BB;
  11954. t['shimacoptic'] = 0x03ED;
  11955. t['shin'] = 0x05E9;
  11956. t['shindagesh'] = 0xFB49;
  11957. t['shindageshhebrew'] = 0xFB49;
  11958. t['shindageshshindot'] = 0xFB2C;
  11959. t['shindageshshindothebrew'] = 0xFB2C;
  11960. t['shindageshsindot'] = 0xFB2D;
  11961. t['shindageshsindothebrew'] = 0xFB2D;
  11962. t['shindothebrew'] = 0x05C1;
  11963. t['shinhebrew'] = 0x05E9;
  11964. t['shinshindot'] = 0xFB2A;
  11965. t['shinshindothebrew'] = 0xFB2A;
  11966. t['shinsindot'] = 0xFB2B;
  11967. t['shinsindothebrew'] = 0xFB2B;
  11968. t['shook'] = 0x0282;
  11969. t['sigma'] = 0x03C3;
  11970. t['sigma1'] = 0x03C2;
  11971. t['sigmafinal'] = 0x03C2;
  11972. t['sigmalunatesymbolgreek'] = 0x03F2;
  11973. t['sihiragana'] = 0x3057;
  11974. t['sikatakana'] = 0x30B7;
  11975. t['sikatakanahalfwidth'] = 0xFF7C;
  11976. t['siluqhebrew'] = 0x05BD;
  11977. t['siluqlefthebrew'] = 0x05BD;
  11978. t['similar'] = 0x223C;
  11979. t['sindothebrew'] = 0x05C2;
  11980. t['siosacirclekorean'] = 0x3274;
  11981. t['siosaparenkorean'] = 0x3214;
  11982. t['sioscieuckorean'] = 0x317E;
  11983. t['sioscirclekorean'] = 0x3266;
  11984. t['sioskiyeokkorean'] = 0x317A;
  11985. t['sioskorean'] = 0x3145;
  11986. t['siosnieunkorean'] = 0x317B;
  11987. t['siosparenkorean'] = 0x3206;
  11988. t['siospieupkorean'] = 0x317D;
  11989. t['siostikeutkorean'] = 0x317C;
  11990. t['six'] = 0x0036;
  11991. t['sixarabic'] = 0x0666;
  11992. t['sixbengali'] = 0x09EC;
  11993. t['sixcircle'] = 0x2465;
  11994. t['sixcircleinversesansserif'] = 0x278F;
  11995. t['sixdeva'] = 0x096C;
  11996. t['sixgujarati'] = 0x0AEC;
  11997. t['sixgurmukhi'] = 0x0A6C;
  11998. t['sixhackarabic'] = 0x0666;
  11999. t['sixhangzhou'] = 0x3026;
  12000. t['sixideographicparen'] = 0x3225;
  12001. t['sixinferior'] = 0x2086;
  12002. t['sixmonospace'] = 0xFF16;
  12003. t['sixoldstyle'] = 0xF736;
  12004. t['sixparen'] = 0x2479;
  12005. t['sixperiod'] = 0x248D;
  12006. t['sixpersian'] = 0x06F6;
  12007. t['sixroman'] = 0x2175;
  12008. t['sixsuperior'] = 0x2076;
  12009. t['sixteencircle'] = 0x246F;
  12010. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  12011. t['sixteenparen'] = 0x2483;
  12012. t['sixteenperiod'] = 0x2497;
  12013. t['sixthai'] = 0x0E56;
  12014. t['slash'] = 0x002F;
  12015. t['slashmonospace'] = 0xFF0F;
  12016. t['slong'] = 0x017F;
  12017. t['slongdotaccent'] = 0x1E9B;
  12018. t['smileface'] = 0x263A;
  12019. t['smonospace'] = 0xFF53;
  12020. t['sofpasuqhebrew'] = 0x05C3;
  12021. t['softhyphen'] = 0x00AD;
  12022. t['softsigncyrillic'] = 0x044C;
  12023. t['sohiragana'] = 0x305D;
  12024. t['sokatakana'] = 0x30BD;
  12025. t['sokatakanahalfwidth'] = 0xFF7F;
  12026. t['soliduslongoverlaycmb'] = 0x0338;
  12027. t['solidusshortoverlaycmb'] = 0x0337;
  12028. t['sorusithai'] = 0x0E29;
  12029. t['sosalathai'] = 0x0E28;
  12030. t['sosothai'] = 0x0E0B;
  12031. t['sosuathai'] = 0x0E2A;
  12032. t['space'] = 0x0020;
  12033. t['spacehackarabic'] = 0x0020;
  12034. t['spade'] = 0x2660;
  12035. t['spadesuitblack'] = 0x2660;
  12036. t['spadesuitwhite'] = 0x2664;
  12037. t['sparen'] = 0x24AE;
  12038. t['squarebelowcmb'] = 0x033B;
  12039. t['squarecc'] = 0x33C4;
  12040. t['squarecm'] = 0x339D;
  12041. t['squarediagonalcrosshatchfill'] = 0x25A9;
  12042. t['squarehorizontalfill'] = 0x25A4;
  12043. t['squarekg'] = 0x338F;
  12044. t['squarekm'] = 0x339E;
  12045. t['squarekmcapital'] = 0x33CE;
  12046. t['squareln'] = 0x33D1;
  12047. t['squarelog'] = 0x33D2;
  12048. t['squaremg'] = 0x338E;
  12049. t['squaremil'] = 0x33D5;
  12050. t['squaremm'] = 0x339C;
  12051. t['squaremsquared'] = 0x33A1;
  12052. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  12053. t['squareupperlefttolowerrightfill'] = 0x25A7;
  12054. t['squareupperrighttolowerleftfill'] = 0x25A8;
  12055. t['squareverticalfill'] = 0x25A5;
  12056. t['squarewhitewithsmallblack'] = 0x25A3;
  12057. t['srsquare'] = 0x33DB;
  12058. t['ssabengali'] = 0x09B7;
  12059. t['ssadeva'] = 0x0937;
  12060. t['ssagujarati'] = 0x0AB7;
  12061. t['ssangcieuckorean'] = 0x3149;
  12062. t['ssanghieuhkorean'] = 0x3185;
  12063. t['ssangieungkorean'] = 0x3180;
  12064. t['ssangkiyeokkorean'] = 0x3132;
  12065. t['ssangnieunkorean'] = 0x3165;
  12066. t['ssangpieupkorean'] = 0x3143;
  12067. t['ssangsioskorean'] = 0x3146;
  12068. t['ssangtikeutkorean'] = 0x3138;
  12069. t['ssuperior'] = 0xF6F2;
  12070. t['sterling'] = 0x00A3;
  12071. t['sterlingmonospace'] = 0xFFE1;
  12072. t['strokelongoverlaycmb'] = 0x0336;
  12073. t['strokeshortoverlaycmb'] = 0x0335;
  12074. t['subset'] = 0x2282;
  12075. t['subsetnotequal'] = 0x228A;
  12076. t['subsetorequal'] = 0x2286;
  12077. t['succeeds'] = 0x227B;
  12078. t['suchthat'] = 0x220B;
  12079. t['suhiragana'] = 0x3059;
  12080. t['sukatakana'] = 0x30B9;
  12081. t['sukatakanahalfwidth'] = 0xFF7D;
  12082. t['sukunarabic'] = 0x0652;
  12083. t['summation'] = 0x2211;
  12084. t['sun'] = 0x263C;
  12085. t['superset'] = 0x2283;
  12086. t['supersetnotequal'] = 0x228B;
  12087. t['supersetorequal'] = 0x2287;
  12088. t['svsquare'] = 0x33DC;
  12089. t['syouwaerasquare'] = 0x337C;
  12090. t['t'] = 0x0074;
  12091. t['tabengali'] = 0x09A4;
  12092. t['tackdown'] = 0x22A4;
  12093. t['tackleft'] = 0x22A3;
  12094. t['tadeva'] = 0x0924;
  12095. t['tagujarati'] = 0x0AA4;
  12096. t['tagurmukhi'] = 0x0A24;
  12097. t['taharabic'] = 0x0637;
  12098. t['tahfinalarabic'] = 0xFEC2;
  12099. t['tahinitialarabic'] = 0xFEC3;
  12100. t['tahiragana'] = 0x305F;
  12101. t['tahmedialarabic'] = 0xFEC4;
  12102. t['taisyouerasquare'] = 0x337D;
  12103. t['takatakana'] = 0x30BF;
  12104. t['takatakanahalfwidth'] = 0xFF80;
  12105. t['tatweelarabic'] = 0x0640;
  12106. t['tau'] = 0x03C4;
  12107. t['tav'] = 0x05EA;
  12108. t['tavdages'] = 0xFB4A;
  12109. t['tavdagesh'] = 0xFB4A;
  12110. t['tavdageshhebrew'] = 0xFB4A;
  12111. t['tavhebrew'] = 0x05EA;
  12112. t['tbar'] = 0x0167;
  12113. t['tbopomofo'] = 0x310A;
  12114. t['tcaron'] = 0x0165;
  12115. t['tccurl'] = 0x02A8;
  12116. t['tcedilla'] = 0x0163;
  12117. t['tcheharabic'] = 0x0686;
  12118. t['tchehfinalarabic'] = 0xFB7B;
  12119. t['tchehinitialarabic'] = 0xFB7C;
  12120. t['tchehmedialarabic'] = 0xFB7D;
  12121. t['tcircle'] = 0x24E3;
  12122. t['tcircumflexbelow'] = 0x1E71;
  12123. t['tcommaaccent'] = 0x0163;
  12124. t['tdieresis'] = 0x1E97;
  12125. t['tdotaccent'] = 0x1E6B;
  12126. t['tdotbelow'] = 0x1E6D;
  12127. t['tecyrillic'] = 0x0442;
  12128. t['tedescendercyrillic'] = 0x04AD;
  12129. t['teharabic'] = 0x062A;
  12130. t['tehfinalarabic'] = 0xFE96;
  12131. t['tehhahinitialarabic'] = 0xFCA2;
  12132. t['tehhahisolatedarabic'] = 0xFC0C;
  12133. t['tehinitialarabic'] = 0xFE97;
  12134. t['tehiragana'] = 0x3066;
  12135. t['tehjeeminitialarabic'] = 0xFCA1;
  12136. t['tehjeemisolatedarabic'] = 0xFC0B;
  12137. t['tehmarbutaarabic'] = 0x0629;
  12138. t['tehmarbutafinalarabic'] = 0xFE94;
  12139. t['tehmedialarabic'] = 0xFE98;
  12140. t['tehmeeminitialarabic'] = 0xFCA4;
  12141. t['tehmeemisolatedarabic'] = 0xFC0E;
  12142. t['tehnoonfinalarabic'] = 0xFC73;
  12143. t['tekatakana'] = 0x30C6;
  12144. t['tekatakanahalfwidth'] = 0xFF83;
  12145. t['telephone'] = 0x2121;
  12146. t['telephoneblack'] = 0x260E;
  12147. t['telishagedolahebrew'] = 0x05A0;
  12148. t['telishaqetanahebrew'] = 0x05A9;
  12149. t['tencircle'] = 0x2469;
  12150. t['tenideographicparen'] = 0x3229;
  12151. t['tenparen'] = 0x247D;
  12152. t['tenperiod'] = 0x2491;
  12153. t['tenroman'] = 0x2179;
  12154. t['tesh'] = 0x02A7;
  12155. t['tet'] = 0x05D8;
  12156. t['tetdagesh'] = 0xFB38;
  12157. t['tetdageshhebrew'] = 0xFB38;
  12158. t['tethebrew'] = 0x05D8;
  12159. t['tetsecyrillic'] = 0x04B5;
  12160. t['tevirhebrew'] = 0x059B;
  12161. t['tevirlefthebrew'] = 0x059B;
  12162. t['thabengali'] = 0x09A5;
  12163. t['thadeva'] = 0x0925;
  12164. t['thagujarati'] = 0x0AA5;
  12165. t['thagurmukhi'] = 0x0A25;
  12166. t['thalarabic'] = 0x0630;
  12167. t['thalfinalarabic'] = 0xFEAC;
  12168. t['thanthakhatlowleftthai'] = 0xF898;
  12169. t['thanthakhatlowrightthai'] = 0xF897;
  12170. t['thanthakhatthai'] = 0x0E4C;
  12171. t['thanthakhatupperleftthai'] = 0xF896;
  12172. t['theharabic'] = 0x062B;
  12173. t['thehfinalarabic'] = 0xFE9A;
  12174. t['thehinitialarabic'] = 0xFE9B;
  12175. t['thehmedialarabic'] = 0xFE9C;
  12176. t['thereexists'] = 0x2203;
  12177. t['therefore'] = 0x2234;
  12178. t['theta'] = 0x03B8;
  12179. t['theta1'] = 0x03D1;
  12180. t['thetasymbolgreek'] = 0x03D1;
  12181. t['thieuthacirclekorean'] = 0x3279;
  12182. t['thieuthaparenkorean'] = 0x3219;
  12183. t['thieuthcirclekorean'] = 0x326B;
  12184. t['thieuthkorean'] = 0x314C;
  12185. t['thieuthparenkorean'] = 0x320B;
  12186. t['thirteencircle'] = 0x246C;
  12187. t['thirteenparen'] = 0x2480;
  12188. t['thirteenperiod'] = 0x2494;
  12189. t['thonangmonthothai'] = 0x0E11;
  12190. t['thook'] = 0x01AD;
  12191. t['thophuthaothai'] = 0x0E12;
  12192. t['thorn'] = 0x00FE;
  12193. t['thothahanthai'] = 0x0E17;
  12194. t['thothanthai'] = 0x0E10;
  12195. t['thothongthai'] = 0x0E18;
  12196. t['thothungthai'] = 0x0E16;
  12197. t['thousandcyrillic'] = 0x0482;
  12198. t['thousandsseparatorarabic'] = 0x066C;
  12199. t['thousandsseparatorpersian'] = 0x066C;
  12200. t['three'] = 0x0033;
  12201. t['threearabic'] = 0x0663;
  12202. t['threebengali'] = 0x09E9;
  12203. t['threecircle'] = 0x2462;
  12204. t['threecircleinversesansserif'] = 0x278C;
  12205. t['threedeva'] = 0x0969;
  12206. t['threeeighths'] = 0x215C;
  12207. t['threegujarati'] = 0x0AE9;
  12208. t['threegurmukhi'] = 0x0A69;
  12209. t['threehackarabic'] = 0x0663;
  12210. t['threehangzhou'] = 0x3023;
  12211. t['threeideographicparen'] = 0x3222;
  12212. t['threeinferior'] = 0x2083;
  12213. t['threemonospace'] = 0xFF13;
  12214. t['threenumeratorbengali'] = 0x09F6;
  12215. t['threeoldstyle'] = 0xF733;
  12216. t['threeparen'] = 0x2476;
  12217. t['threeperiod'] = 0x248A;
  12218. t['threepersian'] = 0x06F3;
  12219. t['threequarters'] = 0x00BE;
  12220. t['threequartersemdash'] = 0xF6DE;
  12221. t['threeroman'] = 0x2172;
  12222. t['threesuperior'] = 0x00B3;
  12223. t['threethai'] = 0x0E53;
  12224. t['thzsquare'] = 0x3394;
  12225. t['tihiragana'] = 0x3061;
  12226. t['tikatakana'] = 0x30C1;
  12227. t['tikatakanahalfwidth'] = 0xFF81;
  12228. t['tikeutacirclekorean'] = 0x3270;
  12229. t['tikeutaparenkorean'] = 0x3210;
  12230. t['tikeutcirclekorean'] = 0x3262;
  12231. t['tikeutkorean'] = 0x3137;
  12232. t['tikeutparenkorean'] = 0x3202;
  12233. t['tilde'] = 0x02DC;
  12234. t['tildebelowcmb'] = 0x0330;
  12235. t['tildecmb'] = 0x0303;
  12236. t['tildecomb'] = 0x0303;
  12237. t['tildedoublecmb'] = 0x0360;
  12238. t['tildeoperator'] = 0x223C;
  12239. t['tildeoverlaycmb'] = 0x0334;
  12240. t['tildeverticalcmb'] = 0x033E;
  12241. t['timescircle'] = 0x2297;
  12242. t['tipehahebrew'] = 0x0596;
  12243. t['tipehalefthebrew'] = 0x0596;
  12244. t['tippigurmukhi'] = 0x0A70;
  12245. t['titlocyrilliccmb'] = 0x0483;
  12246. t['tiwnarmenian'] = 0x057F;
  12247. t['tlinebelow'] = 0x1E6F;
  12248. t['tmonospace'] = 0xFF54;
  12249. t['toarmenian'] = 0x0569;
  12250. t['tohiragana'] = 0x3068;
  12251. t['tokatakana'] = 0x30C8;
  12252. t['tokatakanahalfwidth'] = 0xFF84;
  12253. t['tonebarextrahighmod'] = 0x02E5;
  12254. t['tonebarextralowmod'] = 0x02E9;
  12255. t['tonebarhighmod'] = 0x02E6;
  12256. t['tonebarlowmod'] = 0x02E8;
  12257. t['tonebarmidmod'] = 0x02E7;
  12258. t['tonefive'] = 0x01BD;
  12259. t['tonesix'] = 0x0185;
  12260. t['tonetwo'] = 0x01A8;
  12261. t['tonos'] = 0x0384;
  12262. t['tonsquare'] = 0x3327;
  12263. t['topatakthai'] = 0x0E0F;
  12264. t['tortoiseshellbracketleft'] = 0x3014;
  12265. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  12266. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  12267. t['tortoiseshellbracketright'] = 0x3015;
  12268. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  12269. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  12270. t['totaothai'] = 0x0E15;
  12271. t['tpalatalhook'] = 0x01AB;
  12272. t['tparen'] = 0x24AF;
  12273. t['trademark'] = 0x2122;
  12274. t['trademarksans'] = 0xF8EA;
  12275. t['trademarkserif'] = 0xF6DB;
  12276. t['tretroflexhook'] = 0x0288;
  12277. t['triagdn'] = 0x25BC;
  12278. t['triaglf'] = 0x25C4;
  12279. t['triagrt'] = 0x25BA;
  12280. t['triagup'] = 0x25B2;
  12281. t['ts'] = 0x02A6;
  12282. t['tsadi'] = 0x05E6;
  12283. t['tsadidagesh'] = 0xFB46;
  12284. t['tsadidageshhebrew'] = 0xFB46;
  12285. t['tsadihebrew'] = 0x05E6;
  12286. t['tsecyrillic'] = 0x0446;
  12287. t['tsere'] = 0x05B5;
  12288. t['tsere12'] = 0x05B5;
  12289. t['tsere1e'] = 0x05B5;
  12290. t['tsere2b'] = 0x05B5;
  12291. t['tserehebrew'] = 0x05B5;
  12292. t['tserenarrowhebrew'] = 0x05B5;
  12293. t['tserequarterhebrew'] = 0x05B5;
  12294. t['tserewidehebrew'] = 0x05B5;
  12295. t['tshecyrillic'] = 0x045B;
  12296. t['tsuperior'] = 0xF6F3;
  12297. t['ttabengali'] = 0x099F;
  12298. t['ttadeva'] = 0x091F;
  12299. t['ttagujarati'] = 0x0A9F;
  12300. t['ttagurmukhi'] = 0x0A1F;
  12301. t['tteharabic'] = 0x0679;
  12302. t['ttehfinalarabic'] = 0xFB67;
  12303. t['ttehinitialarabic'] = 0xFB68;
  12304. t['ttehmedialarabic'] = 0xFB69;
  12305. t['tthabengali'] = 0x09A0;
  12306. t['tthadeva'] = 0x0920;
  12307. t['tthagujarati'] = 0x0AA0;
  12308. t['tthagurmukhi'] = 0x0A20;
  12309. t['tturned'] = 0x0287;
  12310. t['tuhiragana'] = 0x3064;
  12311. t['tukatakana'] = 0x30C4;
  12312. t['tukatakanahalfwidth'] = 0xFF82;
  12313. t['tusmallhiragana'] = 0x3063;
  12314. t['tusmallkatakana'] = 0x30C3;
  12315. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  12316. t['twelvecircle'] = 0x246B;
  12317. t['twelveparen'] = 0x247F;
  12318. t['twelveperiod'] = 0x2493;
  12319. t['twelveroman'] = 0x217B;
  12320. t['twentycircle'] = 0x2473;
  12321. t['twentyhangzhou'] = 0x5344;
  12322. t['twentyparen'] = 0x2487;
  12323. t['twentyperiod'] = 0x249B;
  12324. t['two'] = 0x0032;
  12325. t['twoarabic'] = 0x0662;
  12326. t['twobengali'] = 0x09E8;
  12327. t['twocircle'] = 0x2461;
  12328. t['twocircleinversesansserif'] = 0x278B;
  12329. t['twodeva'] = 0x0968;
  12330. t['twodotenleader'] = 0x2025;
  12331. t['twodotleader'] = 0x2025;
  12332. t['twodotleadervertical'] = 0xFE30;
  12333. t['twogujarati'] = 0x0AE8;
  12334. t['twogurmukhi'] = 0x0A68;
  12335. t['twohackarabic'] = 0x0662;
  12336. t['twohangzhou'] = 0x3022;
  12337. t['twoideographicparen'] = 0x3221;
  12338. t['twoinferior'] = 0x2082;
  12339. t['twomonospace'] = 0xFF12;
  12340. t['twonumeratorbengali'] = 0x09F5;
  12341. t['twooldstyle'] = 0xF732;
  12342. t['twoparen'] = 0x2475;
  12343. t['twoperiod'] = 0x2489;
  12344. t['twopersian'] = 0x06F2;
  12345. t['tworoman'] = 0x2171;
  12346. t['twostroke'] = 0x01BB;
  12347. t['twosuperior'] = 0x00B2;
  12348. t['twothai'] = 0x0E52;
  12349. t['twothirds'] = 0x2154;
  12350. t['u'] = 0x0075;
  12351. t['uacute'] = 0x00FA;
  12352. t['ubar'] = 0x0289;
  12353. t['ubengali'] = 0x0989;
  12354. t['ubopomofo'] = 0x3128;
  12355. t['ubreve'] = 0x016D;
  12356. t['ucaron'] = 0x01D4;
  12357. t['ucircle'] = 0x24E4;
  12358. t['ucircumflex'] = 0x00FB;
  12359. t['ucircumflexbelow'] = 0x1E77;
  12360. t['ucyrillic'] = 0x0443;
  12361. t['udattadeva'] = 0x0951;
  12362. t['udblacute'] = 0x0171;
  12363. t['udblgrave'] = 0x0215;
  12364. t['udeva'] = 0x0909;
  12365. t['udieresis'] = 0x00FC;
  12366. t['udieresisacute'] = 0x01D8;
  12367. t['udieresisbelow'] = 0x1E73;
  12368. t['udieresiscaron'] = 0x01DA;
  12369. t['udieresiscyrillic'] = 0x04F1;
  12370. t['udieresisgrave'] = 0x01DC;
  12371. t['udieresismacron'] = 0x01D6;
  12372. t['udotbelow'] = 0x1EE5;
  12373. t['ugrave'] = 0x00F9;
  12374. t['ugujarati'] = 0x0A89;
  12375. t['ugurmukhi'] = 0x0A09;
  12376. t['uhiragana'] = 0x3046;
  12377. t['uhookabove'] = 0x1EE7;
  12378. t['uhorn'] = 0x01B0;
  12379. t['uhornacute'] = 0x1EE9;
  12380. t['uhorndotbelow'] = 0x1EF1;
  12381. t['uhorngrave'] = 0x1EEB;
  12382. t['uhornhookabove'] = 0x1EED;
  12383. t['uhorntilde'] = 0x1EEF;
  12384. t['uhungarumlaut'] = 0x0171;
  12385. t['uhungarumlautcyrillic'] = 0x04F3;
  12386. t['uinvertedbreve'] = 0x0217;
  12387. t['ukatakana'] = 0x30A6;
  12388. t['ukatakanahalfwidth'] = 0xFF73;
  12389. t['ukcyrillic'] = 0x0479;
  12390. t['ukorean'] = 0x315C;
  12391. t['umacron'] = 0x016B;
  12392. t['umacroncyrillic'] = 0x04EF;
  12393. t['umacrondieresis'] = 0x1E7B;
  12394. t['umatragurmukhi'] = 0x0A41;
  12395. t['umonospace'] = 0xFF55;
  12396. t['underscore'] = 0x005F;
  12397. t['underscoredbl'] = 0x2017;
  12398. t['underscoremonospace'] = 0xFF3F;
  12399. t['underscorevertical'] = 0xFE33;
  12400. t['underscorewavy'] = 0xFE4F;
  12401. t['union'] = 0x222A;
  12402. t['universal'] = 0x2200;
  12403. t['uogonek'] = 0x0173;
  12404. t['uparen'] = 0x24B0;
  12405. t['upblock'] = 0x2580;
  12406. t['upperdothebrew'] = 0x05C4;
  12407. t['upsilon'] = 0x03C5;
  12408. t['upsilondieresis'] = 0x03CB;
  12409. t['upsilondieresistonos'] = 0x03B0;
  12410. t['upsilonlatin'] = 0x028A;
  12411. t['upsilontonos'] = 0x03CD;
  12412. t['uptackbelowcmb'] = 0x031D;
  12413. t['uptackmod'] = 0x02D4;
  12414. t['uragurmukhi'] = 0x0A73;
  12415. t['uring'] = 0x016F;
  12416. t['ushortcyrillic'] = 0x045E;
  12417. t['usmallhiragana'] = 0x3045;
  12418. t['usmallkatakana'] = 0x30A5;
  12419. t['usmallkatakanahalfwidth'] = 0xFF69;
  12420. t['ustraightcyrillic'] = 0x04AF;
  12421. t['ustraightstrokecyrillic'] = 0x04B1;
  12422. t['utilde'] = 0x0169;
  12423. t['utildeacute'] = 0x1E79;
  12424. t['utildebelow'] = 0x1E75;
  12425. t['uubengali'] = 0x098A;
  12426. t['uudeva'] = 0x090A;
  12427. t['uugujarati'] = 0x0A8A;
  12428. t['uugurmukhi'] = 0x0A0A;
  12429. t['uumatragurmukhi'] = 0x0A42;
  12430. t['uuvowelsignbengali'] = 0x09C2;
  12431. t['uuvowelsigndeva'] = 0x0942;
  12432. t['uuvowelsigngujarati'] = 0x0AC2;
  12433. t['uvowelsignbengali'] = 0x09C1;
  12434. t['uvowelsigndeva'] = 0x0941;
  12435. t['uvowelsigngujarati'] = 0x0AC1;
  12436. t['v'] = 0x0076;
  12437. t['vadeva'] = 0x0935;
  12438. t['vagujarati'] = 0x0AB5;
  12439. t['vagurmukhi'] = 0x0A35;
  12440. t['vakatakana'] = 0x30F7;
  12441. t['vav'] = 0x05D5;
  12442. t['vavdagesh'] = 0xFB35;
  12443. t['vavdagesh65'] = 0xFB35;
  12444. t['vavdageshhebrew'] = 0xFB35;
  12445. t['vavhebrew'] = 0x05D5;
  12446. t['vavholam'] = 0xFB4B;
  12447. t['vavholamhebrew'] = 0xFB4B;
  12448. t['vavvavhebrew'] = 0x05F0;
  12449. t['vavyodhebrew'] = 0x05F1;
  12450. t['vcircle'] = 0x24E5;
  12451. t['vdotbelow'] = 0x1E7F;
  12452. t['vecyrillic'] = 0x0432;
  12453. t['veharabic'] = 0x06A4;
  12454. t['vehfinalarabic'] = 0xFB6B;
  12455. t['vehinitialarabic'] = 0xFB6C;
  12456. t['vehmedialarabic'] = 0xFB6D;
  12457. t['vekatakana'] = 0x30F9;
  12458. t['venus'] = 0x2640;
  12459. t['verticalbar'] = 0x007C;
  12460. t['verticallineabovecmb'] = 0x030D;
  12461. t['verticallinebelowcmb'] = 0x0329;
  12462. t['verticallinelowmod'] = 0x02CC;
  12463. t['verticallinemod'] = 0x02C8;
  12464. t['vewarmenian'] = 0x057E;
  12465. t['vhook'] = 0x028B;
  12466. t['vikatakana'] = 0x30F8;
  12467. t['viramabengali'] = 0x09CD;
  12468. t['viramadeva'] = 0x094D;
  12469. t['viramagujarati'] = 0x0ACD;
  12470. t['visargabengali'] = 0x0983;
  12471. t['visargadeva'] = 0x0903;
  12472. t['visargagujarati'] = 0x0A83;
  12473. t['vmonospace'] = 0xFF56;
  12474. t['voarmenian'] = 0x0578;
  12475. t['voicediterationhiragana'] = 0x309E;
  12476. t['voicediterationkatakana'] = 0x30FE;
  12477. t['voicedmarkkana'] = 0x309B;
  12478. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  12479. t['vokatakana'] = 0x30FA;
  12480. t['vparen'] = 0x24B1;
  12481. t['vtilde'] = 0x1E7D;
  12482. t['vturned'] = 0x028C;
  12483. t['vuhiragana'] = 0x3094;
  12484. t['vukatakana'] = 0x30F4;
  12485. t['w'] = 0x0077;
  12486. t['wacute'] = 0x1E83;
  12487. t['waekorean'] = 0x3159;
  12488. t['wahiragana'] = 0x308F;
  12489. t['wakatakana'] = 0x30EF;
  12490. t['wakatakanahalfwidth'] = 0xFF9C;
  12491. t['wakorean'] = 0x3158;
  12492. t['wasmallhiragana'] = 0x308E;
  12493. t['wasmallkatakana'] = 0x30EE;
  12494. t['wattosquare'] = 0x3357;
  12495. t['wavedash'] = 0x301C;
  12496. t['wavyunderscorevertical'] = 0xFE34;
  12497. t['wawarabic'] = 0x0648;
  12498. t['wawfinalarabic'] = 0xFEEE;
  12499. t['wawhamzaabovearabic'] = 0x0624;
  12500. t['wawhamzaabovefinalarabic'] = 0xFE86;
  12501. t['wbsquare'] = 0x33DD;
  12502. t['wcircle'] = 0x24E6;
  12503. t['wcircumflex'] = 0x0175;
  12504. t['wdieresis'] = 0x1E85;
  12505. t['wdotaccent'] = 0x1E87;
  12506. t['wdotbelow'] = 0x1E89;
  12507. t['wehiragana'] = 0x3091;
  12508. t['weierstrass'] = 0x2118;
  12509. t['wekatakana'] = 0x30F1;
  12510. t['wekorean'] = 0x315E;
  12511. t['weokorean'] = 0x315D;
  12512. t['wgrave'] = 0x1E81;
  12513. t['whitebullet'] = 0x25E6;
  12514. t['whitecircle'] = 0x25CB;
  12515. t['whitecircleinverse'] = 0x25D9;
  12516. t['whitecornerbracketleft'] = 0x300E;
  12517. t['whitecornerbracketleftvertical'] = 0xFE43;
  12518. t['whitecornerbracketright'] = 0x300F;
  12519. t['whitecornerbracketrightvertical'] = 0xFE44;
  12520. t['whitediamond'] = 0x25C7;
  12521. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  12522. t['whitedownpointingsmalltriangle'] = 0x25BF;
  12523. t['whitedownpointingtriangle'] = 0x25BD;
  12524. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  12525. t['whiteleftpointingtriangle'] = 0x25C1;
  12526. t['whitelenticularbracketleft'] = 0x3016;
  12527. t['whitelenticularbracketright'] = 0x3017;
  12528. t['whiterightpointingsmalltriangle'] = 0x25B9;
  12529. t['whiterightpointingtriangle'] = 0x25B7;
  12530. t['whitesmallsquare'] = 0x25AB;
  12531. t['whitesmilingface'] = 0x263A;
  12532. t['whitesquare'] = 0x25A1;
  12533. t['whitestar'] = 0x2606;
  12534. t['whitetelephone'] = 0x260F;
  12535. t['whitetortoiseshellbracketleft'] = 0x3018;
  12536. t['whitetortoiseshellbracketright'] = 0x3019;
  12537. t['whiteuppointingsmalltriangle'] = 0x25B5;
  12538. t['whiteuppointingtriangle'] = 0x25B3;
  12539. t['wihiragana'] = 0x3090;
  12540. t['wikatakana'] = 0x30F0;
  12541. t['wikorean'] = 0x315F;
  12542. t['wmonospace'] = 0xFF57;
  12543. t['wohiragana'] = 0x3092;
  12544. t['wokatakana'] = 0x30F2;
  12545. t['wokatakanahalfwidth'] = 0xFF66;
  12546. t['won'] = 0x20A9;
  12547. t['wonmonospace'] = 0xFFE6;
  12548. t['wowaenthai'] = 0x0E27;
  12549. t['wparen'] = 0x24B2;
  12550. t['wring'] = 0x1E98;
  12551. t['wsuperior'] = 0x02B7;
  12552. t['wturned'] = 0x028D;
  12553. t['wynn'] = 0x01BF;
  12554. t['x'] = 0x0078;
  12555. t['xabovecmb'] = 0x033D;
  12556. t['xbopomofo'] = 0x3112;
  12557. t['xcircle'] = 0x24E7;
  12558. t['xdieresis'] = 0x1E8D;
  12559. t['xdotaccent'] = 0x1E8B;
  12560. t['xeharmenian'] = 0x056D;
  12561. t['xi'] = 0x03BE;
  12562. t['xmonospace'] = 0xFF58;
  12563. t['xparen'] = 0x24B3;
  12564. t['xsuperior'] = 0x02E3;
  12565. t['y'] = 0x0079;
  12566. t['yaadosquare'] = 0x334E;
  12567. t['yabengali'] = 0x09AF;
  12568. t['yacute'] = 0x00FD;
  12569. t['yadeva'] = 0x092F;
  12570. t['yaekorean'] = 0x3152;
  12571. t['yagujarati'] = 0x0AAF;
  12572. t['yagurmukhi'] = 0x0A2F;
  12573. t['yahiragana'] = 0x3084;
  12574. t['yakatakana'] = 0x30E4;
  12575. t['yakatakanahalfwidth'] = 0xFF94;
  12576. t['yakorean'] = 0x3151;
  12577. t['yamakkanthai'] = 0x0E4E;
  12578. t['yasmallhiragana'] = 0x3083;
  12579. t['yasmallkatakana'] = 0x30E3;
  12580. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  12581. t['yatcyrillic'] = 0x0463;
  12582. t['ycircle'] = 0x24E8;
  12583. t['ycircumflex'] = 0x0177;
  12584. t['ydieresis'] = 0x00FF;
  12585. t['ydotaccent'] = 0x1E8F;
  12586. t['ydotbelow'] = 0x1EF5;
  12587. t['yeharabic'] = 0x064A;
  12588. t['yehbarreearabic'] = 0x06D2;
  12589. t['yehbarreefinalarabic'] = 0xFBAF;
  12590. t['yehfinalarabic'] = 0xFEF2;
  12591. t['yehhamzaabovearabic'] = 0x0626;
  12592. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  12593. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  12594. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  12595. t['yehinitialarabic'] = 0xFEF3;
  12596. t['yehmedialarabic'] = 0xFEF4;
  12597. t['yehmeeminitialarabic'] = 0xFCDD;
  12598. t['yehmeemisolatedarabic'] = 0xFC58;
  12599. t['yehnoonfinalarabic'] = 0xFC94;
  12600. t['yehthreedotsbelowarabic'] = 0x06D1;
  12601. t['yekorean'] = 0x3156;
  12602. t['yen'] = 0x00A5;
  12603. t['yenmonospace'] = 0xFFE5;
  12604. t['yeokorean'] = 0x3155;
  12605. t['yeorinhieuhkorean'] = 0x3186;
  12606. t['yerahbenyomohebrew'] = 0x05AA;
  12607. t['yerahbenyomolefthebrew'] = 0x05AA;
  12608. t['yericyrillic'] = 0x044B;
  12609. t['yerudieresiscyrillic'] = 0x04F9;
  12610. t['yesieungkorean'] = 0x3181;
  12611. t['yesieungpansioskorean'] = 0x3183;
  12612. t['yesieungsioskorean'] = 0x3182;
  12613. t['yetivhebrew'] = 0x059A;
  12614. t['ygrave'] = 0x1EF3;
  12615. t['yhook'] = 0x01B4;
  12616. t['yhookabove'] = 0x1EF7;
  12617. t['yiarmenian'] = 0x0575;
  12618. t['yicyrillic'] = 0x0457;
  12619. t['yikorean'] = 0x3162;
  12620. t['yinyang'] = 0x262F;
  12621. t['yiwnarmenian'] = 0x0582;
  12622. t['ymonospace'] = 0xFF59;
  12623. t['yod'] = 0x05D9;
  12624. t['yoddagesh'] = 0xFB39;
  12625. t['yoddageshhebrew'] = 0xFB39;
  12626. t['yodhebrew'] = 0x05D9;
  12627. t['yodyodhebrew'] = 0x05F2;
  12628. t['yodyodpatahhebrew'] = 0xFB1F;
  12629. t['yohiragana'] = 0x3088;
  12630. t['yoikorean'] = 0x3189;
  12631. t['yokatakana'] = 0x30E8;
  12632. t['yokatakanahalfwidth'] = 0xFF96;
  12633. t['yokorean'] = 0x315B;
  12634. t['yosmallhiragana'] = 0x3087;
  12635. t['yosmallkatakana'] = 0x30E7;
  12636. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  12637. t['yotgreek'] = 0x03F3;
  12638. t['yoyaekorean'] = 0x3188;
  12639. t['yoyakorean'] = 0x3187;
  12640. t['yoyakthai'] = 0x0E22;
  12641. t['yoyingthai'] = 0x0E0D;
  12642. t['yparen'] = 0x24B4;
  12643. t['ypogegrammeni'] = 0x037A;
  12644. t['ypogegrammenigreekcmb'] = 0x0345;
  12645. t['yr'] = 0x01A6;
  12646. t['yring'] = 0x1E99;
  12647. t['ysuperior'] = 0x02B8;
  12648. t['ytilde'] = 0x1EF9;
  12649. t['yturned'] = 0x028E;
  12650. t['yuhiragana'] = 0x3086;
  12651. t['yuikorean'] = 0x318C;
  12652. t['yukatakana'] = 0x30E6;
  12653. t['yukatakanahalfwidth'] = 0xFF95;
  12654. t['yukorean'] = 0x3160;
  12655. t['yusbigcyrillic'] = 0x046B;
  12656. t['yusbigiotifiedcyrillic'] = 0x046D;
  12657. t['yuslittlecyrillic'] = 0x0467;
  12658. t['yuslittleiotifiedcyrillic'] = 0x0469;
  12659. t['yusmallhiragana'] = 0x3085;
  12660. t['yusmallkatakana'] = 0x30E5;
  12661. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  12662. t['yuyekorean'] = 0x318B;
  12663. t['yuyeokorean'] = 0x318A;
  12664. t['yyabengali'] = 0x09DF;
  12665. t['yyadeva'] = 0x095F;
  12666. t['z'] = 0x007A;
  12667. t['zaarmenian'] = 0x0566;
  12668. t['zacute'] = 0x017A;
  12669. t['zadeva'] = 0x095B;
  12670. t['zagurmukhi'] = 0x0A5B;
  12671. t['zaharabic'] = 0x0638;
  12672. t['zahfinalarabic'] = 0xFEC6;
  12673. t['zahinitialarabic'] = 0xFEC7;
  12674. t['zahiragana'] = 0x3056;
  12675. t['zahmedialarabic'] = 0xFEC8;
  12676. t['zainarabic'] = 0x0632;
  12677. t['zainfinalarabic'] = 0xFEB0;
  12678. t['zakatakana'] = 0x30B6;
  12679. t['zaqefgadolhebrew'] = 0x0595;
  12680. t['zaqefqatanhebrew'] = 0x0594;
  12681. t['zarqahebrew'] = 0x0598;
  12682. t['zayin'] = 0x05D6;
  12683. t['zayindagesh'] = 0xFB36;
  12684. t['zayindageshhebrew'] = 0xFB36;
  12685. t['zayinhebrew'] = 0x05D6;
  12686. t['zbopomofo'] = 0x3117;
  12687. t['zcaron'] = 0x017E;
  12688. t['zcircle'] = 0x24E9;
  12689. t['zcircumflex'] = 0x1E91;
  12690. t['zcurl'] = 0x0291;
  12691. t['zdot'] = 0x017C;
  12692. t['zdotaccent'] = 0x017C;
  12693. t['zdotbelow'] = 0x1E93;
  12694. t['zecyrillic'] = 0x0437;
  12695. t['zedescendercyrillic'] = 0x0499;
  12696. t['zedieresiscyrillic'] = 0x04DF;
  12697. t['zehiragana'] = 0x305C;
  12698. t['zekatakana'] = 0x30BC;
  12699. t['zero'] = 0x0030;
  12700. t['zeroarabic'] = 0x0660;
  12701. t['zerobengali'] = 0x09E6;
  12702. t['zerodeva'] = 0x0966;
  12703. t['zerogujarati'] = 0x0AE6;
  12704. t['zerogurmukhi'] = 0x0A66;
  12705. t['zerohackarabic'] = 0x0660;
  12706. t['zeroinferior'] = 0x2080;
  12707. t['zeromonospace'] = 0xFF10;
  12708. t['zerooldstyle'] = 0xF730;
  12709. t['zeropersian'] = 0x06F0;
  12710. t['zerosuperior'] = 0x2070;
  12711. t['zerothai'] = 0x0E50;
  12712. t['zerowidthjoiner'] = 0xFEFF;
  12713. t['zerowidthnonjoiner'] = 0x200C;
  12714. t['zerowidthspace'] = 0x200B;
  12715. t['zeta'] = 0x03B6;
  12716. t['zhbopomofo'] = 0x3113;
  12717. t['zhearmenian'] = 0x056A;
  12718. t['zhebrevecyrillic'] = 0x04C2;
  12719. t['zhecyrillic'] = 0x0436;
  12720. t['zhedescendercyrillic'] = 0x0497;
  12721. t['zhedieresiscyrillic'] = 0x04DD;
  12722. t['zihiragana'] = 0x3058;
  12723. t['zikatakana'] = 0x30B8;
  12724. t['zinorhebrew'] = 0x05AE;
  12725. t['zlinebelow'] = 0x1E95;
  12726. t['zmonospace'] = 0xFF5A;
  12727. t['zohiragana'] = 0x305E;
  12728. t['zokatakana'] = 0x30BE;
  12729. t['zparen'] = 0x24B5;
  12730. t['zretroflexhook'] = 0x0290;
  12731. t['zstroke'] = 0x01B6;
  12732. t['zuhiragana'] = 0x305A;
  12733. t['zukatakana'] = 0x30BA;
  12734. t['.notdef'] = 0x0000;
  12735. });
  12736. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  12737. t['space'] = 0x0020;
  12738. t['a1'] = 0x2701;
  12739. t['a2'] = 0x2702;
  12740. t['a202'] = 0x2703;
  12741. t['a3'] = 0x2704;
  12742. t['a4'] = 0x260E;
  12743. t['a5'] = 0x2706;
  12744. t['a119'] = 0x2707;
  12745. t['a118'] = 0x2708;
  12746. t['a117'] = 0x2709;
  12747. t['a11'] = 0x261B;
  12748. t['a12'] = 0x261E;
  12749. t['a13'] = 0x270C;
  12750. t['a14'] = 0x270D;
  12751. t['a15'] = 0x270E;
  12752. t['a16'] = 0x270F;
  12753. t['a105'] = 0x2710;
  12754. t['a17'] = 0x2711;
  12755. t['a18'] = 0x2712;
  12756. t['a19'] = 0x2713;
  12757. t['a20'] = 0x2714;
  12758. t['a21'] = 0x2715;
  12759. t['a22'] = 0x2716;
  12760. t['a23'] = 0x2717;
  12761. t['a24'] = 0x2718;
  12762. t['a25'] = 0x2719;
  12763. t['a26'] = 0x271A;
  12764. t['a27'] = 0x271B;
  12765. t['a28'] = 0x271C;
  12766. t['a6'] = 0x271D;
  12767. t['a7'] = 0x271E;
  12768. t['a8'] = 0x271F;
  12769. t['a9'] = 0x2720;
  12770. t['a10'] = 0x2721;
  12771. t['a29'] = 0x2722;
  12772. t['a30'] = 0x2723;
  12773. t['a31'] = 0x2724;
  12774. t['a32'] = 0x2725;
  12775. t['a33'] = 0x2726;
  12776. t['a34'] = 0x2727;
  12777. t['a35'] = 0x2605;
  12778. t['a36'] = 0x2729;
  12779. t['a37'] = 0x272A;
  12780. t['a38'] = 0x272B;
  12781. t['a39'] = 0x272C;
  12782. t['a40'] = 0x272D;
  12783. t['a41'] = 0x272E;
  12784. t['a42'] = 0x272F;
  12785. t['a43'] = 0x2730;
  12786. t['a44'] = 0x2731;
  12787. t['a45'] = 0x2732;
  12788. t['a46'] = 0x2733;
  12789. t['a47'] = 0x2734;
  12790. t['a48'] = 0x2735;
  12791. t['a49'] = 0x2736;
  12792. t['a50'] = 0x2737;
  12793. t['a51'] = 0x2738;
  12794. t['a52'] = 0x2739;
  12795. t['a53'] = 0x273A;
  12796. t['a54'] = 0x273B;
  12797. t['a55'] = 0x273C;
  12798. t['a56'] = 0x273D;
  12799. t['a57'] = 0x273E;
  12800. t['a58'] = 0x273F;
  12801. t['a59'] = 0x2740;
  12802. t['a60'] = 0x2741;
  12803. t['a61'] = 0x2742;
  12804. t['a62'] = 0x2743;
  12805. t['a63'] = 0x2744;
  12806. t['a64'] = 0x2745;
  12807. t['a65'] = 0x2746;
  12808. t['a66'] = 0x2747;
  12809. t['a67'] = 0x2748;
  12810. t['a68'] = 0x2749;
  12811. t['a69'] = 0x274A;
  12812. t['a70'] = 0x274B;
  12813. t['a71'] = 0x25CF;
  12814. t['a72'] = 0x274D;
  12815. t['a73'] = 0x25A0;
  12816. t['a74'] = 0x274F;
  12817. t['a203'] = 0x2750;
  12818. t['a75'] = 0x2751;
  12819. t['a204'] = 0x2752;
  12820. t['a76'] = 0x25B2;
  12821. t['a77'] = 0x25BC;
  12822. t['a78'] = 0x25C6;
  12823. t['a79'] = 0x2756;
  12824. t['a81'] = 0x25D7;
  12825. t['a82'] = 0x2758;
  12826. t['a83'] = 0x2759;
  12827. t['a84'] = 0x275A;
  12828. t['a97'] = 0x275B;
  12829. t['a98'] = 0x275C;
  12830. t['a99'] = 0x275D;
  12831. t['a100'] = 0x275E;
  12832. t['a101'] = 0x2761;
  12833. t['a102'] = 0x2762;
  12834. t['a103'] = 0x2763;
  12835. t['a104'] = 0x2764;
  12836. t['a106'] = 0x2765;
  12837. t['a107'] = 0x2766;
  12838. t['a108'] = 0x2767;
  12839. t['a112'] = 0x2663;
  12840. t['a111'] = 0x2666;
  12841. t['a110'] = 0x2665;
  12842. t['a109'] = 0x2660;
  12843. t['a120'] = 0x2460;
  12844. t['a121'] = 0x2461;
  12845. t['a122'] = 0x2462;
  12846. t['a123'] = 0x2463;
  12847. t['a124'] = 0x2464;
  12848. t['a125'] = 0x2465;
  12849. t['a126'] = 0x2466;
  12850. t['a127'] = 0x2467;
  12851. t['a128'] = 0x2468;
  12852. t['a129'] = 0x2469;
  12853. t['a130'] = 0x2776;
  12854. t['a131'] = 0x2777;
  12855. t['a132'] = 0x2778;
  12856. t['a133'] = 0x2779;
  12857. t['a134'] = 0x277A;
  12858. t['a135'] = 0x277B;
  12859. t['a136'] = 0x277C;
  12860. t['a137'] = 0x277D;
  12861. t['a138'] = 0x277E;
  12862. t['a139'] = 0x277F;
  12863. t['a140'] = 0x2780;
  12864. t['a141'] = 0x2781;
  12865. t['a142'] = 0x2782;
  12866. t['a143'] = 0x2783;
  12867. t['a144'] = 0x2784;
  12868. t['a145'] = 0x2785;
  12869. t['a146'] = 0x2786;
  12870. t['a147'] = 0x2787;
  12871. t['a148'] = 0x2788;
  12872. t['a149'] = 0x2789;
  12873. t['a150'] = 0x278A;
  12874. t['a151'] = 0x278B;
  12875. t['a152'] = 0x278C;
  12876. t['a153'] = 0x278D;
  12877. t['a154'] = 0x278E;
  12878. t['a155'] = 0x278F;
  12879. t['a156'] = 0x2790;
  12880. t['a157'] = 0x2791;
  12881. t['a158'] = 0x2792;
  12882. t['a159'] = 0x2793;
  12883. t['a160'] = 0x2794;
  12884. t['a161'] = 0x2192;
  12885. t['a163'] = 0x2194;
  12886. t['a164'] = 0x2195;
  12887. t['a196'] = 0x2798;
  12888. t['a165'] = 0x2799;
  12889. t['a192'] = 0x279A;
  12890. t['a166'] = 0x279B;
  12891. t['a167'] = 0x279C;
  12892. t['a168'] = 0x279D;
  12893. t['a169'] = 0x279E;
  12894. t['a170'] = 0x279F;
  12895. t['a171'] = 0x27A0;
  12896. t['a172'] = 0x27A1;
  12897. t['a173'] = 0x27A2;
  12898. t['a162'] = 0x27A3;
  12899. t['a174'] = 0x27A4;
  12900. t['a175'] = 0x27A5;
  12901. t['a176'] = 0x27A6;
  12902. t['a177'] = 0x27A7;
  12903. t['a178'] = 0x27A8;
  12904. t['a179'] = 0x27A9;
  12905. t['a193'] = 0x27AA;
  12906. t['a180'] = 0x27AB;
  12907. t['a199'] = 0x27AC;
  12908. t['a181'] = 0x27AD;
  12909. t['a200'] = 0x27AE;
  12910. t['a182'] = 0x27AF;
  12911. t['a201'] = 0x27B1;
  12912. t['a183'] = 0x27B2;
  12913. t['a184'] = 0x27B3;
  12914. t['a197'] = 0x27B4;
  12915. t['a185'] = 0x27B5;
  12916. t['a194'] = 0x27B6;
  12917. t['a198'] = 0x27B7;
  12918. t['a186'] = 0x27B8;
  12919. t['a195'] = 0x27B9;
  12920. t['a187'] = 0x27BA;
  12921. t['a188'] = 0x27BB;
  12922. t['a189'] = 0x27BC;
  12923. t['a190'] = 0x27BD;
  12924. t['a191'] = 0x27BE;
  12925. t['a89'] = 0x2768;
  12926. t['a90'] = 0x2769;
  12927. t['a93'] = 0x276A;
  12928. t['a94'] = 0x276B;
  12929. t['a91'] = 0x276C;
  12930. t['a92'] = 0x276D;
  12931. t['a205'] = 0x276E;
  12932. t['a85'] = 0x276F;
  12933. t['a206'] = 0x2770;
  12934. t['a86'] = 0x2771;
  12935. t['a87'] = 0x2772;
  12936. t['a88'] = 0x2773;
  12937. t['a95'] = 0x2774;
  12938. t['a96'] = 0x2775;
  12939. t['.notdef'] = 0x0000;
  12940. });
  12941. exports.getGlyphsUnicode = getGlyphsUnicode;
  12942. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  12943. }));
  12944. (function (root, factory) {
  12945. factory(root.pdfjsCoreJbig2 = {}, root.pdfjsSharedUtil, root.pdfjsCoreArithmeticDecoder);
  12946. }(this, function (exports, sharedUtil, coreArithmeticDecoder) {
  12947. var error = sharedUtil.error;
  12948. var log2 = sharedUtil.log2;
  12949. var readInt8 = sharedUtil.readInt8;
  12950. var readUint16 = sharedUtil.readUint16;
  12951. var readUint32 = sharedUtil.readUint32;
  12952. var shadow = sharedUtil.shadow;
  12953. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  12954. var Jbig2Image = function Jbig2ImageClosure() {
  12955. function ContextCache() {
  12956. }
  12957. ContextCache.prototype = {
  12958. getContexts: function (id) {
  12959. if (id in this) {
  12960. return this[id];
  12961. }
  12962. return this[id] = new Int8Array(1 << 16);
  12963. }
  12964. };
  12965. function DecodingContext(data, start, end) {
  12966. this.data = data;
  12967. this.start = start;
  12968. this.end = end;
  12969. }
  12970. DecodingContext.prototype = {
  12971. get decoder() {
  12972. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  12973. return shadow(this, 'decoder', decoder);
  12974. },
  12975. get contextCache() {
  12976. var cache = new ContextCache();
  12977. return shadow(this, 'contextCache', cache);
  12978. }
  12979. };
  12980. function decodeInteger(contextCache, procedure, decoder) {
  12981. var contexts = contextCache.getContexts(procedure);
  12982. var prev = 1;
  12983. function readBits(length) {
  12984. var v = 0;
  12985. for (var i = 0; i < length; i++) {
  12986. var bit = decoder.readBit(contexts, prev);
  12987. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  12988. v = v << 1 | bit;
  12989. }
  12990. return v >>> 0;
  12991. }
  12992. var sign = readBits(1);
  12993. 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);
  12994. return sign === 0 ? value : value > 0 ? -value : null;
  12995. }
  12996. function decodeIAID(contextCache, decoder, codeLength) {
  12997. var contexts = contextCache.getContexts('IAID');
  12998. var prev = 1;
  12999. for (var i = 0; i < codeLength; i++) {
  13000. var bit = decoder.readBit(contexts, prev);
  13001. prev = prev << 1 | bit;
  13002. }
  13003. if (codeLength < 31) {
  13004. return prev & (1 << codeLength) - 1;
  13005. }
  13006. return prev & 0x7FFFFFFF;
  13007. }
  13008. var SegmentTypes = [
  13009. 'SymbolDictionary',
  13010. null,
  13011. null,
  13012. null,
  13013. 'IntermediateTextRegion',
  13014. null,
  13015. 'ImmediateTextRegion',
  13016. 'ImmediateLosslessTextRegion',
  13017. null,
  13018. null,
  13019. null,
  13020. null,
  13021. null,
  13022. null,
  13023. null,
  13024. null,
  13025. 'patternDictionary',
  13026. null,
  13027. null,
  13028. null,
  13029. 'IntermediateHalftoneRegion',
  13030. null,
  13031. 'ImmediateHalftoneRegion',
  13032. 'ImmediateLosslessHalftoneRegion',
  13033. null,
  13034. null,
  13035. null,
  13036. null,
  13037. null,
  13038. null,
  13039. null,
  13040. null,
  13041. null,
  13042. null,
  13043. null,
  13044. null,
  13045. 'IntermediateGenericRegion',
  13046. null,
  13047. 'ImmediateGenericRegion',
  13048. 'ImmediateLosslessGenericRegion',
  13049. 'IntermediateGenericRefinementRegion',
  13050. null,
  13051. 'ImmediateGenericRefinementRegion',
  13052. 'ImmediateLosslessGenericRefinementRegion',
  13053. null,
  13054. null,
  13055. null,
  13056. null,
  13057. 'PageInformation',
  13058. 'EndOfPage',
  13059. 'EndOfStripe',
  13060. 'EndOfFile',
  13061. 'Profiles',
  13062. 'Tables',
  13063. null,
  13064. null,
  13065. null,
  13066. null,
  13067. null,
  13068. null,
  13069. null,
  13070. null,
  13071. 'Extension'
  13072. ];
  13073. var CodingTemplates = [
  13074. [
  13075. {
  13076. x: -1,
  13077. y: -2
  13078. },
  13079. {
  13080. x: 0,
  13081. y: -2
  13082. },
  13083. {
  13084. x: 1,
  13085. y: -2
  13086. },
  13087. {
  13088. x: -2,
  13089. y: -1
  13090. },
  13091. {
  13092. x: -1,
  13093. y: -1
  13094. },
  13095. {
  13096. x: 0,
  13097. y: -1
  13098. },
  13099. {
  13100. x: 1,
  13101. y: -1
  13102. },
  13103. {
  13104. x: 2,
  13105. y: -1
  13106. },
  13107. {
  13108. x: -4,
  13109. y: 0
  13110. },
  13111. {
  13112. x: -3,
  13113. y: 0
  13114. },
  13115. {
  13116. x: -2,
  13117. y: 0
  13118. },
  13119. {
  13120. x: -1,
  13121. y: 0
  13122. }
  13123. ],
  13124. [
  13125. {
  13126. x: -1,
  13127. y: -2
  13128. },
  13129. {
  13130. x: 0,
  13131. y: -2
  13132. },
  13133. {
  13134. x: 1,
  13135. y: -2
  13136. },
  13137. {
  13138. x: 2,
  13139. y: -2
  13140. },
  13141. {
  13142. x: -2,
  13143. y: -1
  13144. },
  13145. {
  13146. x: -1,
  13147. y: -1
  13148. },
  13149. {
  13150. x: 0,
  13151. y: -1
  13152. },
  13153. {
  13154. x: 1,
  13155. y: -1
  13156. },
  13157. {
  13158. x: 2,
  13159. y: -1
  13160. },
  13161. {
  13162. x: -3,
  13163. y: 0
  13164. },
  13165. {
  13166. x: -2,
  13167. y: 0
  13168. },
  13169. {
  13170. x: -1,
  13171. y: 0
  13172. }
  13173. ],
  13174. [
  13175. {
  13176. x: -1,
  13177. y: -2
  13178. },
  13179. {
  13180. x: 0,
  13181. y: -2
  13182. },
  13183. {
  13184. x: 1,
  13185. y: -2
  13186. },
  13187. {
  13188. x: -2,
  13189. y: -1
  13190. },
  13191. {
  13192. x: -1,
  13193. y: -1
  13194. },
  13195. {
  13196. x: 0,
  13197. y: -1
  13198. },
  13199. {
  13200. x: 1,
  13201. y: -1
  13202. },
  13203. {
  13204. x: -2,
  13205. y: 0
  13206. },
  13207. {
  13208. x: -1,
  13209. y: 0
  13210. }
  13211. ],
  13212. [
  13213. {
  13214. x: -3,
  13215. y: -1
  13216. },
  13217. {
  13218. x: -2,
  13219. y: -1
  13220. },
  13221. {
  13222. x: -1,
  13223. y: -1
  13224. },
  13225. {
  13226. x: 0,
  13227. y: -1
  13228. },
  13229. {
  13230. x: 1,
  13231. y: -1
  13232. },
  13233. {
  13234. x: -4,
  13235. y: 0
  13236. },
  13237. {
  13238. x: -3,
  13239. y: 0
  13240. },
  13241. {
  13242. x: -2,
  13243. y: 0
  13244. },
  13245. {
  13246. x: -1,
  13247. y: 0
  13248. }
  13249. ]
  13250. ];
  13251. var RefinementTemplates = [
  13252. {
  13253. coding: [
  13254. {
  13255. x: 0,
  13256. y: -1
  13257. },
  13258. {
  13259. x: 1,
  13260. y: -1
  13261. },
  13262. {
  13263. x: -1,
  13264. y: 0
  13265. }
  13266. ],
  13267. reference: [
  13268. {
  13269. x: 0,
  13270. y: -1
  13271. },
  13272. {
  13273. x: 1,
  13274. y: -1
  13275. },
  13276. {
  13277. x: -1,
  13278. y: 0
  13279. },
  13280. {
  13281. x: 0,
  13282. y: 0
  13283. },
  13284. {
  13285. x: 1,
  13286. y: 0
  13287. },
  13288. {
  13289. x: -1,
  13290. y: 1
  13291. },
  13292. {
  13293. x: 0,
  13294. y: 1
  13295. },
  13296. {
  13297. x: 1,
  13298. y: 1
  13299. }
  13300. ]
  13301. },
  13302. {
  13303. coding: [
  13304. {
  13305. x: -1,
  13306. y: -1
  13307. },
  13308. {
  13309. x: 0,
  13310. y: -1
  13311. },
  13312. {
  13313. x: 1,
  13314. y: -1
  13315. },
  13316. {
  13317. x: -1,
  13318. y: 0
  13319. }
  13320. ],
  13321. reference: [
  13322. {
  13323. x: 0,
  13324. y: -1
  13325. },
  13326. {
  13327. x: -1,
  13328. y: 0
  13329. },
  13330. {
  13331. x: 0,
  13332. y: 0
  13333. },
  13334. {
  13335. x: 1,
  13336. y: 0
  13337. },
  13338. {
  13339. x: 0,
  13340. y: 1
  13341. },
  13342. {
  13343. x: 1,
  13344. y: 1
  13345. }
  13346. ]
  13347. }
  13348. ];
  13349. var ReusedContexts = [
  13350. 0x9B25,
  13351. 0x0795,
  13352. 0x00E5,
  13353. 0x0195
  13354. ];
  13355. var RefinementReusedContexts = [
  13356. 0x0020,
  13357. 0x0008
  13358. ];
  13359. function decodeBitmapTemplate0(width, height, decodingContext) {
  13360. var decoder = decodingContext.decoder;
  13361. var contexts = decodingContext.contextCache.getContexts('GB');
  13362. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  13363. var OLD_PIXEL_MASK = 0x7BF7;
  13364. for (i = 0; i < height; i++) {
  13365. row = bitmap[i] = new Uint8Array(width);
  13366. row1 = i < 1 ? row : bitmap[i - 1];
  13367. row2 = i < 2 ? row : bitmap[i - 2];
  13368. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  13369. for (j = 0; j < width; j++) {
  13370. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  13371. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  13372. }
  13373. }
  13374. return bitmap;
  13375. }
  13376. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  13377. if (mmr) {
  13378. error('JBIG2 error: MMR encoding is not supported');
  13379. }
  13380. 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) {
  13381. return decodeBitmapTemplate0(width, height, decodingContext);
  13382. }
  13383. var useskip = !!skip;
  13384. var template = CodingTemplates[templateIndex].concat(at);
  13385. template.sort(function (a, b) {
  13386. return a.y - b.y || a.x - b.x;
  13387. });
  13388. var templateLength = template.length;
  13389. var templateX = new Int8Array(templateLength);
  13390. var templateY = new Int8Array(templateLength);
  13391. var changingTemplateEntries = [];
  13392. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  13393. var c, k;
  13394. for (k = 0; k < templateLength; k++) {
  13395. templateX[k] = template[k].x;
  13396. templateY[k] = template[k].y;
  13397. minX = Math.min(minX, template[k].x);
  13398. maxX = Math.max(maxX, template[k].x);
  13399. minY = Math.min(minY, template[k].y);
  13400. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  13401. reuseMask |= 1 << templateLength - 1 - k;
  13402. } else {
  13403. changingTemplateEntries.push(k);
  13404. }
  13405. }
  13406. var changingEntriesLength = changingTemplateEntries.length;
  13407. var changingTemplateX = new Int8Array(changingEntriesLength);
  13408. var changingTemplateY = new Int8Array(changingEntriesLength);
  13409. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  13410. for (c = 0; c < changingEntriesLength; c++) {
  13411. k = changingTemplateEntries[c];
  13412. changingTemplateX[c] = template[k].x;
  13413. changingTemplateY[c] = template[k].y;
  13414. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  13415. }
  13416. var sbb_left = -minX;
  13417. var sbb_top = -minY;
  13418. var sbb_right = width - maxX;
  13419. var pseudoPixelContext = ReusedContexts[templateIndex];
  13420. var row = new Uint8Array(width);
  13421. var bitmap = [];
  13422. var decoder = decodingContext.decoder;
  13423. var contexts = decodingContext.contextCache.getContexts('GB');
  13424. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  13425. for (var i = 0; i < height; i++) {
  13426. if (prediction) {
  13427. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  13428. ltp ^= sltp;
  13429. if (ltp) {
  13430. bitmap.push(row);
  13431. continue;
  13432. }
  13433. }
  13434. row = new Uint8Array(row);
  13435. bitmap.push(row);
  13436. for (j = 0; j < width; j++) {
  13437. if (useskip && skip[i][j]) {
  13438. row[j] = 0;
  13439. continue;
  13440. }
  13441. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  13442. contextLabel = contextLabel << 1 & reuseMask;
  13443. for (k = 0; k < changingEntriesLength; k++) {
  13444. i0 = i + changingTemplateY[k];
  13445. j0 = j + changingTemplateX[k];
  13446. bit = bitmap[i0][j0];
  13447. if (bit) {
  13448. bit = changingTemplateBit[k];
  13449. contextLabel |= bit;
  13450. }
  13451. }
  13452. } else {
  13453. contextLabel = 0;
  13454. shift = templateLength - 1;
  13455. for (k = 0; k < templateLength; k++, shift--) {
  13456. j0 = j + templateX[k];
  13457. if (j0 >= 0 && j0 < width) {
  13458. i0 = i + templateY[k];
  13459. if (i0 >= 0) {
  13460. bit = bitmap[i0][j0];
  13461. if (bit) {
  13462. contextLabel |= bit << shift;
  13463. }
  13464. }
  13465. }
  13466. }
  13467. }
  13468. var pixel = decoder.readBit(contexts, contextLabel);
  13469. row[j] = pixel;
  13470. }
  13471. }
  13472. return bitmap;
  13473. }
  13474. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  13475. var codingTemplate = RefinementTemplates[templateIndex].coding;
  13476. if (templateIndex === 0) {
  13477. codingTemplate = codingTemplate.concat([at[0]]);
  13478. }
  13479. var codingTemplateLength = codingTemplate.length;
  13480. var codingTemplateX = new Int32Array(codingTemplateLength);
  13481. var codingTemplateY = new Int32Array(codingTemplateLength);
  13482. var k;
  13483. for (k = 0; k < codingTemplateLength; k++) {
  13484. codingTemplateX[k] = codingTemplate[k].x;
  13485. codingTemplateY[k] = codingTemplate[k].y;
  13486. }
  13487. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  13488. if (templateIndex === 0) {
  13489. referenceTemplate = referenceTemplate.concat([at[1]]);
  13490. }
  13491. var referenceTemplateLength = referenceTemplate.length;
  13492. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  13493. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  13494. for (k = 0; k < referenceTemplateLength; k++) {
  13495. referenceTemplateX[k] = referenceTemplate[k].x;
  13496. referenceTemplateY[k] = referenceTemplate[k].y;
  13497. }
  13498. var referenceWidth = referenceBitmap[0].length;
  13499. var referenceHeight = referenceBitmap.length;
  13500. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  13501. var bitmap = [];
  13502. var decoder = decodingContext.decoder;
  13503. var contexts = decodingContext.contextCache.getContexts('GR');
  13504. var ltp = 0;
  13505. for (var i = 0; i < height; i++) {
  13506. if (prediction) {
  13507. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  13508. ltp ^= sltp;
  13509. if (ltp) {
  13510. error('JBIG2 error: prediction is not supported');
  13511. }
  13512. }
  13513. var row = new Uint8Array(width);
  13514. bitmap.push(row);
  13515. for (var j = 0; j < width; j++) {
  13516. var i0, j0;
  13517. var contextLabel = 0;
  13518. for (k = 0; k < codingTemplateLength; k++) {
  13519. i0 = i + codingTemplateY[k];
  13520. j0 = j + codingTemplateX[k];
  13521. if (i0 < 0 || j0 < 0 || j0 >= width) {
  13522. contextLabel <<= 1;
  13523. } else
  13524. {
  13525. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  13526. }
  13527. }
  13528. for (k = 0; k < referenceTemplateLength; k++) {
  13529. i0 = i + referenceTemplateY[k] + offsetY;
  13530. j0 = j + referenceTemplateX[k] + offsetX;
  13531. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  13532. contextLabel <<= 1;
  13533. } else
  13534. {
  13535. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  13536. }
  13537. }
  13538. var pixel = decoder.readBit(contexts, contextLabel);
  13539. row[j] = pixel;
  13540. }
  13541. }
  13542. return bitmap;
  13543. }
  13544. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  13545. if (huffman) {
  13546. error('JBIG2 error: huffman is not supported');
  13547. }
  13548. var newSymbols = [];
  13549. var currentHeight = 0;
  13550. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  13551. var decoder = decodingContext.decoder;
  13552. var contextCache = decodingContext.contextCache;
  13553. while (newSymbols.length < numberOfNewSymbols) {
  13554. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  13555. currentHeight += deltaHeight;
  13556. var currentWidth = 0;
  13557. var totalWidth = 0;
  13558. while (true) {
  13559. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  13560. if (deltaWidth === null) {
  13561. break;
  13562. }
  13563. currentWidth += deltaWidth;
  13564. totalWidth += currentWidth;
  13565. var bitmap;
  13566. if (refinement) {
  13567. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  13568. if (numberOfInstances > 1) {
  13569. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  13570. } else {
  13571. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  13572. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  13573. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  13574. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  13575. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  13576. }
  13577. } else {
  13578. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  13579. }
  13580. newSymbols.push(bitmap);
  13581. }
  13582. }
  13583. var exportedSymbols = [];
  13584. var flags = [], currentFlag = false;
  13585. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  13586. while (flags.length < totalSymbolsLength) {
  13587. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  13588. while (runLength--) {
  13589. flags.push(currentFlag);
  13590. }
  13591. currentFlag = !currentFlag;
  13592. }
  13593. for (var i = 0, ii = symbols.length; i < ii; i++) {
  13594. if (flags[i]) {
  13595. exportedSymbols.push(symbols[i]);
  13596. }
  13597. }
  13598. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  13599. if (flags[i]) {
  13600. exportedSymbols.push(newSymbols[j]);
  13601. }
  13602. }
  13603. return exportedSymbols;
  13604. }
  13605. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  13606. if (huffman) {
  13607. error('JBIG2 error: huffman is not supported');
  13608. }
  13609. var bitmap = [];
  13610. var i, row;
  13611. for (i = 0; i < height; i++) {
  13612. row = new Uint8Array(width);
  13613. if (defaultPixelValue) {
  13614. for (var j = 0; j < width; j++) {
  13615. row[j] = defaultPixelValue;
  13616. }
  13617. }
  13618. bitmap.push(row);
  13619. }
  13620. var decoder = decodingContext.decoder;
  13621. var contextCache = decodingContext.contextCache;
  13622. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  13623. var firstS = 0;
  13624. i = 0;
  13625. while (i < numberOfSymbolInstances) {
  13626. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  13627. stripT += deltaT;
  13628. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  13629. firstS += deltaFirstS;
  13630. var currentS = firstS;
  13631. do {
  13632. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  13633. var t = stripSize * stripT + currentT;
  13634. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  13635. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  13636. var symbolBitmap = inputSymbols[symbolId];
  13637. var symbolWidth = symbolBitmap[0].length;
  13638. var symbolHeight = symbolBitmap.length;
  13639. if (applyRefinement) {
  13640. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  13641. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  13642. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  13643. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  13644. symbolWidth += rdw;
  13645. symbolHeight += rdh;
  13646. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  13647. }
  13648. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  13649. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  13650. var s2, t2, symbolRow;
  13651. if (transposed) {
  13652. for (s2 = 0; s2 < symbolHeight; s2++) {
  13653. row = bitmap[offsetS + s2];
  13654. if (!row) {
  13655. continue;
  13656. }
  13657. symbolRow = symbolBitmap[s2];
  13658. var maxWidth = Math.min(width - offsetT, symbolWidth);
  13659. switch (combinationOperator) {
  13660. case 0:
  13661. for (t2 = 0; t2 < maxWidth; t2++) {
  13662. row[offsetT + t2] |= symbolRow[t2];
  13663. }
  13664. break;
  13665. case 2:
  13666. for (t2 = 0; t2 < maxWidth; t2++) {
  13667. row[offsetT + t2] ^= symbolRow[t2];
  13668. }
  13669. break;
  13670. default:
  13671. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  13672. }
  13673. }
  13674. currentS += symbolHeight - 1;
  13675. } else {
  13676. for (t2 = 0; t2 < symbolHeight; t2++) {
  13677. row = bitmap[offsetT + t2];
  13678. if (!row) {
  13679. continue;
  13680. }
  13681. symbolRow = symbolBitmap[t2];
  13682. switch (combinationOperator) {
  13683. case 0:
  13684. for (s2 = 0; s2 < symbolWidth; s2++) {
  13685. row[offsetS + s2] |= symbolRow[s2];
  13686. }
  13687. break;
  13688. case 2:
  13689. for (s2 = 0; s2 < symbolWidth; s2++) {
  13690. row[offsetS + s2] ^= symbolRow[s2];
  13691. }
  13692. break;
  13693. default:
  13694. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  13695. }
  13696. }
  13697. currentS += symbolWidth - 1;
  13698. }
  13699. i++;
  13700. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  13701. if (deltaS === null) {
  13702. break;
  13703. }
  13704. currentS += deltaS + dsOffset;
  13705. } while (true);
  13706. }
  13707. return bitmap;
  13708. }
  13709. function readSegmentHeader(data, start) {
  13710. var segmentHeader = {};
  13711. segmentHeader.number = readUint32(data, start);
  13712. var flags = data[start + 4];
  13713. var segmentType = flags & 0x3F;
  13714. if (!SegmentTypes[segmentType]) {
  13715. error('JBIG2 error: invalid segment type: ' + segmentType);
  13716. }
  13717. segmentHeader.type = segmentType;
  13718. segmentHeader.typeName = SegmentTypes[segmentType];
  13719. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  13720. var pageAssociationFieldSize = !!(flags & 0x40);
  13721. var referredFlags = data[start + 5];
  13722. var referredToCount = referredFlags >> 5 & 7;
  13723. var retainBits = [referredFlags & 31];
  13724. var position = start + 6;
  13725. if (referredFlags === 7) {
  13726. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  13727. position += 3;
  13728. var bytes = referredToCount + 7 >> 3;
  13729. retainBits[0] = data[position++];
  13730. while (--bytes > 0) {
  13731. retainBits.push(data[position++]);
  13732. }
  13733. } else if (referredFlags === 5 || referredFlags === 6) {
  13734. error('JBIG2 error: invalid referred-to flags');
  13735. }
  13736. segmentHeader.retainBits = retainBits;
  13737. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  13738. var referredTo = [];
  13739. var i, ii;
  13740. for (i = 0; i < referredToCount; i++) {
  13741. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  13742. referredTo.push(number);
  13743. position += referredToSegmentNumberSize;
  13744. }
  13745. segmentHeader.referredTo = referredTo;
  13746. if (!pageAssociationFieldSize) {
  13747. segmentHeader.pageAssociation = data[position++];
  13748. } else {
  13749. segmentHeader.pageAssociation = readUint32(data, position);
  13750. position += 4;
  13751. }
  13752. segmentHeader.length = readUint32(data, position);
  13753. position += 4;
  13754. if (segmentHeader.length === 0xFFFFFFFF) {
  13755. if (segmentType === 38) {
  13756. var genericRegionInfo = readRegionSegmentInformation(data, position);
  13757. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  13758. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  13759. var searchPatternLength = 6;
  13760. var searchPattern = new Uint8Array(searchPatternLength);
  13761. if (!genericRegionMmr) {
  13762. searchPattern[0] = 0xFF;
  13763. searchPattern[1] = 0xAC;
  13764. }
  13765. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  13766. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  13767. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  13768. searchPattern[5] = genericRegionInfo.height & 0xFF;
  13769. for (i = position, ii = data.length; i < ii; i++) {
  13770. var j = 0;
  13771. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  13772. j++;
  13773. }
  13774. if (j === searchPatternLength) {
  13775. segmentHeader.length = i + searchPatternLength;
  13776. break;
  13777. }
  13778. }
  13779. if (segmentHeader.length === 0xFFFFFFFF) {
  13780. error('JBIG2 error: segment end was not found');
  13781. }
  13782. } else {
  13783. error('JBIG2 error: invalid unknown segment length');
  13784. }
  13785. }
  13786. segmentHeader.headerEnd = position;
  13787. return segmentHeader;
  13788. }
  13789. function readSegments(header, data, start, end) {
  13790. var segments = [];
  13791. var position = start;
  13792. while (position < end) {
  13793. var segmentHeader = readSegmentHeader(data, position);
  13794. position = segmentHeader.headerEnd;
  13795. var segment = {
  13796. header: segmentHeader,
  13797. data: data
  13798. };
  13799. if (!header.randomAccess) {
  13800. segment.start = position;
  13801. position += segmentHeader.length;
  13802. segment.end = position;
  13803. }
  13804. segments.push(segment);
  13805. if (segmentHeader.type === 51) {
  13806. break;
  13807. }
  13808. }
  13809. if (header.randomAccess) {
  13810. for (var i = 0, ii = segments.length; i < ii; i++) {
  13811. segments[i].start = position;
  13812. position += segments[i].header.length;
  13813. segments[i].end = position;
  13814. }
  13815. }
  13816. return segments;
  13817. }
  13818. function readRegionSegmentInformation(data, start) {
  13819. return {
  13820. width: readUint32(data, start),
  13821. height: readUint32(data, start + 4),
  13822. x: readUint32(data, start + 8),
  13823. y: readUint32(data, start + 12),
  13824. combinationOperator: data[start + 16] & 7
  13825. };
  13826. }
  13827. var RegionSegmentInformationFieldLength = 17;
  13828. function processSegment(segment, visitor) {
  13829. var header = segment.header;
  13830. var data = segment.data, position = segment.start, end = segment.end;
  13831. var args, at, i, atLength;
  13832. switch (header.type) {
  13833. case 0:
  13834. var dictionary = {};
  13835. var dictionaryFlags = readUint16(data, position);
  13836. dictionary.huffman = !!(dictionaryFlags & 1);
  13837. dictionary.refinement = !!(dictionaryFlags & 2);
  13838. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  13839. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  13840. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  13841. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  13842. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  13843. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  13844. dictionary.template = dictionaryFlags >> 10 & 3;
  13845. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  13846. position += 2;
  13847. if (!dictionary.huffman) {
  13848. atLength = dictionary.template === 0 ? 4 : 1;
  13849. at = [];
  13850. for (i = 0; i < atLength; i++) {
  13851. at.push({
  13852. x: readInt8(data, position),
  13853. y: readInt8(data, position + 1)
  13854. });
  13855. position += 2;
  13856. }
  13857. dictionary.at = at;
  13858. }
  13859. if (dictionary.refinement && !dictionary.refinementTemplate) {
  13860. at = [];
  13861. for (i = 0; i < 2; i++) {
  13862. at.push({
  13863. x: readInt8(data, position),
  13864. y: readInt8(data, position + 1)
  13865. });
  13866. position += 2;
  13867. }
  13868. dictionary.refinementAt = at;
  13869. }
  13870. dictionary.numberOfExportedSymbols = readUint32(data, position);
  13871. position += 4;
  13872. dictionary.numberOfNewSymbols = readUint32(data, position);
  13873. position += 4;
  13874. args = [
  13875. dictionary,
  13876. header.number,
  13877. header.referredTo,
  13878. data,
  13879. position,
  13880. end
  13881. ];
  13882. break;
  13883. case 6:
  13884. case 7:
  13885. var textRegion = {};
  13886. textRegion.info = readRegionSegmentInformation(data, position);
  13887. position += RegionSegmentInformationFieldLength;
  13888. var textRegionSegmentFlags = readUint16(data, position);
  13889. position += 2;
  13890. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  13891. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  13892. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  13893. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  13894. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  13895. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  13896. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  13897. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  13898. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  13899. if (textRegion.huffman) {
  13900. var textRegionHuffmanFlags = readUint16(data, position);
  13901. position += 2;
  13902. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  13903. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  13904. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  13905. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  13906. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  13907. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  13908. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  13909. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  13910. }
  13911. if (textRegion.refinement && !textRegion.refinementTemplate) {
  13912. at = [];
  13913. for (i = 0; i < 2; i++) {
  13914. at.push({
  13915. x: readInt8(data, position),
  13916. y: readInt8(data, position + 1)
  13917. });
  13918. position += 2;
  13919. }
  13920. textRegion.refinementAt = at;
  13921. }
  13922. textRegion.numberOfSymbolInstances = readUint32(data, position);
  13923. position += 4;
  13924. if (textRegion.huffman) {
  13925. error('JBIG2 error: huffman is not supported');
  13926. }
  13927. args = [
  13928. textRegion,
  13929. header.referredTo,
  13930. data,
  13931. position,
  13932. end
  13933. ];
  13934. break;
  13935. case 38:
  13936. case 39:
  13937. var genericRegion = {};
  13938. genericRegion.info = readRegionSegmentInformation(data, position);
  13939. position += RegionSegmentInformationFieldLength;
  13940. var genericRegionSegmentFlags = data[position++];
  13941. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  13942. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  13943. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  13944. if (!genericRegion.mmr) {
  13945. atLength = genericRegion.template === 0 ? 4 : 1;
  13946. at = [];
  13947. for (i = 0; i < atLength; i++) {
  13948. at.push({
  13949. x: readInt8(data, position),
  13950. y: readInt8(data, position + 1)
  13951. });
  13952. position += 2;
  13953. }
  13954. genericRegion.at = at;
  13955. }
  13956. args = [
  13957. genericRegion,
  13958. data,
  13959. position,
  13960. end
  13961. ];
  13962. break;
  13963. case 48:
  13964. var pageInfo = {
  13965. width: readUint32(data, position),
  13966. height: readUint32(data, position + 4),
  13967. resolutionX: readUint32(data, position + 8),
  13968. resolutionY: readUint32(data, position + 12)
  13969. };
  13970. if (pageInfo.height === 0xFFFFFFFF) {
  13971. delete pageInfo.height;
  13972. }
  13973. var pageSegmentFlags = data[position + 16];
  13974. var pageStripingInformation = readUint16(data, position + 17);
  13975. pageInfo.lossless = !!(pageSegmentFlags & 1);
  13976. pageInfo.refinement = !!(pageSegmentFlags & 2);
  13977. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  13978. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  13979. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  13980. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  13981. args = [pageInfo];
  13982. break;
  13983. case 49:
  13984. break;
  13985. case 50:
  13986. break;
  13987. case 51:
  13988. break;
  13989. case 62:
  13990. break;
  13991. default:
  13992. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  13993. }
  13994. var callbackName = 'on' + header.typeName;
  13995. if (callbackName in visitor) {
  13996. visitor[callbackName].apply(visitor, args);
  13997. }
  13998. }
  13999. function processSegments(segments, visitor) {
  14000. for (var i = 0, ii = segments.length; i < ii; i++) {
  14001. processSegment(segments[i], visitor);
  14002. }
  14003. }
  14004. function parseJbig2(data, start, end) {
  14005. var position = start;
  14006. 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) {
  14007. error('JBIG2 error: invalid header');
  14008. }
  14009. var header = {};
  14010. position += 8;
  14011. var flags = data[position++];
  14012. header.randomAccess = !(flags & 1);
  14013. if (!(flags & 2)) {
  14014. header.numberOfPages = readUint32(data, position);
  14015. position += 4;
  14016. }
  14017. var segments = readSegments(header, data, position, end);
  14018. error('Not implemented');
  14019. }
  14020. function parseJbig2Chunks(chunks) {
  14021. var visitor = new SimpleSegmentVisitor();
  14022. for (var i = 0, ii = chunks.length; i < ii; i++) {
  14023. var chunk = chunks[i];
  14024. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  14025. processSegments(segments, visitor);
  14026. }
  14027. return visitor.buffer;
  14028. }
  14029. function SimpleSegmentVisitor() {
  14030. }
  14031. SimpleSegmentVisitor.prototype = {
  14032. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  14033. this.currentPageInfo = info;
  14034. var rowSize = info.width + 7 >> 3;
  14035. var buffer = new Uint8Array(rowSize * info.height);
  14036. if (info.defaultPixelValue) {
  14037. for (var i = 0, ii = buffer.length; i < ii; i++) {
  14038. buffer[i] = 0xFF;
  14039. }
  14040. }
  14041. this.buffer = buffer;
  14042. },
  14043. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  14044. var pageInfo = this.currentPageInfo;
  14045. var width = regionInfo.width, height = regionInfo.height;
  14046. var rowSize = pageInfo.width + 7 >> 3;
  14047. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  14048. var buffer = this.buffer;
  14049. var mask0 = 128 >> (regionInfo.x & 7);
  14050. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  14051. var i, j, mask, offset;
  14052. switch (combinationOperator) {
  14053. case 0:
  14054. for (i = 0; i < height; i++) {
  14055. mask = mask0;
  14056. offset = offset0;
  14057. for (j = 0; j < width; j++) {
  14058. if (bitmap[i][j]) {
  14059. buffer[offset] |= mask;
  14060. }
  14061. mask >>= 1;
  14062. if (!mask) {
  14063. mask = 128;
  14064. offset++;
  14065. }
  14066. }
  14067. offset0 += rowSize;
  14068. }
  14069. break;
  14070. case 2:
  14071. for (i = 0; i < height; i++) {
  14072. mask = mask0;
  14073. offset = offset0;
  14074. for (j = 0; j < width; j++) {
  14075. if (bitmap[i][j]) {
  14076. buffer[offset] ^= mask;
  14077. }
  14078. mask >>= 1;
  14079. if (!mask) {
  14080. mask = 128;
  14081. offset++;
  14082. }
  14083. }
  14084. offset0 += rowSize;
  14085. }
  14086. break;
  14087. default:
  14088. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  14089. }
  14090. },
  14091. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  14092. var regionInfo = region.info;
  14093. var decodingContext = new DecodingContext(data, start, end);
  14094. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  14095. this.drawBitmap(regionInfo, bitmap);
  14096. },
  14097. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  14098. this.onImmediateGenericRegion.apply(this, arguments);
  14099. },
  14100. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  14101. var huffmanTables;
  14102. if (dictionary.huffman) {
  14103. error('JBIG2 error: huffman is not supported');
  14104. }
  14105. var symbols = this.symbols;
  14106. if (!symbols) {
  14107. this.symbols = symbols = {};
  14108. }
  14109. var inputSymbols = [];
  14110. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  14111. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  14112. }
  14113. var decodingContext = new DecodingContext(data, start, end);
  14114. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  14115. },
  14116. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  14117. var regionInfo = region.info;
  14118. var huffmanTables;
  14119. var symbols = this.symbols;
  14120. var inputSymbols = [];
  14121. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  14122. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  14123. }
  14124. var symbolCodeLength = log2(inputSymbols.length);
  14125. var decodingContext = new DecodingContext(data, start, end);
  14126. 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);
  14127. this.drawBitmap(regionInfo, bitmap);
  14128. },
  14129. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  14130. this.onImmediateTextRegion.apply(this, arguments);
  14131. }
  14132. };
  14133. function Jbig2Image() {
  14134. }
  14135. Jbig2Image.prototype = {
  14136. parseChunks: function Jbig2Image_parseChunks(chunks) {
  14137. return parseJbig2Chunks(chunks);
  14138. }
  14139. };
  14140. return Jbig2Image;
  14141. }();
  14142. exports.Jbig2Image = Jbig2Image;
  14143. }));
  14144. (function (root, factory) {
  14145. factory(root.pdfjsCoreJpg = {}, root.pdfjsSharedUtil);
  14146. }(this, function (exports, sharedUtil) {
  14147. var error = sharedUtil.error;
  14148. var JpegImage = function JpegImageClosure() {
  14149. var dctZigZag = new Uint8Array([
  14150. 0,
  14151. 1,
  14152. 8,
  14153. 16,
  14154. 9,
  14155. 2,
  14156. 3,
  14157. 10,
  14158. 17,
  14159. 24,
  14160. 32,
  14161. 25,
  14162. 18,
  14163. 11,
  14164. 4,
  14165. 5,
  14166. 12,
  14167. 19,
  14168. 26,
  14169. 33,
  14170. 40,
  14171. 48,
  14172. 41,
  14173. 34,
  14174. 27,
  14175. 20,
  14176. 13,
  14177. 6,
  14178. 7,
  14179. 14,
  14180. 21,
  14181. 28,
  14182. 35,
  14183. 42,
  14184. 49,
  14185. 56,
  14186. 57,
  14187. 50,
  14188. 43,
  14189. 36,
  14190. 29,
  14191. 22,
  14192. 15,
  14193. 23,
  14194. 30,
  14195. 37,
  14196. 44,
  14197. 51,
  14198. 58,
  14199. 59,
  14200. 52,
  14201. 45,
  14202. 38,
  14203. 31,
  14204. 39,
  14205. 46,
  14206. 53,
  14207. 60,
  14208. 61,
  14209. 54,
  14210. 47,
  14211. 55,
  14212. 62,
  14213. 63
  14214. ]);
  14215. var dctCos1 = 4017;
  14216. var dctSin1 = 799;
  14217. var dctCos3 = 3406;
  14218. var dctSin3 = 2276;
  14219. var dctCos6 = 1567;
  14220. var dctSin6 = 3784;
  14221. var dctSqrt2 = 5793;
  14222. var dctSqrt1d2 = 2896;
  14223. function JpegImage() {
  14224. this.decodeTransform = null;
  14225. this.colorTransform = -1;
  14226. }
  14227. function buildHuffmanTable(codeLengths, values) {
  14228. var k = 0, code = [], i, j, length = 16;
  14229. while (length > 0 && !codeLengths[length - 1]) {
  14230. length--;
  14231. }
  14232. code.push({
  14233. children: [],
  14234. index: 0
  14235. });
  14236. var p = code[0], q;
  14237. for (i = 0; i < length; i++) {
  14238. for (j = 0; j < codeLengths[i]; j++) {
  14239. p = code.pop();
  14240. p.children[p.index] = values[k];
  14241. while (p.index > 0) {
  14242. p = code.pop();
  14243. }
  14244. p.index++;
  14245. code.push(p);
  14246. while (code.length <= i) {
  14247. code.push(q = {
  14248. children: [],
  14249. index: 0
  14250. });
  14251. p.children[p.index] = q.children;
  14252. p = q;
  14253. }
  14254. k++;
  14255. }
  14256. if (i + 1 < length) {
  14257. code.push(q = {
  14258. children: [],
  14259. index: 0
  14260. });
  14261. p.children[p.index] = q.children;
  14262. p = q;
  14263. }
  14264. }
  14265. return code[0].children;
  14266. }
  14267. function getBlockBufferOffset(component, row, col) {
  14268. return 64 * ((component.blocksPerLine + 1) * row + col);
  14269. }
  14270. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  14271. var mcusPerLine = frame.mcusPerLine;
  14272. var progressive = frame.progressive;
  14273. var startOffset = offset, bitsData = 0, bitsCount = 0;
  14274. function readBit() {
  14275. if (bitsCount > 0) {
  14276. bitsCount--;
  14277. return bitsData >> bitsCount & 1;
  14278. }
  14279. bitsData = data[offset++];
  14280. if (bitsData === 0xFF) {
  14281. var nextByte = data[offset++];
  14282. if (nextByte) {
  14283. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  14284. }
  14285. }
  14286. bitsCount = 7;
  14287. return bitsData >>> 7;
  14288. }
  14289. function decodeHuffman(tree) {
  14290. var node = tree;
  14291. while (true) {
  14292. node = node[readBit()];
  14293. if (typeof node === 'number') {
  14294. return node;
  14295. }
  14296. if (typeof node !== 'object') {
  14297. error('JPEG error: invalid huffman sequence');
  14298. }
  14299. }
  14300. }
  14301. function receive(length) {
  14302. var n = 0;
  14303. while (length > 0) {
  14304. n = n << 1 | readBit();
  14305. length--;
  14306. }
  14307. return n;
  14308. }
  14309. function receiveAndExtend(length) {
  14310. if (length === 1) {
  14311. return readBit() === 1 ? 1 : -1;
  14312. }
  14313. var n = receive(length);
  14314. if (n >= 1 << length - 1) {
  14315. return n;
  14316. }
  14317. return n + (-1 << length) + 1;
  14318. }
  14319. function decodeBaseline(component, offset) {
  14320. var t = decodeHuffman(component.huffmanTableDC);
  14321. var diff = t === 0 ? 0 : receiveAndExtend(t);
  14322. component.blockData[offset] = component.pred += diff;
  14323. var k = 1;
  14324. while (k < 64) {
  14325. var rs = decodeHuffman(component.huffmanTableAC);
  14326. var s = rs & 15, r = rs >> 4;
  14327. if (s === 0) {
  14328. if (r < 15) {
  14329. break;
  14330. }
  14331. k += 16;
  14332. continue;
  14333. }
  14334. k += r;
  14335. var z = dctZigZag[k];
  14336. component.blockData[offset + z] = receiveAndExtend(s);
  14337. k++;
  14338. }
  14339. }
  14340. function decodeDCFirst(component, offset) {
  14341. var t = decodeHuffman(component.huffmanTableDC);
  14342. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  14343. component.blockData[offset] = component.pred += diff;
  14344. }
  14345. function decodeDCSuccessive(component, offset) {
  14346. component.blockData[offset] |= readBit() << successive;
  14347. }
  14348. var eobrun = 0;
  14349. function decodeACFirst(component, offset) {
  14350. if (eobrun > 0) {
  14351. eobrun--;
  14352. return;
  14353. }
  14354. var k = spectralStart, e = spectralEnd;
  14355. while (k <= e) {
  14356. var rs = decodeHuffman(component.huffmanTableAC);
  14357. var s = rs & 15, r = rs >> 4;
  14358. if (s === 0) {
  14359. if (r < 15) {
  14360. eobrun = receive(r) + (1 << r) - 1;
  14361. break;
  14362. }
  14363. k += 16;
  14364. continue;
  14365. }
  14366. k += r;
  14367. var z = dctZigZag[k];
  14368. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  14369. k++;
  14370. }
  14371. }
  14372. var successiveACState = 0, successiveACNextValue;
  14373. function decodeACSuccessive(component, offset) {
  14374. var k = spectralStart;
  14375. var e = spectralEnd;
  14376. var r = 0;
  14377. var s;
  14378. var rs;
  14379. while (k <= e) {
  14380. var z = dctZigZag[k];
  14381. switch (successiveACState) {
  14382. case 0:
  14383. rs = decodeHuffman(component.huffmanTableAC);
  14384. s = rs & 15;
  14385. r = rs >> 4;
  14386. if (s === 0) {
  14387. if (r < 15) {
  14388. eobrun = receive(r) + (1 << r);
  14389. successiveACState = 4;
  14390. } else {
  14391. r = 16;
  14392. successiveACState = 1;
  14393. }
  14394. } else {
  14395. if (s !== 1) {
  14396. error('JPEG error: invalid ACn encoding');
  14397. }
  14398. successiveACNextValue = receiveAndExtend(s);
  14399. successiveACState = r ? 2 : 3;
  14400. }
  14401. continue;
  14402. case 1:
  14403. case 2:
  14404. if (component.blockData[offset + z]) {
  14405. component.blockData[offset + z] += readBit() << successive;
  14406. } else {
  14407. r--;
  14408. if (r === 0) {
  14409. successiveACState = successiveACState === 2 ? 3 : 0;
  14410. }
  14411. }
  14412. break;
  14413. case 3:
  14414. if (component.blockData[offset + z]) {
  14415. component.blockData[offset + z] += readBit() << successive;
  14416. } else {
  14417. component.blockData[offset + z] = successiveACNextValue << successive;
  14418. successiveACState = 0;
  14419. }
  14420. break;
  14421. case 4:
  14422. if (component.blockData[offset + z]) {
  14423. component.blockData[offset + z] += readBit() << successive;
  14424. }
  14425. break;
  14426. }
  14427. k++;
  14428. }
  14429. if (successiveACState === 4) {
  14430. eobrun--;
  14431. if (eobrun === 0) {
  14432. successiveACState = 0;
  14433. }
  14434. }
  14435. }
  14436. function decodeMcu(component, decode, mcu, row, col) {
  14437. var mcuRow = mcu / mcusPerLine | 0;
  14438. var mcuCol = mcu % mcusPerLine;
  14439. var blockRow = mcuRow * component.v + row;
  14440. var blockCol = mcuCol * component.h + col;
  14441. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14442. decode(component, offset);
  14443. }
  14444. function decodeBlock(component, decode, mcu) {
  14445. var blockRow = mcu / component.blocksPerLine | 0;
  14446. var blockCol = mcu % component.blocksPerLine;
  14447. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14448. decode(component, offset);
  14449. }
  14450. var componentsLength = components.length;
  14451. var component, i, j, k, n;
  14452. var decodeFn;
  14453. if (progressive) {
  14454. if (spectralStart === 0) {
  14455. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  14456. } else {
  14457. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  14458. }
  14459. } else {
  14460. decodeFn = decodeBaseline;
  14461. }
  14462. var mcu = 0, marker;
  14463. var mcuExpected;
  14464. if (componentsLength === 1) {
  14465. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  14466. } else {
  14467. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  14468. }
  14469. if (!resetInterval) {
  14470. resetInterval = mcuExpected;
  14471. }
  14472. var h, v;
  14473. while (mcu < mcuExpected) {
  14474. for (i = 0; i < componentsLength; i++) {
  14475. components[i].pred = 0;
  14476. }
  14477. eobrun = 0;
  14478. if (componentsLength === 1) {
  14479. component = components[0];
  14480. for (n = 0; n < resetInterval; n++) {
  14481. decodeBlock(component, decodeFn, mcu);
  14482. mcu++;
  14483. }
  14484. } else {
  14485. for (n = 0; n < resetInterval; n++) {
  14486. for (i = 0; i < componentsLength; i++) {
  14487. component = components[i];
  14488. h = component.h;
  14489. v = component.v;
  14490. for (j = 0; j < v; j++) {
  14491. for (k = 0; k < h; k++) {
  14492. decodeMcu(component, decodeFn, mcu, j, k);
  14493. }
  14494. }
  14495. }
  14496. mcu++;
  14497. }
  14498. }
  14499. bitsCount = 0;
  14500. marker = data[offset] << 8 | data[offset + 1];
  14501. while (data[offset] === 0x00 && offset < data.length - 1) {
  14502. offset++;
  14503. marker = data[offset] << 8 | data[offset + 1];
  14504. }
  14505. if (marker <= 0xFF00) {
  14506. error('JPEG error: marker was not found');
  14507. }
  14508. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  14509. offset += 2;
  14510. } else {
  14511. break;
  14512. }
  14513. }
  14514. return offset - startOffset;
  14515. }
  14516. function quantizeAndInverse(component, blockBufferOffset, p) {
  14517. var qt = component.quantizationTable, blockData = component.blockData;
  14518. var v0, v1, v2, v3, v4, v5, v6, v7;
  14519. var p0, p1, p2, p3, p4, p5, p6, p7;
  14520. var t;
  14521. if (!qt) {
  14522. error('JPEG error: missing required Quantization Table.');
  14523. }
  14524. for (var row = 0; row < 64; row += 8) {
  14525. p0 = blockData[blockBufferOffset + row];
  14526. p1 = blockData[blockBufferOffset + row + 1];
  14527. p2 = blockData[blockBufferOffset + row + 2];
  14528. p3 = blockData[blockBufferOffset + row + 3];
  14529. p4 = blockData[blockBufferOffset + row + 4];
  14530. p5 = blockData[blockBufferOffset + row + 5];
  14531. p6 = blockData[blockBufferOffset + row + 6];
  14532. p7 = blockData[blockBufferOffset + row + 7];
  14533. p0 *= qt[row];
  14534. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  14535. t = dctSqrt2 * p0 + 512 >> 10;
  14536. p[row] = t;
  14537. p[row + 1] = t;
  14538. p[row + 2] = t;
  14539. p[row + 3] = t;
  14540. p[row + 4] = t;
  14541. p[row + 5] = t;
  14542. p[row + 6] = t;
  14543. p[row + 7] = t;
  14544. continue;
  14545. }
  14546. p1 *= qt[row + 1];
  14547. p2 *= qt[row + 2];
  14548. p3 *= qt[row + 3];
  14549. p4 *= qt[row + 4];
  14550. p5 *= qt[row + 5];
  14551. p6 *= qt[row + 6];
  14552. p7 *= qt[row + 7];
  14553. v0 = dctSqrt2 * p0 + 128 >> 8;
  14554. v1 = dctSqrt2 * p4 + 128 >> 8;
  14555. v2 = p2;
  14556. v3 = p6;
  14557. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  14558. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  14559. v5 = p3 << 4;
  14560. v6 = p5 << 4;
  14561. v0 = v0 + v1 + 1 >> 1;
  14562. v1 = v0 - v1;
  14563. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  14564. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  14565. v3 = t;
  14566. v4 = v4 + v6 + 1 >> 1;
  14567. v6 = v4 - v6;
  14568. v7 = v7 + v5 + 1 >> 1;
  14569. v5 = v7 - v5;
  14570. v0 = v0 + v3 + 1 >> 1;
  14571. v3 = v0 - v3;
  14572. v1 = v1 + v2 + 1 >> 1;
  14573. v2 = v1 - v2;
  14574. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  14575. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  14576. v7 = t;
  14577. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  14578. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  14579. v6 = t;
  14580. p[row] = v0 + v7;
  14581. p[row + 7] = v0 - v7;
  14582. p[row + 1] = v1 + v6;
  14583. p[row + 6] = v1 - v6;
  14584. p[row + 2] = v2 + v5;
  14585. p[row + 5] = v2 - v5;
  14586. p[row + 3] = v3 + v4;
  14587. p[row + 4] = v3 - v4;
  14588. }
  14589. for (var col = 0; col < 8; ++col) {
  14590. p0 = p[col];
  14591. p1 = p[col + 8];
  14592. p2 = p[col + 16];
  14593. p3 = p[col + 24];
  14594. p4 = p[col + 32];
  14595. p5 = p[col + 40];
  14596. p6 = p[col + 48];
  14597. p7 = p[col + 56];
  14598. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  14599. t = dctSqrt2 * p0 + 8192 >> 14;
  14600. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  14601. blockData[blockBufferOffset + col] = t;
  14602. blockData[blockBufferOffset + col + 8] = t;
  14603. blockData[blockBufferOffset + col + 16] = t;
  14604. blockData[blockBufferOffset + col + 24] = t;
  14605. blockData[blockBufferOffset + col + 32] = t;
  14606. blockData[blockBufferOffset + col + 40] = t;
  14607. blockData[blockBufferOffset + col + 48] = t;
  14608. blockData[blockBufferOffset + col + 56] = t;
  14609. continue;
  14610. }
  14611. v0 = dctSqrt2 * p0 + 2048 >> 12;
  14612. v1 = dctSqrt2 * p4 + 2048 >> 12;
  14613. v2 = p2;
  14614. v3 = p6;
  14615. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  14616. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  14617. v5 = p3;
  14618. v6 = p5;
  14619. v0 = (v0 + v1 + 1 >> 1) + 4112;
  14620. v1 = v0 - v1;
  14621. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  14622. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  14623. v3 = t;
  14624. v4 = v4 + v6 + 1 >> 1;
  14625. v6 = v4 - v6;
  14626. v7 = v7 + v5 + 1 >> 1;
  14627. v5 = v7 - v5;
  14628. v0 = v0 + v3 + 1 >> 1;
  14629. v3 = v0 - v3;
  14630. v1 = v1 + v2 + 1 >> 1;
  14631. v2 = v1 - v2;
  14632. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  14633. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  14634. v7 = t;
  14635. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  14636. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  14637. v6 = t;
  14638. p0 = v0 + v7;
  14639. p7 = v0 - v7;
  14640. p1 = v1 + v6;
  14641. p6 = v1 - v6;
  14642. p2 = v2 + v5;
  14643. p5 = v2 - v5;
  14644. p3 = v3 + v4;
  14645. p4 = v3 - v4;
  14646. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  14647. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  14648. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  14649. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  14650. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  14651. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  14652. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  14653. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  14654. blockData[blockBufferOffset + col] = p0;
  14655. blockData[blockBufferOffset + col + 8] = p1;
  14656. blockData[blockBufferOffset + col + 16] = p2;
  14657. blockData[blockBufferOffset + col + 24] = p3;
  14658. blockData[blockBufferOffset + col + 32] = p4;
  14659. blockData[blockBufferOffset + col + 40] = p5;
  14660. blockData[blockBufferOffset + col + 48] = p6;
  14661. blockData[blockBufferOffset + col + 56] = p7;
  14662. }
  14663. }
  14664. function buildComponentData(frame, component) {
  14665. var blocksPerLine = component.blocksPerLine;
  14666. var blocksPerColumn = component.blocksPerColumn;
  14667. var computationBuffer = new Int16Array(64);
  14668. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  14669. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  14670. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14671. quantizeAndInverse(component, offset, computationBuffer);
  14672. }
  14673. }
  14674. return component.blockData;
  14675. }
  14676. function clamp0to255(a) {
  14677. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  14678. }
  14679. JpegImage.prototype = {
  14680. parse: function parse(data) {
  14681. function readUint16() {
  14682. var value = data[offset] << 8 | data[offset + 1];
  14683. offset += 2;
  14684. return value;
  14685. }
  14686. function readDataBlock() {
  14687. var length = readUint16();
  14688. var array = data.subarray(offset, offset + length - 2);
  14689. offset += array.length;
  14690. return array;
  14691. }
  14692. function prepareComponents(frame) {
  14693. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  14694. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  14695. for (var i = 0; i < frame.components.length; i++) {
  14696. component = frame.components[i];
  14697. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  14698. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  14699. var blocksPerLineForMcu = mcusPerLine * component.h;
  14700. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  14701. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  14702. component.blockData = new Int16Array(blocksBufferSize);
  14703. component.blocksPerLine = blocksPerLine;
  14704. component.blocksPerColumn = blocksPerColumn;
  14705. }
  14706. frame.mcusPerLine = mcusPerLine;
  14707. frame.mcusPerColumn = mcusPerColumn;
  14708. }
  14709. var offset = 0;
  14710. var jfif = null;
  14711. var adobe = null;
  14712. var frame, resetInterval;
  14713. var quantizationTables = [];
  14714. var huffmanTablesAC = [], huffmanTablesDC = [];
  14715. var fileMarker = readUint16();
  14716. if (fileMarker !== 0xFFD8) {
  14717. error('JPEG error: SOI not found');
  14718. }
  14719. fileMarker = readUint16();
  14720. while (fileMarker !== 0xFFD9) {
  14721. var i, j, l;
  14722. switch (fileMarker) {
  14723. case 0xFFE0:
  14724. case 0xFFE1:
  14725. case 0xFFE2:
  14726. case 0xFFE3:
  14727. case 0xFFE4:
  14728. case 0xFFE5:
  14729. case 0xFFE6:
  14730. case 0xFFE7:
  14731. case 0xFFE8:
  14732. case 0xFFE9:
  14733. case 0xFFEA:
  14734. case 0xFFEB:
  14735. case 0xFFEC:
  14736. case 0xFFED:
  14737. case 0xFFEE:
  14738. case 0xFFEF:
  14739. case 0xFFFE:
  14740. var appData = readDataBlock();
  14741. if (fileMarker === 0xFFE0) {
  14742. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  14743. jfif = {
  14744. version: {
  14745. major: appData[5],
  14746. minor: appData[6]
  14747. },
  14748. densityUnits: appData[7],
  14749. xDensity: appData[8] << 8 | appData[9],
  14750. yDensity: appData[10] << 8 | appData[11],
  14751. thumbWidth: appData[12],
  14752. thumbHeight: appData[13],
  14753. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  14754. };
  14755. }
  14756. }
  14757. if (fileMarker === 0xFFEE) {
  14758. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  14759. adobe = {
  14760. version: appData[5] << 8 | appData[6],
  14761. flags0: appData[7] << 8 | appData[8],
  14762. flags1: appData[9] << 8 | appData[10],
  14763. transformCode: appData[11]
  14764. };
  14765. }
  14766. }
  14767. break;
  14768. case 0xFFDB:
  14769. var quantizationTablesLength = readUint16();
  14770. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  14771. var z;
  14772. while (offset < quantizationTablesEnd) {
  14773. var quantizationTableSpec = data[offset++];
  14774. var tableData = new Uint16Array(64);
  14775. if (quantizationTableSpec >> 4 === 0) {
  14776. for (j = 0; j < 64; j++) {
  14777. z = dctZigZag[j];
  14778. tableData[z] = data[offset++];
  14779. }
  14780. } else if (quantizationTableSpec >> 4 === 1) {
  14781. for (j = 0; j < 64; j++) {
  14782. z = dctZigZag[j];
  14783. tableData[z] = readUint16();
  14784. }
  14785. } else {
  14786. error('JPEG error: DQT - invalid table spec');
  14787. }
  14788. quantizationTables[quantizationTableSpec & 15] = tableData;
  14789. }
  14790. break;
  14791. case 0xFFC0:
  14792. case 0xFFC1:
  14793. case 0xFFC2:
  14794. if (frame) {
  14795. error('JPEG error: Only single frame JPEGs supported');
  14796. }
  14797. readUint16();
  14798. frame = {};
  14799. frame.extended = fileMarker === 0xFFC1;
  14800. frame.progressive = fileMarker === 0xFFC2;
  14801. frame.precision = data[offset++];
  14802. frame.scanLines = readUint16();
  14803. frame.samplesPerLine = readUint16();
  14804. frame.components = [];
  14805. frame.componentIds = {};
  14806. var componentsCount = data[offset++], componentId;
  14807. var maxH = 0, maxV = 0;
  14808. for (i = 0; i < componentsCount; i++) {
  14809. componentId = data[offset];
  14810. var h = data[offset + 1] >> 4;
  14811. var v = data[offset + 1] & 15;
  14812. if (maxH < h) {
  14813. maxH = h;
  14814. }
  14815. if (maxV < v) {
  14816. maxV = v;
  14817. }
  14818. var qId = data[offset + 2];
  14819. l = frame.components.push({
  14820. h: h,
  14821. v: v,
  14822. quantizationId: qId,
  14823. quantizationTable: null
  14824. });
  14825. frame.componentIds[componentId] = l - 1;
  14826. offset += 3;
  14827. }
  14828. frame.maxH = maxH;
  14829. frame.maxV = maxV;
  14830. prepareComponents(frame);
  14831. break;
  14832. case 0xFFC4:
  14833. var huffmanLength = readUint16();
  14834. for (i = 2; i < huffmanLength;) {
  14835. var huffmanTableSpec = data[offset++];
  14836. var codeLengths = new Uint8Array(16);
  14837. var codeLengthSum = 0;
  14838. for (j = 0; j < 16; j++, offset++) {
  14839. codeLengthSum += codeLengths[j] = data[offset];
  14840. }
  14841. var huffmanValues = new Uint8Array(codeLengthSum);
  14842. for (j = 0; j < codeLengthSum; j++, offset++) {
  14843. huffmanValues[j] = data[offset];
  14844. }
  14845. i += 17 + codeLengthSum;
  14846. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  14847. }
  14848. break;
  14849. case 0xFFDD:
  14850. readUint16();
  14851. resetInterval = readUint16();
  14852. break;
  14853. case 0xFFDA:
  14854. var scanLength = readUint16();
  14855. var selectorsCount = data[offset++];
  14856. var components = [], component;
  14857. for (i = 0; i < selectorsCount; i++) {
  14858. var componentIndex = frame.componentIds[data[offset++]];
  14859. component = frame.components[componentIndex];
  14860. var tableSpec = data[offset++];
  14861. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  14862. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  14863. components.push(component);
  14864. }
  14865. var spectralStart = data[offset++];
  14866. var spectralEnd = data[offset++];
  14867. var successiveApproximation = data[offset++];
  14868. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  14869. offset += processed;
  14870. break;
  14871. case 0xFFFF:
  14872. if (data[offset] !== 0xFF) {
  14873. offset--;
  14874. }
  14875. break;
  14876. default:
  14877. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  14878. offset -= 3;
  14879. break;
  14880. }
  14881. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  14882. }
  14883. fileMarker = readUint16();
  14884. }
  14885. this.width = frame.samplesPerLine;
  14886. this.height = frame.scanLines;
  14887. this.jfif = jfif;
  14888. this.adobe = adobe;
  14889. this.components = [];
  14890. for (i = 0; i < frame.components.length; i++) {
  14891. component = frame.components[i];
  14892. var quantizationTable = quantizationTables[component.quantizationId];
  14893. if (quantizationTable) {
  14894. component.quantizationTable = quantizationTable;
  14895. }
  14896. this.components.push({
  14897. output: buildComponentData(frame, component),
  14898. scaleX: component.h / frame.maxH,
  14899. scaleY: component.v / frame.maxV,
  14900. blocksPerLine: component.blocksPerLine,
  14901. blocksPerColumn: component.blocksPerColumn
  14902. });
  14903. }
  14904. this.numComponents = this.components.length;
  14905. },
  14906. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  14907. var scaleX = this.width / width, scaleY = this.height / height;
  14908. var component, componentScaleX, componentScaleY, blocksPerScanline;
  14909. var x, y, i, j, k;
  14910. var index;
  14911. var offset = 0;
  14912. var output;
  14913. var numComponents = this.components.length;
  14914. var dataLength = width * height * numComponents;
  14915. var data = new Uint8Array(dataLength);
  14916. var xScaleBlockOffset = new Uint32Array(width);
  14917. var mask3LSB = 0xfffffff8;
  14918. for (i = 0; i < numComponents; i++) {
  14919. component = this.components[i];
  14920. componentScaleX = component.scaleX * scaleX;
  14921. componentScaleY = component.scaleY * scaleY;
  14922. offset = i;
  14923. output = component.output;
  14924. blocksPerScanline = component.blocksPerLine + 1 << 3;
  14925. for (x = 0; x < width; x++) {
  14926. j = 0 | x * componentScaleX;
  14927. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  14928. }
  14929. for (y = 0; y < height; y++) {
  14930. j = 0 | y * componentScaleY;
  14931. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  14932. for (x = 0; x < width; x++) {
  14933. data[offset] = output[index + xScaleBlockOffset[x]];
  14934. offset += numComponents;
  14935. }
  14936. }
  14937. }
  14938. var transform = this.decodeTransform;
  14939. if (transform) {
  14940. for (i = 0; i < dataLength;) {
  14941. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  14942. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  14943. }
  14944. }
  14945. }
  14946. return data;
  14947. },
  14948. _isColorConversionNeeded: function isColorConversionNeeded() {
  14949. if (this.adobe && this.adobe.transformCode) {
  14950. return true;
  14951. } else if (this.numComponents === 3) {
  14952. if (!this.adobe && this.colorTransform === 0) {
  14953. return false;
  14954. }
  14955. return true;
  14956. } else {
  14957. if (!this.adobe && this.colorTransform === 1) {
  14958. return true;
  14959. }
  14960. return false;
  14961. }
  14962. },
  14963. _convertYccToRgb: function convertYccToRgb(data) {
  14964. var Y, Cb, Cr;
  14965. for (var i = 0, length = data.length; i < length; i += 3) {
  14966. Y = data[i];
  14967. Cb = data[i + 1];
  14968. Cr = data[i + 2];
  14969. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  14970. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  14971. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  14972. }
  14973. return data;
  14974. },
  14975. _convertYcckToRgb: function convertYcckToRgb(data) {
  14976. var Y, Cb, Cr, k;
  14977. var offset = 0;
  14978. for (var i = 0, length = data.length; i < length; i += 4) {
  14979. Y = data[i];
  14980. Cb = data[i + 1];
  14981. Cr = data[i + 2];
  14982. k = data[i + 3];
  14983. 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);
  14984. 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);
  14985. 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);
  14986. data[offset++] = clamp0to255(r);
  14987. data[offset++] = clamp0to255(g);
  14988. data[offset++] = clamp0to255(b);
  14989. }
  14990. return data;
  14991. },
  14992. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  14993. var Y, Cb, Cr;
  14994. for (var i = 0, length = data.length; i < length; i += 4) {
  14995. Y = data[i];
  14996. Cb = data[i + 1];
  14997. Cr = data[i + 2];
  14998. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  14999. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  15000. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  15001. }
  15002. return data;
  15003. },
  15004. _convertCmykToRgb: function convertCmykToRgb(data) {
  15005. var c, m, y, k;
  15006. var offset = 0;
  15007. var min = -255 * 255 * 255;
  15008. var scale = 1 / 255 / 255;
  15009. for (var i = 0, length = data.length; i < length; i += 4) {
  15010. c = data[i];
  15011. m = data[i + 1];
  15012. y = data[i + 2];
  15013. k = data[i + 3];
  15014. 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);
  15015. 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);
  15016. 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);
  15017. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  15018. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  15019. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  15020. }
  15021. return data;
  15022. },
  15023. getData: function getData(width, height, forceRGBoutput) {
  15024. if (this.numComponents > 4) {
  15025. error('JPEG error: Unsupported color mode');
  15026. }
  15027. var data = this._getLinearizedBlockData(width, height);
  15028. if (this.numComponents === 1 && forceRGBoutput) {
  15029. var dataLength = data.length;
  15030. var rgbData = new Uint8Array(dataLength * 3);
  15031. var offset = 0;
  15032. for (var i = 0; i < dataLength; i++) {
  15033. var grayColor = data[i];
  15034. rgbData[offset++] = grayColor;
  15035. rgbData[offset++] = grayColor;
  15036. rgbData[offset++] = grayColor;
  15037. }
  15038. return rgbData;
  15039. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  15040. return this._convertYccToRgb(data);
  15041. } else if (this.numComponents === 4) {
  15042. if (this._isColorConversionNeeded()) {
  15043. if (forceRGBoutput) {
  15044. return this._convertYcckToRgb(data);
  15045. } else {
  15046. return this._convertYcckToCmyk(data);
  15047. }
  15048. } else if (forceRGBoutput) {
  15049. return this._convertCmykToRgb(data);
  15050. }
  15051. }
  15052. return data;
  15053. }
  15054. };
  15055. return JpegImage;
  15056. }();
  15057. exports.JpegImage = JpegImage;
  15058. }));
  15059. (function (root, factory) {
  15060. factory(root.pdfjsCoreJpx = {}, root.pdfjsSharedUtil, root.pdfjsCoreArithmeticDecoder);
  15061. }(this, function (exports, sharedUtil, coreArithmeticDecoder) {
  15062. var info = sharedUtil.info;
  15063. var warn = sharedUtil.warn;
  15064. var error = sharedUtil.error;
  15065. var log2 = sharedUtil.log2;
  15066. var readUint16 = sharedUtil.readUint16;
  15067. var readUint32 = sharedUtil.readUint32;
  15068. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  15069. var JpxImage = function JpxImageClosure() {
  15070. var SubbandsGainLog2 = {
  15071. 'LL': 0,
  15072. 'LH': 1,
  15073. 'HL': 1,
  15074. 'HH': 2
  15075. };
  15076. function JpxImage() {
  15077. this.failOnCorruptedImage = false;
  15078. }
  15079. JpxImage.prototype = {
  15080. parse: function JpxImage_parse(data) {
  15081. var head = readUint16(data, 0);
  15082. if (head === 0xFF4F) {
  15083. this.parseCodestream(data, 0, data.length);
  15084. return;
  15085. }
  15086. var position = 0, length = data.length;
  15087. while (position < length) {
  15088. var headerSize = 8;
  15089. var lbox = readUint32(data, position);
  15090. var tbox = readUint32(data, position + 4);
  15091. position += headerSize;
  15092. if (lbox === 1) {
  15093. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  15094. position += 8;
  15095. headerSize += 8;
  15096. }
  15097. if (lbox === 0) {
  15098. lbox = length - position + headerSize;
  15099. }
  15100. if (lbox < headerSize) {
  15101. error('JPX Error: Invalid box field size');
  15102. }
  15103. var dataLength = lbox - headerSize;
  15104. var jumpDataLength = true;
  15105. switch (tbox) {
  15106. case 0x6A703268:
  15107. jumpDataLength = false;
  15108. break;
  15109. case 0x636F6C72:
  15110. var method = data[position];
  15111. if (method === 1) {
  15112. var colorspace = readUint32(data, position + 3);
  15113. switch (colorspace) {
  15114. case 16:
  15115. case 17:
  15116. case 18:
  15117. break;
  15118. default:
  15119. warn('Unknown colorspace ' + colorspace);
  15120. break;
  15121. }
  15122. } else if (method === 2) {
  15123. info('ICC profile not supported');
  15124. }
  15125. break;
  15126. case 0x6A703263:
  15127. this.parseCodestream(data, position, position + dataLength);
  15128. break;
  15129. case 0x6A502020:
  15130. if (0x0d0a870a !== readUint32(data, position)) {
  15131. warn('Invalid JP2 signature');
  15132. }
  15133. break;
  15134. case 0x6A501A1A:
  15135. case 0x66747970:
  15136. case 0x72726571:
  15137. case 0x72657320:
  15138. case 0x69686472:
  15139. break;
  15140. default:
  15141. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  15142. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  15143. break;
  15144. }
  15145. if (jumpDataLength) {
  15146. position += dataLength;
  15147. }
  15148. }
  15149. },
  15150. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  15151. var newByte = stream.getByte();
  15152. while (newByte >= 0) {
  15153. var oldByte = newByte;
  15154. newByte = stream.getByte();
  15155. var code = oldByte << 8 | newByte;
  15156. if (code === 0xFF51) {
  15157. stream.skip(4);
  15158. var Xsiz = stream.getInt32() >>> 0;
  15159. var Ysiz = stream.getInt32() >>> 0;
  15160. var XOsiz = stream.getInt32() >>> 0;
  15161. var YOsiz = stream.getInt32() >>> 0;
  15162. stream.skip(16);
  15163. var Csiz = stream.getUint16();
  15164. this.width = Xsiz - XOsiz;
  15165. this.height = Ysiz - YOsiz;
  15166. this.componentsCount = Csiz;
  15167. this.bitsPerComponent = 8;
  15168. return;
  15169. }
  15170. }
  15171. error('JPX Error: No size marker found in JPX stream');
  15172. },
  15173. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  15174. var context = {};
  15175. var doNotRecover = false;
  15176. try {
  15177. var position = start;
  15178. while (position + 1 < end) {
  15179. var code = readUint16(data, position);
  15180. position += 2;
  15181. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  15182. switch (code) {
  15183. case 0xFF4F:
  15184. context.mainHeader = true;
  15185. break;
  15186. case 0xFFD9:
  15187. break;
  15188. case 0xFF51:
  15189. length = readUint16(data, position);
  15190. var siz = {};
  15191. siz.Xsiz = readUint32(data, position + 4);
  15192. siz.Ysiz = readUint32(data, position + 8);
  15193. siz.XOsiz = readUint32(data, position + 12);
  15194. siz.YOsiz = readUint32(data, position + 16);
  15195. siz.XTsiz = readUint32(data, position + 20);
  15196. siz.YTsiz = readUint32(data, position + 24);
  15197. siz.XTOsiz = readUint32(data, position + 28);
  15198. siz.YTOsiz = readUint32(data, position + 32);
  15199. var componentsCount = readUint16(data, position + 36);
  15200. siz.Csiz = componentsCount;
  15201. var components = [];
  15202. j = position + 38;
  15203. for (var i = 0; i < componentsCount; i++) {
  15204. var component = {
  15205. precision: (data[j] & 0x7F) + 1,
  15206. isSigned: !!(data[j] & 0x80),
  15207. XRsiz: data[j + 1],
  15208. YRsiz: data[j + 1]
  15209. };
  15210. calculateComponentDimensions(component, siz);
  15211. components.push(component);
  15212. }
  15213. context.SIZ = siz;
  15214. context.components = components;
  15215. calculateTileGrids(context, components);
  15216. context.QCC = [];
  15217. context.COC = [];
  15218. break;
  15219. case 0xFF5C:
  15220. length = readUint16(data, position);
  15221. var qcd = {};
  15222. j = position + 2;
  15223. sqcd = data[j++];
  15224. switch (sqcd & 0x1F) {
  15225. case 0:
  15226. spqcdSize = 8;
  15227. scalarExpounded = true;
  15228. break;
  15229. case 1:
  15230. spqcdSize = 16;
  15231. scalarExpounded = false;
  15232. break;
  15233. case 2:
  15234. spqcdSize = 16;
  15235. scalarExpounded = true;
  15236. break;
  15237. default:
  15238. throw new Error('Invalid SQcd value ' + sqcd);
  15239. }
  15240. qcd.noQuantization = spqcdSize === 8;
  15241. qcd.scalarExpounded = scalarExpounded;
  15242. qcd.guardBits = sqcd >> 5;
  15243. spqcds = [];
  15244. while (j < length + position) {
  15245. var spqcd = {};
  15246. if (spqcdSize === 8) {
  15247. spqcd.epsilon = data[j++] >> 3;
  15248. spqcd.mu = 0;
  15249. } else {
  15250. spqcd.epsilon = data[j] >> 3;
  15251. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  15252. j += 2;
  15253. }
  15254. spqcds.push(spqcd);
  15255. }
  15256. qcd.SPqcds = spqcds;
  15257. if (context.mainHeader) {
  15258. context.QCD = qcd;
  15259. } else {
  15260. context.currentTile.QCD = qcd;
  15261. context.currentTile.QCC = [];
  15262. }
  15263. break;
  15264. case 0xFF5D:
  15265. length = readUint16(data, position);
  15266. var qcc = {};
  15267. j = position + 2;
  15268. var cqcc;
  15269. if (context.SIZ.Csiz < 257) {
  15270. cqcc = data[j++];
  15271. } else {
  15272. cqcc = readUint16(data, j);
  15273. j += 2;
  15274. }
  15275. sqcd = data[j++];
  15276. switch (sqcd & 0x1F) {
  15277. case 0:
  15278. spqcdSize = 8;
  15279. scalarExpounded = true;
  15280. break;
  15281. case 1:
  15282. spqcdSize = 16;
  15283. scalarExpounded = false;
  15284. break;
  15285. case 2:
  15286. spqcdSize = 16;
  15287. scalarExpounded = true;
  15288. break;
  15289. default:
  15290. throw new Error('Invalid SQcd value ' + sqcd);
  15291. }
  15292. qcc.noQuantization = spqcdSize === 8;
  15293. qcc.scalarExpounded = scalarExpounded;
  15294. qcc.guardBits = sqcd >> 5;
  15295. spqcds = [];
  15296. while (j < length + position) {
  15297. spqcd = {};
  15298. if (spqcdSize === 8) {
  15299. spqcd.epsilon = data[j++] >> 3;
  15300. spqcd.mu = 0;
  15301. } else {
  15302. spqcd.epsilon = data[j] >> 3;
  15303. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  15304. j += 2;
  15305. }
  15306. spqcds.push(spqcd);
  15307. }
  15308. qcc.SPqcds = spqcds;
  15309. if (context.mainHeader) {
  15310. context.QCC[cqcc] = qcc;
  15311. } else {
  15312. context.currentTile.QCC[cqcc] = qcc;
  15313. }
  15314. break;
  15315. case 0xFF52:
  15316. length = readUint16(data, position);
  15317. var cod = {};
  15318. j = position + 2;
  15319. var scod = data[j++];
  15320. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  15321. cod.sopMarkerUsed = !!(scod & 2);
  15322. cod.ephMarkerUsed = !!(scod & 4);
  15323. cod.progressionOrder = data[j++];
  15324. cod.layersCount = readUint16(data, j);
  15325. j += 2;
  15326. cod.multipleComponentTransform = data[j++];
  15327. cod.decompositionLevelsCount = data[j++];
  15328. cod.xcb = (data[j++] & 0xF) + 2;
  15329. cod.ycb = (data[j++] & 0xF) + 2;
  15330. var blockStyle = data[j++];
  15331. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  15332. cod.resetContextProbabilities = !!(blockStyle & 2);
  15333. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  15334. cod.verticalyStripe = !!(blockStyle & 8);
  15335. cod.predictableTermination = !!(blockStyle & 16);
  15336. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  15337. cod.reversibleTransformation = data[j++];
  15338. if (cod.entropyCoderWithCustomPrecincts) {
  15339. var precinctsSizes = [];
  15340. while (j < length + position) {
  15341. var precinctsSize = data[j++];
  15342. precinctsSizes.push({
  15343. PPx: precinctsSize & 0xF,
  15344. PPy: precinctsSize >> 4
  15345. });
  15346. }
  15347. cod.precinctsSizes = precinctsSizes;
  15348. }
  15349. var unsupported = [];
  15350. if (cod.selectiveArithmeticCodingBypass) {
  15351. unsupported.push('selectiveArithmeticCodingBypass');
  15352. }
  15353. if (cod.resetContextProbabilities) {
  15354. unsupported.push('resetContextProbabilities');
  15355. }
  15356. if (cod.terminationOnEachCodingPass) {
  15357. unsupported.push('terminationOnEachCodingPass');
  15358. }
  15359. if (cod.verticalyStripe) {
  15360. unsupported.push('verticalyStripe');
  15361. }
  15362. if (cod.predictableTermination) {
  15363. unsupported.push('predictableTermination');
  15364. }
  15365. if (unsupported.length > 0) {
  15366. doNotRecover = true;
  15367. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  15368. }
  15369. if (context.mainHeader) {
  15370. context.COD = cod;
  15371. } else {
  15372. context.currentTile.COD = cod;
  15373. context.currentTile.COC = [];
  15374. }
  15375. break;
  15376. case 0xFF90:
  15377. length = readUint16(data, position);
  15378. tile = {};
  15379. tile.index = readUint16(data, position + 2);
  15380. tile.length = readUint32(data, position + 4);
  15381. tile.dataEnd = tile.length + position - 2;
  15382. tile.partIndex = data[position + 8];
  15383. tile.partsCount = data[position + 9];
  15384. context.mainHeader = false;
  15385. if (tile.partIndex === 0) {
  15386. tile.COD = context.COD;
  15387. tile.COC = context.COC.slice(0);
  15388. tile.QCD = context.QCD;
  15389. tile.QCC = context.QCC.slice(0);
  15390. }
  15391. context.currentTile = tile;
  15392. break;
  15393. case 0xFF93:
  15394. tile = context.currentTile;
  15395. if (tile.partIndex === 0) {
  15396. initializeTile(context, tile.index);
  15397. buildPackets(context);
  15398. }
  15399. length = tile.dataEnd - position;
  15400. parseTilePackets(context, data, position, length);
  15401. break;
  15402. case 0xFF55:
  15403. case 0xFF57:
  15404. case 0xFF58:
  15405. case 0xFF64:
  15406. length = readUint16(data, position);
  15407. break;
  15408. case 0xFF53:
  15409. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  15410. default:
  15411. throw new Error('Unknown codestream code: ' + code.toString(16));
  15412. }
  15413. position += length;
  15414. }
  15415. } catch (e) {
  15416. if (doNotRecover || this.failOnCorruptedImage) {
  15417. error('JPX Error: ' + e.message);
  15418. } else {
  15419. warn('JPX: Trying to recover from: ' + e.message);
  15420. }
  15421. }
  15422. this.tiles = transformComponents(context);
  15423. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  15424. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  15425. this.componentsCount = context.SIZ.Csiz;
  15426. }
  15427. };
  15428. function calculateComponentDimensions(component, siz) {
  15429. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  15430. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  15431. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  15432. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  15433. component.width = component.x1 - component.x0;
  15434. component.height = component.y1 - component.y0;
  15435. }
  15436. function calculateTileGrids(context, components) {
  15437. var siz = context.SIZ;
  15438. var tile, tiles = [];
  15439. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  15440. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  15441. for (var q = 0; q < numYtiles; q++) {
  15442. for (var p = 0; p < numXtiles; p++) {
  15443. tile = {};
  15444. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  15445. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  15446. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  15447. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  15448. tile.width = tile.tx1 - tile.tx0;
  15449. tile.height = tile.ty1 - tile.ty0;
  15450. tile.components = [];
  15451. tiles.push(tile);
  15452. }
  15453. }
  15454. context.tiles = tiles;
  15455. var componentsCount = siz.Csiz;
  15456. for (var i = 0, ii = componentsCount; i < ii; i++) {
  15457. var component = components[i];
  15458. for (var j = 0, jj = tiles.length; j < jj; j++) {
  15459. var tileComponent = {};
  15460. tile = tiles[j];
  15461. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  15462. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  15463. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  15464. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  15465. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  15466. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  15467. tile.components[i] = tileComponent;
  15468. }
  15469. }
  15470. }
  15471. function getBlocksDimensions(context, component, r) {
  15472. var codOrCoc = component.codingStyleParameters;
  15473. var result = {};
  15474. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  15475. result.PPx = 15;
  15476. result.PPy = 15;
  15477. } else {
  15478. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  15479. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  15480. }
  15481. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  15482. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  15483. return result;
  15484. }
  15485. function buildPrecincts(context, resolution, dimensions) {
  15486. var precinctWidth = 1 << dimensions.PPx;
  15487. var precinctHeight = 1 << dimensions.PPy;
  15488. var isZeroRes = resolution.resLevel === 0;
  15489. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  15490. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  15491. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  15492. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  15493. var numprecincts = numprecinctswide * numprecinctshigh;
  15494. resolution.precinctParameters = {
  15495. precinctWidth: precinctWidth,
  15496. precinctHeight: precinctHeight,
  15497. numprecinctswide: numprecinctswide,
  15498. numprecinctshigh: numprecinctshigh,
  15499. numprecincts: numprecincts,
  15500. precinctWidthInSubband: precinctWidthInSubband,
  15501. precinctHeightInSubband: precinctHeightInSubband
  15502. };
  15503. }
  15504. function buildCodeblocks(context, subband, dimensions) {
  15505. var xcb_ = dimensions.xcb_;
  15506. var ycb_ = dimensions.ycb_;
  15507. var codeblockWidth = 1 << xcb_;
  15508. var codeblockHeight = 1 << ycb_;
  15509. var cbx0 = subband.tbx0 >> xcb_;
  15510. var cby0 = subband.tby0 >> ycb_;
  15511. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  15512. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  15513. var precinctParameters = subband.resolution.precinctParameters;
  15514. var codeblocks = [];
  15515. var precincts = [];
  15516. var i, j, codeblock, precinctNumber;
  15517. for (j = cby0; j < cby1; j++) {
  15518. for (i = cbx0; i < cbx1; i++) {
  15519. codeblock = {
  15520. cbx: i,
  15521. cby: j,
  15522. tbx0: codeblockWidth * i,
  15523. tby0: codeblockHeight * j,
  15524. tbx1: codeblockWidth * (i + 1),
  15525. tby1: codeblockHeight * (j + 1)
  15526. };
  15527. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  15528. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  15529. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  15530. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  15531. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  15532. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  15533. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  15534. codeblock.precinctNumber = precinctNumber;
  15535. codeblock.subbandType = subband.type;
  15536. codeblock.Lblock = 3;
  15537. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  15538. continue;
  15539. }
  15540. codeblocks.push(codeblock);
  15541. var precinct = precincts[precinctNumber];
  15542. if (precinct !== undefined) {
  15543. if (i < precinct.cbxMin) {
  15544. precinct.cbxMin = i;
  15545. } else if (i > precinct.cbxMax) {
  15546. precinct.cbxMax = i;
  15547. }
  15548. if (j < precinct.cbyMin) {
  15549. precinct.cbxMin = j;
  15550. } else if (j > precinct.cbyMax) {
  15551. precinct.cbyMax = j;
  15552. }
  15553. } else {
  15554. precincts[precinctNumber] = precinct = {
  15555. cbxMin: i,
  15556. cbyMin: j,
  15557. cbxMax: i,
  15558. cbyMax: j
  15559. };
  15560. }
  15561. codeblock.precinct = precinct;
  15562. }
  15563. }
  15564. subband.codeblockParameters = {
  15565. codeblockWidth: xcb_,
  15566. codeblockHeight: ycb_,
  15567. numcodeblockwide: cbx1 - cbx0 + 1,
  15568. numcodeblockhigh: cby1 - cby0 + 1
  15569. };
  15570. subband.codeblocks = codeblocks;
  15571. subband.precincts = precincts;
  15572. }
  15573. function createPacket(resolution, precinctNumber, layerNumber) {
  15574. var precinctCodeblocks = [];
  15575. var subbands = resolution.subbands;
  15576. for (var i = 0, ii = subbands.length; i < ii; i++) {
  15577. var subband = subbands[i];
  15578. var codeblocks = subband.codeblocks;
  15579. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  15580. var codeblock = codeblocks[j];
  15581. if (codeblock.precinctNumber !== precinctNumber) {
  15582. continue;
  15583. }
  15584. precinctCodeblocks.push(codeblock);
  15585. }
  15586. }
  15587. return {
  15588. layerNumber: layerNumber,
  15589. codeblocks: precinctCodeblocks
  15590. };
  15591. }
  15592. function LayerResolutionComponentPositionIterator(context) {
  15593. var siz = context.SIZ;
  15594. var tileIndex = context.currentTile.index;
  15595. var tile = context.tiles[tileIndex];
  15596. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15597. var componentsCount = siz.Csiz;
  15598. var maxDecompositionLevelsCount = 0;
  15599. for (var q = 0; q < componentsCount; q++) {
  15600. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  15601. }
  15602. var l = 0, r = 0, i = 0, k = 0;
  15603. this.nextPacket = function JpxImage_nextPacket() {
  15604. for (; l < layersCount; l++) {
  15605. for (; r <= maxDecompositionLevelsCount; r++) {
  15606. for (; i < componentsCount; i++) {
  15607. var component = tile.components[i];
  15608. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15609. continue;
  15610. }
  15611. var resolution = component.resolutions[r];
  15612. var numprecincts = resolution.precinctParameters.numprecincts;
  15613. for (; k < numprecincts;) {
  15614. var packet = createPacket(resolution, k, l);
  15615. k++;
  15616. return packet;
  15617. }
  15618. k = 0;
  15619. }
  15620. i = 0;
  15621. }
  15622. r = 0;
  15623. }
  15624. error('JPX Error: Out of packets');
  15625. };
  15626. }
  15627. function ResolutionLayerComponentPositionIterator(context) {
  15628. var siz = context.SIZ;
  15629. var tileIndex = context.currentTile.index;
  15630. var tile = context.tiles[tileIndex];
  15631. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15632. var componentsCount = siz.Csiz;
  15633. var maxDecompositionLevelsCount = 0;
  15634. for (var q = 0; q < componentsCount; q++) {
  15635. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  15636. }
  15637. var r = 0, l = 0, i = 0, k = 0;
  15638. this.nextPacket = function JpxImage_nextPacket() {
  15639. for (; r <= maxDecompositionLevelsCount; r++) {
  15640. for (; l < layersCount; l++) {
  15641. for (; i < componentsCount; i++) {
  15642. var component = tile.components[i];
  15643. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15644. continue;
  15645. }
  15646. var resolution = component.resolutions[r];
  15647. var numprecincts = resolution.precinctParameters.numprecincts;
  15648. for (; k < numprecincts;) {
  15649. var packet = createPacket(resolution, k, l);
  15650. k++;
  15651. return packet;
  15652. }
  15653. k = 0;
  15654. }
  15655. i = 0;
  15656. }
  15657. l = 0;
  15658. }
  15659. error('JPX Error: Out of packets');
  15660. };
  15661. }
  15662. function ResolutionPositionComponentLayerIterator(context) {
  15663. var siz = context.SIZ;
  15664. var tileIndex = context.currentTile.index;
  15665. var tile = context.tiles[tileIndex];
  15666. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15667. var componentsCount = siz.Csiz;
  15668. var l, r, c, p;
  15669. var maxDecompositionLevelsCount = 0;
  15670. for (c = 0; c < componentsCount; c++) {
  15671. var component = tile.components[c];
  15672. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  15673. }
  15674. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  15675. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  15676. var maxNumPrecincts = 0;
  15677. for (c = 0; c < componentsCount; ++c) {
  15678. var resolutions = tile.components[c].resolutions;
  15679. if (r < resolutions.length) {
  15680. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  15681. }
  15682. }
  15683. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  15684. }
  15685. l = 0;
  15686. r = 0;
  15687. c = 0;
  15688. p = 0;
  15689. this.nextPacket = function JpxImage_nextPacket() {
  15690. for (; r <= maxDecompositionLevelsCount; r++) {
  15691. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  15692. for (; c < componentsCount; c++) {
  15693. var component = tile.components[c];
  15694. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15695. continue;
  15696. }
  15697. var resolution = component.resolutions[r];
  15698. var numprecincts = resolution.precinctParameters.numprecincts;
  15699. if (p >= numprecincts) {
  15700. continue;
  15701. }
  15702. for (; l < layersCount;) {
  15703. var packet = createPacket(resolution, p, l);
  15704. l++;
  15705. return packet;
  15706. }
  15707. l = 0;
  15708. }
  15709. c = 0;
  15710. }
  15711. p = 0;
  15712. }
  15713. error('JPX Error: Out of packets');
  15714. };
  15715. }
  15716. function PositionComponentResolutionLayerIterator(context) {
  15717. var siz = context.SIZ;
  15718. var tileIndex = context.currentTile.index;
  15719. var tile = context.tiles[tileIndex];
  15720. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15721. var componentsCount = siz.Csiz;
  15722. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  15723. var precinctsIterationSizes = precinctsSizes;
  15724. var l = 0, r = 0, c = 0, px = 0, py = 0;
  15725. this.nextPacket = function JpxImage_nextPacket() {
  15726. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  15727. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  15728. for (; c < componentsCount; c++) {
  15729. var component = tile.components[c];
  15730. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15731. for (; r <= decompositionLevelsCount; r++) {
  15732. var resolution = component.resolutions[r];
  15733. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  15734. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  15735. if (k === null) {
  15736. continue;
  15737. }
  15738. for (; l < layersCount;) {
  15739. var packet = createPacket(resolution, k, l);
  15740. l++;
  15741. return packet;
  15742. }
  15743. l = 0;
  15744. }
  15745. r = 0;
  15746. }
  15747. c = 0;
  15748. }
  15749. px = 0;
  15750. }
  15751. error('JPX Error: Out of packets');
  15752. };
  15753. }
  15754. function ComponentPositionResolutionLayerIterator(context) {
  15755. var siz = context.SIZ;
  15756. var tileIndex = context.currentTile.index;
  15757. var tile = context.tiles[tileIndex];
  15758. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15759. var componentsCount = siz.Csiz;
  15760. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  15761. var l = 0, r = 0, c = 0, px = 0, py = 0;
  15762. this.nextPacket = function JpxImage_nextPacket() {
  15763. for (; c < componentsCount; ++c) {
  15764. var component = tile.components[c];
  15765. var precinctsIterationSizes = precinctsSizes.components[c];
  15766. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15767. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  15768. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  15769. for (; r <= decompositionLevelsCount; r++) {
  15770. var resolution = component.resolutions[r];
  15771. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  15772. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  15773. if (k === null) {
  15774. continue;
  15775. }
  15776. for (; l < layersCount;) {
  15777. var packet = createPacket(resolution, k, l);
  15778. l++;
  15779. return packet;
  15780. }
  15781. l = 0;
  15782. }
  15783. r = 0;
  15784. }
  15785. px = 0;
  15786. }
  15787. py = 0;
  15788. }
  15789. error('JPX Error: Out of packets');
  15790. };
  15791. }
  15792. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  15793. var posX = pxIndex * precinctIterationSizes.minWidth;
  15794. var posY = pyIndex * precinctIterationSizes.minHeight;
  15795. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  15796. return null;
  15797. }
  15798. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  15799. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  15800. }
  15801. function getPrecinctSizesInImageScale(tile) {
  15802. var componentsCount = tile.components.length;
  15803. var minWidth = Number.MAX_VALUE;
  15804. var minHeight = Number.MAX_VALUE;
  15805. var maxNumWide = 0;
  15806. var maxNumHigh = 0;
  15807. var sizePerComponent = new Array(componentsCount);
  15808. for (var c = 0; c < componentsCount; c++) {
  15809. var component = tile.components[c];
  15810. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15811. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  15812. var minWidthCurrentComponent = Number.MAX_VALUE;
  15813. var minHeightCurrentComponent = Number.MAX_VALUE;
  15814. var maxNumWideCurrentComponent = 0;
  15815. var maxNumHighCurrentComponent = 0;
  15816. var scale = 1;
  15817. for (var r = decompositionLevelsCount; r >= 0; --r) {
  15818. var resolution = component.resolutions[r];
  15819. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  15820. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  15821. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  15822. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  15823. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  15824. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  15825. sizePerResolution[r] = {
  15826. width: widthCurrentResolution,
  15827. height: heightCurrentResolution
  15828. };
  15829. scale <<= 1;
  15830. }
  15831. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  15832. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  15833. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  15834. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  15835. sizePerComponent[c] = {
  15836. resolutions: sizePerResolution,
  15837. minWidth: minWidthCurrentComponent,
  15838. minHeight: minHeightCurrentComponent,
  15839. maxNumWide: maxNumWideCurrentComponent,
  15840. maxNumHigh: maxNumHighCurrentComponent
  15841. };
  15842. }
  15843. return {
  15844. components: sizePerComponent,
  15845. minWidth: minWidth,
  15846. minHeight: minHeight,
  15847. maxNumWide: maxNumWide,
  15848. maxNumHigh: maxNumHigh
  15849. };
  15850. }
  15851. function buildPackets(context) {
  15852. var siz = context.SIZ;
  15853. var tileIndex = context.currentTile.index;
  15854. var tile = context.tiles[tileIndex];
  15855. var componentsCount = siz.Csiz;
  15856. for (var c = 0; c < componentsCount; c++) {
  15857. var component = tile.components[c];
  15858. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15859. var resolutions = [];
  15860. var subbands = [];
  15861. for (var r = 0; r <= decompositionLevelsCount; r++) {
  15862. var blocksDimensions = getBlocksDimensions(context, component, r);
  15863. var resolution = {};
  15864. var scale = 1 << decompositionLevelsCount - r;
  15865. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  15866. resolution.try0 = Math.ceil(component.tcy0 / scale);
  15867. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  15868. resolution.try1 = Math.ceil(component.tcy1 / scale);
  15869. resolution.resLevel = r;
  15870. buildPrecincts(context, resolution, blocksDimensions);
  15871. resolutions.push(resolution);
  15872. var subband;
  15873. if (r === 0) {
  15874. subband = {};
  15875. subband.type = 'LL';
  15876. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  15877. subband.tby0 = Math.ceil(component.tcy0 / scale);
  15878. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  15879. subband.tby1 = Math.ceil(component.tcy1 / scale);
  15880. subband.resolution = resolution;
  15881. buildCodeblocks(context, subband, blocksDimensions);
  15882. subbands.push(subband);
  15883. resolution.subbands = [subband];
  15884. } else {
  15885. var bscale = 1 << decompositionLevelsCount - r + 1;
  15886. var resolutionSubbands = [];
  15887. subband = {};
  15888. subband.type = 'HL';
  15889. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  15890. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  15891. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  15892. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  15893. subband.resolution = resolution;
  15894. buildCodeblocks(context, subband, blocksDimensions);
  15895. subbands.push(subband);
  15896. resolutionSubbands.push(subband);
  15897. subband = {};
  15898. subband.type = 'LH';
  15899. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  15900. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  15901. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  15902. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  15903. subband.resolution = resolution;
  15904. buildCodeblocks(context, subband, blocksDimensions);
  15905. subbands.push(subband);
  15906. resolutionSubbands.push(subband);
  15907. subband = {};
  15908. subband.type = 'HH';
  15909. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  15910. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  15911. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  15912. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  15913. subband.resolution = resolution;
  15914. buildCodeblocks(context, subband, blocksDimensions);
  15915. subbands.push(subband);
  15916. resolutionSubbands.push(subband);
  15917. resolution.subbands = resolutionSubbands;
  15918. }
  15919. }
  15920. component.resolutions = resolutions;
  15921. component.subbands = subbands;
  15922. }
  15923. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  15924. switch (progressionOrder) {
  15925. case 0:
  15926. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  15927. break;
  15928. case 1:
  15929. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  15930. break;
  15931. case 2:
  15932. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  15933. break;
  15934. case 3:
  15935. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  15936. break;
  15937. case 4:
  15938. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  15939. break;
  15940. default:
  15941. error('JPX Error: Unsupported progression order ' + progressionOrder);
  15942. }
  15943. }
  15944. function parseTilePackets(context, data, offset, dataLength) {
  15945. var position = 0;
  15946. var buffer, bufferSize = 0, skipNextBit = false;
  15947. function readBits(count) {
  15948. while (bufferSize < count) {
  15949. var b = data[offset + position];
  15950. position++;
  15951. if (skipNextBit) {
  15952. buffer = buffer << 7 | b;
  15953. bufferSize += 7;
  15954. skipNextBit = false;
  15955. } else {
  15956. buffer = buffer << 8 | b;
  15957. bufferSize += 8;
  15958. }
  15959. if (b === 0xFF) {
  15960. skipNextBit = true;
  15961. }
  15962. }
  15963. bufferSize -= count;
  15964. return buffer >>> bufferSize & (1 << count) - 1;
  15965. }
  15966. function skipMarkerIfEqual(value) {
  15967. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  15968. skipBytes(1);
  15969. return true;
  15970. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  15971. skipBytes(2);
  15972. return true;
  15973. }
  15974. return false;
  15975. }
  15976. function skipBytes(count) {
  15977. position += count;
  15978. }
  15979. function alignToByte() {
  15980. bufferSize = 0;
  15981. if (skipNextBit) {
  15982. position++;
  15983. skipNextBit = false;
  15984. }
  15985. }
  15986. function readCodingpasses() {
  15987. if (readBits(1) === 0) {
  15988. return 1;
  15989. }
  15990. if (readBits(1) === 0) {
  15991. return 2;
  15992. }
  15993. var value = readBits(2);
  15994. if (value < 3) {
  15995. return value + 3;
  15996. }
  15997. value = readBits(5);
  15998. if (value < 31) {
  15999. return value + 6;
  16000. }
  16001. value = readBits(7);
  16002. return value + 37;
  16003. }
  16004. var tileIndex = context.currentTile.index;
  16005. var tile = context.tiles[tileIndex];
  16006. var sopMarkerUsed = context.COD.sopMarkerUsed;
  16007. var ephMarkerUsed = context.COD.ephMarkerUsed;
  16008. var packetsIterator = tile.packetsIterator;
  16009. while (position < dataLength) {
  16010. alignToByte();
  16011. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  16012. skipBytes(4);
  16013. }
  16014. var packet = packetsIterator.nextPacket();
  16015. if (!readBits(1)) {
  16016. continue;
  16017. }
  16018. var layerNumber = packet.layerNumber;
  16019. var queue = [], codeblock;
  16020. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  16021. codeblock = packet.codeblocks[i];
  16022. var precinct = codeblock.precinct;
  16023. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  16024. var codeblockRow = codeblock.cby - precinct.cbyMin;
  16025. var codeblockIncluded = false;
  16026. var firstTimeInclusion = false;
  16027. var valueReady;
  16028. if (codeblock['included'] !== undefined) {
  16029. codeblockIncluded = !!readBits(1);
  16030. } else {
  16031. precinct = codeblock.precinct;
  16032. var inclusionTree, zeroBitPlanesTree;
  16033. if (precinct['inclusionTree'] !== undefined) {
  16034. inclusionTree = precinct.inclusionTree;
  16035. } else {
  16036. var width = precinct.cbxMax - precinct.cbxMin + 1;
  16037. var height = precinct.cbyMax - precinct.cbyMin + 1;
  16038. inclusionTree = new InclusionTree(width, height, layerNumber);
  16039. zeroBitPlanesTree = new TagTree(width, height);
  16040. precinct.inclusionTree = inclusionTree;
  16041. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  16042. }
  16043. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  16044. while (true) {
  16045. if (readBits(1)) {
  16046. valueReady = !inclusionTree.nextLevel();
  16047. if (valueReady) {
  16048. codeblock.included = true;
  16049. codeblockIncluded = firstTimeInclusion = true;
  16050. break;
  16051. }
  16052. } else {
  16053. inclusionTree.incrementValue(layerNumber);
  16054. break;
  16055. }
  16056. }
  16057. }
  16058. }
  16059. if (!codeblockIncluded) {
  16060. continue;
  16061. }
  16062. if (firstTimeInclusion) {
  16063. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  16064. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  16065. while (true) {
  16066. if (readBits(1)) {
  16067. valueReady = !zeroBitPlanesTree.nextLevel();
  16068. if (valueReady) {
  16069. break;
  16070. }
  16071. } else {
  16072. zeroBitPlanesTree.incrementValue();
  16073. }
  16074. }
  16075. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  16076. }
  16077. var codingpasses = readCodingpasses();
  16078. while (readBits(1)) {
  16079. codeblock.Lblock++;
  16080. }
  16081. var codingpassesLog2 = log2(codingpasses);
  16082. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  16083. var codedDataLength = readBits(bits);
  16084. queue.push({
  16085. codeblock: codeblock,
  16086. codingpasses: codingpasses,
  16087. dataLength: codedDataLength
  16088. });
  16089. }
  16090. alignToByte();
  16091. if (ephMarkerUsed) {
  16092. skipMarkerIfEqual(0x92);
  16093. }
  16094. while (queue.length > 0) {
  16095. var packetItem = queue.shift();
  16096. codeblock = packetItem.codeblock;
  16097. if (codeblock['data'] === undefined) {
  16098. codeblock.data = [];
  16099. }
  16100. codeblock.data.push({
  16101. data: data,
  16102. start: offset + position,
  16103. end: offset + position + packetItem.dataLength,
  16104. codingpasses: packetItem.codingpasses
  16105. });
  16106. position += packetItem.dataLength;
  16107. }
  16108. }
  16109. return position;
  16110. }
  16111. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  16112. var x0 = subband.tbx0;
  16113. var y0 = subband.tby0;
  16114. var width = subband.tbx1 - subband.tbx0;
  16115. var codeblocks = subband.codeblocks;
  16116. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  16117. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  16118. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  16119. var codeblock = codeblocks[i];
  16120. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  16121. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  16122. if (blockWidth === 0 || blockHeight === 0) {
  16123. continue;
  16124. }
  16125. if (codeblock['data'] === undefined) {
  16126. continue;
  16127. }
  16128. var bitModel, currentCodingpassType;
  16129. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  16130. currentCodingpassType = 2;
  16131. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  16132. var j, jj, dataItem;
  16133. for (j = 0, jj = data.length; j < jj; j++) {
  16134. dataItem = data[j];
  16135. totalLength += dataItem.end - dataItem.start;
  16136. codingpasses += dataItem.codingpasses;
  16137. }
  16138. var encodedData = new Uint8Array(totalLength);
  16139. var position = 0;
  16140. for (j = 0, jj = data.length; j < jj; j++) {
  16141. dataItem = data[j];
  16142. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  16143. encodedData.set(chunk, position);
  16144. position += chunk.length;
  16145. }
  16146. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  16147. bitModel.setDecoder(decoder);
  16148. for (j = 0; j < codingpasses; j++) {
  16149. switch (currentCodingpassType) {
  16150. case 0:
  16151. bitModel.runSignificancePropagationPass();
  16152. break;
  16153. case 1:
  16154. bitModel.runMagnitudeRefinementPass();
  16155. break;
  16156. case 2:
  16157. bitModel.runCleanupPass();
  16158. if (segmentationSymbolUsed) {
  16159. bitModel.checkSegmentationSymbol();
  16160. }
  16161. break;
  16162. }
  16163. currentCodingpassType = (currentCodingpassType + 1) % 3;
  16164. }
  16165. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  16166. var sign = bitModel.coefficentsSign;
  16167. var magnitude = bitModel.coefficentsMagnitude;
  16168. var bitsDecoded = bitModel.bitsDecoded;
  16169. var magnitudeCorrection = reversible ? 0 : 0.5;
  16170. var k, n, nb;
  16171. position = 0;
  16172. var interleave = subband.type !== 'LL';
  16173. for (j = 0; j < blockHeight; j++) {
  16174. var row = offset / width | 0;
  16175. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  16176. for (k = 0; k < blockWidth; k++) {
  16177. n = magnitude[position];
  16178. if (n !== 0) {
  16179. n = (n + magnitudeCorrection) * delta;
  16180. if (sign[position] !== 0) {
  16181. n = -n;
  16182. }
  16183. nb = bitsDecoded[position];
  16184. var pos = interleave ? levelOffset + (offset << 1) : offset;
  16185. if (reversible && nb >= mb) {
  16186. coefficients[pos] = n;
  16187. } else {
  16188. coefficients[pos] = n * (1 << mb - nb);
  16189. }
  16190. }
  16191. offset++;
  16192. position++;
  16193. }
  16194. offset += width - blockWidth;
  16195. }
  16196. }
  16197. }
  16198. function transformTile(context, tile, c) {
  16199. var component = tile.components[c];
  16200. var codingStyleParameters = component.codingStyleParameters;
  16201. var quantizationParameters = component.quantizationParameters;
  16202. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  16203. var spqcds = quantizationParameters.SPqcds;
  16204. var scalarExpounded = quantizationParameters.scalarExpounded;
  16205. var guardBits = quantizationParameters.guardBits;
  16206. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  16207. var precision = context.components[c].precision;
  16208. var reversible = codingStyleParameters.reversibleTransformation;
  16209. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  16210. var subbandCoefficients = [];
  16211. var b = 0;
  16212. for (var i = 0; i <= decompositionLevelsCount; i++) {
  16213. var resolution = component.resolutions[i];
  16214. var width = resolution.trx1 - resolution.trx0;
  16215. var height = resolution.try1 - resolution.try0;
  16216. var coefficients = new Float32Array(width * height);
  16217. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  16218. var mu, epsilon;
  16219. if (!scalarExpounded) {
  16220. mu = spqcds[0].mu;
  16221. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  16222. } else {
  16223. mu = spqcds[b].mu;
  16224. epsilon = spqcds[b].epsilon;
  16225. b++;
  16226. }
  16227. var subband = resolution.subbands[j];
  16228. var gainLog2 = SubbandsGainLog2[subband.type];
  16229. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  16230. var mb = guardBits + epsilon - 1;
  16231. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  16232. }
  16233. subbandCoefficients.push({
  16234. width: width,
  16235. height: height,
  16236. items: coefficients
  16237. });
  16238. }
  16239. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  16240. return {
  16241. left: component.tcx0,
  16242. top: component.tcy0,
  16243. width: result.width,
  16244. height: result.height,
  16245. items: result.items
  16246. };
  16247. }
  16248. function transformComponents(context) {
  16249. var siz = context.SIZ;
  16250. var components = context.components;
  16251. var componentsCount = siz.Csiz;
  16252. var resultImages = [];
  16253. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  16254. var tile = context.tiles[i];
  16255. var transformedTiles = [];
  16256. var c;
  16257. for (c = 0; c < componentsCount; c++) {
  16258. transformedTiles[c] = transformTile(context, tile, c);
  16259. }
  16260. var tile0 = transformedTiles[0];
  16261. var out = new Uint8Array(tile0.items.length * componentsCount);
  16262. var result = {
  16263. left: tile0.left,
  16264. top: tile0.top,
  16265. width: tile0.width,
  16266. height: tile0.height,
  16267. items: out
  16268. };
  16269. var shift, offset, max, min, maxK;
  16270. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  16271. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  16272. var fourComponents = componentsCount === 4;
  16273. var y0items = transformedTiles[0].items;
  16274. var y1items = transformedTiles[1].items;
  16275. var y2items = transformedTiles[2].items;
  16276. var y3items = fourComponents ? transformedTiles[3].items : null;
  16277. shift = components[0].precision - 8;
  16278. offset = (128 << shift) + 0.5;
  16279. max = 255 * (1 << shift);
  16280. maxK = max * 0.5;
  16281. min = -maxK;
  16282. var component0 = tile.components[0];
  16283. var alpha01 = componentsCount - 3;
  16284. jj = y0items.length;
  16285. if (!component0.codingStyleParameters.reversibleTransformation) {
  16286. for (j = 0; j < jj; j++, pos += alpha01) {
  16287. y0 = y0items[j] + offset;
  16288. y1 = y1items[j];
  16289. y2 = y2items[j];
  16290. r = y0 + 1.402 * y2;
  16291. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  16292. b = y0 + 1.772 * y1;
  16293. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  16294. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  16295. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  16296. }
  16297. } else {
  16298. for (j = 0; j < jj; j++, pos += alpha01) {
  16299. y0 = y0items[j] + offset;
  16300. y1 = y1items[j];
  16301. y2 = y2items[j];
  16302. g = y0 - (y2 + y1 >> 2);
  16303. r = g + y2;
  16304. b = g + y1;
  16305. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  16306. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  16307. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  16308. }
  16309. }
  16310. if (fourComponents) {
  16311. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  16312. k = y3items[j];
  16313. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  16314. }
  16315. }
  16316. } else {
  16317. for (c = 0; c < componentsCount; c++) {
  16318. var items = transformedTiles[c].items;
  16319. shift = components[c].precision - 8;
  16320. offset = (128 << shift) + 0.5;
  16321. max = 127.5 * (1 << shift);
  16322. min = -max;
  16323. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  16324. val = items[j];
  16325. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  16326. pos += componentsCount;
  16327. }
  16328. }
  16329. }
  16330. resultImages.push(result);
  16331. }
  16332. return resultImages;
  16333. }
  16334. function initializeTile(context, tileIndex) {
  16335. var siz = context.SIZ;
  16336. var componentsCount = siz.Csiz;
  16337. var tile = context.tiles[tileIndex];
  16338. for (var c = 0; c < componentsCount; c++) {
  16339. var component = tile.components[c];
  16340. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  16341. component.quantizationParameters = qcdOrQcc;
  16342. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  16343. component.codingStyleParameters = codOrCoc;
  16344. }
  16345. tile.codingStyleDefaultParameters = context.currentTile.COD;
  16346. }
  16347. var TagTree = function TagTreeClosure() {
  16348. function TagTree(width, height) {
  16349. var levelsLength = log2(Math.max(width, height)) + 1;
  16350. this.levels = [];
  16351. for (var i = 0; i < levelsLength; i++) {
  16352. var level = {
  16353. width: width,
  16354. height: height,
  16355. items: []
  16356. };
  16357. this.levels.push(level);
  16358. width = Math.ceil(width / 2);
  16359. height = Math.ceil(height / 2);
  16360. }
  16361. }
  16362. TagTree.prototype = {
  16363. reset: function TagTree_reset(i, j) {
  16364. var currentLevel = 0, value = 0, level;
  16365. while (currentLevel < this.levels.length) {
  16366. level = this.levels[currentLevel];
  16367. var index = i + j * level.width;
  16368. if (level.items[index] !== undefined) {
  16369. value = level.items[index];
  16370. break;
  16371. }
  16372. level.index = index;
  16373. i >>= 1;
  16374. j >>= 1;
  16375. currentLevel++;
  16376. }
  16377. currentLevel--;
  16378. level = this.levels[currentLevel];
  16379. level.items[level.index] = value;
  16380. this.currentLevel = currentLevel;
  16381. delete this.value;
  16382. },
  16383. incrementValue: function TagTree_incrementValue() {
  16384. var level = this.levels[this.currentLevel];
  16385. level.items[level.index]++;
  16386. },
  16387. nextLevel: function TagTree_nextLevel() {
  16388. var currentLevel = this.currentLevel;
  16389. var level = this.levels[currentLevel];
  16390. var value = level.items[level.index];
  16391. currentLevel--;
  16392. if (currentLevel < 0) {
  16393. this.value = value;
  16394. return false;
  16395. }
  16396. this.currentLevel = currentLevel;
  16397. level = this.levels[currentLevel];
  16398. level.items[level.index] = value;
  16399. return true;
  16400. }
  16401. };
  16402. return TagTree;
  16403. }();
  16404. var InclusionTree = function InclusionTreeClosure() {
  16405. function InclusionTree(width, height, defaultValue) {
  16406. var levelsLength = log2(Math.max(width, height)) + 1;
  16407. this.levels = [];
  16408. for (var i = 0; i < levelsLength; i++) {
  16409. var items = new Uint8Array(width * height);
  16410. for (var j = 0, jj = items.length; j < jj; j++) {
  16411. items[j] = defaultValue;
  16412. }
  16413. var level = {
  16414. width: width,
  16415. height: height,
  16416. items: items
  16417. };
  16418. this.levels.push(level);
  16419. width = Math.ceil(width / 2);
  16420. height = Math.ceil(height / 2);
  16421. }
  16422. }
  16423. InclusionTree.prototype = {
  16424. reset: function InclusionTree_reset(i, j, stopValue) {
  16425. var currentLevel = 0;
  16426. while (currentLevel < this.levels.length) {
  16427. var level = this.levels[currentLevel];
  16428. var index = i + j * level.width;
  16429. level.index = index;
  16430. var value = level.items[index];
  16431. if (value === 0xFF) {
  16432. break;
  16433. }
  16434. if (value > stopValue) {
  16435. this.currentLevel = currentLevel;
  16436. this.propagateValues();
  16437. return false;
  16438. }
  16439. i >>= 1;
  16440. j >>= 1;
  16441. currentLevel++;
  16442. }
  16443. this.currentLevel = currentLevel - 1;
  16444. return true;
  16445. },
  16446. incrementValue: function InclusionTree_incrementValue(stopValue) {
  16447. var level = this.levels[this.currentLevel];
  16448. level.items[level.index] = stopValue + 1;
  16449. this.propagateValues();
  16450. },
  16451. propagateValues: function InclusionTree_propagateValues() {
  16452. var levelIndex = this.currentLevel;
  16453. var level = this.levels[levelIndex];
  16454. var currentValue = level.items[level.index];
  16455. while (--levelIndex >= 0) {
  16456. level = this.levels[levelIndex];
  16457. level.items[level.index] = currentValue;
  16458. }
  16459. },
  16460. nextLevel: function InclusionTree_nextLevel() {
  16461. var currentLevel = this.currentLevel;
  16462. var level = this.levels[currentLevel];
  16463. var value = level.items[level.index];
  16464. level.items[level.index] = 0xFF;
  16465. currentLevel--;
  16466. if (currentLevel < 0) {
  16467. return false;
  16468. }
  16469. this.currentLevel = currentLevel;
  16470. level = this.levels[currentLevel];
  16471. level.items[level.index] = value;
  16472. return true;
  16473. }
  16474. };
  16475. return InclusionTree;
  16476. }();
  16477. var BitModel = function BitModelClosure() {
  16478. var UNIFORM_CONTEXT = 17;
  16479. var RUNLENGTH_CONTEXT = 18;
  16480. var LLAndLHContextsLabel = new Uint8Array([
  16481. 0,
  16482. 5,
  16483. 8,
  16484. 0,
  16485. 3,
  16486. 7,
  16487. 8,
  16488. 0,
  16489. 4,
  16490. 7,
  16491. 8,
  16492. 0,
  16493. 0,
  16494. 0,
  16495. 0,
  16496. 0,
  16497. 1,
  16498. 6,
  16499. 8,
  16500. 0,
  16501. 3,
  16502. 7,
  16503. 8,
  16504. 0,
  16505. 4,
  16506. 7,
  16507. 8,
  16508. 0,
  16509. 0,
  16510. 0,
  16511. 0,
  16512. 0,
  16513. 2,
  16514. 6,
  16515. 8,
  16516. 0,
  16517. 3,
  16518. 7,
  16519. 8,
  16520. 0,
  16521. 4,
  16522. 7,
  16523. 8,
  16524. 0,
  16525. 0,
  16526. 0,
  16527. 0,
  16528. 0,
  16529. 2,
  16530. 6,
  16531. 8,
  16532. 0,
  16533. 3,
  16534. 7,
  16535. 8,
  16536. 0,
  16537. 4,
  16538. 7,
  16539. 8,
  16540. 0,
  16541. 0,
  16542. 0,
  16543. 0,
  16544. 0,
  16545. 2,
  16546. 6,
  16547. 8,
  16548. 0,
  16549. 3,
  16550. 7,
  16551. 8,
  16552. 0,
  16553. 4,
  16554. 7,
  16555. 8
  16556. ]);
  16557. var HLContextLabel = new Uint8Array([
  16558. 0,
  16559. 3,
  16560. 4,
  16561. 0,
  16562. 5,
  16563. 7,
  16564. 7,
  16565. 0,
  16566. 8,
  16567. 8,
  16568. 8,
  16569. 0,
  16570. 0,
  16571. 0,
  16572. 0,
  16573. 0,
  16574. 1,
  16575. 3,
  16576. 4,
  16577. 0,
  16578. 6,
  16579. 7,
  16580. 7,
  16581. 0,
  16582. 8,
  16583. 8,
  16584. 8,
  16585. 0,
  16586. 0,
  16587. 0,
  16588. 0,
  16589. 0,
  16590. 2,
  16591. 3,
  16592. 4,
  16593. 0,
  16594. 6,
  16595. 7,
  16596. 7,
  16597. 0,
  16598. 8,
  16599. 8,
  16600. 8,
  16601. 0,
  16602. 0,
  16603. 0,
  16604. 0,
  16605. 0,
  16606. 2,
  16607. 3,
  16608. 4,
  16609. 0,
  16610. 6,
  16611. 7,
  16612. 7,
  16613. 0,
  16614. 8,
  16615. 8,
  16616. 8,
  16617. 0,
  16618. 0,
  16619. 0,
  16620. 0,
  16621. 0,
  16622. 2,
  16623. 3,
  16624. 4,
  16625. 0,
  16626. 6,
  16627. 7,
  16628. 7,
  16629. 0,
  16630. 8,
  16631. 8,
  16632. 8
  16633. ]);
  16634. var HHContextLabel = new Uint8Array([
  16635. 0,
  16636. 1,
  16637. 2,
  16638. 0,
  16639. 1,
  16640. 2,
  16641. 2,
  16642. 0,
  16643. 2,
  16644. 2,
  16645. 2,
  16646. 0,
  16647. 0,
  16648. 0,
  16649. 0,
  16650. 0,
  16651. 3,
  16652. 4,
  16653. 5,
  16654. 0,
  16655. 4,
  16656. 5,
  16657. 5,
  16658. 0,
  16659. 5,
  16660. 5,
  16661. 5,
  16662. 0,
  16663. 0,
  16664. 0,
  16665. 0,
  16666. 0,
  16667. 6,
  16668. 7,
  16669. 7,
  16670. 0,
  16671. 7,
  16672. 7,
  16673. 7,
  16674. 0,
  16675. 7,
  16676. 7,
  16677. 7,
  16678. 0,
  16679. 0,
  16680. 0,
  16681. 0,
  16682. 0,
  16683. 8,
  16684. 8,
  16685. 8,
  16686. 0,
  16687. 8,
  16688. 8,
  16689. 8,
  16690. 0,
  16691. 8,
  16692. 8,
  16693. 8,
  16694. 0,
  16695. 0,
  16696. 0,
  16697. 0,
  16698. 0,
  16699. 8,
  16700. 8,
  16701. 8,
  16702. 0,
  16703. 8,
  16704. 8,
  16705. 8,
  16706. 0,
  16707. 8,
  16708. 8,
  16709. 8
  16710. ]);
  16711. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  16712. this.width = width;
  16713. this.height = height;
  16714. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  16715. var coefficientCount = width * height;
  16716. this.neighborsSignificance = new Uint8Array(coefficientCount);
  16717. this.coefficentsSign = new Uint8Array(coefficientCount);
  16718. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  16719. this.processingFlags = new Uint8Array(coefficientCount);
  16720. var bitsDecoded = new Uint8Array(coefficientCount);
  16721. if (zeroBitPlanes !== 0) {
  16722. for (var i = 0; i < coefficientCount; i++) {
  16723. bitsDecoded[i] = zeroBitPlanes;
  16724. }
  16725. }
  16726. this.bitsDecoded = bitsDecoded;
  16727. this.reset();
  16728. }
  16729. BitModel.prototype = {
  16730. setDecoder: function BitModel_setDecoder(decoder) {
  16731. this.decoder = decoder;
  16732. },
  16733. reset: function BitModel_reset() {
  16734. this.contexts = new Int8Array(19);
  16735. this.contexts[0] = 4 << 1 | 0;
  16736. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  16737. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  16738. },
  16739. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  16740. var neighborsSignificance = this.neighborsSignificance;
  16741. var width = this.width, height = this.height;
  16742. var left = column > 0;
  16743. var right = column + 1 < width;
  16744. var i;
  16745. if (row > 0) {
  16746. i = index - width;
  16747. if (left) {
  16748. neighborsSignificance[i - 1] += 0x10;
  16749. }
  16750. if (right) {
  16751. neighborsSignificance[i + 1] += 0x10;
  16752. }
  16753. neighborsSignificance[i] += 0x04;
  16754. }
  16755. if (row + 1 < height) {
  16756. i = index + width;
  16757. if (left) {
  16758. neighborsSignificance[i - 1] += 0x10;
  16759. }
  16760. if (right) {
  16761. neighborsSignificance[i + 1] += 0x10;
  16762. }
  16763. neighborsSignificance[i] += 0x04;
  16764. }
  16765. if (left) {
  16766. neighborsSignificance[index - 1] += 0x01;
  16767. }
  16768. if (right) {
  16769. neighborsSignificance[index + 1] += 0x01;
  16770. }
  16771. neighborsSignificance[index] |= 0x80;
  16772. },
  16773. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  16774. var decoder = this.decoder;
  16775. var width = this.width, height = this.height;
  16776. var coefficentsMagnitude = this.coefficentsMagnitude;
  16777. var coefficentsSign = this.coefficentsSign;
  16778. var neighborsSignificance = this.neighborsSignificance;
  16779. var processingFlags = this.processingFlags;
  16780. var contexts = this.contexts;
  16781. var labels = this.contextLabelTable;
  16782. var bitsDecoded = this.bitsDecoded;
  16783. var processedInverseMask = ~1;
  16784. var processedMask = 1;
  16785. var firstMagnitudeBitMask = 2;
  16786. for (var i0 = 0; i0 < height; i0 += 4) {
  16787. for (var j = 0; j < width; j++) {
  16788. var index = i0 * width + j;
  16789. for (var i1 = 0; i1 < 4; i1++, index += width) {
  16790. var i = i0 + i1;
  16791. if (i >= height) {
  16792. break;
  16793. }
  16794. processingFlags[index] &= processedInverseMask;
  16795. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  16796. continue;
  16797. }
  16798. var contextLabel = labels[neighborsSignificance[index]];
  16799. var decision = decoder.readBit(contexts, contextLabel);
  16800. if (decision) {
  16801. var sign = this.decodeSignBit(i, j, index);
  16802. coefficentsSign[index] = sign;
  16803. coefficentsMagnitude[index] = 1;
  16804. this.setNeighborsSignificance(i, j, index);
  16805. processingFlags[index] |= firstMagnitudeBitMask;
  16806. }
  16807. bitsDecoded[index]++;
  16808. processingFlags[index] |= processedMask;
  16809. }
  16810. }
  16811. }
  16812. },
  16813. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  16814. var width = this.width, height = this.height;
  16815. var coefficentsMagnitude = this.coefficentsMagnitude;
  16816. var coefficentsSign = this.coefficentsSign;
  16817. var contribution, sign0, sign1, significance1;
  16818. var contextLabel, decoded;
  16819. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  16820. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  16821. sign1 = coefficentsSign[index + 1];
  16822. if (significance1) {
  16823. sign0 = coefficentsSign[index - 1];
  16824. contribution = 1 - sign1 - sign0;
  16825. } else {
  16826. contribution = 1 - sign1 - sign1;
  16827. }
  16828. } else if (significance1) {
  16829. sign0 = coefficentsSign[index - 1];
  16830. contribution = 1 - sign0 - sign0;
  16831. } else {
  16832. contribution = 0;
  16833. }
  16834. var horizontalContribution = 3 * contribution;
  16835. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  16836. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  16837. sign1 = coefficentsSign[index + width];
  16838. if (significance1) {
  16839. sign0 = coefficentsSign[index - width];
  16840. contribution = 1 - sign1 - sign0 + horizontalContribution;
  16841. } else {
  16842. contribution = 1 - sign1 - sign1 + horizontalContribution;
  16843. }
  16844. } else if (significance1) {
  16845. sign0 = coefficentsSign[index - width];
  16846. contribution = 1 - sign0 - sign0 + horizontalContribution;
  16847. } else {
  16848. contribution = horizontalContribution;
  16849. }
  16850. if (contribution >= 0) {
  16851. contextLabel = 9 + contribution;
  16852. decoded = this.decoder.readBit(this.contexts, contextLabel);
  16853. } else {
  16854. contextLabel = 9 - contribution;
  16855. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  16856. }
  16857. return decoded;
  16858. },
  16859. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  16860. var decoder = this.decoder;
  16861. var width = this.width, height = this.height;
  16862. var coefficentsMagnitude = this.coefficentsMagnitude;
  16863. var neighborsSignificance = this.neighborsSignificance;
  16864. var contexts = this.contexts;
  16865. var bitsDecoded = this.bitsDecoded;
  16866. var processingFlags = this.processingFlags;
  16867. var processedMask = 1;
  16868. var firstMagnitudeBitMask = 2;
  16869. var length = width * height;
  16870. var width4 = width * 4;
  16871. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  16872. indexNext = Math.min(length, index0 + width4);
  16873. for (var j = 0; j < width; j++) {
  16874. for (var index = index0 + j; index < indexNext; index += width) {
  16875. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  16876. continue;
  16877. }
  16878. var contextLabel = 16;
  16879. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  16880. processingFlags[index] ^= firstMagnitudeBitMask;
  16881. var significance = neighborsSignificance[index] & 127;
  16882. contextLabel = significance === 0 ? 15 : 14;
  16883. }
  16884. var bit = decoder.readBit(contexts, contextLabel);
  16885. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  16886. bitsDecoded[index]++;
  16887. processingFlags[index] |= processedMask;
  16888. }
  16889. }
  16890. }
  16891. },
  16892. runCleanupPass: function BitModel_runCleanupPass() {
  16893. var decoder = this.decoder;
  16894. var width = this.width, height = this.height;
  16895. var neighborsSignificance = this.neighborsSignificance;
  16896. var coefficentsMagnitude = this.coefficentsMagnitude;
  16897. var coefficentsSign = this.coefficentsSign;
  16898. var contexts = this.contexts;
  16899. var labels = this.contextLabelTable;
  16900. var bitsDecoded = this.bitsDecoded;
  16901. var processingFlags = this.processingFlags;
  16902. var processedMask = 1;
  16903. var firstMagnitudeBitMask = 2;
  16904. var oneRowDown = width;
  16905. var twoRowsDown = width * 2;
  16906. var threeRowsDown = width * 3;
  16907. var iNext;
  16908. for (var i0 = 0; i0 < height; i0 = iNext) {
  16909. iNext = Math.min(i0 + 4, height);
  16910. var indexBase = i0 * width;
  16911. var checkAllEmpty = i0 + 3 < height;
  16912. for (var j = 0; j < width; j++) {
  16913. var index0 = indexBase + j;
  16914. 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;
  16915. var i1 = 0, index = index0;
  16916. var i = i0, sign;
  16917. if (allEmpty) {
  16918. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  16919. if (!hasSignificantCoefficent) {
  16920. bitsDecoded[index0]++;
  16921. bitsDecoded[index0 + oneRowDown]++;
  16922. bitsDecoded[index0 + twoRowsDown]++;
  16923. bitsDecoded[index0 + threeRowsDown]++;
  16924. continue;
  16925. }
  16926. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  16927. if (i1 !== 0) {
  16928. i = i0 + i1;
  16929. index += i1 * width;
  16930. }
  16931. sign = this.decodeSignBit(i, j, index);
  16932. coefficentsSign[index] = sign;
  16933. coefficentsMagnitude[index] = 1;
  16934. this.setNeighborsSignificance(i, j, index);
  16935. processingFlags[index] |= firstMagnitudeBitMask;
  16936. index = index0;
  16937. for (var i2 = i0; i2 <= i; i2++, index += width) {
  16938. bitsDecoded[index]++;
  16939. }
  16940. i1++;
  16941. }
  16942. for (i = i0 + i1; i < iNext; i++, index += width) {
  16943. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  16944. continue;
  16945. }
  16946. var contextLabel = labels[neighborsSignificance[index]];
  16947. var decision = decoder.readBit(contexts, contextLabel);
  16948. if (decision === 1) {
  16949. sign = this.decodeSignBit(i, j, index);
  16950. coefficentsSign[index] = sign;
  16951. coefficentsMagnitude[index] = 1;
  16952. this.setNeighborsSignificance(i, j, index);
  16953. processingFlags[index] |= firstMagnitudeBitMask;
  16954. }
  16955. bitsDecoded[index]++;
  16956. }
  16957. }
  16958. }
  16959. },
  16960. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  16961. var decoder = this.decoder;
  16962. var contexts = this.contexts;
  16963. 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);
  16964. if (symbol !== 0xA) {
  16965. error('JPX Error: Invalid segmentation symbol');
  16966. }
  16967. }
  16968. };
  16969. return BitModel;
  16970. }();
  16971. var Transform = function TransformClosure() {
  16972. function Transform() {
  16973. }
  16974. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  16975. var ll = subbands[0];
  16976. for (var i = 1, ii = subbands.length; i < ii; i++) {
  16977. ll = this.iterate(ll, subbands[i], u0, v0);
  16978. }
  16979. return ll;
  16980. };
  16981. Transform.prototype.extend = function extend(buffer, offset, size) {
  16982. var i1 = offset - 1, j1 = offset + 1;
  16983. var i2 = offset + size - 2, j2 = offset + size;
  16984. buffer[i1--] = buffer[j1++];
  16985. buffer[j2++] = buffer[i2--];
  16986. buffer[i1--] = buffer[j1++];
  16987. buffer[j2++] = buffer[i2--];
  16988. buffer[i1--] = buffer[j1++];
  16989. buffer[j2++] = buffer[i2--];
  16990. buffer[i1] = buffer[j1];
  16991. buffer[j2] = buffer[i2];
  16992. };
  16993. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  16994. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  16995. var width = hl_lh_hh.width;
  16996. var height = hl_lh_hh.height;
  16997. var items = hl_lh_hh.items;
  16998. var i, j, k, l, u, v;
  16999. for (k = 0, i = 0; i < llHeight; i++) {
  17000. l = i * 2 * width;
  17001. for (j = 0; j < llWidth; j++, k++, l += 2) {
  17002. items[l] = llItems[k];
  17003. }
  17004. }
  17005. llItems = ll.items = null;
  17006. var bufferPadding = 4;
  17007. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  17008. if (width === 1) {
  17009. if ((u0 & 1) !== 0) {
  17010. for (v = 0, k = 0; v < height; v++, k += width) {
  17011. items[k] *= 0.5;
  17012. }
  17013. }
  17014. } else {
  17015. for (v = 0, k = 0; v < height; v++, k += width) {
  17016. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  17017. this.extend(rowBuffer, bufferPadding, width);
  17018. this.filter(rowBuffer, bufferPadding, width);
  17019. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  17020. }
  17021. }
  17022. var numBuffers = 16;
  17023. var colBuffers = [];
  17024. for (i = 0; i < numBuffers; i++) {
  17025. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  17026. }
  17027. var b, currentBuffer = 0;
  17028. ll = bufferPadding + height;
  17029. if (height === 1) {
  17030. if ((v0 & 1) !== 0) {
  17031. for (u = 0; u < width; u++) {
  17032. items[u] *= 0.5;
  17033. }
  17034. }
  17035. } else {
  17036. for (u = 0; u < width; u++) {
  17037. if (currentBuffer === 0) {
  17038. numBuffers = Math.min(width - u, numBuffers);
  17039. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  17040. for (b = 0; b < numBuffers; b++) {
  17041. colBuffers[b][l] = items[k + b];
  17042. }
  17043. }
  17044. currentBuffer = numBuffers;
  17045. }
  17046. currentBuffer--;
  17047. var buffer = colBuffers[currentBuffer];
  17048. this.extend(buffer, bufferPadding, height);
  17049. this.filter(buffer, bufferPadding, height);
  17050. if (currentBuffer === 0) {
  17051. k = u - numBuffers + 1;
  17052. for (l = bufferPadding; l < ll; k += width, l++) {
  17053. for (b = 0; b < numBuffers; b++) {
  17054. items[k + b] = colBuffers[b][l];
  17055. }
  17056. }
  17057. }
  17058. }
  17059. }
  17060. return {
  17061. width: width,
  17062. height: height,
  17063. items: items
  17064. };
  17065. };
  17066. return Transform;
  17067. }();
  17068. var IrreversibleTransform = function IrreversibleTransformClosure() {
  17069. function IrreversibleTransform() {
  17070. Transform.call(this);
  17071. }
  17072. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  17073. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  17074. var len = length >> 1;
  17075. offset = offset | 0;
  17076. var j, n, current, next;
  17077. var alpha = -1.586134342059924;
  17078. var beta = -0.052980118572961;
  17079. var gamma = 0.882911075530934;
  17080. var delta = 0.443506852043971;
  17081. var K = 1.230174104914001;
  17082. var K_ = 1 / K;
  17083. j = offset - 3;
  17084. for (n = len + 4; n--; j += 2) {
  17085. x[j] *= K_;
  17086. }
  17087. j = offset - 2;
  17088. current = delta * x[j - 1];
  17089. for (n = len + 3; n--; j += 2) {
  17090. next = delta * x[j + 1];
  17091. x[j] = K * x[j] - current - next;
  17092. if (n--) {
  17093. j += 2;
  17094. current = delta * x[j + 1];
  17095. x[j] = K * x[j] - current - next;
  17096. } else {
  17097. break;
  17098. }
  17099. }
  17100. j = offset - 1;
  17101. current = gamma * x[j - 1];
  17102. for (n = len + 2; n--; j += 2) {
  17103. next = gamma * x[j + 1];
  17104. x[j] -= current + next;
  17105. if (n--) {
  17106. j += 2;
  17107. current = gamma * x[j + 1];
  17108. x[j] -= current + next;
  17109. } else {
  17110. break;
  17111. }
  17112. }
  17113. j = offset;
  17114. current = beta * x[j - 1];
  17115. for (n = len + 1; n--; j += 2) {
  17116. next = beta * x[j + 1];
  17117. x[j] -= current + next;
  17118. if (n--) {
  17119. j += 2;
  17120. current = beta * x[j + 1];
  17121. x[j] -= current + next;
  17122. } else {
  17123. break;
  17124. }
  17125. }
  17126. if (len !== 0) {
  17127. j = offset + 1;
  17128. current = alpha * x[j - 1];
  17129. for (n = len; n--; j += 2) {
  17130. next = alpha * x[j + 1];
  17131. x[j] -= current + next;
  17132. if (n--) {
  17133. j += 2;
  17134. current = alpha * x[j + 1];
  17135. x[j] -= current + next;
  17136. } else {
  17137. break;
  17138. }
  17139. }
  17140. }
  17141. };
  17142. return IrreversibleTransform;
  17143. }();
  17144. var ReversibleTransform = function ReversibleTransformClosure() {
  17145. function ReversibleTransform() {
  17146. Transform.call(this);
  17147. }
  17148. ReversibleTransform.prototype = Object.create(Transform.prototype);
  17149. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  17150. var len = length >> 1;
  17151. offset = offset | 0;
  17152. var j, n;
  17153. for (j = offset, n = len + 1; n--; j += 2) {
  17154. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  17155. }
  17156. for (j = offset + 1, n = len; n--; j += 2) {
  17157. x[j] += x[j - 1] + x[j + 1] >> 1;
  17158. }
  17159. };
  17160. return ReversibleTransform;
  17161. }();
  17162. return JpxImage;
  17163. }();
  17164. exports.JpxImage = JpxImage;
  17165. }));
  17166. (function (root, factory) {
  17167. factory(root.pdfjsCoreMetrics = {}, root.pdfjsSharedUtil);
  17168. }(this, function (exports, sharedUtil) {
  17169. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  17170. var getMetrics = getLookupTableFactory(function (t) {
  17171. t['Courier'] = 600;
  17172. t['Courier-Bold'] = 600;
  17173. t['Courier-BoldOblique'] = 600;
  17174. t['Courier-Oblique'] = 600;
  17175. t['Helvetica'] = getLookupTableFactory(function (t) {
  17176. t['space'] = 278;
  17177. t['exclam'] = 278;
  17178. t['quotedbl'] = 355;
  17179. t['numbersign'] = 556;
  17180. t['dollar'] = 556;
  17181. t['percent'] = 889;
  17182. t['ampersand'] = 667;
  17183. t['quoteright'] = 222;
  17184. t['parenleft'] = 333;
  17185. t['parenright'] = 333;
  17186. t['asterisk'] = 389;
  17187. t['plus'] = 584;
  17188. t['comma'] = 278;
  17189. t['hyphen'] = 333;
  17190. t['period'] = 278;
  17191. t['slash'] = 278;
  17192. t['zero'] = 556;
  17193. t['one'] = 556;
  17194. t['two'] = 556;
  17195. t['three'] = 556;
  17196. t['four'] = 556;
  17197. t['five'] = 556;
  17198. t['six'] = 556;
  17199. t['seven'] = 556;
  17200. t['eight'] = 556;
  17201. t['nine'] = 556;
  17202. t['colon'] = 278;
  17203. t['semicolon'] = 278;
  17204. t['less'] = 584;
  17205. t['equal'] = 584;
  17206. t['greater'] = 584;
  17207. t['question'] = 556;
  17208. t['at'] = 1015;
  17209. t['A'] = 667;
  17210. t['B'] = 667;
  17211. t['C'] = 722;
  17212. t['D'] = 722;
  17213. t['E'] = 667;
  17214. t['F'] = 611;
  17215. t['G'] = 778;
  17216. t['H'] = 722;
  17217. t['I'] = 278;
  17218. t['J'] = 500;
  17219. t['K'] = 667;
  17220. t['L'] = 556;
  17221. t['M'] = 833;
  17222. t['N'] = 722;
  17223. t['O'] = 778;
  17224. t['P'] = 667;
  17225. t['Q'] = 778;
  17226. t['R'] = 722;
  17227. t['S'] = 667;
  17228. t['T'] = 611;
  17229. t['U'] = 722;
  17230. t['V'] = 667;
  17231. t['W'] = 944;
  17232. t['X'] = 667;
  17233. t['Y'] = 667;
  17234. t['Z'] = 611;
  17235. t['bracketleft'] = 278;
  17236. t['backslash'] = 278;
  17237. t['bracketright'] = 278;
  17238. t['asciicircum'] = 469;
  17239. t['underscore'] = 556;
  17240. t['quoteleft'] = 222;
  17241. t['a'] = 556;
  17242. t['b'] = 556;
  17243. t['c'] = 500;
  17244. t['d'] = 556;
  17245. t['e'] = 556;
  17246. t['f'] = 278;
  17247. t['g'] = 556;
  17248. t['h'] = 556;
  17249. t['i'] = 222;
  17250. t['j'] = 222;
  17251. t['k'] = 500;
  17252. t['l'] = 222;
  17253. t['m'] = 833;
  17254. t['n'] = 556;
  17255. t['o'] = 556;
  17256. t['p'] = 556;
  17257. t['q'] = 556;
  17258. t['r'] = 333;
  17259. t['s'] = 500;
  17260. t['t'] = 278;
  17261. t['u'] = 556;
  17262. t['v'] = 500;
  17263. t['w'] = 722;
  17264. t['x'] = 500;
  17265. t['y'] = 500;
  17266. t['z'] = 500;
  17267. t['braceleft'] = 334;
  17268. t['bar'] = 260;
  17269. t['braceright'] = 334;
  17270. t['asciitilde'] = 584;
  17271. t['exclamdown'] = 333;
  17272. t['cent'] = 556;
  17273. t['sterling'] = 556;
  17274. t['fraction'] = 167;
  17275. t['yen'] = 556;
  17276. t['florin'] = 556;
  17277. t['section'] = 556;
  17278. t['currency'] = 556;
  17279. t['quotesingle'] = 191;
  17280. t['quotedblleft'] = 333;
  17281. t['guillemotleft'] = 556;
  17282. t['guilsinglleft'] = 333;
  17283. t['guilsinglright'] = 333;
  17284. t['fi'] = 500;
  17285. t['fl'] = 500;
  17286. t['endash'] = 556;
  17287. t['dagger'] = 556;
  17288. t['daggerdbl'] = 556;
  17289. t['periodcentered'] = 278;
  17290. t['paragraph'] = 537;
  17291. t['bullet'] = 350;
  17292. t['quotesinglbase'] = 222;
  17293. t['quotedblbase'] = 333;
  17294. t['quotedblright'] = 333;
  17295. t['guillemotright'] = 556;
  17296. t['ellipsis'] = 1000;
  17297. t['perthousand'] = 1000;
  17298. t['questiondown'] = 611;
  17299. t['grave'] = 333;
  17300. t['acute'] = 333;
  17301. t['circumflex'] = 333;
  17302. t['tilde'] = 333;
  17303. t['macron'] = 333;
  17304. t['breve'] = 333;
  17305. t['dotaccent'] = 333;
  17306. t['dieresis'] = 333;
  17307. t['ring'] = 333;
  17308. t['cedilla'] = 333;
  17309. t['hungarumlaut'] = 333;
  17310. t['ogonek'] = 333;
  17311. t['caron'] = 333;
  17312. t['emdash'] = 1000;
  17313. t['AE'] = 1000;
  17314. t['ordfeminine'] = 370;
  17315. t['Lslash'] = 556;
  17316. t['Oslash'] = 778;
  17317. t['OE'] = 1000;
  17318. t['ordmasculine'] = 365;
  17319. t['ae'] = 889;
  17320. t['dotlessi'] = 278;
  17321. t['lslash'] = 222;
  17322. t['oslash'] = 611;
  17323. t['oe'] = 944;
  17324. t['germandbls'] = 611;
  17325. t['Idieresis'] = 278;
  17326. t['eacute'] = 556;
  17327. t['abreve'] = 556;
  17328. t['uhungarumlaut'] = 556;
  17329. t['ecaron'] = 556;
  17330. t['Ydieresis'] = 667;
  17331. t['divide'] = 584;
  17332. t['Yacute'] = 667;
  17333. t['Acircumflex'] = 667;
  17334. t['aacute'] = 556;
  17335. t['Ucircumflex'] = 722;
  17336. t['yacute'] = 500;
  17337. t['scommaaccent'] = 500;
  17338. t['ecircumflex'] = 556;
  17339. t['Uring'] = 722;
  17340. t['Udieresis'] = 722;
  17341. t['aogonek'] = 556;
  17342. t['Uacute'] = 722;
  17343. t['uogonek'] = 556;
  17344. t['Edieresis'] = 667;
  17345. t['Dcroat'] = 722;
  17346. t['commaaccent'] = 250;
  17347. t['copyright'] = 737;
  17348. t['Emacron'] = 667;
  17349. t['ccaron'] = 500;
  17350. t['aring'] = 556;
  17351. t['Ncommaaccent'] = 722;
  17352. t['lacute'] = 222;
  17353. t['agrave'] = 556;
  17354. t['Tcommaaccent'] = 611;
  17355. t['Cacute'] = 722;
  17356. t['atilde'] = 556;
  17357. t['Edotaccent'] = 667;
  17358. t['scaron'] = 500;
  17359. t['scedilla'] = 500;
  17360. t['iacute'] = 278;
  17361. t['lozenge'] = 471;
  17362. t['Rcaron'] = 722;
  17363. t['Gcommaaccent'] = 778;
  17364. t['ucircumflex'] = 556;
  17365. t['acircumflex'] = 556;
  17366. t['Amacron'] = 667;
  17367. t['rcaron'] = 333;
  17368. t['ccedilla'] = 500;
  17369. t['Zdotaccent'] = 611;
  17370. t['Thorn'] = 667;
  17371. t['Omacron'] = 778;
  17372. t['Racute'] = 722;
  17373. t['Sacute'] = 667;
  17374. t['dcaron'] = 643;
  17375. t['Umacron'] = 722;
  17376. t['uring'] = 556;
  17377. t['threesuperior'] = 333;
  17378. t['Ograve'] = 778;
  17379. t['Agrave'] = 667;
  17380. t['Abreve'] = 667;
  17381. t['multiply'] = 584;
  17382. t['uacute'] = 556;
  17383. t['Tcaron'] = 611;
  17384. t['partialdiff'] = 476;
  17385. t['ydieresis'] = 500;
  17386. t['Nacute'] = 722;
  17387. t['icircumflex'] = 278;
  17388. t['Ecircumflex'] = 667;
  17389. t['adieresis'] = 556;
  17390. t['edieresis'] = 556;
  17391. t['cacute'] = 500;
  17392. t['nacute'] = 556;
  17393. t['umacron'] = 556;
  17394. t['Ncaron'] = 722;
  17395. t['Iacute'] = 278;
  17396. t['plusminus'] = 584;
  17397. t['brokenbar'] = 260;
  17398. t['registered'] = 737;
  17399. t['Gbreve'] = 778;
  17400. t['Idotaccent'] = 278;
  17401. t['summation'] = 600;
  17402. t['Egrave'] = 667;
  17403. t['racute'] = 333;
  17404. t['omacron'] = 556;
  17405. t['Zacute'] = 611;
  17406. t['Zcaron'] = 611;
  17407. t['greaterequal'] = 549;
  17408. t['Eth'] = 722;
  17409. t['Ccedilla'] = 722;
  17410. t['lcommaaccent'] = 222;
  17411. t['tcaron'] = 317;
  17412. t['eogonek'] = 556;
  17413. t['Uogonek'] = 722;
  17414. t['Aacute'] = 667;
  17415. t['Adieresis'] = 667;
  17416. t['egrave'] = 556;
  17417. t['zacute'] = 500;
  17418. t['iogonek'] = 222;
  17419. t['Oacute'] = 778;
  17420. t['oacute'] = 556;
  17421. t['amacron'] = 556;
  17422. t['sacute'] = 500;
  17423. t['idieresis'] = 278;
  17424. t['Ocircumflex'] = 778;
  17425. t['Ugrave'] = 722;
  17426. t['Delta'] = 612;
  17427. t['thorn'] = 556;
  17428. t['twosuperior'] = 333;
  17429. t['Odieresis'] = 778;
  17430. t['mu'] = 556;
  17431. t['igrave'] = 278;
  17432. t['ohungarumlaut'] = 556;
  17433. t['Eogonek'] = 667;
  17434. t['dcroat'] = 556;
  17435. t['threequarters'] = 834;
  17436. t['Scedilla'] = 667;
  17437. t['lcaron'] = 299;
  17438. t['Kcommaaccent'] = 667;
  17439. t['Lacute'] = 556;
  17440. t['trademark'] = 1000;
  17441. t['edotaccent'] = 556;
  17442. t['Igrave'] = 278;
  17443. t['Imacron'] = 278;
  17444. t['Lcaron'] = 556;
  17445. t['onehalf'] = 834;
  17446. t['lessequal'] = 549;
  17447. t['ocircumflex'] = 556;
  17448. t['ntilde'] = 556;
  17449. t['Uhungarumlaut'] = 722;
  17450. t['Eacute'] = 667;
  17451. t['emacron'] = 556;
  17452. t['gbreve'] = 556;
  17453. t['onequarter'] = 834;
  17454. t['Scaron'] = 667;
  17455. t['Scommaaccent'] = 667;
  17456. t['Ohungarumlaut'] = 778;
  17457. t['degree'] = 400;
  17458. t['ograve'] = 556;
  17459. t['Ccaron'] = 722;
  17460. t['ugrave'] = 556;
  17461. t['radical'] = 453;
  17462. t['Dcaron'] = 722;
  17463. t['rcommaaccent'] = 333;
  17464. t['Ntilde'] = 722;
  17465. t['otilde'] = 556;
  17466. t['Rcommaaccent'] = 722;
  17467. t['Lcommaaccent'] = 556;
  17468. t['Atilde'] = 667;
  17469. t['Aogonek'] = 667;
  17470. t['Aring'] = 667;
  17471. t['Otilde'] = 778;
  17472. t['zdotaccent'] = 500;
  17473. t['Ecaron'] = 667;
  17474. t['Iogonek'] = 278;
  17475. t['kcommaaccent'] = 500;
  17476. t['minus'] = 584;
  17477. t['Icircumflex'] = 278;
  17478. t['ncaron'] = 556;
  17479. t['tcommaaccent'] = 278;
  17480. t['logicalnot'] = 584;
  17481. t['odieresis'] = 556;
  17482. t['udieresis'] = 556;
  17483. t['notequal'] = 549;
  17484. t['gcommaaccent'] = 556;
  17485. t['eth'] = 556;
  17486. t['zcaron'] = 500;
  17487. t['ncommaaccent'] = 556;
  17488. t['onesuperior'] = 333;
  17489. t['imacron'] = 278;
  17490. t['Euro'] = 556;
  17491. });
  17492. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  17493. t['space'] = 278;
  17494. t['exclam'] = 333;
  17495. t['quotedbl'] = 474;
  17496. t['numbersign'] = 556;
  17497. t['dollar'] = 556;
  17498. t['percent'] = 889;
  17499. t['ampersand'] = 722;
  17500. t['quoteright'] = 278;
  17501. t['parenleft'] = 333;
  17502. t['parenright'] = 333;
  17503. t['asterisk'] = 389;
  17504. t['plus'] = 584;
  17505. t['comma'] = 278;
  17506. t['hyphen'] = 333;
  17507. t['period'] = 278;
  17508. t['slash'] = 278;
  17509. t['zero'] = 556;
  17510. t['one'] = 556;
  17511. t['two'] = 556;
  17512. t['three'] = 556;
  17513. t['four'] = 556;
  17514. t['five'] = 556;
  17515. t['six'] = 556;
  17516. t['seven'] = 556;
  17517. t['eight'] = 556;
  17518. t['nine'] = 556;
  17519. t['colon'] = 333;
  17520. t['semicolon'] = 333;
  17521. t['less'] = 584;
  17522. t['equal'] = 584;
  17523. t['greater'] = 584;
  17524. t['question'] = 611;
  17525. t['at'] = 975;
  17526. t['A'] = 722;
  17527. t['B'] = 722;
  17528. t['C'] = 722;
  17529. t['D'] = 722;
  17530. t['E'] = 667;
  17531. t['F'] = 611;
  17532. t['G'] = 778;
  17533. t['H'] = 722;
  17534. t['I'] = 278;
  17535. t['J'] = 556;
  17536. t['K'] = 722;
  17537. t['L'] = 611;
  17538. t['M'] = 833;
  17539. t['N'] = 722;
  17540. t['O'] = 778;
  17541. t['P'] = 667;
  17542. t['Q'] = 778;
  17543. t['R'] = 722;
  17544. t['S'] = 667;
  17545. t['T'] = 611;
  17546. t['U'] = 722;
  17547. t['V'] = 667;
  17548. t['W'] = 944;
  17549. t['X'] = 667;
  17550. t['Y'] = 667;
  17551. t['Z'] = 611;
  17552. t['bracketleft'] = 333;
  17553. t['backslash'] = 278;
  17554. t['bracketright'] = 333;
  17555. t['asciicircum'] = 584;
  17556. t['underscore'] = 556;
  17557. t['quoteleft'] = 278;
  17558. t['a'] = 556;
  17559. t['b'] = 611;
  17560. t['c'] = 556;
  17561. t['d'] = 611;
  17562. t['e'] = 556;
  17563. t['f'] = 333;
  17564. t['g'] = 611;
  17565. t['h'] = 611;
  17566. t['i'] = 278;
  17567. t['j'] = 278;
  17568. t['k'] = 556;
  17569. t['l'] = 278;
  17570. t['m'] = 889;
  17571. t['n'] = 611;
  17572. t['o'] = 611;
  17573. t['p'] = 611;
  17574. t['q'] = 611;
  17575. t['r'] = 389;
  17576. t['s'] = 556;
  17577. t['t'] = 333;
  17578. t['u'] = 611;
  17579. t['v'] = 556;
  17580. t['w'] = 778;
  17581. t['x'] = 556;
  17582. t['y'] = 556;
  17583. t['z'] = 500;
  17584. t['braceleft'] = 389;
  17585. t['bar'] = 280;
  17586. t['braceright'] = 389;
  17587. t['asciitilde'] = 584;
  17588. t['exclamdown'] = 333;
  17589. t['cent'] = 556;
  17590. t['sterling'] = 556;
  17591. t['fraction'] = 167;
  17592. t['yen'] = 556;
  17593. t['florin'] = 556;
  17594. t['section'] = 556;
  17595. t['currency'] = 556;
  17596. t['quotesingle'] = 238;
  17597. t['quotedblleft'] = 500;
  17598. t['guillemotleft'] = 556;
  17599. t['guilsinglleft'] = 333;
  17600. t['guilsinglright'] = 333;
  17601. t['fi'] = 611;
  17602. t['fl'] = 611;
  17603. t['endash'] = 556;
  17604. t['dagger'] = 556;
  17605. t['daggerdbl'] = 556;
  17606. t['periodcentered'] = 278;
  17607. t['paragraph'] = 556;
  17608. t['bullet'] = 350;
  17609. t['quotesinglbase'] = 278;
  17610. t['quotedblbase'] = 500;
  17611. t['quotedblright'] = 500;
  17612. t['guillemotright'] = 556;
  17613. t['ellipsis'] = 1000;
  17614. t['perthousand'] = 1000;
  17615. t['questiondown'] = 611;
  17616. t['grave'] = 333;
  17617. t['acute'] = 333;
  17618. t['circumflex'] = 333;
  17619. t['tilde'] = 333;
  17620. t['macron'] = 333;
  17621. t['breve'] = 333;
  17622. t['dotaccent'] = 333;
  17623. t['dieresis'] = 333;
  17624. t['ring'] = 333;
  17625. t['cedilla'] = 333;
  17626. t['hungarumlaut'] = 333;
  17627. t['ogonek'] = 333;
  17628. t['caron'] = 333;
  17629. t['emdash'] = 1000;
  17630. t['AE'] = 1000;
  17631. t['ordfeminine'] = 370;
  17632. t['Lslash'] = 611;
  17633. t['Oslash'] = 778;
  17634. t['OE'] = 1000;
  17635. t['ordmasculine'] = 365;
  17636. t['ae'] = 889;
  17637. t['dotlessi'] = 278;
  17638. t['lslash'] = 278;
  17639. t['oslash'] = 611;
  17640. t['oe'] = 944;
  17641. t['germandbls'] = 611;
  17642. t['Idieresis'] = 278;
  17643. t['eacute'] = 556;
  17644. t['abreve'] = 556;
  17645. t['uhungarumlaut'] = 611;
  17646. t['ecaron'] = 556;
  17647. t['Ydieresis'] = 667;
  17648. t['divide'] = 584;
  17649. t['Yacute'] = 667;
  17650. t['Acircumflex'] = 722;
  17651. t['aacute'] = 556;
  17652. t['Ucircumflex'] = 722;
  17653. t['yacute'] = 556;
  17654. t['scommaaccent'] = 556;
  17655. t['ecircumflex'] = 556;
  17656. t['Uring'] = 722;
  17657. t['Udieresis'] = 722;
  17658. t['aogonek'] = 556;
  17659. t['Uacute'] = 722;
  17660. t['uogonek'] = 611;
  17661. t['Edieresis'] = 667;
  17662. t['Dcroat'] = 722;
  17663. t['commaaccent'] = 250;
  17664. t['copyright'] = 737;
  17665. t['Emacron'] = 667;
  17666. t['ccaron'] = 556;
  17667. t['aring'] = 556;
  17668. t['Ncommaaccent'] = 722;
  17669. t['lacute'] = 278;
  17670. t['agrave'] = 556;
  17671. t['Tcommaaccent'] = 611;
  17672. t['Cacute'] = 722;
  17673. t['atilde'] = 556;
  17674. t['Edotaccent'] = 667;
  17675. t['scaron'] = 556;
  17676. t['scedilla'] = 556;
  17677. t['iacute'] = 278;
  17678. t['lozenge'] = 494;
  17679. t['Rcaron'] = 722;
  17680. t['Gcommaaccent'] = 778;
  17681. t['ucircumflex'] = 611;
  17682. t['acircumflex'] = 556;
  17683. t['Amacron'] = 722;
  17684. t['rcaron'] = 389;
  17685. t['ccedilla'] = 556;
  17686. t['Zdotaccent'] = 611;
  17687. t['Thorn'] = 667;
  17688. t['Omacron'] = 778;
  17689. t['Racute'] = 722;
  17690. t['Sacute'] = 667;
  17691. t['dcaron'] = 743;
  17692. t['Umacron'] = 722;
  17693. t['uring'] = 611;
  17694. t['threesuperior'] = 333;
  17695. t['Ograve'] = 778;
  17696. t['Agrave'] = 722;
  17697. t['Abreve'] = 722;
  17698. t['multiply'] = 584;
  17699. t['uacute'] = 611;
  17700. t['Tcaron'] = 611;
  17701. t['partialdiff'] = 494;
  17702. t['ydieresis'] = 556;
  17703. t['Nacute'] = 722;
  17704. t['icircumflex'] = 278;
  17705. t['Ecircumflex'] = 667;
  17706. t['adieresis'] = 556;
  17707. t['edieresis'] = 556;
  17708. t['cacute'] = 556;
  17709. t['nacute'] = 611;
  17710. t['umacron'] = 611;
  17711. t['Ncaron'] = 722;
  17712. t['Iacute'] = 278;
  17713. t['plusminus'] = 584;
  17714. t['brokenbar'] = 280;
  17715. t['registered'] = 737;
  17716. t['Gbreve'] = 778;
  17717. t['Idotaccent'] = 278;
  17718. t['summation'] = 600;
  17719. t['Egrave'] = 667;
  17720. t['racute'] = 389;
  17721. t['omacron'] = 611;
  17722. t['Zacute'] = 611;
  17723. t['Zcaron'] = 611;
  17724. t['greaterequal'] = 549;
  17725. t['Eth'] = 722;
  17726. t['Ccedilla'] = 722;
  17727. t['lcommaaccent'] = 278;
  17728. t['tcaron'] = 389;
  17729. t['eogonek'] = 556;
  17730. t['Uogonek'] = 722;
  17731. t['Aacute'] = 722;
  17732. t['Adieresis'] = 722;
  17733. t['egrave'] = 556;
  17734. t['zacute'] = 500;
  17735. t['iogonek'] = 278;
  17736. t['Oacute'] = 778;
  17737. t['oacute'] = 611;
  17738. t['amacron'] = 556;
  17739. t['sacute'] = 556;
  17740. t['idieresis'] = 278;
  17741. t['Ocircumflex'] = 778;
  17742. t['Ugrave'] = 722;
  17743. t['Delta'] = 612;
  17744. t['thorn'] = 611;
  17745. t['twosuperior'] = 333;
  17746. t['Odieresis'] = 778;
  17747. t['mu'] = 611;
  17748. t['igrave'] = 278;
  17749. t['ohungarumlaut'] = 611;
  17750. t['Eogonek'] = 667;
  17751. t['dcroat'] = 611;
  17752. t['threequarters'] = 834;
  17753. t['Scedilla'] = 667;
  17754. t['lcaron'] = 400;
  17755. t['Kcommaaccent'] = 722;
  17756. t['Lacute'] = 611;
  17757. t['trademark'] = 1000;
  17758. t['edotaccent'] = 556;
  17759. t['Igrave'] = 278;
  17760. t['Imacron'] = 278;
  17761. t['Lcaron'] = 611;
  17762. t['onehalf'] = 834;
  17763. t['lessequal'] = 549;
  17764. t['ocircumflex'] = 611;
  17765. t['ntilde'] = 611;
  17766. t['Uhungarumlaut'] = 722;
  17767. t['Eacute'] = 667;
  17768. t['emacron'] = 556;
  17769. t['gbreve'] = 611;
  17770. t['onequarter'] = 834;
  17771. t['Scaron'] = 667;
  17772. t['Scommaaccent'] = 667;
  17773. t['Ohungarumlaut'] = 778;
  17774. t['degree'] = 400;
  17775. t['ograve'] = 611;
  17776. t['Ccaron'] = 722;
  17777. t['ugrave'] = 611;
  17778. t['radical'] = 549;
  17779. t['Dcaron'] = 722;
  17780. t['rcommaaccent'] = 389;
  17781. t['Ntilde'] = 722;
  17782. t['otilde'] = 611;
  17783. t['Rcommaaccent'] = 722;
  17784. t['Lcommaaccent'] = 611;
  17785. t['Atilde'] = 722;
  17786. t['Aogonek'] = 722;
  17787. t['Aring'] = 722;
  17788. t['Otilde'] = 778;
  17789. t['zdotaccent'] = 500;
  17790. t['Ecaron'] = 667;
  17791. t['Iogonek'] = 278;
  17792. t['kcommaaccent'] = 556;
  17793. t['minus'] = 584;
  17794. t['Icircumflex'] = 278;
  17795. t['ncaron'] = 611;
  17796. t['tcommaaccent'] = 333;
  17797. t['logicalnot'] = 584;
  17798. t['odieresis'] = 611;
  17799. t['udieresis'] = 611;
  17800. t['notequal'] = 549;
  17801. t['gcommaaccent'] = 611;
  17802. t['eth'] = 611;
  17803. t['zcaron'] = 500;
  17804. t['ncommaaccent'] = 611;
  17805. t['onesuperior'] = 333;
  17806. t['imacron'] = 278;
  17807. t['Euro'] = 556;
  17808. });
  17809. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  17810. t['space'] = 278;
  17811. t['exclam'] = 333;
  17812. t['quotedbl'] = 474;
  17813. t['numbersign'] = 556;
  17814. t['dollar'] = 556;
  17815. t['percent'] = 889;
  17816. t['ampersand'] = 722;
  17817. t['quoteright'] = 278;
  17818. t['parenleft'] = 333;
  17819. t['parenright'] = 333;
  17820. t['asterisk'] = 389;
  17821. t['plus'] = 584;
  17822. t['comma'] = 278;
  17823. t['hyphen'] = 333;
  17824. t['period'] = 278;
  17825. t['slash'] = 278;
  17826. t['zero'] = 556;
  17827. t['one'] = 556;
  17828. t['two'] = 556;
  17829. t['three'] = 556;
  17830. t['four'] = 556;
  17831. t['five'] = 556;
  17832. t['six'] = 556;
  17833. t['seven'] = 556;
  17834. t['eight'] = 556;
  17835. t['nine'] = 556;
  17836. t['colon'] = 333;
  17837. t['semicolon'] = 333;
  17838. t['less'] = 584;
  17839. t['equal'] = 584;
  17840. t['greater'] = 584;
  17841. t['question'] = 611;
  17842. t['at'] = 975;
  17843. t['A'] = 722;
  17844. t['B'] = 722;
  17845. t['C'] = 722;
  17846. t['D'] = 722;
  17847. t['E'] = 667;
  17848. t['F'] = 611;
  17849. t['G'] = 778;
  17850. t['H'] = 722;
  17851. t['I'] = 278;
  17852. t['J'] = 556;
  17853. t['K'] = 722;
  17854. t['L'] = 611;
  17855. t['M'] = 833;
  17856. t['N'] = 722;
  17857. t['O'] = 778;
  17858. t['P'] = 667;
  17859. t['Q'] = 778;
  17860. t['R'] = 722;
  17861. t['S'] = 667;
  17862. t['T'] = 611;
  17863. t['U'] = 722;
  17864. t['V'] = 667;
  17865. t['W'] = 944;
  17866. t['X'] = 667;
  17867. t['Y'] = 667;
  17868. t['Z'] = 611;
  17869. t['bracketleft'] = 333;
  17870. t['backslash'] = 278;
  17871. t['bracketright'] = 333;
  17872. t['asciicircum'] = 584;
  17873. t['underscore'] = 556;
  17874. t['quoteleft'] = 278;
  17875. t['a'] = 556;
  17876. t['b'] = 611;
  17877. t['c'] = 556;
  17878. t['d'] = 611;
  17879. t['e'] = 556;
  17880. t['f'] = 333;
  17881. t['g'] = 611;
  17882. t['h'] = 611;
  17883. t['i'] = 278;
  17884. t['j'] = 278;
  17885. t['k'] = 556;
  17886. t['l'] = 278;
  17887. t['m'] = 889;
  17888. t['n'] = 611;
  17889. t['o'] = 611;
  17890. t['p'] = 611;
  17891. t['q'] = 611;
  17892. t['r'] = 389;
  17893. t['s'] = 556;
  17894. t['t'] = 333;
  17895. t['u'] = 611;
  17896. t['v'] = 556;
  17897. t['w'] = 778;
  17898. t['x'] = 556;
  17899. t['y'] = 556;
  17900. t['z'] = 500;
  17901. t['braceleft'] = 389;
  17902. t['bar'] = 280;
  17903. t['braceright'] = 389;
  17904. t['asciitilde'] = 584;
  17905. t['exclamdown'] = 333;
  17906. t['cent'] = 556;
  17907. t['sterling'] = 556;
  17908. t['fraction'] = 167;
  17909. t['yen'] = 556;
  17910. t['florin'] = 556;
  17911. t['section'] = 556;
  17912. t['currency'] = 556;
  17913. t['quotesingle'] = 238;
  17914. t['quotedblleft'] = 500;
  17915. t['guillemotleft'] = 556;
  17916. t['guilsinglleft'] = 333;
  17917. t['guilsinglright'] = 333;
  17918. t['fi'] = 611;
  17919. t['fl'] = 611;
  17920. t['endash'] = 556;
  17921. t['dagger'] = 556;
  17922. t['daggerdbl'] = 556;
  17923. t['periodcentered'] = 278;
  17924. t['paragraph'] = 556;
  17925. t['bullet'] = 350;
  17926. t['quotesinglbase'] = 278;
  17927. t['quotedblbase'] = 500;
  17928. t['quotedblright'] = 500;
  17929. t['guillemotright'] = 556;
  17930. t['ellipsis'] = 1000;
  17931. t['perthousand'] = 1000;
  17932. t['questiondown'] = 611;
  17933. t['grave'] = 333;
  17934. t['acute'] = 333;
  17935. t['circumflex'] = 333;
  17936. t['tilde'] = 333;
  17937. t['macron'] = 333;
  17938. t['breve'] = 333;
  17939. t['dotaccent'] = 333;
  17940. t['dieresis'] = 333;
  17941. t['ring'] = 333;
  17942. t['cedilla'] = 333;
  17943. t['hungarumlaut'] = 333;
  17944. t['ogonek'] = 333;
  17945. t['caron'] = 333;
  17946. t['emdash'] = 1000;
  17947. t['AE'] = 1000;
  17948. t['ordfeminine'] = 370;
  17949. t['Lslash'] = 611;
  17950. t['Oslash'] = 778;
  17951. t['OE'] = 1000;
  17952. t['ordmasculine'] = 365;
  17953. t['ae'] = 889;
  17954. t['dotlessi'] = 278;
  17955. t['lslash'] = 278;
  17956. t['oslash'] = 611;
  17957. t['oe'] = 944;
  17958. t['germandbls'] = 611;
  17959. t['Idieresis'] = 278;
  17960. t['eacute'] = 556;
  17961. t['abreve'] = 556;
  17962. t['uhungarumlaut'] = 611;
  17963. t['ecaron'] = 556;
  17964. t['Ydieresis'] = 667;
  17965. t['divide'] = 584;
  17966. t['Yacute'] = 667;
  17967. t['Acircumflex'] = 722;
  17968. t['aacute'] = 556;
  17969. t['Ucircumflex'] = 722;
  17970. t['yacute'] = 556;
  17971. t['scommaaccent'] = 556;
  17972. t['ecircumflex'] = 556;
  17973. t['Uring'] = 722;
  17974. t['Udieresis'] = 722;
  17975. t['aogonek'] = 556;
  17976. t['Uacute'] = 722;
  17977. t['uogonek'] = 611;
  17978. t['Edieresis'] = 667;
  17979. t['Dcroat'] = 722;
  17980. t['commaaccent'] = 250;
  17981. t['copyright'] = 737;
  17982. t['Emacron'] = 667;
  17983. t['ccaron'] = 556;
  17984. t['aring'] = 556;
  17985. t['Ncommaaccent'] = 722;
  17986. t['lacute'] = 278;
  17987. t['agrave'] = 556;
  17988. t['Tcommaaccent'] = 611;
  17989. t['Cacute'] = 722;
  17990. t['atilde'] = 556;
  17991. t['Edotaccent'] = 667;
  17992. t['scaron'] = 556;
  17993. t['scedilla'] = 556;
  17994. t['iacute'] = 278;
  17995. t['lozenge'] = 494;
  17996. t['Rcaron'] = 722;
  17997. t['Gcommaaccent'] = 778;
  17998. t['ucircumflex'] = 611;
  17999. t['acircumflex'] = 556;
  18000. t['Amacron'] = 722;
  18001. t['rcaron'] = 389;
  18002. t['ccedilla'] = 556;
  18003. t['Zdotaccent'] = 611;
  18004. t['Thorn'] = 667;
  18005. t['Omacron'] = 778;
  18006. t['Racute'] = 722;
  18007. t['Sacute'] = 667;
  18008. t['dcaron'] = 743;
  18009. t['Umacron'] = 722;
  18010. t['uring'] = 611;
  18011. t['threesuperior'] = 333;
  18012. t['Ograve'] = 778;
  18013. t['Agrave'] = 722;
  18014. t['Abreve'] = 722;
  18015. t['multiply'] = 584;
  18016. t['uacute'] = 611;
  18017. t['Tcaron'] = 611;
  18018. t['partialdiff'] = 494;
  18019. t['ydieresis'] = 556;
  18020. t['Nacute'] = 722;
  18021. t['icircumflex'] = 278;
  18022. t['Ecircumflex'] = 667;
  18023. t['adieresis'] = 556;
  18024. t['edieresis'] = 556;
  18025. t['cacute'] = 556;
  18026. t['nacute'] = 611;
  18027. t['umacron'] = 611;
  18028. t['Ncaron'] = 722;
  18029. t['Iacute'] = 278;
  18030. t['plusminus'] = 584;
  18031. t['brokenbar'] = 280;
  18032. t['registered'] = 737;
  18033. t['Gbreve'] = 778;
  18034. t['Idotaccent'] = 278;
  18035. t['summation'] = 600;
  18036. t['Egrave'] = 667;
  18037. t['racute'] = 389;
  18038. t['omacron'] = 611;
  18039. t['Zacute'] = 611;
  18040. t['Zcaron'] = 611;
  18041. t['greaterequal'] = 549;
  18042. t['Eth'] = 722;
  18043. t['Ccedilla'] = 722;
  18044. t['lcommaaccent'] = 278;
  18045. t['tcaron'] = 389;
  18046. t['eogonek'] = 556;
  18047. t['Uogonek'] = 722;
  18048. t['Aacute'] = 722;
  18049. t['Adieresis'] = 722;
  18050. t['egrave'] = 556;
  18051. t['zacute'] = 500;
  18052. t['iogonek'] = 278;
  18053. t['Oacute'] = 778;
  18054. t['oacute'] = 611;
  18055. t['amacron'] = 556;
  18056. t['sacute'] = 556;
  18057. t['idieresis'] = 278;
  18058. t['Ocircumflex'] = 778;
  18059. t['Ugrave'] = 722;
  18060. t['Delta'] = 612;
  18061. t['thorn'] = 611;
  18062. t['twosuperior'] = 333;
  18063. t['Odieresis'] = 778;
  18064. t['mu'] = 611;
  18065. t['igrave'] = 278;
  18066. t['ohungarumlaut'] = 611;
  18067. t['Eogonek'] = 667;
  18068. t['dcroat'] = 611;
  18069. t['threequarters'] = 834;
  18070. t['Scedilla'] = 667;
  18071. t['lcaron'] = 400;
  18072. t['Kcommaaccent'] = 722;
  18073. t['Lacute'] = 611;
  18074. t['trademark'] = 1000;
  18075. t['edotaccent'] = 556;
  18076. t['Igrave'] = 278;
  18077. t['Imacron'] = 278;
  18078. t['Lcaron'] = 611;
  18079. t['onehalf'] = 834;
  18080. t['lessequal'] = 549;
  18081. t['ocircumflex'] = 611;
  18082. t['ntilde'] = 611;
  18083. t['Uhungarumlaut'] = 722;
  18084. t['Eacute'] = 667;
  18085. t['emacron'] = 556;
  18086. t['gbreve'] = 611;
  18087. t['onequarter'] = 834;
  18088. t['Scaron'] = 667;
  18089. t['Scommaaccent'] = 667;
  18090. t['Ohungarumlaut'] = 778;
  18091. t['degree'] = 400;
  18092. t['ograve'] = 611;
  18093. t['Ccaron'] = 722;
  18094. t['ugrave'] = 611;
  18095. t['radical'] = 549;
  18096. t['Dcaron'] = 722;
  18097. t['rcommaaccent'] = 389;
  18098. t['Ntilde'] = 722;
  18099. t['otilde'] = 611;
  18100. t['Rcommaaccent'] = 722;
  18101. t['Lcommaaccent'] = 611;
  18102. t['Atilde'] = 722;
  18103. t['Aogonek'] = 722;
  18104. t['Aring'] = 722;
  18105. t['Otilde'] = 778;
  18106. t['zdotaccent'] = 500;
  18107. t['Ecaron'] = 667;
  18108. t['Iogonek'] = 278;
  18109. t['kcommaaccent'] = 556;
  18110. t['minus'] = 584;
  18111. t['Icircumflex'] = 278;
  18112. t['ncaron'] = 611;
  18113. t['tcommaaccent'] = 333;
  18114. t['logicalnot'] = 584;
  18115. t['odieresis'] = 611;
  18116. t['udieresis'] = 611;
  18117. t['notequal'] = 549;
  18118. t['gcommaaccent'] = 611;
  18119. t['eth'] = 611;
  18120. t['zcaron'] = 500;
  18121. t['ncommaaccent'] = 611;
  18122. t['onesuperior'] = 333;
  18123. t['imacron'] = 278;
  18124. t['Euro'] = 556;
  18125. });
  18126. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  18127. t['space'] = 278;
  18128. t['exclam'] = 278;
  18129. t['quotedbl'] = 355;
  18130. t['numbersign'] = 556;
  18131. t['dollar'] = 556;
  18132. t['percent'] = 889;
  18133. t['ampersand'] = 667;
  18134. t['quoteright'] = 222;
  18135. t['parenleft'] = 333;
  18136. t['parenright'] = 333;
  18137. t['asterisk'] = 389;
  18138. t['plus'] = 584;
  18139. t['comma'] = 278;
  18140. t['hyphen'] = 333;
  18141. t['period'] = 278;
  18142. t['slash'] = 278;
  18143. t['zero'] = 556;
  18144. t['one'] = 556;
  18145. t['two'] = 556;
  18146. t['three'] = 556;
  18147. t['four'] = 556;
  18148. t['five'] = 556;
  18149. t['six'] = 556;
  18150. t['seven'] = 556;
  18151. t['eight'] = 556;
  18152. t['nine'] = 556;
  18153. t['colon'] = 278;
  18154. t['semicolon'] = 278;
  18155. t['less'] = 584;
  18156. t['equal'] = 584;
  18157. t['greater'] = 584;
  18158. t['question'] = 556;
  18159. t['at'] = 1015;
  18160. t['A'] = 667;
  18161. t['B'] = 667;
  18162. t['C'] = 722;
  18163. t['D'] = 722;
  18164. t['E'] = 667;
  18165. t['F'] = 611;
  18166. t['G'] = 778;
  18167. t['H'] = 722;
  18168. t['I'] = 278;
  18169. t['J'] = 500;
  18170. t['K'] = 667;
  18171. t['L'] = 556;
  18172. t['M'] = 833;
  18173. t['N'] = 722;
  18174. t['O'] = 778;
  18175. t['P'] = 667;
  18176. t['Q'] = 778;
  18177. t['R'] = 722;
  18178. t['S'] = 667;
  18179. t['T'] = 611;
  18180. t['U'] = 722;
  18181. t['V'] = 667;
  18182. t['W'] = 944;
  18183. t['X'] = 667;
  18184. t['Y'] = 667;
  18185. t['Z'] = 611;
  18186. t['bracketleft'] = 278;
  18187. t['backslash'] = 278;
  18188. t['bracketright'] = 278;
  18189. t['asciicircum'] = 469;
  18190. t['underscore'] = 556;
  18191. t['quoteleft'] = 222;
  18192. t['a'] = 556;
  18193. t['b'] = 556;
  18194. t['c'] = 500;
  18195. t['d'] = 556;
  18196. t['e'] = 556;
  18197. t['f'] = 278;
  18198. t['g'] = 556;
  18199. t['h'] = 556;
  18200. t['i'] = 222;
  18201. t['j'] = 222;
  18202. t['k'] = 500;
  18203. t['l'] = 222;
  18204. t['m'] = 833;
  18205. t['n'] = 556;
  18206. t['o'] = 556;
  18207. t['p'] = 556;
  18208. t['q'] = 556;
  18209. t['r'] = 333;
  18210. t['s'] = 500;
  18211. t['t'] = 278;
  18212. t['u'] = 556;
  18213. t['v'] = 500;
  18214. t['w'] = 722;
  18215. t['x'] = 500;
  18216. t['y'] = 500;
  18217. t['z'] = 500;
  18218. t['braceleft'] = 334;
  18219. t['bar'] = 260;
  18220. t['braceright'] = 334;
  18221. t['asciitilde'] = 584;
  18222. t['exclamdown'] = 333;
  18223. t['cent'] = 556;
  18224. t['sterling'] = 556;
  18225. t['fraction'] = 167;
  18226. t['yen'] = 556;
  18227. t['florin'] = 556;
  18228. t['section'] = 556;
  18229. t['currency'] = 556;
  18230. t['quotesingle'] = 191;
  18231. t['quotedblleft'] = 333;
  18232. t['guillemotleft'] = 556;
  18233. t['guilsinglleft'] = 333;
  18234. t['guilsinglright'] = 333;
  18235. t['fi'] = 500;
  18236. t['fl'] = 500;
  18237. t['endash'] = 556;
  18238. t['dagger'] = 556;
  18239. t['daggerdbl'] = 556;
  18240. t['periodcentered'] = 278;
  18241. t['paragraph'] = 537;
  18242. t['bullet'] = 350;
  18243. t['quotesinglbase'] = 222;
  18244. t['quotedblbase'] = 333;
  18245. t['quotedblright'] = 333;
  18246. t['guillemotright'] = 556;
  18247. t['ellipsis'] = 1000;
  18248. t['perthousand'] = 1000;
  18249. t['questiondown'] = 611;
  18250. t['grave'] = 333;
  18251. t['acute'] = 333;
  18252. t['circumflex'] = 333;
  18253. t['tilde'] = 333;
  18254. t['macron'] = 333;
  18255. t['breve'] = 333;
  18256. t['dotaccent'] = 333;
  18257. t['dieresis'] = 333;
  18258. t['ring'] = 333;
  18259. t['cedilla'] = 333;
  18260. t['hungarumlaut'] = 333;
  18261. t['ogonek'] = 333;
  18262. t['caron'] = 333;
  18263. t['emdash'] = 1000;
  18264. t['AE'] = 1000;
  18265. t['ordfeminine'] = 370;
  18266. t['Lslash'] = 556;
  18267. t['Oslash'] = 778;
  18268. t['OE'] = 1000;
  18269. t['ordmasculine'] = 365;
  18270. t['ae'] = 889;
  18271. t['dotlessi'] = 278;
  18272. t['lslash'] = 222;
  18273. t['oslash'] = 611;
  18274. t['oe'] = 944;
  18275. t['germandbls'] = 611;
  18276. t['Idieresis'] = 278;
  18277. t['eacute'] = 556;
  18278. t['abreve'] = 556;
  18279. t['uhungarumlaut'] = 556;
  18280. t['ecaron'] = 556;
  18281. t['Ydieresis'] = 667;
  18282. t['divide'] = 584;
  18283. t['Yacute'] = 667;
  18284. t['Acircumflex'] = 667;
  18285. t['aacute'] = 556;
  18286. t['Ucircumflex'] = 722;
  18287. t['yacute'] = 500;
  18288. t['scommaaccent'] = 500;
  18289. t['ecircumflex'] = 556;
  18290. t['Uring'] = 722;
  18291. t['Udieresis'] = 722;
  18292. t['aogonek'] = 556;
  18293. t['Uacute'] = 722;
  18294. t['uogonek'] = 556;
  18295. t['Edieresis'] = 667;
  18296. t['Dcroat'] = 722;
  18297. t['commaaccent'] = 250;
  18298. t['copyright'] = 737;
  18299. t['Emacron'] = 667;
  18300. t['ccaron'] = 500;
  18301. t['aring'] = 556;
  18302. t['Ncommaaccent'] = 722;
  18303. t['lacute'] = 222;
  18304. t['agrave'] = 556;
  18305. t['Tcommaaccent'] = 611;
  18306. t['Cacute'] = 722;
  18307. t['atilde'] = 556;
  18308. t['Edotaccent'] = 667;
  18309. t['scaron'] = 500;
  18310. t['scedilla'] = 500;
  18311. t['iacute'] = 278;
  18312. t['lozenge'] = 471;
  18313. t['Rcaron'] = 722;
  18314. t['Gcommaaccent'] = 778;
  18315. t['ucircumflex'] = 556;
  18316. t['acircumflex'] = 556;
  18317. t['Amacron'] = 667;
  18318. t['rcaron'] = 333;
  18319. t['ccedilla'] = 500;
  18320. t['Zdotaccent'] = 611;
  18321. t['Thorn'] = 667;
  18322. t['Omacron'] = 778;
  18323. t['Racute'] = 722;
  18324. t['Sacute'] = 667;
  18325. t['dcaron'] = 643;
  18326. t['Umacron'] = 722;
  18327. t['uring'] = 556;
  18328. t['threesuperior'] = 333;
  18329. t['Ograve'] = 778;
  18330. t['Agrave'] = 667;
  18331. t['Abreve'] = 667;
  18332. t['multiply'] = 584;
  18333. t['uacute'] = 556;
  18334. t['Tcaron'] = 611;
  18335. t['partialdiff'] = 476;
  18336. t['ydieresis'] = 500;
  18337. t['Nacute'] = 722;
  18338. t['icircumflex'] = 278;
  18339. t['Ecircumflex'] = 667;
  18340. t['adieresis'] = 556;
  18341. t['edieresis'] = 556;
  18342. t['cacute'] = 500;
  18343. t['nacute'] = 556;
  18344. t['umacron'] = 556;
  18345. t['Ncaron'] = 722;
  18346. t['Iacute'] = 278;
  18347. t['plusminus'] = 584;
  18348. t['brokenbar'] = 260;
  18349. t['registered'] = 737;
  18350. t['Gbreve'] = 778;
  18351. t['Idotaccent'] = 278;
  18352. t['summation'] = 600;
  18353. t['Egrave'] = 667;
  18354. t['racute'] = 333;
  18355. t['omacron'] = 556;
  18356. t['Zacute'] = 611;
  18357. t['Zcaron'] = 611;
  18358. t['greaterequal'] = 549;
  18359. t['Eth'] = 722;
  18360. t['Ccedilla'] = 722;
  18361. t['lcommaaccent'] = 222;
  18362. t['tcaron'] = 317;
  18363. t['eogonek'] = 556;
  18364. t['Uogonek'] = 722;
  18365. t['Aacute'] = 667;
  18366. t['Adieresis'] = 667;
  18367. t['egrave'] = 556;
  18368. t['zacute'] = 500;
  18369. t['iogonek'] = 222;
  18370. t['Oacute'] = 778;
  18371. t['oacute'] = 556;
  18372. t['amacron'] = 556;
  18373. t['sacute'] = 500;
  18374. t['idieresis'] = 278;
  18375. t['Ocircumflex'] = 778;
  18376. t['Ugrave'] = 722;
  18377. t['Delta'] = 612;
  18378. t['thorn'] = 556;
  18379. t['twosuperior'] = 333;
  18380. t['Odieresis'] = 778;
  18381. t['mu'] = 556;
  18382. t['igrave'] = 278;
  18383. t['ohungarumlaut'] = 556;
  18384. t['Eogonek'] = 667;
  18385. t['dcroat'] = 556;
  18386. t['threequarters'] = 834;
  18387. t['Scedilla'] = 667;
  18388. t['lcaron'] = 299;
  18389. t['Kcommaaccent'] = 667;
  18390. t['Lacute'] = 556;
  18391. t['trademark'] = 1000;
  18392. t['edotaccent'] = 556;
  18393. t['Igrave'] = 278;
  18394. t['Imacron'] = 278;
  18395. t['Lcaron'] = 556;
  18396. t['onehalf'] = 834;
  18397. t['lessequal'] = 549;
  18398. t['ocircumflex'] = 556;
  18399. t['ntilde'] = 556;
  18400. t['Uhungarumlaut'] = 722;
  18401. t['Eacute'] = 667;
  18402. t['emacron'] = 556;
  18403. t['gbreve'] = 556;
  18404. t['onequarter'] = 834;
  18405. t['Scaron'] = 667;
  18406. t['Scommaaccent'] = 667;
  18407. t['Ohungarumlaut'] = 778;
  18408. t['degree'] = 400;
  18409. t['ograve'] = 556;
  18410. t['Ccaron'] = 722;
  18411. t['ugrave'] = 556;
  18412. t['radical'] = 453;
  18413. t['Dcaron'] = 722;
  18414. t['rcommaaccent'] = 333;
  18415. t['Ntilde'] = 722;
  18416. t['otilde'] = 556;
  18417. t['Rcommaaccent'] = 722;
  18418. t['Lcommaaccent'] = 556;
  18419. t['Atilde'] = 667;
  18420. t['Aogonek'] = 667;
  18421. t['Aring'] = 667;
  18422. t['Otilde'] = 778;
  18423. t['zdotaccent'] = 500;
  18424. t['Ecaron'] = 667;
  18425. t['Iogonek'] = 278;
  18426. t['kcommaaccent'] = 500;
  18427. t['minus'] = 584;
  18428. t['Icircumflex'] = 278;
  18429. t['ncaron'] = 556;
  18430. t['tcommaaccent'] = 278;
  18431. t['logicalnot'] = 584;
  18432. t['odieresis'] = 556;
  18433. t['udieresis'] = 556;
  18434. t['notequal'] = 549;
  18435. t['gcommaaccent'] = 556;
  18436. t['eth'] = 556;
  18437. t['zcaron'] = 500;
  18438. t['ncommaaccent'] = 556;
  18439. t['onesuperior'] = 333;
  18440. t['imacron'] = 278;
  18441. t['Euro'] = 556;
  18442. });
  18443. t['Symbol'] = getLookupTableFactory(function (t) {
  18444. t['space'] = 250;
  18445. t['exclam'] = 333;
  18446. t['universal'] = 713;
  18447. t['numbersign'] = 500;
  18448. t['existential'] = 549;
  18449. t['percent'] = 833;
  18450. t['ampersand'] = 778;
  18451. t['suchthat'] = 439;
  18452. t['parenleft'] = 333;
  18453. t['parenright'] = 333;
  18454. t['asteriskmath'] = 500;
  18455. t['plus'] = 549;
  18456. t['comma'] = 250;
  18457. t['minus'] = 549;
  18458. t['period'] = 250;
  18459. t['slash'] = 278;
  18460. t['zero'] = 500;
  18461. t['one'] = 500;
  18462. t['two'] = 500;
  18463. t['three'] = 500;
  18464. t['four'] = 500;
  18465. t['five'] = 500;
  18466. t['six'] = 500;
  18467. t['seven'] = 500;
  18468. t['eight'] = 500;
  18469. t['nine'] = 500;
  18470. t['colon'] = 278;
  18471. t['semicolon'] = 278;
  18472. t['less'] = 549;
  18473. t['equal'] = 549;
  18474. t['greater'] = 549;
  18475. t['question'] = 444;
  18476. t['congruent'] = 549;
  18477. t['Alpha'] = 722;
  18478. t['Beta'] = 667;
  18479. t['Chi'] = 722;
  18480. t['Delta'] = 612;
  18481. t['Epsilon'] = 611;
  18482. t['Phi'] = 763;
  18483. t['Gamma'] = 603;
  18484. t['Eta'] = 722;
  18485. t['Iota'] = 333;
  18486. t['theta1'] = 631;
  18487. t['Kappa'] = 722;
  18488. t['Lambda'] = 686;
  18489. t['Mu'] = 889;
  18490. t['Nu'] = 722;
  18491. t['Omicron'] = 722;
  18492. t['Pi'] = 768;
  18493. t['Theta'] = 741;
  18494. t['Rho'] = 556;
  18495. t['Sigma'] = 592;
  18496. t['Tau'] = 611;
  18497. t['Upsilon'] = 690;
  18498. t['sigma1'] = 439;
  18499. t['Omega'] = 768;
  18500. t['Xi'] = 645;
  18501. t['Psi'] = 795;
  18502. t['Zeta'] = 611;
  18503. t['bracketleft'] = 333;
  18504. t['therefore'] = 863;
  18505. t['bracketright'] = 333;
  18506. t['perpendicular'] = 658;
  18507. t['underscore'] = 500;
  18508. t['radicalex'] = 500;
  18509. t['alpha'] = 631;
  18510. t['beta'] = 549;
  18511. t['chi'] = 549;
  18512. t['delta'] = 494;
  18513. t['epsilon'] = 439;
  18514. t['phi'] = 521;
  18515. t['gamma'] = 411;
  18516. t['eta'] = 603;
  18517. t['iota'] = 329;
  18518. t['phi1'] = 603;
  18519. t['kappa'] = 549;
  18520. t['lambda'] = 549;
  18521. t['mu'] = 576;
  18522. t['nu'] = 521;
  18523. t['omicron'] = 549;
  18524. t['pi'] = 549;
  18525. t['theta'] = 521;
  18526. t['rho'] = 549;
  18527. t['sigma'] = 603;
  18528. t['tau'] = 439;
  18529. t['upsilon'] = 576;
  18530. t['omega1'] = 713;
  18531. t['omega'] = 686;
  18532. t['xi'] = 493;
  18533. t['psi'] = 686;
  18534. t['zeta'] = 494;
  18535. t['braceleft'] = 480;
  18536. t['bar'] = 200;
  18537. t['braceright'] = 480;
  18538. t['similar'] = 549;
  18539. t['Euro'] = 750;
  18540. t['Upsilon1'] = 620;
  18541. t['minute'] = 247;
  18542. t['lessequal'] = 549;
  18543. t['fraction'] = 167;
  18544. t['infinity'] = 713;
  18545. t['florin'] = 500;
  18546. t['club'] = 753;
  18547. t['diamond'] = 753;
  18548. t['heart'] = 753;
  18549. t['spade'] = 753;
  18550. t['arrowboth'] = 1042;
  18551. t['arrowleft'] = 987;
  18552. t['arrowup'] = 603;
  18553. t['arrowright'] = 987;
  18554. t['arrowdown'] = 603;
  18555. t['degree'] = 400;
  18556. t['plusminus'] = 549;
  18557. t['second'] = 411;
  18558. t['greaterequal'] = 549;
  18559. t['multiply'] = 549;
  18560. t['proportional'] = 713;
  18561. t['partialdiff'] = 494;
  18562. t['bullet'] = 460;
  18563. t['divide'] = 549;
  18564. t['notequal'] = 549;
  18565. t['equivalence'] = 549;
  18566. t['approxequal'] = 549;
  18567. t['ellipsis'] = 1000;
  18568. t['arrowvertex'] = 603;
  18569. t['arrowhorizex'] = 1000;
  18570. t['carriagereturn'] = 658;
  18571. t['aleph'] = 823;
  18572. t['Ifraktur'] = 686;
  18573. t['Rfraktur'] = 795;
  18574. t['weierstrass'] = 987;
  18575. t['circlemultiply'] = 768;
  18576. t['circleplus'] = 768;
  18577. t['emptyset'] = 823;
  18578. t['intersection'] = 768;
  18579. t['union'] = 768;
  18580. t['propersuperset'] = 713;
  18581. t['reflexsuperset'] = 713;
  18582. t['notsubset'] = 713;
  18583. t['propersubset'] = 713;
  18584. t['reflexsubset'] = 713;
  18585. t['element'] = 713;
  18586. t['notelement'] = 713;
  18587. t['angle'] = 768;
  18588. t['gradient'] = 713;
  18589. t['registerserif'] = 790;
  18590. t['copyrightserif'] = 790;
  18591. t['trademarkserif'] = 890;
  18592. t['product'] = 823;
  18593. t['radical'] = 549;
  18594. t['dotmath'] = 250;
  18595. t['logicalnot'] = 713;
  18596. t['logicaland'] = 603;
  18597. t['logicalor'] = 603;
  18598. t['arrowdblboth'] = 1042;
  18599. t['arrowdblleft'] = 987;
  18600. t['arrowdblup'] = 603;
  18601. t['arrowdblright'] = 987;
  18602. t['arrowdbldown'] = 603;
  18603. t['lozenge'] = 494;
  18604. t['angleleft'] = 329;
  18605. t['registersans'] = 790;
  18606. t['copyrightsans'] = 790;
  18607. t['trademarksans'] = 786;
  18608. t['summation'] = 713;
  18609. t['parenlefttp'] = 384;
  18610. t['parenleftex'] = 384;
  18611. t['parenleftbt'] = 384;
  18612. t['bracketlefttp'] = 384;
  18613. t['bracketleftex'] = 384;
  18614. t['bracketleftbt'] = 384;
  18615. t['bracelefttp'] = 494;
  18616. t['braceleftmid'] = 494;
  18617. t['braceleftbt'] = 494;
  18618. t['braceex'] = 494;
  18619. t['angleright'] = 329;
  18620. t['integral'] = 274;
  18621. t['integraltp'] = 686;
  18622. t['integralex'] = 686;
  18623. t['integralbt'] = 686;
  18624. t['parenrighttp'] = 384;
  18625. t['parenrightex'] = 384;
  18626. t['parenrightbt'] = 384;
  18627. t['bracketrighttp'] = 384;
  18628. t['bracketrightex'] = 384;
  18629. t['bracketrightbt'] = 384;
  18630. t['bracerighttp'] = 494;
  18631. t['bracerightmid'] = 494;
  18632. t['bracerightbt'] = 494;
  18633. t['apple'] = 790;
  18634. });
  18635. t['Times-Roman'] = getLookupTableFactory(function (t) {
  18636. t['space'] = 250;
  18637. t['exclam'] = 333;
  18638. t['quotedbl'] = 408;
  18639. t['numbersign'] = 500;
  18640. t['dollar'] = 500;
  18641. t['percent'] = 833;
  18642. t['ampersand'] = 778;
  18643. t['quoteright'] = 333;
  18644. t['parenleft'] = 333;
  18645. t['parenright'] = 333;
  18646. t['asterisk'] = 500;
  18647. t['plus'] = 564;
  18648. t['comma'] = 250;
  18649. t['hyphen'] = 333;
  18650. t['period'] = 250;
  18651. t['slash'] = 278;
  18652. t['zero'] = 500;
  18653. t['one'] = 500;
  18654. t['two'] = 500;
  18655. t['three'] = 500;
  18656. t['four'] = 500;
  18657. t['five'] = 500;
  18658. t['six'] = 500;
  18659. t['seven'] = 500;
  18660. t['eight'] = 500;
  18661. t['nine'] = 500;
  18662. t['colon'] = 278;
  18663. t['semicolon'] = 278;
  18664. t['less'] = 564;
  18665. t['equal'] = 564;
  18666. t['greater'] = 564;
  18667. t['question'] = 444;
  18668. t['at'] = 921;
  18669. t['A'] = 722;
  18670. t['B'] = 667;
  18671. t['C'] = 667;
  18672. t['D'] = 722;
  18673. t['E'] = 611;
  18674. t['F'] = 556;
  18675. t['G'] = 722;
  18676. t['H'] = 722;
  18677. t['I'] = 333;
  18678. t['J'] = 389;
  18679. t['K'] = 722;
  18680. t['L'] = 611;
  18681. t['M'] = 889;
  18682. t['N'] = 722;
  18683. t['O'] = 722;
  18684. t['P'] = 556;
  18685. t['Q'] = 722;
  18686. t['R'] = 667;
  18687. t['S'] = 556;
  18688. t['T'] = 611;
  18689. t['U'] = 722;
  18690. t['V'] = 722;
  18691. t['W'] = 944;
  18692. t['X'] = 722;
  18693. t['Y'] = 722;
  18694. t['Z'] = 611;
  18695. t['bracketleft'] = 333;
  18696. t['backslash'] = 278;
  18697. t['bracketright'] = 333;
  18698. t['asciicircum'] = 469;
  18699. t['underscore'] = 500;
  18700. t['quoteleft'] = 333;
  18701. t['a'] = 444;
  18702. t['b'] = 500;
  18703. t['c'] = 444;
  18704. t['d'] = 500;
  18705. t['e'] = 444;
  18706. t['f'] = 333;
  18707. t['g'] = 500;
  18708. t['h'] = 500;
  18709. t['i'] = 278;
  18710. t['j'] = 278;
  18711. t['k'] = 500;
  18712. t['l'] = 278;
  18713. t['m'] = 778;
  18714. t['n'] = 500;
  18715. t['o'] = 500;
  18716. t['p'] = 500;
  18717. t['q'] = 500;
  18718. t['r'] = 333;
  18719. t['s'] = 389;
  18720. t['t'] = 278;
  18721. t['u'] = 500;
  18722. t['v'] = 500;
  18723. t['w'] = 722;
  18724. t['x'] = 500;
  18725. t['y'] = 500;
  18726. t['z'] = 444;
  18727. t['braceleft'] = 480;
  18728. t['bar'] = 200;
  18729. t['braceright'] = 480;
  18730. t['asciitilde'] = 541;
  18731. t['exclamdown'] = 333;
  18732. t['cent'] = 500;
  18733. t['sterling'] = 500;
  18734. t['fraction'] = 167;
  18735. t['yen'] = 500;
  18736. t['florin'] = 500;
  18737. t['section'] = 500;
  18738. t['currency'] = 500;
  18739. t['quotesingle'] = 180;
  18740. t['quotedblleft'] = 444;
  18741. t['guillemotleft'] = 500;
  18742. t['guilsinglleft'] = 333;
  18743. t['guilsinglright'] = 333;
  18744. t['fi'] = 556;
  18745. t['fl'] = 556;
  18746. t['endash'] = 500;
  18747. t['dagger'] = 500;
  18748. t['daggerdbl'] = 500;
  18749. t['periodcentered'] = 250;
  18750. t['paragraph'] = 453;
  18751. t['bullet'] = 350;
  18752. t['quotesinglbase'] = 333;
  18753. t['quotedblbase'] = 444;
  18754. t['quotedblright'] = 444;
  18755. t['guillemotright'] = 500;
  18756. t['ellipsis'] = 1000;
  18757. t['perthousand'] = 1000;
  18758. t['questiondown'] = 444;
  18759. t['grave'] = 333;
  18760. t['acute'] = 333;
  18761. t['circumflex'] = 333;
  18762. t['tilde'] = 333;
  18763. t['macron'] = 333;
  18764. t['breve'] = 333;
  18765. t['dotaccent'] = 333;
  18766. t['dieresis'] = 333;
  18767. t['ring'] = 333;
  18768. t['cedilla'] = 333;
  18769. t['hungarumlaut'] = 333;
  18770. t['ogonek'] = 333;
  18771. t['caron'] = 333;
  18772. t['emdash'] = 1000;
  18773. t['AE'] = 889;
  18774. t['ordfeminine'] = 276;
  18775. t['Lslash'] = 611;
  18776. t['Oslash'] = 722;
  18777. t['OE'] = 889;
  18778. t['ordmasculine'] = 310;
  18779. t['ae'] = 667;
  18780. t['dotlessi'] = 278;
  18781. t['lslash'] = 278;
  18782. t['oslash'] = 500;
  18783. t['oe'] = 722;
  18784. t['germandbls'] = 500;
  18785. t['Idieresis'] = 333;
  18786. t['eacute'] = 444;
  18787. t['abreve'] = 444;
  18788. t['uhungarumlaut'] = 500;
  18789. t['ecaron'] = 444;
  18790. t['Ydieresis'] = 722;
  18791. t['divide'] = 564;
  18792. t['Yacute'] = 722;
  18793. t['Acircumflex'] = 722;
  18794. t['aacute'] = 444;
  18795. t['Ucircumflex'] = 722;
  18796. t['yacute'] = 500;
  18797. t['scommaaccent'] = 389;
  18798. t['ecircumflex'] = 444;
  18799. t['Uring'] = 722;
  18800. t['Udieresis'] = 722;
  18801. t['aogonek'] = 444;
  18802. t['Uacute'] = 722;
  18803. t['uogonek'] = 500;
  18804. t['Edieresis'] = 611;
  18805. t['Dcroat'] = 722;
  18806. t['commaaccent'] = 250;
  18807. t['copyright'] = 760;
  18808. t['Emacron'] = 611;
  18809. t['ccaron'] = 444;
  18810. t['aring'] = 444;
  18811. t['Ncommaaccent'] = 722;
  18812. t['lacute'] = 278;
  18813. t['agrave'] = 444;
  18814. t['Tcommaaccent'] = 611;
  18815. t['Cacute'] = 667;
  18816. t['atilde'] = 444;
  18817. t['Edotaccent'] = 611;
  18818. t['scaron'] = 389;
  18819. t['scedilla'] = 389;
  18820. t['iacute'] = 278;
  18821. t['lozenge'] = 471;
  18822. t['Rcaron'] = 667;
  18823. t['Gcommaaccent'] = 722;
  18824. t['ucircumflex'] = 500;
  18825. t['acircumflex'] = 444;
  18826. t['Amacron'] = 722;
  18827. t['rcaron'] = 333;
  18828. t['ccedilla'] = 444;
  18829. t['Zdotaccent'] = 611;
  18830. t['Thorn'] = 556;
  18831. t['Omacron'] = 722;
  18832. t['Racute'] = 667;
  18833. t['Sacute'] = 556;
  18834. t['dcaron'] = 588;
  18835. t['Umacron'] = 722;
  18836. t['uring'] = 500;
  18837. t['threesuperior'] = 300;
  18838. t['Ograve'] = 722;
  18839. t['Agrave'] = 722;
  18840. t['Abreve'] = 722;
  18841. t['multiply'] = 564;
  18842. t['uacute'] = 500;
  18843. t['Tcaron'] = 611;
  18844. t['partialdiff'] = 476;
  18845. t['ydieresis'] = 500;
  18846. t['Nacute'] = 722;
  18847. t['icircumflex'] = 278;
  18848. t['Ecircumflex'] = 611;
  18849. t['adieresis'] = 444;
  18850. t['edieresis'] = 444;
  18851. t['cacute'] = 444;
  18852. t['nacute'] = 500;
  18853. t['umacron'] = 500;
  18854. t['Ncaron'] = 722;
  18855. t['Iacute'] = 333;
  18856. t['plusminus'] = 564;
  18857. t['brokenbar'] = 200;
  18858. t['registered'] = 760;
  18859. t['Gbreve'] = 722;
  18860. t['Idotaccent'] = 333;
  18861. t['summation'] = 600;
  18862. t['Egrave'] = 611;
  18863. t['racute'] = 333;
  18864. t['omacron'] = 500;
  18865. t['Zacute'] = 611;
  18866. t['Zcaron'] = 611;
  18867. t['greaterequal'] = 549;
  18868. t['Eth'] = 722;
  18869. t['Ccedilla'] = 667;
  18870. t['lcommaaccent'] = 278;
  18871. t['tcaron'] = 326;
  18872. t['eogonek'] = 444;
  18873. t['Uogonek'] = 722;
  18874. t['Aacute'] = 722;
  18875. t['Adieresis'] = 722;
  18876. t['egrave'] = 444;
  18877. t['zacute'] = 444;
  18878. t['iogonek'] = 278;
  18879. t['Oacute'] = 722;
  18880. t['oacute'] = 500;
  18881. t['amacron'] = 444;
  18882. t['sacute'] = 389;
  18883. t['idieresis'] = 278;
  18884. t['Ocircumflex'] = 722;
  18885. t['Ugrave'] = 722;
  18886. t['Delta'] = 612;
  18887. t['thorn'] = 500;
  18888. t['twosuperior'] = 300;
  18889. t['Odieresis'] = 722;
  18890. t['mu'] = 500;
  18891. t['igrave'] = 278;
  18892. t['ohungarumlaut'] = 500;
  18893. t['Eogonek'] = 611;
  18894. t['dcroat'] = 500;
  18895. t['threequarters'] = 750;
  18896. t['Scedilla'] = 556;
  18897. t['lcaron'] = 344;
  18898. t['Kcommaaccent'] = 722;
  18899. t['Lacute'] = 611;
  18900. t['trademark'] = 980;
  18901. t['edotaccent'] = 444;
  18902. t['Igrave'] = 333;
  18903. t['Imacron'] = 333;
  18904. t['Lcaron'] = 611;
  18905. t['onehalf'] = 750;
  18906. t['lessequal'] = 549;
  18907. t['ocircumflex'] = 500;
  18908. t['ntilde'] = 500;
  18909. t['Uhungarumlaut'] = 722;
  18910. t['Eacute'] = 611;
  18911. t['emacron'] = 444;
  18912. t['gbreve'] = 500;
  18913. t['onequarter'] = 750;
  18914. t['Scaron'] = 556;
  18915. t['Scommaaccent'] = 556;
  18916. t['Ohungarumlaut'] = 722;
  18917. t['degree'] = 400;
  18918. t['ograve'] = 500;
  18919. t['Ccaron'] = 667;
  18920. t['ugrave'] = 500;
  18921. t['radical'] = 453;
  18922. t['Dcaron'] = 722;
  18923. t['rcommaaccent'] = 333;
  18924. t['Ntilde'] = 722;
  18925. t['otilde'] = 500;
  18926. t['Rcommaaccent'] = 667;
  18927. t['Lcommaaccent'] = 611;
  18928. t['Atilde'] = 722;
  18929. t['Aogonek'] = 722;
  18930. t['Aring'] = 722;
  18931. t['Otilde'] = 722;
  18932. t['zdotaccent'] = 444;
  18933. t['Ecaron'] = 611;
  18934. t['Iogonek'] = 333;
  18935. t['kcommaaccent'] = 500;
  18936. t['minus'] = 564;
  18937. t['Icircumflex'] = 333;
  18938. t['ncaron'] = 500;
  18939. t['tcommaaccent'] = 278;
  18940. t['logicalnot'] = 564;
  18941. t['odieresis'] = 500;
  18942. t['udieresis'] = 500;
  18943. t['notequal'] = 549;
  18944. t['gcommaaccent'] = 500;
  18945. t['eth'] = 500;
  18946. t['zcaron'] = 444;
  18947. t['ncommaaccent'] = 500;
  18948. t['onesuperior'] = 300;
  18949. t['imacron'] = 278;
  18950. t['Euro'] = 500;
  18951. });
  18952. t['Times-Bold'] = getLookupTableFactory(function (t) {
  18953. t['space'] = 250;
  18954. t['exclam'] = 333;
  18955. t['quotedbl'] = 555;
  18956. t['numbersign'] = 500;
  18957. t['dollar'] = 500;
  18958. t['percent'] = 1000;
  18959. t['ampersand'] = 833;
  18960. t['quoteright'] = 333;
  18961. t['parenleft'] = 333;
  18962. t['parenright'] = 333;
  18963. t['asterisk'] = 500;
  18964. t['plus'] = 570;
  18965. t['comma'] = 250;
  18966. t['hyphen'] = 333;
  18967. t['period'] = 250;
  18968. t['slash'] = 278;
  18969. t['zero'] = 500;
  18970. t['one'] = 500;
  18971. t['two'] = 500;
  18972. t['three'] = 500;
  18973. t['four'] = 500;
  18974. t['five'] = 500;
  18975. t['six'] = 500;
  18976. t['seven'] = 500;
  18977. t['eight'] = 500;
  18978. t['nine'] = 500;
  18979. t['colon'] = 333;
  18980. t['semicolon'] = 333;
  18981. t['less'] = 570;
  18982. t['equal'] = 570;
  18983. t['greater'] = 570;
  18984. t['question'] = 500;
  18985. t['at'] = 930;
  18986. t['A'] = 722;
  18987. t['B'] = 667;
  18988. t['C'] = 722;
  18989. t['D'] = 722;
  18990. t['E'] = 667;
  18991. t['F'] = 611;
  18992. t['G'] = 778;
  18993. t['H'] = 778;
  18994. t['I'] = 389;
  18995. t['J'] = 500;
  18996. t['K'] = 778;
  18997. t['L'] = 667;
  18998. t['M'] = 944;
  18999. t['N'] = 722;
  19000. t['O'] = 778;
  19001. t['P'] = 611;
  19002. t['Q'] = 778;
  19003. t['R'] = 722;
  19004. t['S'] = 556;
  19005. t['T'] = 667;
  19006. t['U'] = 722;
  19007. t['V'] = 722;
  19008. t['W'] = 1000;
  19009. t['X'] = 722;
  19010. t['Y'] = 722;
  19011. t['Z'] = 667;
  19012. t['bracketleft'] = 333;
  19013. t['backslash'] = 278;
  19014. t['bracketright'] = 333;
  19015. t['asciicircum'] = 581;
  19016. t['underscore'] = 500;
  19017. t['quoteleft'] = 333;
  19018. t['a'] = 500;
  19019. t['b'] = 556;
  19020. t['c'] = 444;
  19021. t['d'] = 556;
  19022. t['e'] = 444;
  19023. t['f'] = 333;
  19024. t['g'] = 500;
  19025. t['h'] = 556;
  19026. t['i'] = 278;
  19027. t['j'] = 333;
  19028. t['k'] = 556;
  19029. t['l'] = 278;
  19030. t['m'] = 833;
  19031. t['n'] = 556;
  19032. t['o'] = 500;
  19033. t['p'] = 556;
  19034. t['q'] = 556;
  19035. t['r'] = 444;
  19036. t['s'] = 389;
  19037. t['t'] = 333;
  19038. t['u'] = 556;
  19039. t['v'] = 500;
  19040. t['w'] = 722;
  19041. t['x'] = 500;
  19042. t['y'] = 500;
  19043. t['z'] = 444;
  19044. t['braceleft'] = 394;
  19045. t['bar'] = 220;
  19046. t['braceright'] = 394;
  19047. t['asciitilde'] = 520;
  19048. t['exclamdown'] = 333;
  19049. t['cent'] = 500;
  19050. t['sterling'] = 500;
  19051. t['fraction'] = 167;
  19052. t['yen'] = 500;
  19053. t['florin'] = 500;
  19054. t['section'] = 500;
  19055. t['currency'] = 500;
  19056. t['quotesingle'] = 278;
  19057. t['quotedblleft'] = 500;
  19058. t['guillemotleft'] = 500;
  19059. t['guilsinglleft'] = 333;
  19060. t['guilsinglright'] = 333;
  19061. t['fi'] = 556;
  19062. t['fl'] = 556;
  19063. t['endash'] = 500;
  19064. t['dagger'] = 500;
  19065. t['daggerdbl'] = 500;
  19066. t['periodcentered'] = 250;
  19067. t['paragraph'] = 540;
  19068. t['bullet'] = 350;
  19069. t['quotesinglbase'] = 333;
  19070. t['quotedblbase'] = 500;
  19071. t['quotedblright'] = 500;
  19072. t['guillemotright'] = 500;
  19073. t['ellipsis'] = 1000;
  19074. t['perthousand'] = 1000;
  19075. t['questiondown'] = 500;
  19076. t['grave'] = 333;
  19077. t['acute'] = 333;
  19078. t['circumflex'] = 333;
  19079. t['tilde'] = 333;
  19080. t['macron'] = 333;
  19081. t['breve'] = 333;
  19082. t['dotaccent'] = 333;
  19083. t['dieresis'] = 333;
  19084. t['ring'] = 333;
  19085. t['cedilla'] = 333;
  19086. t['hungarumlaut'] = 333;
  19087. t['ogonek'] = 333;
  19088. t['caron'] = 333;
  19089. t['emdash'] = 1000;
  19090. t['AE'] = 1000;
  19091. t['ordfeminine'] = 300;
  19092. t['Lslash'] = 667;
  19093. t['Oslash'] = 778;
  19094. t['OE'] = 1000;
  19095. t['ordmasculine'] = 330;
  19096. t['ae'] = 722;
  19097. t['dotlessi'] = 278;
  19098. t['lslash'] = 278;
  19099. t['oslash'] = 500;
  19100. t['oe'] = 722;
  19101. t['germandbls'] = 556;
  19102. t['Idieresis'] = 389;
  19103. t['eacute'] = 444;
  19104. t['abreve'] = 500;
  19105. t['uhungarumlaut'] = 556;
  19106. t['ecaron'] = 444;
  19107. t['Ydieresis'] = 722;
  19108. t['divide'] = 570;
  19109. t['Yacute'] = 722;
  19110. t['Acircumflex'] = 722;
  19111. t['aacute'] = 500;
  19112. t['Ucircumflex'] = 722;
  19113. t['yacute'] = 500;
  19114. t['scommaaccent'] = 389;
  19115. t['ecircumflex'] = 444;
  19116. t['Uring'] = 722;
  19117. t['Udieresis'] = 722;
  19118. t['aogonek'] = 500;
  19119. t['Uacute'] = 722;
  19120. t['uogonek'] = 556;
  19121. t['Edieresis'] = 667;
  19122. t['Dcroat'] = 722;
  19123. t['commaaccent'] = 250;
  19124. t['copyright'] = 747;
  19125. t['Emacron'] = 667;
  19126. t['ccaron'] = 444;
  19127. t['aring'] = 500;
  19128. t['Ncommaaccent'] = 722;
  19129. t['lacute'] = 278;
  19130. t['agrave'] = 500;
  19131. t['Tcommaaccent'] = 667;
  19132. t['Cacute'] = 722;
  19133. t['atilde'] = 500;
  19134. t['Edotaccent'] = 667;
  19135. t['scaron'] = 389;
  19136. t['scedilla'] = 389;
  19137. t['iacute'] = 278;
  19138. t['lozenge'] = 494;
  19139. t['Rcaron'] = 722;
  19140. t['Gcommaaccent'] = 778;
  19141. t['ucircumflex'] = 556;
  19142. t['acircumflex'] = 500;
  19143. t['Amacron'] = 722;
  19144. t['rcaron'] = 444;
  19145. t['ccedilla'] = 444;
  19146. t['Zdotaccent'] = 667;
  19147. t['Thorn'] = 611;
  19148. t['Omacron'] = 778;
  19149. t['Racute'] = 722;
  19150. t['Sacute'] = 556;
  19151. t['dcaron'] = 672;
  19152. t['Umacron'] = 722;
  19153. t['uring'] = 556;
  19154. t['threesuperior'] = 300;
  19155. t['Ograve'] = 778;
  19156. t['Agrave'] = 722;
  19157. t['Abreve'] = 722;
  19158. t['multiply'] = 570;
  19159. t['uacute'] = 556;
  19160. t['Tcaron'] = 667;
  19161. t['partialdiff'] = 494;
  19162. t['ydieresis'] = 500;
  19163. t['Nacute'] = 722;
  19164. t['icircumflex'] = 278;
  19165. t['Ecircumflex'] = 667;
  19166. t['adieresis'] = 500;
  19167. t['edieresis'] = 444;
  19168. t['cacute'] = 444;
  19169. t['nacute'] = 556;
  19170. t['umacron'] = 556;
  19171. t['Ncaron'] = 722;
  19172. t['Iacute'] = 389;
  19173. t['plusminus'] = 570;
  19174. t['brokenbar'] = 220;
  19175. t['registered'] = 747;
  19176. t['Gbreve'] = 778;
  19177. t['Idotaccent'] = 389;
  19178. t['summation'] = 600;
  19179. t['Egrave'] = 667;
  19180. t['racute'] = 444;
  19181. t['omacron'] = 500;
  19182. t['Zacute'] = 667;
  19183. t['Zcaron'] = 667;
  19184. t['greaterequal'] = 549;
  19185. t['Eth'] = 722;
  19186. t['Ccedilla'] = 722;
  19187. t['lcommaaccent'] = 278;
  19188. t['tcaron'] = 416;
  19189. t['eogonek'] = 444;
  19190. t['Uogonek'] = 722;
  19191. t['Aacute'] = 722;
  19192. t['Adieresis'] = 722;
  19193. t['egrave'] = 444;
  19194. t['zacute'] = 444;
  19195. t['iogonek'] = 278;
  19196. t['Oacute'] = 778;
  19197. t['oacute'] = 500;
  19198. t['amacron'] = 500;
  19199. t['sacute'] = 389;
  19200. t['idieresis'] = 278;
  19201. t['Ocircumflex'] = 778;
  19202. t['Ugrave'] = 722;
  19203. t['Delta'] = 612;
  19204. t['thorn'] = 556;
  19205. t['twosuperior'] = 300;
  19206. t['Odieresis'] = 778;
  19207. t['mu'] = 556;
  19208. t['igrave'] = 278;
  19209. t['ohungarumlaut'] = 500;
  19210. t['Eogonek'] = 667;
  19211. t['dcroat'] = 556;
  19212. t['threequarters'] = 750;
  19213. t['Scedilla'] = 556;
  19214. t['lcaron'] = 394;
  19215. t['Kcommaaccent'] = 778;
  19216. t['Lacute'] = 667;
  19217. t['trademark'] = 1000;
  19218. t['edotaccent'] = 444;
  19219. t['Igrave'] = 389;
  19220. t['Imacron'] = 389;
  19221. t['Lcaron'] = 667;
  19222. t['onehalf'] = 750;
  19223. t['lessequal'] = 549;
  19224. t['ocircumflex'] = 500;
  19225. t['ntilde'] = 556;
  19226. t['Uhungarumlaut'] = 722;
  19227. t['Eacute'] = 667;
  19228. t['emacron'] = 444;
  19229. t['gbreve'] = 500;
  19230. t['onequarter'] = 750;
  19231. t['Scaron'] = 556;
  19232. t['Scommaaccent'] = 556;
  19233. t['Ohungarumlaut'] = 778;
  19234. t['degree'] = 400;
  19235. t['ograve'] = 500;
  19236. t['Ccaron'] = 722;
  19237. t['ugrave'] = 556;
  19238. t['radical'] = 549;
  19239. t['Dcaron'] = 722;
  19240. t['rcommaaccent'] = 444;
  19241. t['Ntilde'] = 722;
  19242. t['otilde'] = 500;
  19243. t['Rcommaaccent'] = 722;
  19244. t['Lcommaaccent'] = 667;
  19245. t['Atilde'] = 722;
  19246. t['Aogonek'] = 722;
  19247. t['Aring'] = 722;
  19248. t['Otilde'] = 778;
  19249. t['zdotaccent'] = 444;
  19250. t['Ecaron'] = 667;
  19251. t['Iogonek'] = 389;
  19252. t['kcommaaccent'] = 556;
  19253. t['minus'] = 570;
  19254. t['Icircumflex'] = 389;
  19255. t['ncaron'] = 556;
  19256. t['tcommaaccent'] = 333;
  19257. t['logicalnot'] = 570;
  19258. t['odieresis'] = 500;
  19259. t['udieresis'] = 556;
  19260. t['notequal'] = 549;
  19261. t['gcommaaccent'] = 500;
  19262. t['eth'] = 500;
  19263. t['zcaron'] = 444;
  19264. t['ncommaaccent'] = 556;
  19265. t['onesuperior'] = 300;
  19266. t['imacron'] = 278;
  19267. t['Euro'] = 500;
  19268. });
  19269. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  19270. t['space'] = 250;
  19271. t['exclam'] = 389;
  19272. t['quotedbl'] = 555;
  19273. t['numbersign'] = 500;
  19274. t['dollar'] = 500;
  19275. t['percent'] = 833;
  19276. t['ampersand'] = 778;
  19277. t['quoteright'] = 333;
  19278. t['parenleft'] = 333;
  19279. t['parenright'] = 333;
  19280. t['asterisk'] = 500;
  19281. t['plus'] = 570;
  19282. t['comma'] = 250;
  19283. t['hyphen'] = 333;
  19284. t['period'] = 250;
  19285. t['slash'] = 278;
  19286. t['zero'] = 500;
  19287. t['one'] = 500;
  19288. t['two'] = 500;
  19289. t['three'] = 500;
  19290. t['four'] = 500;
  19291. t['five'] = 500;
  19292. t['six'] = 500;
  19293. t['seven'] = 500;
  19294. t['eight'] = 500;
  19295. t['nine'] = 500;
  19296. t['colon'] = 333;
  19297. t['semicolon'] = 333;
  19298. t['less'] = 570;
  19299. t['equal'] = 570;
  19300. t['greater'] = 570;
  19301. t['question'] = 500;
  19302. t['at'] = 832;
  19303. t['A'] = 667;
  19304. t['B'] = 667;
  19305. t['C'] = 667;
  19306. t['D'] = 722;
  19307. t['E'] = 667;
  19308. t['F'] = 667;
  19309. t['G'] = 722;
  19310. t['H'] = 778;
  19311. t['I'] = 389;
  19312. t['J'] = 500;
  19313. t['K'] = 667;
  19314. t['L'] = 611;
  19315. t['M'] = 889;
  19316. t['N'] = 722;
  19317. t['O'] = 722;
  19318. t['P'] = 611;
  19319. t['Q'] = 722;
  19320. t['R'] = 667;
  19321. t['S'] = 556;
  19322. t['T'] = 611;
  19323. t['U'] = 722;
  19324. t['V'] = 667;
  19325. t['W'] = 889;
  19326. t['X'] = 667;
  19327. t['Y'] = 611;
  19328. t['Z'] = 611;
  19329. t['bracketleft'] = 333;
  19330. t['backslash'] = 278;
  19331. t['bracketright'] = 333;
  19332. t['asciicircum'] = 570;
  19333. t['underscore'] = 500;
  19334. t['quoteleft'] = 333;
  19335. t['a'] = 500;
  19336. t['b'] = 500;
  19337. t['c'] = 444;
  19338. t['d'] = 500;
  19339. t['e'] = 444;
  19340. t['f'] = 333;
  19341. t['g'] = 500;
  19342. t['h'] = 556;
  19343. t['i'] = 278;
  19344. t['j'] = 278;
  19345. t['k'] = 500;
  19346. t['l'] = 278;
  19347. t['m'] = 778;
  19348. t['n'] = 556;
  19349. t['o'] = 500;
  19350. t['p'] = 500;
  19351. t['q'] = 500;
  19352. t['r'] = 389;
  19353. t['s'] = 389;
  19354. t['t'] = 278;
  19355. t['u'] = 556;
  19356. t['v'] = 444;
  19357. t['w'] = 667;
  19358. t['x'] = 500;
  19359. t['y'] = 444;
  19360. t['z'] = 389;
  19361. t['braceleft'] = 348;
  19362. t['bar'] = 220;
  19363. t['braceright'] = 348;
  19364. t['asciitilde'] = 570;
  19365. t['exclamdown'] = 389;
  19366. t['cent'] = 500;
  19367. t['sterling'] = 500;
  19368. t['fraction'] = 167;
  19369. t['yen'] = 500;
  19370. t['florin'] = 500;
  19371. t['section'] = 500;
  19372. t['currency'] = 500;
  19373. t['quotesingle'] = 278;
  19374. t['quotedblleft'] = 500;
  19375. t['guillemotleft'] = 500;
  19376. t['guilsinglleft'] = 333;
  19377. t['guilsinglright'] = 333;
  19378. t['fi'] = 556;
  19379. t['fl'] = 556;
  19380. t['endash'] = 500;
  19381. t['dagger'] = 500;
  19382. t['daggerdbl'] = 500;
  19383. t['periodcentered'] = 250;
  19384. t['paragraph'] = 500;
  19385. t['bullet'] = 350;
  19386. t['quotesinglbase'] = 333;
  19387. t['quotedblbase'] = 500;
  19388. t['quotedblright'] = 500;
  19389. t['guillemotright'] = 500;
  19390. t['ellipsis'] = 1000;
  19391. t['perthousand'] = 1000;
  19392. t['questiondown'] = 500;
  19393. t['grave'] = 333;
  19394. t['acute'] = 333;
  19395. t['circumflex'] = 333;
  19396. t['tilde'] = 333;
  19397. t['macron'] = 333;
  19398. t['breve'] = 333;
  19399. t['dotaccent'] = 333;
  19400. t['dieresis'] = 333;
  19401. t['ring'] = 333;
  19402. t['cedilla'] = 333;
  19403. t['hungarumlaut'] = 333;
  19404. t['ogonek'] = 333;
  19405. t['caron'] = 333;
  19406. t['emdash'] = 1000;
  19407. t['AE'] = 944;
  19408. t['ordfeminine'] = 266;
  19409. t['Lslash'] = 611;
  19410. t['Oslash'] = 722;
  19411. t['OE'] = 944;
  19412. t['ordmasculine'] = 300;
  19413. t['ae'] = 722;
  19414. t['dotlessi'] = 278;
  19415. t['lslash'] = 278;
  19416. t['oslash'] = 500;
  19417. t['oe'] = 722;
  19418. t['germandbls'] = 500;
  19419. t['Idieresis'] = 389;
  19420. t['eacute'] = 444;
  19421. t['abreve'] = 500;
  19422. t['uhungarumlaut'] = 556;
  19423. t['ecaron'] = 444;
  19424. t['Ydieresis'] = 611;
  19425. t['divide'] = 570;
  19426. t['Yacute'] = 611;
  19427. t['Acircumflex'] = 667;
  19428. t['aacute'] = 500;
  19429. t['Ucircumflex'] = 722;
  19430. t['yacute'] = 444;
  19431. t['scommaaccent'] = 389;
  19432. t['ecircumflex'] = 444;
  19433. t['Uring'] = 722;
  19434. t['Udieresis'] = 722;
  19435. t['aogonek'] = 500;
  19436. t['Uacute'] = 722;
  19437. t['uogonek'] = 556;
  19438. t['Edieresis'] = 667;
  19439. t['Dcroat'] = 722;
  19440. t['commaaccent'] = 250;
  19441. t['copyright'] = 747;
  19442. t['Emacron'] = 667;
  19443. t['ccaron'] = 444;
  19444. t['aring'] = 500;
  19445. t['Ncommaaccent'] = 722;
  19446. t['lacute'] = 278;
  19447. t['agrave'] = 500;
  19448. t['Tcommaaccent'] = 611;
  19449. t['Cacute'] = 667;
  19450. t['atilde'] = 500;
  19451. t['Edotaccent'] = 667;
  19452. t['scaron'] = 389;
  19453. t['scedilla'] = 389;
  19454. t['iacute'] = 278;
  19455. t['lozenge'] = 494;
  19456. t['Rcaron'] = 667;
  19457. t['Gcommaaccent'] = 722;
  19458. t['ucircumflex'] = 556;
  19459. t['acircumflex'] = 500;
  19460. t['Amacron'] = 667;
  19461. t['rcaron'] = 389;
  19462. t['ccedilla'] = 444;
  19463. t['Zdotaccent'] = 611;
  19464. t['Thorn'] = 611;
  19465. t['Omacron'] = 722;
  19466. t['Racute'] = 667;
  19467. t['Sacute'] = 556;
  19468. t['dcaron'] = 608;
  19469. t['Umacron'] = 722;
  19470. t['uring'] = 556;
  19471. t['threesuperior'] = 300;
  19472. t['Ograve'] = 722;
  19473. t['Agrave'] = 667;
  19474. t['Abreve'] = 667;
  19475. t['multiply'] = 570;
  19476. t['uacute'] = 556;
  19477. t['Tcaron'] = 611;
  19478. t['partialdiff'] = 494;
  19479. t['ydieresis'] = 444;
  19480. t['Nacute'] = 722;
  19481. t['icircumflex'] = 278;
  19482. t['Ecircumflex'] = 667;
  19483. t['adieresis'] = 500;
  19484. t['edieresis'] = 444;
  19485. t['cacute'] = 444;
  19486. t['nacute'] = 556;
  19487. t['umacron'] = 556;
  19488. t['Ncaron'] = 722;
  19489. t['Iacute'] = 389;
  19490. t['plusminus'] = 570;
  19491. t['brokenbar'] = 220;
  19492. t['registered'] = 747;
  19493. t['Gbreve'] = 722;
  19494. t['Idotaccent'] = 389;
  19495. t['summation'] = 600;
  19496. t['Egrave'] = 667;
  19497. t['racute'] = 389;
  19498. t['omacron'] = 500;
  19499. t['Zacute'] = 611;
  19500. t['Zcaron'] = 611;
  19501. t['greaterequal'] = 549;
  19502. t['Eth'] = 722;
  19503. t['Ccedilla'] = 667;
  19504. t['lcommaaccent'] = 278;
  19505. t['tcaron'] = 366;
  19506. t['eogonek'] = 444;
  19507. t['Uogonek'] = 722;
  19508. t['Aacute'] = 667;
  19509. t['Adieresis'] = 667;
  19510. t['egrave'] = 444;
  19511. t['zacute'] = 389;
  19512. t['iogonek'] = 278;
  19513. t['Oacute'] = 722;
  19514. t['oacute'] = 500;
  19515. t['amacron'] = 500;
  19516. t['sacute'] = 389;
  19517. t['idieresis'] = 278;
  19518. t['Ocircumflex'] = 722;
  19519. t['Ugrave'] = 722;
  19520. t['Delta'] = 612;
  19521. t['thorn'] = 500;
  19522. t['twosuperior'] = 300;
  19523. t['Odieresis'] = 722;
  19524. t['mu'] = 576;
  19525. t['igrave'] = 278;
  19526. t['ohungarumlaut'] = 500;
  19527. t['Eogonek'] = 667;
  19528. t['dcroat'] = 500;
  19529. t['threequarters'] = 750;
  19530. t['Scedilla'] = 556;
  19531. t['lcaron'] = 382;
  19532. t['Kcommaaccent'] = 667;
  19533. t['Lacute'] = 611;
  19534. t['trademark'] = 1000;
  19535. t['edotaccent'] = 444;
  19536. t['Igrave'] = 389;
  19537. t['Imacron'] = 389;
  19538. t['Lcaron'] = 611;
  19539. t['onehalf'] = 750;
  19540. t['lessequal'] = 549;
  19541. t['ocircumflex'] = 500;
  19542. t['ntilde'] = 556;
  19543. t['Uhungarumlaut'] = 722;
  19544. t['Eacute'] = 667;
  19545. t['emacron'] = 444;
  19546. t['gbreve'] = 500;
  19547. t['onequarter'] = 750;
  19548. t['Scaron'] = 556;
  19549. t['Scommaaccent'] = 556;
  19550. t['Ohungarumlaut'] = 722;
  19551. t['degree'] = 400;
  19552. t['ograve'] = 500;
  19553. t['Ccaron'] = 667;
  19554. t['ugrave'] = 556;
  19555. t['radical'] = 549;
  19556. t['Dcaron'] = 722;
  19557. t['rcommaaccent'] = 389;
  19558. t['Ntilde'] = 722;
  19559. t['otilde'] = 500;
  19560. t['Rcommaaccent'] = 667;
  19561. t['Lcommaaccent'] = 611;
  19562. t['Atilde'] = 667;
  19563. t['Aogonek'] = 667;
  19564. t['Aring'] = 667;
  19565. t['Otilde'] = 722;
  19566. t['zdotaccent'] = 389;
  19567. t['Ecaron'] = 667;
  19568. t['Iogonek'] = 389;
  19569. t['kcommaaccent'] = 500;
  19570. t['minus'] = 606;
  19571. t['Icircumflex'] = 389;
  19572. t['ncaron'] = 556;
  19573. t['tcommaaccent'] = 278;
  19574. t['logicalnot'] = 606;
  19575. t['odieresis'] = 500;
  19576. t['udieresis'] = 556;
  19577. t['notequal'] = 549;
  19578. t['gcommaaccent'] = 500;
  19579. t['eth'] = 500;
  19580. t['zcaron'] = 389;
  19581. t['ncommaaccent'] = 556;
  19582. t['onesuperior'] = 300;
  19583. t['imacron'] = 278;
  19584. t['Euro'] = 500;
  19585. });
  19586. t['Times-Italic'] = getLookupTableFactory(function (t) {
  19587. t['space'] = 250;
  19588. t['exclam'] = 333;
  19589. t['quotedbl'] = 420;
  19590. t['numbersign'] = 500;
  19591. t['dollar'] = 500;
  19592. t['percent'] = 833;
  19593. t['ampersand'] = 778;
  19594. t['quoteright'] = 333;
  19595. t['parenleft'] = 333;
  19596. t['parenright'] = 333;
  19597. t['asterisk'] = 500;
  19598. t['plus'] = 675;
  19599. t['comma'] = 250;
  19600. t['hyphen'] = 333;
  19601. t['period'] = 250;
  19602. t['slash'] = 278;
  19603. t['zero'] = 500;
  19604. t['one'] = 500;
  19605. t['two'] = 500;
  19606. t['three'] = 500;
  19607. t['four'] = 500;
  19608. t['five'] = 500;
  19609. t['six'] = 500;
  19610. t['seven'] = 500;
  19611. t['eight'] = 500;
  19612. t['nine'] = 500;
  19613. t['colon'] = 333;
  19614. t['semicolon'] = 333;
  19615. t['less'] = 675;
  19616. t['equal'] = 675;
  19617. t['greater'] = 675;
  19618. t['question'] = 500;
  19619. t['at'] = 920;
  19620. t['A'] = 611;
  19621. t['B'] = 611;
  19622. t['C'] = 667;
  19623. t['D'] = 722;
  19624. t['E'] = 611;
  19625. t['F'] = 611;
  19626. t['G'] = 722;
  19627. t['H'] = 722;
  19628. t['I'] = 333;
  19629. t['J'] = 444;
  19630. t['K'] = 667;
  19631. t['L'] = 556;
  19632. t['M'] = 833;
  19633. t['N'] = 667;
  19634. t['O'] = 722;
  19635. t['P'] = 611;
  19636. t['Q'] = 722;
  19637. t['R'] = 611;
  19638. t['S'] = 500;
  19639. t['T'] = 556;
  19640. t['U'] = 722;
  19641. t['V'] = 611;
  19642. t['W'] = 833;
  19643. t['X'] = 611;
  19644. t['Y'] = 556;
  19645. t['Z'] = 556;
  19646. t['bracketleft'] = 389;
  19647. t['backslash'] = 278;
  19648. t['bracketright'] = 389;
  19649. t['asciicircum'] = 422;
  19650. t['underscore'] = 500;
  19651. t['quoteleft'] = 333;
  19652. t['a'] = 500;
  19653. t['b'] = 500;
  19654. t['c'] = 444;
  19655. t['d'] = 500;
  19656. t['e'] = 444;
  19657. t['f'] = 278;
  19658. t['g'] = 500;
  19659. t['h'] = 500;
  19660. t['i'] = 278;
  19661. t['j'] = 278;
  19662. t['k'] = 444;
  19663. t['l'] = 278;
  19664. t['m'] = 722;
  19665. t['n'] = 500;
  19666. t['o'] = 500;
  19667. t['p'] = 500;
  19668. t['q'] = 500;
  19669. t['r'] = 389;
  19670. t['s'] = 389;
  19671. t['t'] = 278;
  19672. t['u'] = 500;
  19673. t['v'] = 444;
  19674. t['w'] = 667;
  19675. t['x'] = 444;
  19676. t['y'] = 444;
  19677. t['z'] = 389;
  19678. t['braceleft'] = 400;
  19679. t['bar'] = 275;
  19680. t['braceright'] = 400;
  19681. t['asciitilde'] = 541;
  19682. t['exclamdown'] = 389;
  19683. t['cent'] = 500;
  19684. t['sterling'] = 500;
  19685. t['fraction'] = 167;
  19686. t['yen'] = 500;
  19687. t['florin'] = 500;
  19688. t['section'] = 500;
  19689. t['currency'] = 500;
  19690. t['quotesingle'] = 214;
  19691. t['quotedblleft'] = 556;
  19692. t['guillemotleft'] = 500;
  19693. t['guilsinglleft'] = 333;
  19694. t['guilsinglright'] = 333;
  19695. t['fi'] = 500;
  19696. t['fl'] = 500;
  19697. t['endash'] = 500;
  19698. t['dagger'] = 500;
  19699. t['daggerdbl'] = 500;
  19700. t['periodcentered'] = 250;
  19701. t['paragraph'] = 523;
  19702. t['bullet'] = 350;
  19703. t['quotesinglbase'] = 333;
  19704. t['quotedblbase'] = 556;
  19705. t['quotedblright'] = 556;
  19706. t['guillemotright'] = 500;
  19707. t['ellipsis'] = 889;
  19708. t['perthousand'] = 1000;
  19709. t['questiondown'] = 500;
  19710. t['grave'] = 333;
  19711. t['acute'] = 333;
  19712. t['circumflex'] = 333;
  19713. t['tilde'] = 333;
  19714. t['macron'] = 333;
  19715. t['breve'] = 333;
  19716. t['dotaccent'] = 333;
  19717. t['dieresis'] = 333;
  19718. t['ring'] = 333;
  19719. t['cedilla'] = 333;
  19720. t['hungarumlaut'] = 333;
  19721. t['ogonek'] = 333;
  19722. t['caron'] = 333;
  19723. t['emdash'] = 889;
  19724. t['AE'] = 889;
  19725. t['ordfeminine'] = 276;
  19726. t['Lslash'] = 556;
  19727. t['Oslash'] = 722;
  19728. t['OE'] = 944;
  19729. t['ordmasculine'] = 310;
  19730. t['ae'] = 667;
  19731. t['dotlessi'] = 278;
  19732. t['lslash'] = 278;
  19733. t['oslash'] = 500;
  19734. t['oe'] = 667;
  19735. t['germandbls'] = 500;
  19736. t['Idieresis'] = 333;
  19737. t['eacute'] = 444;
  19738. t['abreve'] = 500;
  19739. t['uhungarumlaut'] = 500;
  19740. t['ecaron'] = 444;
  19741. t['Ydieresis'] = 556;
  19742. t['divide'] = 675;
  19743. t['Yacute'] = 556;
  19744. t['Acircumflex'] = 611;
  19745. t['aacute'] = 500;
  19746. t['Ucircumflex'] = 722;
  19747. t['yacute'] = 444;
  19748. t['scommaaccent'] = 389;
  19749. t['ecircumflex'] = 444;
  19750. t['Uring'] = 722;
  19751. t['Udieresis'] = 722;
  19752. t['aogonek'] = 500;
  19753. t['Uacute'] = 722;
  19754. t['uogonek'] = 500;
  19755. t['Edieresis'] = 611;
  19756. t['Dcroat'] = 722;
  19757. t['commaaccent'] = 250;
  19758. t['copyright'] = 760;
  19759. t['Emacron'] = 611;
  19760. t['ccaron'] = 444;
  19761. t['aring'] = 500;
  19762. t['Ncommaaccent'] = 667;
  19763. t['lacute'] = 278;
  19764. t['agrave'] = 500;
  19765. t['Tcommaaccent'] = 556;
  19766. t['Cacute'] = 667;
  19767. t['atilde'] = 500;
  19768. t['Edotaccent'] = 611;
  19769. t['scaron'] = 389;
  19770. t['scedilla'] = 389;
  19771. t['iacute'] = 278;
  19772. t['lozenge'] = 471;
  19773. t['Rcaron'] = 611;
  19774. t['Gcommaaccent'] = 722;
  19775. t['ucircumflex'] = 500;
  19776. t['acircumflex'] = 500;
  19777. t['Amacron'] = 611;
  19778. t['rcaron'] = 389;
  19779. t['ccedilla'] = 444;
  19780. t['Zdotaccent'] = 556;
  19781. t['Thorn'] = 611;
  19782. t['Omacron'] = 722;
  19783. t['Racute'] = 611;
  19784. t['Sacute'] = 500;
  19785. t['dcaron'] = 544;
  19786. t['Umacron'] = 722;
  19787. t['uring'] = 500;
  19788. t['threesuperior'] = 300;
  19789. t['Ograve'] = 722;
  19790. t['Agrave'] = 611;
  19791. t['Abreve'] = 611;
  19792. t['multiply'] = 675;
  19793. t['uacute'] = 500;
  19794. t['Tcaron'] = 556;
  19795. t['partialdiff'] = 476;
  19796. t['ydieresis'] = 444;
  19797. t['Nacute'] = 667;
  19798. t['icircumflex'] = 278;
  19799. t['Ecircumflex'] = 611;
  19800. t['adieresis'] = 500;
  19801. t['edieresis'] = 444;
  19802. t['cacute'] = 444;
  19803. t['nacute'] = 500;
  19804. t['umacron'] = 500;
  19805. t['Ncaron'] = 667;
  19806. t['Iacute'] = 333;
  19807. t['plusminus'] = 675;
  19808. t['brokenbar'] = 275;
  19809. t['registered'] = 760;
  19810. t['Gbreve'] = 722;
  19811. t['Idotaccent'] = 333;
  19812. t['summation'] = 600;
  19813. t['Egrave'] = 611;
  19814. t['racute'] = 389;
  19815. t['omacron'] = 500;
  19816. t['Zacute'] = 556;
  19817. t['Zcaron'] = 556;
  19818. t['greaterequal'] = 549;
  19819. t['Eth'] = 722;
  19820. t['Ccedilla'] = 667;
  19821. t['lcommaaccent'] = 278;
  19822. t['tcaron'] = 300;
  19823. t['eogonek'] = 444;
  19824. t['Uogonek'] = 722;
  19825. t['Aacute'] = 611;
  19826. t['Adieresis'] = 611;
  19827. t['egrave'] = 444;
  19828. t['zacute'] = 389;
  19829. t['iogonek'] = 278;
  19830. t['Oacute'] = 722;
  19831. t['oacute'] = 500;
  19832. t['amacron'] = 500;
  19833. t['sacute'] = 389;
  19834. t['idieresis'] = 278;
  19835. t['Ocircumflex'] = 722;
  19836. t['Ugrave'] = 722;
  19837. t['Delta'] = 612;
  19838. t['thorn'] = 500;
  19839. t['twosuperior'] = 300;
  19840. t['Odieresis'] = 722;
  19841. t['mu'] = 500;
  19842. t['igrave'] = 278;
  19843. t['ohungarumlaut'] = 500;
  19844. t['Eogonek'] = 611;
  19845. t['dcroat'] = 500;
  19846. t['threequarters'] = 750;
  19847. t['Scedilla'] = 500;
  19848. t['lcaron'] = 300;
  19849. t['Kcommaaccent'] = 667;
  19850. t['Lacute'] = 556;
  19851. t['trademark'] = 980;
  19852. t['edotaccent'] = 444;
  19853. t['Igrave'] = 333;
  19854. t['Imacron'] = 333;
  19855. t['Lcaron'] = 611;
  19856. t['onehalf'] = 750;
  19857. t['lessequal'] = 549;
  19858. t['ocircumflex'] = 500;
  19859. t['ntilde'] = 500;
  19860. t['Uhungarumlaut'] = 722;
  19861. t['Eacute'] = 611;
  19862. t['emacron'] = 444;
  19863. t['gbreve'] = 500;
  19864. t['onequarter'] = 750;
  19865. t['Scaron'] = 500;
  19866. t['Scommaaccent'] = 500;
  19867. t['Ohungarumlaut'] = 722;
  19868. t['degree'] = 400;
  19869. t['ograve'] = 500;
  19870. t['Ccaron'] = 667;
  19871. t['ugrave'] = 500;
  19872. t['radical'] = 453;
  19873. t['Dcaron'] = 722;
  19874. t['rcommaaccent'] = 389;
  19875. t['Ntilde'] = 667;
  19876. t['otilde'] = 500;
  19877. t['Rcommaaccent'] = 611;
  19878. t['Lcommaaccent'] = 556;
  19879. t['Atilde'] = 611;
  19880. t['Aogonek'] = 611;
  19881. t['Aring'] = 611;
  19882. t['Otilde'] = 722;
  19883. t['zdotaccent'] = 389;
  19884. t['Ecaron'] = 611;
  19885. t['Iogonek'] = 333;
  19886. t['kcommaaccent'] = 444;
  19887. t['minus'] = 675;
  19888. t['Icircumflex'] = 333;
  19889. t['ncaron'] = 500;
  19890. t['tcommaaccent'] = 278;
  19891. t['logicalnot'] = 675;
  19892. t['odieresis'] = 500;
  19893. t['udieresis'] = 500;
  19894. t['notequal'] = 549;
  19895. t['gcommaaccent'] = 500;
  19896. t['eth'] = 500;
  19897. t['zcaron'] = 389;
  19898. t['ncommaaccent'] = 500;
  19899. t['onesuperior'] = 300;
  19900. t['imacron'] = 278;
  19901. t['Euro'] = 500;
  19902. });
  19903. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  19904. t['space'] = 278;
  19905. t['a1'] = 974;
  19906. t['a2'] = 961;
  19907. t['a202'] = 974;
  19908. t['a3'] = 980;
  19909. t['a4'] = 719;
  19910. t['a5'] = 789;
  19911. t['a119'] = 790;
  19912. t['a118'] = 791;
  19913. t['a117'] = 690;
  19914. t['a11'] = 960;
  19915. t['a12'] = 939;
  19916. t['a13'] = 549;
  19917. t['a14'] = 855;
  19918. t['a15'] = 911;
  19919. t['a16'] = 933;
  19920. t['a105'] = 911;
  19921. t['a17'] = 945;
  19922. t['a18'] = 974;
  19923. t['a19'] = 755;
  19924. t['a20'] = 846;
  19925. t['a21'] = 762;
  19926. t['a22'] = 761;
  19927. t['a23'] = 571;
  19928. t['a24'] = 677;
  19929. t['a25'] = 763;
  19930. t['a26'] = 760;
  19931. t['a27'] = 759;
  19932. t['a28'] = 754;
  19933. t['a6'] = 494;
  19934. t['a7'] = 552;
  19935. t['a8'] = 537;
  19936. t['a9'] = 577;
  19937. t['a10'] = 692;
  19938. t['a29'] = 786;
  19939. t['a30'] = 788;
  19940. t['a31'] = 788;
  19941. t['a32'] = 790;
  19942. t['a33'] = 793;
  19943. t['a34'] = 794;
  19944. t['a35'] = 816;
  19945. t['a36'] = 823;
  19946. t['a37'] = 789;
  19947. t['a38'] = 841;
  19948. t['a39'] = 823;
  19949. t['a40'] = 833;
  19950. t['a41'] = 816;
  19951. t['a42'] = 831;
  19952. t['a43'] = 923;
  19953. t['a44'] = 744;
  19954. t['a45'] = 723;
  19955. t['a46'] = 749;
  19956. t['a47'] = 790;
  19957. t['a48'] = 792;
  19958. t['a49'] = 695;
  19959. t['a50'] = 776;
  19960. t['a51'] = 768;
  19961. t['a52'] = 792;
  19962. t['a53'] = 759;
  19963. t['a54'] = 707;
  19964. t['a55'] = 708;
  19965. t['a56'] = 682;
  19966. t['a57'] = 701;
  19967. t['a58'] = 826;
  19968. t['a59'] = 815;
  19969. t['a60'] = 789;
  19970. t['a61'] = 789;
  19971. t['a62'] = 707;
  19972. t['a63'] = 687;
  19973. t['a64'] = 696;
  19974. t['a65'] = 689;
  19975. t['a66'] = 786;
  19976. t['a67'] = 787;
  19977. t['a68'] = 713;
  19978. t['a69'] = 791;
  19979. t['a70'] = 785;
  19980. t['a71'] = 791;
  19981. t['a72'] = 873;
  19982. t['a73'] = 761;
  19983. t['a74'] = 762;
  19984. t['a203'] = 762;
  19985. t['a75'] = 759;
  19986. t['a204'] = 759;
  19987. t['a76'] = 892;
  19988. t['a77'] = 892;
  19989. t['a78'] = 788;
  19990. t['a79'] = 784;
  19991. t['a81'] = 438;
  19992. t['a82'] = 138;
  19993. t['a83'] = 277;
  19994. t['a84'] = 415;
  19995. t['a97'] = 392;
  19996. t['a98'] = 392;
  19997. t['a99'] = 668;
  19998. t['a100'] = 668;
  19999. t['a89'] = 390;
  20000. t['a90'] = 390;
  20001. t['a93'] = 317;
  20002. t['a94'] = 317;
  20003. t['a91'] = 276;
  20004. t['a92'] = 276;
  20005. t['a205'] = 509;
  20006. t['a85'] = 509;
  20007. t['a206'] = 410;
  20008. t['a86'] = 410;
  20009. t['a87'] = 234;
  20010. t['a88'] = 234;
  20011. t['a95'] = 334;
  20012. t['a96'] = 334;
  20013. t['a101'] = 732;
  20014. t['a102'] = 544;
  20015. t['a103'] = 544;
  20016. t['a104'] = 910;
  20017. t['a106'] = 667;
  20018. t['a107'] = 760;
  20019. t['a108'] = 760;
  20020. t['a112'] = 776;
  20021. t['a111'] = 595;
  20022. t['a110'] = 694;
  20023. t['a109'] = 626;
  20024. t['a120'] = 788;
  20025. t['a121'] = 788;
  20026. t['a122'] = 788;
  20027. t['a123'] = 788;
  20028. t['a124'] = 788;
  20029. t['a125'] = 788;
  20030. t['a126'] = 788;
  20031. t['a127'] = 788;
  20032. t['a128'] = 788;
  20033. t['a129'] = 788;
  20034. t['a130'] = 788;
  20035. t['a131'] = 788;
  20036. t['a132'] = 788;
  20037. t['a133'] = 788;
  20038. t['a134'] = 788;
  20039. t['a135'] = 788;
  20040. t['a136'] = 788;
  20041. t['a137'] = 788;
  20042. t['a138'] = 788;
  20043. t['a139'] = 788;
  20044. t['a140'] = 788;
  20045. t['a141'] = 788;
  20046. t['a142'] = 788;
  20047. t['a143'] = 788;
  20048. t['a144'] = 788;
  20049. t['a145'] = 788;
  20050. t['a146'] = 788;
  20051. t['a147'] = 788;
  20052. t['a148'] = 788;
  20053. t['a149'] = 788;
  20054. t['a150'] = 788;
  20055. t['a151'] = 788;
  20056. t['a152'] = 788;
  20057. t['a153'] = 788;
  20058. t['a154'] = 788;
  20059. t['a155'] = 788;
  20060. t['a156'] = 788;
  20061. t['a157'] = 788;
  20062. t['a158'] = 788;
  20063. t['a159'] = 788;
  20064. t['a160'] = 894;
  20065. t['a161'] = 838;
  20066. t['a163'] = 1016;
  20067. t['a164'] = 458;
  20068. t['a196'] = 748;
  20069. t['a165'] = 924;
  20070. t['a192'] = 748;
  20071. t['a166'] = 918;
  20072. t['a167'] = 927;
  20073. t['a168'] = 928;
  20074. t['a169'] = 928;
  20075. t['a170'] = 834;
  20076. t['a171'] = 873;
  20077. t['a172'] = 828;
  20078. t['a173'] = 924;
  20079. t['a162'] = 924;
  20080. t['a174'] = 917;
  20081. t['a175'] = 930;
  20082. t['a176'] = 931;
  20083. t['a177'] = 463;
  20084. t['a178'] = 883;
  20085. t['a179'] = 836;
  20086. t['a193'] = 836;
  20087. t['a180'] = 867;
  20088. t['a199'] = 867;
  20089. t['a181'] = 696;
  20090. t['a200'] = 696;
  20091. t['a182'] = 874;
  20092. t['a201'] = 874;
  20093. t['a183'] = 760;
  20094. t['a184'] = 946;
  20095. t['a197'] = 771;
  20096. t['a185'] = 865;
  20097. t['a194'] = 771;
  20098. t['a198'] = 888;
  20099. t['a186'] = 967;
  20100. t['a195'] = 888;
  20101. t['a187'] = 831;
  20102. t['a188'] = 873;
  20103. t['a189'] = 927;
  20104. t['a190'] = 970;
  20105. t['a191'] = 918;
  20106. });
  20107. });
  20108. exports.getMetrics = getMetrics;
  20109. }));
  20110. (function (root, factory) {
  20111. factory(root.pdfjsCoreMurmurHash3 = {}, root.pdfjsSharedUtil);
  20112. }(this, function (exports, sharedUtil) {
  20113. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  20114. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  20115. var MASK_HIGH = 0xffff0000;
  20116. var MASK_LOW = 0xffff;
  20117. function MurmurHash3_64(seed) {
  20118. var SEED = 0xc3d2e1f0;
  20119. this.h1 = seed ? seed & 0xffffffff : SEED;
  20120. this.h2 = seed ? seed & 0xffffffff : SEED;
  20121. }
  20122. var alwaysUseUint32ArrayView = false;
  20123. try {
  20124. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  20125. } catch (e) {
  20126. alwaysUseUint32ArrayView = true;
  20127. }
  20128. MurmurHash3_64.prototype = {
  20129. update: function MurmurHash3_64_update(input) {
  20130. var useUint32ArrayView = alwaysUseUint32ArrayView;
  20131. var i;
  20132. if (typeof input === 'string') {
  20133. var data = new Uint8Array(input.length * 2);
  20134. var length = 0;
  20135. for (i = 0; i < input.length; i++) {
  20136. var code = input.charCodeAt(i);
  20137. if (code <= 0xff) {
  20138. data[length++] = code;
  20139. } else {
  20140. data[length++] = code >>> 8;
  20141. data[length++] = code & 0xff;
  20142. }
  20143. }
  20144. } else if (input instanceof Uint8Array) {
  20145. data = input;
  20146. length = data.length;
  20147. } else if (typeof input === 'object' && 'length' in input) {
  20148. data = input;
  20149. length = data.length;
  20150. useUint32ArrayView = true;
  20151. } else {
  20152. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  20153. }
  20154. var blockCounts = length >> 2;
  20155. var tailLength = length - blockCounts * 4;
  20156. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  20157. var k1 = 0;
  20158. var k2 = 0;
  20159. var h1 = this.h1;
  20160. var h2 = this.h2;
  20161. var C1 = 0xcc9e2d51;
  20162. var C2 = 0x1b873593;
  20163. var C1_LOW = C1 & MASK_LOW;
  20164. var C2_LOW = C2 & MASK_LOW;
  20165. for (i = 0; i < blockCounts; i++) {
  20166. if (i & 1) {
  20167. k1 = dataUint32[i];
  20168. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  20169. k1 = k1 << 15 | k1 >>> 17;
  20170. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  20171. h1 ^= k1;
  20172. h1 = h1 << 13 | h1 >>> 19;
  20173. h1 = h1 * 5 + 0xe6546b64;
  20174. } else {
  20175. k2 = dataUint32[i];
  20176. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  20177. k2 = k2 << 15 | k2 >>> 17;
  20178. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  20179. h2 ^= k2;
  20180. h2 = h2 << 13 | h2 >>> 19;
  20181. h2 = h2 * 5 + 0xe6546b64;
  20182. }
  20183. }
  20184. k1 = 0;
  20185. switch (tailLength) {
  20186. case 3:
  20187. k1 ^= data[blockCounts * 4 + 2] << 16;
  20188. case 2:
  20189. k1 ^= data[blockCounts * 4 + 1] << 8;
  20190. case 1:
  20191. k1 ^= data[blockCounts * 4];
  20192. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  20193. k1 = k1 << 15 | k1 >>> 17;
  20194. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  20195. if (blockCounts & 1) {
  20196. h1 ^= k1;
  20197. } else {
  20198. h2 ^= k1;
  20199. }
  20200. }
  20201. this.h1 = h1;
  20202. this.h2 = h2;
  20203. return this;
  20204. },
  20205. hexdigest: function MurmurHash3_64_hexdigest() {
  20206. var h1 = this.h1;
  20207. var h2 = this.h2;
  20208. h1 ^= h2 >>> 1;
  20209. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  20210. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  20211. h1 ^= h2 >>> 1;
  20212. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  20213. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  20214. h1 ^= h2 >>> 1;
  20215. for (var i = 0, arr = [
  20216. h1,
  20217. h2
  20218. ], str = ''; i < arr.length; i++) {
  20219. var hex = (arr[i] >>> 0).toString(16);
  20220. while (hex.length < 8) {
  20221. hex = '0' + hex;
  20222. }
  20223. str += hex;
  20224. }
  20225. return str;
  20226. }
  20227. };
  20228. return MurmurHash3_64;
  20229. }();
  20230. exports.MurmurHash3_64 = MurmurHash3_64;
  20231. }));
  20232. (function (root, factory) {
  20233. factory(root.pdfjsCorePrimitives = {}, root.pdfjsSharedUtil);
  20234. }(this, function (exports, sharedUtil) {
  20235. var isArray = sharedUtil.isArray;
  20236. var Name = function NameClosure() {
  20237. function Name(name) {
  20238. this.name = name;
  20239. }
  20240. Name.prototype = {};
  20241. var nameCache = Object.create(null);
  20242. Name.get = function Name_get(name) {
  20243. var nameValue = nameCache[name];
  20244. return nameValue ? nameValue : nameCache[name] = new Name(name);
  20245. };
  20246. return Name;
  20247. }();
  20248. var Cmd = function CmdClosure() {
  20249. function Cmd(cmd) {
  20250. this.cmd = cmd;
  20251. }
  20252. Cmd.prototype = {};
  20253. var cmdCache = Object.create(null);
  20254. Cmd.get = function Cmd_get(cmd) {
  20255. var cmdValue = cmdCache[cmd];
  20256. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  20257. };
  20258. return Cmd;
  20259. }();
  20260. var Dict = function DictClosure() {
  20261. var nonSerializable = function nonSerializableClosure() {
  20262. return nonSerializable;
  20263. };
  20264. function Dict(xref) {
  20265. this.map = Object.create(null);
  20266. this.xref = xref;
  20267. this.objId = null;
  20268. this.suppressEncryption = false;
  20269. this.__nonSerializable__ = nonSerializable;
  20270. }
  20271. Dict.prototype = {
  20272. assignXref: function Dict_assignXref(newXref) {
  20273. this.xref = newXref;
  20274. },
  20275. get: function Dict_get(key1, key2, key3) {
  20276. var value;
  20277. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20278. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  20279. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20280. }
  20281. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  20282. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20283. }
  20284. value = this.map[key3] || null;
  20285. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20286. },
  20287. getAsync: function Dict_getAsync(key1, key2, key3) {
  20288. var value;
  20289. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20290. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  20291. if (xref) {
  20292. return xref.fetchIfRefAsync(value, suppressEncryption);
  20293. }
  20294. return Promise.resolve(value);
  20295. }
  20296. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  20297. if (xref) {
  20298. return xref.fetchIfRefAsync(value, suppressEncryption);
  20299. }
  20300. return Promise.resolve(value);
  20301. }
  20302. value = this.map[key3] || null;
  20303. if (xref) {
  20304. return xref.fetchIfRefAsync(value, suppressEncryption);
  20305. }
  20306. return Promise.resolve(value);
  20307. },
  20308. getArray: function Dict_getArray(key1, key2, key3) {
  20309. var value = this.get(key1, key2, key3);
  20310. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20311. if (!isArray(value) || !xref) {
  20312. return value;
  20313. }
  20314. value = value.slice();
  20315. for (var i = 0, ii = value.length; i < ii; i++) {
  20316. if (!isRef(value[i])) {
  20317. continue;
  20318. }
  20319. value[i] = xref.fetch(value[i], suppressEncryption);
  20320. }
  20321. return value;
  20322. },
  20323. getRaw: function Dict_getRaw(key) {
  20324. return this.map[key];
  20325. },
  20326. getKeys: function Dict_getKeys() {
  20327. return Object.keys(this.map);
  20328. },
  20329. set: function Dict_set(key, value) {
  20330. this.map[key] = value;
  20331. },
  20332. has: function Dict_has(key) {
  20333. return key in this.map;
  20334. },
  20335. forEach: function Dict_forEach(callback) {
  20336. for (var key in this.map) {
  20337. callback(key, this.get(key));
  20338. }
  20339. }
  20340. };
  20341. Dict.empty = new Dict(null);
  20342. Dict.merge = function Dict_merge(xref, dictArray) {
  20343. var mergedDict = new Dict(xref);
  20344. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  20345. var dict = dictArray[i];
  20346. if (!isDict(dict)) {
  20347. continue;
  20348. }
  20349. for (var keyName in dict.map) {
  20350. if (mergedDict.map[keyName]) {
  20351. continue;
  20352. }
  20353. mergedDict.map[keyName] = dict.map[keyName];
  20354. }
  20355. }
  20356. return mergedDict;
  20357. };
  20358. return Dict;
  20359. }();
  20360. var Ref = function RefClosure() {
  20361. function Ref(num, gen) {
  20362. this.num = num;
  20363. this.gen = gen;
  20364. }
  20365. Ref.prototype = {
  20366. toString: function Ref_toString() {
  20367. var str = this.num + 'R';
  20368. if (this.gen !== 0) {
  20369. str += this.gen;
  20370. }
  20371. return str;
  20372. }
  20373. };
  20374. return Ref;
  20375. }();
  20376. var RefSet = function RefSetClosure() {
  20377. function RefSet() {
  20378. this.dict = Object.create(null);
  20379. }
  20380. RefSet.prototype = {
  20381. has: function RefSet_has(ref) {
  20382. return ref.toString() in this.dict;
  20383. },
  20384. put: function RefSet_put(ref) {
  20385. this.dict[ref.toString()] = true;
  20386. },
  20387. remove: function RefSet_remove(ref) {
  20388. delete this.dict[ref.toString()];
  20389. }
  20390. };
  20391. return RefSet;
  20392. }();
  20393. var RefSetCache = function RefSetCacheClosure() {
  20394. function RefSetCache() {
  20395. this.dict = Object.create(null);
  20396. }
  20397. RefSetCache.prototype = {
  20398. get: function RefSetCache_get(ref) {
  20399. return this.dict[ref.toString()];
  20400. },
  20401. has: function RefSetCache_has(ref) {
  20402. return ref.toString() in this.dict;
  20403. },
  20404. put: function RefSetCache_put(ref, obj) {
  20405. this.dict[ref.toString()] = obj;
  20406. },
  20407. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  20408. this.dict[ref.toString()] = this.get(aliasRef);
  20409. },
  20410. forEach: function RefSetCache_forEach(fn, thisArg) {
  20411. for (var i in this.dict) {
  20412. fn.call(thisArg, this.dict[i]);
  20413. }
  20414. },
  20415. clear: function RefSetCache_clear() {
  20416. this.dict = Object.create(null);
  20417. }
  20418. };
  20419. return RefSetCache;
  20420. }();
  20421. function isName(v, name) {
  20422. return v instanceof Name && (name === undefined || v.name === name);
  20423. }
  20424. function isCmd(v, cmd) {
  20425. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  20426. }
  20427. function isDict(v, type) {
  20428. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  20429. }
  20430. function isRef(v) {
  20431. return v instanceof Ref;
  20432. }
  20433. function isRefsEqual(v1, v2) {
  20434. return v1.num === v2.num && v1.gen === v2.gen;
  20435. }
  20436. function isStream(v) {
  20437. return typeof v === 'object' && v !== null && v.getBytes !== undefined;
  20438. }
  20439. exports.Cmd = Cmd;
  20440. exports.Dict = Dict;
  20441. exports.Name = Name;
  20442. exports.Ref = Ref;
  20443. exports.RefSet = RefSet;
  20444. exports.RefSetCache = RefSetCache;
  20445. exports.isCmd = isCmd;
  20446. exports.isDict = isDict;
  20447. exports.isName = isName;
  20448. exports.isRef = isRef;
  20449. exports.isRefsEqual = isRefsEqual;
  20450. exports.isStream = isStream;
  20451. }));
  20452. (function (root, factory) {
  20453. factory(root.pdfjsCoreStandardFonts = {}, root.pdfjsSharedUtil);
  20454. }(this, function (exports, sharedUtil) {
  20455. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  20456. var getStdFontMap = getLookupTableFactory(function (t) {
  20457. t['ArialNarrow'] = 'Helvetica';
  20458. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  20459. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  20460. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  20461. t['ArialBlack'] = 'Helvetica';
  20462. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  20463. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  20464. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  20465. t['Arial-Black'] = 'Helvetica';
  20466. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  20467. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  20468. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  20469. t['Arial'] = 'Helvetica';
  20470. t['Arial-Bold'] = 'Helvetica-Bold';
  20471. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  20472. t['Arial-Italic'] = 'Helvetica-Oblique';
  20473. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  20474. t['Arial-BoldMT'] = 'Helvetica-Bold';
  20475. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  20476. t['ArialMT'] = 'Helvetica';
  20477. t['Courier-Bold'] = 'Courier-Bold';
  20478. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  20479. t['Courier-Italic'] = 'Courier-Oblique';
  20480. t['CourierNew'] = 'Courier';
  20481. t['CourierNew-Bold'] = 'Courier-Bold';
  20482. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  20483. t['CourierNew-Italic'] = 'Courier-Oblique';
  20484. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  20485. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  20486. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  20487. t['CourierNewPSMT'] = 'Courier';
  20488. t['Helvetica'] = 'Helvetica';
  20489. t['Helvetica-Bold'] = 'Helvetica-Bold';
  20490. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  20491. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  20492. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  20493. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  20494. t['Symbol-Bold'] = 'Symbol';
  20495. t['Symbol-BoldItalic'] = 'Symbol';
  20496. t['Symbol-Italic'] = 'Symbol';
  20497. t['TimesNewRoman'] = 'Times-Roman';
  20498. t['TimesNewRoman-Bold'] = 'Times-Bold';
  20499. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  20500. t['TimesNewRoman-Italic'] = 'Times-Italic';
  20501. t['TimesNewRomanPS'] = 'Times-Roman';
  20502. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  20503. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  20504. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  20505. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  20506. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  20507. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  20508. t['TimesNewRomanPSMT'] = 'Times-Roman';
  20509. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  20510. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  20511. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  20512. });
  20513. var getNonStdFontMap = getLookupTableFactory(function (t) {
  20514. t['CenturyGothic'] = 'Helvetica';
  20515. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  20516. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  20517. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  20518. t['ComicSansMS'] = 'Comic Sans MS';
  20519. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  20520. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  20521. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  20522. t['LucidaConsole'] = 'Courier';
  20523. t['LucidaConsole-Bold'] = 'Courier-Bold';
  20524. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  20525. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  20526. t['MS-Gothic'] = 'MS Gothic';
  20527. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  20528. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  20529. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  20530. t['MS-Mincho'] = 'MS Mincho';
  20531. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  20532. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  20533. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  20534. t['MS-PGothic'] = 'MS PGothic';
  20535. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  20536. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  20537. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  20538. t['MS-PMincho'] = 'MS PMincho';
  20539. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  20540. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  20541. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  20542. t['NuptialScript'] = 'Times-Italic';
  20543. t['Wingdings'] = 'ZapfDingbats';
  20544. });
  20545. var getSerifFonts = getLookupTableFactory(function (t) {
  20546. t['Adobe Jenson'] = true;
  20547. t['Adobe Text'] = true;
  20548. t['Albertus'] = true;
  20549. t['Aldus'] = true;
  20550. t['Alexandria'] = true;
  20551. t['Algerian'] = true;
  20552. t['American Typewriter'] = true;
  20553. t['Antiqua'] = true;
  20554. t['Apex'] = true;
  20555. t['Arno'] = true;
  20556. t['Aster'] = true;
  20557. t['Aurora'] = true;
  20558. t['Baskerville'] = true;
  20559. t['Bell'] = true;
  20560. t['Bembo'] = true;
  20561. t['Bembo Schoolbook'] = true;
  20562. t['Benguiat'] = true;
  20563. t['Berkeley Old Style'] = true;
  20564. t['Bernhard Modern'] = true;
  20565. t['Berthold City'] = true;
  20566. t['Bodoni'] = true;
  20567. t['Bauer Bodoni'] = true;
  20568. t['Book Antiqua'] = true;
  20569. t['Bookman'] = true;
  20570. t['Bordeaux Roman'] = true;
  20571. t['Californian FB'] = true;
  20572. t['Calisto'] = true;
  20573. t['Calvert'] = true;
  20574. t['Capitals'] = true;
  20575. t['Cambria'] = true;
  20576. t['Cartier'] = true;
  20577. t['Caslon'] = true;
  20578. t['Catull'] = true;
  20579. t['Centaur'] = true;
  20580. t['Century Old Style'] = true;
  20581. t['Century Schoolbook'] = true;
  20582. t['Chaparral'] = true;
  20583. t['Charis SIL'] = true;
  20584. t['Cheltenham'] = true;
  20585. t['Cholla Slab'] = true;
  20586. t['Clarendon'] = true;
  20587. t['Clearface'] = true;
  20588. t['Cochin'] = true;
  20589. t['Colonna'] = true;
  20590. t['Computer Modern'] = true;
  20591. t['Concrete Roman'] = true;
  20592. t['Constantia'] = true;
  20593. t['Cooper Black'] = true;
  20594. t['Corona'] = true;
  20595. t['Ecotype'] = true;
  20596. t['Egyptienne'] = true;
  20597. t['Elephant'] = true;
  20598. t['Excelsior'] = true;
  20599. t['Fairfield'] = true;
  20600. t['FF Scala'] = true;
  20601. t['Folkard'] = true;
  20602. t['Footlight'] = true;
  20603. t['FreeSerif'] = true;
  20604. t['Friz Quadrata'] = true;
  20605. t['Garamond'] = true;
  20606. t['Gentium'] = true;
  20607. t['Georgia'] = true;
  20608. t['Gloucester'] = true;
  20609. t['Goudy Old Style'] = true;
  20610. t['Goudy Schoolbook'] = true;
  20611. t['Goudy Pro Font'] = true;
  20612. t['Granjon'] = true;
  20613. t['Guardian Egyptian'] = true;
  20614. t['Heather'] = true;
  20615. t['Hercules'] = true;
  20616. t['High Tower Text'] = true;
  20617. t['Hiroshige'] = true;
  20618. t['Hoefler Text'] = true;
  20619. t['Humana Serif'] = true;
  20620. t['Imprint'] = true;
  20621. t['Ionic No. 5'] = true;
  20622. t['Janson'] = true;
  20623. t['Joanna'] = true;
  20624. t['Korinna'] = true;
  20625. t['Lexicon'] = true;
  20626. t['Liberation Serif'] = true;
  20627. t['Linux Libertine'] = true;
  20628. t['Literaturnaya'] = true;
  20629. t['Lucida'] = true;
  20630. t['Lucida Bright'] = true;
  20631. t['Melior'] = true;
  20632. t['Memphis'] = true;
  20633. t['Miller'] = true;
  20634. t['Minion'] = true;
  20635. t['Modern'] = true;
  20636. t['Mona Lisa'] = true;
  20637. t['Mrs Eaves'] = true;
  20638. t['MS Serif'] = true;
  20639. t['Museo Slab'] = true;
  20640. t['New York'] = true;
  20641. t['Nimbus Roman'] = true;
  20642. t['NPS Rawlinson Roadway'] = true;
  20643. t['NuptialScript'] = true;
  20644. t['Palatino'] = true;
  20645. t['Perpetua'] = true;
  20646. t['Plantin'] = true;
  20647. t['Plantin Schoolbook'] = true;
  20648. t['Playbill'] = true;
  20649. t['Poor Richard'] = true;
  20650. t['Rawlinson Roadway'] = true;
  20651. t['Renault'] = true;
  20652. t['Requiem'] = true;
  20653. t['Rockwell'] = true;
  20654. t['Roman'] = true;
  20655. t['Rotis Serif'] = true;
  20656. t['Sabon'] = true;
  20657. t['Scala'] = true;
  20658. t['Seagull'] = true;
  20659. t['Sistina'] = true;
  20660. t['Souvenir'] = true;
  20661. t['STIX'] = true;
  20662. t['Stone Informal'] = true;
  20663. t['Stone Serif'] = true;
  20664. t['Sylfaen'] = true;
  20665. t['Times'] = true;
  20666. t['Trajan'] = true;
  20667. t['Trinité'] = true;
  20668. t['Trump Mediaeval'] = true;
  20669. t['Utopia'] = true;
  20670. t['Vale Type'] = true;
  20671. t['Bitstream Vera'] = true;
  20672. t['Vera Serif'] = true;
  20673. t['Versailles'] = true;
  20674. t['Wanted'] = true;
  20675. t['Weiss'] = true;
  20676. t['Wide Latin'] = true;
  20677. t['Windsor'] = true;
  20678. t['XITS'] = true;
  20679. });
  20680. var getSymbolsFonts = getLookupTableFactory(function (t) {
  20681. t['Dingbats'] = true;
  20682. t['Symbol'] = true;
  20683. t['ZapfDingbats'] = true;
  20684. });
  20685. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  20686. t[2] = 10;
  20687. t[3] = 32;
  20688. t[4] = 33;
  20689. t[5] = 34;
  20690. t[6] = 35;
  20691. t[7] = 36;
  20692. t[8] = 37;
  20693. t[9] = 38;
  20694. t[10] = 39;
  20695. t[11] = 40;
  20696. t[12] = 41;
  20697. t[13] = 42;
  20698. t[14] = 43;
  20699. t[15] = 44;
  20700. t[16] = 45;
  20701. t[17] = 46;
  20702. t[18] = 47;
  20703. t[19] = 48;
  20704. t[20] = 49;
  20705. t[21] = 50;
  20706. t[22] = 51;
  20707. t[23] = 52;
  20708. t[24] = 53;
  20709. t[25] = 54;
  20710. t[26] = 55;
  20711. t[27] = 56;
  20712. t[28] = 57;
  20713. t[29] = 58;
  20714. t[30] = 894;
  20715. t[31] = 60;
  20716. t[32] = 61;
  20717. t[33] = 62;
  20718. t[34] = 63;
  20719. t[35] = 64;
  20720. t[36] = 65;
  20721. t[37] = 66;
  20722. t[38] = 67;
  20723. t[39] = 68;
  20724. t[40] = 69;
  20725. t[41] = 70;
  20726. t[42] = 71;
  20727. t[43] = 72;
  20728. t[44] = 73;
  20729. t[45] = 74;
  20730. t[46] = 75;
  20731. t[47] = 76;
  20732. t[48] = 77;
  20733. t[49] = 78;
  20734. t[50] = 79;
  20735. t[51] = 80;
  20736. t[52] = 81;
  20737. t[53] = 82;
  20738. t[54] = 83;
  20739. t[55] = 84;
  20740. t[56] = 85;
  20741. t[57] = 86;
  20742. t[58] = 87;
  20743. t[59] = 88;
  20744. t[60] = 89;
  20745. t[61] = 90;
  20746. t[62] = 91;
  20747. t[63] = 92;
  20748. t[64] = 93;
  20749. t[65] = 94;
  20750. t[66] = 95;
  20751. t[67] = 96;
  20752. t[68] = 97;
  20753. t[69] = 98;
  20754. t[70] = 99;
  20755. t[71] = 100;
  20756. t[72] = 101;
  20757. t[73] = 102;
  20758. t[74] = 103;
  20759. t[75] = 104;
  20760. t[76] = 105;
  20761. t[77] = 106;
  20762. t[78] = 107;
  20763. t[79] = 108;
  20764. t[80] = 109;
  20765. t[81] = 110;
  20766. t[82] = 111;
  20767. t[83] = 112;
  20768. t[84] = 113;
  20769. t[85] = 114;
  20770. t[86] = 115;
  20771. t[87] = 116;
  20772. t[88] = 117;
  20773. t[89] = 118;
  20774. t[90] = 119;
  20775. t[91] = 120;
  20776. t[92] = 121;
  20777. t[93] = 122;
  20778. t[94] = 123;
  20779. t[95] = 124;
  20780. t[96] = 125;
  20781. t[97] = 126;
  20782. t[98] = 196;
  20783. t[99] = 197;
  20784. t[100] = 199;
  20785. t[101] = 201;
  20786. t[102] = 209;
  20787. t[103] = 214;
  20788. t[104] = 220;
  20789. t[105] = 225;
  20790. t[106] = 224;
  20791. t[107] = 226;
  20792. t[108] = 228;
  20793. t[109] = 227;
  20794. t[110] = 229;
  20795. t[111] = 231;
  20796. t[112] = 233;
  20797. t[113] = 232;
  20798. t[114] = 234;
  20799. t[115] = 235;
  20800. t[116] = 237;
  20801. t[117] = 236;
  20802. t[118] = 238;
  20803. t[119] = 239;
  20804. t[120] = 241;
  20805. t[121] = 243;
  20806. t[122] = 242;
  20807. t[123] = 244;
  20808. t[124] = 246;
  20809. t[125] = 245;
  20810. t[126] = 250;
  20811. t[127] = 249;
  20812. t[128] = 251;
  20813. t[129] = 252;
  20814. t[130] = 8224;
  20815. t[131] = 176;
  20816. t[132] = 162;
  20817. t[133] = 163;
  20818. t[134] = 167;
  20819. t[135] = 8226;
  20820. t[136] = 182;
  20821. t[137] = 223;
  20822. t[138] = 174;
  20823. t[139] = 169;
  20824. t[140] = 8482;
  20825. t[141] = 180;
  20826. t[142] = 168;
  20827. t[143] = 8800;
  20828. t[144] = 198;
  20829. t[145] = 216;
  20830. t[146] = 8734;
  20831. t[147] = 177;
  20832. t[148] = 8804;
  20833. t[149] = 8805;
  20834. t[150] = 165;
  20835. t[151] = 181;
  20836. t[152] = 8706;
  20837. t[153] = 8721;
  20838. t[154] = 8719;
  20839. t[156] = 8747;
  20840. t[157] = 170;
  20841. t[158] = 186;
  20842. t[159] = 8486;
  20843. t[160] = 230;
  20844. t[161] = 248;
  20845. t[162] = 191;
  20846. t[163] = 161;
  20847. t[164] = 172;
  20848. t[165] = 8730;
  20849. t[166] = 402;
  20850. t[167] = 8776;
  20851. t[168] = 8710;
  20852. t[169] = 171;
  20853. t[170] = 187;
  20854. t[171] = 8230;
  20855. t[210] = 218;
  20856. t[223] = 711;
  20857. t[224] = 321;
  20858. t[225] = 322;
  20859. t[227] = 353;
  20860. t[229] = 382;
  20861. t[234] = 253;
  20862. t[252] = 263;
  20863. t[253] = 268;
  20864. t[254] = 269;
  20865. t[258] = 258;
  20866. t[260] = 260;
  20867. t[261] = 261;
  20868. t[265] = 280;
  20869. t[266] = 281;
  20870. t[268] = 283;
  20871. t[269] = 313;
  20872. t[275] = 323;
  20873. t[276] = 324;
  20874. t[278] = 328;
  20875. t[284] = 345;
  20876. t[285] = 346;
  20877. t[286] = 347;
  20878. t[292] = 367;
  20879. t[295] = 377;
  20880. t[296] = 378;
  20881. t[298] = 380;
  20882. t[305] = 963;
  20883. t[306] = 964;
  20884. t[307] = 966;
  20885. t[308] = 8215;
  20886. t[309] = 8252;
  20887. t[310] = 8319;
  20888. t[311] = 8359;
  20889. t[312] = 8592;
  20890. t[313] = 8593;
  20891. t[337] = 9552;
  20892. t[493] = 1039;
  20893. t[494] = 1040;
  20894. t[705] = 1524;
  20895. t[706] = 8362;
  20896. t[710] = 64288;
  20897. t[711] = 64298;
  20898. t[759] = 1617;
  20899. t[761] = 1776;
  20900. t[763] = 1778;
  20901. t[775] = 1652;
  20902. t[777] = 1764;
  20903. t[778] = 1780;
  20904. t[779] = 1781;
  20905. t[780] = 1782;
  20906. t[782] = 771;
  20907. t[783] = 64726;
  20908. t[786] = 8363;
  20909. t[788] = 8532;
  20910. t[790] = 768;
  20911. t[791] = 769;
  20912. t[792] = 768;
  20913. t[795] = 803;
  20914. t[797] = 64336;
  20915. t[798] = 64337;
  20916. t[799] = 64342;
  20917. t[800] = 64343;
  20918. t[801] = 64344;
  20919. t[802] = 64345;
  20920. t[803] = 64362;
  20921. t[804] = 64363;
  20922. t[805] = 64364;
  20923. t[2424] = 7821;
  20924. t[2425] = 7822;
  20925. t[2426] = 7823;
  20926. t[2427] = 7824;
  20927. t[2428] = 7825;
  20928. t[2429] = 7826;
  20929. t[2430] = 7827;
  20930. t[2433] = 7682;
  20931. t[2678] = 8045;
  20932. t[2679] = 8046;
  20933. t[2830] = 1552;
  20934. t[2838] = 686;
  20935. t[2840] = 751;
  20936. t[2842] = 753;
  20937. t[2843] = 754;
  20938. t[2844] = 755;
  20939. t[2846] = 757;
  20940. t[2856] = 767;
  20941. t[2857] = 848;
  20942. t[2858] = 849;
  20943. t[2862] = 853;
  20944. t[2863] = 854;
  20945. t[2864] = 855;
  20946. t[2865] = 861;
  20947. t[2866] = 862;
  20948. t[2906] = 7460;
  20949. t[2908] = 7462;
  20950. t[2909] = 7463;
  20951. t[2910] = 7464;
  20952. t[2912] = 7466;
  20953. t[2913] = 7467;
  20954. t[2914] = 7468;
  20955. t[2916] = 7470;
  20956. t[2917] = 7471;
  20957. t[2918] = 7472;
  20958. t[2920] = 7474;
  20959. t[2921] = 7475;
  20960. t[2922] = 7476;
  20961. t[2924] = 7478;
  20962. t[2925] = 7479;
  20963. t[2926] = 7480;
  20964. t[2928] = 7482;
  20965. t[2929] = 7483;
  20966. t[2930] = 7484;
  20967. t[2932] = 7486;
  20968. t[2933] = 7487;
  20969. t[2934] = 7488;
  20970. t[2936] = 7490;
  20971. t[2937] = 7491;
  20972. t[2938] = 7492;
  20973. t[2940] = 7494;
  20974. t[2941] = 7495;
  20975. t[2942] = 7496;
  20976. t[2944] = 7498;
  20977. t[2946] = 7500;
  20978. t[2948] = 7502;
  20979. t[2950] = 7504;
  20980. t[2951] = 7505;
  20981. t[2952] = 7506;
  20982. t[2954] = 7508;
  20983. t[2955] = 7509;
  20984. t[2956] = 7510;
  20985. t[2958] = 7512;
  20986. t[2959] = 7513;
  20987. t[2960] = 7514;
  20988. t[2962] = 7516;
  20989. t[2963] = 7517;
  20990. t[2964] = 7518;
  20991. t[2966] = 7520;
  20992. t[2967] = 7521;
  20993. t[2968] = 7522;
  20994. t[2970] = 7524;
  20995. t[2971] = 7525;
  20996. t[2972] = 7526;
  20997. t[2974] = 7528;
  20998. t[2975] = 7529;
  20999. t[2976] = 7530;
  21000. t[2978] = 1537;
  21001. t[2979] = 1538;
  21002. t[2980] = 1539;
  21003. t[2982] = 1549;
  21004. t[2983] = 1551;
  21005. t[2984] = 1552;
  21006. t[2986] = 1554;
  21007. t[2987] = 1555;
  21008. t[2988] = 1556;
  21009. t[2990] = 1623;
  21010. t[2991] = 1624;
  21011. t[2995] = 1775;
  21012. t[2999] = 1791;
  21013. t[3002] = 64290;
  21014. t[3003] = 64291;
  21015. t[3004] = 64292;
  21016. t[3006] = 64294;
  21017. t[3007] = 64295;
  21018. t[3008] = 64296;
  21019. t[3011] = 1900;
  21020. t[3014] = 8223;
  21021. t[3015] = 8244;
  21022. t[3017] = 7532;
  21023. t[3018] = 7533;
  21024. t[3019] = 7534;
  21025. t[3075] = 7590;
  21026. t[3076] = 7591;
  21027. t[3079] = 7594;
  21028. t[3080] = 7595;
  21029. t[3083] = 7598;
  21030. t[3084] = 7599;
  21031. t[3087] = 7602;
  21032. t[3088] = 7603;
  21033. t[3091] = 7606;
  21034. t[3092] = 7607;
  21035. t[3095] = 7610;
  21036. t[3096] = 7611;
  21037. t[3099] = 7614;
  21038. t[3100] = 7615;
  21039. t[3103] = 7618;
  21040. t[3104] = 7619;
  21041. t[3107] = 8337;
  21042. t[3108] = 8338;
  21043. t[3116] = 1884;
  21044. t[3119] = 1885;
  21045. t[3120] = 1885;
  21046. t[3123] = 1886;
  21047. t[3124] = 1886;
  21048. t[3127] = 1887;
  21049. t[3128] = 1887;
  21050. t[3131] = 1888;
  21051. t[3132] = 1888;
  21052. t[3135] = 1889;
  21053. t[3136] = 1889;
  21054. t[3139] = 1890;
  21055. t[3140] = 1890;
  21056. t[3143] = 1891;
  21057. t[3144] = 1891;
  21058. t[3147] = 1892;
  21059. t[3148] = 1892;
  21060. t[3153] = 580;
  21061. t[3154] = 581;
  21062. t[3157] = 584;
  21063. t[3158] = 585;
  21064. t[3161] = 588;
  21065. t[3162] = 589;
  21066. t[3165] = 891;
  21067. t[3166] = 892;
  21068. t[3169] = 1274;
  21069. t[3170] = 1275;
  21070. t[3173] = 1278;
  21071. t[3174] = 1279;
  21072. t[3181] = 7622;
  21073. t[3182] = 7623;
  21074. t[3282] = 11799;
  21075. t[3316] = 578;
  21076. t[3379] = 42785;
  21077. t[3393] = 1159;
  21078. t[3416] = 8377;
  21079. });
  21080. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  21081. t[227] = 322;
  21082. t[264] = 261;
  21083. t[291] = 346;
  21084. });
  21085. exports.getStdFontMap = getStdFontMap;
  21086. exports.getNonStdFontMap = getNonStdFontMap;
  21087. exports.getSerifFonts = getSerifFonts;
  21088. exports.getSymbolsFonts = getSymbolsFonts;
  21089. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  21090. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  21091. }));
  21092. (function (root, factory) {
  21093. factory(root.pdfjsCoreUnicode = {}, root.pdfjsSharedUtil);
  21094. }(this, function (exports, sharedUtil) {
  21095. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  21096. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  21097. t[63721] = 0x00A9;
  21098. t[63193] = 0x00A9;
  21099. t[63720] = 0x00AE;
  21100. t[63194] = 0x00AE;
  21101. t[63722] = 0x2122;
  21102. t[63195] = 0x2122;
  21103. t[63729] = 0x23A7;
  21104. t[63730] = 0x23A8;
  21105. t[63731] = 0x23A9;
  21106. t[63740] = 0x23AB;
  21107. t[63741] = 0x23AC;
  21108. t[63742] = 0x23AD;
  21109. t[63726] = 0x23A1;
  21110. t[63727] = 0x23A2;
  21111. t[63728] = 0x23A3;
  21112. t[63737] = 0x23A4;
  21113. t[63738] = 0x23A5;
  21114. t[63739] = 0x23A6;
  21115. t[63723] = 0x239B;
  21116. t[63724] = 0x239C;
  21117. t[63725] = 0x239D;
  21118. t[63734] = 0x239E;
  21119. t[63735] = 0x239F;
  21120. t[63736] = 0x23A0;
  21121. });
  21122. function mapSpecialUnicodeValues(code) {
  21123. if (code >= 0xFFF0 && code <= 0xFFFF) {
  21124. return 0;
  21125. } else if (code >= 0xF600 && code <= 0xF8FF) {
  21126. return getSpecialPUASymbols()[code] || code;
  21127. }
  21128. return code;
  21129. }
  21130. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  21131. var unicode = glyphsUnicodeMap[name];
  21132. if (unicode !== undefined) {
  21133. return unicode;
  21134. }
  21135. if (!name) {
  21136. return -1;
  21137. }
  21138. if (name[0] === 'u') {
  21139. var nameLen = name.length, hexStr;
  21140. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  21141. hexStr = name.substr(3);
  21142. } else if (nameLen >= 5 && nameLen <= 7) {
  21143. hexStr = name.substr(1);
  21144. } else {
  21145. return -1;
  21146. }
  21147. if (hexStr === hexStr.toUpperCase()) {
  21148. unicode = parseInt(hexStr, 16);
  21149. if (unicode >= 0) {
  21150. return unicode;
  21151. }
  21152. }
  21153. }
  21154. return -1;
  21155. }
  21156. var UnicodeRanges = [
  21157. {
  21158. 'begin': 0x0000,
  21159. 'end': 0x007F
  21160. },
  21161. {
  21162. 'begin': 0x0080,
  21163. 'end': 0x00FF
  21164. },
  21165. {
  21166. 'begin': 0x0100,
  21167. 'end': 0x017F
  21168. },
  21169. {
  21170. 'begin': 0x0180,
  21171. 'end': 0x024F
  21172. },
  21173. {
  21174. 'begin': 0x0250,
  21175. 'end': 0x02AF
  21176. },
  21177. {
  21178. 'begin': 0x02B0,
  21179. 'end': 0x02FF
  21180. },
  21181. {
  21182. 'begin': 0x0300,
  21183. 'end': 0x036F
  21184. },
  21185. {
  21186. 'begin': 0x0370,
  21187. 'end': 0x03FF
  21188. },
  21189. {
  21190. 'begin': 0x2C80,
  21191. 'end': 0x2CFF
  21192. },
  21193. {
  21194. 'begin': 0x0400,
  21195. 'end': 0x04FF
  21196. },
  21197. {
  21198. 'begin': 0x0530,
  21199. 'end': 0x058F
  21200. },
  21201. {
  21202. 'begin': 0x0590,
  21203. 'end': 0x05FF
  21204. },
  21205. {
  21206. 'begin': 0xA500,
  21207. 'end': 0xA63F
  21208. },
  21209. {
  21210. 'begin': 0x0600,
  21211. 'end': 0x06FF
  21212. },
  21213. {
  21214. 'begin': 0x07C0,
  21215. 'end': 0x07FF
  21216. },
  21217. {
  21218. 'begin': 0x0900,
  21219. 'end': 0x097F
  21220. },
  21221. {
  21222. 'begin': 0x0980,
  21223. 'end': 0x09FF
  21224. },
  21225. {
  21226. 'begin': 0x0A00,
  21227. 'end': 0x0A7F
  21228. },
  21229. {
  21230. 'begin': 0x0A80,
  21231. 'end': 0x0AFF
  21232. },
  21233. {
  21234. 'begin': 0x0B00,
  21235. 'end': 0x0B7F
  21236. },
  21237. {
  21238. 'begin': 0x0B80,
  21239. 'end': 0x0BFF
  21240. },
  21241. {
  21242. 'begin': 0x0C00,
  21243. 'end': 0x0C7F
  21244. },
  21245. {
  21246. 'begin': 0x0C80,
  21247. 'end': 0x0CFF
  21248. },
  21249. {
  21250. 'begin': 0x0D00,
  21251. 'end': 0x0D7F
  21252. },
  21253. {
  21254. 'begin': 0x0E00,
  21255. 'end': 0x0E7F
  21256. },
  21257. {
  21258. 'begin': 0x0E80,
  21259. 'end': 0x0EFF
  21260. },
  21261. {
  21262. 'begin': 0x10A0,
  21263. 'end': 0x10FF
  21264. },
  21265. {
  21266. 'begin': 0x1B00,
  21267. 'end': 0x1B7F
  21268. },
  21269. {
  21270. 'begin': 0x1100,
  21271. 'end': 0x11FF
  21272. },
  21273. {
  21274. 'begin': 0x1E00,
  21275. 'end': 0x1EFF
  21276. },
  21277. {
  21278. 'begin': 0x1F00,
  21279. 'end': 0x1FFF
  21280. },
  21281. {
  21282. 'begin': 0x2000,
  21283. 'end': 0x206F
  21284. },
  21285. {
  21286. 'begin': 0x2070,
  21287. 'end': 0x209F
  21288. },
  21289. {
  21290. 'begin': 0x20A0,
  21291. 'end': 0x20CF
  21292. },
  21293. {
  21294. 'begin': 0x20D0,
  21295. 'end': 0x20FF
  21296. },
  21297. {
  21298. 'begin': 0x2100,
  21299. 'end': 0x214F
  21300. },
  21301. {
  21302. 'begin': 0x2150,
  21303. 'end': 0x218F
  21304. },
  21305. {
  21306. 'begin': 0x2190,
  21307. 'end': 0x21FF
  21308. },
  21309. {
  21310. 'begin': 0x2200,
  21311. 'end': 0x22FF
  21312. },
  21313. {
  21314. 'begin': 0x2300,
  21315. 'end': 0x23FF
  21316. },
  21317. {
  21318. 'begin': 0x2400,
  21319. 'end': 0x243F
  21320. },
  21321. {
  21322. 'begin': 0x2440,
  21323. 'end': 0x245F
  21324. },
  21325. {
  21326. 'begin': 0x2460,
  21327. 'end': 0x24FF
  21328. },
  21329. {
  21330. 'begin': 0x2500,
  21331. 'end': 0x257F
  21332. },
  21333. {
  21334. 'begin': 0x2580,
  21335. 'end': 0x259F
  21336. },
  21337. {
  21338. 'begin': 0x25A0,
  21339. 'end': 0x25FF
  21340. },
  21341. {
  21342. 'begin': 0x2600,
  21343. 'end': 0x26FF
  21344. },
  21345. {
  21346. 'begin': 0x2700,
  21347. 'end': 0x27BF
  21348. },
  21349. {
  21350. 'begin': 0x3000,
  21351. 'end': 0x303F
  21352. },
  21353. {
  21354. 'begin': 0x3040,
  21355. 'end': 0x309F
  21356. },
  21357. {
  21358. 'begin': 0x30A0,
  21359. 'end': 0x30FF
  21360. },
  21361. {
  21362. 'begin': 0x3100,
  21363. 'end': 0x312F
  21364. },
  21365. {
  21366. 'begin': 0x3130,
  21367. 'end': 0x318F
  21368. },
  21369. {
  21370. 'begin': 0xA840,
  21371. 'end': 0xA87F
  21372. },
  21373. {
  21374. 'begin': 0x3200,
  21375. 'end': 0x32FF
  21376. },
  21377. {
  21378. 'begin': 0x3300,
  21379. 'end': 0x33FF
  21380. },
  21381. {
  21382. 'begin': 0xAC00,
  21383. 'end': 0xD7AF
  21384. },
  21385. {
  21386. 'begin': 0xD800,
  21387. 'end': 0xDFFF
  21388. },
  21389. {
  21390. 'begin': 0x10900,
  21391. 'end': 0x1091F
  21392. },
  21393. {
  21394. 'begin': 0x4E00,
  21395. 'end': 0x9FFF
  21396. },
  21397. {
  21398. 'begin': 0xE000,
  21399. 'end': 0xF8FF
  21400. },
  21401. {
  21402. 'begin': 0x31C0,
  21403. 'end': 0x31EF
  21404. },
  21405. {
  21406. 'begin': 0xFB00,
  21407. 'end': 0xFB4F
  21408. },
  21409. {
  21410. 'begin': 0xFB50,
  21411. 'end': 0xFDFF
  21412. },
  21413. {
  21414. 'begin': 0xFE20,
  21415. 'end': 0xFE2F
  21416. },
  21417. {
  21418. 'begin': 0xFE10,
  21419. 'end': 0xFE1F
  21420. },
  21421. {
  21422. 'begin': 0xFE50,
  21423. 'end': 0xFE6F
  21424. },
  21425. {
  21426. 'begin': 0xFE70,
  21427. 'end': 0xFEFF
  21428. },
  21429. {
  21430. 'begin': 0xFF00,
  21431. 'end': 0xFFEF
  21432. },
  21433. {
  21434. 'begin': 0xFFF0,
  21435. 'end': 0xFFFF
  21436. },
  21437. {
  21438. 'begin': 0x0F00,
  21439. 'end': 0x0FFF
  21440. },
  21441. {
  21442. 'begin': 0x0700,
  21443. 'end': 0x074F
  21444. },
  21445. {
  21446. 'begin': 0x0780,
  21447. 'end': 0x07BF
  21448. },
  21449. {
  21450. 'begin': 0x0D80,
  21451. 'end': 0x0DFF
  21452. },
  21453. {
  21454. 'begin': 0x1000,
  21455. 'end': 0x109F
  21456. },
  21457. {
  21458. 'begin': 0x1200,
  21459. 'end': 0x137F
  21460. },
  21461. {
  21462. 'begin': 0x13A0,
  21463. 'end': 0x13FF
  21464. },
  21465. {
  21466. 'begin': 0x1400,
  21467. 'end': 0x167F
  21468. },
  21469. {
  21470. 'begin': 0x1680,
  21471. 'end': 0x169F
  21472. },
  21473. {
  21474. 'begin': 0x16A0,
  21475. 'end': 0x16FF
  21476. },
  21477. {
  21478. 'begin': 0x1780,
  21479. 'end': 0x17FF
  21480. },
  21481. {
  21482. 'begin': 0x1800,
  21483. 'end': 0x18AF
  21484. },
  21485. {
  21486. 'begin': 0x2800,
  21487. 'end': 0x28FF
  21488. },
  21489. {
  21490. 'begin': 0xA000,
  21491. 'end': 0xA48F
  21492. },
  21493. {
  21494. 'begin': 0x1700,
  21495. 'end': 0x171F
  21496. },
  21497. {
  21498. 'begin': 0x10300,
  21499. 'end': 0x1032F
  21500. },
  21501. {
  21502. 'begin': 0x10330,
  21503. 'end': 0x1034F
  21504. },
  21505. {
  21506. 'begin': 0x10400,
  21507. 'end': 0x1044F
  21508. },
  21509. {
  21510. 'begin': 0x1D000,
  21511. 'end': 0x1D0FF
  21512. },
  21513. {
  21514. 'begin': 0x1D400,
  21515. 'end': 0x1D7FF
  21516. },
  21517. {
  21518. 'begin': 0xFF000,
  21519. 'end': 0xFFFFD
  21520. },
  21521. {
  21522. 'begin': 0xFE00,
  21523. 'end': 0xFE0F
  21524. },
  21525. {
  21526. 'begin': 0xE0000,
  21527. 'end': 0xE007F
  21528. },
  21529. {
  21530. 'begin': 0x1900,
  21531. 'end': 0x194F
  21532. },
  21533. {
  21534. 'begin': 0x1950,
  21535. 'end': 0x197F
  21536. },
  21537. {
  21538. 'begin': 0x1980,
  21539. 'end': 0x19DF
  21540. },
  21541. {
  21542. 'begin': 0x1A00,
  21543. 'end': 0x1A1F
  21544. },
  21545. {
  21546. 'begin': 0x2C00,
  21547. 'end': 0x2C5F
  21548. },
  21549. {
  21550. 'begin': 0x2D30,
  21551. 'end': 0x2D7F
  21552. },
  21553. {
  21554. 'begin': 0x4DC0,
  21555. 'end': 0x4DFF
  21556. },
  21557. {
  21558. 'begin': 0xA800,
  21559. 'end': 0xA82F
  21560. },
  21561. {
  21562. 'begin': 0x10000,
  21563. 'end': 0x1007F
  21564. },
  21565. {
  21566. 'begin': 0x10140,
  21567. 'end': 0x1018F
  21568. },
  21569. {
  21570. 'begin': 0x10380,
  21571. 'end': 0x1039F
  21572. },
  21573. {
  21574. 'begin': 0x103A0,
  21575. 'end': 0x103DF
  21576. },
  21577. {
  21578. 'begin': 0x10450,
  21579. 'end': 0x1047F
  21580. },
  21581. {
  21582. 'begin': 0x10480,
  21583. 'end': 0x104AF
  21584. },
  21585. {
  21586. 'begin': 0x10800,
  21587. 'end': 0x1083F
  21588. },
  21589. {
  21590. 'begin': 0x10A00,
  21591. 'end': 0x10A5F
  21592. },
  21593. {
  21594. 'begin': 0x1D300,
  21595. 'end': 0x1D35F
  21596. },
  21597. {
  21598. 'begin': 0x12000,
  21599. 'end': 0x123FF
  21600. },
  21601. {
  21602. 'begin': 0x1D360,
  21603. 'end': 0x1D37F
  21604. },
  21605. {
  21606. 'begin': 0x1B80,
  21607. 'end': 0x1BBF
  21608. },
  21609. {
  21610. 'begin': 0x1C00,
  21611. 'end': 0x1C4F
  21612. },
  21613. {
  21614. 'begin': 0x1C50,
  21615. 'end': 0x1C7F
  21616. },
  21617. {
  21618. 'begin': 0xA880,
  21619. 'end': 0xA8DF
  21620. },
  21621. {
  21622. 'begin': 0xA900,
  21623. 'end': 0xA92F
  21624. },
  21625. {
  21626. 'begin': 0xA930,
  21627. 'end': 0xA95F
  21628. },
  21629. {
  21630. 'begin': 0xAA00,
  21631. 'end': 0xAA5F
  21632. },
  21633. {
  21634. 'begin': 0x10190,
  21635. 'end': 0x101CF
  21636. },
  21637. {
  21638. 'begin': 0x101D0,
  21639. 'end': 0x101FF
  21640. },
  21641. {
  21642. 'begin': 0x102A0,
  21643. 'end': 0x102DF
  21644. },
  21645. {
  21646. 'begin': 0x1F030,
  21647. 'end': 0x1F09F
  21648. }
  21649. ];
  21650. function getUnicodeRangeFor(value) {
  21651. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  21652. var range = UnicodeRanges[i];
  21653. if (value >= range.begin && value < range.end) {
  21654. return i;
  21655. }
  21656. }
  21657. return -1;
  21658. }
  21659. function isRTLRangeFor(value) {
  21660. var range = UnicodeRanges[13];
  21661. if (value >= range.begin && value < range.end) {
  21662. return true;
  21663. }
  21664. range = UnicodeRanges[11];
  21665. if (value >= range.begin && value < range.end) {
  21666. return true;
  21667. }
  21668. return false;
  21669. }
  21670. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  21671. t['\u00A8'] = '\u0020\u0308';
  21672. t['\u00AF'] = '\u0020\u0304';
  21673. t['\u00B4'] = '\u0020\u0301';
  21674. t['\u00B5'] = '\u03BC';
  21675. t['\u00B8'] = '\u0020\u0327';
  21676. t['\u0132'] = '\u0049\u004A';
  21677. t['\u0133'] = '\u0069\u006A';
  21678. t['\u013F'] = '\u004C\u00B7';
  21679. t['\u0140'] = '\u006C\u00B7';
  21680. t['\u0149'] = '\u02BC\u006E';
  21681. t['\u017F'] = '\u0073';
  21682. t['\u01C4'] = '\u0044\u017D';
  21683. t['\u01C5'] = '\u0044\u017E';
  21684. t['\u01C6'] = '\u0064\u017E';
  21685. t['\u01C7'] = '\u004C\u004A';
  21686. t['\u01C8'] = '\u004C\u006A';
  21687. t['\u01C9'] = '\u006C\u006A';
  21688. t['\u01CA'] = '\u004E\u004A';
  21689. t['\u01CB'] = '\u004E\u006A';
  21690. t['\u01CC'] = '\u006E\u006A';
  21691. t['\u01F1'] = '\u0044\u005A';
  21692. t['\u01F2'] = '\u0044\u007A';
  21693. t['\u01F3'] = '\u0064\u007A';
  21694. t['\u02D8'] = '\u0020\u0306';
  21695. t['\u02D9'] = '\u0020\u0307';
  21696. t['\u02DA'] = '\u0020\u030A';
  21697. t['\u02DB'] = '\u0020\u0328';
  21698. t['\u02DC'] = '\u0020\u0303';
  21699. t['\u02DD'] = '\u0020\u030B';
  21700. t['\u037A'] = '\u0020\u0345';
  21701. t['\u0384'] = '\u0020\u0301';
  21702. t['\u03D0'] = '\u03B2';
  21703. t['\u03D1'] = '\u03B8';
  21704. t['\u03D2'] = '\u03A5';
  21705. t['\u03D5'] = '\u03C6';
  21706. t['\u03D6'] = '\u03C0';
  21707. t['\u03F0'] = '\u03BA';
  21708. t['\u03F1'] = '\u03C1';
  21709. t['\u03F2'] = '\u03C2';
  21710. t['\u03F4'] = '\u0398';
  21711. t['\u03F5'] = '\u03B5';
  21712. t['\u03F9'] = '\u03A3';
  21713. t['\u0587'] = '\u0565\u0582';
  21714. t['\u0675'] = '\u0627\u0674';
  21715. t['\u0676'] = '\u0648\u0674';
  21716. t['\u0677'] = '\u06C7\u0674';
  21717. t['\u0678'] = '\u064A\u0674';
  21718. t['\u0E33'] = '\u0E4D\u0E32';
  21719. t['\u0EB3'] = '\u0ECD\u0EB2';
  21720. t['\u0EDC'] = '\u0EAB\u0E99';
  21721. t['\u0EDD'] = '\u0EAB\u0EA1';
  21722. t['\u0F77'] = '\u0FB2\u0F81';
  21723. t['\u0F79'] = '\u0FB3\u0F81';
  21724. t['\u1E9A'] = '\u0061\u02BE';
  21725. t['\u1FBD'] = '\u0020\u0313';
  21726. t['\u1FBF'] = '\u0020\u0313';
  21727. t['\u1FC0'] = '\u0020\u0342';
  21728. t['\u1FFE'] = '\u0020\u0314';
  21729. t['\u2002'] = '\u0020';
  21730. t['\u2003'] = '\u0020';
  21731. t['\u2004'] = '\u0020';
  21732. t['\u2005'] = '\u0020';
  21733. t['\u2006'] = '\u0020';
  21734. t['\u2008'] = '\u0020';
  21735. t['\u2009'] = '\u0020';
  21736. t['\u200A'] = '\u0020';
  21737. t['\u2017'] = '\u0020\u0333';
  21738. t['\u2024'] = '\u002E';
  21739. t['\u2025'] = '\u002E\u002E';
  21740. t['\u2026'] = '\u002E\u002E\u002E';
  21741. t['\u2033'] = '\u2032\u2032';
  21742. t['\u2034'] = '\u2032\u2032\u2032';
  21743. t['\u2036'] = '\u2035\u2035';
  21744. t['\u2037'] = '\u2035\u2035\u2035';
  21745. t['\u203C'] = '\u0021\u0021';
  21746. t['\u203E'] = '\u0020\u0305';
  21747. t['\u2047'] = '\u003F\u003F';
  21748. t['\u2048'] = '\u003F\u0021';
  21749. t['\u2049'] = '\u0021\u003F';
  21750. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  21751. t['\u205F'] = '\u0020';
  21752. t['\u20A8'] = '\u0052\u0073';
  21753. t['\u2100'] = '\u0061\u002F\u0063';
  21754. t['\u2101'] = '\u0061\u002F\u0073';
  21755. t['\u2103'] = '\u00B0\u0043';
  21756. t['\u2105'] = '\u0063\u002F\u006F';
  21757. t['\u2106'] = '\u0063\u002F\u0075';
  21758. t['\u2107'] = '\u0190';
  21759. t['\u2109'] = '\u00B0\u0046';
  21760. t['\u2116'] = '\u004E\u006F';
  21761. t['\u2121'] = '\u0054\u0045\u004C';
  21762. t['\u2135'] = '\u05D0';
  21763. t['\u2136'] = '\u05D1';
  21764. t['\u2137'] = '\u05D2';
  21765. t['\u2138'] = '\u05D3';
  21766. t['\u213B'] = '\u0046\u0041\u0058';
  21767. t['\u2160'] = '\u0049';
  21768. t['\u2161'] = '\u0049\u0049';
  21769. t['\u2162'] = '\u0049\u0049\u0049';
  21770. t['\u2163'] = '\u0049\u0056';
  21771. t['\u2164'] = '\u0056';
  21772. t['\u2165'] = '\u0056\u0049';
  21773. t['\u2166'] = '\u0056\u0049\u0049';
  21774. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  21775. t['\u2168'] = '\u0049\u0058';
  21776. t['\u2169'] = '\u0058';
  21777. t['\u216A'] = '\u0058\u0049';
  21778. t['\u216B'] = '\u0058\u0049\u0049';
  21779. t['\u216C'] = '\u004C';
  21780. t['\u216D'] = '\u0043';
  21781. t['\u216E'] = '\u0044';
  21782. t['\u216F'] = '\u004D';
  21783. t['\u2170'] = '\u0069';
  21784. t['\u2171'] = '\u0069\u0069';
  21785. t['\u2172'] = '\u0069\u0069\u0069';
  21786. t['\u2173'] = '\u0069\u0076';
  21787. t['\u2174'] = '\u0076';
  21788. t['\u2175'] = '\u0076\u0069';
  21789. t['\u2176'] = '\u0076\u0069\u0069';
  21790. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  21791. t['\u2178'] = '\u0069\u0078';
  21792. t['\u2179'] = '\u0078';
  21793. t['\u217A'] = '\u0078\u0069';
  21794. t['\u217B'] = '\u0078\u0069\u0069';
  21795. t['\u217C'] = '\u006C';
  21796. t['\u217D'] = '\u0063';
  21797. t['\u217E'] = '\u0064';
  21798. t['\u217F'] = '\u006D';
  21799. t['\u222C'] = '\u222B\u222B';
  21800. t['\u222D'] = '\u222B\u222B\u222B';
  21801. t['\u222F'] = '\u222E\u222E';
  21802. t['\u2230'] = '\u222E\u222E\u222E';
  21803. t['\u2474'] = '\u0028\u0031\u0029';
  21804. t['\u2475'] = '\u0028\u0032\u0029';
  21805. t['\u2476'] = '\u0028\u0033\u0029';
  21806. t['\u2477'] = '\u0028\u0034\u0029';
  21807. t['\u2478'] = '\u0028\u0035\u0029';
  21808. t['\u2479'] = '\u0028\u0036\u0029';
  21809. t['\u247A'] = '\u0028\u0037\u0029';
  21810. t['\u247B'] = '\u0028\u0038\u0029';
  21811. t['\u247C'] = '\u0028\u0039\u0029';
  21812. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  21813. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  21814. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  21815. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  21816. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  21817. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  21818. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  21819. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  21820. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  21821. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  21822. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  21823. t['\u2488'] = '\u0031\u002E';
  21824. t['\u2489'] = '\u0032\u002E';
  21825. t['\u248A'] = '\u0033\u002E';
  21826. t['\u248B'] = '\u0034\u002E';
  21827. t['\u248C'] = '\u0035\u002E';
  21828. t['\u248D'] = '\u0036\u002E';
  21829. t['\u248E'] = '\u0037\u002E';
  21830. t['\u248F'] = '\u0038\u002E';
  21831. t['\u2490'] = '\u0039\u002E';
  21832. t['\u2491'] = '\u0031\u0030\u002E';
  21833. t['\u2492'] = '\u0031\u0031\u002E';
  21834. t['\u2493'] = '\u0031\u0032\u002E';
  21835. t['\u2494'] = '\u0031\u0033\u002E';
  21836. t['\u2495'] = '\u0031\u0034\u002E';
  21837. t['\u2496'] = '\u0031\u0035\u002E';
  21838. t['\u2497'] = '\u0031\u0036\u002E';
  21839. t['\u2498'] = '\u0031\u0037\u002E';
  21840. t['\u2499'] = '\u0031\u0038\u002E';
  21841. t['\u249A'] = '\u0031\u0039\u002E';
  21842. t['\u249B'] = '\u0032\u0030\u002E';
  21843. t['\u249C'] = '\u0028\u0061\u0029';
  21844. t['\u249D'] = '\u0028\u0062\u0029';
  21845. t['\u249E'] = '\u0028\u0063\u0029';
  21846. t['\u249F'] = '\u0028\u0064\u0029';
  21847. t['\u24A0'] = '\u0028\u0065\u0029';
  21848. t['\u24A1'] = '\u0028\u0066\u0029';
  21849. t['\u24A2'] = '\u0028\u0067\u0029';
  21850. t['\u24A3'] = '\u0028\u0068\u0029';
  21851. t['\u24A4'] = '\u0028\u0069\u0029';
  21852. t['\u24A5'] = '\u0028\u006A\u0029';
  21853. t['\u24A6'] = '\u0028\u006B\u0029';
  21854. t['\u24A7'] = '\u0028\u006C\u0029';
  21855. t['\u24A8'] = '\u0028\u006D\u0029';
  21856. t['\u24A9'] = '\u0028\u006E\u0029';
  21857. t['\u24AA'] = '\u0028\u006F\u0029';
  21858. t['\u24AB'] = '\u0028\u0070\u0029';
  21859. t['\u24AC'] = '\u0028\u0071\u0029';
  21860. t['\u24AD'] = '\u0028\u0072\u0029';
  21861. t['\u24AE'] = '\u0028\u0073\u0029';
  21862. t['\u24AF'] = '\u0028\u0074\u0029';
  21863. t['\u24B0'] = '\u0028\u0075\u0029';
  21864. t['\u24B1'] = '\u0028\u0076\u0029';
  21865. t['\u24B2'] = '\u0028\u0077\u0029';
  21866. t['\u24B3'] = '\u0028\u0078\u0029';
  21867. t['\u24B4'] = '\u0028\u0079\u0029';
  21868. t['\u24B5'] = '\u0028\u007A\u0029';
  21869. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  21870. t['\u2A74'] = '\u003A\u003A\u003D';
  21871. t['\u2A75'] = '\u003D\u003D';
  21872. t['\u2A76'] = '\u003D\u003D\u003D';
  21873. t['\u2E9F'] = '\u6BCD';
  21874. t['\u2EF3'] = '\u9F9F';
  21875. t['\u2F00'] = '\u4E00';
  21876. t['\u2F01'] = '\u4E28';
  21877. t['\u2F02'] = '\u4E36';
  21878. t['\u2F03'] = '\u4E3F';
  21879. t['\u2F04'] = '\u4E59';
  21880. t['\u2F05'] = '\u4E85';
  21881. t['\u2F06'] = '\u4E8C';
  21882. t['\u2F07'] = '\u4EA0';
  21883. t['\u2F08'] = '\u4EBA';
  21884. t['\u2F09'] = '\u513F';
  21885. t['\u2F0A'] = '\u5165';
  21886. t['\u2F0B'] = '\u516B';
  21887. t['\u2F0C'] = '\u5182';
  21888. t['\u2F0D'] = '\u5196';
  21889. t['\u2F0E'] = '\u51AB';
  21890. t['\u2F0F'] = '\u51E0';
  21891. t['\u2F10'] = '\u51F5';
  21892. t['\u2F11'] = '\u5200';
  21893. t['\u2F12'] = '\u529B';
  21894. t['\u2F13'] = '\u52F9';
  21895. t['\u2F14'] = '\u5315';
  21896. t['\u2F15'] = '\u531A';
  21897. t['\u2F16'] = '\u5338';
  21898. t['\u2F17'] = '\u5341';
  21899. t['\u2F18'] = '\u535C';
  21900. t['\u2F19'] = '\u5369';
  21901. t['\u2F1A'] = '\u5382';
  21902. t['\u2F1B'] = '\u53B6';
  21903. t['\u2F1C'] = '\u53C8';
  21904. t['\u2F1D'] = '\u53E3';
  21905. t['\u2F1E'] = '\u56D7';
  21906. t['\u2F1F'] = '\u571F';
  21907. t['\u2F20'] = '\u58EB';
  21908. t['\u2F21'] = '\u5902';
  21909. t['\u2F22'] = '\u590A';
  21910. t['\u2F23'] = '\u5915';
  21911. t['\u2F24'] = '\u5927';
  21912. t['\u2F25'] = '\u5973';
  21913. t['\u2F26'] = '\u5B50';
  21914. t['\u2F27'] = '\u5B80';
  21915. t['\u2F28'] = '\u5BF8';
  21916. t['\u2F29'] = '\u5C0F';
  21917. t['\u2F2A'] = '\u5C22';
  21918. t['\u2F2B'] = '\u5C38';
  21919. t['\u2F2C'] = '\u5C6E';
  21920. t['\u2F2D'] = '\u5C71';
  21921. t['\u2F2E'] = '\u5DDB';
  21922. t['\u2F2F'] = '\u5DE5';
  21923. t['\u2F30'] = '\u5DF1';
  21924. t['\u2F31'] = '\u5DFE';
  21925. t['\u2F32'] = '\u5E72';
  21926. t['\u2F33'] = '\u5E7A';
  21927. t['\u2F34'] = '\u5E7F';
  21928. t['\u2F35'] = '\u5EF4';
  21929. t['\u2F36'] = '\u5EFE';
  21930. t['\u2F37'] = '\u5F0B';
  21931. t['\u2F38'] = '\u5F13';
  21932. t['\u2F39'] = '\u5F50';
  21933. t['\u2F3A'] = '\u5F61';
  21934. t['\u2F3B'] = '\u5F73';
  21935. t['\u2F3C'] = '\u5FC3';
  21936. t['\u2F3D'] = '\u6208';
  21937. t['\u2F3E'] = '\u6236';
  21938. t['\u2F3F'] = '\u624B';
  21939. t['\u2F40'] = '\u652F';
  21940. t['\u2F41'] = '\u6534';
  21941. t['\u2F42'] = '\u6587';
  21942. t['\u2F43'] = '\u6597';
  21943. t['\u2F44'] = '\u65A4';
  21944. t['\u2F45'] = '\u65B9';
  21945. t['\u2F46'] = '\u65E0';
  21946. t['\u2F47'] = '\u65E5';
  21947. t['\u2F48'] = '\u66F0';
  21948. t['\u2F49'] = '\u6708';
  21949. t['\u2F4A'] = '\u6728';
  21950. t['\u2F4B'] = '\u6B20';
  21951. t['\u2F4C'] = '\u6B62';
  21952. t['\u2F4D'] = '\u6B79';
  21953. t['\u2F4E'] = '\u6BB3';
  21954. t['\u2F4F'] = '\u6BCB';
  21955. t['\u2F50'] = '\u6BD4';
  21956. t['\u2F51'] = '\u6BDB';
  21957. t['\u2F52'] = '\u6C0F';
  21958. t['\u2F53'] = '\u6C14';
  21959. t['\u2F54'] = '\u6C34';
  21960. t['\u2F55'] = '\u706B';
  21961. t['\u2F56'] = '\u722A';
  21962. t['\u2F57'] = '\u7236';
  21963. t['\u2F58'] = '\u723B';
  21964. t['\u2F59'] = '\u723F';
  21965. t['\u2F5A'] = '\u7247';
  21966. t['\u2F5B'] = '\u7259';
  21967. t['\u2F5C'] = '\u725B';
  21968. t['\u2F5D'] = '\u72AC';
  21969. t['\u2F5E'] = '\u7384';
  21970. t['\u2F5F'] = '\u7389';
  21971. t['\u2F60'] = '\u74DC';
  21972. t['\u2F61'] = '\u74E6';
  21973. t['\u2F62'] = '\u7518';
  21974. t['\u2F63'] = '\u751F';
  21975. t['\u2F64'] = '\u7528';
  21976. t['\u2F65'] = '\u7530';
  21977. t['\u2F66'] = '\u758B';
  21978. t['\u2F67'] = '\u7592';
  21979. t['\u2F68'] = '\u7676';
  21980. t['\u2F69'] = '\u767D';
  21981. t['\u2F6A'] = '\u76AE';
  21982. t['\u2F6B'] = '\u76BF';
  21983. t['\u2F6C'] = '\u76EE';
  21984. t['\u2F6D'] = '\u77DB';
  21985. t['\u2F6E'] = '\u77E2';
  21986. t['\u2F6F'] = '\u77F3';
  21987. t['\u2F70'] = '\u793A';
  21988. t['\u2F71'] = '\u79B8';
  21989. t['\u2F72'] = '\u79BE';
  21990. t['\u2F73'] = '\u7A74';
  21991. t['\u2F74'] = '\u7ACB';
  21992. t['\u2F75'] = '\u7AF9';
  21993. t['\u2F76'] = '\u7C73';
  21994. t['\u2F77'] = '\u7CF8';
  21995. t['\u2F78'] = '\u7F36';
  21996. t['\u2F79'] = '\u7F51';
  21997. t['\u2F7A'] = '\u7F8A';
  21998. t['\u2F7B'] = '\u7FBD';
  21999. t['\u2F7C'] = '\u8001';
  22000. t['\u2F7D'] = '\u800C';
  22001. t['\u2F7E'] = '\u8012';
  22002. t['\u2F7F'] = '\u8033';
  22003. t['\u2F80'] = '\u807F';
  22004. t['\u2F81'] = '\u8089';
  22005. t['\u2F82'] = '\u81E3';
  22006. t['\u2F83'] = '\u81EA';
  22007. t['\u2F84'] = '\u81F3';
  22008. t['\u2F85'] = '\u81FC';
  22009. t['\u2F86'] = '\u820C';
  22010. t['\u2F87'] = '\u821B';
  22011. t['\u2F88'] = '\u821F';
  22012. t['\u2F89'] = '\u826E';
  22013. t['\u2F8A'] = '\u8272';
  22014. t['\u2F8B'] = '\u8278';
  22015. t['\u2F8C'] = '\u864D';
  22016. t['\u2F8D'] = '\u866B';
  22017. t['\u2F8E'] = '\u8840';
  22018. t['\u2F8F'] = '\u884C';
  22019. t['\u2F90'] = '\u8863';
  22020. t['\u2F91'] = '\u897E';
  22021. t['\u2F92'] = '\u898B';
  22022. t['\u2F93'] = '\u89D2';
  22023. t['\u2F94'] = '\u8A00';
  22024. t['\u2F95'] = '\u8C37';
  22025. t['\u2F96'] = '\u8C46';
  22026. t['\u2F97'] = '\u8C55';
  22027. t['\u2F98'] = '\u8C78';
  22028. t['\u2F99'] = '\u8C9D';
  22029. t['\u2F9A'] = '\u8D64';
  22030. t['\u2F9B'] = '\u8D70';
  22031. t['\u2F9C'] = '\u8DB3';
  22032. t['\u2F9D'] = '\u8EAB';
  22033. t['\u2F9E'] = '\u8ECA';
  22034. t['\u2F9F'] = '\u8F9B';
  22035. t['\u2FA0'] = '\u8FB0';
  22036. t['\u2FA1'] = '\u8FB5';
  22037. t['\u2FA2'] = '\u9091';
  22038. t['\u2FA3'] = '\u9149';
  22039. t['\u2FA4'] = '\u91C6';
  22040. t['\u2FA5'] = '\u91CC';
  22041. t['\u2FA6'] = '\u91D1';
  22042. t['\u2FA7'] = '\u9577';
  22043. t['\u2FA8'] = '\u9580';
  22044. t['\u2FA9'] = '\u961C';
  22045. t['\u2FAA'] = '\u96B6';
  22046. t['\u2FAB'] = '\u96B9';
  22047. t['\u2FAC'] = '\u96E8';
  22048. t['\u2FAD'] = '\u9751';
  22049. t['\u2FAE'] = '\u975E';
  22050. t['\u2FAF'] = '\u9762';
  22051. t['\u2FB0'] = '\u9769';
  22052. t['\u2FB1'] = '\u97CB';
  22053. t['\u2FB2'] = '\u97ED';
  22054. t['\u2FB3'] = '\u97F3';
  22055. t['\u2FB4'] = '\u9801';
  22056. t['\u2FB5'] = '\u98A8';
  22057. t['\u2FB6'] = '\u98DB';
  22058. t['\u2FB7'] = '\u98DF';
  22059. t['\u2FB8'] = '\u9996';
  22060. t['\u2FB9'] = '\u9999';
  22061. t['\u2FBA'] = '\u99AC';
  22062. t['\u2FBB'] = '\u9AA8';
  22063. t['\u2FBC'] = '\u9AD8';
  22064. t['\u2FBD'] = '\u9ADF';
  22065. t['\u2FBE'] = '\u9B25';
  22066. t['\u2FBF'] = '\u9B2F';
  22067. t['\u2FC0'] = '\u9B32';
  22068. t['\u2FC1'] = '\u9B3C';
  22069. t['\u2FC2'] = '\u9B5A';
  22070. t['\u2FC3'] = '\u9CE5';
  22071. t['\u2FC4'] = '\u9E75';
  22072. t['\u2FC5'] = '\u9E7F';
  22073. t['\u2FC6'] = '\u9EA5';
  22074. t['\u2FC7'] = '\u9EBB';
  22075. t['\u2FC8'] = '\u9EC3';
  22076. t['\u2FC9'] = '\u9ECD';
  22077. t['\u2FCA'] = '\u9ED1';
  22078. t['\u2FCB'] = '\u9EF9';
  22079. t['\u2FCC'] = '\u9EFD';
  22080. t['\u2FCD'] = '\u9F0E';
  22081. t['\u2FCE'] = '\u9F13';
  22082. t['\u2FCF'] = '\u9F20';
  22083. t['\u2FD0'] = '\u9F3B';
  22084. t['\u2FD1'] = '\u9F4A';
  22085. t['\u2FD2'] = '\u9F52';
  22086. t['\u2FD3'] = '\u9F8D';
  22087. t['\u2FD4'] = '\u9F9C';
  22088. t['\u2FD5'] = '\u9FA0';
  22089. t['\u3036'] = '\u3012';
  22090. t['\u3038'] = '\u5341';
  22091. t['\u3039'] = '\u5344';
  22092. t['\u303A'] = '\u5345';
  22093. t['\u309B'] = '\u0020\u3099';
  22094. t['\u309C'] = '\u0020\u309A';
  22095. t['\u3131'] = '\u1100';
  22096. t['\u3132'] = '\u1101';
  22097. t['\u3133'] = '\u11AA';
  22098. t['\u3134'] = '\u1102';
  22099. t['\u3135'] = '\u11AC';
  22100. t['\u3136'] = '\u11AD';
  22101. t['\u3137'] = '\u1103';
  22102. t['\u3138'] = '\u1104';
  22103. t['\u3139'] = '\u1105';
  22104. t['\u313A'] = '\u11B0';
  22105. t['\u313B'] = '\u11B1';
  22106. t['\u313C'] = '\u11B2';
  22107. t['\u313D'] = '\u11B3';
  22108. t['\u313E'] = '\u11B4';
  22109. t['\u313F'] = '\u11B5';
  22110. t['\u3140'] = '\u111A';
  22111. t['\u3141'] = '\u1106';
  22112. t['\u3142'] = '\u1107';
  22113. t['\u3143'] = '\u1108';
  22114. t['\u3144'] = '\u1121';
  22115. t['\u3145'] = '\u1109';
  22116. t['\u3146'] = '\u110A';
  22117. t['\u3147'] = '\u110B';
  22118. t['\u3148'] = '\u110C';
  22119. t['\u3149'] = '\u110D';
  22120. t['\u314A'] = '\u110E';
  22121. t['\u314B'] = '\u110F';
  22122. t['\u314C'] = '\u1110';
  22123. t['\u314D'] = '\u1111';
  22124. t['\u314E'] = '\u1112';
  22125. t['\u314F'] = '\u1161';
  22126. t['\u3150'] = '\u1162';
  22127. t['\u3151'] = '\u1163';
  22128. t['\u3152'] = '\u1164';
  22129. t['\u3153'] = '\u1165';
  22130. t['\u3154'] = '\u1166';
  22131. t['\u3155'] = '\u1167';
  22132. t['\u3156'] = '\u1168';
  22133. t['\u3157'] = '\u1169';
  22134. t['\u3158'] = '\u116A';
  22135. t['\u3159'] = '\u116B';
  22136. t['\u315A'] = '\u116C';
  22137. t['\u315B'] = '\u116D';
  22138. t['\u315C'] = '\u116E';
  22139. t['\u315D'] = '\u116F';
  22140. t['\u315E'] = '\u1170';
  22141. t['\u315F'] = '\u1171';
  22142. t['\u3160'] = '\u1172';
  22143. t['\u3161'] = '\u1173';
  22144. t['\u3162'] = '\u1174';
  22145. t['\u3163'] = '\u1175';
  22146. t['\u3164'] = '\u1160';
  22147. t['\u3165'] = '\u1114';
  22148. t['\u3166'] = '\u1115';
  22149. t['\u3167'] = '\u11C7';
  22150. t['\u3168'] = '\u11C8';
  22151. t['\u3169'] = '\u11CC';
  22152. t['\u316A'] = '\u11CE';
  22153. t['\u316B'] = '\u11D3';
  22154. t['\u316C'] = '\u11D7';
  22155. t['\u316D'] = '\u11D9';
  22156. t['\u316E'] = '\u111C';
  22157. t['\u316F'] = '\u11DD';
  22158. t['\u3170'] = '\u11DF';
  22159. t['\u3171'] = '\u111D';
  22160. t['\u3172'] = '\u111E';
  22161. t['\u3173'] = '\u1120';
  22162. t['\u3174'] = '\u1122';
  22163. t['\u3175'] = '\u1123';
  22164. t['\u3176'] = '\u1127';
  22165. t['\u3177'] = '\u1129';
  22166. t['\u3178'] = '\u112B';
  22167. t['\u3179'] = '\u112C';
  22168. t['\u317A'] = '\u112D';
  22169. t['\u317B'] = '\u112E';
  22170. t['\u317C'] = '\u112F';
  22171. t['\u317D'] = '\u1132';
  22172. t['\u317E'] = '\u1136';
  22173. t['\u317F'] = '\u1140';
  22174. t['\u3180'] = '\u1147';
  22175. t['\u3181'] = '\u114C';
  22176. t['\u3182'] = '\u11F1';
  22177. t['\u3183'] = '\u11F2';
  22178. t['\u3184'] = '\u1157';
  22179. t['\u3185'] = '\u1158';
  22180. t['\u3186'] = '\u1159';
  22181. t['\u3187'] = '\u1184';
  22182. t['\u3188'] = '\u1185';
  22183. t['\u3189'] = '\u1188';
  22184. t['\u318A'] = '\u1191';
  22185. t['\u318B'] = '\u1192';
  22186. t['\u318C'] = '\u1194';
  22187. t['\u318D'] = '\u119E';
  22188. t['\u318E'] = '\u11A1';
  22189. t['\u3200'] = '\u0028\u1100\u0029';
  22190. t['\u3201'] = '\u0028\u1102\u0029';
  22191. t['\u3202'] = '\u0028\u1103\u0029';
  22192. t['\u3203'] = '\u0028\u1105\u0029';
  22193. t['\u3204'] = '\u0028\u1106\u0029';
  22194. t['\u3205'] = '\u0028\u1107\u0029';
  22195. t['\u3206'] = '\u0028\u1109\u0029';
  22196. t['\u3207'] = '\u0028\u110B\u0029';
  22197. t['\u3208'] = '\u0028\u110C\u0029';
  22198. t['\u3209'] = '\u0028\u110E\u0029';
  22199. t['\u320A'] = '\u0028\u110F\u0029';
  22200. t['\u320B'] = '\u0028\u1110\u0029';
  22201. t['\u320C'] = '\u0028\u1111\u0029';
  22202. t['\u320D'] = '\u0028\u1112\u0029';
  22203. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  22204. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  22205. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  22206. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  22207. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  22208. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  22209. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  22210. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  22211. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  22212. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  22213. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  22214. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  22215. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  22216. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  22217. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  22218. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  22219. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  22220. t['\u3220'] = '\u0028\u4E00\u0029';
  22221. t['\u3221'] = '\u0028\u4E8C\u0029';
  22222. t['\u3222'] = '\u0028\u4E09\u0029';
  22223. t['\u3223'] = '\u0028\u56DB\u0029';
  22224. t['\u3224'] = '\u0028\u4E94\u0029';
  22225. t['\u3225'] = '\u0028\u516D\u0029';
  22226. t['\u3226'] = '\u0028\u4E03\u0029';
  22227. t['\u3227'] = '\u0028\u516B\u0029';
  22228. t['\u3228'] = '\u0028\u4E5D\u0029';
  22229. t['\u3229'] = '\u0028\u5341\u0029';
  22230. t['\u322A'] = '\u0028\u6708\u0029';
  22231. t['\u322B'] = '\u0028\u706B\u0029';
  22232. t['\u322C'] = '\u0028\u6C34\u0029';
  22233. t['\u322D'] = '\u0028\u6728\u0029';
  22234. t['\u322E'] = '\u0028\u91D1\u0029';
  22235. t['\u322F'] = '\u0028\u571F\u0029';
  22236. t['\u3230'] = '\u0028\u65E5\u0029';
  22237. t['\u3231'] = '\u0028\u682A\u0029';
  22238. t['\u3232'] = '\u0028\u6709\u0029';
  22239. t['\u3233'] = '\u0028\u793E\u0029';
  22240. t['\u3234'] = '\u0028\u540D\u0029';
  22241. t['\u3235'] = '\u0028\u7279\u0029';
  22242. t['\u3236'] = '\u0028\u8CA1\u0029';
  22243. t['\u3237'] = '\u0028\u795D\u0029';
  22244. t['\u3238'] = '\u0028\u52B4\u0029';
  22245. t['\u3239'] = '\u0028\u4EE3\u0029';
  22246. t['\u323A'] = '\u0028\u547C\u0029';
  22247. t['\u323B'] = '\u0028\u5B66\u0029';
  22248. t['\u323C'] = '\u0028\u76E3\u0029';
  22249. t['\u323D'] = '\u0028\u4F01\u0029';
  22250. t['\u323E'] = '\u0028\u8CC7\u0029';
  22251. t['\u323F'] = '\u0028\u5354\u0029';
  22252. t['\u3240'] = '\u0028\u796D\u0029';
  22253. t['\u3241'] = '\u0028\u4F11\u0029';
  22254. t['\u3242'] = '\u0028\u81EA\u0029';
  22255. t['\u3243'] = '\u0028\u81F3\u0029';
  22256. t['\u32C0'] = '\u0031\u6708';
  22257. t['\u32C1'] = '\u0032\u6708';
  22258. t['\u32C2'] = '\u0033\u6708';
  22259. t['\u32C3'] = '\u0034\u6708';
  22260. t['\u32C4'] = '\u0035\u6708';
  22261. t['\u32C5'] = '\u0036\u6708';
  22262. t['\u32C6'] = '\u0037\u6708';
  22263. t['\u32C7'] = '\u0038\u6708';
  22264. t['\u32C8'] = '\u0039\u6708';
  22265. t['\u32C9'] = '\u0031\u0030\u6708';
  22266. t['\u32CA'] = '\u0031\u0031\u6708';
  22267. t['\u32CB'] = '\u0031\u0032\u6708';
  22268. t['\u3358'] = '\u0030\u70B9';
  22269. t['\u3359'] = '\u0031\u70B9';
  22270. t['\u335A'] = '\u0032\u70B9';
  22271. t['\u335B'] = '\u0033\u70B9';
  22272. t['\u335C'] = '\u0034\u70B9';
  22273. t['\u335D'] = '\u0035\u70B9';
  22274. t['\u335E'] = '\u0036\u70B9';
  22275. t['\u335F'] = '\u0037\u70B9';
  22276. t['\u3360'] = '\u0038\u70B9';
  22277. t['\u3361'] = '\u0039\u70B9';
  22278. t['\u3362'] = '\u0031\u0030\u70B9';
  22279. t['\u3363'] = '\u0031\u0031\u70B9';
  22280. t['\u3364'] = '\u0031\u0032\u70B9';
  22281. t['\u3365'] = '\u0031\u0033\u70B9';
  22282. t['\u3366'] = '\u0031\u0034\u70B9';
  22283. t['\u3367'] = '\u0031\u0035\u70B9';
  22284. t['\u3368'] = '\u0031\u0036\u70B9';
  22285. t['\u3369'] = '\u0031\u0037\u70B9';
  22286. t['\u336A'] = '\u0031\u0038\u70B9';
  22287. t['\u336B'] = '\u0031\u0039\u70B9';
  22288. t['\u336C'] = '\u0032\u0030\u70B9';
  22289. t['\u336D'] = '\u0032\u0031\u70B9';
  22290. t['\u336E'] = '\u0032\u0032\u70B9';
  22291. t['\u336F'] = '\u0032\u0033\u70B9';
  22292. t['\u3370'] = '\u0032\u0034\u70B9';
  22293. t['\u33E0'] = '\u0031\u65E5';
  22294. t['\u33E1'] = '\u0032\u65E5';
  22295. t['\u33E2'] = '\u0033\u65E5';
  22296. t['\u33E3'] = '\u0034\u65E5';
  22297. t['\u33E4'] = '\u0035\u65E5';
  22298. t['\u33E5'] = '\u0036\u65E5';
  22299. t['\u33E6'] = '\u0037\u65E5';
  22300. t['\u33E7'] = '\u0038\u65E5';
  22301. t['\u33E8'] = '\u0039\u65E5';
  22302. t['\u33E9'] = '\u0031\u0030\u65E5';
  22303. t['\u33EA'] = '\u0031\u0031\u65E5';
  22304. t['\u33EB'] = '\u0031\u0032\u65E5';
  22305. t['\u33EC'] = '\u0031\u0033\u65E5';
  22306. t['\u33ED'] = '\u0031\u0034\u65E5';
  22307. t['\u33EE'] = '\u0031\u0035\u65E5';
  22308. t['\u33EF'] = '\u0031\u0036\u65E5';
  22309. t['\u33F0'] = '\u0031\u0037\u65E5';
  22310. t['\u33F1'] = '\u0031\u0038\u65E5';
  22311. t['\u33F2'] = '\u0031\u0039\u65E5';
  22312. t['\u33F3'] = '\u0032\u0030\u65E5';
  22313. t['\u33F4'] = '\u0032\u0031\u65E5';
  22314. t['\u33F5'] = '\u0032\u0032\u65E5';
  22315. t['\u33F6'] = '\u0032\u0033\u65E5';
  22316. t['\u33F7'] = '\u0032\u0034\u65E5';
  22317. t['\u33F8'] = '\u0032\u0035\u65E5';
  22318. t['\u33F9'] = '\u0032\u0036\u65E5';
  22319. t['\u33FA'] = '\u0032\u0037\u65E5';
  22320. t['\u33FB'] = '\u0032\u0038\u65E5';
  22321. t['\u33FC'] = '\u0032\u0039\u65E5';
  22322. t['\u33FD'] = '\u0033\u0030\u65E5';
  22323. t['\u33FE'] = '\u0033\u0031\u65E5';
  22324. t['\uFB00'] = '\u0066\u0066';
  22325. t['\uFB01'] = '\u0066\u0069';
  22326. t['\uFB02'] = '\u0066\u006C';
  22327. t['\uFB03'] = '\u0066\u0066\u0069';
  22328. t['\uFB04'] = '\u0066\u0066\u006C';
  22329. t['\uFB05'] = '\u017F\u0074';
  22330. t['\uFB06'] = '\u0073\u0074';
  22331. t['\uFB13'] = '\u0574\u0576';
  22332. t['\uFB14'] = '\u0574\u0565';
  22333. t['\uFB15'] = '\u0574\u056B';
  22334. t['\uFB16'] = '\u057E\u0576';
  22335. t['\uFB17'] = '\u0574\u056D';
  22336. t['\uFB4F'] = '\u05D0\u05DC';
  22337. t['\uFB50'] = '\u0671';
  22338. t['\uFB51'] = '\u0671';
  22339. t['\uFB52'] = '\u067B';
  22340. t['\uFB53'] = '\u067B';
  22341. t['\uFB54'] = '\u067B';
  22342. t['\uFB55'] = '\u067B';
  22343. t['\uFB56'] = '\u067E';
  22344. t['\uFB57'] = '\u067E';
  22345. t['\uFB58'] = '\u067E';
  22346. t['\uFB59'] = '\u067E';
  22347. t['\uFB5A'] = '\u0680';
  22348. t['\uFB5B'] = '\u0680';
  22349. t['\uFB5C'] = '\u0680';
  22350. t['\uFB5D'] = '\u0680';
  22351. t['\uFB5E'] = '\u067A';
  22352. t['\uFB5F'] = '\u067A';
  22353. t['\uFB60'] = '\u067A';
  22354. t['\uFB61'] = '\u067A';
  22355. t['\uFB62'] = '\u067F';
  22356. t['\uFB63'] = '\u067F';
  22357. t['\uFB64'] = '\u067F';
  22358. t['\uFB65'] = '\u067F';
  22359. t['\uFB66'] = '\u0679';
  22360. t['\uFB67'] = '\u0679';
  22361. t['\uFB68'] = '\u0679';
  22362. t['\uFB69'] = '\u0679';
  22363. t['\uFB6A'] = '\u06A4';
  22364. t['\uFB6B'] = '\u06A4';
  22365. t['\uFB6C'] = '\u06A4';
  22366. t['\uFB6D'] = '\u06A4';
  22367. t['\uFB6E'] = '\u06A6';
  22368. t['\uFB6F'] = '\u06A6';
  22369. t['\uFB70'] = '\u06A6';
  22370. t['\uFB71'] = '\u06A6';
  22371. t['\uFB72'] = '\u0684';
  22372. t['\uFB73'] = '\u0684';
  22373. t['\uFB74'] = '\u0684';
  22374. t['\uFB75'] = '\u0684';
  22375. t['\uFB76'] = '\u0683';
  22376. t['\uFB77'] = '\u0683';
  22377. t['\uFB78'] = '\u0683';
  22378. t['\uFB79'] = '\u0683';
  22379. t['\uFB7A'] = '\u0686';
  22380. t['\uFB7B'] = '\u0686';
  22381. t['\uFB7C'] = '\u0686';
  22382. t['\uFB7D'] = '\u0686';
  22383. t['\uFB7E'] = '\u0687';
  22384. t['\uFB7F'] = '\u0687';
  22385. t['\uFB80'] = '\u0687';
  22386. t['\uFB81'] = '\u0687';
  22387. t['\uFB82'] = '\u068D';
  22388. t['\uFB83'] = '\u068D';
  22389. t['\uFB84'] = '\u068C';
  22390. t['\uFB85'] = '\u068C';
  22391. t['\uFB86'] = '\u068E';
  22392. t['\uFB87'] = '\u068E';
  22393. t['\uFB88'] = '\u0688';
  22394. t['\uFB89'] = '\u0688';
  22395. t['\uFB8A'] = '\u0698';
  22396. t['\uFB8B'] = '\u0698';
  22397. t['\uFB8C'] = '\u0691';
  22398. t['\uFB8D'] = '\u0691';
  22399. t['\uFB8E'] = '\u06A9';
  22400. t['\uFB8F'] = '\u06A9';
  22401. t['\uFB90'] = '\u06A9';
  22402. t['\uFB91'] = '\u06A9';
  22403. t['\uFB92'] = '\u06AF';
  22404. t['\uFB93'] = '\u06AF';
  22405. t['\uFB94'] = '\u06AF';
  22406. t['\uFB95'] = '\u06AF';
  22407. t['\uFB96'] = '\u06B3';
  22408. t['\uFB97'] = '\u06B3';
  22409. t['\uFB98'] = '\u06B3';
  22410. t['\uFB99'] = '\u06B3';
  22411. t['\uFB9A'] = '\u06B1';
  22412. t['\uFB9B'] = '\u06B1';
  22413. t['\uFB9C'] = '\u06B1';
  22414. t['\uFB9D'] = '\u06B1';
  22415. t['\uFB9E'] = '\u06BA';
  22416. t['\uFB9F'] = '\u06BA';
  22417. t['\uFBA0'] = '\u06BB';
  22418. t['\uFBA1'] = '\u06BB';
  22419. t['\uFBA2'] = '\u06BB';
  22420. t['\uFBA3'] = '\u06BB';
  22421. t['\uFBA4'] = '\u06C0';
  22422. t['\uFBA5'] = '\u06C0';
  22423. t['\uFBA6'] = '\u06C1';
  22424. t['\uFBA7'] = '\u06C1';
  22425. t['\uFBA8'] = '\u06C1';
  22426. t['\uFBA9'] = '\u06C1';
  22427. t['\uFBAA'] = '\u06BE';
  22428. t['\uFBAB'] = '\u06BE';
  22429. t['\uFBAC'] = '\u06BE';
  22430. t['\uFBAD'] = '\u06BE';
  22431. t['\uFBAE'] = '\u06D2';
  22432. t['\uFBAF'] = '\u06D2';
  22433. t['\uFBB0'] = '\u06D3';
  22434. t['\uFBB1'] = '\u06D3';
  22435. t['\uFBD3'] = '\u06AD';
  22436. t['\uFBD4'] = '\u06AD';
  22437. t['\uFBD5'] = '\u06AD';
  22438. t['\uFBD6'] = '\u06AD';
  22439. t['\uFBD7'] = '\u06C7';
  22440. t['\uFBD8'] = '\u06C7';
  22441. t['\uFBD9'] = '\u06C6';
  22442. t['\uFBDA'] = '\u06C6';
  22443. t['\uFBDB'] = '\u06C8';
  22444. t['\uFBDC'] = '\u06C8';
  22445. t['\uFBDD'] = '\u0677';
  22446. t['\uFBDE'] = '\u06CB';
  22447. t['\uFBDF'] = '\u06CB';
  22448. t['\uFBE0'] = '\u06C5';
  22449. t['\uFBE1'] = '\u06C5';
  22450. t['\uFBE2'] = '\u06C9';
  22451. t['\uFBE3'] = '\u06C9';
  22452. t['\uFBE4'] = '\u06D0';
  22453. t['\uFBE5'] = '\u06D0';
  22454. t['\uFBE6'] = '\u06D0';
  22455. t['\uFBE7'] = '\u06D0';
  22456. t['\uFBE8'] = '\u0649';
  22457. t['\uFBE9'] = '\u0649';
  22458. t['\uFBEA'] = '\u0626\u0627';
  22459. t['\uFBEB'] = '\u0626\u0627';
  22460. t['\uFBEC'] = '\u0626\u06D5';
  22461. t['\uFBED'] = '\u0626\u06D5';
  22462. t['\uFBEE'] = '\u0626\u0648';
  22463. t['\uFBEF'] = '\u0626\u0648';
  22464. t['\uFBF0'] = '\u0626\u06C7';
  22465. t['\uFBF1'] = '\u0626\u06C7';
  22466. t['\uFBF2'] = '\u0626\u06C6';
  22467. t['\uFBF3'] = '\u0626\u06C6';
  22468. t['\uFBF4'] = '\u0626\u06C8';
  22469. t['\uFBF5'] = '\u0626\u06C8';
  22470. t['\uFBF6'] = '\u0626\u06D0';
  22471. t['\uFBF7'] = '\u0626\u06D0';
  22472. t['\uFBF8'] = '\u0626\u06D0';
  22473. t['\uFBF9'] = '\u0626\u0649';
  22474. t['\uFBFA'] = '\u0626\u0649';
  22475. t['\uFBFB'] = '\u0626\u0649';
  22476. t['\uFBFC'] = '\u06CC';
  22477. t['\uFBFD'] = '\u06CC';
  22478. t['\uFBFE'] = '\u06CC';
  22479. t['\uFBFF'] = '\u06CC';
  22480. t['\uFC00'] = '\u0626\u062C';
  22481. t['\uFC01'] = '\u0626\u062D';
  22482. t['\uFC02'] = '\u0626\u0645';
  22483. t['\uFC03'] = '\u0626\u0649';
  22484. t['\uFC04'] = '\u0626\u064A';
  22485. t['\uFC05'] = '\u0628\u062C';
  22486. t['\uFC06'] = '\u0628\u062D';
  22487. t['\uFC07'] = '\u0628\u062E';
  22488. t['\uFC08'] = '\u0628\u0645';
  22489. t['\uFC09'] = '\u0628\u0649';
  22490. t['\uFC0A'] = '\u0628\u064A';
  22491. t['\uFC0B'] = '\u062A\u062C';
  22492. t['\uFC0C'] = '\u062A\u062D';
  22493. t['\uFC0D'] = '\u062A\u062E';
  22494. t['\uFC0E'] = '\u062A\u0645';
  22495. t['\uFC0F'] = '\u062A\u0649';
  22496. t['\uFC10'] = '\u062A\u064A';
  22497. t['\uFC11'] = '\u062B\u062C';
  22498. t['\uFC12'] = '\u062B\u0645';
  22499. t['\uFC13'] = '\u062B\u0649';
  22500. t['\uFC14'] = '\u062B\u064A';
  22501. t['\uFC15'] = '\u062C\u062D';
  22502. t['\uFC16'] = '\u062C\u0645';
  22503. t['\uFC17'] = '\u062D\u062C';
  22504. t['\uFC18'] = '\u062D\u0645';
  22505. t['\uFC19'] = '\u062E\u062C';
  22506. t['\uFC1A'] = '\u062E\u062D';
  22507. t['\uFC1B'] = '\u062E\u0645';
  22508. t['\uFC1C'] = '\u0633\u062C';
  22509. t['\uFC1D'] = '\u0633\u062D';
  22510. t['\uFC1E'] = '\u0633\u062E';
  22511. t['\uFC1F'] = '\u0633\u0645';
  22512. t['\uFC20'] = '\u0635\u062D';
  22513. t['\uFC21'] = '\u0635\u0645';
  22514. t['\uFC22'] = '\u0636\u062C';
  22515. t['\uFC23'] = '\u0636\u062D';
  22516. t['\uFC24'] = '\u0636\u062E';
  22517. t['\uFC25'] = '\u0636\u0645';
  22518. t['\uFC26'] = '\u0637\u062D';
  22519. t['\uFC27'] = '\u0637\u0645';
  22520. t['\uFC28'] = '\u0638\u0645';
  22521. t['\uFC29'] = '\u0639\u062C';
  22522. t['\uFC2A'] = '\u0639\u0645';
  22523. t['\uFC2B'] = '\u063A\u062C';
  22524. t['\uFC2C'] = '\u063A\u0645';
  22525. t['\uFC2D'] = '\u0641\u062C';
  22526. t['\uFC2E'] = '\u0641\u062D';
  22527. t['\uFC2F'] = '\u0641\u062E';
  22528. t['\uFC30'] = '\u0641\u0645';
  22529. t['\uFC31'] = '\u0641\u0649';
  22530. t['\uFC32'] = '\u0641\u064A';
  22531. t['\uFC33'] = '\u0642\u062D';
  22532. t['\uFC34'] = '\u0642\u0645';
  22533. t['\uFC35'] = '\u0642\u0649';
  22534. t['\uFC36'] = '\u0642\u064A';
  22535. t['\uFC37'] = '\u0643\u0627';
  22536. t['\uFC38'] = '\u0643\u062C';
  22537. t['\uFC39'] = '\u0643\u062D';
  22538. t['\uFC3A'] = '\u0643\u062E';
  22539. t['\uFC3B'] = '\u0643\u0644';
  22540. t['\uFC3C'] = '\u0643\u0645';
  22541. t['\uFC3D'] = '\u0643\u0649';
  22542. t['\uFC3E'] = '\u0643\u064A';
  22543. t['\uFC3F'] = '\u0644\u062C';
  22544. t['\uFC40'] = '\u0644\u062D';
  22545. t['\uFC41'] = '\u0644\u062E';
  22546. t['\uFC42'] = '\u0644\u0645';
  22547. t['\uFC43'] = '\u0644\u0649';
  22548. t['\uFC44'] = '\u0644\u064A';
  22549. t['\uFC45'] = '\u0645\u062C';
  22550. t['\uFC46'] = '\u0645\u062D';
  22551. t['\uFC47'] = '\u0645\u062E';
  22552. t['\uFC48'] = '\u0645\u0645';
  22553. t['\uFC49'] = '\u0645\u0649';
  22554. t['\uFC4A'] = '\u0645\u064A';
  22555. t['\uFC4B'] = '\u0646\u062C';
  22556. t['\uFC4C'] = '\u0646\u062D';
  22557. t['\uFC4D'] = '\u0646\u062E';
  22558. t['\uFC4E'] = '\u0646\u0645';
  22559. t['\uFC4F'] = '\u0646\u0649';
  22560. t['\uFC50'] = '\u0646\u064A';
  22561. t['\uFC51'] = '\u0647\u062C';
  22562. t['\uFC52'] = '\u0647\u0645';
  22563. t['\uFC53'] = '\u0647\u0649';
  22564. t['\uFC54'] = '\u0647\u064A';
  22565. t['\uFC55'] = '\u064A\u062C';
  22566. t['\uFC56'] = '\u064A\u062D';
  22567. t['\uFC57'] = '\u064A\u062E';
  22568. t['\uFC58'] = '\u064A\u0645';
  22569. t['\uFC59'] = '\u064A\u0649';
  22570. t['\uFC5A'] = '\u064A\u064A';
  22571. t['\uFC5B'] = '\u0630\u0670';
  22572. t['\uFC5C'] = '\u0631\u0670';
  22573. t['\uFC5D'] = '\u0649\u0670';
  22574. t['\uFC5E'] = '\u0020\u064C\u0651';
  22575. t['\uFC5F'] = '\u0020\u064D\u0651';
  22576. t['\uFC60'] = '\u0020\u064E\u0651';
  22577. t['\uFC61'] = '\u0020\u064F\u0651';
  22578. t['\uFC62'] = '\u0020\u0650\u0651';
  22579. t['\uFC63'] = '\u0020\u0651\u0670';
  22580. t['\uFC64'] = '\u0626\u0631';
  22581. t['\uFC65'] = '\u0626\u0632';
  22582. t['\uFC66'] = '\u0626\u0645';
  22583. t['\uFC67'] = '\u0626\u0646';
  22584. t['\uFC68'] = '\u0626\u0649';
  22585. t['\uFC69'] = '\u0626\u064A';
  22586. t['\uFC6A'] = '\u0628\u0631';
  22587. t['\uFC6B'] = '\u0628\u0632';
  22588. t['\uFC6C'] = '\u0628\u0645';
  22589. t['\uFC6D'] = '\u0628\u0646';
  22590. t['\uFC6E'] = '\u0628\u0649';
  22591. t['\uFC6F'] = '\u0628\u064A';
  22592. t['\uFC70'] = '\u062A\u0631';
  22593. t['\uFC71'] = '\u062A\u0632';
  22594. t['\uFC72'] = '\u062A\u0645';
  22595. t['\uFC73'] = '\u062A\u0646';
  22596. t['\uFC74'] = '\u062A\u0649';
  22597. t['\uFC75'] = '\u062A\u064A';
  22598. t['\uFC76'] = '\u062B\u0631';
  22599. t['\uFC77'] = '\u062B\u0632';
  22600. t['\uFC78'] = '\u062B\u0645';
  22601. t['\uFC79'] = '\u062B\u0646';
  22602. t['\uFC7A'] = '\u062B\u0649';
  22603. t['\uFC7B'] = '\u062B\u064A';
  22604. t['\uFC7C'] = '\u0641\u0649';
  22605. t['\uFC7D'] = '\u0641\u064A';
  22606. t['\uFC7E'] = '\u0642\u0649';
  22607. t['\uFC7F'] = '\u0642\u064A';
  22608. t['\uFC80'] = '\u0643\u0627';
  22609. t['\uFC81'] = '\u0643\u0644';
  22610. t['\uFC82'] = '\u0643\u0645';
  22611. t['\uFC83'] = '\u0643\u0649';
  22612. t['\uFC84'] = '\u0643\u064A';
  22613. t['\uFC85'] = '\u0644\u0645';
  22614. t['\uFC86'] = '\u0644\u0649';
  22615. t['\uFC87'] = '\u0644\u064A';
  22616. t['\uFC88'] = '\u0645\u0627';
  22617. t['\uFC89'] = '\u0645\u0645';
  22618. t['\uFC8A'] = '\u0646\u0631';
  22619. t['\uFC8B'] = '\u0646\u0632';
  22620. t['\uFC8C'] = '\u0646\u0645';
  22621. t['\uFC8D'] = '\u0646\u0646';
  22622. t['\uFC8E'] = '\u0646\u0649';
  22623. t['\uFC8F'] = '\u0646\u064A';
  22624. t['\uFC90'] = '\u0649\u0670';
  22625. t['\uFC91'] = '\u064A\u0631';
  22626. t['\uFC92'] = '\u064A\u0632';
  22627. t['\uFC93'] = '\u064A\u0645';
  22628. t['\uFC94'] = '\u064A\u0646';
  22629. t['\uFC95'] = '\u064A\u0649';
  22630. t['\uFC96'] = '\u064A\u064A';
  22631. t['\uFC97'] = '\u0626\u062C';
  22632. t['\uFC98'] = '\u0626\u062D';
  22633. t['\uFC99'] = '\u0626\u062E';
  22634. t['\uFC9A'] = '\u0626\u0645';
  22635. t['\uFC9B'] = '\u0626\u0647';
  22636. t['\uFC9C'] = '\u0628\u062C';
  22637. t['\uFC9D'] = '\u0628\u062D';
  22638. t['\uFC9E'] = '\u0628\u062E';
  22639. t['\uFC9F'] = '\u0628\u0645';
  22640. t['\uFCA0'] = '\u0628\u0647';
  22641. t['\uFCA1'] = '\u062A\u062C';
  22642. t['\uFCA2'] = '\u062A\u062D';
  22643. t['\uFCA3'] = '\u062A\u062E';
  22644. t['\uFCA4'] = '\u062A\u0645';
  22645. t['\uFCA5'] = '\u062A\u0647';
  22646. t['\uFCA6'] = '\u062B\u0645';
  22647. t['\uFCA7'] = '\u062C\u062D';
  22648. t['\uFCA8'] = '\u062C\u0645';
  22649. t['\uFCA9'] = '\u062D\u062C';
  22650. t['\uFCAA'] = '\u062D\u0645';
  22651. t['\uFCAB'] = '\u062E\u062C';
  22652. t['\uFCAC'] = '\u062E\u0645';
  22653. t['\uFCAD'] = '\u0633\u062C';
  22654. t['\uFCAE'] = '\u0633\u062D';
  22655. t['\uFCAF'] = '\u0633\u062E';
  22656. t['\uFCB0'] = '\u0633\u0645';
  22657. t['\uFCB1'] = '\u0635\u062D';
  22658. t['\uFCB2'] = '\u0635\u062E';
  22659. t['\uFCB3'] = '\u0635\u0645';
  22660. t['\uFCB4'] = '\u0636\u062C';
  22661. t['\uFCB5'] = '\u0636\u062D';
  22662. t['\uFCB6'] = '\u0636\u062E';
  22663. t['\uFCB7'] = '\u0636\u0645';
  22664. t['\uFCB8'] = '\u0637\u062D';
  22665. t['\uFCB9'] = '\u0638\u0645';
  22666. t['\uFCBA'] = '\u0639\u062C';
  22667. t['\uFCBB'] = '\u0639\u0645';
  22668. t['\uFCBC'] = '\u063A\u062C';
  22669. t['\uFCBD'] = '\u063A\u0645';
  22670. t['\uFCBE'] = '\u0641\u062C';
  22671. t['\uFCBF'] = '\u0641\u062D';
  22672. t['\uFCC0'] = '\u0641\u062E';
  22673. t['\uFCC1'] = '\u0641\u0645';
  22674. t['\uFCC2'] = '\u0642\u062D';
  22675. t['\uFCC3'] = '\u0642\u0645';
  22676. t['\uFCC4'] = '\u0643\u062C';
  22677. t['\uFCC5'] = '\u0643\u062D';
  22678. t['\uFCC6'] = '\u0643\u062E';
  22679. t['\uFCC7'] = '\u0643\u0644';
  22680. t['\uFCC8'] = '\u0643\u0645';
  22681. t['\uFCC9'] = '\u0644\u062C';
  22682. t['\uFCCA'] = '\u0644\u062D';
  22683. t['\uFCCB'] = '\u0644\u062E';
  22684. t['\uFCCC'] = '\u0644\u0645';
  22685. t['\uFCCD'] = '\u0644\u0647';
  22686. t['\uFCCE'] = '\u0645\u062C';
  22687. t['\uFCCF'] = '\u0645\u062D';
  22688. t['\uFCD0'] = '\u0645\u062E';
  22689. t['\uFCD1'] = '\u0645\u0645';
  22690. t['\uFCD2'] = '\u0646\u062C';
  22691. t['\uFCD3'] = '\u0646\u062D';
  22692. t['\uFCD4'] = '\u0646\u062E';
  22693. t['\uFCD5'] = '\u0646\u0645';
  22694. t['\uFCD6'] = '\u0646\u0647';
  22695. t['\uFCD7'] = '\u0647\u062C';
  22696. t['\uFCD8'] = '\u0647\u0645';
  22697. t['\uFCD9'] = '\u0647\u0670';
  22698. t['\uFCDA'] = '\u064A\u062C';
  22699. t['\uFCDB'] = '\u064A\u062D';
  22700. t['\uFCDC'] = '\u064A\u062E';
  22701. t['\uFCDD'] = '\u064A\u0645';
  22702. t['\uFCDE'] = '\u064A\u0647';
  22703. t['\uFCDF'] = '\u0626\u0645';
  22704. t['\uFCE0'] = '\u0626\u0647';
  22705. t['\uFCE1'] = '\u0628\u0645';
  22706. t['\uFCE2'] = '\u0628\u0647';
  22707. t['\uFCE3'] = '\u062A\u0645';
  22708. t['\uFCE4'] = '\u062A\u0647';
  22709. t['\uFCE5'] = '\u062B\u0645';
  22710. t['\uFCE6'] = '\u062B\u0647';
  22711. t['\uFCE7'] = '\u0633\u0645';
  22712. t['\uFCE8'] = '\u0633\u0647';
  22713. t['\uFCE9'] = '\u0634\u0645';
  22714. t['\uFCEA'] = '\u0634\u0647';
  22715. t['\uFCEB'] = '\u0643\u0644';
  22716. t['\uFCEC'] = '\u0643\u0645';
  22717. t['\uFCED'] = '\u0644\u0645';
  22718. t['\uFCEE'] = '\u0646\u0645';
  22719. t['\uFCEF'] = '\u0646\u0647';
  22720. t['\uFCF0'] = '\u064A\u0645';
  22721. t['\uFCF1'] = '\u064A\u0647';
  22722. t['\uFCF2'] = '\u0640\u064E\u0651';
  22723. t['\uFCF3'] = '\u0640\u064F\u0651';
  22724. t['\uFCF4'] = '\u0640\u0650\u0651';
  22725. t['\uFCF5'] = '\u0637\u0649';
  22726. t['\uFCF6'] = '\u0637\u064A';
  22727. t['\uFCF7'] = '\u0639\u0649';
  22728. t['\uFCF8'] = '\u0639\u064A';
  22729. t['\uFCF9'] = '\u063A\u0649';
  22730. t['\uFCFA'] = '\u063A\u064A';
  22731. t['\uFCFB'] = '\u0633\u0649';
  22732. t['\uFCFC'] = '\u0633\u064A';
  22733. t['\uFCFD'] = '\u0634\u0649';
  22734. t['\uFCFE'] = '\u0634\u064A';
  22735. t['\uFCFF'] = '\u062D\u0649';
  22736. t['\uFD00'] = '\u062D\u064A';
  22737. t['\uFD01'] = '\u062C\u0649';
  22738. t['\uFD02'] = '\u062C\u064A';
  22739. t['\uFD03'] = '\u062E\u0649';
  22740. t['\uFD04'] = '\u062E\u064A';
  22741. t['\uFD05'] = '\u0635\u0649';
  22742. t['\uFD06'] = '\u0635\u064A';
  22743. t['\uFD07'] = '\u0636\u0649';
  22744. t['\uFD08'] = '\u0636\u064A';
  22745. t['\uFD09'] = '\u0634\u062C';
  22746. t['\uFD0A'] = '\u0634\u062D';
  22747. t['\uFD0B'] = '\u0634\u062E';
  22748. t['\uFD0C'] = '\u0634\u0645';
  22749. t['\uFD0D'] = '\u0634\u0631';
  22750. t['\uFD0E'] = '\u0633\u0631';
  22751. t['\uFD0F'] = '\u0635\u0631';
  22752. t['\uFD10'] = '\u0636\u0631';
  22753. t['\uFD11'] = '\u0637\u0649';
  22754. t['\uFD12'] = '\u0637\u064A';
  22755. t['\uFD13'] = '\u0639\u0649';
  22756. t['\uFD14'] = '\u0639\u064A';
  22757. t['\uFD15'] = '\u063A\u0649';
  22758. t['\uFD16'] = '\u063A\u064A';
  22759. t['\uFD17'] = '\u0633\u0649';
  22760. t['\uFD18'] = '\u0633\u064A';
  22761. t['\uFD19'] = '\u0634\u0649';
  22762. t['\uFD1A'] = '\u0634\u064A';
  22763. t['\uFD1B'] = '\u062D\u0649';
  22764. t['\uFD1C'] = '\u062D\u064A';
  22765. t['\uFD1D'] = '\u062C\u0649';
  22766. t['\uFD1E'] = '\u062C\u064A';
  22767. t['\uFD1F'] = '\u062E\u0649';
  22768. t['\uFD20'] = '\u062E\u064A';
  22769. t['\uFD21'] = '\u0635\u0649';
  22770. t['\uFD22'] = '\u0635\u064A';
  22771. t['\uFD23'] = '\u0636\u0649';
  22772. t['\uFD24'] = '\u0636\u064A';
  22773. t['\uFD25'] = '\u0634\u062C';
  22774. t['\uFD26'] = '\u0634\u062D';
  22775. t['\uFD27'] = '\u0634\u062E';
  22776. t['\uFD28'] = '\u0634\u0645';
  22777. t['\uFD29'] = '\u0634\u0631';
  22778. t['\uFD2A'] = '\u0633\u0631';
  22779. t['\uFD2B'] = '\u0635\u0631';
  22780. t['\uFD2C'] = '\u0636\u0631';
  22781. t['\uFD2D'] = '\u0634\u062C';
  22782. t['\uFD2E'] = '\u0634\u062D';
  22783. t['\uFD2F'] = '\u0634\u062E';
  22784. t['\uFD30'] = '\u0634\u0645';
  22785. t['\uFD31'] = '\u0633\u0647';
  22786. t['\uFD32'] = '\u0634\u0647';
  22787. t['\uFD33'] = '\u0637\u0645';
  22788. t['\uFD34'] = '\u0633\u062C';
  22789. t['\uFD35'] = '\u0633\u062D';
  22790. t['\uFD36'] = '\u0633\u062E';
  22791. t['\uFD37'] = '\u0634\u062C';
  22792. t['\uFD38'] = '\u0634\u062D';
  22793. t['\uFD39'] = '\u0634\u062E';
  22794. t['\uFD3A'] = '\u0637\u0645';
  22795. t['\uFD3B'] = '\u0638\u0645';
  22796. t['\uFD3C'] = '\u0627\u064B';
  22797. t['\uFD3D'] = '\u0627\u064B';
  22798. t['\uFD50'] = '\u062A\u062C\u0645';
  22799. t['\uFD51'] = '\u062A\u062D\u062C';
  22800. t['\uFD52'] = '\u062A\u062D\u062C';
  22801. t['\uFD53'] = '\u062A\u062D\u0645';
  22802. t['\uFD54'] = '\u062A\u062E\u0645';
  22803. t['\uFD55'] = '\u062A\u0645\u062C';
  22804. t['\uFD56'] = '\u062A\u0645\u062D';
  22805. t['\uFD57'] = '\u062A\u0645\u062E';
  22806. t['\uFD58'] = '\u062C\u0645\u062D';
  22807. t['\uFD59'] = '\u062C\u0645\u062D';
  22808. t['\uFD5A'] = '\u062D\u0645\u064A';
  22809. t['\uFD5B'] = '\u062D\u0645\u0649';
  22810. t['\uFD5C'] = '\u0633\u062D\u062C';
  22811. t['\uFD5D'] = '\u0633\u062C\u062D';
  22812. t['\uFD5E'] = '\u0633\u062C\u0649';
  22813. t['\uFD5F'] = '\u0633\u0645\u062D';
  22814. t['\uFD60'] = '\u0633\u0645\u062D';
  22815. t['\uFD61'] = '\u0633\u0645\u062C';
  22816. t['\uFD62'] = '\u0633\u0645\u0645';
  22817. t['\uFD63'] = '\u0633\u0645\u0645';
  22818. t['\uFD64'] = '\u0635\u062D\u062D';
  22819. t['\uFD65'] = '\u0635\u062D\u062D';
  22820. t['\uFD66'] = '\u0635\u0645\u0645';
  22821. t['\uFD67'] = '\u0634\u062D\u0645';
  22822. t['\uFD68'] = '\u0634\u062D\u0645';
  22823. t['\uFD69'] = '\u0634\u062C\u064A';
  22824. t['\uFD6A'] = '\u0634\u0645\u062E';
  22825. t['\uFD6B'] = '\u0634\u0645\u062E';
  22826. t['\uFD6C'] = '\u0634\u0645\u0645';
  22827. t['\uFD6D'] = '\u0634\u0645\u0645';
  22828. t['\uFD6E'] = '\u0636\u062D\u0649';
  22829. t['\uFD6F'] = '\u0636\u062E\u0645';
  22830. t['\uFD70'] = '\u0636\u062E\u0645';
  22831. t['\uFD71'] = '\u0637\u0645\u062D';
  22832. t['\uFD72'] = '\u0637\u0645\u062D';
  22833. t['\uFD73'] = '\u0637\u0645\u0645';
  22834. t['\uFD74'] = '\u0637\u0645\u064A';
  22835. t['\uFD75'] = '\u0639\u062C\u0645';
  22836. t['\uFD76'] = '\u0639\u0645\u0645';
  22837. t['\uFD77'] = '\u0639\u0645\u0645';
  22838. t['\uFD78'] = '\u0639\u0645\u0649';
  22839. t['\uFD79'] = '\u063A\u0645\u0645';
  22840. t['\uFD7A'] = '\u063A\u0645\u064A';
  22841. t['\uFD7B'] = '\u063A\u0645\u0649';
  22842. t['\uFD7C'] = '\u0641\u062E\u0645';
  22843. t['\uFD7D'] = '\u0641\u062E\u0645';
  22844. t['\uFD7E'] = '\u0642\u0645\u062D';
  22845. t['\uFD7F'] = '\u0642\u0645\u0645';
  22846. t['\uFD80'] = '\u0644\u062D\u0645';
  22847. t['\uFD81'] = '\u0644\u062D\u064A';
  22848. t['\uFD82'] = '\u0644\u062D\u0649';
  22849. t['\uFD83'] = '\u0644\u062C\u062C';
  22850. t['\uFD84'] = '\u0644\u062C\u062C';
  22851. t['\uFD85'] = '\u0644\u062E\u0645';
  22852. t['\uFD86'] = '\u0644\u062E\u0645';
  22853. t['\uFD87'] = '\u0644\u0645\u062D';
  22854. t['\uFD88'] = '\u0644\u0645\u062D';
  22855. t['\uFD89'] = '\u0645\u062D\u062C';
  22856. t['\uFD8A'] = '\u0645\u062D\u0645';
  22857. t['\uFD8B'] = '\u0645\u062D\u064A';
  22858. t['\uFD8C'] = '\u0645\u062C\u062D';
  22859. t['\uFD8D'] = '\u0645\u062C\u0645';
  22860. t['\uFD8E'] = '\u0645\u062E\u062C';
  22861. t['\uFD8F'] = '\u0645\u062E\u0645';
  22862. t['\uFD92'] = '\u0645\u062C\u062E';
  22863. t['\uFD93'] = '\u0647\u0645\u062C';
  22864. t['\uFD94'] = '\u0647\u0645\u0645';
  22865. t['\uFD95'] = '\u0646\u062D\u0645';
  22866. t['\uFD96'] = '\u0646\u062D\u0649';
  22867. t['\uFD97'] = '\u0646\u062C\u0645';
  22868. t['\uFD98'] = '\u0646\u062C\u0645';
  22869. t['\uFD99'] = '\u0646\u062C\u0649';
  22870. t['\uFD9A'] = '\u0646\u0645\u064A';
  22871. t['\uFD9B'] = '\u0646\u0645\u0649';
  22872. t['\uFD9C'] = '\u064A\u0645\u0645';
  22873. t['\uFD9D'] = '\u064A\u0645\u0645';
  22874. t['\uFD9E'] = '\u0628\u062E\u064A';
  22875. t['\uFD9F'] = '\u062A\u062C\u064A';
  22876. t['\uFDA0'] = '\u062A\u062C\u0649';
  22877. t['\uFDA1'] = '\u062A\u062E\u064A';
  22878. t['\uFDA2'] = '\u062A\u062E\u0649';
  22879. t['\uFDA3'] = '\u062A\u0645\u064A';
  22880. t['\uFDA4'] = '\u062A\u0645\u0649';
  22881. t['\uFDA5'] = '\u062C\u0645\u064A';
  22882. t['\uFDA6'] = '\u062C\u062D\u0649';
  22883. t['\uFDA7'] = '\u062C\u0645\u0649';
  22884. t['\uFDA8'] = '\u0633\u062E\u0649';
  22885. t['\uFDA9'] = '\u0635\u062D\u064A';
  22886. t['\uFDAA'] = '\u0634\u062D\u064A';
  22887. t['\uFDAB'] = '\u0636\u062D\u064A';
  22888. t['\uFDAC'] = '\u0644\u062C\u064A';
  22889. t['\uFDAD'] = '\u0644\u0645\u064A';
  22890. t['\uFDAE'] = '\u064A\u062D\u064A';
  22891. t['\uFDAF'] = '\u064A\u062C\u064A';
  22892. t['\uFDB0'] = '\u064A\u0645\u064A';
  22893. t['\uFDB1'] = '\u0645\u0645\u064A';
  22894. t['\uFDB2'] = '\u0642\u0645\u064A';
  22895. t['\uFDB3'] = '\u0646\u062D\u064A';
  22896. t['\uFDB4'] = '\u0642\u0645\u062D';
  22897. t['\uFDB5'] = '\u0644\u062D\u0645';
  22898. t['\uFDB6'] = '\u0639\u0645\u064A';
  22899. t['\uFDB7'] = '\u0643\u0645\u064A';
  22900. t['\uFDB8'] = '\u0646\u062C\u062D';
  22901. t['\uFDB9'] = '\u0645\u062E\u064A';
  22902. t['\uFDBA'] = '\u0644\u062C\u0645';
  22903. t['\uFDBB'] = '\u0643\u0645\u0645';
  22904. t['\uFDBC'] = '\u0644\u062C\u0645';
  22905. t['\uFDBD'] = '\u0646\u062C\u062D';
  22906. t['\uFDBE'] = '\u062C\u062D\u064A';
  22907. t['\uFDBF'] = '\u062D\u062C\u064A';
  22908. t['\uFDC0'] = '\u0645\u062C\u064A';
  22909. t['\uFDC1'] = '\u0641\u0645\u064A';
  22910. t['\uFDC2'] = '\u0628\u062D\u064A';
  22911. t['\uFDC3'] = '\u0643\u0645\u0645';
  22912. t['\uFDC4'] = '\u0639\u062C\u0645';
  22913. t['\uFDC5'] = '\u0635\u0645\u0645';
  22914. t['\uFDC6'] = '\u0633\u062E\u064A';
  22915. t['\uFDC7'] = '\u0646\u062C\u064A';
  22916. t['\uFE49'] = '\u203E';
  22917. t['\uFE4A'] = '\u203E';
  22918. t['\uFE4B'] = '\u203E';
  22919. t['\uFE4C'] = '\u203E';
  22920. t['\uFE4D'] = '\u005F';
  22921. t['\uFE4E'] = '\u005F';
  22922. t['\uFE4F'] = '\u005F';
  22923. t['\uFE80'] = '\u0621';
  22924. t['\uFE81'] = '\u0622';
  22925. t['\uFE82'] = '\u0622';
  22926. t['\uFE83'] = '\u0623';
  22927. t['\uFE84'] = '\u0623';
  22928. t['\uFE85'] = '\u0624';
  22929. t['\uFE86'] = '\u0624';
  22930. t['\uFE87'] = '\u0625';
  22931. t['\uFE88'] = '\u0625';
  22932. t['\uFE89'] = '\u0626';
  22933. t['\uFE8A'] = '\u0626';
  22934. t['\uFE8B'] = '\u0626';
  22935. t['\uFE8C'] = '\u0626';
  22936. t['\uFE8D'] = '\u0627';
  22937. t['\uFE8E'] = '\u0627';
  22938. t['\uFE8F'] = '\u0628';
  22939. t['\uFE90'] = '\u0628';
  22940. t['\uFE91'] = '\u0628';
  22941. t['\uFE92'] = '\u0628';
  22942. t['\uFE93'] = '\u0629';
  22943. t['\uFE94'] = '\u0629';
  22944. t['\uFE95'] = '\u062A';
  22945. t['\uFE96'] = '\u062A';
  22946. t['\uFE97'] = '\u062A';
  22947. t['\uFE98'] = '\u062A';
  22948. t['\uFE99'] = '\u062B';
  22949. t['\uFE9A'] = '\u062B';
  22950. t['\uFE9B'] = '\u062B';
  22951. t['\uFE9C'] = '\u062B';
  22952. t['\uFE9D'] = '\u062C';
  22953. t['\uFE9E'] = '\u062C';
  22954. t['\uFE9F'] = '\u062C';
  22955. t['\uFEA0'] = '\u062C';
  22956. t['\uFEA1'] = '\u062D';
  22957. t['\uFEA2'] = '\u062D';
  22958. t['\uFEA3'] = '\u062D';
  22959. t['\uFEA4'] = '\u062D';
  22960. t['\uFEA5'] = '\u062E';
  22961. t['\uFEA6'] = '\u062E';
  22962. t['\uFEA7'] = '\u062E';
  22963. t['\uFEA8'] = '\u062E';
  22964. t['\uFEA9'] = '\u062F';
  22965. t['\uFEAA'] = '\u062F';
  22966. t['\uFEAB'] = '\u0630';
  22967. t['\uFEAC'] = '\u0630';
  22968. t['\uFEAD'] = '\u0631';
  22969. t['\uFEAE'] = '\u0631';
  22970. t['\uFEAF'] = '\u0632';
  22971. t['\uFEB0'] = '\u0632';
  22972. t['\uFEB1'] = '\u0633';
  22973. t['\uFEB2'] = '\u0633';
  22974. t['\uFEB3'] = '\u0633';
  22975. t['\uFEB4'] = '\u0633';
  22976. t['\uFEB5'] = '\u0634';
  22977. t['\uFEB6'] = '\u0634';
  22978. t['\uFEB7'] = '\u0634';
  22979. t['\uFEB8'] = '\u0634';
  22980. t['\uFEB9'] = '\u0635';
  22981. t['\uFEBA'] = '\u0635';
  22982. t['\uFEBB'] = '\u0635';
  22983. t['\uFEBC'] = '\u0635';
  22984. t['\uFEBD'] = '\u0636';
  22985. t['\uFEBE'] = '\u0636';
  22986. t['\uFEBF'] = '\u0636';
  22987. t['\uFEC0'] = '\u0636';
  22988. t['\uFEC1'] = '\u0637';
  22989. t['\uFEC2'] = '\u0637';
  22990. t['\uFEC3'] = '\u0637';
  22991. t['\uFEC4'] = '\u0637';
  22992. t['\uFEC5'] = '\u0638';
  22993. t['\uFEC6'] = '\u0638';
  22994. t['\uFEC7'] = '\u0638';
  22995. t['\uFEC8'] = '\u0638';
  22996. t['\uFEC9'] = '\u0639';
  22997. t['\uFECA'] = '\u0639';
  22998. t['\uFECB'] = '\u0639';
  22999. t['\uFECC'] = '\u0639';
  23000. t['\uFECD'] = '\u063A';
  23001. t['\uFECE'] = '\u063A';
  23002. t['\uFECF'] = '\u063A';
  23003. t['\uFED0'] = '\u063A';
  23004. t['\uFED1'] = '\u0641';
  23005. t['\uFED2'] = '\u0641';
  23006. t['\uFED3'] = '\u0641';
  23007. t['\uFED4'] = '\u0641';
  23008. t['\uFED5'] = '\u0642';
  23009. t['\uFED6'] = '\u0642';
  23010. t['\uFED7'] = '\u0642';
  23011. t['\uFED8'] = '\u0642';
  23012. t['\uFED9'] = '\u0643';
  23013. t['\uFEDA'] = '\u0643';
  23014. t['\uFEDB'] = '\u0643';
  23015. t['\uFEDC'] = '\u0643';
  23016. t['\uFEDD'] = '\u0644';
  23017. t['\uFEDE'] = '\u0644';
  23018. t['\uFEDF'] = '\u0644';
  23019. t['\uFEE0'] = '\u0644';
  23020. t['\uFEE1'] = '\u0645';
  23021. t['\uFEE2'] = '\u0645';
  23022. t['\uFEE3'] = '\u0645';
  23023. t['\uFEE4'] = '\u0645';
  23024. t['\uFEE5'] = '\u0646';
  23025. t['\uFEE6'] = '\u0646';
  23026. t['\uFEE7'] = '\u0646';
  23027. t['\uFEE8'] = '\u0646';
  23028. t['\uFEE9'] = '\u0647';
  23029. t['\uFEEA'] = '\u0647';
  23030. t['\uFEEB'] = '\u0647';
  23031. t['\uFEEC'] = '\u0647';
  23032. t['\uFEED'] = '\u0648';
  23033. t['\uFEEE'] = '\u0648';
  23034. t['\uFEEF'] = '\u0649';
  23035. t['\uFEF0'] = '\u0649';
  23036. t['\uFEF1'] = '\u064A';
  23037. t['\uFEF2'] = '\u064A';
  23038. t['\uFEF3'] = '\u064A';
  23039. t['\uFEF4'] = '\u064A';
  23040. t['\uFEF5'] = '\u0644\u0622';
  23041. t['\uFEF6'] = '\u0644\u0622';
  23042. t['\uFEF7'] = '\u0644\u0623';
  23043. t['\uFEF8'] = '\u0644\u0623';
  23044. t['\uFEF9'] = '\u0644\u0625';
  23045. t['\uFEFA'] = '\u0644\u0625';
  23046. t['\uFEFB'] = '\u0644\u0627';
  23047. t['\uFEFC'] = '\u0644\u0627';
  23048. });
  23049. function reverseIfRtl(chars) {
  23050. var charsLength = chars.length;
  23051. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  23052. return chars;
  23053. }
  23054. var s = '';
  23055. for (var ii = charsLength - 1; ii >= 0; ii--) {
  23056. s += chars[ii];
  23057. }
  23058. return s;
  23059. }
  23060. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  23061. exports.reverseIfRtl = reverseIfRtl;
  23062. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  23063. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  23064. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  23065. }));
  23066. (function (root, factory) {
  23067. factory(root.pdfjsDisplayDOMUtils = {}, root.pdfjsSharedUtil);
  23068. }(this, function (exports, sharedUtil) {
  23069. var removeNullCharacters = sharedUtil.removeNullCharacters;
  23070. var warn = sharedUtil.warn;
  23071. var deprecated = sharedUtil.deprecated;
  23072. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  23073. var CustomStyle = function CustomStyleClosure() {
  23074. var prefixes = [
  23075. 'ms',
  23076. 'Moz',
  23077. 'Webkit',
  23078. 'O'
  23079. ];
  23080. var _cache = Object.create(null);
  23081. function CustomStyle() {
  23082. }
  23083. CustomStyle.getProp = function get(propName, element) {
  23084. if (arguments.length === 1 && typeof _cache[propName] === 'string') {
  23085. return _cache[propName];
  23086. }
  23087. element = element || document.documentElement;
  23088. var style = element.style, prefixed, uPropName;
  23089. if (typeof style[propName] === 'string') {
  23090. return _cache[propName] = propName;
  23091. }
  23092. uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
  23093. for (var i = 0, l = prefixes.length; i < l; i++) {
  23094. prefixed = prefixes[i] + uPropName;
  23095. if (typeof style[prefixed] === 'string') {
  23096. return _cache[propName] = prefixed;
  23097. }
  23098. }
  23099. return _cache[propName] = 'undefined';
  23100. };
  23101. CustomStyle.setProp = function set(propName, element, str) {
  23102. var prop = this.getProp(propName);
  23103. if (prop !== 'undefined') {
  23104. element.style[prop] = str;
  23105. }
  23106. };
  23107. return CustomStyle;
  23108. }();
  23109. var hasCanvasTypedArrays;
  23110. hasCanvasTypedArrays = function hasCanvasTypedArrays() {
  23111. var canvas = document.createElement('canvas');
  23112. canvas.width = canvas.height = 1;
  23113. var ctx = canvas.getContext('2d');
  23114. var imageData = ctx.createImageData(1, 1);
  23115. return typeof imageData.data.buffer !== 'undefined';
  23116. };
  23117. var LinkTarget = {
  23118. NONE: 0,
  23119. SELF: 1,
  23120. BLANK: 2,
  23121. PARENT: 3,
  23122. TOP: 4
  23123. };
  23124. var LinkTargetStringMap = [
  23125. '',
  23126. '_self',
  23127. '_blank',
  23128. '_parent',
  23129. '_top'
  23130. ];
  23131. function addLinkAttributes(link, params) {
  23132. var url = params && params.url;
  23133. link.href = link.title = url ? removeNullCharacters(url) : '';
  23134. if (url) {
  23135. var target = params.target;
  23136. if (typeof target === 'undefined') {
  23137. target = getDefaultSetting('externalLinkTarget');
  23138. }
  23139. link.target = LinkTargetStringMap[target];
  23140. var rel = params.rel;
  23141. if (typeof rel === 'undefined') {
  23142. rel = getDefaultSetting('externalLinkRel');
  23143. }
  23144. link.rel = rel;
  23145. }
  23146. }
  23147. function getFilenameFromUrl(url) {
  23148. var anchor = url.indexOf('#');
  23149. var query = url.indexOf('?');
  23150. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  23151. return url.substring(url.lastIndexOf('/', end) + 1, end);
  23152. }
  23153. function getDefaultSetting(id) {
  23154. var globalSettings = sharedUtil.globalScope.PDFJS;
  23155. switch (id) {
  23156. case 'pdfBug':
  23157. return globalSettings ? globalSettings.pdfBug : false;
  23158. case 'disableAutoFetch':
  23159. return globalSettings ? globalSettings.disableAutoFetch : false;
  23160. case 'disableStream':
  23161. return globalSettings ? globalSettings.disableStream : false;
  23162. case 'disableRange':
  23163. return globalSettings ? globalSettings.disableRange : false;
  23164. case 'disableFontFace':
  23165. return globalSettings ? globalSettings.disableFontFace : false;
  23166. case 'disableCreateObjectURL':
  23167. return globalSettings ? globalSettings.disableCreateObjectURL : false;
  23168. case 'disableWebGL':
  23169. return globalSettings ? globalSettings.disableWebGL : true;
  23170. case 'cMapUrl':
  23171. return globalSettings ? globalSettings.cMapUrl : null;
  23172. case 'cMapPacked':
  23173. return globalSettings ? globalSettings.cMapPacked : false;
  23174. case 'postMessageTransfers':
  23175. return globalSettings ? globalSettings.postMessageTransfers : true;
  23176. case 'workerSrc':
  23177. return globalSettings ? globalSettings.workerSrc : null;
  23178. case 'disableWorker':
  23179. return globalSettings ? globalSettings.disableWorker : false;
  23180. case 'maxImageSize':
  23181. return globalSettings ? globalSettings.maxImageSize : -1;
  23182. case 'imageResourcesPath':
  23183. return globalSettings ? globalSettings.imageResourcesPath : '';
  23184. case 'isEvalSupported':
  23185. return globalSettings ? globalSettings.isEvalSupported : true;
  23186. case 'externalLinkTarget':
  23187. if (!globalSettings) {
  23188. return LinkTarget.NONE;
  23189. }
  23190. switch (globalSettings.externalLinkTarget) {
  23191. case LinkTarget.NONE:
  23192. case LinkTarget.SELF:
  23193. case LinkTarget.BLANK:
  23194. case LinkTarget.PARENT:
  23195. case LinkTarget.TOP:
  23196. return globalSettings.externalLinkTarget;
  23197. }
  23198. warn('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
  23199. globalSettings.externalLinkTarget = LinkTarget.NONE;
  23200. return LinkTarget.NONE;
  23201. case 'externalLinkRel':
  23202. return globalSettings ? globalSettings.externalLinkRel : 'noreferrer';
  23203. case 'enableStats':
  23204. return !!(globalSettings && globalSettings.enableStats);
  23205. default:
  23206. throw new Error('Unknown default setting: ' + id);
  23207. }
  23208. }
  23209. function isExternalLinkTargetSet() {
  23210. var externalLinkTarget = getDefaultSetting('externalLinkTarget');
  23211. switch (externalLinkTarget) {
  23212. case LinkTarget.NONE:
  23213. return false;
  23214. case LinkTarget.SELF:
  23215. case LinkTarget.BLANK:
  23216. case LinkTarget.PARENT:
  23217. case LinkTarget.TOP:
  23218. return true;
  23219. }
  23220. }
  23221. function isValidUrl(url, allowRelative) {
  23222. deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.');
  23223. var baseUrl = allowRelative ? 'http://example.com' : null;
  23224. return createValidAbsoluteUrl(url, baseUrl) !== null;
  23225. }
  23226. exports.CustomStyle = CustomStyle;
  23227. exports.addLinkAttributes = addLinkAttributes;
  23228. exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
  23229. exports.isValidUrl = isValidUrl;
  23230. exports.getFilenameFromUrl = getFilenameFromUrl;
  23231. exports.LinkTarget = LinkTarget;
  23232. exports.hasCanvasTypedArrays = hasCanvasTypedArrays;
  23233. exports.getDefaultSetting = getDefaultSetting;
  23234. }));
  23235. (function (root, factory) {
  23236. factory(root.pdfjsDisplayFontLoader = {}, root.pdfjsSharedUtil);
  23237. }(this, function (exports, sharedUtil) {
  23238. var assert = sharedUtil.assert;
  23239. var bytesToString = sharedUtil.bytesToString;
  23240. var string32 = sharedUtil.string32;
  23241. var shadow = sharedUtil.shadow;
  23242. var warn = sharedUtil.warn;
  23243. function FontLoader(docId) {
  23244. this.docId = docId;
  23245. this.styleElement = null;
  23246. this.nativeFontFaces = [];
  23247. this.loadTestFontId = 0;
  23248. this.loadingContext = {
  23249. requests: [],
  23250. nextRequestId: 0
  23251. };
  23252. }
  23253. FontLoader.prototype = {
  23254. insertRule: function fontLoaderInsertRule(rule) {
  23255. var styleElement = this.styleElement;
  23256. if (!styleElement) {
  23257. styleElement = this.styleElement = document.createElement('style');
  23258. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  23259. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  23260. }
  23261. var styleSheet = styleElement.sheet;
  23262. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  23263. },
  23264. clear: function fontLoaderClear() {
  23265. var styleElement = this.styleElement;
  23266. if (styleElement) {
  23267. styleElement.parentNode.removeChild(styleElement);
  23268. styleElement = this.styleElement = null;
  23269. }
  23270. this.nativeFontFaces.forEach(function (nativeFontFace) {
  23271. document.fonts.delete(nativeFontFace);
  23272. });
  23273. this.nativeFontFaces.length = 0;
  23274. }
  23275. };
  23276. var getLoadTestFont = function () {
  23277. 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==');
  23278. };
  23279. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  23280. get: function () {
  23281. return shadow(this, 'loadTestFont', getLoadTestFont());
  23282. },
  23283. configurable: true
  23284. });
  23285. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  23286. this.nativeFontFaces.push(nativeFontFace);
  23287. document.fonts.add(nativeFontFace);
  23288. };
  23289. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  23290. var rules = [];
  23291. var fontsToLoad = [];
  23292. var fontLoadPromises = [];
  23293. var getNativeFontPromise = function (nativeFontFace) {
  23294. return nativeFontFace.loaded.catch(function (e) {
  23295. warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
  23296. });
  23297. };
  23298. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  23299. for (var i = 0, ii = fonts.length; i < ii; i++) {
  23300. var font = fonts[i];
  23301. if (font.attached || font.loading === false) {
  23302. continue;
  23303. }
  23304. font.attached = true;
  23305. if (isFontLoadingAPISupported) {
  23306. var nativeFontFace = font.createNativeFontFace();
  23307. if (nativeFontFace) {
  23308. this.addNativeFontFace(nativeFontFace);
  23309. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  23310. }
  23311. } else {
  23312. var rule = font.createFontFaceRule();
  23313. if (rule) {
  23314. this.insertRule(rule);
  23315. rules.push(rule);
  23316. fontsToLoad.push(font);
  23317. }
  23318. }
  23319. }
  23320. var request = this.queueLoadingCallback(callback);
  23321. if (isFontLoadingAPISupported) {
  23322. Promise.all(fontLoadPromises).then(function () {
  23323. request.complete();
  23324. });
  23325. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  23326. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  23327. } else {
  23328. request.complete();
  23329. }
  23330. };
  23331. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  23332. function LoadLoader_completeRequest() {
  23333. assert(!request.end, 'completeRequest() cannot be called twice');
  23334. request.end = Date.now();
  23335. while (context.requests.length > 0 && context.requests[0].end) {
  23336. var otherRequest = context.requests.shift();
  23337. setTimeout(otherRequest.callback, 0);
  23338. }
  23339. }
  23340. var context = this.loadingContext;
  23341. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  23342. var request = {
  23343. id: requestId,
  23344. complete: LoadLoader_completeRequest,
  23345. callback: callback,
  23346. started: Date.now()
  23347. };
  23348. context.requests.push(request);
  23349. return request;
  23350. };
  23351. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  23352. function int32(data, offset) {
  23353. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  23354. }
  23355. function spliceString(s, offset, remove, insert) {
  23356. var chunk1 = s.substr(0, offset);
  23357. var chunk2 = s.substr(offset + remove);
  23358. return chunk1 + insert + chunk2;
  23359. }
  23360. var i, ii;
  23361. var canvas = document.createElement('canvas');
  23362. canvas.width = 1;
  23363. canvas.height = 1;
  23364. var ctx = canvas.getContext('2d');
  23365. var called = 0;
  23366. function isFontReady(name, callback) {
  23367. called++;
  23368. if (called > 30) {
  23369. warn('Load test font never loaded.');
  23370. callback();
  23371. return;
  23372. }
  23373. ctx.font = '30px ' + name;
  23374. ctx.fillText('.', 0, 20);
  23375. var imageData = ctx.getImageData(0, 0, 1, 1);
  23376. if (imageData.data[3] > 0) {
  23377. callback();
  23378. return;
  23379. }
  23380. setTimeout(isFontReady.bind(null, name, callback));
  23381. }
  23382. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  23383. var data = this.loadTestFont;
  23384. var COMMENT_OFFSET = 976;
  23385. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  23386. var CFF_CHECKSUM_OFFSET = 16;
  23387. var XXXX_VALUE = 0x58585858;
  23388. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  23389. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  23390. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  23391. }
  23392. if (i < loadTestFontId.length) {
  23393. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  23394. }
  23395. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
  23396. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  23397. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  23398. this.insertRule(rule);
  23399. var names = [];
  23400. for (i = 0, ii = fonts.length; i < ii; i++) {
  23401. names.push(fonts[i].loadedName);
  23402. }
  23403. names.push(loadTestFontId);
  23404. var div = document.createElement('div');
  23405. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  23406. for (i = 0, ii = names.length; i < ii; ++i) {
  23407. var span = document.createElement('span');
  23408. span.textContent = 'Hi';
  23409. span.style.fontFamily = names[i];
  23410. div.appendChild(span);
  23411. }
  23412. document.body.appendChild(div);
  23413. isFontReady(loadTestFontId, function () {
  23414. document.body.removeChild(div);
  23415. request.complete();
  23416. });
  23417. };
  23418. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  23419. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  23420. if (typeof navigator === 'undefined') {
  23421. return true;
  23422. }
  23423. var supported = false;
  23424. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  23425. if (m && m[1] >= 14) {
  23426. supported = true;
  23427. }
  23428. return supported;
  23429. };
  23430. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  23431. get: function () {
  23432. return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  23433. },
  23434. enumerable: true,
  23435. configurable: true
  23436. });
  23437. var IsEvalSupportedCached = {
  23438. get value() {
  23439. return shadow(this, 'value', sharedUtil.isEvalSupported());
  23440. }
  23441. };
  23442. var FontFaceObject = function FontFaceObjectClosure() {
  23443. function FontFaceObject(translatedData, options) {
  23444. this.compiledGlyphs = Object.create(null);
  23445. for (var i in translatedData) {
  23446. this[i] = translatedData[i];
  23447. }
  23448. this.options = options;
  23449. }
  23450. FontFaceObject.prototype = {
  23451. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  23452. if (!this.data) {
  23453. return null;
  23454. }
  23455. if (this.options.disableFontFace) {
  23456. this.disableFontFace = true;
  23457. return null;
  23458. }
  23459. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  23460. if (this.options.fontRegistry) {
  23461. this.options.fontRegistry.registerFont(this);
  23462. }
  23463. return nativeFontFace;
  23464. },
  23465. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  23466. if (!this.data) {
  23467. return null;
  23468. }
  23469. if (this.options.disableFontFace) {
  23470. this.disableFontFace = true;
  23471. return null;
  23472. }
  23473. var data = bytesToString(new Uint8Array(this.data));
  23474. var fontName = this.loadedName;
  23475. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  23476. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  23477. if (this.options.fontRegistry) {
  23478. this.options.fontRegistry.registerFont(this, url);
  23479. }
  23480. return rule;
  23481. },
  23482. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  23483. if (!(character in this.compiledGlyphs)) {
  23484. var cmds = objs.get(this.loadedName + '_path_' + character);
  23485. var current, i, len;
  23486. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  23487. var args, js = '';
  23488. for (i = 0, len = cmds.length; i < len; i++) {
  23489. current = cmds[i];
  23490. if (current.args !== undefined) {
  23491. args = current.args.join(',');
  23492. } else {
  23493. args = '';
  23494. }
  23495. js += 'c.' + current.cmd + '(' + args + ');\n';
  23496. }
  23497. this.compiledGlyphs[character] = new Function('c', 'size', js);
  23498. } else {
  23499. this.compiledGlyphs[character] = function (c, size) {
  23500. for (i = 0, len = cmds.length; i < len; i++) {
  23501. current = cmds[i];
  23502. if (current.cmd === 'scale') {
  23503. current.args = [
  23504. size,
  23505. -size
  23506. ];
  23507. }
  23508. c[current.cmd].apply(c, current.args);
  23509. }
  23510. };
  23511. }
  23512. }
  23513. return this.compiledGlyphs[character];
  23514. }
  23515. };
  23516. return FontFaceObject;
  23517. }();
  23518. exports.FontFaceObject = FontFaceObject;
  23519. exports.FontLoader = FontLoader;
  23520. }));
  23521. (function (root, factory) {
  23522. factory(root.pdfjsDisplayMetadata = {}, root.pdfjsSharedUtil);
  23523. }(this, function (exports, sharedUtil) {
  23524. var error = sharedUtil.error;
  23525. function fixMetadata(meta) {
  23526. return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  23527. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  23528. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  23529. });
  23530. var chars = '';
  23531. for (var i = 0; i < bytes.length; i += 2) {
  23532. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  23533. chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 && false ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  23534. }
  23535. return '>' + chars;
  23536. });
  23537. }
  23538. function Metadata(meta) {
  23539. if (typeof meta === 'string') {
  23540. meta = fixMetadata(meta);
  23541. var parser = new DOMParser();
  23542. meta = parser.parseFromString(meta, 'application/xml');
  23543. } else if (!(meta instanceof Document)) {
  23544. error('Metadata: Invalid metadata object');
  23545. }
  23546. this.metaDocument = meta;
  23547. this.metadata = Object.create(null);
  23548. this.parse();
  23549. }
  23550. Metadata.prototype = {
  23551. parse: function Metadata_parse() {
  23552. var doc = this.metaDocument;
  23553. var rdf = doc.documentElement;
  23554. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  23555. rdf = rdf.firstChild;
  23556. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  23557. rdf = rdf.nextSibling;
  23558. }
  23559. }
  23560. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  23561. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  23562. return;
  23563. }
  23564. var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
  23565. for (i = 0, length = children.length; i < length; i++) {
  23566. desc = children[i];
  23567. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  23568. continue;
  23569. }
  23570. for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
  23571. if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
  23572. entry = desc.childNodes[ii];
  23573. name = entry.nodeName.toLowerCase();
  23574. this.metadata[name] = entry.textContent.trim();
  23575. }
  23576. }
  23577. }
  23578. },
  23579. get: function Metadata_get(name) {
  23580. return this.metadata[name] || null;
  23581. },
  23582. has: function Metadata_has(name) {
  23583. return typeof this.metadata[name] !== 'undefined';
  23584. }
  23585. };
  23586. exports.Metadata = Metadata;
  23587. }));
  23588. (function (root, factory) {
  23589. factory(root.pdfjsDisplaySVG = {}, root.pdfjsSharedUtil);
  23590. }(this, function (exports, sharedUtil) {
  23591. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  23592. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  23593. var ImageKind = sharedUtil.ImageKind;
  23594. var OPS = sharedUtil.OPS;
  23595. var Util = sharedUtil.Util;
  23596. var isNum = sharedUtil.isNum;
  23597. var isArray = sharedUtil.isArray;
  23598. var warn = sharedUtil.warn;
  23599. var createObjectURL = sharedUtil.createObjectURL;
  23600. var SVG_DEFAULTS = {
  23601. fontStyle: 'normal',
  23602. fontWeight: 'normal',
  23603. fillColor: '#000000'
  23604. };
  23605. var convertImgDataToPng = function convertImgDataToPngClosure() {
  23606. var PNG_HEADER = new Uint8Array([
  23607. 0x89,
  23608. 0x50,
  23609. 0x4e,
  23610. 0x47,
  23611. 0x0d,
  23612. 0x0a,
  23613. 0x1a,
  23614. 0x0a
  23615. ]);
  23616. var CHUNK_WRAPPER_SIZE = 12;
  23617. var crcTable = new Int32Array(256);
  23618. for (var i = 0; i < 256; i++) {
  23619. var c = i;
  23620. for (var h = 0; h < 8; h++) {
  23621. if (c & 1) {
  23622. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  23623. } else {
  23624. c = c >> 1 & 0x7fffffff;
  23625. }
  23626. }
  23627. crcTable[i] = c;
  23628. }
  23629. function crc32(data, start, end) {
  23630. var crc = -1;
  23631. for (var i = start; i < end; i++) {
  23632. var a = (crc ^ data[i]) & 0xff;
  23633. var b = crcTable[a];
  23634. crc = crc >>> 8 ^ b;
  23635. }
  23636. return crc ^ -1;
  23637. }
  23638. function writePngChunk(type, body, data, offset) {
  23639. var p = offset;
  23640. var len = body.length;
  23641. data[p] = len >> 24 & 0xff;
  23642. data[p + 1] = len >> 16 & 0xff;
  23643. data[p + 2] = len >> 8 & 0xff;
  23644. data[p + 3] = len & 0xff;
  23645. p += 4;
  23646. data[p] = type.charCodeAt(0) & 0xff;
  23647. data[p + 1] = type.charCodeAt(1) & 0xff;
  23648. data[p + 2] = type.charCodeAt(2) & 0xff;
  23649. data[p + 3] = type.charCodeAt(3) & 0xff;
  23650. p += 4;
  23651. data.set(body, p);
  23652. p += body.length;
  23653. var crc = crc32(data, offset + 4, p);
  23654. data[p] = crc >> 24 & 0xff;
  23655. data[p + 1] = crc >> 16 & 0xff;
  23656. data[p + 2] = crc >> 8 & 0xff;
  23657. data[p + 3] = crc & 0xff;
  23658. }
  23659. function adler32(data, start, end) {
  23660. var a = 1;
  23661. var b = 0;
  23662. for (var i = start; i < end; ++i) {
  23663. a = (a + (data[i] & 0xff)) % 65521;
  23664. b = (b + a) % 65521;
  23665. }
  23666. return b << 16 | a;
  23667. }
  23668. function encode(imgData, kind, forceDataSchema) {
  23669. var width = imgData.width;
  23670. var height = imgData.height;
  23671. var bitDepth, colorType, lineSize;
  23672. var bytes = imgData.data;
  23673. switch (kind) {
  23674. case ImageKind.GRAYSCALE_1BPP:
  23675. colorType = 0;
  23676. bitDepth = 1;
  23677. lineSize = width + 7 >> 3;
  23678. break;
  23679. case ImageKind.RGB_24BPP:
  23680. colorType = 2;
  23681. bitDepth = 8;
  23682. lineSize = width * 3;
  23683. break;
  23684. case ImageKind.RGBA_32BPP:
  23685. colorType = 6;
  23686. bitDepth = 8;
  23687. lineSize = width * 4;
  23688. break;
  23689. default:
  23690. throw new Error('invalid format');
  23691. }
  23692. var literals = new Uint8Array((1 + lineSize) * height);
  23693. var offsetLiterals = 0, offsetBytes = 0;
  23694. var y, i;
  23695. for (y = 0; y < height; ++y) {
  23696. literals[offsetLiterals++] = 0;
  23697. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  23698. offsetBytes += lineSize;
  23699. offsetLiterals += lineSize;
  23700. }
  23701. if (kind === ImageKind.GRAYSCALE_1BPP) {
  23702. offsetLiterals = 0;
  23703. for (y = 0; y < height; y++) {
  23704. offsetLiterals++;
  23705. for (i = 0; i < lineSize; i++) {
  23706. literals[offsetLiterals++] ^= 0xFF;
  23707. }
  23708. }
  23709. }
  23710. var ihdr = new Uint8Array([
  23711. width >> 24 & 0xff,
  23712. width >> 16 & 0xff,
  23713. width >> 8 & 0xff,
  23714. width & 0xff,
  23715. height >> 24 & 0xff,
  23716. height >> 16 & 0xff,
  23717. height >> 8 & 0xff,
  23718. height & 0xff,
  23719. bitDepth,
  23720. colorType,
  23721. 0x00,
  23722. 0x00,
  23723. 0x00
  23724. ]);
  23725. var len = literals.length;
  23726. var maxBlockLength = 0xFFFF;
  23727. var deflateBlocks = Math.ceil(len / maxBlockLength);
  23728. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  23729. var pi = 0;
  23730. idat[pi++] = 0x78;
  23731. idat[pi++] = 0x9c;
  23732. var pos = 0;
  23733. while (len > maxBlockLength) {
  23734. idat[pi++] = 0x00;
  23735. idat[pi++] = 0xff;
  23736. idat[pi++] = 0xff;
  23737. idat[pi++] = 0x00;
  23738. idat[pi++] = 0x00;
  23739. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  23740. pi += maxBlockLength;
  23741. pos += maxBlockLength;
  23742. len -= maxBlockLength;
  23743. }
  23744. idat[pi++] = 0x01;
  23745. idat[pi++] = len & 0xff;
  23746. idat[pi++] = len >> 8 & 0xff;
  23747. idat[pi++] = ~len & 0xffff & 0xff;
  23748. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  23749. idat.set(literals.subarray(pos), pi);
  23750. pi += literals.length - pos;
  23751. var adler = adler32(literals, 0, literals.length);
  23752. idat[pi++] = adler >> 24 & 0xff;
  23753. idat[pi++] = adler >> 16 & 0xff;
  23754. idat[pi++] = adler >> 8 & 0xff;
  23755. idat[pi++] = adler & 0xff;
  23756. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  23757. var data = new Uint8Array(pngLength);
  23758. var offset = 0;
  23759. data.set(PNG_HEADER, offset);
  23760. offset += PNG_HEADER.length;
  23761. writePngChunk('IHDR', ihdr, data, offset);
  23762. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  23763. writePngChunk('IDATA', idat, data, offset);
  23764. offset += CHUNK_WRAPPER_SIZE + idat.length;
  23765. writePngChunk('IEND', new Uint8Array(0), data, offset);
  23766. return createObjectURL(data, 'image/png', forceDataSchema);
  23767. }
  23768. return function convertImgDataToPng(imgData, forceDataSchema) {
  23769. var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind;
  23770. return encode(imgData, kind, forceDataSchema);
  23771. };
  23772. }();
  23773. var SVGExtraState = function SVGExtraStateClosure() {
  23774. function SVGExtraState() {
  23775. this.fontSizeScale = 1;
  23776. this.fontWeight = SVG_DEFAULTS.fontWeight;
  23777. this.fontSize = 0;
  23778. this.textMatrix = IDENTITY_MATRIX;
  23779. this.fontMatrix = FONT_IDENTITY_MATRIX;
  23780. this.leading = 0;
  23781. this.x = 0;
  23782. this.y = 0;
  23783. this.lineX = 0;
  23784. this.lineY = 0;
  23785. this.charSpacing = 0;
  23786. this.wordSpacing = 0;
  23787. this.textHScale = 1;
  23788. this.textRise = 0;
  23789. this.fillColor = SVG_DEFAULTS.fillColor;
  23790. this.strokeColor = '#000000';
  23791. this.fillAlpha = 1;
  23792. this.strokeAlpha = 1;
  23793. this.lineWidth = 1;
  23794. this.lineJoin = '';
  23795. this.lineCap = '';
  23796. this.miterLimit = 0;
  23797. this.dashArray = [];
  23798. this.dashPhase = 0;
  23799. this.dependencies = [];
  23800. this.activeClipUrl = null;
  23801. this.clipGroup = null;
  23802. this.maskId = '';
  23803. }
  23804. SVGExtraState.prototype = {
  23805. clone: function SVGExtraState_clone() {
  23806. return Object.create(this);
  23807. },
  23808. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  23809. this.x = x;
  23810. this.y = y;
  23811. }
  23812. };
  23813. return SVGExtraState;
  23814. }();
  23815. var SVGGraphics = function SVGGraphicsClosure() {
  23816. function opListToTree(opList) {
  23817. var opTree = [];
  23818. var tmp = [];
  23819. var opListLen = opList.length;
  23820. for (var x = 0; x < opListLen; x++) {
  23821. if (opList[x].fn === 'save') {
  23822. opTree.push({
  23823. 'fnId': 92,
  23824. 'fn': 'group',
  23825. 'items': []
  23826. });
  23827. tmp.push(opTree);
  23828. opTree = opTree[opTree.length - 1].items;
  23829. continue;
  23830. }
  23831. if (opList[x].fn === 'restore') {
  23832. opTree = tmp.pop();
  23833. } else {
  23834. opTree.push(opList[x]);
  23835. }
  23836. }
  23837. return opTree;
  23838. }
  23839. function pf(value) {
  23840. if (value === (value | 0)) {
  23841. return value.toString();
  23842. }
  23843. var s = value.toFixed(10);
  23844. var i = s.length - 1;
  23845. if (s[i] !== '0') {
  23846. return s;
  23847. }
  23848. do {
  23849. i--;
  23850. } while (s[i] === '0');
  23851. return s.substr(0, s[i] === '.' ? i : i + 1);
  23852. }
  23853. function pm(m) {
  23854. if (m[4] === 0 && m[5] === 0) {
  23855. if (m[1] === 0 && m[2] === 0) {
  23856. if (m[0] === 1 && m[3] === 1) {
  23857. return '';
  23858. }
  23859. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  23860. }
  23861. if (m[0] === m[3] && m[1] === -m[2]) {
  23862. var a = Math.acos(m[0]) * 180 / Math.PI;
  23863. return 'rotate(' + pf(a) + ')';
  23864. }
  23865. } else {
  23866. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  23867. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  23868. }
  23869. }
  23870. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  23871. }
  23872. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  23873. this.current = new SVGExtraState();
  23874. this.transformMatrix = IDENTITY_MATRIX;
  23875. this.transformStack = [];
  23876. this.extraStack = [];
  23877. this.commonObjs = commonObjs;
  23878. this.objs = objs;
  23879. this.pendingEOFill = false;
  23880. this.embedFonts = false;
  23881. this.embeddedFonts = Object.create(null);
  23882. this.cssStyle = null;
  23883. this.forceDataSchema = !!forceDataSchema;
  23884. }
  23885. var NS = 'http://www.w3.org/2000/svg';
  23886. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  23887. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  23888. var LINE_CAP_STYLES = [
  23889. 'butt',
  23890. 'round',
  23891. 'square'
  23892. ];
  23893. var LINE_JOIN_STYLES = [
  23894. 'miter',
  23895. 'round',
  23896. 'bevel'
  23897. ];
  23898. var clipCount = 0;
  23899. var maskCount = 0;
  23900. SVGGraphics.prototype = {
  23901. save: function SVGGraphics_save() {
  23902. this.transformStack.push(this.transformMatrix);
  23903. var old = this.current;
  23904. this.extraStack.push(old);
  23905. this.current = old.clone();
  23906. },
  23907. restore: function SVGGraphics_restore() {
  23908. this.transformMatrix = this.transformStack.pop();
  23909. this.current = this.extraStack.pop();
  23910. this.tgrp = null;
  23911. },
  23912. group: function SVGGraphics_group(items) {
  23913. this.save();
  23914. this.executeOpTree(items);
  23915. this.restore();
  23916. },
  23917. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  23918. var fnArray = operatorList.fnArray;
  23919. var fnArrayLen = fnArray.length;
  23920. var argsArray = operatorList.argsArray;
  23921. var self = this;
  23922. for (var i = 0; i < fnArrayLen; i++) {
  23923. if (OPS.dependency === fnArray[i]) {
  23924. var deps = argsArray[i];
  23925. for (var n = 0, nn = deps.length; n < nn; n++) {
  23926. var obj = deps[n];
  23927. var common = obj.substring(0, 2) === 'g_';
  23928. var promise;
  23929. if (common) {
  23930. promise = new Promise(function (resolve) {
  23931. self.commonObjs.get(obj, resolve);
  23932. });
  23933. } else {
  23934. promise = new Promise(function (resolve) {
  23935. self.objs.get(obj, resolve);
  23936. });
  23937. }
  23938. this.current.dependencies.push(promise);
  23939. }
  23940. }
  23941. }
  23942. return Promise.all(this.current.dependencies);
  23943. },
  23944. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  23945. var transformMatrix = [
  23946. a,
  23947. b,
  23948. c,
  23949. d,
  23950. e,
  23951. f
  23952. ];
  23953. this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix);
  23954. this.tgrp = null;
  23955. },
  23956. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  23957. this.viewport = viewport;
  23958. var svgElement = this._initialize(viewport);
  23959. return this.loadDependencies(operatorList).then(function () {
  23960. this.transformMatrix = IDENTITY_MATRIX;
  23961. var opTree = this.convertOpList(operatorList);
  23962. this.executeOpTree(opTree);
  23963. return svgElement;
  23964. }.bind(this));
  23965. },
  23966. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  23967. var argsArray = operatorList.argsArray;
  23968. var fnArray = operatorList.fnArray;
  23969. var fnArrayLen = fnArray.length;
  23970. var REVOPS = [];
  23971. var opList = [];
  23972. for (var op in OPS) {
  23973. REVOPS[OPS[op]] = op;
  23974. }
  23975. for (var x = 0; x < fnArrayLen; x++) {
  23976. var fnId = fnArray[x];
  23977. opList.push({
  23978. 'fnId': fnId,
  23979. 'fn': REVOPS[fnId],
  23980. 'args': argsArray[x]
  23981. });
  23982. }
  23983. return opListToTree(opList);
  23984. },
  23985. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  23986. var opTreeLen = opTree.length;
  23987. for (var x = 0; x < opTreeLen; x++) {
  23988. var fn = opTree[x].fn;
  23989. var fnId = opTree[x].fnId;
  23990. var args = opTree[x].args;
  23991. switch (fnId | 0) {
  23992. case OPS.beginText:
  23993. this.beginText();
  23994. break;
  23995. case OPS.setLeading:
  23996. this.setLeading(args);
  23997. break;
  23998. case OPS.setLeadingMoveText:
  23999. this.setLeadingMoveText(args[0], args[1]);
  24000. break;
  24001. case OPS.setFont:
  24002. this.setFont(args);
  24003. break;
  24004. case OPS.showText:
  24005. this.showText(args[0]);
  24006. break;
  24007. case OPS.showSpacedText:
  24008. this.showText(args[0]);
  24009. break;
  24010. case OPS.endText:
  24011. this.endText();
  24012. break;
  24013. case OPS.moveText:
  24014. this.moveText(args[0], args[1]);
  24015. break;
  24016. case OPS.setCharSpacing:
  24017. this.setCharSpacing(args[0]);
  24018. break;
  24019. case OPS.setWordSpacing:
  24020. this.setWordSpacing(args[0]);
  24021. break;
  24022. case OPS.setHScale:
  24023. this.setHScale(args[0]);
  24024. break;
  24025. case OPS.setTextMatrix:
  24026. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  24027. break;
  24028. case OPS.setLineWidth:
  24029. this.setLineWidth(args[0]);
  24030. break;
  24031. case OPS.setLineJoin:
  24032. this.setLineJoin(args[0]);
  24033. break;
  24034. case OPS.setLineCap:
  24035. this.setLineCap(args[0]);
  24036. break;
  24037. case OPS.setMiterLimit:
  24038. this.setMiterLimit(args[0]);
  24039. break;
  24040. case OPS.setFillRGBColor:
  24041. this.setFillRGBColor(args[0], args[1], args[2]);
  24042. break;
  24043. case OPS.setStrokeRGBColor:
  24044. this.setStrokeRGBColor(args[0], args[1], args[2]);
  24045. break;
  24046. case OPS.setDash:
  24047. this.setDash(args[0], args[1]);
  24048. break;
  24049. case OPS.setGState:
  24050. this.setGState(args[0]);
  24051. break;
  24052. case OPS.fill:
  24053. this.fill();
  24054. break;
  24055. case OPS.eoFill:
  24056. this.eoFill();
  24057. break;
  24058. case OPS.stroke:
  24059. this.stroke();
  24060. break;
  24061. case OPS.fillStroke:
  24062. this.fillStroke();
  24063. break;
  24064. case OPS.eoFillStroke:
  24065. this.eoFillStroke();
  24066. break;
  24067. case OPS.clip:
  24068. this.clip('nonzero');
  24069. break;
  24070. case OPS.eoClip:
  24071. this.clip('evenodd');
  24072. break;
  24073. case OPS.paintSolidColorImageMask:
  24074. this.paintSolidColorImageMask();
  24075. break;
  24076. case OPS.paintJpegXObject:
  24077. this.paintJpegXObject(args[0], args[1], args[2]);
  24078. break;
  24079. case OPS.paintImageXObject:
  24080. this.paintImageXObject(args[0]);
  24081. break;
  24082. case OPS.paintInlineImageXObject:
  24083. this.paintInlineImageXObject(args[0]);
  24084. break;
  24085. case OPS.paintImageMaskXObject:
  24086. this.paintImageMaskXObject(args[0]);
  24087. break;
  24088. case OPS.paintFormXObjectBegin:
  24089. this.paintFormXObjectBegin(args[0], args[1]);
  24090. break;
  24091. case OPS.paintFormXObjectEnd:
  24092. this.paintFormXObjectEnd();
  24093. break;
  24094. case OPS.closePath:
  24095. this.closePath();
  24096. break;
  24097. case OPS.closeStroke:
  24098. this.closeStroke();
  24099. break;
  24100. case OPS.closeFillStroke:
  24101. this.closeFillStroke();
  24102. break;
  24103. case OPS.nextLine:
  24104. this.nextLine();
  24105. break;
  24106. case OPS.transform:
  24107. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  24108. break;
  24109. case OPS.constructPath:
  24110. this.constructPath(args[0], args[1]);
  24111. break;
  24112. case OPS.endPath:
  24113. this.endPath();
  24114. break;
  24115. case 92:
  24116. this.group(opTree[x].items);
  24117. break;
  24118. default:
  24119. warn('Unimplemented operator ' + fn);
  24120. break;
  24121. }
  24122. }
  24123. },
  24124. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  24125. this.current.wordSpacing = wordSpacing;
  24126. },
  24127. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  24128. this.current.charSpacing = charSpacing;
  24129. },
  24130. nextLine: function SVGGraphics_nextLine() {
  24131. this.moveText(0, this.current.leading);
  24132. },
  24133. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  24134. var current = this.current;
  24135. this.current.textMatrix = this.current.lineMatrix = [
  24136. a,
  24137. b,
  24138. c,
  24139. d,
  24140. e,
  24141. f
  24142. ];
  24143. this.current.x = this.current.lineX = 0;
  24144. this.current.y = this.current.lineY = 0;
  24145. current.xcoords = [];
  24146. current.tspan = document.createElementNS(NS, 'svg:tspan');
  24147. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  24148. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  24149. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24150. current.txtElement = document.createElementNS(NS, 'svg:text');
  24151. current.txtElement.appendChild(current.tspan);
  24152. },
  24153. beginText: function SVGGraphics_beginText() {
  24154. this.current.x = this.current.lineX = 0;
  24155. this.current.y = this.current.lineY = 0;
  24156. this.current.textMatrix = IDENTITY_MATRIX;
  24157. this.current.lineMatrix = IDENTITY_MATRIX;
  24158. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  24159. this.current.txtElement = document.createElementNS(NS, 'svg:text');
  24160. this.current.txtgrp = document.createElementNS(NS, 'svg:g');
  24161. this.current.xcoords = [];
  24162. },
  24163. moveText: function SVGGraphics_moveText(x, y) {
  24164. var current = this.current;
  24165. this.current.x = this.current.lineX += x;
  24166. this.current.y = this.current.lineY += y;
  24167. current.xcoords = [];
  24168. current.tspan = document.createElementNS(NS, 'svg:tspan');
  24169. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  24170. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  24171. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24172. },
  24173. showText: function SVGGraphics_showText(glyphs) {
  24174. var current = this.current;
  24175. var font = current.font;
  24176. var fontSize = current.fontSize;
  24177. if (fontSize === 0) {
  24178. return;
  24179. }
  24180. var charSpacing = current.charSpacing;
  24181. var wordSpacing = current.wordSpacing;
  24182. var fontDirection = current.fontDirection;
  24183. var textHScale = current.textHScale * fontDirection;
  24184. var glyphsLength = glyphs.length;
  24185. var vertical = font.vertical;
  24186. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  24187. var x = 0, i;
  24188. for (i = 0; i < glyphsLength; ++i) {
  24189. var glyph = glyphs[i];
  24190. if (glyph === null) {
  24191. x += fontDirection * wordSpacing;
  24192. continue;
  24193. } else if (isNum(glyph)) {
  24194. x += -glyph * fontSize * 0.001;
  24195. continue;
  24196. }
  24197. current.xcoords.push(current.x + x * textHScale);
  24198. var width = glyph.width;
  24199. var character = glyph.fontChar;
  24200. var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
  24201. x += charWidth;
  24202. current.tspan.textContent += character;
  24203. }
  24204. if (vertical) {
  24205. current.y -= x * textHScale;
  24206. } else {
  24207. current.x += x * textHScale;
  24208. }
  24209. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  24210. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24211. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  24212. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  24213. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  24214. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  24215. }
  24216. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  24217. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  24218. }
  24219. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  24220. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  24221. }
  24222. current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)');
  24223. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  24224. current.txtElement.appendChild(current.tspan);
  24225. current.txtgrp.appendChild(current.txtElement);
  24226. this._ensureTransformGroup().appendChild(current.txtElement);
  24227. },
  24228. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  24229. this.setLeading(-y);
  24230. this.moveText(x, y);
  24231. },
  24232. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  24233. if (!this.cssStyle) {
  24234. this.cssStyle = document.createElementNS(NS, 'svg:style');
  24235. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  24236. this.defs.appendChild(this.cssStyle);
  24237. }
  24238. var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  24239. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  24240. },
  24241. setFont: function SVGGraphics_setFont(details) {
  24242. var current = this.current;
  24243. var fontObj = this.commonObjs.get(details[0]);
  24244. var size = details[1];
  24245. this.current.font = fontObj;
  24246. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  24247. this.addFontStyle(fontObj);
  24248. this.embeddedFonts[fontObj.loadedName] = fontObj;
  24249. }
  24250. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  24251. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  24252. var italic = fontObj.italic ? 'italic' : 'normal';
  24253. if (size < 0) {
  24254. size = -size;
  24255. current.fontDirection = -1;
  24256. } else {
  24257. current.fontDirection = 1;
  24258. }
  24259. current.fontSize = size;
  24260. current.fontFamily = fontObj.loadedName;
  24261. current.fontWeight = bold;
  24262. current.fontStyle = italic;
  24263. current.tspan = document.createElementNS(NS, 'svg:tspan');
  24264. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24265. current.xcoords = [];
  24266. },
  24267. endText: function SVGGraphics_endText() {
  24268. },
  24269. setLineWidth: function SVGGraphics_setLineWidth(width) {
  24270. this.current.lineWidth = width;
  24271. },
  24272. setLineCap: function SVGGraphics_setLineCap(style) {
  24273. this.current.lineCap = LINE_CAP_STYLES[style];
  24274. },
  24275. setLineJoin: function SVGGraphics_setLineJoin(style) {
  24276. this.current.lineJoin = LINE_JOIN_STYLES[style];
  24277. },
  24278. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  24279. this.current.miterLimit = limit;
  24280. },
  24281. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  24282. var color = Util.makeCssRgb(r, g, b);
  24283. this.current.strokeColor = color;
  24284. },
  24285. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  24286. var color = Util.makeCssRgb(r, g, b);
  24287. this.current.fillColor = color;
  24288. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  24289. this.current.xcoords = [];
  24290. },
  24291. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  24292. this.current.dashArray = dashArray;
  24293. this.current.dashPhase = dashPhase;
  24294. },
  24295. constructPath: function SVGGraphics_constructPath(ops, args) {
  24296. var current = this.current;
  24297. var x = current.x, y = current.y;
  24298. current.path = document.createElementNS(NS, 'svg:path');
  24299. var d = [];
  24300. var opLength = ops.length;
  24301. for (var i = 0, j = 0; i < opLength; i++) {
  24302. switch (ops[i] | 0) {
  24303. case OPS.rectangle:
  24304. x = args[j++];
  24305. y = args[j++];
  24306. var width = args[j++];
  24307. var height = args[j++];
  24308. var xw = x + width;
  24309. var yh = y + height;
  24310. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  24311. break;
  24312. case OPS.moveTo:
  24313. x = args[j++];
  24314. y = args[j++];
  24315. d.push('M', pf(x), pf(y));
  24316. break;
  24317. case OPS.lineTo:
  24318. x = args[j++];
  24319. y = args[j++];
  24320. d.push('L', pf(x), pf(y));
  24321. break;
  24322. case OPS.curveTo:
  24323. x = args[j + 4];
  24324. y = args[j + 5];
  24325. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  24326. j += 6;
  24327. break;
  24328. case OPS.curveTo2:
  24329. x = args[j + 2];
  24330. y = args[j + 3];
  24331. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  24332. j += 4;
  24333. break;
  24334. case OPS.curveTo3:
  24335. x = args[j + 2];
  24336. y = args[j + 3];
  24337. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  24338. j += 4;
  24339. break;
  24340. case OPS.closePath:
  24341. d.push('Z');
  24342. break;
  24343. }
  24344. }
  24345. current.path.setAttributeNS(null, 'd', d.join(' '));
  24346. current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  24347. current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  24348. current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  24349. current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  24350. current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  24351. current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  24352. current.path.setAttributeNS(null, 'fill', 'none');
  24353. this._ensureTransformGroup().appendChild(current.path);
  24354. current.element = current.path;
  24355. current.setCurrentPoint(x, y);
  24356. },
  24357. endPath: function SVGGraphics_endPath() {
  24358. },
  24359. clip: function SVGGraphics_clip(type) {
  24360. var current = this.current;
  24361. var clipId = 'clippath' + clipCount;
  24362. clipCount++;
  24363. var clipPath = document.createElementNS(NS, 'svg:clipPath');
  24364. clipPath.setAttributeNS(null, 'id', clipId);
  24365. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  24366. var clipElement = current.element.cloneNode();
  24367. if (type === 'evenodd') {
  24368. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  24369. } else {
  24370. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  24371. }
  24372. clipPath.appendChild(clipElement);
  24373. this.defs.appendChild(clipPath);
  24374. if (current.activeClipUrl) {
  24375. current.clipGroup = null;
  24376. this.extraStack.forEach(function (prev) {
  24377. prev.clipGroup = null;
  24378. });
  24379. }
  24380. current.activeClipUrl = 'url(#' + clipId + ')';
  24381. this.tgrp = null;
  24382. },
  24383. closePath: function SVGGraphics_closePath() {
  24384. var current = this.current;
  24385. var d = current.path.getAttributeNS(null, 'd');
  24386. d += 'Z';
  24387. current.path.setAttributeNS(null, 'd', d);
  24388. },
  24389. setLeading: function SVGGraphics_setLeading(leading) {
  24390. this.current.leading = -leading;
  24391. },
  24392. setTextRise: function SVGGraphics_setTextRise(textRise) {
  24393. this.current.textRise = textRise;
  24394. },
  24395. setHScale: function SVGGraphics_setHScale(scale) {
  24396. this.current.textHScale = scale / 100;
  24397. },
  24398. setGState: function SVGGraphics_setGState(states) {
  24399. for (var i = 0, ii = states.length; i < ii; i++) {
  24400. var state = states[i];
  24401. var key = state[0];
  24402. var value = state[1];
  24403. switch (key) {
  24404. case 'LW':
  24405. this.setLineWidth(value);
  24406. break;
  24407. case 'LC':
  24408. this.setLineCap(value);
  24409. break;
  24410. case 'LJ':
  24411. this.setLineJoin(value);
  24412. break;
  24413. case 'ML':
  24414. this.setMiterLimit(value);
  24415. break;
  24416. case 'D':
  24417. this.setDash(value[0], value[1]);
  24418. break;
  24419. case 'Font':
  24420. this.setFont(value);
  24421. break;
  24422. default:
  24423. warn('Unimplemented graphic state ' + key);
  24424. break;
  24425. }
  24426. }
  24427. },
  24428. fill: function SVGGraphics_fill() {
  24429. var current = this.current;
  24430. current.element.setAttributeNS(null, 'fill', current.fillColor);
  24431. },
  24432. stroke: function SVGGraphics_stroke() {
  24433. var current = this.current;
  24434. current.element.setAttributeNS(null, 'stroke', current.strokeColor);
  24435. current.element.setAttributeNS(null, 'fill', 'none');
  24436. },
  24437. eoFill: function SVGGraphics_eoFill() {
  24438. var current = this.current;
  24439. current.element.setAttributeNS(null, 'fill', current.fillColor);
  24440. current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  24441. },
  24442. fillStroke: function SVGGraphics_fillStroke() {
  24443. this.stroke();
  24444. this.fill();
  24445. },
  24446. eoFillStroke: function SVGGraphics_eoFillStroke() {
  24447. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  24448. this.fillStroke();
  24449. },
  24450. closeStroke: function SVGGraphics_closeStroke() {
  24451. this.closePath();
  24452. this.stroke();
  24453. },
  24454. closeFillStroke: function SVGGraphics_closeFillStroke() {
  24455. this.closePath();
  24456. this.fillStroke();
  24457. },
  24458. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  24459. var current = this.current;
  24460. var rect = document.createElementNS(NS, 'svg:rect');
  24461. rect.setAttributeNS(null, 'x', '0');
  24462. rect.setAttributeNS(null, 'y', '0');
  24463. rect.setAttributeNS(null, 'width', '1px');
  24464. rect.setAttributeNS(null, 'height', '1px');
  24465. rect.setAttributeNS(null, 'fill', current.fillColor);
  24466. this._ensureTransformGroup().appendChild(rect);
  24467. },
  24468. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  24469. var imgObj = this.objs.get(objId);
  24470. var imgEl = document.createElementNS(NS, 'svg:image');
  24471. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  24472. imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
  24473. imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
  24474. imgEl.setAttributeNS(null, 'x', '0');
  24475. imgEl.setAttributeNS(null, 'y', pf(-h));
  24476. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  24477. this._ensureTransformGroup().appendChild(imgEl);
  24478. },
  24479. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  24480. var imgData = this.objs.get(objId);
  24481. if (!imgData) {
  24482. warn('Dependent image isn\'t ready yet');
  24483. return;
  24484. }
  24485. this.paintInlineImageXObject(imgData);
  24486. },
  24487. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  24488. var width = imgData.width;
  24489. var height = imgData.height;
  24490. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
  24491. var cliprect = document.createElementNS(NS, 'svg:rect');
  24492. cliprect.setAttributeNS(null, 'x', '0');
  24493. cliprect.setAttributeNS(null, 'y', '0');
  24494. cliprect.setAttributeNS(null, 'width', pf(width));
  24495. cliprect.setAttributeNS(null, 'height', pf(height));
  24496. this.current.element = cliprect;
  24497. this.clip('nonzero');
  24498. var imgEl = document.createElementNS(NS, 'svg:image');
  24499. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  24500. imgEl.setAttributeNS(null, 'x', '0');
  24501. imgEl.setAttributeNS(null, 'y', pf(-height));
  24502. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  24503. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  24504. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  24505. if (mask) {
  24506. mask.appendChild(imgEl);
  24507. } else {
  24508. this._ensureTransformGroup().appendChild(imgEl);
  24509. }
  24510. },
  24511. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  24512. var current = this.current;
  24513. var width = imgData.width;
  24514. var height = imgData.height;
  24515. var fillColor = current.fillColor;
  24516. current.maskId = 'mask' + maskCount++;
  24517. var mask = document.createElementNS(NS, 'svg:mask');
  24518. mask.setAttributeNS(null, 'id', current.maskId);
  24519. var rect = document.createElementNS(NS, 'svg:rect');
  24520. rect.setAttributeNS(null, 'x', '0');
  24521. rect.setAttributeNS(null, 'y', '0');
  24522. rect.setAttributeNS(null, 'width', pf(width));
  24523. rect.setAttributeNS(null, 'height', pf(height));
  24524. rect.setAttributeNS(null, 'fill', fillColor);
  24525. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  24526. this.defs.appendChild(mask);
  24527. this._ensureTransformGroup().appendChild(rect);
  24528. this.paintInlineImageXObject(imgData, mask);
  24529. },
  24530. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  24531. if (isArray(matrix) && matrix.length === 6) {
  24532. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  24533. }
  24534. if (isArray(bbox) && bbox.length === 4) {
  24535. var width = bbox[2] - bbox[0];
  24536. var height = bbox[3] - bbox[1];
  24537. var cliprect = document.createElementNS(NS, 'svg:rect');
  24538. cliprect.setAttributeNS(null, 'x', bbox[0]);
  24539. cliprect.setAttributeNS(null, 'y', bbox[1]);
  24540. cliprect.setAttributeNS(null, 'width', pf(width));
  24541. cliprect.setAttributeNS(null, 'height', pf(height));
  24542. this.current.element = cliprect;
  24543. this.clip('nonzero');
  24544. this.endPath();
  24545. }
  24546. },
  24547. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {
  24548. },
  24549. _initialize: function SVGGraphics_initialize(viewport) {
  24550. var svg = document.createElementNS(NS, 'svg:svg');
  24551. svg.setAttributeNS(null, 'version', '1.1');
  24552. svg.setAttributeNS(null, 'width', viewport.width + 'px');
  24553. svg.setAttributeNS(null, 'height', viewport.height + 'px');
  24554. svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
  24555. svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
  24556. var definitions = document.createElementNS(NS, 'svg:defs');
  24557. svg.appendChild(definitions);
  24558. this.defs = definitions;
  24559. var rootGroup = document.createElementNS(NS, 'svg:g');
  24560. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  24561. svg.appendChild(rootGroup);
  24562. this.svg = rootGroup;
  24563. return svg;
  24564. },
  24565. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  24566. if (!this.current.clipGroup) {
  24567. var clipGroup = document.createElementNS(NS, 'svg:g');
  24568. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  24569. this.svg.appendChild(clipGroup);
  24570. this.current.clipGroup = clipGroup;
  24571. }
  24572. return this.current.clipGroup;
  24573. },
  24574. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  24575. if (!this.tgrp) {
  24576. this.tgrp = document.createElementNS(NS, 'svg:g');
  24577. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  24578. if (this.current.activeClipUrl) {
  24579. this._ensureClipGroup().appendChild(this.tgrp);
  24580. } else {
  24581. this.svg.appendChild(this.tgrp);
  24582. }
  24583. }
  24584. return this.tgrp;
  24585. }
  24586. };
  24587. return SVGGraphics;
  24588. }();
  24589. exports.SVGGraphics = SVGGraphics;
  24590. }));
  24591. (function (root, factory) {
  24592. factory(root.pdfjsCoreStream = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreJbig2, root.pdfjsCoreJpg, root.pdfjsCoreJpx);
  24593. }(this, function (exports, sharedUtil, corePrimitives, coreJbig2, coreJpg, coreJpx) {
  24594. var Util = sharedUtil.Util;
  24595. var error = sharedUtil.error;
  24596. var info = sharedUtil.info;
  24597. var isInt = sharedUtil.isInt;
  24598. var isArray = sharedUtil.isArray;
  24599. var createObjectURL = sharedUtil.createObjectURL;
  24600. var shadow = sharedUtil.shadow;
  24601. var warn = sharedUtil.warn;
  24602. var isSpace = sharedUtil.isSpace;
  24603. var Dict = corePrimitives.Dict;
  24604. var isDict = corePrimitives.isDict;
  24605. var isStream = corePrimitives.isStream;
  24606. var Jbig2Image = coreJbig2.Jbig2Image;
  24607. var JpegImage = coreJpg.JpegImage;
  24608. var JpxImage = coreJpx.JpxImage;
  24609. var Stream = function StreamClosure() {
  24610. function Stream(arrayBuffer, start, length, dict) {
  24611. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  24612. this.start = start || 0;
  24613. this.pos = this.start;
  24614. this.end = start + length || this.bytes.length;
  24615. this.dict = dict;
  24616. }
  24617. Stream.prototype = {
  24618. get length() {
  24619. return this.end - this.start;
  24620. },
  24621. get isEmpty() {
  24622. return this.length === 0;
  24623. },
  24624. getByte: function Stream_getByte() {
  24625. if (this.pos >= this.end) {
  24626. return -1;
  24627. }
  24628. return this.bytes[this.pos++];
  24629. },
  24630. getUint16: function Stream_getUint16() {
  24631. var b0 = this.getByte();
  24632. var b1 = this.getByte();
  24633. if (b0 === -1 || b1 === -1) {
  24634. return -1;
  24635. }
  24636. return (b0 << 8) + b1;
  24637. },
  24638. getInt32: function Stream_getInt32() {
  24639. var b0 = this.getByte();
  24640. var b1 = this.getByte();
  24641. var b2 = this.getByte();
  24642. var b3 = this.getByte();
  24643. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  24644. },
  24645. getBytes: function Stream_getBytes(length) {
  24646. var bytes = this.bytes;
  24647. var pos = this.pos;
  24648. var strEnd = this.end;
  24649. if (!length) {
  24650. return bytes.subarray(pos, strEnd);
  24651. }
  24652. var end = pos + length;
  24653. if (end > strEnd) {
  24654. end = strEnd;
  24655. }
  24656. this.pos = end;
  24657. return bytes.subarray(pos, end);
  24658. },
  24659. peekByte: function Stream_peekByte() {
  24660. var peekedByte = this.getByte();
  24661. this.pos--;
  24662. return peekedByte;
  24663. },
  24664. peekBytes: function Stream_peekBytes(length) {
  24665. var bytes = this.getBytes(length);
  24666. this.pos -= bytes.length;
  24667. return bytes;
  24668. },
  24669. skip: function Stream_skip(n) {
  24670. if (!n) {
  24671. n = 1;
  24672. }
  24673. this.pos += n;
  24674. },
  24675. reset: function Stream_reset() {
  24676. this.pos = this.start;
  24677. },
  24678. moveStart: function Stream_moveStart() {
  24679. this.start = this.pos;
  24680. },
  24681. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  24682. return new Stream(this.bytes.buffer, start, length, dict);
  24683. },
  24684. isStream: true
  24685. };
  24686. return Stream;
  24687. }();
  24688. var StringStream = function StringStreamClosure() {
  24689. function StringStream(str) {
  24690. var length = str.length;
  24691. var bytes = new Uint8Array(length);
  24692. for (var n = 0; n < length; ++n) {
  24693. bytes[n] = str.charCodeAt(n);
  24694. }
  24695. Stream.call(this, bytes);
  24696. }
  24697. StringStream.prototype = Stream.prototype;
  24698. return StringStream;
  24699. }();
  24700. var DecodeStream = function DecodeStreamClosure() {
  24701. var emptyBuffer = new Uint8Array(0);
  24702. function DecodeStream(maybeMinBufferLength) {
  24703. this.pos = 0;
  24704. this.bufferLength = 0;
  24705. this.eof = false;
  24706. this.buffer = emptyBuffer;
  24707. this.minBufferLength = 512;
  24708. if (maybeMinBufferLength) {
  24709. while (this.minBufferLength < maybeMinBufferLength) {
  24710. this.minBufferLength *= 2;
  24711. }
  24712. }
  24713. }
  24714. DecodeStream.prototype = {
  24715. get isEmpty() {
  24716. while (!this.eof && this.bufferLength === 0) {
  24717. this.readBlock();
  24718. }
  24719. return this.bufferLength === 0;
  24720. },
  24721. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  24722. var buffer = this.buffer;
  24723. if (requested <= buffer.byteLength) {
  24724. return buffer;
  24725. }
  24726. var size = this.minBufferLength;
  24727. while (size < requested) {
  24728. size *= 2;
  24729. }
  24730. var buffer2 = new Uint8Array(size);
  24731. buffer2.set(buffer);
  24732. return this.buffer = buffer2;
  24733. },
  24734. getByte: function DecodeStream_getByte() {
  24735. var pos = this.pos;
  24736. while (this.bufferLength <= pos) {
  24737. if (this.eof) {
  24738. return -1;
  24739. }
  24740. this.readBlock();
  24741. }
  24742. return this.buffer[this.pos++];
  24743. },
  24744. getUint16: function DecodeStream_getUint16() {
  24745. var b0 = this.getByte();
  24746. var b1 = this.getByte();
  24747. if (b0 === -1 || b1 === -1) {
  24748. return -1;
  24749. }
  24750. return (b0 << 8) + b1;
  24751. },
  24752. getInt32: function DecodeStream_getInt32() {
  24753. var b0 = this.getByte();
  24754. var b1 = this.getByte();
  24755. var b2 = this.getByte();
  24756. var b3 = this.getByte();
  24757. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  24758. },
  24759. getBytes: function DecodeStream_getBytes(length) {
  24760. var end, pos = this.pos;
  24761. if (length) {
  24762. this.ensureBuffer(pos + length);
  24763. end = pos + length;
  24764. while (!this.eof && this.bufferLength < end) {
  24765. this.readBlock();
  24766. }
  24767. var bufEnd = this.bufferLength;
  24768. if (end > bufEnd) {
  24769. end = bufEnd;
  24770. }
  24771. } else {
  24772. while (!this.eof) {
  24773. this.readBlock();
  24774. }
  24775. end = this.bufferLength;
  24776. }
  24777. this.pos = end;
  24778. return this.buffer.subarray(pos, end);
  24779. },
  24780. peekByte: function DecodeStream_peekByte() {
  24781. var peekedByte = this.getByte();
  24782. this.pos--;
  24783. return peekedByte;
  24784. },
  24785. peekBytes: function DecodeStream_peekBytes(length) {
  24786. var bytes = this.getBytes(length);
  24787. this.pos -= bytes.length;
  24788. return bytes;
  24789. },
  24790. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  24791. var end = start + length;
  24792. while (this.bufferLength <= end && !this.eof) {
  24793. this.readBlock();
  24794. }
  24795. return new Stream(this.buffer, start, length, dict);
  24796. },
  24797. skip: function DecodeStream_skip(n) {
  24798. if (!n) {
  24799. n = 1;
  24800. }
  24801. this.pos += n;
  24802. },
  24803. reset: function DecodeStream_reset() {
  24804. this.pos = 0;
  24805. },
  24806. getBaseStreams: function DecodeStream_getBaseStreams() {
  24807. if (this.str && this.str.getBaseStreams) {
  24808. return this.str.getBaseStreams();
  24809. }
  24810. return [];
  24811. }
  24812. };
  24813. return DecodeStream;
  24814. }();
  24815. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  24816. function StreamsSequenceStream(streams) {
  24817. this.streams = streams;
  24818. DecodeStream.call(this, null);
  24819. }
  24820. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  24821. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  24822. var streams = this.streams;
  24823. if (streams.length === 0) {
  24824. this.eof = true;
  24825. return;
  24826. }
  24827. var stream = streams.shift();
  24828. var chunk = stream.getBytes();
  24829. var bufferLength = this.bufferLength;
  24830. var newLength = bufferLength + chunk.length;
  24831. var buffer = this.ensureBuffer(newLength);
  24832. buffer.set(chunk, bufferLength);
  24833. this.bufferLength = newLength;
  24834. };
  24835. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  24836. var baseStreams = [];
  24837. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  24838. var stream = this.streams[i];
  24839. if (stream.getBaseStreams) {
  24840. Util.appendToArray(baseStreams, stream.getBaseStreams());
  24841. }
  24842. }
  24843. return baseStreams;
  24844. };
  24845. return StreamsSequenceStream;
  24846. }();
  24847. var FlateStream = function FlateStreamClosure() {
  24848. var codeLenCodeMap = new Int32Array([
  24849. 16,
  24850. 17,
  24851. 18,
  24852. 0,
  24853. 8,
  24854. 7,
  24855. 9,
  24856. 6,
  24857. 10,
  24858. 5,
  24859. 11,
  24860. 4,
  24861. 12,
  24862. 3,
  24863. 13,
  24864. 2,
  24865. 14,
  24866. 1,
  24867. 15
  24868. ]);
  24869. var lengthDecode = new Int32Array([
  24870. 0x00003,
  24871. 0x00004,
  24872. 0x00005,
  24873. 0x00006,
  24874. 0x00007,
  24875. 0x00008,
  24876. 0x00009,
  24877. 0x0000a,
  24878. 0x1000b,
  24879. 0x1000d,
  24880. 0x1000f,
  24881. 0x10011,
  24882. 0x20013,
  24883. 0x20017,
  24884. 0x2001b,
  24885. 0x2001f,
  24886. 0x30023,
  24887. 0x3002b,
  24888. 0x30033,
  24889. 0x3003b,
  24890. 0x40043,
  24891. 0x40053,
  24892. 0x40063,
  24893. 0x40073,
  24894. 0x50083,
  24895. 0x500a3,
  24896. 0x500c3,
  24897. 0x500e3,
  24898. 0x00102,
  24899. 0x00102,
  24900. 0x00102
  24901. ]);
  24902. var distDecode = new Int32Array([
  24903. 0x00001,
  24904. 0x00002,
  24905. 0x00003,
  24906. 0x00004,
  24907. 0x10005,
  24908. 0x10007,
  24909. 0x20009,
  24910. 0x2000d,
  24911. 0x30011,
  24912. 0x30019,
  24913. 0x40021,
  24914. 0x40031,
  24915. 0x50041,
  24916. 0x50061,
  24917. 0x60081,
  24918. 0x600c1,
  24919. 0x70101,
  24920. 0x70181,
  24921. 0x80201,
  24922. 0x80301,
  24923. 0x90401,
  24924. 0x90601,
  24925. 0xa0801,
  24926. 0xa0c01,
  24927. 0xb1001,
  24928. 0xb1801,
  24929. 0xc2001,
  24930. 0xc3001,
  24931. 0xd4001,
  24932. 0xd6001
  24933. ]);
  24934. var fixedLitCodeTab = [
  24935. new Int32Array([
  24936. 0x70100,
  24937. 0x80050,
  24938. 0x80010,
  24939. 0x80118,
  24940. 0x70110,
  24941. 0x80070,
  24942. 0x80030,
  24943. 0x900c0,
  24944. 0x70108,
  24945. 0x80060,
  24946. 0x80020,
  24947. 0x900a0,
  24948. 0x80000,
  24949. 0x80080,
  24950. 0x80040,
  24951. 0x900e0,
  24952. 0x70104,
  24953. 0x80058,
  24954. 0x80018,
  24955. 0x90090,
  24956. 0x70114,
  24957. 0x80078,
  24958. 0x80038,
  24959. 0x900d0,
  24960. 0x7010c,
  24961. 0x80068,
  24962. 0x80028,
  24963. 0x900b0,
  24964. 0x80008,
  24965. 0x80088,
  24966. 0x80048,
  24967. 0x900f0,
  24968. 0x70102,
  24969. 0x80054,
  24970. 0x80014,
  24971. 0x8011c,
  24972. 0x70112,
  24973. 0x80074,
  24974. 0x80034,
  24975. 0x900c8,
  24976. 0x7010a,
  24977. 0x80064,
  24978. 0x80024,
  24979. 0x900a8,
  24980. 0x80004,
  24981. 0x80084,
  24982. 0x80044,
  24983. 0x900e8,
  24984. 0x70106,
  24985. 0x8005c,
  24986. 0x8001c,
  24987. 0x90098,
  24988. 0x70116,
  24989. 0x8007c,
  24990. 0x8003c,
  24991. 0x900d8,
  24992. 0x7010e,
  24993. 0x8006c,
  24994. 0x8002c,
  24995. 0x900b8,
  24996. 0x8000c,
  24997. 0x8008c,
  24998. 0x8004c,
  24999. 0x900f8,
  25000. 0x70101,
  25001. 0x80052,
  25002. 0x80012,
  25003. 0x8011a,
  25004. 0x70111,
  25005. 0x80072,
  25006. 0x80032,
  25007. 0x900c4,
  25008. 0x70109,
  25009. 0x80062,
  25010. 0x80022,
  25011. 0x900a4,
  25012. 0x80002,
  25013. 0x80082,
  25014. 0x80042,
  25015. 0x900e4,
  25016. 0x70105,
  25017. 0x8005a,
  25018. 0x8001a,
  25019. 0x90094,
  25020. 0x70115,
  25021. 0x8007a,
  25022. 0x8003a,
  25023. 0x900d4,
  25024. 0x7010d,
  25025. 0x8006a,
  25026. 0x8002a,
  25027. 0x900b4,
  25028. 0x8000a,
  25029. 0x8008a,
  25030. 0x8004a,
  25031. 0x900f4,
  25032. 0x70103,
  25033. 0x80056,
  25034. 0x80016,
  25035. 0x8011e,
  25036. 0x70113,
  25037. 0x80076,
  25038. 0x80036,
  25039. 0x900cc,
  25040. 0x7010b,
  25041. 0x80066,
  25042. 0x80026,
  25043. 0x900ac,
  25044. 0x80006,
  25045. 0x80086,
  25046. 0x80046,
  25047. 0x900ec,
  25048. 0x70107,
  25049. 0x8005e,
  25050. 0x8001e,
  25051. 0x9009c,
  25052. 0x70117,
  25053. 0x8007e,
  25054. 0x8003e,
  25055. 0x900dc,
  25056. 0x7010f,
  25057. 0x8006e,
  25058. 0x8002e,
  25059. 0x900bc,
  25060. 0x8000e,
  25061. 0x8008e,
  25062. 0x8004e,
  25063. 0x900fc,
  25064. 0x70100,
  25065. 0x80051,
  25066. 0x80011,
  25067. 0x80119,
  25068. 0x70110,
  25069. 0x80071,
  25070. 0x80031,
  25071. 0x900c2,
  25072. 0x70108,
  25073. 0x80061,
  25074. 0x80021,
  25075. 0x900a2,
  25076. 0x80001,
  25077. 0x80081,
  25078. 0x80041,
  25079. 0x900e2,
  25080. 0x70104,
  25081. 0x80059,
  25082. 0x80019,
  25083. 0x90092,
  25084. 0x70114,
  25085. 0x80079,
  25086. 0x80039,
  25087. 0x900d2,
  25088. 0x7010c,
  25089. 0x80069,
  25090. 0x80029,
  25091. 0x900b2,
  25092. 0x80009,
  25093. 0x80089,
  25094. 0x80049,
  25095. 0x900f2,
  25096. 0x70102,
  25097. 0x80055,
  25098. 0x80015,
  25099. 0x8011d,
  25100. 0x70112,
  25101. 0x80075,
  25102. 0x80035,
  25103. 0x900ca,
  25104. 0x7010a,
  25105. 0x80065,
  25106. 0x80025,
  25107. 0x900aa,
  25108. 0x80005,
  25109. 0x80085,
  25110. 0x80045,
  25111. 0x900ea,
  25112. 0x70106,
  25113. 0x8005d,
  25114. 0x8001d,
  25115. 0x9009a,
  25116. 0x70116,
  25117. 0x8007d,
  25118. 0x8003d,
  25119. 0x900da,
  25120. 0x7010e,
  25121. 0x8006d,
  25122. 0x8002d,
  25123. 0x900ba,
  25124. 0x8000d,
  25125. 0x8008d,
  25126. 0x8004d,
  25127. 0x900fa,
  25128. 0x70101,
  25129. 0x80053,
  25130. 0x80013,
  25131. 0x8011b,
  25132. 0x70111,
  25133. 0x80073,
  25134. 0x80033,
  25135. 0x900c6,
  25136. 0x70109,
  25137. 0x80063,
  25138. 0x80023,
  25139. 0x900a6,
  25140. 0x80003,
  25141. 0x80083,
  25142. 0x80043,
  25143. 0x900e6,
  25144. 0x70105,
  25145. 0x8005b,
  25146. 0x8001b,
  25147. 0x90096,
  25148. 0x70115,
  25149. 0x8007b,
  25150. 0x8003b,
  25151. 0x900d6,
  25152. 0x7010d,
  25153. 0x8006b,
  25154. 0x8002b,
  25155. 0x900b6,
  25156. 0x8000b,
  25157. 0x8008b,
  25158. 0x8004b,
  25159. 0x900f6,
  25160. 0x70103,
  25161. 0x80057,
  25162. 0x80017,
  25163. 0x8011f,
  25164. 0x70113,
  25165. 0x80077,
  25166. 0x80037,
  25167. 0x900ce,
  25168. 0x7010b,
  25169. 0x80067,
  25170. 0x80027,
  25171. 0x900ae,
  25172. 0x80007,
  25173. 0x80087,
  25174. 0x80047,
  25175. 0x900ee,
  25176. 0x70107,
  25177. 0x8005f,
  25178. 0x8001f,
  25179. 0x9009e,
  25180. 0x70117,
  25181. 0x8007f,
  25182. 0x8003f,
  25183. 0x900de,
  25184. 0x7010f,
  25185. 0x8006f,
  25186. 0x8002f,
  25187. 0x900be,
  25188. 0x8000f,
  25189. 0x8008f,
  25190. 0x8004f,
  25191. 0x900fe,
  25192. 0x70100,
  25193. 0x80050,
  25194. 0x80010,
  25195. 0x80118,
  25196. 0x70110,
  25197. 0x80070,
  25198. 0x80030,
  25199. 0x900c1,
  25200. 0x70108,
  25201. 0x80060,
  25202. 0x80020,
  25203. 0x900a1,
  25204. 0x80000,
  25205. 0x80080,
  25206. 0x80040,
  25207. 0x900e1,
  25208. 0x70104,
  25209. 0x80058,
  25210. 0x80018,
  25211. 0x90091,
  25212. 0x70114,
  25213. 0x80078,
  25214. 0x80038,
  25215. 0x900d1,
  25216. 0x7010c,
  25217. 0x80068,
  25218. 0x80028,
  25219. 0x900b1,
  25220. 0x80008,
  25221. 0x80088,
  25222. 0x80048,
  25223. 0x900f1,
  25224. 0x70102,
  25225. 0x80054,
  25226. 0x80014,
  25227. 0x8011c,
  25228. 0x70112,
  25229. 0x80074,
  25230. 0x80034,
  25231. 0x900c9,
  25232. 0x7010a,
  25233. 0x80064,
  25234. 0x80024,
  25235. 0x900a9,
  25236. 0x80004,
  25237. 0x80084,
  25238. 0x80044,
  25239. 0x900e9,
  25240. 0x70106,
  25241. 0x8005c,
  25242. 0x8001c,
  25243. 0x90099,
  25244. 0x70116,
  25245. 0x8007c,
  25246. 0x8003c,
  25247. 0x900d9,
  25248. 0x7010e,
  25249. 0x8006c,
  25250. 0x8002c,
  25251. 0x900b9,
  25252. 0x8000c,
  25253. 0x8008c,
  25254. 0x8004c,
  25255. 0x900f9,
  25256. 0x70101,
  25257. 0x80052,
  25258. 0x80012,
  25259. 0x8011a,
  25260. 0x70111,
  25261. 0x80072,
  25262. 0x80032,
  25263. 0x900c5,
  25264. 0x70109,
  25265. 0x80062,
  25266. 0x80022,
  25267. 0x900a5,
  25268. 0x80002,
  25269. 0x80082,
  25270. 0x80042,
  25271. 0x900e5,
  25272. 0x70105,
  25273. 0x8005a,
  25274. 0x8001a,
  25275. 0x90095,
  25276. 0x70115,
  25277. 0x8007a,
  25278. 0x8003a,
  25279. 0x900d5,
  25280. 0x7010d,
  25281. 0x8006a,
  25282. 0x8002a,
  25283. 0x900b5,
  25284. 0x8000a,
  25285. 0x8008a,
  25286. 0x8004a,
  25287. 0x900f5,
  25288. 0x70103,
  25289. 0x80056,
  25290. 0x80016,
  25291. 0x8011e,
  25292. 0x70113,
  25293. 0x80076,
  25294. 0x80036,
  25295. 0x900cd,
  25296. 0x7010b,
  25297. 0x80066,
  25298. 0x80026,
  25299. 0x900ad,
  25300. 0x80006,
  25301. 0x80086,
  25302. 0x80046,
  25303. 0x900ed,
  25304. 0x70107,
  25305. 0x8005e,
  25306. 0x8001e,
  25307. 0x9009d,
  25308. 0x70117,
  25309. 0x8007e,
  25310. 0x8003e,
  25311. 0x900dd,
  25312. 0x7010f,
  25313. 0x8006e,
  25314. 0x8002e,
  25315. 0x900bd,
  25316. 0x8000e,
  25317. 0x8008e,
  25318. 0x8004e,
  25319. 0x900fd,
  25320. 0x70100,
  25321. 0x80051,
  25322. 0x80011,
  25323. 0x80119,
  25324. 0x70110,
  25325. 0x80071,
  25326. 0x80031,
  25327. 0x900c3,
  25328. 0x70108,
  25329. 0x80061,
  25330. 0x80021,
  25331. 0x900a3,
  25332. 0x80001,
  25333. 0x80081,
  25334. 0x80041,
  25335. 0x900e3,
  25336. 0x70104,
  25337. 0x80059,
  25338. 0x80019,
  25339. 0x90093,
  25340. 0x70114,
  25341. 0x80079,
  25342. 0x80039,
  25343. 0x900d3,
  25344. 0x7010c,
  25345. 0x80069,
  25346. 0x80029,
  25347. 0x900b3,
  25348. 0x80009,
  25349. 0x80089,
  25350. 0x80049,
  25351. 0x900f3,
  25352. 0x70102,
  25353. 0x80055,
  25354. 0x80015,
  25355. 0x8011d,
  25356. 0x70112,
  25357. 0x80075,
  25358. 0x80035,
  25359. 0x900cb,
  25360. 0x7010a,
  25361. 0x80065,
  25362. 0x80025,
  25363. 0x900ab,
  25364. 0x80005,
  25365. 0x80085,
  25366. 0x80045,
  25367. 0x900eb,
  25368. 0x70106,
  25369. 0x8005d,
  25370. 0x8001d,
  25371. 0x9009b,
  25372. 0x70116,
  25373. 0x8007d,
  25374. 0x8003d,
  25375. 0x900db,
  25376. 0x7010e,
  25377. 0x8006d,
  25378. 0x8002d,
  25379. 0x900bb,
  25380. 0x8000d,
  25381. 0x8008d,
  25382. 0x8004d,
  25383. 0x900fb,
  25384. 0x70101,
  25385. 0x80053,
  25386. 0x80013,
  25387. 0x8011b,
  25388. 0x70111,
  25389. 0x80073,
  25390. 0x80033,
  25391. 0x900c7,
  25392. 0x70109,
  25393. 0x80063,
  25394. 0x80023,
  25395. 0x900a7,
  25396. 0x80003,
  25397. 0x80083,
  25398. 0x80043,
  25399. 0x900e7,
  25400. 0x70105,
  25401. 0x8005b,
  25402. 0x8001b,
  25403. 0x90097,
  25404. 0x70115,
  25405. 0x8007b,
  25406. 0x8003b,
  25407. 0x900d7,
  25408. 0x7010d,
  25409. 0x8006b,
  25410. 0x8002b,
  25411. 0x900b7,
  25412. 0x8000b,
  25413. 0x8008b,
  25414. 0x8004b,
  25415. 0x900f7,
  25416. 0x70103,
  25417. 0x80057,
  25418. 0x80017,
  25419. 0x8011f,
  25420. 0x70113,
  25421. 0x80077,
  25422. 0x80037,
  25423. 0x900cf,
  25424. 0x7010b,
  25425. 0x80067,
  25426. 0x80027,
  25427. 0x900af,
  25428. 0x80007,
  25429. 0x80087,
  25430. 0x80047,
  25431. 0x900ef,
  25432. 0x70107,
  25433. 0x8005f,
  25434. 0x8001f,
  25435. 0x9009f,
  25436. 0x70117,
  25437. 0x8007f,
  25438. 0x8003f,
  25439. 0x900df,
  25440. 0x7010f,
  25441. 0x8006f,
  25442. 0x8002f,
  25443. 0x900bf,
  25444. 0x8000f,
  25445. 0x8008f,
  25446. 0x8004f,
  25447. 0x900ff
  25448. ]),
  25449. 9
  25450. ];
  25451. var fixedDistCodeTab = [
  25452. new Int32Array([
  25453. 0x50000,
  25454. 0x50010,
  25455. 0x50008,
  25456. 0x50018,
  25457. 0x50004,
  25458. 0x50014,
  25459. 0x5000c,
  25460. 0x5001c,
  25461. 0x50002,
  25462. 0x50012,
  25463. 0x5000a,
  25464. 0x5001a,
  25465. 0x50006,
  25466. 0x50016,
  25467. 0x5000e,
  25468. 0x00000,
  25469. 0x50001,
  25470. 0x50011,
  25471. 0x50009,
  25472. 0x50019,
  25473. 0x50005,
  25474. 0x50015,
  25475. 0x5000d,
  25476. 0x5001d,
  25477. 0x50003,
  25478. 0x50013,
  25479. 0x5000b,
  25480. 0x5001b,
  25481. 0x50007,
  25482. 0x50017,
  25483. 0x5000f,
  25484. 0x00000
  25485. ]),
  25486. 5
  25487. ];
  25488. function FlateStream(str, maybeLength) {
  25489. this.str = str;
  25490. this.dict = str.dict;
  25491. var cmf = str.getByte();
  25492. var flg = str.getByte();
  25493. if (cmf === -1 || flg === -1) {
  25494. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  25495. }
  25496. if ((cmf & 0x0f) !== 0x08) {
  25497. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  25498. }
  25499. if (((cmf << 8) + flg) % 31 !== 0) {
  25500. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  25501. }
  25502. if (flg & 0x20) {
  25503. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  25504. }
  25505. this.codeSize = 0;
  25506. this.codeBuf = 0;
  25507. DecodeStream.call(this, maybeLength);
  25508. }
  25509. FlateStream.prototype = Object.create(DecodeStream.prototype);
  25510. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  25511. var str = this.str;
  25512. var codeSize = this.codeSize;
  25513. var codeBuf = this.codeBuf;
  25514. var b;
  25515. while (codeSize < bits) {
  25516. if ((b = str.getByte()) === -1) {
  25517. error('Bad encoding in flate stream');
  25518. }
  25519. codeBuf |= b << codeSize;
  25520. codeSize += 8;
  25521. }
  25522. b = codeBuf & (1 << bits) - 1;
  25523. this.codeBuf = codeBuf >> bits;
  25524. this.codeSize = codeSize -= bits;
  25525. return b;
  25526. };
  25527. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  25528. var str = this.str;
  25529. var codes = table[0];
  25530. var maxLen = table[1];
  25531. var codeSize = this.codeSize;
  25532. var codeBuf = this.codeBuf;
  25533. var b;
  25534. while (codeSize < maxLen) {
  25535. if ((b = str.getByte()) === -1) {
  25536. break;
  25537. }
  25538. codeBuf |= b << codeSize;
  25539. codeSize += 8;
  25540. }
  25541. var code = codes[codeBuf & (1 << maxLen) - 1];
  25542. var codeLen = code >> 16;
  25543. var codeVal = code & 0xffff;
  25544. if (codeLen < 1 || codeSize < codeLen) {
  25545. error('Bad encoding in flate stream');
  25546. }
  25547. this.codeBuf = codeBuf >> codeLen;
  25548. this.codeSize = codeSize - codeLen;
  25549. return codeVal;
  25550. };
  25551. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  25552. var n = lengths.length;
  25553. var maxLen = 0;
  25554. var i;
  25555. for (i = 0; i < n; ++i) {
  25556. if (lengths[i] > maxLen) {
  25557. maxLen = lengths[i];
  25558. }
  25559. }
  25560. var size = 1 << maxLen;
  25561. var codes = new Int32Array(size);
  25562. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  25563. for (var val = 0; val < n; ++val) {
  25564. if (lengths[val] === len) {
  25565. var code2 = 0;
  25566. var t = code;
  25567. for (i = 0; i < len; ++i) {
  25568. code2 = code2 << 1 | t & 1;
  25569. t >>= 1;
  25570. }
  25571. for (i = code2; i < size; i += skip) {
  25572. codes[i] = len << 16 | val;
  25573. }
  25574. ++code;
  25575. }
  25576. }
  25577. }
  25578. return [
  25579. codes,
  25580. maxLen
  25581. ];
  25582. };
  25583. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  25584. var buffer, len;
  25585. var str = this.str;
  25586. var hdr = this.getBits(3);
  25587. if (hdr & 1) {
  25588. this.eof = true;
  25589. }
  25590. hdr >>= 1;
  25591. if (hdr === 0) {
  25592. var b;
  25593. if ((b = str.getByte()) === -1) {
  25594. error('Bad block header in flate stream');
  25595. }
  25596. var blockLen = b;
  25597. if ((b = str.getByte()) === -1) {
  25598. error('Bad block header in flate stream');
  25599. }
  25600. blockLen |= b << 8;
  25601. if ((b = str.getByte()) === -1) {
  25602. error('Bad block header in flate stream');
  25603. }
  25604. var check = b;
  25605. if ((b = str.getByte()) === -1) {
  25606. error('Bad block header in flate stream');
  25607. }
  25608. check |= b << 8;
  25609. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  25610. error('Bad uncompressed block length in flate stream');
  25611. }
  25612. this.codeBuf = 0;
  25613. this.codeSize = 0;
  25614. var bufferLength = this.bufferLength;
  25615. buffer = this.ensureBuffer(bufferLength + blockLen);
  25616. var end = bufferLength + blockLen;
  25617. this.bufferLength = end;
  25618. if (blockLen === 0) {
  25619. if (str.peekByte() === -1) {
  25620. this.eof = true;
  25621. }
  25622. } else {
  25623. for (var n = bufferLength; n < end; ++n) {
  25624. if ((b = str.getByte()) === -1) {
  25625. this.eof = true;
  25626. break;
  25627. }
  25628. buffer[n] = b;
  25629. }
  25630. }
  25631. return;
  25632. }
  25633. var litCodeTable;
  25634. var distCodeTable;
  25635. if (hdr === 1) {
  25636. litCodeTable = fixedLitCodeTab;
  25637. distCodeTable = fixedDistCodeTab;
  25638. } else if (hdr === 2) {
  25639. var numLitCodes = this.getBits(5) + 257;
  25640. var numDistCodes = this.getBits(5) + 1;
  25641. var numCodeLenCodes = this.getBits(4) + 4;
  25642. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  25643. var i;
  25644. for (i = 0; i < numCodeLenCodes; ++i) {
  25645. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  25646. }
  25647. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  25648. len = 0;
  25649. i = 0;
  25650. var codes = numLitCodes + numDistCodes;
  25651. var codeLengths = new Uint8Array(codes);
  25652. var bitsLength, bitsOffset, what;
  25653. while (i < codes) {
  25654. var code = this.getCode(codeLenCodeTab);
  25655. if (code === 16) {
  25656. bitsLength = 2;
  25657. bitsOffset = 3;
  25658. what = len;
  25659. } else if (code === 17) {
  25660. bitsLength = 3;
  25661. bitsOffset = 3;
  25662. what = len = 0;
  25663. } else if (code === 18) {
  25664. bitsLength = 7;
  25665. bitsOffset = 11;
  25666. what = len = 0;
  25667. } else {
  25668. codeLengths[i++] = len = code;
  25669. continue;
  25670. }
  25671. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  25672. while (repeatLength-- > 0) {
  25673. codeLengths[i++] = what;
  25674. }
  25675. }
  25676. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  25677. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  25678. } else {
  25679. error('Unknown block type in flate stream');
  25680. }
  25681. buffer = this.buffer;
  25682. var limit = buffer ? buffer.length : 0;
  25683. var pos = this.bufferLength;
  25684. while (true) {
  25685. var code1 = this.getCode(litCodeTable);
  25686. if (code1 < 256) {
  25687. if (pos + 1 >= limit) {
  25688. buffer = this.ensureBuffer(pos + 1);
  25689. limit = buffer.length;
  25690. }
  25691. buffer[pos++] = code1;
  25692. continue;
  25693. }
  25694. if (code1 === 256) {
  25695. this.bufferLength = pos;
  25696. return;
  25697. }
  25698. code1 -= 257;
  25699. code1 = lengthDecode[code1];
  25700. var code2 = code1 >> 16;
  25701. if (code2 > 0) {
  25702. code2 = this.getBits(code2);
  25703. }
  25704. len = (code1 & 0xffff) + code2;
  25705. code1 = this.getCode(distCodeTable);
  25706. code1 = distDecode[code1];
  25707. code2 = code1 >> 16;
  25708. if (code2 > 0) {
  25709. code2 = this.getBits(code2);
  25710. }
  25711. var dist = (code1 & 0xffff) + code2;
  25712. if (pos + len >= limit) {
  25713. buffer = this.ensureBuffer(pos + len);
  25714. limit = buffer.length;
  25715. }
  25716. for (var k = 0; k < len; ++k, ++pos) {
  25717. buffer[pos] = buffer[pos - dist];
  25718. }
  25719. }
  25720. };
  25721. return FlateStream;
  25722. }();
  25723. var PredictorStream = function PredictorStreamClosure() {
  25724. function PredictorStream(str, maybeLength, params) {
  25725. if (!isDict(params)) {
  25726. return str;
  25727. }
  25728. var predictor = this.predictor = params.get('Predictor') || 1;
  25729. if (predictor <= 1) {
  25730. return str;
  25731. }
  25732. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  25733. error('Unsupported predictor: ' + predictor);
  25734. }
  25735. if (predictor === 2) {
  25736. this.readBlock = this.readBlockTiff;
  25737. } else {
  25738. this.readBlock = this.readBlockPng;
  25739. }
  25740. this.str = str;
  25741. this.dict = str.dict;
  25742. var colors = this.colors = params.get('Colors') || 1;
  25743. var bits = this.bits = params.get('BitsPerComponent') || 8;
  25744. var columns = this.columns = params.get('Columns') || 1;
  25745. this.pixBytes = colors * bits + 7 >> 3;
  25746. this.rowBytes = columns * colors * bits + 7 >> 3;
  25747. DecodeStream.call(this, maybeLength);
  25748. return this;
  25749. }
  25750. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  25751. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  25752. var rowBytes = this.rowBytes;
  25753. var bufferLength = this.bufferLength;
  25754. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  25755. var bits = this.bits;
  25756. var colors = this.colors;
  25757. var rawBytes = this.str.getBytes(rowBytes);
  25758. this.eof = !rawBytes.length;
  25759. if (this.eof) {
  25760. return;
  25761. }
  25762. var inbuf = 0, outbuf = 0;
  25763. var inbits = 0, outbits = 0;
  25764. var pos = bufferLength;
  25765. var i;
  25766. if (bits === 1) {
  25767. for (i = 0; i < rowBytes; ++i) {
  25768. var c = rawBytes[i];
  25769. inbuf = inbuf << 8 | c;
  25770. buffer[pos++] = (c ^ inbuf >> colors) & 0xFF;
  25771. inbuf &= 0xFFFF;
  25772. }
  25773. } else if (bits === 8) {
  25774. for (i = 0; i < colors; ++i) {
  25775. buffer[pos++] = rawBytes[i];
  25776. }
  25777. for (; i < rowBytes; ++i) {
  25778. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  25779. pos++;
  25780. }
  25781. } else {
  25782. var compArray = new Uint8Array(colors + 1);
  25783. var bitMask = (1 << bits) - 1;
  25784. var j = 0, k = bufferLength;
  25785. var columns = this.columns;
  25786. for (i = 0; i < columns; ++i) {
  25787. for (var kk = 0; kk < colors; ++kk) {
  25788. if (inbits < bits) {
  25789. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  25790. inbits += 8;
  25791. }
  25792. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  25793. inbits -= bits;
  25794. outbuf = outbuf << bits | compArray[kk];
  25795. outbits += bits;
  25796. if (outbits >= 8) {
  25797. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  25798. outbits -= 8;
  25799. }
  25800. }
  25801. }
  25802. if (outbits > 0) {
  25803. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  25804. }
  25805. }
  25806. this.bufferLength += rowBytes;
  25807. };
  25808. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  25809. var rowBytes = this.rowBytes;
  25810. var pixBytes = this.pixBytes;
  25811. var predictor = this.str.getByte();
  25812. var rawBytes = this.str.getBytes(rowBytes);
  25813. this.eof = !rawBytes.length;
  25814. if (this.eof) {
  25815. return;
  25816. }
  25817. var bufferLength = this.bufferLength;
  25818. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  25819. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  25820. if (prevRow.length === 0) {
  25821. prevRow = new Uint8Array(rowBytes);
  25822. }
  25823. var i, j = bufferLength, up, c;
  25824. switch (predictor) {
  25825. case 0:
  25826. for (i = 0; i < rowBytes; ++i) {
  25827. buffer[j++] = rawBytes[i];
  25828. }
  25829. break;
  25830. case 1:
  25831. for (i = 0; i < pixBytes; ++i) {
  25832. buffer[j++] = rawBytes[i];
  25833. }
  25834. for (; i < rowBytes; ++i) {
  25835. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  25836. j++;
  25837. }
  25838. break;
  25839. case 2:
  25840. for (i = 0; i < rowBytes; ++i) {
  25841. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  25842. }
  25843. break;
  25844. case 3:
  25845. for (i = 0; i < pixBytes; ++i) {
  25846. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  25847. }
  25848. for (; i < rowBytes; ++i) {
  25849. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  25850. j++;
  25851. }
  25852. break;
  25853. case 4:
  25854. for (i = 0; i < pixBytes; ++i) {
  25855. up = prevRow[i];
  25856. c = rawBytes[i];
  25857. buffer[j++] = up + c;
  25858. }
  25859. for (; i < rowBytes; ++i) {
  25860. up = prevRow[i];
  25861. var upLeft = prevRow[i - pixBytes];
  25862. var left = buffer[j - pixBytes];
  25863. var p = left + up - upLeft;
  25864. var pa = p - left;
  25865. if (pa < 0) {
  25866. pa = -pa;
  25867. }
  25868. var pb = p - up;
  25869. if (pb < 0) {
  25870. pb = -pb;
  25871. }
  25872. var pc = p - upLeft;
  25873. if (pc < 0) {
  25874. pc = -pc;
  25875. }
  25876. c = rawBytes[i];
  25877. if (pa <= pb && pa <= pc) {
  25878. buffer[j++] = left + c;
  25879. } else if (pb <= pc) {
  25880. buffer[j++] = up + c;
  25881. } else {
  25882. buffer[j++] = upLeft + c;
  25883. }
  25884. }
  25885. break;
  25886. default:
  25887. error('Unsupported predictor: ' + predictor);
  25888. }
  25889. this.bufferLength += rowBytes;
  25890. };
  25891. return PredictorStream;
  25892. }();
  25893. var JpegStream = function JpegStreamClosure() {
  25894. function JpegStream(stream, maybeLength, dict, params) {
  25895. var ch;
  25896. while ((ch = stream.getByte()) !== -1) {
  25897. if (ch === 0xFF) {
  25898. stream.skip(-1);
  25899. break;
  25900. }
  25901. }
  25902. this.stream = stream;
  25903. this.maybeLength = maybeLength;
  25904. this.dict = dict;
  25905. this.params = params;
  25906. DecodeStream.call(this, maybeLength);
  25907. }
  25908. JpegStream.prototype = Object.create(DecodeStream.prototype);
  25909. Object.defineProperty(JpegStream.prototype, 'bytes', {
  25910. get: function JpegStream_bytes() {
  25911. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  25912. },
  25913. configurable: true
  25914. });
  25915. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  25916. if (this.bufferLength) {
  25917. return;
  25918. }
  25919. var jpegImage = new JpegImage();
  25920. var decodeArr = this.dict.getArray('Decode', 'D');
  25921. if (this.forceRGB && isArray(decodeArr)) {
  25922. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  25923. var decodeArrLength = decodeArr.length;
  25924. var transform = new Int32Array(decodeArrLength);
  25925. var transformNeeded = false;
  25926. var maxValue = (1 << bitsPerComponent) - 1;
  25927. for (var i = 0; i < decodeArrLength; i += 2) {
  25928. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  25929. transform[i + 1] = decodeArr[i] * maxValue | 0;
  25930. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  25931. transformNeeded = true;
  25932. }
  25933. }
  25934. if (transformNeeded) {
  25935. jpegImage.decodeTransform = transform;
  25936. }
  25937. }
  25938. if (isDict(this.params)) {
  25939. var colorTransform = this.params.get('ColorTransform');
  25940. if (isInt(colorTransform)) {
  25941. jpegImage.colorTransform = colorTransform;
  25942. }
  25943. }
  25944. jpegImage.parse(this.bytes);
  25945. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  25946. this.buffer = data;
  25947. this.bufferLength = data.length;
  25948. this.eof = true;
  25949. };
  25950. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  25951. this.ensureBuffer();
  25952. return this.buffer;
  25953. };
  25954. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  25955. return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
  25956. };
  25957. return JpegStream;
  25958. }();
  25959. var JpxStream = function JpxStreamClosure() {
  25960. function JpxStream(stream, maybeLength, dict, params) {
  25961. this.stream = stream;
  25962. this.maybeLength = maybeLength;
  25963. this.dict = dict;
  25964. this.params = params;
  25965. DecodeStream.call(this, maybeLength);
  25966. }
  25967. JpxStream.prototype = Object.create(DecodeStream.prototype);
  25968. Object.defineProperty(JpxStream.prototype, 'bytes', {
  25969. get: function JpxStream_bytes() {
  25970. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  25971. },
  25972. configurable: true
  25973. });
  25974. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  25975. if (this.bufferLength) {
  25976. return;
  25977. }
  25978. var jpxImage = new JpxImage();
  25979. jpxImage.parse(this.bytes);
  25980. var width = jpxImage.width;
  25981. var height = jpxImage.height;
  25982. var componentsCount = jpxImage.componentsCount;
  25983. var tileCount = jpxImage.tiles.length;
  25984. if (tileCount === 1) {
  25985. this.buffer = jpxImage.tiles[0].items;
  25986. } else {
  25987. var data = new Uint8Array(width * height * componentsCount);
  25988. for (var k = 0; k < tileCount; k++) {
  25989. var tileComponents = jpxImage.tiles[k];
  25990. var tileWidth = tileComponents.width;
  25991. var tileHeight = tileComponents.height;
  25992. var tileLeft = tileComponents.left;
  25993. var tileTop = tileComponents.top;
  25994. var src = tileComponents.items;
  25995. var srcPosition = 0;
  25996. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  25997. var imgRowSize = width * componentsCount;
  25998. var tileRowSize = tileWidth * componentsCount;
  25999. for (var j = 0; j < tileHeight; j++) {
  26000. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  26001. data.set(rowBytes, dataPosition);
  26002. srcPosition += tileRowSize;
  26003. dataPosition += imgRowSize;
  26004. }
  26005. }
  26006. this.buffer = data;
  26007. }
  26008. this.bufferLength = this.buffer.length;
  26009. this.eof = true;
  26010. };
  26011. return JpxStream;
  26012. }();
  26013. var Jbig2Stream = function Jbig2StreamClosure() {
  26014. function Jbig2Stream(stream, maybeLength, dict, params) {
  26015. this.stream = stream;
  26016. this.maybeLength = maybeLength;
  26017. this.dict = dict;
  26018. this.params = params;
  26019. DecodeStream.call(this, maybeLength);
  26020. }
  26021. Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
  26022. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  26023. get: function Jbig2Stream_bytes() {
  26024. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  26025. },
  26026. configurable: true
  26027. });
  26028. Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
  26029. if (this.bufferLength) {
  26030. return;
  26031. }
  26032. var jbig2Image = new Jbig2Image();
  26033. var chunks = [];
  26034. if (isDict(this.params)) {
  26035. var globalsStream = this.params.get('JBIG2Globals');
  26036. if (isStream(globalsStream)) {
  26037. var globals = globalsStream.getBytes();
  26038. chunks.push({
  26039. data: globals,
  26040. start: 0,
  26041. end: globals.length
  26042. });
  26043. }
  26044. }
  26045. chunks.push({
  26046. data: this.bytes,
  26047. start: 0,
  26048. end: this.bytes.length
  26049. });
  26050. var data = jbig2Image.parseChunks(chunks);
  26051. var dataLength = data.length;
  26052. for (var i = 0; i < dataLength; i++) {
  26053. data[i] ^= 0xFF;
  26054. }
  26055. this.buffer = data;
  26056. this.bufferLength = dataLength;
  26057. this.eof = true;
  26058. };
  26059. return Jbig2Stream;
  26060. }();
  26061. var DecryptStream = function DecryptStreamClosure() {
  26062. function DecryptStream(str, maybeLength, decrypt) {
  26063. this.str = str;
  26064. this.dict = str.dict;
  26065. this.decrypt = decrypt;
  26066. this.nextChunk = null;
  26067. this.initialized = false;
  26068. DecodeStream.call(this, maybeLength);
  26069. }
  26070. var chunkSize = 512;
  26071. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  26072. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  26073. var chunk;
  26074. if (this.initialized) {
  26075. chunk = this.nextChunk;
  26076. } else {
  26077. chunk = this.str.getBytes(chunkSize);
  26078. this.initialized = true;
  26079. }
  26080. if (!chunk || chunk.length === 0) {
  26081. this.eof = true;
  26082. return;
  26083. }
  26084. this.nextChunk = this.str.getBytes(chunkSize);
  26085. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  26086. var decrypt = this.decrypt;
  26087. chunk = decrypt(chunk, !hasMoreData);
  26088. var bufferLength = this.bufferLength;
  26089. var i, n = chunk.length;
  26090. var buffer = this.ensureBuffer(bufferLength + n);
  26091. for (i = 0; i < n; i++) {
  26092. buffer[bufferLength++] = chunk[i];
  26093. }
  26094. this.bufferLength = bufferLength;
  26095. };
  26096. return DecryptStream;
  26097. }();
  26098. var Ascii85Stream = function Ascii85StreamClosure() {
  26099. function Ascii85Stream(str, maybeLength) {
  26100. this.str = str;
  26101. this.dict = str.dict;
  26102. this.input = new Uint8Array(5);
  26103. if (maybeLength) {
  26104. maybeLength = 0.8 * maybeLength;
  26105. }
  26106. DecodeStream.call(this, maybeLength);
  26107. }
  26108. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  26109. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  26110. var TILDA_CHAR = 0x7E;
  26111. var Z_LOWER_CHAR = 0x7A;
  26112. var EOF = -1;
  26113. var str = this.str;
  26114. var c = str.getByte();
  26115. while (isSpace(c)) {
  26116. c = str.getByte();
  26117. }
  26118. if (c === EOF || c === TILDA_CHAR) {
  26119. this.eof = true;
  26120. return;
  26121. }
  26122. var bufferLength = this.bufferLength, buffer;
  26123. var i;
  26124. if (c === Z_LOWER_CHAR) {
  26125. buffer = this.ensureBuffer(bufferLength + 4);
  26126. for (i = 0; i < 4; ++i) {
  26127. buffer[bufferLength + i] = 0;
  26128. }
  26129. this.bufferLength += 4;
  26130. } else {
  26131. var input = this.input;
  26132. input[0] = c;
  26133. for (i = 1; i < 5; ++i) {
  26134. c = str.getByte();
  26135. while (isSpace(c)) {
  26136. c = str.getByte();
  26137. }
  26138. input[i] = c;
  26139. if (c === EOF || c === TILDA_CHAR) {
  26140. break;
  26141. }
  26142. }
  26143. buffer = this.ensureBuffer(bufferLength + i - 1);
  26144. this.bufferLength += i - 1;
  26145. if (i < 5) {
  26146. for (; i < 5; ++i) {
  26147. input[i] = 0x21 + 84;
  26148. }
  26149. this.eof = true;
  26150. }
  26151. var t = 0;
  26152. for (i = 0; i < 5; ++i) {
  26153. t = t * 85 + (input[i] - 0x21);
  26154. }
  26155. for (i = 3; i >= 0; --i) {
  26156. buffer[bufferLength + i] = t & 0xFF;
  26157. t >>= 8;
  26158. }
  26159. }
  26160. };
  26161. return Ascii85Stream;
  26162. }();
  26163. var AsciiHexStream = function AsciiHexStreamClosure() {
  26164. function AsciiHexStream(str, maybeLength) {
  26165. this.str = str;
  26166. this.dict = str.dict;
  26167. this.firstDigit = -1;
  26168. if (maybeLength) {
  26169. maybeLength = 0.5 * maybeLength;
  26170. }
  26171. DecodeStream.call(this, maybeLength);
  26172. }
  26173. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  26174. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  26175. var UPSTREAM_BLOCK_SIZE = 8000;
  26176. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  26177. if (!bytes.length) {
  26178. this.eof = true;
  26179. return;
  26180. }
  26181. var maxDecodeLength = bytes.length + 1 >> 1;
  26182. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  26183. var bufferLength = this.bufferLength;
  26184. var firstDigit = this.firstDigit;
  26185. for (var i = 0, ii = bytes.length; i < ii; i++) {
  26186. var ch = bytes[i], digit;
  26187. if (ch >= 0x30 && ch <= 0x39) {
  26188. digit = ch & 0x0F;
  26189. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  26190. digit = (ch & 0x0F) + 9;
  26191. } else if (ch === 0x3E) {
  26192. this.eof = true;
  26193. break;
  26194. } else {
  26195. continue;
  26196. }
  26197. if (firstDigit < 0) {
  26198. firstDigit = digit;
  26199. } else {
  26200. buffer[bufferLength++] = firstDigit << 4 | digit;
  26201. firstDigit = -1;
  26202. }
  26203. }
  26204. if (firstDigit >= 0 && this.eof) {
  26205. buffer[bufferLength++] = firstDigit << 4;
  26206. firstDigit = -1;
  26207. }
  26208. this.firstDigit = firstDigit;
  26209. this.bufferLength = bufferLength;
  26210. };
  26211. return AsciiHexStream;
  26212. }();
  26213. var RunLengthStream = function RunLengthStreamClosure() {
  26214. function RunLengthStream(str, maybeLength) {
  26215. this.str = str;
  26216. this.dict = str.dict;
  26217. DecodeStream.call(this, maybeLength);
  26218. }
  26219. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  26220. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  26221. var repeatHeader = this.str.getBytes(2);
  26222. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  26223. this.eof = true;
  26224. return;
  26225. }
  26226. var buffer;
  26227. var bufferLength = this.bufferLength;
  26228. var n = repeatHeader[0];
  26229. if (n < 128) {
  26230. buffer = this.ensureBuffer(bufferLength + n + 1);
  26231. buffer[bufferLength++] = repeatHeader[1];
  26232. if (n > 0) {
  26233. var source = this.str.getBytes(n);
  26234. buffer.set(source, bufferLength);
  26235. bufferLength += n;
  26236. }
  26237. } else {
  26238. n = 257 - n;
  26239. var b = repeatHeader[1];
  26240. buffer = this.ensureBuffer(bufferLength + n + 1);
  26241. for (var i = 0; i < n; i++) {
  26242. buffer[bufferLength++] = b;
  26243. }
  26244. }
  26245. this.bufferLength = bufferLength;
  26246. };
  26247. return RunLengthStream;
  26248. }();
  26249. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  26250. var ccittEOL = -2;
  26251. var ccittEOF = -1;
  26252. var twoDimPass = 0;
  26253. var twoDimHoriz = 1;
  26254. var twoDimVert0 = 2;
  26255. var twoDimVertR1 = 3;
  26256. var twoDimVertL1 = 4;
  26257. var twoDimVertR2 = 5;
  26258. var twoDimVertL2 = 6;
  26259. var twoDimVertR3 = 7;
  26260. var twoDimVertL3 = 8;
  26261. var twoDimTable = [
  26262. [
  26263. -1,
  26264. -1
  26265. ],
  26266. [
  26267. -1,
  26268. -1
  26269. ],
  26270. [
  26271. 7,
  26272. twoDimVertL3
  26273. ],
  26274. [
  26275. 7,
  26276. twoDimVertR3
  26277. ],
  26278. [
  26279. 6,
  26280. twoDimVertL2
  26281. ],
  26282. [
  26283. 6,
  26284. twoDimVertL2
  26285. ],
  26286. [
  26287. 6,
  26288. twoDimVertR2
  26289. ],
  26290. [
  26291. 6,
  26292. twoDimVertR2
  26293. ],
  26294. [
  26295. 4,
  26296. twoDimPass
  26297. ],
  26298. [
  26299. 4,
  26300. twoDimPass
  26301. ],
  26302. [
  26303. 4,
  26304. twoDimPass
  26305. ],
  26306. [
  26307. 4,
  26308. twoDimPass
  26309. ],
  26310. [
  26311. 4,
  26312. twoDimPass
  26313. ],
  26314. [
  26315. 4,
  26316. twoDimPass
  26317. ],
  26318. [
  26319. 4,
  26320. twoDimPass
  26321. ],
  26322. [
  26323. 4,
  26324. twoDimPass
  26325. ],
  26326. [
  26327. 3,
  26328. twoDimHoriz
  26329. ],
  26330. [
  26331. 3,
  26332. twoDimHoriz
  26333. ],
  26334. [
  26335. 3,
  26336. twoDimHoriz
  26337. ],
  26338. [
  26339. 3,
  26340. twoDimHoriz
  26341. ],
  26342. [
  26343. 3,
  26344. twoDimHoriz
  26345. ],
  26346. [
  26347. 3,
  26348. twoDimHoriz
  26349. ],
  26350. [
  26351. 3,
  26352. twoDimHoriz
  26353. ],
  26354. [
  26355. 3,
  26356. twoDimHoriz
  26357. ],
  26358. [
  26359. 3,
  26360. twoDimHoriz
  26361. ],
  26362. [
  26363. 3,
  26364. twoDimHoriz
  26365. ],
  26366. [
  26367. 3,
  26368. twoDimHoriz
  26369. ],
  26370. [
  26371. 3,
  26372. twoDimHoriz
  26373. ],
  26374. [
  26375. 3,
  26376. twoDimHoriz
  26377. ],
  26378. [
  26379. 3,
  26380. twoDimHoriz
  26381. ],
  26382. [
  26383. 3,
  26384. twoDimHoriz
  26385. ],
  26386. [
  26387. 3,
  26388. twoDimHoriz
  26389. ],
  26390. [
  26391. 3,
  26392. twoDimVertL1
  26393. ],
  26394. [
  26395. 3,
  26396. twoDimVertL1
  26397. ],
  26398. [
  26399. 3,
  26400. twoDimVertL1
  26401. ],
  26402. [
  26403. 3,
  26404. twoDimVertL1
  26405. ],
  26406. [
  26407. 3,
  26408. twoDimVertL1
  26409. ],
  26410. [
  26411. 3,
  26412. twoDimVertL1
  26413. ],
  26414. [
  26415. 3,
  26416. twoDimVertL1
  26417. ],
  26418. [
  26419. 3,
  26420. twoDimVertL1
  26421. ],
  26422. [
  26423. 3,
  26424. twoDimVertL1
  26425. ],
  26426. [
  26427. 3,
  26428. twoDimVertL1
  26429. ],
  26430. [
  26431. 3,
  26432. twoDimVertL1
  26433. ],
  26434. [
  26435. 3,
  26436. twoDimVertL1
  26437. ],
  26438. [
  26439. 3,
  26440. twoDimVertL1
  26441. ],
  26442. [
  26443. 3,
  26444. twoDimVertL1
  26445. ],
  26446. [
  26447. 3,
  26448. twoDimVertL1
  26449. ],
  26450. [
  26451. 3,
  26452. twoDimVertL1
  26453. ],
  26454. [
  26455. 3,
  26456. twoDimVertR1
  26457. ],
  26458. [
  26459. 3,
  26460. twoDimVertR1
  26461. ],
  26462. [
  26463. 3,
  26464. twoDimVertR1
  26465. ],
  26466. [
  26467. 3,
  26468. twoDimVertR1
  26469. ],
  26470. [
  26471. 3,
  26472. twoDimVertR1
  26473. ],
  26474. [
  26475. 3,
  26476. twoDimVertR1
  26477. ],
  26478. [
  26479. 3,
  26480. twoDimVertR1
  26481. ],
  26482. [
  26483. 3,
  26484. twoDimVertR1
  26485. ],
  26486. [
  26487. 3,
  26488. twoDimVertR1
  26489. ],
  26490. [
  26491. 3,
  26492. twoDimVertR1
  26493. ],
  26494. [
  26495. 3,
  26496. twoDimVertR1
  26497. ],
  26498. [
  26499. 3,
  26500. twoDimVertR1
  26501. ],
  26502. [
  26503. 3,
  26504. twoDimVertR1
  26505. ],
  26506. [
  26507. 3,
  26508. twoDimVertR1
  26509. ],
  26510. [
  26511. 3,
  26512. twoDimVertR1
  26513. ],
  26514. [
  26515. 3,
  26516. twoDimVertR1
  26517. ],
  26518. [
  26519. 1,
  26520. twoDimVert0
  26521. ],
  26522. [
  26523. 1,
  26524. twoDimVert0
  26525. ],
  26526. [
  26527. 1,
  26528. twoDimVert0
  26529. ],
  26530. [
  26531. 1,
  26532. twoDimVert0
  26533. ],
  26534. [
  26535. 1,
  26536. twoDimVert0
  26537. ],
  26538. [
  26539. 1,
  26540. twoDimVert0
  26541. ],
  26542. [
  26543. 1,
  26544. twoDimVert0
  26545. ],
  26546. [
  26547. 1,
  26548. twoDimVert0
  26549. ],
  26550. [
  26551. 1,
  26552. twoDimVert0
  26553. ],
  26554. [
  26555. 1,
  26556. twoDimVert0
  26557. ],
  26558. [
  26559. 1,
  26560. twoDimVert0
  26561. ],
  26562. [
  26563. 1,
  26564. twoDimVert0
  26565. ],
  26566. [
  26567. 1,
  26568. twoDimVert0
  26569. ],
  26570. [
  26571. 1,
  26572. twoDimVert0
  26573. ],
  26574. [
  26575. 1,
  26576. twoDimVert0
  26577. ],
  26578. [
  26579. 1,
  26580. twoDimVert0
  26581. ],
  26582. [
  26583. 1,
  26584. twoDimVert0
  26585. ],
  26586. [
  26587. 1,
  26588. twoDimVert0
  26589. ],
  26590. [
  26591. 1,
  26592. twoDimVert0
  26593. ],
  26594. [
  26595. 1,
  26596. twoDimVert0
  26597. ],
  26598. [
  26599. 1,
  26600. twoDimVert0
  26601. ],
  26602. [
  26603. 1,
  26604. twoDimVert0
  26605. ],
  26606. [
  26607. 1,
  26608. twoDimVert0
  26609. ],
  26610. [
  26611. 1,
  26612. twoDimVert0
  26613. ],
  26614. [
  26615. 1,
  26616. twoDimVert0
  26617. ],
  26618. [
  26619. 1,
  26620. twoDimVert0
  26621. ],
  26622. [
  26623. 1,
  26624. twoDimVert0
  26625. ],
  26626. [
  26627. 1,
  26628. twoDimVert0
  26629. ],
  26630. [
  26631. 1,
  26632. twoDimVert0
  26633. ],
  26634. [
  26635. 1,
  26636. twoDimVert0
  26637. ],
  26638. [
  26639. 1,
  26640. twoDimVert0
  26641. ],
  26642. [
  26643. 1,
  26644. twoDimVert0
  26645. ],
  26646. [
  26647. 1,
  26648. twoDimVert0
  26649. ],
  26650. [
  26651. 1,
  26652. twoDimVert0
  26653. ],
  26654. [
  26655. 1,
  26656. twoDimVert0
  26657. ],
  26658. [
  26659. 1,
  26660. twoDimVert0
  26661. ],
  26662. [
  26663. 1,
  26664. twoDimVert0
  26665. ],
  26666. [
  26667. 1,
  26668. twoDimVert0
  26669. ],
  26670. [
  26671. 1,
  26672. twoDimVert0
  26673. ],
  26674. [
  26675. 1,
  26676. twoDimVert0
  26677. ],
  26678. [
  26679. 1,
  26680. twoDimVert0
  26681. ],
  26682. [
  26683. 1,
  26684. twoDimVert0
  26685. ],
  26686. [
  26687. 1,
  26688. twoDimVert0
  26689. ],
  26690. [
  26691. 1,
  26692. twoDimVert0
  26693. ],
  26694. [
  26695. 1,
  26696. twoDimVert0
  26697. ],
  26698. [
  26699. 1,
  26700. twoDimVert0
  26701. ],
  26702. [
  26703. 1,
  26704. twoDimVert0
  26705. ],
  26706. [
  26707. 1,
  26708. twoDimVert0
  26709. ],
  26710. [
  26711. 1,
  26712. twoDimVert0
  26713. ],
  26714. [
  26715. 1,
  26716. twoDimVert0
  26717. ],
  26718. [
  26719. 1,
  26720. twoDimVert0
  26721. ],
  26722. [
  26723. 1,
  26724. twoDimVert0
  26725. ],
  26726. [
  26727. 1,
  26728. twoDimVert0
  26729. ],
  26730. [
  26731. 1,
  26732. twoDimVert0
  26733. ],
  26734. [
  26735. 1,
  26736. twoDimVert0
  26737. ],
  26738. [
  26739. 1,
  26740. twoDimVert0
  26741. ],
  26742. [
  26743. 1,
  26744. twoDimVert0
  26745. ],
  26746. [
  26747. 1,
  26748. twoDimVert0
  26749. ],
  26750. [
  26751. 1,
  26752. twoDimVert0
  26753. ],
  26754. [
  26755. 1,
  26756. twoDimVert0
  26757. ],
  26758. [
  26759. 1,
  26760. twoDimVert0
  26761. ],
  26762. [
  26763. 1,
  26764. twoDimVert0
  26765. ],
  26766. [
  26767. 1,
  26768. twoDimVert0
  26769. ],
  26770. [
  26771. 1,
  26772. twoDimVert0
  26773. ]
  26774. ];
  26775. var whiteTable1 = [
  26776. [
  26777. -1,
  26778. -1
  26779. ],
  26780. [
  26781. 12,
  26782. ccittEOL
  26783. ],
  26784. [
  26785. -1,
  26786. -1
  26787. ],
  26788. [
  26789. -1,
  26790. -1
  26791. ],
  26792. [
  26793. -1,
  26794. -1
  26795. ],
  26796. [
  26797. -1,
  26798. -1
  26799. ],
  26800. [
  26801. -1,
  26802. -1
  26803. ],
  26804. [
  26805. -1,
  26806. -1
  26807. ],
  26808. [
  26809. -1,
  26810. -1
  26811. ],
  26812. [
  26813. -1,
  26814. -1
  26815. ],
  26816. [
  26817. -1,
  26818. -1
  26819. ],
  26820. [
  26821. -1,
  26822. -1
  26823. ],
  26824. [
  26825. -1,
  26826. -1
  26827. ],
  26828. [
  26829. -1,
  26830. -1
  26831. ],
  26832. [
  26833. -1,
  26834. -1
  26835. ],
  26836. [
  26837. -1,
  26838. -1
  26839. ],
  26840. [
  26841. 11,
  26842. 1792
  26843. ],
  26844. [
  26845. 11,
  26846. 1792
  26847. ],
  26848. [
  26849. 12,
  26850. 1984
  26851. ],
  26852. [
  26853. 12,
  26854. 2048
  26855. ],
  26856. [
  26857. 12,
  26858. 2112
  26859. ],
  26860. [
  26861. 12,
  26862. 2176
  26863. ],
  26864. [
  26865. 12,
  26866. 2240
  26867. ],
  26868. [
  26869. 12,
  26870. 2304
  26871. ],
  26872. [
  26873. 11,
  26874. 1856
  26875. ],
  26876. [
  26877. 11,
  26878. 1856
  26879. ],
  26880. [
  26881. 11,
  26882. 1920
  26883. ],
  26884. [
  26885. 11,
  26886. 1920
  26887. ],
  26888. [
  26889. 12,
  26890. 2368
  26891. ],
  26892. [
  26893. 12,
  26894. 2432
  26895. ],
  26896. [
  26897. 12,
  26898. 2496
  26899. ],
  26900. [
  26901. 12,
  26902. 2560
  26903. ]
  26904. ];
  26905. var whiteTable2 = [
  26906. [
  26907. -1,
  26908. -1
  26909. ],
  26910. [
  26911. -1,
  26912. -1
  26913. ],
  26914. [
  26915. -1,
  26916. -1
  26917. ],
  26918. [
  26919. -1,
  26920. -1
  26921. ],
  26922. [
  26923. 8,
  26924. 29
  26925. ],
  26926. [
  26927. 8,
  26928. 29
  26929. ],
  26930. [
  26931. 8,
  26932. 30
  26933. ],
  26934. [
  26935. 8,
  26936. 30
  26937. ],
  26938. [
  26939. 8,
  26940. 45
  26941. ],
  26942. [
  26943. 8,
  26944. 45
  26945. ],
  26946. [
  26947. 8,
  26948. 46
  26949. ],
  26950. [
  26951. 8,
  26952. 46
  26953. ],
  26954. [
  26955. 7,
  26956. 22
  26957. ],
  26958. [
  26959. 7,
  26960. 22
  26961. ],
  26962. [
  26963. 7,
  26964. 22
  26965. ],
  26966. [
  26967. 7,
  26968. 22
  26969. ],
  26970. [
  26971. 7,
  26972. 23
  26973. ],
  26974. [
  26975. 7,
  26976. 23
  26977. ],
  26978. [
  26979. 7,
  26980. 23
  26981. ],
  26982. [
  26983. 7,
  26984. 23
  26985. ],
  26986. [
  26987. 8,
  26988. 47
  26989. ],
  26990. [
  26991. 8,
  26992. 47
  26993. ],
  26994. [
  26995. 8,
  26996. 48
  26997. ],
  26998. [
  26999. 8,
  27000. 48
  27001. ],
  27002. [
  27003. 6,
  27004. 13
  27005. ],
  27006. [
  27007. 6,
  27008. 13
  27009. ],
  27010. [
  27011. 6,
  27012. 13
  27013. ],
  27014. [
  27015. 6,
  27016. 13
  27017. ],
  27018. [
  27019. 6,
  27020. 13
  27021. ],
  27022. [
  27023. 6,
  27024. 13
  27025. ],
  27026. [
  27027. 6,
  27028. 13
  27029. ],
  27030. [
  27031. 6,
  27032. 13
  27033. ],
  27034. [
  27035. 7,
  27036. 20
  27037. ],
  27038. [
  27039. 7,
  27040. 20
  27041. ],
  27042. [
  27043. 7,
  27044. 20
  27045. ],
  27046. [
  27047. 7,
  27048. 20
  27049. ],
  27050. [
  27051. 8,
  27052. 33
  27053. ],
  27054. [
  27055. 8,
  27056. 33
  27057. ],
  27058. [
  27059. 8,
  27060. 34
  27061. ],
  27062. [
  27063. 8,
  27064. 34
  27065. ],
  27066. [
  27067. 8,
  27068. 35
  27069. ],
  27070. [
  27071. 8,
  27072. 35
  27073. ],
  27074. [
  27075. 8,
  27076. 36
  27077. ],
  27078. [
  27079. 8,
  27080. 36
  27081. ],
  27082. [
  27083. 8,
  27084. 37
  27085. ],
  27086. [
  27087. 8,
  27088. 37
  27089. ],
  27090. [
  27091. 8,
  27092. 38
  27093. ],
  27094. [
  27095. 8,
  27096. 38
  27097. ],
  27098. [
  27099. 7,
  27100. 19
  27101. ],
  27102. [
  27103. 7,
  27104. 19
  27105. ],
  27106. [
  27107. 7,
  27108. 19
  27109. ],
  27110. [
  27111. 7,
  27112. 19
  27113. ],
  27114. [
  27115. 8,
  27116. 31
  27117. ],
  27118. [
  27119. 8,
  27120. 31
  27121. ],
  27122. [
  27123. 8,
  27124. 32
  27125. ],
  27126. [
  27127. 8,
  27128. 32
  27129. ],
  27130. [
  27131. 6,
  27132. 1
  27133. ],
  27134. [
  27135. 6,
  27136. 1
  27137. ],
  27138. [
  27139. 6,
  27140. 1
  27141. ],
  27142. [
  27143. 6,
  27144. 1
  27145. ],
  27146. [
  27147. 6,
  27148. 1
  27149. ],
  27150. [
  27151. 6,
  27152. 1
  27153. ],
  27154. [
  27155. 6,
  27156. 1
  27157. ],
  27158. [
  27159. 6,
  27160. 1
  27161. ],
  27162. [
  27163. 6,
  27164. 12
  27165. ],
  27166. [
  27167. 6,
  27168. 12
  27169. ],
  27170. [
  27171. 6,
  27172. 12
  27173. ],
  27174. [
  27175. 6,
  27176. 12
  27177. ],
  27178. [
  27179. 6,
  27180. 12
  27181. ],
  27182. [
  27183. 6,
  27184. 12
  27185. ],
  27186. [
  27187. 6,
  27188. 12
  27189. ],
  27190. [
  27191. 6,
  27192. 12
  27193. ],
  27194. [
  27195. 8,
  27196. 53
  27197. ],
  27198. [
  27199. 8,
  27200. 53
  27201. ],
  27202. [
  27203. 8,
  27204. 54
  27205. ],
  27206. [
  27207. 8,
  27208. 54
  27209. ],
  27210. [
  27211. 7,
  27212. 26
  27213. ],
  27214. [
  27215. 7,
  27216. 26
  27217. ],
  27218. [
  27219. 7,
  27220. 26
  27221. ],
  27222. [
  27223. 7,
  27224. 26
  27225. ],
  27226. [
  27227. 8,
  27228. 39
  27229. ],
  27230. [
  27231. 8,
  27232. 39
  27233. ],
  27234. [
  27235. 8,
  27236. 40
  27237. ],
  27238. [
  27239. 8,
  27240. 40
  27241. ],
  27242. [
  27243. 8,
  27244. 41
  27245. ],
  27246. [
  27247. 8,
  27248. 41
  27249. ],
  27250. [
  27251. 8,
  27252. 42
  27253. ],
  27254. [
  27255. 8,
  27256. 42
  27257. ],
  27258. [
  27259. 8,
  27260. 43
  27261. ],
  27262. [
  27263. 8,
  27264. 43
  27265. ],
  27266. [
  27267. 8,
  27268. 44
  27269. ],
  27270. [
  27271. 8,
  27272. 44
  27273. ],
  27274. [
  27275. 7,
  27276. 21
  27277. ],
  27278. [
  27279. 7,
  27280. 21
  27281. ],
  27282. [
  27283. 7,
  27284. 21
  27285. ],
  27286. [
  27287. 7,
  27288. 21
  27289. ],
  27290. [
  27291. 7,
  27292. 28
  27293. ],
  27294. [
  27295. 7,
  27296. 28
  27297. ],
  27298. [
  27299. 7,
  27300. 28
  27301. ],
  27302. [
  27303. 7,
  27304. 28
  27305. ],
  27306. [
  27307. 8,
  27308. 61
  27309. ],
  27310. [
  27311. 8,
  27312. 61
  27313. ],
  27314. [
  27315. 8,
  27316. 62
  27317. ],
  27318. [
  27319. 8,
  27320. 62
  27321. ],
  27322. [
  27323. 8,
  27324. 63
  27325. ],
  27326. [
  27327. 8,
  27328. 63
  27329. ],
  27330. [
  27331. 8,
  27332. 0
  27333. ],
  27334. [
  27335. 8,
  27336. 0
  27337. ],
  27338. [
  27339. 8,
  27340. 320
  27341. ],
  27342. [
  27343. 8,
  27344. 320
  27345. ],
  27346. [
  27347. 8,
  27348. 384
  27349. ],
  27350. [
  27351. 8,
  27352. 384
  27353. ],
  27354. [
  27355. 5,
  27356. 10
  27357. ],
  27358. [
  27359. 5,
  27360. 10
  27361. ],
  27362. [
  27363. 5,
  27364. 10
  27365. ],
  27366. [
  27367. 5,
  27368. 10
  27369. ],
  27370. [
  27371. 5,
  27372. 10
  27373. ],
  27374. [
  27375. 5,
  27376. 10
  27377. ],
  27378. [
  27379. 5,
  27380. 10
  27381. ],
  27382. [
  27383. 5,
  27384. 10
  27385. ],
  27386. [
  27387. 5,
  27388. 10
  27389. ],
  27390. [
  27391. 5,
  27392. 10
  27393. ],
  27394. [
  27395. 5,
  27396. 10
  27397. ],
  27398. [
  27399. 5,
  27400. 10
  27401. ],
  27402. [
  27403. 5,
  27404. 10
  27405. ],
  27406. [
  27407. 5,
  27408. 10
  27409. ],
  27410. [
  27411. 5,
  27412. 10
  27413. ],
  27414. [
  27415. 5,
  27416. 10
  27417. ],
  27418. [
  27419. 5,
  27420. 11
  27421. ],
  27422. [
  27423. 5,
  27424. 11
  27425. ],
  27426. [
  27427. 5,
  27428. 11
  27429. ],
  27430. [
  27431. 5,
  27432. 11
  27433. ],
  27434. [
  27435. 5,
  27436. 11
  27437. ],
  27438. [
  27439. 5,
  27440. 11
  27441. ],
  27442. [
  27443. 5,
  27444. 11
  27445. ],
  27446. [
  27447. 5,
  27448. 11
  27449. ],
  27450. [
  27451. 5,
  27452. 11
  27453. ],
  27454. [
  27455. 5,
  27456. 11
  27457. ],
  27458. [
  27459. 5,
  27460. 11
  27461. ],
  27462. [
  27463. 5,
  27464. 11
  27465. ],
  27466. [
  27467. 5,
  27468. 11
  27469. ],
  27470. [
  27471. 5,
  27472. 11
  27473. ],
  27474. [
  27475. 5,
  27476. 11
  27477. ],
  27478. [
  27479. 5,
  27480. 11
  27481. ],
  27482. [
  27483. 7,
  27484. 27
  27485. ],
  27486. [
  27487. 7,
  27488. 27
  27489. ],
  27490. [
  27491. 7,
  27492. 27
  27493. ],
  27494. [
  27495. 7,
  27496. 27
  27497. ],
  27498. [
  27499. 8,
  27500. 59
  27501. ],
  27502. [
  27503. 8,
  27504. 59
  27505. ],
  27506. [
  27507. 8,
  27508. 60
  27509. ],
  27510. [
  27511. 8,
  27512. 60
  27513. ],
  27514. [
  27515. 9,
  27516. 1472
  27517. ],
  27518. [
  27519. 9,
  27520. 1536
  27521. ],
  27522. [
  27523. 9,
  27524. 1600
  27525. ],
  27526. [
  27527. 9,
  27528. 1728
  27529. ],
  27530. [
  27531. 7,
  27532. 18
  27533. ],
  27534. [
  27535. 7,
  27536. 18
  27537. ],
  27538. [
  27539. 7,
  27540. 18
  27541. ],
  27542. [
  27543. 7,
  27544. 18
  27545. ],
  27546. [
  27547. 7,
  27548. 24
  27549. ],
  27550. [
  27551. 7,
  27552. 24
  27553. ],
  27554. [
  27555. 7,
  27556. 24
  27557. ],
  27558. [
  27559. 7,
  27560. 24
  27561. ],
  27562. [
  27563. 8,
  27564. 49
  27565. ],
  27566. [
  27567. 8,
  27568. 49
  27569. ],
  27570. [
  27571. 8,
  27572. 50
  27573. ],
  27574. [
  27575. 8,
  27576. 50
  27577. ],
  27578. [
  27579. 8,
  27580. 51
  27581. ],
  27582. [
  27583. 8,
  27584. 51
  27585. ],
  27586. [
  27587. 8,
  27588. 52
  27589. ],
  27590. [
  27591. 8,
  27592. 52
  27593. ],
  27594. [
  27595. 7,
  27596. 25
  27597. ],
  27598. [
  27599. 7,
  27600. 25
  27601. ],
  27602. [
  27603. 7,
  27604. 25
  27605. ],
  27606. [
  27607. 7,
  27608. 25
  27609. ],
  27610. [
  27611. 8,
  27612. 55
  27613. ],
  27614. [
  27615. 8,
  27616. 55
  27617. ],
  27618. [
  27619. 8,
  27620. 56
  27621. ],
  27622. [
  27623. 8,
  27624. 56
  27625. ],
  27626. [
  27627. 8,
  27628. 57
  27629. ],
  27630. [
  27631. 8,
  27632. 57
  27633. ],
  27634. [
  27635. 8,
  27636. 58
  27637. ],
  27638. [
  27639. 8,
  27640. 58
  27641. ],
  27642. [
  27643. 6,
  27644. 192
  27645. ],
  27646. [
  27647. 6,
  27648. 192
  27649. ],
  27650. [
  27651. 6,
  27652. 192
  27653. ],
  27654. [
  27655. 6,
  27656. 192
  27657. ],
  27658. [
  27659. 6,
  27660. 192
  27661. ],
  27662. [
  27663. 6,
  27664. 192
  27665. ],
  27666. [
  27667. 6,
  27668. 192
  27669. ],
  27670. [
  27671. 6,
  27672. 192
  27673. ],
  27674. [
  27675. 6,
  27676. 1664
  27677. ],
  27678. [
  27679. 6,
  27680. 1664
  27681. ],
  27682. [
  27683. 6,
  27684. 1664
  27685. ],
  27686. [
  27687. 6,
  27688. 1664
  27689. ],
  27690. [
  27691. 6,
  27692. 1664
  27693. ],
  27694. [
  27695. 6,
  27696. 1664
  27697. ],
  27698. [
  27699. 6,
  27700. 1664
  27701. ],
  27702. [
  27703. 6,
  27704. 1664
  27705. ],
  27706. [
  27707. 8,
  27708. 448
  27709. ],
  27710. [
  27711. 8,
  27712. 448
  27713. ],
  27714. [
  27715. 8,
  27716. 512
  27717. ],
  27718. [
  27719. 8,
  27720. 512
  27721. ],
  27722. [
  27723. 9,
  27724. 704
  27725. ],
  27726. [
  27727. 9,
  27728. 768
  27729. ],
  27730. [
  27731. 8,
  27732. 640
  27733. ],
  27734. [
  27735. 8,
  27736. 640
  27737. ],
  27738. [
  27739. 8,
  27740. 576
  27741. ],
  27742. [
  27743. 8,
  27744. 576
  27745. ],
  27746. [
  27747. 9,
  27748. 832
  27749. ],
  27750. [
  27751. 9,
  27752. 896
  27753. ],
  27754. [
  27755. 9,
  27756. 960
  27757. ],
  27758. [
  27759. 9,
  27760. 1024
  27761. ],
  27762. [
  27763. 9,
  27764. 1088
  27765. ],
  27766. [
  27767. 9,
  27768. 1152
  27769. ],
  27770. [
  27771. 9,
  27772. 1216
  27773. ],
  27774. [
  27775. 9,
  27776. 1280
  27777. ],
  27778. [
  27779. 9,
  27780. 1344
  27781. ],
  27782. [
  27783. 9,
  27784. 1408
  27785. ],
  27786. [
  27787. 7,
  27788. 256
  27789. ],
  27790. [
  27791. 7,
  27792. 256
  27793. ],
  27794. [
  27795. 7,
  27796. 256
  27797. ],
  27798. [
  27799. 7,
  27800. 256
  27801. ],
  27802. [
  27803. 4,
  27804. 2
  27805. ],
  27806. [
  27807. 4,
  27808. 2
  27809. ],
  27810. [
  27811. 4,
  27812. 2
  27813. ],
  27814. [
  27815. 4,
  27816. 2
  27817. ],
  27818. [
  27819. 4,
  27820. 2
  27821. ],
  27822. [
  27823. 4,
  27824. 2
  27825. ],
  27826. [
  27827. 4,
  27828. 2
  27829. ],
  27830. [
  27831. 4,
  27832. 2
  27833. ],
  27834. [
  27835. 4,
  27836. 2
  27837. ],
  27838. [
  27839. 4,
  27840. 2
  27841. ],
  27842. [
  27843. 4,
  27844. 2
  27845. ],
  27846. [
  27847. 4,
  27848. 2
  27849. ],
  27850. [
  27851. 4,
  27852. 2
  27853. ],
  27854. [
  27855. 4,
  27856. 2
  27857. ],
  27858. [
  27859. 4,
  27860. 2
  27861. ],
  27862. [
  27863. 4,
  27864. 2
  27865. ],
  27866. [
  27867. 4,
  27868. 2
  27869. ],
  27870. [
  27871. 4,
  27872. 2
  27873. ],
  27874. [
  27875. 4,
  27876. 2
  27877. ],
  27878. [
  27879. 4,
  27880. 2
  27881. ],
  27882. [
  27883. 4,
  27884. 2
  27885. ],
  27886. [
  27887. 4,
  27888. 2
  27889. ],
  27890. [
  27891. 4,
  27892. 2
  27893. ],
  27894. [
  27895. 4,
  27896. 2
  27897. ],
  27898. [
  27899. 4,
  27900. 2
  27901. ],
  27902. [
  27903. 4,
  27904. 2
  27905. ],
  27906. [
  27907. 4,
  27908. 2
  27909. ],
  27910. [
  27911. 4,
  27912. 2
  27913. ],
  27914. [
  27915. 4,
  27916. 2
  27917. ],
  27918. [
  27919. 4,
  27920. 2
  27921. ],
  27922. [
  27923. 4,
  27924. 2
  27925. ],
  27926. [
  27927. 4,
  27928. 2
  27929. ],
  27930. [
  27931. 4,
  27932. 3
  27933. ],
  27934. [
  27935. 4,
  27936. 3
  27937. ],
  27938. [
  27939. 4,
  27940. 3
  27941. ],
  27942. [
  27943. 4,
  27944. 3
  27945. ],
  27946. [
  27947. 4,
  27948. 3
  27949. ],
  27950. [
  27951. 4,
  27952. 3
  27953. ],
  27954. [
  27955. 4,
  27956. 3
  27957. ],
  27958. [
  27959. 4,
  27960. 3
  27961. ],
  27962. [
  27963. 4,
  27964. 3
  27965. ],
  27966. [
  27967. 4,
  27968. 3
  27969. ],
  27970. [
  27971. 4,
  27972. 3
  27973. ],
  27974. [
  27975. 4,
  27976. 3
  27977. ],
  27978. [
  27979. 4,
  27980. 3
  27981. ],
  27982. [
  27983. 4,
  27984. 3
  27985. ],
  27986. [
  27987. 4,
  27988. 3
  27989. ],
  27990. [
  27991. 4,
  27992. 3
  27993. ],
  27994. [
  27995. 4,
  27996. 3
  27997. ],
  27998. [
  27999. 4,
  28000. 3
  28001. ],
  28002. [
  28003. 4,
  28004. 3
  28005. ],
  28006. [
  28007. 4,
  28008. 3
  28009. ],
  28010. [
  28011. 4,
  28012. 3
  28013. ],
  28014. [
  28015. 4,
  28016. 3
  28017. ],
  28018. [
  28019. 4,
  28020. 3
  28021. ],
  28022. [
  28023. 4,
  28024. 3
  28025. ],
  28026. [
  28027. 4,
  28028. 3
  28029. ],
  28030. [
  28031. 4,
  28032. 3
  28033. ],
  28034. [
  28035. 4,
  28036. 3
  28037. ],
  28038. [
  28039. 4,
  28040. 3
  28041. ],
  28042. [
  28043. 4,
  28044. 3
  28045. ],
  28046. [
  28047. 4,
  28048. 3
  28049. ],
  28050. [
  28051. 4,
  28052. 3
  28053. ],
  28054. [
  28055. 4,
  28056. 3
  28057. ],
  28058. [
  28059. 5,
  28060. 128
  28061. ],
  28062. [
  28063. 5,
  28064. 128
  28065. ],
  28066. [
  28067. 5,
  28068. 128
  28069. ],
  28070. [
  28071. 5,
  28072. 128
  28073. ],
  28074. [
  28075. 5,
  28076. 128
  28077. ],
  28078. [
  28079. 5,
  28080. 128
  28081. ],
  28082. [
  28083. 5,
  28084. 128
  28085. ],
  28086. [
  28087. 5,
  28088. 128
  28089. ],
  28090. [
  28091. 5,
  28092. 128
  28093. ],
  28094. [
  28095. 5,
  28096. 128
  28097. ],
  28098. [
  28099. 5,
  28100. 128
  28101. ],
  28102. [
  28103. 5,
  28104. 128
  28105. ],
  28106. [
  28107. 5,
  28108. 128
  28109. ],
  28110. [
  28111. 5,
  28112. 128
  28113. ],
  28114. [
  28115. 5,
  28116. 128
  28117. ],
  28118. [
  28119. 5,
  28120. 128
  28121. ],
  28122. [
  28123. 5,
  28124. 8
  28125. ],
  28126. [
  28127. 5,
  28128. 8
  28129. ],
  28130. [
  28131. 5,
  28132. 8
  28133. ],
  28134. [
  28135. 5,
  28136. 8
  28137. ],
  28138. [
  28139. 5,
  28140. 8
  28141. ],
  28142. [
  28143. 5,
  28144. 8
  28145. ],
  28146. [
  28147. 5,
  28148. 8
  28149. ],
  28150. [
  28151. 5,
  28152. 8
  28153. ],
  28154. [
  28155. 5,
  28156. 8
  28157. ],
  28158. [
  28159. 5,
  28160. 8
  28161. ],
  28162. [
  28163. 5,
  28164. 8
  28165. ],
  28166. [
  28167. 5,
  28168. 8
  28169. ],
  28170. [
  28171. 5,
  28172. 8
  28173. ],
  28174. [
  28175. 5,
  28176. 8
  28177. ],
  28178. [
  28179. 5,
  28180. 8
  28181. ],
  28182. [
  28183. 5,
  28184. 8
  28185. ],
  28186. [
  28187. 5,
  28188. 9
  28189. ],
  28190. [
  28191. 5,
  28192. 9
  28193. ],
  28194. [
  28195. 5,
  28196. 9
  28197. ],
  28198. [
  28199. 5,
  28200. 9
  28201. ],
  28202. [
  28203. 5,
  28204. 9
  28205. ],
  28206. [
  28207. 5,
  28208. 9
  28209. ],
  28210. [
  28211. 5,
  28212. 9
  28213. ],
  28214. [
  28215. 5,
  28216. 9
  28217. ],
  28218. [
  28219. 5,
  28220. 9
  28221. ],
  28222. [
  28223. 5,
  28224. 9
  28225. ],
  28226. [
  28227. 5,
  28228. 9
  28229. ],
  28230. [
  28231. 5,
  28232. 9
  28233. ],
  28234. [
  28235. 5,
  28236. 9
  28237. ],
  28238. [
  28239. 5,
  28240. 9
  28241. ],
  28242. [
  28243. 5,
  28244. 9
  28245. ],
  28246. [
  28247. 5,
  28248. 9
  28249. ],
  28250. [
  28251. 6,
  28252. 16
  28253. ],
  28254. [
  28255. 6,
  28256. 16
  28257. ],
  28258. [
  28259. 6,
  28260. 16
  28261. ],
  28262. [
  28263. 6,
  28264. 16
  28265. ],
  28266. [
  28267. 6,
  28268. 16
  28269. ],
  28270. [
  28271. 6,
  28272. 16
  28273. ],
  28274. [
  28275. 6,
  28276. 16
  28277. ],
  28278. [
  28279. 6,
  28280. 16
  28281. ],
  28282. [
  28283. 6,
  28284. 17
  28285. ],
  28286. [
  28287. 6,
  28288. 17
  28289. ],
  28290. [
  28291. 6,
  28292. 17
  28293. ],
  28294. [
  28295. 6,
  28296. 17
  28297. ],
  28298. [
  28299. 6,
  28300. 17
  28301. ],
  28302. [
  28303. 6,
  28304. 17
  28305. ],
  28306. [
  28307. 6,
  28308. 17
  28309. ],
  28310. [
  28311. 6,
  28312. 17
  28313. ],
  28314. [
  28315. 4,
  28316. 4
  28317. ],
  28318. [
  28319. 4,
  28320. 4
  28321. ],
  28322. [
  28323. 4,
  28324. 4
  28325. ],
  28326. [
  28327. 4,
  28328. 4
  28329. ],
  28330. [
  28331. 4,
  28332. 4
  28333. ],
  28334. [
  28335. 4,
  28336. 4
  28337. ],
  28338. [
  28339. 4,
  28340. 4
  28341. ],
  28342. [
  28343. 4,
  28344. 4
  28345. ],
  28346. [
  28347. 4,
  28348. 4
  28349. ],
  28350. [
  28351. 4,
  28352. 4
  28353. ],
  28354. [
  28355. 4,
  28356. 4
  28357. ],
  28358. [
  28359. 4,
  28360. 4
  28361. ],
  28362. [
  28363. 4,
  28364. 4
  28365. ],
  28366. [
  28367. 4,
  28368. 4
  28369. ],
  28370. [
  28371. 4,
  28372. 4
  28373. ],
  28374. [
  28375. 4,
  28376. 4
  28377. ],
  28378. [
  28379. 4,
  28380. 4
  28381. ],
  28382. [
  28383. 4,
  28384. 4
  28385. ],
  28386. [
  28387. 4,
  28388. 4
  28389. ],
  28390. [
  28391. 4,
  28392. 4
  28393. ],
  28394. [
  28395. 4,
  28396. 4
  28397. ],
  28398. [
  28399. 4,
  28400. 4
  28401. ],
  28402. [
  28403. 4,
  28404. 4
  28405. ],
  28406. [
  28407. 4,
  28408. 4
  28409. ],
  28410. [
  28411. 4,
  28412. 4
  28413. ],
  28414. [
  28415. 4,
  28416. 4
  28417. ],
  28418. [
  28419. 4,
  28420. 4
  28421. ],
  28422. [
  28423. 4,
  28424. 4
  28425. ],
  28426. [
  28427. 4,
  28428. 4
  28429. ],
  28430. [
  28431. 4,
  28432. 4
  28433. ],
  28434. [
  28435. 4,
  28436. 4
  28437. ],
  28438. [
  28439. 4,
  28440. 4
  28441. ],
  28442. [
  28443. 4,
  28444. 5
  28445. ],
  28446. [
  28447. 4,
  28448. 5
  28449. ],
  28450. [
  28451. 4,
  28452. 5
  28453. ],
  28454. [
  28455. 4,
  28456. 5
  28457. ],
  28458. [
  28459. 4,
  28460. 5
  28461. ],
  28462. [
  28463. 4,
  28464. 5
  28465. ],
  28466. [
  28467. 4,
  28468. 5
  28469. ],
  28470. [
  28471. 4,
  28472. 5
  28473. ],
  28474. [
  28475. 4,
  28476. 5
  28477. ],
  28478. [
  28479. 4,
  28480. 5
  28481. ],
  28482. [
  28483. 4,
  28484. 5
  28485. ],
  28486. [
  28487. 4,
  28488. 5
  28489. ],
  28490. [
  28491. 4,
  28492. 5
  28493. ],
  28494. [
  28495. 4,
  28496. 5
  28497. ],
  28498. [
  28499. 4,
  28500. 5
  28501. ],
  28502. [
  28503. 4,
  28504. 5
  28505. ],
  28506. [
  28507. 4,
  28508. 5
  28509. ],
  28510. [
  28511. 4,
  28512. 5
  28513. ],
  28514. [
  28515. 4,
  28516. 5
  28517. ],
  28518. [
  28519. 4,
  28520. 5
  28521. ],
  28522. [
  28523. 4,
  28524. 5
  28525. ],
  28526. [
  28527. 4,
  28528. 5
  28529. ],
  28530. [
  28531. 4,
  28532. 5
  28533. ],
  28534. [
  28535. 4,
  28536. 5
  28537. ],
  28538. [
  28539. 4,
  28540. 5
  28541. ],
  28542. [
  28543. 4,
  28544. 5
  28545. ],
  28546. [
  28547. 4,
  28548. 5
  28549. ],
  28550. [
  28551. 4,
  28552. 5
  28553. ],
  28554. [
  28555. 4,
  28556. 5
  28557. ],
  28558. [
  28559. 4,
  28560. 5
  28561. ],
  28562. [
  28563. 4,
  28564. 5
  28565. ],
  28566. [
  28567. 4,
  28568. 5
  28569. ],
  28570. [
  28571. 6,
  28572. 14
  28573. ],
  28574. [
  28575. 6,
  28576. 14
  28577. ],
  28578. [
  28579. 6,
  28580. 14
  28581. ],
  28582. [
  28583. 6,
  28584. 14
  28585. ],
  28586. [
  28587. 6,
  28588. 14
  28589. ],
  28590. [
  28591. 6,
  28592. 14
  28593. ],
  28594. [
  28595. 6,
  28596. 14
  28597. ],
  28598. [
  28599. 6,
  28600. 14
  28601. ],
  28602. [
  28603. 6,
  28604. 15
  28605. ],
  28606. [
  28607. 6,
  28608. 15
  28609. ],
  28610. [
  28611. 6,
  28612. 15
  28613. ],
  28614. [
  28615. 6,
  28616. 15
  28617. ],
  28618. [
  28619. 6,
  28620. 15
  28621. ],
  28622. [
  28623. 6,
  28624. 15
  28625. ],
  28626. [
  28627. 6,
  28628. 15
  28629. ],
  28630. [
  28631. 6,
  28632. 15
  28633. ],
  28634. [
  28635. 5,
  28636. 64
  28637. ],
  28638. [
  28639. 5,
  28640. 64
  28641. ],
  28642. [
  28643. 5,
  28644. 64
  28645. ],
  28646. [
  28647. 5,
  28648. 64
  28649. ],
  28650. [
  28651. 5,
  28652. 64
  28653. ],
  28654. [
  28655. 5,
  28656. 64
  28657. ],
  28658. [
  28659. 5,
  28660. 64
  28661. ],
  28662. [
  28663. 5,
  28664. 64
  28665. ],
  28666. [
  28667. 5,
  28668. 64
  28669. ],
  28670. [
  28671. 5,
  28672. 64
  28673. ],
  28674. [
  28675. 5,
  28676. 64
  28677. ],
  28678. [
  28679. 5,
  28680. 64
  28681. ],
  28682. [
  28683. 5,
  28684. 64
  28685. ],
  28686. [
  28687. 5,
  28688. 64
  28689. ],
  28690. [
  28691. 5,
  28692. 64
  28693. ],
  28694. [
  28695. 5,
  28696. 64
  28697. ],
  28698. [
  28699. 4,
  28700. 6
  28701. ],
  28702. [
  28703. 4,
  28704. 6
  28705. ],
  28706. [
  28707. 4,
  28708. 6
  28709. ],
  28710. [
  28711. 4,
  28712. 6
  28713. ],
  28714. [
  28715. 4,
  28716. 6
  28717. ],
  28718. [
  28719. 4,
  28720. 6
  28721. ],
  28722. [
  28723. 4,
  28724. 6
  28725. ],
  28726. [
  28727. 4,
  28728. 6
  28729. ],
  28730. [
  28731. 4,
  28732. 6
  28733. ],
  28734. [
  28735. 4,
  28736. 6
  28737. ],
  28738. [
  28739. 4,
  28740. 6
  28741. ],
  28742. [
  28743. 4,
  28744. 6
  28745. ],
  28746. [
  28747. 4,
  28748. 6
  28749. ],
  28750. [
  28751. 4,
  28752. 6
  28753. ],
  28754. [
  28755. 4,
  28756. 6
  28757. ],
  28758. [
  28759. 4,
  28760. 6
  28761. ],
  28762. [
  28763. 4,
  28764. 6
  28765. ],
  28766. [
  28767. 4,
  28768. 6
  28769. ],
  28770. [
  28771. 4,
  28772. 6
  28773. ],
  28774. [
  28775. 4,
  28776. 6
  28777. ],
  28778. [
  28779. 4,
  28780. 6
  28781. ],
  28782. [
  28783. 4,
  28784. 6
  28785. ],
  28786. [
  28787. 4,
  28788. 6
  28789. ],
  28790. [
  28791. 4,
  28792. 6
  28793. ],
  28794. [
  28795. 4,
  28796. 6
  28797. ],
  28798. [
  28799. 4,
  28800. 6
  28801. ],
  28802. [
  28803. 4,
  28804. 6
  28805. ],
  28806. [
  28807. 4,
  28808. 6
  28809. ],
  28810. [
  28811. 4,
  28812. 6
  28813. ],
  28814. [
  28815. 4,
  28816. 6
  28817. ],
  28818. [
  28819. 4,
  28820. 6
  28821. ],
  28822. [
  28823. 4,
  28824. 6
  28825. ],
  28826. [
  28827. 4,
  28828. 7
  28829. ],
  28830. [
  28831. 4,
  28832. 7
  28833. ],
  28834. [
  28835. 4,
  28836. 7
  28837. ],
  28838. [
  28839. 4,
  28840. 7
  28841. ],
  28842. [
  28843. 4,
  28844. 7
  28845. ],
  28846. [
  28847. 4,
  28848. 7
  28849. ],
  28850. [
  28851. 4,
  28852. 7
  28853. ],
  28854. [
  28855. 4,
  28856. 7
  28857. ],
  28858. [
  28859. 4,
  28860. 7
  28861. ],
  28862. [
  28863. 4,
  28864. 7
  28865. ],
  28866. [
  28867. 4,
  28868. 7
  28869. ],
  28870. [
  28871. 4,
  28872. 7
  28873. ],
  28874. [
  28875. 4,
  28876. 7
  28877. ],
  28878. [
  28879. 4,
  28880. 7
  28881. ],
  28882. [
  28883. 4,
  28884. 7
  28885. ],
  28886. [
  28887. 4,
  28888. 7
  28889. ],
  28890. [
  28891. 4,
  28892. 7
  28893. ],
  28894. [
  28895. 4,
  28896. 7
  28897. ],
  28898. [
  28899. 4,
  28900. 7
  28901. ],
  28902. [
  28903. 4,
  28904. 7
  28905. ],
  28906. [
  28907. 4,
  28908. 7
  28909. ],
  28910. [
  28911. 4,
  28912. 7
  28913. ],
  28914. [
  28915. 4,
  28916. 7
  28917. ],
  28918. [
  28919. 4,
  28920. 7
  28921. ],
  28922. [
  28923. 4,
  28924. 7
  28925. ],
  28926. [
  28927. 4,
  28928. 7
  28929. ],
  28930. [
  28931. 4,
  28932. 7
  28933. ],
  28934. [
  28935. 4,
  28936. 7
  28937. ],
  28938. [
  28939. 4,
  28940. 7
  28941. ],
  28942. [
  28943. 4,
  28944. 7
  28945. ],
  28946. [
  28947. 4,
  28948. 7
  28949. ],
  28950. [
  28951. 4,
  28952. 7
  28953. ]
  28954. ];
  28955. var blackTable1 = [
  28956. [
  28957. -1,
  28958. -1
  28959. ],
  28960. [
  28961. -1,
  28962. -1
  28963. ],
  28964. [
  28965. 12,
  28966. ccittEOL
  28967. ],
  28968. [
  28969. 12,
  28970. ccittEOL
  28971. ],
  28972. [
  28973. -1,
  28974. -1
  28975. ],
  28976. [
  28977. -1,
  28978. -1
  28979. ],
  28980. [
  28981. -1,
  28982. -1
  28983. ],
  28984. [
  28985. -1,
  28986. -1
  28987. ],
  28988. [
  28989. -1,
  28990. -1
  28991. ],
  28992. [
  28993. -1,
  28994. -1
  28995. ],
  28996. [
  28997. -1,
  28998. -1
  28999. ],
  29000. [
  29001. -1,
  29002. -1
  29003. ],
  29004. [
  29005. -1,
  29006. -1
  29007. ],
  29008. [
  29009. -1,
  29010. -1
  29011. ],
  29012. [
  29013. -1,
  29014. -1
  29015. ],
  29016. [
  29017. -1,
  29018. -1
  29019. ],
  29020. [
  29021. -1,
  29022. -1
  29023. ],
  29024. [
  29025. -1,
  29026. -1
  29027. ],
  29028. [
  29029. -1,
  29030. -1
  29031. ],
  29032. [
  29033. -1,
  29034. -1
  29035. ],
  29036. [
  29037. -1,
  29038. -1
  29039. ],
  29040. [
  29041. -1,
  29042. -1
  29043. ],
  29044. [
  29045. -1,
  29046. -1
  29047. ],
  29048. [
  29049. -1,
  29050. -1
  29051. ],
  29052. [
  29053. -1,
  29054. -1
  29055. ],
  29056. [
  29057. -1,
  29058. -1
  29059. ],
  29060. [
  29061. -1,
  29062. -1
  29063. ],
  29064. [
  29065. -1,
  29066. -1
  29067. ],
  29068. [
  29069. -1,
  29070. -1
  29071. ],
  29072. [
  29073. -1,
  29074. -1
  29075. ],
  29076. [
  29077. -1,
  29078. -1
  29079. ],
  29080. [
  29081. -1,
  29082. -1
  29083. ],
  29084. [
  29085. 11,
  29086. 1792
  29087. ],
  29088. [
  29089. 11,
  29090. 1792
  29091. ],
  29092. [
  29093. 11,
  29094. 1792
  29095. ],
  29096. [
  29097. 11,
  29098. 1792
  29099. ],
  29100. [
  29101. 12,
  29102. 1984
  29103. ],
  29104. [
  29105. 12,
  29106. 1984
  29107. ],
  29108. [
  29109. 12,
  29110. 2048
  29111. ],
  29112. [
  29113. 12,
  29114. 2048
  29115. ],
  29116. [
  29117. 12,
  29118. 2112
  29119. ],
  29120. [
  29121. 12,
  29122. 2112
  29123. ],
  29124. [
  29125. 12,
  29126. 2176
  29127. ],
  29128. [
  29129. 12,
  29130. 2176
  29131. ],
  29132. [
  29133. 12,
  29134. 2240
  29135. ],
  29136. [
  29137. 12,
  29138. 2240
  29139. ],
  29140. [
  29141. 12,
  29142. 2304
  29143. ],
  29144. [
  29145. 12,
  29146. 2304
  29147. ],
  29148. [
  29149. 11,
  29150. 1856
  29151. ],
  29152. [
  29153. 11,
  29154. 1856
  29155. ],
  29156. [
  29157. 11,
  29158. 1856
  29159. ],
  29160. [
  29161. 11,
  29162. 1856
  29163. ],
  29164. [
  29165. 11,
  29166. 1920
  29167. ],
  29168. [
  29169. 11,
  29170. 1920
  29171. ],
  29172. [
  29173. 11,
  29174. 1920
  29175. ],
  29176. [
  29177. 11,
  29178. 1920
  29179. ],
  29180. [
  29181. 12,
  29182. 2368
  29183. ],
  29184. [
  29185. 12,
  29186. 2368
  29187. ],
  29188. [
  29189. 12,
  29190. 2432
  29191. ],
  29192. [
  29193. 12,
  29194. 2432
  29195. ],
  29196. [
  29197. 12,
  29198. 2496
  29199. ],
  29200. [
  29201. 12,
  29202. 2496
  29203. ],
  29204. [
  29205. 12,
  29206. 2560
  29207. ],
  29208. [
  29209. 12,
  29210. 2560
  29211. ],
  29212. [
  29213. 10,
  29214. 18
  29215. ],
  29216. [
  29217. 10,
  29218. 18
  29219. ],
  29220. [
  29221. 10,
  29222. 18
  29223. ],
  29224. [
  29225. 10,
  29226. 18
  29227. ],
  29228. [
  29229. 10,
  29230. 18
  29231. ],
  29232. [
  29233. 10,
  29234. 18
  29235. ],
  29236. [
  29237. 10,
  29238. 18
  29239. ],
  29240. [
  29241. 10,
  29242. 18
  29243. ],
  29244. [
  29245. 12,
  29246. 52
  29247. ],
  29248. [
  29249. 12,
  29250. 52
  29251. ],
  29252. [
  29253. 13,
  29254. 640
  29255. ],
  29256. [
  29257. 13,
  29258. 704
  29259. ],
  29260. [
  29261. 13,
  29262. 768
  29263. ],
  29264. [
  29265. 13,
  29266. 832
  29267. ],
  29268. [
  29269. 12,
  29270. 55
  29271. ],
  29272. [
  29273. 12,
  29274. 55
  29275. ],
  29276. [
  29277. 12,
  29278. 56
  29279. ],
  29280. [
  29281. 12,
  29282. 56
  29283. ],
  29284. [
  29285. 13,
  29286. 1280
  29287. ],
  29288. [
  29289. 13,
  29290. 1344
  29291. ],
  29292. [
  29293. 13,
  29294. 1408
  29295. ],
  29296. [
  29297. 13,
  29298. 1472
  29299. ],
  29300. [
  29301. 12,
  29302. 59
  29303. ],
  29304. [
  29305. 12,
  29306. 59
  29307. ],
  29308. [
  29309. 12,
  29310. 60
  29311. ],
  29312. [
  29313. 12,
  29314. 60
  29315. ],
  29316. [
  29317. 13,
  29318. 1536
  29319. ],
  29320. [
  29321. 13,
  29322. 1600
  29323. ],
  29324. [
  29325. 11,
  29326. 24
  29327. ],
  29328. [
  29329. 11,
  29330. 24
  29331. ],
  29332. [
  29333. 11,
  29334. 24
  29335. ],
  29336. [
  29337. 11,
  29338. 24
  29339. ],
  29340. [
  29341. 11,
  29342. 25
  29343. ],
  29344. [
  29345. 11,
  29346. 25
  29347. ],
  29348. [
  29349. 11,
  29350. 25
  29351. ],
  29352. [
  29353. 11,
  29354. 25
  29355. ],
  29356. [
  29357. 13,
  29358. 1664
  29359. ],
  29360. [
  29361. 13,
  29362. 1728
  29363. ],
  29364. [
  29365. 12,
  29366. 320
  29367. ],
  29368. [
  29369. 12,
  29370. 320
  29371. ],
  29372. [
  29373. 12,
  29374. 384
  29375. ],
  29376. [
  29377. 12,
  29378. 384
  29379. ],
  29380. [
  29381. 12,
  29382. 448
  29383. ],
  29384. [
  29385. 12,
  29386. 448
  29387. ],
  29388. [
  29389. 13,
  29390. 512
  29391. ],
  29392. [
  29393. 13,
  29394. 576
  29395. ],
  29396. [
  29397. 12,
  29398. 53
  29399. ],
  29400. [
  29401. 12,
  29402. 53
  29403. ],
  29404. [
  29405. 12,
  29406. 54
  29407. ],
  29408. [
  29409. 12,
  29410. 54
  29411. ],
  29412. [
  29413. 13,
  29414. 896
  29415. ],
  29416. [
  29417. 13,
  29418. 960
  29419. ],
  29420. [
  29421. 13,
  29422. 1024
  29423. ],
  29424. [
  29425. 13,
  29426. 1088
  29427. ],
  29428. [
  29429. 13,
  29430. 1152
  29431. ],
  29432. [
  29433. 13,
  29434. 1216
  29435. ],
  29436. [
  29437. 10,
  29438. 64
  29439. ],
  29440. [
  29441. 10,
  29442. 64
  29443. ],
  29444. [
  29445. 10,
  29446. 64
  29447. ],
  29448. [
  29449. 10,
  29450. 64
  29451. ],
  29452. [
  29453. 10,
  29454. 64
  29455. ],
  29456. [
  29457. 10,
  29458. 64
  29459. ],
  29460. [
  29461. 10,
  29462. 64
  29463. ],
  29464. [
  29465. 10,
  29466. 64
  29467. ]
  29468. ];
  29469. var blackTable2 = [
  29470. [
  29471. 8,
  29472. 13
  29473. ],
  29474. [
  29475. 8,
  29476. 13
  29477. ],
  29478. [
  29479. 8,
  29480. 13
  29481. ],
  29482. [
  29483. 8,
  29484. 13
  29485. ],
  29486. [
  29487. 8,
  29488. 13
  29489. ],
  29490. [
  29491. 8,
  29492. 13
  29493. ],
  29494. [
  29495. 8,
  29496. 13
  29497. ],
  29498. [
  29499. 8,
  29500. 13
  29501. ],
  29502. [
  29503. 8,
  29504. 13
  29505. ],
  29506. [
  29507. 8,
  29508. 13
  29509. ],
  29510. [
  29511. 8,
  29512. 13
  29513. ],
  29514. [
  29515. 8,
  29516. 13
  29517. ],
  29518. [
  29519. 8,
  29520. 13
  29521. ],
  29522. [
  29523. 8,
  29524. 13
  29525. ],
  29526. [
  29527. 8,
  29528. 13
  29529. ],
  29530. [
  29531. 8,
  29532. 13
  29533. ],
  29534. [
  29535. 11,
  29536. 23
  29537. ],
  29538. [
  29539. 11,
  29540. 23
  29541. ],
  29542. [
  29543. 12,
  29544. 50
  29545. ],
  29546. [
  29547. 12,
  29548. 51
  29549. ],
  29550. [
  29551. 12,
  29552. 44
  29553. ],
  29554. [
  29555. 12,
  29556. 45
  29557. ],
  29558. [
  29559. 12,
  29560. 46
  29561. ],
  29562. [
  29563. 12,
  29564. 47
  29565. ],
  29566. [
  29567. 12,
  29568. 57
  29569. ],
  29570. [
  29571. 12,
  29572. 58
  29573. ],
  29574. [
  29575. 12,
  29576. 61
  29577. ],
  29578. [
  29579. 12,
  29580. 256
  29581. ],
  29582. [
  29583. 10,
  29584. 16
  29585. ],
  29586. [
  29587. 10,
  29588. 16
  29589. ],
  29590. [
  29591. 10,
  29592. 16
  29593. ],
  29594. [
  29595. 10,
  29596. 16
  29597. ],
  29598. [
  29599. 10,
  29600. 17
  29601. ],
  29602. [
  29603. 10,
  29604. 17
  29605. ],
  29606. [
  29607. 10,
  29608. 17
  29609. ],
  29610. [
  29611. 10,
  29612. 17
  29613. ],
  29614. [
  29615. 12,
  29616. 48
  29617. ],
  29618. [
  29619. 12,
  29620. 49
  29621. ],
  29622. [
  29623. 12,
  29624. 62
  29625. ],
  29626. [
  29627. 12,
  29628. 63
  29629. ],
  29630. [
  29631. 12,
  29632. 30
  29633. ],
  29634. [
  29635. 12,
  29636. 31
  29637. ],
  29638. [
  29639. 12,
  29640. 32
  29641. ],
  29642. [
  29643. 12,
  29644. 33
  29645. ],
  29646. [
  29647. 12,
  29648. 40
  29649. ],
  29650. [
  29651. 12,
  29652. 41
  29653. ],
  29654. [
  29655. 11,
  29656. 22
  29657. ],
  29658. [
  29659. 11,
  29660. 22
  29661. ],
  29662. [
  29663. 8,
  29664. 14
  29665. ],
  29666. [
  29667. 8,
  29668. 14
  29669. ],
  29670. [
  29671. 8,
  29672. 14
  29673. ],
  29674. [
  29675. 8,
  29676. 14
  29677. ],
  29678. [
  29679. 8,
  29680. 14
  29681. ],
  29682. [
  29683. 8,
  29684. 14
  29685. ],
  29686. [
  29687. 8,
  29688. 14
  29689. ],
  29690. [
  29691. 8,
  29692. 14
  29693. ],
  29694. [
  29695. 8,
  29696. 14
  29697. ],
  29698. [
  29699. 8,
  29700. 14
  29701. ],
  29702. [
  29703. 8,
  29704. 14
  29705. ],
  29706. [
  29707. 8,
  29708. 14
  29709. ],
  29710. [
  29711. 8,
  29712. 14
  29713. ],
  29714. [
  29715. 8,
  29716. 14
  29717. ],
  29718. [
  29719. 8,
  29720. 14
  29721. ],
  29722. [
  29723. 8,
  29724. 14
  29725. ],
  29726. [
  29727. 7,
  29728. 10
  29729. ],
  29730. [
  29731. 7,
  29732. 10
  29733. ],
  29734. [
  29735. 7,
  29736. 10
  29737. ],
  29738. [
  29739. 7,
  29740. 10
  29741. ],
  29742. [
  29743. 7,
  29744. 10
  29745. ],
  29746. [
  29747. 7,
  29748. 10
  29749. ],
  29750. [
  29751. 7,
  29752. 10
  29753. ],
  29754. [
  29755. 7,
  29756. 10
  29757. ],
  29758. [
  29759. 7,
  29760. 10
  29761. ],
  29762. [
  29763. 7,
  29764. 10
  29765. ],
  29766. [
  29767. 7,
  29768. 10
  29769. ],
  29770. [
  29771. 7,
  29772. 10
  29773. ],
  29774. [
  29775. 7,
  29776. 10
  29777. ],
  29778. [
  29779. 7,
  29780. 10
  29781. ],
  29782. [
  29783. 7,
  29784. 10
  29785. ],
  29786. [
  29787. 7,
  29788. 10
  29789. ],
  29790. [
  29791. 7,
  29792. 10
  29793. ],
  29794. [
  29795. 7,
  29796. 10
  29797. ],
  29798. [
  29799. 7,
  29800. 10
  29801. ],
  29802. [
  29803. 7,
  29804. 10
  29805. ],
  29806. [
  29807. 7,
  29808. 10
  29809. ],
  29810. [
  29811. 7,
  29812. 10
  29813. ],
  29814. [
  29815. 7,
  29816. 10
  29817. ],
  29818. [
  29819. 7,
  29820. 10
  29821. ],
  29822. [
  29823. 7,
  29824. 10
  29825. ],
  29826. [
  29827. 7,
  29828. 10
  29829. ],
  29830. [
  29831. 7,
  29832. 10
  29833. ],
  29834. [
  29835. 7,
  29836. 10
  29837. ],
  29838. [
  29839. 7,
  29840. 10
  29841. ],
  29842. [
  29843. 7,
  29844. 10
  29845. ],
  29846. [
  29847. 7,
  29848. 10
  29849. ],
  29850. [
  29851. 7,
  29852. 10
  29853. ],
  29854. [
  29855. 7,
  29856. 11
  29857. ],
  29858. [
  29859. 7,
  29860. 11
  29861. ],
  29862. [
  29863. 7,
  29864. 11
  29865. ],
  29866. [
  29867. 7,
  29868. 11
  29869. ],
  29870. [
  29871. 7,
  29872. 11
  29873. ],
  29874. [
  29875. 7,
  29876. 11
  29877. ],
  29878. [
  29879. 7,
  29880. 11
  29881. ],
  29882. [
  29883. 7,
  29884. 11
  29885. ],
  29886. [
  29887. 7,
  29888. 11
  29889. ],
  29890. [
  29891. 7,
  29892. 11
  29893. ],
  29894. [
  29895. 7,
  29896. 11
  29897. ],
  29898. [
  29899. 7,
  29900. 11
  29901. ],
  29902. [
  29903. 7,
  29904. 11
  29905. ],
  29906. [
  29907. 7,
  29908. 11
  29909. ],
  29910. [
  29911. 7,
  29912. 11
  29913. ],
  29914. [
  29915. 7,
  29916. 11
  29917. ],
  29918. [
  29919. 7,
  29920. 11
  29921. ],
  29922. [
  29923. 7,
  29924. 11
  29925. ],
  29926. [
  29927. 7,
  29928. 11
  29929. ],
  29930. [
  29931. 7,
  29932. 11
  29933. ],
  29934. [
  29935. 7,
  29936. 11
  29937. ],
  29938. [
  29939. 7,
  29940. 11
  29941. ],
  29942. [
  29943. 7,
  29944. 11
  29945. ],
  29946. [
  29947. 7,
  29948. 11
  29949. ],
  29950. [
  29951. 7,
  29952. 11
  29953. ],
  29954. [
  29955. 7,
  29956. 11
  29957. ],
  29958. [
  29959. 7,
  29960. 11
  29961. ],
  29962. [
  29963. 7,
  29964. 11
  29965. ],
  29966. [
  29967. 7,
  29968. 11
  29969. ],
  29970. [
  29971. 7,
  29972. 11
  29973. ],
  29974. [
  29975. 7,
  29976. 11
  29977. ],
  29978. [
  29979. 7,
  29980. 11
  29981. ],
  29982. [
  29983. 9,
  29984. 15
  29985. ],
  29986. [
  29987. 9,
  29988. 15
  29989. ],
  29990. [
  29991. 9,
  29992. 15
  29993. ],
  29994. [
  29995. 9,
  29996. 15
  29997. ],
  29998. [
  29999. 9,
  30000. 15
  30001. ],
  30002. [
  30003. 9,
  30004. 15
  30005. ],
  30006. [
  30007. 9,
  30008. 15
  30009. ],
  30010. [
  30011. 9,
  30012. 15
  30013. ],
  30014. [
  30015. 12,
  30016. 128
  30017. ],
  30018. [
  30019. 12,
  30020. 192
  30021. ],
  30022. [
  30023. 12,
  30024. 26
  30025. ],
  30026. [
  30027. 12,
  30028. 27
  30029. ],
  30030. [
  30031. 12,
  30032. 28
  30033. ],
  30034. [
  30035. 12,
  30036. 29
  30037. ],
  30038. [
  30039. 11,
  30040. 19
  30041. ],
  30042. [
  30043. 11,
  30044. 19
  30045. ],
  30046. [
  30047. 11,
  30048. 20
  30049. ],
  30050. [
  30051. 11,
  30052. 20
  30053. ],
  30054. [
  30055. 12,
  30056. 34
  30057. ],
  30058. [
  30059. 12,
  30060. 35
  30061. ],
  30062. [
  30063. 12,
  30064. 36
  30065. ],
  30066. [
  30067. 12,
  30068. 37
  30069. ],
  30070. [
  30071. 12,
  30072. 38
  30073. ],
  30074. [
  30075. 12,
  30076. 39
  30077. ],
  30078. [
  30079. 11,
  30080. 21
  30081. ],
  30082. [
  30083. 11,
  30084. 21
  30085. ],
  30086. [
  30087. 12,
  30088. 42
  30089. ],
  30090. [
  30091. 12,
  30092. 43
  30093. ],
  30094. [
  30095. 10,
  30096. 0
  30097. ],
  30098. [
  30099. 10,
  30100. 0
  30101. ],
  30102. [
  30103. 10,
  30104. 0
  30105. ],
  30106. [
  30107. 10,
  30108. 0
  30109. ],
  30110. [
  30111. 7,
  30112. 12
  30113. ],
  30114. [
  30115. 7,
  30116. 12
  30117. ],
  30118. [
  30119. 7,
  30120. 12
  30121. ],
  30122. [
  30123. 7,
  30124. 12
  30125. ],
  30126. [
  30127. 7,
  30128. 12
  30129. ],
  30130. [
  30131. 7,
  30132. 12
  30133. ],
  30134. [
  30135. 7,
  30136. 12
  30137. ],
  30138. [
  30139. 7,
  30140. 12
  30141. ],
  30142. [
  30143. 7,
  30144. 12
  30145. ],
  30146. [
  30147. 7,
  30148. 12
  30149. ],
  30150. [
  30151. 7,
  30152. 12
  30153. ],
  30154. [
  30155. 7,
  30156. 12
  30157. ],
  30158. [
  30159. 7,
  30160. 12
  30161. ],
  30162. [
  30163. 7,
  30164. 12
  30165. ],
  30166. [
  30167. 7,
  30168. 12
  30169. ],
  30170. [
  30171. 7,
  30172. 12
  30173. ],
  30174. [
  30175. 7,
  30176. 12
  30177. ],
  30178. [
  30179. 7,
  30180. 12
  30181. ],
  30182. [
  30183. 7,
  30184. 12
  30185. ],
  30186. [
  30187. 7,
  30188. 12
  30189. ],
  30190. [
  30191. 7,
  30192. 12
  30193. ],
  30194. [
  30195. 7,
  30196. 12
  30197. ],
  30198. [
  30199. 7,
  30200. 12
  30201. ],
  30202. [
  30203. 7,
  30204. 12
  30205. ],
  30206. [
  30207. 7,
  30208. 12
  30209. ],
  30210. [
  30211. 7,
  30212. 12
  30213. ],
  30214. [
  30215. 7,
  30216. 12
  30217. ],
  30218. [
  30219. 7,
  30220. 12
  30221. ],
  30222. [
  30223. 7,
  30224. 12
  30225. ],
  30226. [
  30227. 7,
  30228. 12
  30229. ],
  30230. [
  30231. 7,
  30232. 12
  30233. ],
  30234. [
  30235. 7,
  30236. 12
  30237. ]
  30238. ];
  30239. var blackTable3 = [
  30240. [
  30241. -1,
  30242. -1
  30243. ],
  30244. [
  30245. -1,
  30246. -1
  30247. ],
  30248. [
  30249. -1,
  30250. -1
  30251. ],
  30252. [
  30253. -1,
  30254. -1
  30255. ],
  30256. [
  30257. 6,
  30258. 9
  30259. ],
  30260. [
  30261. 6,
  30262. 8
  30263. ],
  30264. [
  30265. 5,
  30266. 7
  30267. ],
  30268. [
  30269. 5,
  30270. 7
  30271. ],
  30272. [
  30273. 4,
  30274. 6
  30275. ],
  30276. [
  30277. 4,
  30278. 6
  30279. ],
  30280. [
  30281. 4,
  30282. 6
  30283. ],
  30284. [
  30285. 4,
  30286. 6
  30287. ],
  30288. [
  30289. 4,
  30290. 5
  30291. ],
  30292. [
  30293. 4,
  30294. 5
  30295. ],
  30296. [
  30297. 4,
  30298. 5
  30299. ],
  30300. [
  30301. 4,
  30302. 5
  30303. ],
  30304. [
  30305. 3,
  30306. 1
  30307. ],
  30308. [
  30309. 3,
  30310. 1
  30311. ],
  30312. [
  30313. 3,
  30314. 1
  30315. ],
  30316. [
  30317. 3,
  30318. 1
  30319. ],
  30320. [
  30321. 3,
  30322. 1
  30323. ],
  30324. [
  30325. 3,
  30326. 1
  30327. ],
  30328. [
  30329. 3,
  30330. 1
  30331. ],
  30332. [
  30333. 3,
  30334. 1
  30335. ],
  30336. [
  30337. 3,
  30338. 4
  30339. ],
  30340. [
  30341. 3,
  30342. 4
  30343. ],
  30344. [
  30345. 3,
  30346. 4
  30347. ],
  30348. [
  30349. 3,
  30350. 4
  30351. ],
  30352. [
  30353. 3,
  30354. 4
  30355. ],
  30356. [
  30357. 3,
  30358. 4
  30359. ],
  30360. [
  30361. 3,
  30362. 4
  30363. ],
  30364. [
  30365. 3,
  30366. 4
  30367. ],
  30368. [
  30369. 2,
  30370. 3
  30371. ],
  30372. [
  30373. 2,
  30374. 3
  30375. ],
  30376. [
  30377. 2,
  30378. 3
  30379. ],
  30380. [
  30381. 2,
  30382. 3
  30383. ],
  30384. [
  30385. 2,
  30386. 3
  30387. ],
  30388. [
  30389. 2,
  30390. 3
  30391. ],
  30392. [
  30393. 2,
  30394. 3
  30395. ],
  30396. [
  30397. 2,
  30398. 3
  30399. ],
  30400. [
  30401. 2,
  30402. 3
  30403. ],
  30404. [
  30405. 2,
  30406. 3
  30407. ],
  30408. [
  30409. 2,
  30410. 3
  30411. ],
  30412. [
  30413. 2,
  30414. 3
  30415. ],
  30416. [
  30417. 2,
  30418. 3
  30419. ],
  30420. [
  30421. 2,
  30422. 3
  30423. ],
  30424. [
  30425. 2,
  30426. 3
  30427. ],
  30428. [
  30429. 2,
  30430. 3
  30431. ],
  30432. [
  30433. 2,
  30434. 2
  30435. ],
  30436. [
  30437. 2,
  30438. 2
  30439. ],
  30440. [
  30441. 2,
  30442. 2
  30443. ],
  30444. [
  30445. 2,
  30446. 2
  30447. ],
  30448. [
  30449. 2,
  30450. 2
  30451. ],
  30452. [
  30453. 2,
  30454. 2
  30455. ],
  30456. [
  30457. 2,
  30458. 2
  30459. ],
  30460. [
  30461. 2,
  30462. 2
  30463. ],
  30464. [
  30465. 2,
  30466. 2
  30467. ],
  30468. [
  30469. 2,
  30470. 2
  30471. ],
  30472. [
  30473. 2,
  30474. 2
  30475. ],
  30476. [
  30477. 2,
  30478. 2
  30479. ],
  30480. [
  30481. 2,
  30482. 2
  30483. ],
  30484. [
  30485. 2,
  30486. 2
  30487. ],
  30488. [
  30489. 2,
  30490. 2
  30491. ],
  30492. [
  30493. 2,
  30494. 2
  30495. ]
  30496. ];
  30497. function CCITTFaxStream(str, maybeLength, params) {
  30498. this.str = str;
  30499. this.dict = str.dict;
  30500. params = params || Dict.empty;
  30501. this.encoding = params.get('K') || 0;
  30502. this.eoline = params.get('EndOfLine') || false;
  30503. this.byteAlign = params.get('EncodedByteAlign') || false;
  30504. this.columns = params.get('Columns') || 1728;
  30505. this.rows = params.get('Rows') || 0;
  30506. var eoblock = params.get('EndOfBlock');
  30507. if (eoblock === null || eoblock === undefined) {
  30508. eoblock = true;
  30509. }
  30510. this.eoblock = eoblock;
  30511. this.black = params.get('BlackIs1') || false;
  30512. this.codingLine = new Uint32Array(this.columns + 1);
  30513. this.refLine = new Uint32Array(this.columns + 2);
  30514. this.codingLine[0] = this.columns;
  30515. this.codingPos = 0;
  30516. this.row = 0;
  30517. this.nextLine2D = this.encoding < 0;
  30518. this.inputBits = 0;
  30519. this.inputBuf = 0;
  30520. this.outputBits = 0;
  30521. var code1;
  30522. while ((code1 = this.lookBits(12)) === 0) {
  30523. this.eatBits(1);
  30524. }
  30525. if (code1 === 1) {
  30526. this.eatBits(12);
  30527. }
  30528. if (this.encoding > 0) {
  30529. this.nextLine2D = !this.lookBits(1);
  30530. this.eatBits(1);
  30531. }
  30532. DecodeStream.call(this, maybeLength);
  30533. }
  30534. CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
  30535. CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
  30536. while (!this.eof) {
  30537. var c = this.lookChar();
  30538. this.ensureBuffer(this.bufferLength + 1);
  30539. this.buffer[this.bufferLength++] = c;
  30540. }
  30541. };
  30542. CCITTFaxStream.prototype.addPixels = function ccittFaxStreamAddPixels(a1, blackPixels) {
  30543. var codingLine = this.codingLine;
  30544. var codingPos = this.codingPos;
  30545. if (a1 > codingLine[codingPos]) {
  30546. if (a1 > this.columns) {
  30547. info('row is wrong length');
  30548. this.err = true;
  30549. a1 = this.columns;
  30550. }
  30551. if (codingPos & 1 ^ blackPixels) {
  30552. ++codingPos;
  30553. }
  30554. codingLine[codingPos] = a1;
  30555. }
  30556. this.codingPos = codingPos;
  30557. };
  30558. CCITTFaxStream.prototype.addPixelsNeg = function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
  30559. var codingLine = this.codingLine;
  30560. var codingPos = this.codingPos;
  30561. if (a1 > codingLine[codingPos]) {
  30562. if (a1 > this.columns) {
  30563. info('row is wrong length');
  30564. this.err = true;
  30565. a1 = this.columns;
  30566. }
  30567. if (codingPos & 1 ^ blackPixels) {
  30568. ++codingPos;
  30569. }
  30570. codingLine[codingPos] = a1;
  30571. } else if (a1 < codingLine[codingPos]) {
  30572. if (a1 < 0) {
  30573. info('invalid code');
  30574. this.err = true;
  30575. a1 = 0;
  30576. }
  30577. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  30578. --codingPos;
  30579. }
  30580. codingLine[codingPos] = a1;
  30581. }
  30582. this.codingPos = codingPos;
  30583. };
  30584. CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
  30585. var refLine = this.refLine;
  30586. var codingLine = this.codingLine;
  30587. var columns = this.columns;
  30588. var refPos, blackPixels, bits, i;
  30589. if (this.outputBits === 0) {
  30590. if (this.eof) {
  30591. return null;
  30592. }
  30593. this.err = false;
  30594. var code1, code2, code3;
  30595. if (this.nextLine2D) {
  30596. for (i = 0; codingLine[i] < columns; ++i) {
  30597. refLine[i] = codingLine[i];
  30598. }
  30599. refLine[i++] = columns;
  30600. refLine[i] = columns;
  30601. codingLine[0] = 0;
  30602. this.codingPos = 0;
  30603. refPos = 0;
  30604. blackPixels = 0;
  30605. while (codingLine[this.codingPos] < columns) {
  30606. code1 = this.getTwoDimCode();
  30607. switch (code1) {
  30608. case twoDimPass:
  30609. this.addPixels(refLine[refPos + 1], blackPixels);
  30610. if (refLine[refPos + 1] < columns) {
  30611. refPos += 2;
  30612. }
  30613. break;
  30614. case twoDimHoriz:
  30615. code1 = code2 = 0;
  30616. if (blackPixels) {
  30617. do {
  30618. code1 += code3 = this.getBlackCode();
  30619. } while (code3 >= 64);
  30620. do {
  30621. code2 += code3 = this.getWhiteCode();
  30622. } while (code3 >= 64);
  30623. } else {
  30624. do {
  30625. code1 += code3 = this.getWhiteCode();
  30626. } while (code3 >= 64);
  30627. do {
  30628. code2 += code3 = this.getBlackCode();
  30629. } while (code3 >= 64);
  30630. }
  30631. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  30632. if (codingLine[this.codingPos] < columns) {
  30633. this.addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  30634. }
  30635. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30636. refPos += 2;
  30637. }
  30638. break;
  30639. case twoDimVertR3:
  30640. this.addPixels(refLine[refPos] + 3, blackPixels);
  30641. blackPixels ^= 1;
  30642. if (codingLine[this.codingPos] < columns) {
  30643. ++refPos;
  30644. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30645. refPos += 2;
  30646. }
  30647. }
  30648. break;
  30649. case twoDimVertR2:
  30650. this.addPixels(refLine[refPos] + 2, blackPixels);
  30651. blackPixels ^= 1;
  30652. if (codingLine[this.codingPos] < columns) {
  30653. ++refPos;
  30654. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30655. refPos += 2;
  30656. }
  30657. }
  30658. break;
  30659. case twoDimVertR1:
  30660. this.addPixels(refLine[refPos] + 1, blackPixels);
  30661. blackPixels ^= 1;
  30662. if (codingLine[this.codingPos] < columns) {
  30663. ++refPos;
  30664. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30665. refPos += 2;
  30666. }
  30667. }
  30668. break;
  30669. case twoDimVert0:
  30670. this.addPixels(refLine[refPos], blackPixels);
  30671. blackPixels ^= 1;
  30672. if (codingLine[this.codingPos] < columns) {
  30673. ++refPos;
  30674. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30675. refPos += 2;
  30676. }
  30677. }
  30678. break;
  30679. case twoDimVertL3:
  30680. this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
  30681. blackPixels ^= 1;
  30682. if (codingLine[this.codingPos] < columns) {
  30683. if (refPos > 0) {
  30684. --refPos;
  30685. } else {
  30686. ++refPos;
  30687. }
  30688. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30689. refPos += 2;
  30690. }
  30691. }
  30692. break;
  30693. case twoDimVertL2:
  30694. this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
  30695. blackPixels ^= 1;
  30696. if (codingLine[this.codingPos] < columns) {
  30697. if (refPos > 0) {
  30698. --refPos;
  30699. } else {
  30700. ++refPos;
  30701. }
  30702. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30703. refPos += 2;
  30704. }
  30705. }
  30706. break;
  30707. case twoDimVertL1:
  30708. this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
  30709. blackPixels ^= 1;
  30710. if (codingLine[this.codingPos] < columns) {
  30711. if (refPos > 0) {
  30712. --refPos;
  30713. } else {
  30714. ++refPos;
  30715. }
  30716. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30717. refPos += 2;
  30718. }
  30719. }
  30720. break;
  30721. case ccittEOF:
  30722. this.addPixels(columns, 0);
  30723. this.eof = true;
  30724. break;
  30725. default:
  30726. info('bad 2d code');
  30727. this.addPixels(columns, 0);
  30728. this.err = true;
  30729. }
  30730. }
  30731. } else {
  30732. codingLine[0] = 0;
  30733. this.codingPos = 0;
  30734. blackPixels = 0;
  30735. while (codingLine[this.codingPos] < columns) {
  30736. code1 = 0;
  30737. if (blackPixels) {
  30738. do {
  30739. code1 += code3 = this.getBlackCode();
  30740. } while (code3 >= 64);
  30741. } else {
  30742. do {
  30743. code1 += code3 = this.getWhiteCode();
  30744. } while (code3 >= 64);
  30745. }
  30746. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  30747. blackPixels ^= 1;
  30748. }
  30749. }
  30750. var gotEOL = false;
  30751. if (this.byteAlign) {
  30752. this.inputBits &= ~7;
  30753. }
  30754. if (!this.eoblock && this.row === this.rows - 1) {
  30755. this.eof = true;
  30756. } else {
  30757. code1 = this.lookBits(12);
  30758. if (this.eoline) {
  30759. while (code1 !== ccittEOF && code1 !== 1) {
  30760. this.eatBits(1);
  30761. code1 = this.lookBits(12);
  30762. }
  30763. } else {
  30764. while (code1 === 0) {
  30765. this.eatBits(1);
  30766. code1 = this.lookBits(12);
  30767. }
  30768. }
  30769. if (code1 === 1) {
  30770. this.eatBits(12);
  30771. gotEOL = true;
  30772. } else if (code1 === ccittEOF) {
  30773. this.eof = true;
  30774. }
  30775. }
  30776. if (!this.eof && this.encoding > 0) {
  30777. this.nextLine2D = !this.lookBits(1);
  30778. this.eatBits(1);
  30779. }
  30780. if (this.eoblock && gotEOL && this.byteAlign) {
  30781. code1 = this.lookBits(12);
  30782. if (code1 === 1) {
  30783. this.eatBits(12);
  30784. if (this.encoding > 0) {
  30785. this.lookBits(1);
  30786. this.eatBits(1);
  30787. }
  30788. if (this.encoding >= 0) {
  30789. for (i = 0; i < 4; ++i) {
  30790. code1 = this.lookBits(12);
  30791. if (code1 !== 1) {
  30792. info('bad rtc code: ' + code1);
  30793. }
  30794. this.eatBits(12);
  30795. if (this.encoding > 0) {
  30796. this.lookBits(1);
  30797. this.eatBits(1);
  30798. }
  30799. }
  30800. }
  30801. this.eof = true;
  30802. }
  30803. } else if (this.err && this.eoline) {
  30804. while (true) {
  30805. code1 = this.lookBits(13);
  30806. if (code1 === ccittEOF) {
  30807. this.eof = true;
  30808. return null;
  30809. }
  30810. if (code1 >> 1 === 1) {
  30811. break;
  30812. }
  30813. this.eatBits(1);
  30814. }
  30815. this.eatBits(12);
  30816. if (this.encoding > 0) {
  30817. this.eatBits(1);
  30818. this.nextLine2D = !(code1 & 1);
  30819. }
  30820. }
  30821. if (codingLine[0] > 0) {
  30822. this.outputBits = codingLine[this.codingPos = 0];
  30823. } else {
  30824. this.outputBits = codingLine[this.codingPos = 1];
  30825. }
  30826. this.row++;
  30827. }
  30828. var c;
  30829. if (this.outputBits >= 8) {
  30830. c = this.codingPos & 1 ? 0 : 0xFF;
  30831. this.outputBits -= 8;
  30832. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  30833. this.codingPos++;
  30834. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  30835. }
  30836. } else {
  30837. bits = 8;
  30838. c = 0;
  30839. do {
  30840. if (this.outputBits > bits) {
  30841. c <<= bits;
  30842. if (!(this.codingPos & 1)) {
  30843. c |= 0xFF >> 8 - bits;
  30844. }
  30845. this.outputBits -= bits;
  30846. bits = 0;
  30847. } else {
  30848. c <<= this.outputBits;
  30849. if (!(this.codingPos & 1)) {
  30850. c |= 0xFF >> 8 - this.outputBits;
  30851. }
  30852. bits -= this.outputBits;
  30853. this.outputBits = 0;
  30854. if (codingLine[this.codingPos] < columns) {
  30855. this.codingPos++;
  30856. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  30857. } else if (bits > 0) {
  30858. c <<= bits;
  30859. bits = 0;
  30860. }
  30861. }
  30862. } while (bits);
  30863. }
  30864. if (this.black) {
  30865. c ^= 0xFF;
  30866. }
  30867. return c;
  30868. };
  30869. CCITTFaxStream.prototype.findTableCode = function ccittFaxStreamFindTableCode(start, end, table, limit) {
  30870. var limitValue = limit || 0;
  30871. for (var i = start; i <= end; ++i) {
  30872. var code = this.lookBits(i);
  30873. if (code === ccittEOF) {
  30874. return [
  30875. true,
  30876. 1,
  30877. false
  30878. ];
  30879. }
  30880. if (i < end) {
  30881. code <<= end - i;
  30882. }
  30883. if (!limitValue || code >= limitValue) {
  30884. var p = table[code - limitValue];
  30885. if (p[0] === i) {
  30886. this.eatBits(i);
  30887. return [
  30888. true,
  30889. p[1],
  30890. true
  30891. ];
  30892. }
  30893. }
  30894. }
  30895. return [
  30896. false,
  30897. 0,
  30898. false
  30899. ];
  30900. };
  30901. CCITTFaxStream.prototype.getTwoDimCode = function ccittFaxStreamGetTwoDimCode() {
  30902. var code = 0;
  30903. var p;
  30904. if (this.eoblock) {
  30905. code = this.lookBits(7);
  30906. p = twoDimTable[code];
  30907. if (p && p[0] > 0) {
  30908. this.eatBits(p[0]);
  30909. return p[1];
  30910. }
  30911. } else {
  30912. var result = this.findTableCode(1, 7, twoDimTable);
  30913. if (result[0] && result[2]) {
  30914. return result[1];
  30915. }
  30916. }
  30917. info('Bad two dim code');
  30918. return ccittEOF;
  30919. };
  30920. CCITTFaxStream.prototype.getWhiteCode = function ccittFaxStreamGetWhiteCode() {
  30921. var code = 0;
  30922. var p;
  30923. if (this.eoblock) {
  30924. code = this.lookBits(12);
  30925. if (code === ccittEOF) {
  30926. return 1;
  30927. }
  30928. if (code >> 5 === 0) {
  30929. p = whiteTable1[code];
  30930. } else {
  30931. p = whiteTable2[code >> 3];
  30932. }
  30933. if (p[0] > 0) {
  30934. this.eatBits(p[0]);
  30935. return p[1];
  30936. }
  30937. } else {
  30938. var result = this.findTableCode(1, 9, whiteTable2);
  30939. if (result[0]) {
  30940. return result[1];
  30941. }
  30942. result = this.findTableCode(11, 12, whiteTable1);
  30943. if (result[0]) {
  30944. return result[1];
  30945. }
  30946. }
  30947. info('bad white code');
  30948. this.eatBits(1);
  30949. return 1;
  30950. };
  30951. CCITTFaxStream.prototype.getBlackCode = function ccittFaxStreamGetBlackCode() {
  30952. var code, p;
  30953. if (this.eoblock) {
  30954. code = this.lookBits(13);
  30955. if (code === ccittEOF) {
  30956. return 1;
  30957. }
  30958. if (code >> 7 === 0) {
  30959. p = blackTable1[code];
  30960. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  30961. p = blackTable2[(code >> 1) - 64];
  30962. } else {
  30963. p = blackTable3[code >> 7];
  30964. }
  30965. if (p[0] > 0) {
  30966. this.eatBits(p[0]);
  30967. return p[1];
  30968. }
  30969. } else {
  30970. var result = this.findTableCode(2, 6, blackTable3);
  30971. if (result[0]) {
  30972. return result[1];
  30973. }
  30974. result = this.findTableCode(7, 12, blackTable2, 64);
  30975. if (result[0]) {
  30976. return result[1];
  30977. }
  30978. result = this.findTableCode(10, 13, blackTable1);
  30979. if (result[0]) {
  30980. return result[1];
  30981. }
  30982. }
  30983. info('bad black code');
  30984. this.eatBits(1);
  30985. return 1;
  30986. };
  30987. CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
  30988. var c;
  30989. while (this.inputBits < n) {
  30990. if ((c = this.str.getByte()) === -1) {
  30991. if (this.inputBits === 0) {
  30992. return ccittEOF;
  30993. }
  30994. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  30995. }
  30996. this.inputBuf = this.inputBuf << 8 | c;
  30997. this.inputBits += 8;
  30998. }
  30999. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  31000. };
  31001. CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
  31002. if ((this.inputBits -= n) < 0) {
  31003. this.inputBits = 0;
  31004. }
  31005. };
  31006. return CCITTFaxStream;
  31007. }();
  31008. var LZWStream = function LZWStreamClosure() {
  31009. function LZWStream(str, maybeLength, earlyChange) {
  31010. this.str = str;
  31011. this.dict = str.dict;
  31012. this.cachedData = 0;
  31013. this.bitsCached = 0;
  31014. var maxLzwDictionarySize = 4096;
  31015. var lzwState = {
  31016. earlyChange: earlyChange,
  31017. codeLength: 9,
  31018. nextCode: 258,
  31019. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  31020. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  31021. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  31022. currentSequence: new Uint8Array(maxLzwDictionarySize),
  31023. currentSequenceLength: 0
  31024. };
  31025. for (var i = 0; i < 256; ++i) {
  31026. lzwState.dictionaryValues[i] = i;
  31027. lzwState.dictionaryLengths[i] = 1;
  31028. }
  31029. this.lzwState = lzwState;
  31030. DecodeStream.call(this, maybeLength);
  31031. }
  31032. LZWStream.prototype = Object.create(DecodeStream.prototype);
  31033. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  31034. var bitsCached = this.bitsCached;
  31035. var cachedData = this.cachedData;
  31036. while (bitsCached < n) {
  31037. var c = this.str.getByte();
  31038. if (c === -1) {
  31039. this.eof = true;
  31040. return null;
  31041. }
  31042. cachedData = cachedData << 8 | c;
  31043. bitsCached += 8;
  31044. }
  31045. this.bitsCached = bitsCached -= n;
  31046. this.cachedData = cachedData;
  31047. this.lastCode = null;
  31048. return cachedData >>> bitsCached & (1 << n) - 1;
  31049. };
  31050. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  31051. var blockSize = 512;
  31052. var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
  31053. var i, j, q;
  31054. var lzwState = this.lzwState;
  31055. if (!lzwState) {
  31056. return;
  31057. }
  31058. var earlyChange = lzwState.earlyChange;
  31059. var nextCode = lzwState.nextCode;
  31060. var dictionaryValues = lzwState.dictionaryValues;
  31061. var dictionaryLengths = lzwState.dictionaryLengths;
  31062. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  31063. var codeLength = lzwState.codeLength;
  31064. var prevCode = lzwState.prevCode;
  31065. var currentSequence = lzwState.currentSequence;
  31066. var currentSequenceLength = lzwState.currentSequenceLength;
  31067. var decodedLength = 0;
  31068. var currentBufferLength = this.bufferLength;
  31069. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  31070. for (i = 0; i < blockSize; i++) {
  31071. var code = this.readBits(codeLength);
  31072. var hasPrev = currentSequenceLength > 0;
  31073. if (code < 256) {
  31074. currentSequence[0] = code;
  31075. currentSequenceLength = 1;
  31076. } else if (code >= 258) {
  31077. if (code < nextCode) {
  31078. currentSequenceLength = dictionaryLengths[code];
  31079. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  31080. currentSequence[j] = dictionaryValues[q];
  31081. q = dictionaryPrevCodes[q];
  31082. }
  31083. } else {
  31084. currentSequence[currentSequenceLength++] = currentSequence[0];
  31085. }
  31086. } else if (code === 256) {
  31087. codeLength = 9;
  31088. nextCode = 258;
  31089. currentSequenceLength = 0;
  31090. continue;
  31091. } else {
  31092. this.eof = true;
  31093. delete this.lzwState;
  31094. break;
  31095. }
  31096. if (hasPrev) {
  31097. dictionaryPrevCodes[nextCode] = prevCode;
  31098. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  31099. dictionaryValues[nextCode] = currentSequence[0];
  31100. nextCode++;
  31101. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  31102. }
  31103. prevCode = code;
  31104. decodedLength += currentSequenceLength;
  31105. if (estimatedDecodedSize < decodedLength) {
  31106. do {
  31107. estimatedDecodedSize += decodedSizeDelta;
  31108. } while (estimatedDecodedSize < decodedLength);
  31109. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  31110. }
  31111. for (j = 0; j < currentSequenceLength; j++) {
  31112. buffer[currentBufferLength++] = currentSequence[j];
  31113. }
  31114. }
  31115. lzwState.nextCode = nextCode;
  31116. lzwState.codeLength = codeLength;
  31117. lzwState.prevCode = prevCode;
  31118. lzwState.currentSequenceLength = currentSequenceLength;
  31119. this.bufferLength = currentBufferLength;
  31120. };
  31121. return LZWStream;
  31122. }();
  31123. var NullStream = function NullStreamClosure() {
  31124. function NullStream() {
  31125. Stream.call(this, new Uint8Array(0));
  31126. }
  31127. NullStream.prototype = Stream.prototype;
  31128. return NullStream;
  31129. }();
  31130. exports.Ascii85Stream = Ascii85Stream;
  31131. exports.AsciiHexStream = AsciiHexStream;
  31132. exports.CCITTFaxStream = CCITTFaxStream;
  31133. exports.DecryptStream = DecryptStream;
  31134. exports.DecodeStream = DecodeStream;
  31135. exports.FlateStream = FlateStream;
  31136. exports.Jbig2Stream = Jbig2Stream;
  31137. exports.JpegStream = JpegStream;
  31138. exports.JpxStream = JpxStream;
  31139. exports.NullStream = NullStream;
  31140. exports.PredictorStream = PredictorStream;
  31141. exports.RunLengthStream = RunLengthStream;
  31142. exports.Stream = Stream;
  31143. exports.StreamsSequenceStream = StreamsSequenceStream;
  31144. exports.StringStream = StringStream;
  31145. exports.LZWStream = LZWStream;
  31146. }));
  31147. (function (root, factory) {
  31148. factory(root.pdfjsDisplayAnnotationLayer = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  31149. }(this, function (exports, sharedUtil, displayDOMUtils) {
  31150. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  31151. var AnnotationType = sharedUtil.AnnotationType;
  31152. var Util = sharedUtil.Util;
  31153. var addLinkAttributes = displayDOMUtils.addLinkAttributes;
  31154. var LinkTarget = displayDOMUtils.LinkTarget;
  31155. var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  31156. var warn = sharedUtil.warn;
  31157. var CustomStyle = displayDOMUtils.CustomStyle;
  31158. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  31159. function AnnotationElementFactory() {
  31160. }
  31161. AnnotationElementFactory.prototype = {
  31162. create: function AnnotationElementFactory_create(parameters) {
  31163. var subtype = parameters.data.annotationType;
  31164. switch (subtype) {
  31165. case AnnotationType.LINK:
  31166. return new LinkAnnotationElement(parameters);
  31167. case AnnotationType.TEXT:
  31168. return new TextAnnotationElement(parameters);
  31169. case AnnotationType.WIDGET:
  31170. var fieldType = parameters.data.fieldType;
  31171. switch (fieldType) {
  31172. case 'Tx':
  31173. return new TextWidgetAnnotationElement(parameters);
  31174. case 'Ch':
  31175. return new ChoiceWidgetAnnotationElement(parameters);
  31176. }
  31177. return new WidgetAnnotationElement(parameters);
  31178. case AnnotationType.POPUP:
  31179. return new PopupAnnotationElement(parameters);
  31180. case AnnotationType.HIGHLIGHT:
  31181. return new HighlightAnnotationElement(parameters);
  31182. case AnnotationType.UNDERLINE:
  31183. return new UnderlineAnnotationElement(parameters);
  31184. case AnnotationType.SQUIGGLY:
  31185. return new SquigglyAnnotationElement(parameters);
  31186. case AnnotationType.STRIKEOUT:
  31187. return new StrikeOutAnnotationElement(parameters);
  31188. case AnnotationType.FILEATTACHMENT:
  31189. return new FileAttachmentAnnotationElement(parameters);
  31190. default:
  31191. return new AnnotationElement(parameters);
  31192. }
  31193. }
  31194. };
  31195. var AnnotationElement = function AnnotationElementClosure() {
  31196. function AnnotationElement(parameters, isRenderable) {
  31197. this.isRenderable = isRenderable || false;
  31198. this.data = parameters.data;
  31199. this.layer = parameters.layer;
  31200. this.page = parameters.page;
  31201. this.viewport = parameters.viewport;
  31202. this.linkService = parameters.linkService;
  31203. this.downloadManager = parameters.downloadManager;
  31204. this.imageResourcesPath = parameters.imageResourcesPath;
  31205. this.renderInteractiveForms = parameters.renderInteractiveForms;
  31206. if (isRenderable) {
  31207. this.container = this._createContainer();
  31208. }
  31209. }
  31210. AnnotationElement.prototype = {
  31211. _createContainer: function AnnotationElement_createContainer() {
  31212. var data = this.data, page = this.page, viewport = this.viewport;
  31213. var container = document.createElement('section');
  31214. var width = data.rect[2] - data.rect[0];
  31215. var height = data.rect[3] - data.rect[1];
  31216. container.setAttribute('data-annotation-id', data.id);
  31217. var rect = Util.normalizeRect([
  31218. data.rect[0],
  31219. page.view[3] - data.rect[1] + page.view[1],
  31220. data.rect[2],
  31221. page.view[3] - data.rect[3] + page.view[1]
  31222. ]);
  31223. CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  31224. CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  31225. if (data.borderStyle.width > 0) {
  31226. container.style.borderWidth = data.borderStyle.width + 'px';
  31227. if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
  31228. width = width - 2 * data.borderStyle.width;
  31229. height = height - 2 * data.borderStyle.width;
  31230. }
  31231. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  31232. var verticalRadius = data.borderStyle.verticalCornerRadius;
  31233. if (horizontalRadius > 0 || verticalRadius > 0) {
  31234. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  31235. CustomStyle.setProp('borderRadius', container, radius);
  31236. }
  31237. switch (data.borderStyle.style) {
  31238. case AnnotationBorderStyleType.SOLID:
  31239. container.style.borderStyle = 'solid';
  31240. break;
  31241. case AnnotationBorderStyleType.DASHED:
  31242. container.style.borderStyle = 'dashed';
  31243. break;
  31244. case AnnotationBorderStyleType.BEVELED:
  31245. warn('Unimplemented border style: beveled');
  31246. break;
  31247. case AnnotationBorderStyleType.INSET:
  31248. warn('Unimplemented border style: inset');
  31249. break;
  31250. case AnnotationBorderStyleType.UNDERLINE:
  31251. container.style.borderBottomStyle = 'solid';
  31252. break;
  31253. default:
  31254. break;
  31255. }
  31256. if (data.color) {
  31257. container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  31258. } else {
  31259. container.style.borderWidth = 0;
  31260. }
  31261. }
  31262. container.style.left = rect[0] + 'px';
  31263. container.style.top = rect[1] + 'px';
  31264. container.style.width = width + 'px';
  31265. container.style.height = height + 'px';
  31266. return container;
  31267. },
  31268. _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
  31269. if (!trigger) {
  31270. trigger = document.createElement('div');
  31271. trigger.style.height = container.style.height;
  31272. trigger.style.width = container.style.width;
  31273. container.appendChild(trigger);
  31274. }
  31275. var popupElement = new PopupElement({
  31276. container: container,
  31277. trigger: trigger,
  31278. color: data.color,
  31279. title: data.title,
  31280. contents: data.contents,
  31281. hideWrapper: true
  31282. });
  31283. var popup = popupElement.render();
  31284. popup.style.left = container.style.width;
  31285. container.appendChild(popup);
  31286. },
  31287. render: function AnnotationElement_render() {
  31288. throw new Error('Abstract method AnnotationElement.render called');
  31289. }
  31290. };
  31291. return AnnotationElement;
  31292. }();
  31293. var LinkAnnotationElement = function LinkAnnotationElementClosure() {
  31294. function LinkAnnotationElement(parameters) {
  31295. AnnotationElement.call(this, parameters, true);
  31296. }
  31297. Util.inherit(LinkAnnotationElement, AnnotationElement, {
  31298. render: function LinkAnnotationElement_render() {
  31299. this.container.className = 'linkAnnotation';
  31300. var link = document.createElement('a');
  31301. addLinkAttributes(link, {
  31302. url: this.data.url,
  31303. target: this.data.newWindow ? LinkTarget.BLANK : undefined
  31304. });
  31305. if (!this.data.url) {
  31306. if (this.data.action) {
  31307. this._bindNamedAction(link, this.data.action);
  31308. } else {
  31309. this._bindLink(link, this.data.dest);
  31310. }
  31311. }
  31312. this.container.appendChild(link);
  31313. return this.container;
  31314. },
  31315. _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
  31316. var self = this;
  31317. link.href = this.linkService.getDestinationHash(destination);
  31318. link.onclick = function () {
  31319. if (destination) {
  31320. self.linkService.navigateTo(destination);
  31321. }
  31322. return false;
  31323. };
  31324. if (destination) {
  31325. link.className = 'internalLink';
  31326. }
  31327. },
  31328. _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) {
  31329. var self = this;
  31330. link.href = this.linkService.getAnchorUrl('');
  31331. link.onclick = function () {
  31332. self.linkService.executeNamedAction(action);
  31333. return false;
  31334. };
  31335. link.className = 'internalLink';
  31336. }
  31337. });
  31338. return LinkAnnotationElement;
  31339. }();
  31340. var TextAnnotationElement = function TextAnnotationElementClosure() {
  31341. function TextAnnotationElement(parameters) {
  31342. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31343. AnnotationElement.call(this, parameters, isRenderable);
  31344. }
  31345. Util.inherit(TextAnnotationElement, AnnotationElement, {
  31346. render: function TextAnnotationElement_render() {
  31347. this.container.className = 'textAnnotation';
  31348. var image = document.createElement('img');
  31349. image.style.height = this.container.style.height;
  31350. image.style.width = this.container.style.width;
  31351. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  31352. image.alt = '[{{type}} Annotation]';
  31353. image.dataset.l10nId = 'text_annotation_type';
  31354. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  31355. if (!this.data.hasPopup) {
  31356. this._createPopup(this.container, image, this.data);
  31357. }
  31358. this.container.appendChild(image);
  31359. return this.container;
  31360. }
  31361. });
  31362. return TextAnnotationElement;
  31363. }();
  31364. var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
  31365. function WidgetAnnotationElement(parameters, isRenderable) {
  31366. AnnotationElement.call(this, parameters, isRenderable);
  31367. }
  31368. Util.inherit(WidgetAnnotationElement, AnnotationElement, {
  31369. render: function WidgetAnnotationElement_render() {
  31370. return this.container;
  31371. }
  31372. });
  31373. return WidgetAnnotationElement;
  31374. }();
  31375. var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
  31376. var TEXT_ALIGNMENT = [
  31377. 'left',
  31378. 'center',
  31379. 'right'
  31380. ];
  31381. function TextWidgetAnnotationElement(parameters) {
  31382. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  31383. WidgetAnnotationElement.call(this, parameters, isRenderable);
  31384. }
  31385. Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
  31386. render: function TextWidgetAnnotationElement_render() {
  31387. this.container.className = 'textWidgetAnnotation';
  31388. var element = null;
  31389. if (this.renderInteractiveForms) {
  31390. if (this.data.multiLine) {
  31391. element = document.createElement('textarea');
  31392. element.textContent = this.data.fieldValue;
  31393. } else {
  31394. element = document.createElement('input');
  31395. element.type = 'text';
  31396. element.setAttribute('value', this.data.fieldValue);
  31397. }
  31398. element.disabled = this.data.readOnly;
  31399. if (this.data.maxLen !== null) {
  31400. element.maxLength = this.data.maxLen;
  31401. }
  31402. if (this.data.comb) {
  31403. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  31404. var combWidth = fieldWidth / this.data.maxLen;
  31405. element.classList.add('comb');
  31406. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  31407. }
  31408. } else {
  31409. element = document.createElement('div');
  31410. element.textContent = this.data.fieldValue;
  31411. element.style.verticalAlign = 'middle';
  31412. element.style.display = 'table-cell';
  31413. var font = null;
  31414. if (this.data.fontRefName) {
  31415. font = this.page.commonObjs.getData(this.data.fontRefName);
  31416. }
  31417. this._setTextStyle(element, font);
  31418. }
  31419. if (this.data.textAlignment !== null) {
  31420. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  31421. }
  31422. this.container.appendChild(element);
  31423. return this.container;
  31424. },
  31425. _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
  31426. var style = element.style;
  31427. style.fontSize = this.data.fontSize + 'px';
  31428. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  31429. if (!font) {
  31430. return;
  31431. }
  31432. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  31433. style.fontStyle = font.italic ? 'italic' : 'normal';
  31434. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  31435. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  31436. style.fontFamily = fontFamily + fallbackName;
  31437. }
  31438. });
  31439. return TextWidgetAnnotationElement;
  31440. }();
  31441. var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
  31442. function ChoiceWidgetAnnotationElement(parameters) {
  31443. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  31444. }
  31445. Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
  31446. render: function ChoiceWidgetAnnotationElement_render() {
  31447. this.container.className = 'choiceWidgetAnnotation';
  31448. var selectElement = document.createElement('select');
  31449. selectElement.disabled = this.data.readOnly;
  31450. if (!this.data.combo) {
  31451. selectElement.size = this.data.options.length;
  31452. if (this.data.multiSelect) {
  31453. selectElement.multiple = true;
  31454. }
  31455. }
  31456. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  31457. var option = this.data.options[i];
  31458. var optionElement = document.createElement('option');
  31459. optionElement.textContent = option.displayValue;
  31460. optionElement.value = option.exportValue;
  31461. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  31462. optionElement.setAttribute('selected', true);
  31463. }
  31464. selectElement.appendChild(optionElement);
  31465. }
  31466. this.container.appendChild(selectElement);
  31467. return this.container;
  31468. }
  31469. });
  31470. return ChoiceWidgetAnnotationElement;
  31471. }();
  31472. var PopupAnnotationElement = function PopupAnnotationElementClosure() {
  31473. function PopupAnnotationElement(parameters) {
  31474. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  31475. AnnotationElement.call(this, parameters, isRenderable);
  31476. }
  31477. Util.inherit(PopupAnnotationElement, AnnotationElement, {
  31478. render: function PopupAnnotationElement_render() {
  31479. this.container.className = 'popupAnnotation';
  31480. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  31481. var parentElement = this.layer.querySelector(selector);
  31482. if (!parentElement) {
  31483. return this.container;
  31484. }
  31485. var popup = new PopupElement({
  31486. container: this.container,
  31487. trigger: parentElement,
  31488. color: this.data.color,
  31489. title: this.data.title,
  31490. contents: this.data.contents
  31491. });
  31492. var parentLeft = parseFloat(parentElement.style.left);
  31493. var parentWidth = parseFloat(parentElement.style.width);
  31494. CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  31495. this.container.style.left = parentLeft + parentWidth + 'px';
  31496. this.container.appendChild(popup.render());
  31497. return this.container;
  31498. }
  31499. });
  31500. return PopupAnnotationElement;
  31501. }();
  31502. var PopupElement = function PopupElementClosure() {
  31503. var BACKGROUND_ENLIGHT = 0.7;
  31504. function PopupElement(parameters) {
  31505. this.container = parameters.container;
  31506. this.trigger = parameters.trigger;
  31507. this.color = parameters.color;
  31508. this.title = parameters.title;
  31509. this.contents = parameters.contents;
  31510. this.hideWrapper = parameters.hideWrapper || false;
  31511. this.pinned = false;
  31512. }
  31513. PopupElement.prototype = {
  31514. render: function PopupElement_render() {
  31515. var wrapper = document.createElement('div');
  31516. wrapper.className = 'popupWrapper';
  31517. this.hideElement = this.hideWrapper ? wrapper : this.container;
  31518. this.hideElement.setAttribute('hidden', true);
  31519. var popup = document.createElement('div');
  31520. popup.className = 'popup';
  31521. var color = this.color;
  31522. if (color) {
  31523. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  31524. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  31525. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  31526. popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
  31527. }
  31528. var contents = this._formatContents(this.contents);
  31529. var title = document.createElement('h1');
  31530. title.textContent = this.title;
  31531. this.trigger.addEventListener('click', this._toggle.bind(this));
  31532. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  31533. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  31534. popup.addEventListener('click', this._hide.bind(this, true));
  31535. popup.appendChild(title);
  31536. popup.appendChild(contents);
  31537. wrapper.appendChild(popup);
  31538. return wrapper;
  31539. },
  31540. _formatContents: function PopupElement_formatContents(contents) {
  31541. var p = document.createElement('p');
  31542. var lines = contents.split(/(?:\r\n?|\n)/);
  31543. for (var i = 0, ii = lines.length; i < ii; ++i) {
  31544. var line = lines[i];
  31545. p.appendChild(document.createTextNode(line));
  31546. if (i < ii - 1) {
  31547. p.appendChild(document.createElement('br'));
  31548. }
  31549. }
  31550. return p;
  31551. },
  31552. _toggle: function PopupElement_toggle() {
  31553. if (this.pinned) {
  31554. this._hide(true);
  31555. } else {
  31556. this._show(true);
  31557. }
  31558. },
  31559. _show: function PopupElement_show(pin) {
  31560. if (pin) {
  31561. this.pinned = true;
  31562. }
  31563. if (this.hideElement.hasAttribute('hidden')) {
  31564. this.hideElement.removeAttribute('hidden');
  31565. this.container.style.zIndex += 1;
  31566. }
  31567. },
  31568. _hide: function PopupElement_hide(unpin) {
  31569. if (unpin) {
  31570. this.pinned = false;
  31571. }
  31572. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  31573. this.hideElement.setAttribute('hidden', true);
  31574. this.container.style.zIndex -= 1;
  31575. }
  31576. }
  31577. };
  31578. return PopupElement;
  31579. }();
  31580. var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
  31581. function HighlightAnnotationElement(parameters) {
  31582. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31583. AnnotationElement.call(this, parameters, isRenderable);
  31584. }
  31585. Util.inherit(HighlightAnnotationElement, AnnotationElement, {
  31586. render: function HighlightAnnotationElement_render() {
  31587. this.container.className = 'highlightAnnotation';
  31588. if (!this.data.hasPopup) {
  31589. this._createPopup(this.container, null, this.data);
  31590. }
  31591. return this.container;
  31592. }
  31593. });
  31594. return HighlightAnnotationElement;
  31595. }();
  31596. var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
  31597. function UnderlineAnnotationElement(parameters) {
  31598. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31599. AnnotationElement.call(this, parameters, isRenderable);
  31600. }
  31601. Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
  31602. render: function UnderlineAnnotationElement_render() {
  31603. this.container.className = 'underlineAnnotation';
  31604. if (!this.data.hasPopup) {
  31605. this._createPopup(this.container, null, this.data);
  31606. }
  31607. return this.container;
  31608. }
  31609. });
  31610. return UnderlineAnnotationElement;
  31611. }();
  31612. var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
  31613. function SquigglyAnnotationElement(parameters) {
  31614. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31615. AnnotationElement.call(this, parameters, isRenderable);
  31616. }
  31617. Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
  31618. render: function SquigglyAnnotationElement_render() {
  31619. this.container.className = 'squigglyAnnotation';
  31620. if (!this.data.hasPopup) {
  31621. this._createPopup(this.container, null, this.data);
  31622. }
  31623. return this.container;
  31624. }
  31625. });
  31626. return SquigglyAnnotationElement;
  31627. }();
  31628. var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
  31629. function StrikeOutAnnotationElement(parameters) {
  31630. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31631. AnnotationElement.call(this, parameters, isRenderable);
  31632. }
  31633. Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
  31634. render: function StrikeOutAnnotationElement_render() {
  31635. this.container.className = 'strikeoutAnnotation';
  31636. if (!this.data.hasPopup) {
  31637. this._createPopup(this.container, null, this.data);
  31638. }
  31639. return this.container;
  31640. }
  31641. });
  31642. return StrikeOutAnnotationElement;
  31643. }();
  31644. var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
  31645. function FileAttachmentAnnotationElement(parameters) {
  31646. AnnotationElement.call(this, parameters, true);
  31647. this.filename = getFilenameFromUrl(parameters.data.file.filename);
  31648. this.content = parameters.data.file.content;
  31649. }
  31650. Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
  31651. render: function FileAttachmentAnnotationElement_render() {
  31652. this.container.className = 'fileAttachmentAnnotation';
  31653. var trigger = document.createElement('div');
  31654. trigger.style.height = this.container.style.height;
  31655. trigger.style.width = this.container.style.width;
  31656. trigger.addEventListener('dblclick', this._download.bind(this));
  31657. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  31658. this._createPopup(this.container, trigger, this.data);
  31659. }
  31660. this.container.appendChild(trigger);
  31661. return this.container;
  31662. },
  31663. _download: function FileAttachmentAnnotationElement_download() {
  31664. if (!this.downloadManager) {
  31665. warn('Download cannot be started due to unavailable download manager');
  31666. return;
  31667. }
  31668. this.downloadManager.downloadData(this.content, this.filename, '');
  31669. }
  31670. });
  31671. return FileAttachmentAnnotationElement;
  31672. }();
  31673. var AnnotationLayer = function AnnotationLayerClosure() {
  31674. return {
  31675. render: function AnnotationLayer_render(parameters) {
  31676. var annotationElementFactory = new AnnotationElementFactory();
  31677. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  31678. var data = parameters.annotations[i];
  31679. if (!data) {
  31680. continue;
  31681. }
  31682. var properties = {
  31683. data: data,
  31684. layer: parameters.div,
  31685. page: parameters.page,
  31686. viewport: parameters.viewport,
  31687. linkService: parameters.linkService,
  31688. downloadManager: parameters.downloadManager,
  31689. imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
  31690. renderInteractiveForms: parameters.renderInteractiveForms || false
  31691. };
  31692. var element = annotationElementFactory.create(properties);
  31693. if (element.isRenderable) {
  31694. parameters.div.appendChild(element.render());
  31695. }
  31696. }
  31697. },
  31698. update: function AnnotationLayer_update(parameters) {
  31699. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  31700. var data = parameters.annotations[i];
  31701. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  31702. if (element) {
  31703. CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  31704. }
  31705. }
  31706. parameters.div.removeAttribute('hidden');
  31707. }
  31708. };
  31709. }();
  31710. exports.AnnotationLayer = AnnotationLayer;
  31711. }));
  31712. (function (root, factory) {
  31713. factory(root.pdfjsDisplayTextLayer = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  31714. }(this, function (exports, sharedUtil, displayDOMUtils) {
  31715. var Util = sharedUtil.Util;
  31716. var createPromiseCapability = sharedUtil.createPromiseCapability;
  31717. var CustomStyle = displayDOMUtils.CustomStyle;
  31718. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  31719. var renderTextLayer = function renderTextLayerClosure() {
  31720. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  31721. var NonWhitespaceRegexp = /\S/;
  31722. function isAllWhitespace(str) {
  31723. return !NonWhitespaceRegexp.test(str);
  31724. }
  31725. var styleBuf = [
  31726. 'left: ',
  31727. 0,
  31728. 'px; top: ',
  31729. 0,
  31730. 'px; font-size: ',
  31731. 0,
  31732. 'px; font-family: ',
  31733. '',
  31734. ';'
  31735. ];
  31736. function appendText(task, geom, styles) {
  31737. var textDiv = document.createElement('div');
  31738. var textDivProperties = {
  31739. style: null,
  31740. angle: 0,
  31741. canvasWidth: 0,
  31742. isWhitespace: false,
  31743. originalTransform: null,
  31744. paddingBottom: 0,
  31745. paddingLeft: 0,
  31746. paddingRight: 0,
  31747. paddingTop: 0,
  31748. scale: 1
  31749. };
  31750. task._textDivs.push(textDiv);
  31751. if (isAllWhitespace(geom.str)) {
  31752. textDivProperties.isWhitespace = true;
  31753. task._textDivProperties.set(textDiv, textDivProperties);
  31754. return;
  31755. }
  31756. var tx = Util.transform(task._viewport.transform, geom.transform);
  31757. var angle = Math.atan2(tx[1], tx[0]);
  31758. var style = styles[geom.fontName];
  31759. if (style.vertical) {
  31760. angle += Math.PI / 2;
  31761. }
  31762. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  31763. var fontAscent = fontHeight;
  31764. if (style.ascent) {
  31765. fontAscent = style.ascent * fontAscent;
  31766. } else if (style.descent) {
  31767. fontAscent = (1 + style.descent) * fontAscent;
  31768. }
  31769. var left;
  31770. var top;
  31771. if (angle === 0) {
  31772. left = tx[4];
  31773. top = tx[5] - fontAscent;
  31774. } else {
  31775. left = tx[4] + fontAscent * Math.sin(angle);
  31776. top = tx[5] - fontAscent * Math.cos(angle);
  31777. }
  31778. styleBuf[1] = left;
  31779. styleBuf[3] = top;
  31780. styleBuf[5] = fontHeight;
  31781. styleBuf[7] = style.fontFamily;
  31782. textDivProperties.style = styleBuf.join('');
  31783. textDiv.setAttribute('style', textDivProperties.style);
  31784. textDiv.textContent = geom.str;
  31785. if (getDefaultSetting('pdfBug')) {
  31786. textDiv.dataset.fontName = geom.fontName;
  31787. }
  31788. if (angle !== 0) {
  31789. textDivProperties.angle = angle * (180 / Math.PI);
  31790. }
  31791. if (geom.str.length > 1) {
  31792. if (style.vertical) {
  31793. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  31794. } else {
  31795. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  31796. }
  31797. }
  31798. task._textDivProperties.set(textDiv, textDivProperties);
  31799. if (task._enhanceTextSelection) {
  31800. var angleCos = 1, angleSin = 0;
  31801. if (angle !== 0) {
  31802. angleCos = Math.cos(angle);
  31803. angleSin = Math.sin(angle);
  31804. }
  31805. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  31806. var divHeight = fontHeight;
  31807. var m, b;
  31808. if (angle !== 0) {
  31809. m = [
  31810. angleCos,
  31811. angleSin,
  31812. -angleSin,
  31813. angleCos,
  31814. left,
  31815. top
  31816. ];
  31817. b = Util.getAxialAlignedBoundingBox([
  31818. 0,
  31819. 0,
  31820. divWidth,
  31821. divHeight
  31822. ], m);
  31823. } else {
  31824. b = [
  31825. left,
  31826. top,
  31827. left + divWidth,
  31828. top + divHeight
  31829. ];
  31830. }
  31831. task._bounds.push({
  31832. left: b[0],
  31833. top: b[1],
  31834. right: b[2],
  31835. bottom: b[3],
  31836. div: textDiv,
  31837. size: [
  31838. divWidth,
  31839. divHeight
  31840. ],
  31841. m: m
  31842. });
  31843. }
  31844. }
  31845. function render(task) {
  31846. if (task._canceled) {
  31847. return;
  31848. }
  31849. var textLayerFrag = task._container;
  31850. var textDivs = task._textDivs;
  31851. var capability = task._capability;
  31852. var textDivsLength = textDivs.length;
  31853. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  31854. task._renderingDone = true;
  31855. capability.resolve();
  31856. return;
  31857. }
  31858. var canvas = document.createElement('canvas');
  31859. var ctx = canvas.getContext('2d', { alpha: false });
  31860. var lastFontSize;
  31861. var lastFontFamily;
  31862. for (var i = 0; i < textDivsLength; i++) {
  31863. var textDiv = textDivs[i];
  31864. var textDivProperties = task._textDivProperties.get(textDiv);
  31865. if (textDivProperties.isWhitespace) {
  31866. continue;
  31867. }
  31868. var fontSize = textDiv.style.fontSize;
  31869. var fontFamily = textDiv.style.fontFamily;
  31870. if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
  31871. ctx.font = fontSize + ' ' + fontFamily;
  31872. lastFontSize = fontSize;
  31873. lastFontFamily = fontFamily;
  31874. }
  31875. var width = ctx.measureText(textDiv.textContent).width;
  31876. textLayerFrag.appendChild(textDiv);
  31877. var transform = '';
  31878. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  31879. textDivProperties.scale = textDivProperties.canvasWidth / width;
  31880. transform = 'scaleX(' + textDivProperties.scale + ')';
  31881. }
  31882. if (textDivProperties.angle !== 0) {
  31883. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  31884. }
  31885. if (transform !== '') {
  31886. textDivProperties.originalTransform = transform;
  31887. CustomStyle.setProp('transform', textDiv, transform);
  31888. }
  31889. task._textDivProperties.set(textDiv, textDivProperties);
  31890. }
  31891. task._renderingDone = true;
  31892. capability.resolve();
  31893. }
  31894. function expand(task) {
  31895. var bounds = task._bounds;
  31896. var viewport = task._viewport;
  31897. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  31898. for (var i = 0; i < expanded.length; i++) {
  31899. var div = bounds[i].div;
  31900. var divProperties = task._textDivProperties.get(div);
  31901. if (divProperties.angle === 0) {
  31902. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  31903. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  31904. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  31905. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  31906. task._textDivProperties.set(div, divProperties);
  31907. continue;
  31908. }
  31909. var e = expanded[i], b = bounds[i];
  31910. var m = b.m, c = m[0], s = m[1];
  31911. var points = [
  31912. [
  31913. 0,
  31914. 0
  31915. ],
  31916. [
  31917. 0,
  31918. b.size[1]
  31919. ],
  31920. [
  31921. b.size[0],
  31922. 0
  31923. ],
  31924. b.size
  31925. ];
  31926. var ts = new Float64Array(64);
  31927. points.forEach(function (p, i) {
  31928. var t = Util.applyTransform(p, m);
  31929. ts[i + 0] = c && (e.left - t[0]) / c;
  31930. ts[i + 4] = s && (e.top - t[1]) / s;
  31931. ts[i + 8] = c && (e.right - t[0]) / c;
  31932. ts[i + 12] = s && (e.bottom - t[1]) / s;
  31933. ts[i + 16] = s && (e.left - t[0]) / -s;
  31934. ts[i + 20] = c && (e.top - t[1]) / c;
  31935. ts[i + 24] = s && (e.right - t[0]) / -s;
  31936. ts[i + 28] = c && (e.bottom - t[1]) / c;
  31937. ts[i + 32] = c && (e.left - t[0]) / -c;
  31938. ts[i + 36] = s && (e.top - t[1]) / -s;
  31939. ts[i + 40] = c && (e.right - t[0]) / -c;
  31940. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  31941. ts[i + 48] = s && (e.left - t[0]) / s;
  31942. ts[i + 52] = c && (e.top - t[1]) / -c;
  31943. ts[i + 56] = s && (e.right - t[0]) / s;
  31944. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  31945. });
  31946. var findPositiveMin = function (ts, offset, count) {
  31947. var result = 0;
  31948. for (var i = 0; i < count; i++) {
  31949. var t = ts[offset++];
  31950. if (t > 0) {
  31951. result = result ? Math.min(t, result) : t;
  31952. }
  31953. }
  31954. return result;
  31955. };
  31956. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  31957. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  31958. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  31959. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  31960. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  31961. task._textDivProperties.set(div, divProperties);
  31962. }
  31963. }
  31964. function expandBounds(width, height, boxes) {
  31965. var bounds = boxes.map(function (box, i) {
  31966. return {
  31967. x1: box.left,
  31968. y1: box.top,
  31969. x2: box.right,
  31970. y2: box.bottom,
  31971. index: i,
  31972. x1New: undefined,
  31973. x2New: undefined
  31974. };
  31975. });
  31976. expandBoundsLTR(width, bounds);
  31977. var expanded = new Array(boxes.length);
  31978. bounds.forEach(function (b) {
  31979. var i = b.index;
  31980. expanded[i] = {
  31981. left: b.x1New,
  31982. top: 0,
  31983. right: b.x2New,
  31984. bottom: 0
  31985. };
  31986. });
  31987. boxes.map(function (box, i) {
  31988. var e = expanded[i], b = bounds[i];
  31989. b.x1 = box.top;
  31990. b.y1 = width - e.right;
  31991. b.x2 = box.bottom;
  31992. b.y2 = width - e.left;
  31993. b.index = i;
  31994. b.x1New = undefined;
  31995. b.x2New = undefined;
  31996. });
  31997. expandBoundsLTR(height, bounds);
  31998. bounds.forEach(function (b) {
  31999. var i = b.index;
  32000. expanded[i].top = b.x1New;
  32001. expanded[i].bottom = b.x2New;
  32002. });
  32003. return expanded;
  32004. }
  32005. function expandBoundsLTR(width, bounds) {
  32006. bounds.sort(function (a, b) {
  32007. return a.x1 - b.x1 || a.index - b.index;
  32008. });
  32009. var fakeBoundary = {
  32010. x1: -Infinity,
  32011. y1: -Infinity,
  32012. x2: 0,
  32013. y2: Infinity,
  32014. index: -1,
  32015. x1New: 0,
  32016. x2New: 0
  32017. };
  32018. var horizon = [{
  32019. start: -Infinity,
  32020. end: Infinity,
  32021. boundary: fakeBoundary
  32022. }];
  32023. bounds.forEach(function (boundary) {
  32024. var i = 0;
  32025. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  32026. i++;
  32027. }
  32028. var j = horizon.length - 1;
  32029. while (j >= 0 && horizon[j].start >= boundary.y2) {
  32030. j--;
  32031. }
  32032. var horizonPart, affectedBoundary;
  32033. var q, k, maxXNew = -Infinity;
  32034. for (q = i; q <= j; q++) {
  32035. horizonPart = horizon[q];
  32036. affectedBoundary = horizonPart.boundary;
  32037. var xNew;
  32038. if (affectedBoundary.x2 > boundary.x1) {
  32039. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  32040. } else if (affectedBoundary.x2New === undefined) {
  32041. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  32042. } else {
  32043. xNew = affectedBoundary.x2New;
  32044. }
  32045. if (xNew > maxXNew) {
  32046. maxXNew = xNew;
  32047. }
  32048. }
  32049. boundary.x1New = maxXNew;
  32050. for (q = i; q <= j; q++) {
  32051. horizonPart = horizon[q];
  32052. affectedBoundary = horizonPart.boundary;
  32053. if (affectedBoundary.x2New === undefined) {
  32054. if (affectedBoundary.x2 > boundary.x1) {
  32055. if (affectedBoundary.index > boundary.index) {
  32056. affectedBoundary.x2New = affectedBoundary.x2;
  32057. }
  32058. } else {
  32059. affectedBoundary.x2New = maxXNew;
  32060. }
  32061. } else if (affectedBoundary.x2New > maxXNew) {
  32062. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  32063. }
  32064. }
  32065. var changedHorizon = [], lastBoundary = null;
  32066. for (q = i; q <= j; q++) {
  32067. horizonPart = horizon[q];
  32068. affectedBoundary = horizonPart.boundary;
  32069. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  32070. if (lastBoundary === useBoundary) {
  32071. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  32072. } else {
  32073. changedHorizon.push({
  32074. start: horizonPart.start,
  32075. end: horizonPart.end,
  32076. boundary: useBoundary
  32077. });
  32078. lastBoundary = useBoundary;
  32079. }
  32080. }
  32081. if (horizon[i].start < boundary.y1) {
  32082. changedHorizon[0].start = boundary.y1;
  32083. changedHorizon.unshift({
  32084. start: horizon[i].start,
  32085. end: boundary.y1,
  32086. boundary: horizon[i].boundary
  32087. });
  32088. }
  32089. if (boundary.y2 < horizon[j].end) {
  32090. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  32091. changedHorizon.push({
  32092. start: boundary.y2,
  32093. end: horizon[j].end,
  32094. boundary: horizon[j].boundary
  32095. });
  32096. }
  32097. for (q = i; q <= j; q++) {
  32098. horizonPart = horizon[q];
  32099. affectedBoundary = horizonPart.boundary;
  32100. if (affectedBoundary.x2New !== undefined) {
  32101. continue;
  32102. }
  32103. var used = false;
  32104. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  32105. used = horizon[k].boundary === affectedBoundary;
  32106. }
  32107. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  32108. used = horizon[k].boundary === affectedBoundary;
  32109. }
  32110. for (k = 0; !used && k < changedHorizon.length; k++) {
  32111. used = changedHorizon[k].boundary === affectedBoundary;
  32112. }
  32113. if (!used) {
  32114. affectedBoundary.x2New = maxXNew;
  32115. }
  32116. }
  32117. Array.prototype.splice.apply(horizon, [
  32118. i,
  32119. j - i + 1
  32120. ].concat(changedHorizon));
  32121. });
  32122. horizon.forEach(function (horizonPart) {
  32123. var affectedBoundary = horizonPart.boundary;
  32124. if (affectedBoundary.x2New === undefined) {
  32125. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  32126. }
  32127. });
  32128. }
  32129. function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) {
  32130. this._textContent = textContent;
  32131. this._container = container;
  32132. this._viewport = viewport;
  32133. this._textDivs = textDivs || [];
  32134. this._textDivProperties = new WeakMap();
  32135. this._renderingDone = false;
  32136. this._canceled = false;
  32137. this._capability = createPromiseCapability();
  32138. this._renderTimer = null;
  32139. this._bounds = [];
  32140. this._enhanceTextSelection = !!enhanceTextSelection;
  32141. }
  32142. TextLayerRenderTask.prototype = {
  32143. get promise() {
  32144. return this._capability.promise;
  32145. },
  32146. cancel: function TextLayer_cancel() {
  32147. this._canceled = true;
  32148. if (this._renderTimer !== null) {
  32149. clearTimeout(this._renderTimer);
  32150. this._renderTimer = null;
  32151. }
  32152. this._capability.reject('canceled');
  32153. },
  32154. _render: function TextLayer_render(timeout) {
  32155. var textItems = this._textContent.items;
  32156. var textStyles = this._textContent.styles;
  32157. for (var i = 0, len = textItems.length; i < len; i++) {
  32158. appendText(this, textItems[i], textStyles);
  32159. }
  32160. if (!timeout) {
  32161. render(this);
  32162. } else {
  32163. var self = this;
  32164. this._renderTimer = setTimeout(function () {
  32165. render(self);
  32166. self._renderTimer = null;
  32167. }, timeout);
  32168. }
  32169. },
  32170. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  32171. if (!this._enhanceTextSelection || !this._renderingDone) {
  32172. return;
  32173. }
  32174. if (this._bounds !== null) {
  32175. expand(this);
  32176. this._bounds = null;
  32177. }
  32178. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  32179. var div = this._textDivs[i];
  32180. var divProperties = this._textDivProperties.get(div);
  32181. if (divProperties.isWhitespace) {
  32182. continue;
  32183. }
  32184. if (expandDivs) {
  32185. var transform = '', padding = '';
  32186. if (divProperties.scale !== 1) {
  32187. transform = 'scaleX(' + divProperties.scale + ')';
  32188. }
  32189. if (divProperties.angle !== 0) {
  32190. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  32191. }
  32192. if (divProperties.paddingLeft !== 0) {
  32193. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  32194. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  32195. }
  32196. if (divProperties.paddingTop !== 0) {
  32197. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  32198. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  32199. }
  32200. if (divProperties.paddingRight !== 0) {
  32201. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  32202. }
  32203. if (divProperties.paddingBottom !== 0) {
  32204. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  32205. }
  32206. if (padding !== '') {
  32207. div.setAttribute('style', divProperties.style + padding);
  32208. }
  32209. if (transform !== '') {
  32210. CustomStyle.setProp('transform', div, transform);
  32211. }
  32212. } else {
  32213. div.style.padding = 0;
  32214. CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  32215. }
  32216. }
  32217. }
  32218. };
  32219. function renderTextLayer(renderParameters) {
  32220. var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection);
  32221. task._render(renderParameters.timeout);
  32222. return task;
  32223. }
  32224. return renderTextLayer;
  32225. }();
  32226. exports.renderTextLayer = renderTextLayer;
  32227. }));
  32228. (function (root, factory) {
  32229. factory(root.pdfjsDisplayWebGL = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  32230. }(this, function (exports, sharedUtil, displayDOMUtils) {
  32231. var shadow = sharedUtil.shadow;
  32232. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  32233. var WebGLUtils = function WebGLUtilsClosure() {
  32234. function loadShader(gl, code, shaderType) {
  32235. var shader = gl.createShader(shaderType);
  32236. gl.shaderSource(shader, code);
  32237. gl.compileShader(shader);
  32238. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  32239. if (!compiled) {
  32240. var errorMsg = gl.getShaderInfoLog(shader);
  32241. throw new Error('Error during shader compilation: ' + errorMsg);
  32242. }
  32243. return shader;
  32244. }
  32245. function createVertexShader(gl, code) {
  32246. return loadShader(gl, code, gl.VERTEX_SHADER);
  32247. }
  32248. function createFragmentShader(gl, code) {
  32249. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  32250. }
  32251. function createProgram(gl, shaders) {
  32252. var program = gl.createProgram();
  32253. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  32254. gl.attachShader(program, shaders[i]);
  32255. }
  32256. gl.linkProgram(program);
  32257. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  32258. if (!linked) {
  32259. var errorMsg = gl.getProgramInfoLog(program);
  32260. throw new Error('Error during program linking: ' + errorMsg);
  32261. }
  32262. return program;
  32263. }
  32264. function createTexture(gl, image, textureId) {
  32265. gl.activeTexture(textureId);
  32266. var texture = gl.createTexture();
  32267. gl.bindTexture(gl.TEXTURE_2D, texture);
  32268. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32269. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32270. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  32271. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  32272. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  32273. return texture;
  32274. }
  32275. var currentGL, currentCanvas;
  32276. function generateGL() {
  32277. if (currentGL) {
  32278. return;
  32279. }
  32280. currentCanvas = document.createElement('canvas');
  32281. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  32282. }
  32283. var smaskVertexShaderCode = '\
  32284. attribute vec2 a_position; \
  32285. attribute vec2 a_texCoord; \
  32286. \
  32287. uniform vec2 u_resolution; \
  32288. \
  32289. varying vec2 v_texCoord; \
  32290. \
  32291. void main() { \
  32292. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  32293. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  32294. \
  32295. v_texCoord = a_texCoord; \
  32296. } ';
  32297. var smaskFragmentShaderCode = '\
  32298. precision mediump float; \
  32299. \
  32300. uniform vec4 u_backdrop; \
  32301. uniform int u_subtype; \
  32302. uniform sampler2D u_image; \
  32303. uniform sampler2D u_mask; \
  32304. \
  32305. varying vec2 v_texCoord; \
  32306. \
  32307. void main() { \
  32308. vec4 imageColor = texture2D(u_image, v_texCoord); \
  32309. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  32310. if (u_backdrop.a > 0.0) { \
  32311. maskColor.rgb = maskColor.rgb * maskColor.a + \
  32312. u_backdrop.rgb * (1.0 - maskColor.a); \
  32313. } \
  32314. float lum; \
  32315. if (u_subtype == 0) { \
  32316. lum = maskColor.a; \
  32317. } else { \
  32318. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  32319. maskColor.b * 0.11; \
  32320. } \
  32321. imageColor.a *= lum; \
  32322. imageColor.rgb *= imageColor.a; \
  32323. gl_FragColor = imageColor; \
  32324. } ';
  32325. var smaskCache = null;
  32326. function initSmaskGL() {
  32327. var canvas, gl;
  32328. generateGL();
  32329. canvas = currentCanvas;
  32330. currentCanvas = null;
  32331. gl = currentGL;
  32332. currentGL = null;
  32333. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  32334. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  32335. var program = createProgram(gl, [
  32336. vertexShader,
  32337. fragmentShader
  32338. ]);
  32339. gl.useProgram(program);
  32340. var cache = {};
  32341. cache.gl = gl;
  32342. cache.canvas = canvas;
  32343. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  32344. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  32345. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  32346. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  32347. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  32348. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  32349. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  32350. var texCoordBuffer = gl.createBuffer();
  32351. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  32352. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  32353. 0.0,
  32354. 0.0,
  32355. 1.0,
  32356. 0.0,
  32357. 0.0,
  32358. 1.0,
  32359. 0.0,
  32360. 1.0,
  32361. 1.0,
  32362. 0.0,
  32363. 1.0,
  32364. 1.0
  32365. ]), gl.STATIC_DRAW);
  32366. gl.enableVertexAttribArray(texCoordLocation);
  32367. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  32368. gl.uniform1i(texLayerLocation, 0);
  32369. gl.uniform1i(texMaskLocation, 1);
  32370. smaskCache = cache;
  32371. }
  32372. function composeSMask(layer, mask, properties) {
  32373. var width = layer.width, height = layer.height;
  32374. if (!smaskCache) {
  32375. initSmaskGL();
  32376. }
  32377. var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
  32378. canvas.width = width;
  32379. canvas.height = height;
  32380. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  32381. gl.uniform2f(cache.resolutionLocation, width, height);
  32382. if (properties.backdrop) {
  32383. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  32384. } else {
  32385. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  32386. }
  32387. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  32388. var texture = createTexture(gl, layer, gl.TEXTURE0);
  32389. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  32390. var buffer = gl.createBuffer();
  32391. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  32392. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  32393. 0,
  32394. 0,
  32395. width,
  32396. 0,
  32397. 0,
  32398. height,
  32399. 0,
  32400. height,
  32401. width,
  32402. 0,
  32403. width,
  32404. height
  32405. ]), gl.STATIC_DRAW);
  32406. gl.enableVertexAttribArray(cache.positionLocation);
  32407. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  32408. gl.clearColor(0, 0, 0, 0);
  32409. gl.enable(gl.BLEND);
  32410. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  32411. gl.clear(gl.COLOR_BUFFER_BIT);
  32412. gl.drawArrays(gl.TRIANGLES, 0, 6);
  32413. gl.flush();
  32414. gl.deleteTexture(texture);
  32415. gl.deleteTexture(maskTexture);
  32416. gl.deleteBuffer(buffer);
  32417. return canvas;
  32418. }
  32419. var figuresVertexShaderCode = '\
  32420. attribute vec2 a_position; \
  32421. attribute vec3 a_color; \
  32422. \
  32423. uniform vec2 u_resolution; \
  32424. uniform vec2 u_scale; \
  32425. uniform vec2 u_offset; \
  32426. \
  32427. varying vec4 v_color; \
  32428. \
  32429. void main() { \
  32430. vec2 position = (a_position + u_offset) * u_scale; \
  32431. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  32432. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  32433. \
  32434. v_color = vec4(a_color / 255.0, 1.0); \
  32435. } ';
  32436. var figuresFragmentShaderCode = '\
  32437. precision mediump float; \
  32438. \
  32439. varying vec4 v_color; \
  32440. \
  32441. void main() { \
  32442. gl_FragColor = v_color; \
  32443. } ';
  32444. var figuresCache = null;
  32445. function initFiguresGL() {
  32446. var canvas, gl;
  32447. generateGL();
  32448. canvas = currentCanvas;
  32449. currentCanvas = null;
  32450. gl = currentGL;
  32451. currentGL = null;
  32452. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  32453. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  32454. var program = createProgram(gl, [
  32455. vertexShader,
  32456. fragmentShader
  32457. ]);
  32458. gl.useProgram(program);
  32459. var cache = {};
  32460. cache.gl = gl;
  32461. cache.canvas = canvas;
  32462. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  32463. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  32464. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  32465. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  32466. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  32467. figuresCache = cache;
  32468. }
  32469. function drawFigures(width, height, backgroundColor, figures, context) {
  32470. if (!figuresCache) {
  32471. initFiguresGL();
  32472. }
  32473. var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
  32474. canvas.width = width;
  32475. canvas.height = height;
  32476. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  32477. gl.uniform2f(cache.resolutionLocation, width, height);
  32478. var count = 0;
  32479. var i, ii, rows;
  32480. for (i = 0, ii = figures.length; i < ii; i++) {
  32481. switch (figures[i].type) {
  32482. case 'lattice':
  32483. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  32484. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  32485. break;
  32486. case 'triangles':
  32487. count += figures[i].coords.length;
  32488. break;
  32489. }
  32490. }
  32491. var coords = new Float32Array(count * 2);
  32492. var colors = new Uint8Array(count * 3);
  32493. var coordsMap = context.coords, colorsMap = context.colors;
  32494. var pIndex = 0, cIndex = 0;
  32495. for (i = 0, ii = figures.length; i < ii; i++) {
  32496. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  32497. switch (figure.type) {
  32498. case 'lattice':
  32499. var cols = figure.verticesPerRow;
  32500. rows = ps.length / cols | 0;
  32501. for (var row = 1; row < rows; row++) {
  32502. var offset = row * cols + 1;
  32503. for (var col = 1; col < cols; col++, offset++) {
  32504. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  32505. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  32506. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  32507. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  32508. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  32509. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  32510. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  32511. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  32512. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  32513. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  32514. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  32515. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  32516. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  32517. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  32518. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  32519. coords[pIndex + 6] = coords[pIndex + 2];
  32520. coords[pIndex + 7] = coords[pIndex + 3];
  32521. coords[pIndex + 8] = coords[pIndex + 4];
  32522. coords[pIndex + 9] = coords[pIndex + 5];
  32523. coords[pIndex + 10] = coordsMap[ps[offset]];
  32524. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  32525. colors[cIndex + 9] = colors[cIndex + 3];
  32526. colors[cIndex + 10] = colors[cIndex + 4];
  32527. colors[cIndex + 11] = colors[cIndex + 5];
  32528. colors[cIndex + 12] = colors[cIndex + 6];
  32529. colors[cIndex + 13] = colors[cIndex + 7];
  32530. colors[cIndex + 14] = colors[cIndex + 8];
  32531. colors[cIndex + 15] = colorsMap[cs[offset]];
  32532. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  32533. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  32534. pIndex += 12;
  32535. cIndex += 18;
  32536. }
  32537. }
  32538. break;
  32539. case 'triangles':
  32540. for (var j = 0, jj = ps.length; j < jj; j++) {
  32541. coords[pIndex] = coordsMap[ps[j]];
  32542. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  32543. colors[cIndex] = colorsMap[cs[j]];
  32544. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  32545. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  32546. pIndex += 2;
  32547. cIndex += 3;
  32548. }
  32549. break;
  32550. }
  32551. }
  32552. if (backgroundColor) {
  32553. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  32554. } else {
  32555. gl.clearColor(0, 0, 0, 0);
  32556. }
  32557. gl.clear(gl.COLOR_BUFFER_BIT);
  32558. var coordsBuffer = gl.createBuffer();
  32559. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  32560. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  32561. gl.enableVertexAttribArray(cache.positionLocation);
  32562. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  32563. var colorsBuffer = gl.createBuffer();
  32564. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  32565. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  32566. gl.enableVertexAttribArray(cache.colorLocation);
  32567. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  32568. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  32569. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  32570. gl.drawArrays(gl.TRIANGLES, 0, count);
  32571. gl.flush();
  32572. gl.deleteBuffer(coordsBuffer);
  32573. gl.deleteBuffer(colorsBuffer);
  32574. return canvas;
  32575. }
  32576. function cleanup() {
  32577. if (smaskCache && smaskCache.canvas) {
  32578. smaskCache.canvas.width = 0;
  32579. smaskCache.canvas.height = 0;
  32580. }
  32581. if (figuresCache && figuresCache.canvas) {
  32582. figuresCache.canvas.width = 0;
  32583. figuresCache.canvas.height = 0;
  32584. }
  32585. smaskCache = null;
  32586. figuresCache = null;
  32587. }
  32588. return {
  32589. get isEnabled() {
  32590. if (getDefaultSetting('disableWebGL')) {
  32591. return false;
  32592. }
  32593. var enabled = false;
  32594. try {
  32595. generateGL();
  32596. enabled = !!currentGL;
  32597. } catch (e) {
  32598. }
  32599. return shadow(this, 'isEnabled', enabled);
  32600. },
  32601. composeSMask: composeSMask,
  32602. drawFigures: drawFigures,
  32603. clear: cleanup
  32604. };
  32605. }();
  32606. exports.WebGLUtils = WebGLUtils;
  32607. }));
  32608. (function (root, factory) {
  32609. factory(root.pdfjsCoreCrypto = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  32610. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  32611. var PasswordException = sharedUtil.PasswordException;
  32612. var PasswordResponses = sharedUtil.PasswordResponses;
  32613. var bytesToString = sharedUtil.bytesToString;
  32614. var warn = sharedUtil.warn;
  32615. var error = sharedUtil.error;
  32616. var assert = sharedUtil.assert;
  32617. var isInt = sharedUtil.isInt;
  32618. var stringToBytes = sharedUtil.stringToBytes;
  32619. var utf8StringToString = sharedUtil.utf8StringToString;
  32620. var Name = corePrimitives.Name;
  32621. var isName = corePrimitives.isName;
  32622. var isDict = corePrimitives.isDict;
  32623. var DecryptStream = coreStream.DecryptStream;
  32624. var ARCFourCipher = function ARCFourCipherClosure() {
  32625. function ARCFourCipher(key) {
  32626. this.a = 0;
  32627. this.b = 0;
  32628. var s = new Uint8Array(256);
  32629. var i, j = 0, tmp, keyLength = key.length;
  32630. for (i = 0; i < 256; ++i) {
  32631. s[i] = i;
  32632. }
  32633. for (i = 0; i < 256; ++i) {
  32634. tmp = s[i];
  32635. j = j + tmp + key[i % keyLength] & 0xFF;
  32636. s[i] = s[j];
  32637. s[j] = tmp;
  32638. }
  32639. this.s = s;
  32640. }
  32641. ARCFourCipher.prototype = {
  32642. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  32643. var i, n = data.length, tmp, tmp2;
  32644. var a = this.a, b = this.b, s = this.s;
  32645. var output = new Uint8Array(n);
  32646. for (i = 0; i < n; ++i) {
  32647. a = a + 1 & 0xFF;
  32648. tmp = s[a];
  32649. b = b + tmp & 0xFF;
  32650. tmp2 = s[b];
  32651. s[a] = tmp2;
  32652. s[b] = tmp;
  32653. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  32654. }
  32655. this.a = a;
  32656. this.b = b;
  32657. return output;
  32658. }
  32659. };
  32660. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  32661. return ARCFourCipher;
  32662. }();
  32663. var calculateMD5 = function calculateMD5Closure() {
  32664. var r = new Uint8Array([
  32665. 7,
  32666. 12,
  32667. 17,
  32668. 22,
  32669. 7,
  32670. 12,
  32671. 17,
  32672. 22,
  32673. 7,
  32674. 12,
  32675. 17,
  32676. 22,
  32677. 7,
  32678. 12,
  32679. 17,
  32680. 22,
  32681. 5,
  32682. 9,
  32683. 14,
  32684. 20,
  32685. 5,
  32686. 9,
  32687. 14,
  32688. 20,
  32689. 5,
  32690. 9,
  32691. 14,
  32692. 20,
  32693. 5,
  32694. 9,
  32695. 14,
  32696. 20,
  32697. 4,
  32698. 11,
  32699. 16,
  32700. 23,
  32701. 4,
  32702. 11,
  32703. 16,
  32704. 23,
  32705. 4,
  32706. 11,
  32707. 16,
  32708. 23,
  32709. 4,
  32710. 11,
  32711. 16,
  32712. 23,
  32713. 6,
  32714. 10,
  32715. 15,
  32716. 21,
  32717. 6,
  32718. 10,
  32719. 15,
  32720. 21,
  32721. 6,
  32722. 10,
  32723. 15,
  32724. 21,
  32725. 6,
  32726. 10,
  32727. 15,
  32728. 21
  32729. ]);
  32730. var k = new Int32Array([
  32731. -680876936,
  32732. -389564586,
  32733. 606105819,
  32734. -1044525330,
  32735. -176418897,
  32736. 1200080426,
  32737. -1473231341,
  32738. -45705983,
  32739. 1770035416,
  32740. -1958414417,
  32741. -42063,
  32742. -1990404162,
  32743. 1804603682,
  32744. -40341101,
  32745. -1502002290,
  32746. 1236535329,
  32747. -165796510,
  32748. -1069501632,
  32749. 643717713,
  32750. -373897302,
  32751. -701558691,
  32752. 38016083,
  32753. -660478335,
  32754. -405537848,
  32755. 568446438,
  32756. -1019803690,
  32757. -187363961,
  32758. 1163531501,
  32759. -1444681467,
  32760. -51403784,
  32761. 1735328473,
  32762. -1926607734,
  32763. -378558,
  32764. -2022574463,
  32765. 1839030562,
  32766. -35309556,
  32767. -1530992060,
  32768. 1272893353,
  32769. -155497632,
  32770. -1094730640,
  32771. 681279174,
  32772. -358537222,
  32773. -722521979,
  32774. 76029189,
  32775. -640364487,
  32776. -421815835,
  32777. 530742520,
  32778. -995338651,
  32779. -198630844,
  32780. 1126891415,
  32781. -1416354905,
  32782. -57434055,
  32783. 1700485571,
  32784. -1894986606,
  32785. -1051523,
  32786. -2054922799,
  32787. 1873313359,
  32788. -30611744,
  32789. -1560198380,
  32790. 1309151649,
  32791. -145523070,
  32792. -1120210379,
  32793. 718787259,
  32794. -343485551
  32795. ]);
  32796. function hash(data, offset, length) {
  32797. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  32798. var paddedLength = length + 72 & ~63;
  32799. var padded = new Uint8Array(paddedLength);
  32800. var i, j, n;
  32801. for (i = 0; i < length; ++i) {
  32802. padded[i] = data[offset++];
  32803. }
  32804. padded[i++] = 0x80;
  32805. n = paddedLength - 8;
  32806. while (i < n) {
  32807. padded[i++] = 0;
  32808. }
  32809. padded[i++] = length << 3 & 0xFF;
  32810. padded[i++] = length >> 5 & 0xFF;
  32811. padded[i++] = length >> 13 & 0xFF;
  32812. padded[i++] = length >> 21 & 0xFF;
  32813. padded[i++] = length >>> 29 & 0xFF;
  32814. padded[i++] = 0;
  32815. padded[i++] = 0;
  32816. padded[i++] = 0;
  32817. var w = new Int32Array(16);
  32818. for (i = 0; i < paddedLength;) {
  32819. for (j = 0; j < 16; ++j, i += 4) {
  32820. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  32821. }
  32822. var a = h0, b = h1, c = h2, d = h3, f, g;
  32823. for (j = 0; j < 64; ++j) {
  32824. if (j < 16) {
  32825. f = b & c | ~b & d;
  32826. g = j;
  32827. } else if (j < 32) {
  32828. f = d & b | ~d & c;
  32829. g = 5 * j + 1 & 15;
  32830. } else if (j < 48) {
  32831. f = b ^ c ^ d;
  32832. g = 3 * j + 5 & 15;
  32833. } else {
  32834. f = c ^ (b | ~d);
  32835. g = 7 * j & 15;
  32836. }
  32837. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  32838. d = c;
  32839. c = b;
  32840. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  32841. a = tmp;
  32842. }
  32843. h0 = h0 + a | 0;
  32844. h1 = h1 + b | 0;
  32845. h2 = h2 + c | 0;
  32846. h3 = h3 + d | 0;
  32847. }
  32848. return new Uint8Array([
  32849. h0 & 0xFF,
  32850. h0 >> 8 & 0xFF,
  32851. h0 >> 16 & 0xFF,
  32852. h0 >>> 24 & 0xFF,
  32853. h1 & 0xFF,
  32854. h1 >> 8 & 0xFF,
  32855. h1 >> 16 & 0xFF,
  32856. h1 >>> 24 & 0xFF,
  32857. h2 & 0xFF,
  32858. h2 >> 8 & 0xFF,
  32859. h2 >> 16 & 0xFF,
  32860. h2 >>> 24 & 0xFF,
  32861. h3 & 0xFF,
  32862. h3 >> 8 & 0xFF,
  32863. h3 >> 16 & 0xFF,
  32864. h3 >>> 24 & 0xFF
  32865. ]);
  32866. }
  32867. return hash;
  32868. }();
  32869. var Word64 = function Word64Closure() {
  32870. function Word64(highInteger, lowInteger) {
  32871. this.high = highInteger | 0;
  32872. this.low = lowInteger | 0;
  32873. }
  32874. Word64.prototype = {
  32875. and: function Word64_and(word) {
  32876. this.high &= word.high;
  32877. this.low &= word.low;
  32878. },
  32879. xor: function Word64_xor(word) {
  32880. this.high ^= word.high;
  32881. this.low ^= word.low;
  32882. },
  32883. or: function Word64_or(word) {
  32884. this.high |= word.high;
  32885. this.low |= word.low;
  32886. },
  32887. shiftRight: function Word64_shiftRight(places) {
  32888. if (places >= 32) {
  32889. this.low = this.high >>> places - 32 | 0;
  32890. this.high = 0;
  32891. } else {
  32892. this.low = this.low >>> places | this.high << 32 - places;
  32893. this.high = this.high >>> places | 0;
  32894. }
  32895. },
  32896. shiftLeft: function Word64_shiftLeft(places) {
  32897. if (places >= 32) {
  32898. this.high = this.low << places - 32;
  32899. this.low = 0;
  32900. } else {
  32901. this.high = this.high << places | this.low >>> 32 - places;
  32902. this.low = this.low << places;
  32903. }
  32904. },
  32905. rotateRight: function Word64_rotateRight(places) {
  32906. var low, high;
  32907. if (places & 32) {
  32908. high = this.low;
  32909. low = this.high;
  32910. } else {
  32911. low = this.low;
  32912. high = this.high;
  32913. }
  32914. places &= 31;
  32915. this.low = low >>> places | high << 32 - places;
  32916. this.high = high >>> places | low << 32 - places;
  32917. },
  32918. not: function Word64_not() {
  32919. this.high = ~this.high;
  32920. this.low = ~this.low;
  32921. },
  32922. add: function Word64_add(word) {
  32923. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  32924. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  32925. if (lowAdd > 0xFFFFFFFF) {
  32926. highAdd += 1;
  32927. }
  32928. this.low = lowAdd | 0;
  32929. this.high = highAdd | 0;
  32930. },
  32931. copyTo: function Word64_copyTo(bytes, offset) {
  32932. bytes[offset] = this.high >>> 24 & 0xFF;
  32933. bytes[offset + 1] = this.high >> 16 & 0xFF;
  32934. bytes[offset + 2] = this.high >> 8 & 0xFF;
  32935. bytes[offset + 3] = this.high & 0xFF;
  32936. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  32937. bytes[offset + 5] = this.low >> 16 & 0xFF;
  32938. bytes[offset + 6] = this.low >> 8 & 0xFF;
  32939. bytes[offset + 7] = this.low & 0xFF;
  32940. },
  32941. assign: function Word64_assign(word) {
  32942. this.high = word.high;
  32943. this.low = word.low;
  32944. }
  32945. };
  32946. return Word64;
  32947. }();
  32948. var calculateSHA256 = function calculateSHA256Closure() {
  32949. function rotr(x, n) {
  32950. return x >>> n | x << 32 - n;
  32951. }
  32952. function ch(x, y, z) {
  32953. return x & y ^ ~x & z;
  32954. }
  32955. function maj(x, y, z) {
  32956. return x & y ^ x & z ^ y & z;
  32957. }
  32958. function sigma(x) {
  32959. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  32960. }
  32961. function sigmaPrime(x) {
  32962. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  32963. }
  32964. function littleSigma(x) {
  32965. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  32966. }
  32967. function littleSigmaPrime(x) {
  32968. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  32969. }
  32970. var k = [
  32971. 0x428a2f98,
  32972. 0x71374491,
  32973. 0xb5c0fbcf,
  32974. 0xe9b5dba5,
  32975. 0x3956c25b,
  32976. 0x59f111f1,
  32977. 0x923f82a4,
  32978. 0xab1c5ed5,
  32979. 0xd807aa98,
  32980. 0x12835b01,
  32981. 0x243185be,
  32982. 0x550c7dc3,
  32983. 0x72be5d74,
  32984. 0x80deb1fe,
  32985. 0x9bdc06a7,
  32986. 0xc19bf174,
  32987. 0xe49b69c1,
  32988. 0xefbe4786,
  32989. 0x0fc19dc6,
  32990. 0x240ca1cc,
  32991. 0x2de92c6f,
  32992. 0x4a7484aa,
  32993. 0x5cb0a9dc,
  32994. 0x76f988da,
  32995. 0x983e5152,
  32996. 0xa831c66d,
  32997. 0xb00327c8,
  32998. 0xbf597fc7,
  32999. 0xc6e00bf3,
  33000. 0xd5a79147,
  33001. 0x06ca6351,
  33002. 0x14292967,
  33003. 0x27b70a85,
  33004. 0x2e1b2138,
  33005. 0x4d2c6dfc,
  33006. 0x53380d13,
  33007. 0x650a7354,
  33008. 0x766a0abb,
  33009. 0x81c2c92e,
  33010. 0x92722c85,
  33011. 0xa2bfe8a1,
  33012. 0xa81a664b,
  33013. 0xc24b8b70,
  33014. 0xc76c51a3,
  33015. 0xd192e819,
  33016. 0xd6990624,
  33017. 0xf40e3585,
  33018. 0x106aa070,
  33019. 0x19a4c116,
  33020. 0x1e376c08,
  33021. 0x2748774c,
  33022. 0x34b0bcb5,
  33023. 0x391c0cb3,
  33024. 0x4ed8aa4a,
  33025. 0x5b9cca4f,
  33026. 0x682e6ff3,
  33027. 0x748f82ee,
  33028. 0x78a5636f,
  33029. 0x84c87814,
  33030. 0x8cc70208,
  33031. 0x90befffa,
  33032. 0xa4506ceb,
  33033. 0xbef9a3f7,
  33034. 0xc67178f2
  33035. ];
  33036. function hash(data, offset, length) {
  33037. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  33038. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  33039. var padded = new Uint8Array(paddedLength);
  33040. var i, j, n;
  33041. for (i = 0; i < length; ++i) {
  33042. padded[i] = data[offset++];
  33043. }
  33044. padded[i++] = 0x80;
  33045. n = paddedLength - 8;
  33046. while (i < n) {
  33047. padded[i++] = 0;
  33048. }
  33049. padded[i++] = 0;
  33050. padded[i++] = 0;
  33051. padded[i++] = 0;
  33052. padded[i++] = length >>> 29 & 0xFF;
  33053. padded[i++] = length >> 21 & 0xFF;
  33054. padded[i++] = length >> 13 & 0xFF;
  33055. padded[i++] = length >> 5 & 0xFF;
  33056. padded[i++] = length << 3 & 0xFF;
  33057. var w = new Uint32Array(64);
  33058. for (i = 0; i < paddedLength;) {
  33059. for (j = 0; j < 16; ++j) {
  33060. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  33061. i += 4;
  33062. }
  33063. for (j = 16; j < 64; ++j) {
  33064. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  33065. }
  33066. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  33067. for (j = 0; j < 64; ++j) {
  33068. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  33069. t2 = sigma(a) + maj(a, b, c);
  33070. h = g;
  33071. g = f;
  33072. f = e;
  33073. e = d + t1 | 0;
  33074. d = c;
  33075. c = b;
  33076. b = a;
  33077. a = t1 + t2 | 0;
  33078. }
  33079. h0 = h0 + a | 0;
  33080. h1 = h1 + b | 0;
  33081. h2 = h2 + c | 0;
  33082. h3 = h3 + d | 0;
  33083. h4 = h4 + e | 0;
  33084. h5 = h5 + f | 0;
  33085. h6 = h6 + g | 0;
  33086. h7 = h7 + h | 0;
  33087. }
  33088. return new Uint8Array([
  33089. h0 >> 24 & 0xFF,
  33090. h0 >> 16 & 0xFF,
  33091. h0 >> 8 & 0xFF,
  33092. h0 & 0xFF,
  33093. h1 >> 24 & 0xFF,
  33094. h1 >> 16 & 0xFF,
  33095. h1 >> 8 & 0xFF,
  33096. h1 & 0xFF,
  33097. h2 >> 24 & 0xFF,
  33098. h2 >> 16 & 0xFF,
  33099. h2 >> 8 & 0xFF,
  33100. h2 & 0xFF,
  33101. h3 >> 24 & 0xFF,
  33102. h3 >> 16 & 0xFF,
  33103. h3 >> 8 & 0xFF,
  33104. h3 & 0xFF,
  33105. h4 >> 24 & 0xFF,
  33106. h4 >> 16 & 0xFF,
  33107. h4 >> 8 & 0xFF,
  33108. h4 & 0xFF,
  33109. h5 >> 24 & 0xFF,
  33110. h5 >> 16 & 0xFF,
  33111. h5 >> 8 & 0xFF,
  33112. h5 & 0xFF,
  33113. h6 >> 24 & 0xFF,
  33114. h6 >> 16 & 0xFF,
  33115. h6 >> 8 & 0xFF,
  33116. h6 & 0xFF,
  33117. h7 >> 24 & 0xFF,
  33118. h7 >> 16 & 0xFF,
  33119. h7 >> 8 & 0xFF,
  33120. h7 & 0xFF
  33121. ]);
  33122. }
  33123. return hash;
  33124. }();
  33125. var calculateSHA512 = function calculateSHA512Closure() {
  33126. function ch(result, x, y, z, tmp) {
  33127. result.assign(x);
  33128. result.and(y);
  33129. tmp.assign(x);
  33130. tmp.not();
  33131. tmp.and(z);
  33132. result.xor(tmp);
  33133. }
  33134. function maj(result, x, y, z, tmp) {
  33135. result.assign(x);
  33136. result.and(y);
  33137. tmp.assign(x);
  33138. tmp.and(z);
  33139. result.xor(tmp);
  33140. tmp.assign(y);
  33141. tmp.and(z);
  33142. result.xor(tmp);
  33143. }
  33144. function sigma(result, x, tmp) {
  33145. result.assign(x);
  33146. result.rotateRight(28);
  33147. tmp.assign(x);
  33148. tmp.rotateRight(34);
  33149. result.xor(tmp);
  33150. tmp.assign(x);
  33151. tmp.rotateRight(39);
  33152. result.xor(tmp);
  33153. }
  33154. function sigmaPrime(result, x, tmp) {
  33155. result.assign(x);
  33156. result.rotateRight(14);
  33157. tmp.assign(x);
  33158. tmp.rotateRight(18);
  33159. result.xor(tmp);
  33160. tmp.assign(x);
  33161. tmp.rotateRight(41);
  33162. result.xor(tmp);
  33163. }
  33164. function littleSigma(result, x, tmp) {
  33165. result.assign(x);
  33166. result.rotateRight(1);
  33167. tmp.assign(x);
  33168. tmp.rotateRight(8);
  33169. result.xor(tmp);
  33170. tmp.assign(x);
  33171. tmp.shiftRight(7);
  33172. result.xor(tmp);
  33173. }
  33174. function littleSigmaPrime(result, x, tmp) {
  33175. result.assign(x);
  33176. result.rotateRight(19);
  33177. tmp.assign(x);
  33178. tmp.rotateRight(61);
  33179. result.xor(tmp);
  33180. tmp.assign(x);
  33181. tmp.shiftRight(6);
  33182. result.xor(tmp);
  33183. }
  33184. var k = [
  33185. new Word64(0x428a2f98, 0xd728ae22),
  33186. new Word64(0x71374491, 0x23ef65cd),
  33187. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  33188. new Word64(0xe9b5dba5, 0x8189dbbc),
  33189. new Word64(0x3956c25b, 0xf348b538),
  33190. new Word64(0x59f111f1, 0xb605d019),
  33191. new Word64(0x923f82a4, 0xaf194f9b),
  33192. new Word64(0xab1c5ed5, 0xda6d8118),
  33193. new Word64(0xd807aa98, 0xa3030242),
  33194. new Word64(0x12835b01, 0x45706fbe),
  33195. new Word64(0x243185be, 0x4ee4b28c),
  33196. new Word64(0x550c7dc3, 0xd5ffb4e2),
  33197. new Word64(0x72be5d74, 0xf27b896f),
  33198. new Word64(0x80deb1fe, 0x3b1696b1),
  33199. new Word64(0x9bdc06a7, 0x25c71235),
  33200. new Word64(0xc19bf174, 0xcf692694),
  33201. new Word64(0xe49b69c1, 0x9ef14ad2),
  33202. new Word64(0xefbe4786, 0x384f25e3),
  33203. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  33204. new Word64(0x240ca1cc, 0x77ac9c65),
  33205. new Word64(0x2de92c6f, 0x592b0275),
  33206. new Word64(0x4a7484aa, 0x6ea6e483),
  33207. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  33208. new Word64(0x76f988da, 0x831153b5),
  33209. new Word64(0x983e5152, 0xee66dfab),
  33210. new Word64(0xa831c66d, 0x2db43210),
  33211. new Word64(0xb00327c8, 0x98fb213f),
  33212. new Word64(0xbf597fc7, 0xbeef0ee4),
  33213. new Word64(0xc6e00bf3, 0x3da88fc2),
  33214. new Word64(0xd5a79147, 0x930aa725),
  33215. new Word64(0x06ca6351, 0xe003826f),
  33216. new Word64(0x14292967, 0x0a0e6e70),
  33217. new Word64(0x27b70a85, 0x46d22ffc),
  33218. new Word64(0x2e1b2138, 0x5c26c926),
  33219. new Word64(0x4d2c6dfc, 0x5ac42aed),
  33220. new Word64(0x53380d13, 0x9d95b3df),
  33221. new Word64(0x650a7354, 0x8baf63de),
  33222. new Word64(0x766a0abb, 0x3c77b2a8),
  33223. new Word64(0x81c2c92e, 0x47edaee6),
  33224. new Word64(0x92722c85, 0x1482353b),
  33225. new Word64(0xa2bfe8a1, 0x4cf10364),
  33226. new Word64(0xa81a664b, 0xbc423001),
  33227. new Word64(0xc24b8b70, 0xd0f89791),
  33228. new Word64(0xc76c51a3, 0x0654be30),
  33229. new Word64(0xd192e819, 0xd6ef5218),
  33230. new Word64(0xd6990624, 0x5565a910),
  33231. new Word64(0xf40e3585, 0x5771202a),
  33232. new Word64(0x106aa070, 0x32bbd1b8),
  33233. new Word64(0x19a4c116, 0xb8d2d0c8),
  33234. new Word64(0x1e376c08, 0x5141ab53),
  33235. new Word64(0x2748774c, 0xdf8eeb99),
  33236. new Word64(0x34b0bcb5, 0xe19b48a8),
  33237. new Word64(0x391c0cb3, 0xc5c95a63),
  33238. new Word64(0x4ed8aa4a, 0xe3418acb),
  33239. new Word64(0x5b9cca4f, 0x7763e373),
  33240. new Word64(0x682e6ff3, 0xd6b2b8a3),
  33241. new Word64(0x748f82ee, 0x5defb2fc),
  33242. new Word64(0x78a5636f, 0x43172f60),
  33243. new Word64(0x84c87814, 0xa1f0ab72),
  33244. new Word64(0x8cc70208, 0x1a6439ec),
  33245. new Word64(0x90befffa, 0x23631e28),
  33246. new Word64(0xa4506ceb, 0xde82bde9),
  33247. new Word64(0xbef9a3f7, 0xb2c67915),
  33248. new Word64(0xc67178f2, 0xe372532b),
  33249. new Word64(0xca273ece, 0xea26619c),
  33250. new Word64(0xd186b8c7, 0x21c0c207),
  33251. new Word64(0xeada7dd6, 0xcde0eb1e),
  33252. new Word64(0xf57d4f7f, 0xee6ed178),
  33253. new Word64(0x06f067aa, 0x72176fba),
  33254. new Word64(0x0a637dc5, 0xa2c898a6),
  33255. new Word64(0x113f9804, 0xbef90dae),
  33256. new Word64(0x1b710b35, 0x131c471b),
  33257. new Word64(0x28db77f5, 0x23047d84),
  33258. new Word64(0x32caab7b, 0x40c72493),
  33259. new Word64(0x3c9ebe0a, 0x15c9bebc),
  33260. new Word64(0x431d67c4, 0x9c100d4c),
  33261. new Word64(0x4cc5d4be, 0xcb3e42b6),
  33262. new Word64(0x597f299c, 0xfc657e2a),
  33263. new Word64(0x5fcb6fab, 0x3ad6faec),
  33264. new Word64(0x6c44198c, 0x4a475817)
  33265. ];
  33266. function hash(data, offset, length, mode384) {
  33267. mode384 = !!mode384;
  33268. var h0, h1, h2, h3, h4, h5, h6, h7;
  33269. if (!mode384) {
  33270. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  33271. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  33272. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  33273. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  33274. h4 = new Word64(0x510e527f, 0xade682d1);
  33275. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  33276. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  33277. h7 = new Word64(0x5be0cd19, 0x137e2179);
  33278. } else {
  33279. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  33280. h1 = new Word64(0x629a292a, 0x367cd507);
  33281. h2 = new Word64(0x9159015a, 0x3070dd17);
  33282. h3 = new Word64(0x152fecd8, 0xf70e5939);
  33283. h4 = new Word64(0x67332667, 0xffc00b31);
  33284. h5 = new Word64(0x8eb44a87, 0x68581511);
  33285. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  33286. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  33287. }
  33288. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  33289. var padded = new Uint8Array(paddedLength);
  33290. var i, j, n;
  33291. for (i = 0; i < length; ++i) {
  33292. padded[i] = data[offset++];
  33293. }
  33294. padded[i++] = 0x80;
  33295. n = paddedLength - 16;
  33296. while (i < n) {
  33297. padded[i++] = 0;
  33298. }
  33299. padded[i++] = 0;
  33300. padded[i++] = 0;
  33301. padded[i++] = 0;
  33302. padded[i++] = 0;
  33303. padded[i++] = 0;
  33304. padded[i++] = 0;
  33305. padded[i++] = 0;
  33306. padded[i++] = 0;
  33307. padded[i++] = 0;
  33308. padded[i++] = 0;
  33309. padded[i++] = 0;
  33310. padded[i++] = length >>> 29 & 0xFF;
  33311. padded[i++] = length >> 21 & 0xFF;
  33312. padded[i++] = length >> 13 & 0xFF;
  33313. padded[i++] = length >> 5 & 0xFF;
  33314. padded[i++] = length << 3 & 0xFF;
  33315. var w = new Array(80);
  33316. for (i = 0; i < 80; i++) {
  33317. w[i] = new Word64(0, 0);
  33318. }
  33319. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  33320. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  33321. var g = new Word64(0, 0), h = new Word64(0, 0);
  33322. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  33323. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  33324. for (i = 0; i < paddedLength;) {
  33325. for (j = 0; j < 16; ++j) {
  33326. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  33327. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  33328. i += 8;
  33329. }
  33330. for (j = 16; j < 80; ++j) {
  33331. tmp3 = w[j];
  33332. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  33333. tmp3.add(w[j - 7]);
  33334. littleSigma(tmp1, w[j - 15], tmp2);
  33335. tmp3.add(tmp1);
  33336. tmp3.add(w[j - 16]);
  33337. }
  33338. a.assign(h0);
  33339. b.assign(h1);
  33340. c.assign(h2);
  33341. d.assign(h3);
  33342. e.assign(h4);
  33343. f.assign(h5);
  33344. g.assign(h6);
  33345. h.assign(h7);
  33346. for (j = 0; j < 80; ++j) {
  33347. t1.assign(h);
  33348. sigmaPrime(tmp1, e, tmp2);
  33349. t1.add(tmp1);
  33350. ch(tmp1, e, f, g, tmp2);
  33351. t1.add(tmp1);
  33352. t1.add(k[j]);
  33353. t1.add(w[j]);
  33354. sigma(t2, a, tmp2);
  33355. maj(tmp1, a, b, c, tmp2);
  33356. t2.add(tmp1);
  33357. tmp3 = h;
  33358. h = g;
  33359. g = f;
  33360. f = e;
  33361. d.add(t1);
  33362. e = d;
  33363. d = c;
  33364. c = b;
  33365. b = a;
  33366. tmp3.assign(t1);
  33367. tmp3.add(t2);
  33368. a = tmp3;
  33369. }
  33370. h0.add(a);
  33371. h1.add(b);
  33372. h2.add(c);
  33373. h3.add(d);
  33374. h4.add(e);
  33375. h5.add(f);
  33376. h6.add(g);
  33377. h7.add(h);
  33378. }
  33379. var result;
  33380. if (!mode384) {
  33381. result = new Uint8Array(64);
  33382. h0.copyTo(result, 0);
  33383. h1.copyTo(result, 8);
  33384. h2.copyTo(result, 16);
  33385. h3.copyTo(result, 24);
  33386. h4.copyTo(result, 32);
  33387. h5.copyTo(result, 40);
  33388. h6.copyTo(result, 48);
  33389. h7.copyTo(result, 56);
  33390. } else {
  33391. result = new Uint8Array(48);
  33392. h0.copyTo(result, 0);
  33393. h1.copyTo(result, 8);
  33394. h2.copyTo(result, 16);
  33395. h3.copyTo(result, 24);
  33396. h4.copyTo(result, 32);
  33397. h5.copyTo(result, 40);
  33398. }
  33399. return result;
  33400. }
  33401. return hash;
  33402. }();
  33403. var calculateSHA384 = function calculateSHA384Closure() {
  33404. function hash(data, offset, length) {
  33405. return calculateSHA512(data, offset, length, true);
  33406. }
  33407. return hash;
  33408. }();
  33409. var NullCipher = function NullCipherClosure() {
  33410. function NullCipher() {
  33411. }
  33412. NullCipher.prototype = {
  33413. decryptBlock: function NullCipher_decryptBlock(data) {
  33414. return data;
  33415. }
  33416. };
  33417. return NullCipher;
  33418. }();
  33419. var AES128Cipher = function AES128CipherClosure() {
  33420. var rcon = new Uint8Array([
  33421. 0x8d,
  33422. 0x01,
  33423. 0x02,
  33424. 0x04,
  33425. 0x08,
  33426. 0x10,
  33427. 0x20,
  33428. 0x40,
  33429. 0x80,
  33430. 0x1b,
  33431. 0x36,
  33432. 0x6c,
  33433. 0xd8,
  33434. 0xab,
  33435. 0x4d,
  33436. 0x9a,
  33437. 0x2f,
  33438. 0x5e,
  33439. 0xbc,
  33440. 0x63,
  33441. 0xc6,
  33442. 0x97,
  33443. 0x35,
  33444. 0x6a,
  33445. 0xd4,
  33446. 0xb3,
  33447. 0x7d,
  33448. 0xfa,
  33449. 0xef,
  33450. 0xc5,
  33451. 0x91,
  33452. 0x39,
  33453. 0x72,
  33454. 0xe4,
  33455. 0xd3,
  33456. 0xbd,
  33457. 0x61,
  33458. 0xc2,
  33459. 0x9f,
  33460. 0x25,
  33461. 0x4a,
  33462. 0x94,
  33463. 0x33,
  33464. 0x66,
  33465. 0xcc,
  33466. 0x83,
  33467. 0x1d,
  33468. 0x3a,
  33469. 0x74,
  33470. 0xe8,
  33471. 0xcb,
  33472. 0x8d,
  33473. 0x01,
  33474. 0x02,
  33475. 0x04,
  33476. 0x08,
  33477. 0x10,
  33478. 0x20,
  33479. 0x40,
  33480. 0x80,
  33481. 0x1b,
  33482. 0x36,
  33483. 0x6c,
  33484. 0xd8,
  33485. 0xab,
  33486. 0x4d,
  33487. 0x9a,
  33488. 0x2f,
  33489. 0x5e,
  33490. 0xbc,
  33491. 0x63,
  33492. 0xc6,
  33493. 0x97,
  33494. 0x35,
  33495. 0x6a,
  33496. 0xd4,
  33497. 0xb3,
  33498. 0x7d,
  33499. 0xfa,
  33500. 0xef,
  33501. 0xc5,
  33502. 0x91,
  33503. 0x39,
  33504. 0x72,
  33505. 0xe4,
  33506. 0xd3,
  33507. 0xbd,
  33508. 0x61,
  33509. 0xc2,
  33510. 0x9f,
  33511. 0x25,
  33512. 0x4a,
  33513. 0x94,
  33514. 0x33,
  33515. 0x66,
  33516. 0xcc,
  33517. 0x83,
  33518. 0x1d,
  33519. 0x3a,
  33520. 0x74,
  33521. 0xe8,
  33522. 0xcb,
  33523. 0x8d,
  33524. 0x01,
  33525. 0x02,
  33526. 0x04,
  33527. 0x08,
  33528. 0x10,
  33529. 0x20,
  33530. 0x40,
  33531. 0x80,
  33532. 0x1b,
  33533. 0x36,
  33534. 0x6c,
  33535. 0xd8,
  33536. 0xab,
  33537. 0x4d,
  33538. 0x9a,
  33539. 0x2f,
  33540. 0x5e,
  33541. 0xbc,
  33542. 0x63,
  33543. 0xc6,
  33544. 0x97,
  33545. 0x35,
  33546. 0x6a,
  33547. 0xd4,
  33548. 0xb3,
  33549. 0x7d,
  33550. 0xfa,
  33551. 0xef,
  33552. 0xc5,
  33553. 0x91,
  33554. 0x39,
  33555. 0x72,
  33556. 0xe4,
  33557. 0xd3,
  33558. 0xbd,
  33559. 0x61,
  33560. 0xc2,
  33561. 0x9f,
  33562. 0x25,
  33563. 0x4a,
  33564. 0x94,
  33565. 0x33,
  33566. 0x66,
  33567. 0xcc,
  33568. 0x83,
  33569. 0x1d,
  33570. 0x3a,
  33571. 0x74,
  33572. 0xe8,
  33573. 0xcb,
  33574. 0x8d,
  33575. 0x01,
  33576. 0x02,
  33577. 0x04,
  33578. 0x08,
  33579. 0x10,
  33580. 0x20,
  33581. 0x40,
  33582. 0x80,
  33583. 0x1b,
  33584. 0x36,
  33585. 0x6c,
  33586. 0xd8,
  33587. 0xab,
  33588. 0x4d,
  33589. 0x9a,
  33590. 0x2f,
  33591. 0x5e,
  33592. 0xbc,
  33593. 0x63,
  33594. 0xc6,
  33595. 0x97,
  33596. 0x35,
  33597. 0x6a,
  33598. 0xd4,
  33599. 0xb3,
  33600. 0x7d,
  33601. 0xfa,
  33602. 0xef,
  33603. 0xc5,
  33604. 0x91,
  33605. 0x39,
  33606. 0x72,
  33607. 0xe4,
  33608. 0xd3,
  33609. 0xbd,
  33610. 0x61,
  33611. 0xc2,
  33612. 0x9f,
  33613. 0x25,
  33614. 0x4a,
  33615. 0x94,
  33616. 0x33,
  33617. 0x66,
  33618. 0xcc,
  33619. 0x83,
  33620. 0x1d,
  33621. 0x3a,
  33622. 0x74,
  33623. 0xe8,
  33624. 0xcb,
  33625. 0x8d,
  33626. 0x01,
  33627. 0x02,
  33628. 0x04,
  33629. 0x08,
  33630. 0x10,
  33631. 0x20,
  33632. 0x40,
  33633. 0x80,
  33634. 0x1b,
  33635. 0x36,
  33636. 0x6c,
  33637. 0xd8,
  33638. 0xab,
  33639. 0x4d,
  33640. 0x9a,
  33641. 0x2f,
  33642. 0x5e,
  33643. 0xbc,
  33644. 0x63,
  33645. 0xc6,
  33646. 0x97,
  33647. 0x35,
  33648. 0x6a,
  33649. 0xd4,
  33650. 0xb3,
  33651. 0x7d,
  33652. 0xfa,
  33653. 0xef,
  33654. 0xc5,
  33655. 0x91,
  33656. 0x39,
  33657. 0x72,
  33658. 0xe4,
  33659. 0xd3,
  33660. 0xbd,
  33661. 0x61,
  33662. 0xc2,
  33663. 0x9f,
  33664. 0x25,
  33665. 0x4a,
  33666. 0x94,
  33667. 0x33,
  33668. 0x66,
  33669. 0xcc,
  33670. 0x83,
  33671. 0x1d,
  33672. 0x3a,
  33673. 0x74,
  33674. 0xe8,
  33675. 0xcb,
  33676. 0x8d
  33677. ]);
  33678. var s = new Uint8Array([
  33679. 0x63,
  33680. 0x7c,
  33681. 0x77,
  33682. 0x7b,
  33683. 0xf2,
  33684. 0x6b,
  33685. 0x6f,
  33686. 0xc5,
  33687. 0x30,
  33688. 0x01,
  33689. 0x67,
  33690. 0x2b,
  33691. 0xfe,
  33692. 0xd7,
  33693. 0xab,
  33694. 0x76,
  33695. 0xca,
  33696. 0x82,
  33697. 0xc9,
  33698. 0x7d,
  33699. 0xfa,
  33700. 0x59,
  33701. 0x47,
  33702. 0xf0,
  33703. 0xad,
  33704. 0xd4,
  33705. 0xa2,
  33706. 0xaf,
  33707. 0x9c,
  33708. 0xa4,
  33709. 0x72,
  33710. 0xc0,
  33711. 0xb7,
  33712. 0xfd,
  33713. 0x93,
  33714. 0x26,
  33715. 0x36,
  33716. 0x3f,
  33717. 0xf7,
  33718. 0xcc,
  33719. 0x34,
  33720. 0xa5,
  33721. 0xe5,
  33722. 0xf1,
  33723. 0x71,
  33724. 0xd8,
  33725. 0x31,
  33726. 0x15,
  33727. 0x04,
  33728. 0xc7,
  33729. 0x23,
  33730. 0xc3,
  33731. 0x18,
  33732. 0x96,
  33733. 0x05,
  33734. 0x9a,
  33735. 0x07,
  33736. 0x12,
  33737. 0x80,
  33738. 0xe2,
  33739. 0xeb,
  33740. 0x27,
  33741. 0xb2,
  33742. 0x75,
  33743. 0x09,
  33744. 0x83,
  33745. 0x2c,
  33746. 0x1a,
  33747. 0x1b,
  33748. 0x6e,
  33749. 0x5a,
  33750. 0xa0,
  33751. 0x52,
  33752. 0x3b,
  33753. 0xd6,
  33754. 0xb3,
  33755. 0x29,
  33756. 0xe3,
  33757. 0x2f,
  33758. 0x84,
  33759. 0x53,
  33760. 0xd1,
  33761. 0x00,
  33762. 0xed,
  33763. 0x20,
  33764. 0xfc,
  33765. 0xb1,
  33766. 0x5b,
  33767. 0x6a,
  33768. 0xcb,
  33769. 0xbe,
  33770. 0x39,
  33771. 0x4a,
  33772. 0x4c,
  33773. 0x58,
  33774. 0xcf,
  33775. 0xd0,
  33776. 0xef,
  33777. 0xaa,
  33778. 0xfb,
  33779. 0x43,
  33780. 0x4d,
  33781. 0x33,
  33782. 0x85,
  33783. 0x45,
  33784. 0xf9,
  33785. 0x02,
  33786. 0x7f,
  33787. 0x50,
  33788. 0x3c,
  33789. 0x9f,
  33790. 0xa8,
  33791. 0x51,
  33792. 0xa3,
  33793. 0x40,
  33794. 0x8f,
  33795. 0x92,
  33796. 0x9d,
  33797. 0x38,
  33798. 0xf5,
  33799. 0xbc,
  33800. 0xb6,
  33801. 0xda,
  33802. 0x21,
  33803. 0x10,
  33804. 0xff,
  33805. 0xf3,
  33806. 0xd2,
  33807. 0xcd,
  33808. 0x0c,
  33809. 0x13,
  33810. 0xec,
  33811. 0x5f,
  33812. 0x97,
  33813. 0x44,
  33814. 0x17,
  33815. 0xc4,
  33816. 0xa7,
  33817. 0x7e,
  33818. 0x3d,
  33819. 0x64,
  33820. 0x5d,
  33821. 0x19,
  33822. 0x73,
  33823. 0x60,
  33824. 0x81,
  33825. 0x4f,
  33826. 0xdc,
  33827. 0x22,
  33828. 0x2a,
  33829. 0x90,
  33830. 0x88,
  33831. 0x46,
  33832. 0xee,
  33833. 0xb8,
  33834. 0x14,
  33835. 0xde,
  33836. 0x5e,
  33837. 0x0b,
  33838. 0xdb,
  33839. 0xe0,
  33840. 0x32,
  33841. 0x3a,
  33842. 0x0a,
  33843. 0x49,
  33844. 0x06,
  33845. 0x24,
  33846. 0x5c,
  33847. 0xc2,
  33848. 0xd3,
  33849. 0xac,
  33850. 0x62,
  33851. 0x91,
  33852. 0x95,
  33853. 0xe4,
  33854. 0x79,
  33855. 0xe7,
  33856. 0xc8,
  33857. 0x37,
  33858. 0x6d,
  33859. 0x8d,
  33860. 0xd5,
  33861. 0x4e,
  33862. 0xa9,
  33863. 0x6c,
  33864. 0x56,
  33865. 0xf4,
  33866. 0xea,
  33867. 0x65,
  33868. 0x7a,
  33869. 0xae,
  33870. 0x08,
  33871. 0xba,
  33872. 0x78,
  33873. 0x25,
  33874. 0x2e,
  33875. 0x1c,
  33876. 0xa6,
  33877. 0xb4,
  33878. 0xc6,
  33879. 0xe8,
  33880. 0xdd,
  33881. 0x74,
  33882. 0x1f,
  33883. 0x4b,
  33884. 0xbd,
  33885. 0x8b,
  33886. 0x8a,
  33887. 0x70,
  33888. 0x3e,
  33889. 0xb5,
  33890. 0x66,
  33891. 0x48,
  33892. 0x03,
  33893. 0xf6,
  33894. 0x0e,
  33895. 0x61,
  33896. 0x35,
  33897. 0x57,
  33898. 0xb9,
  33899. 0x86,
  33900. 0xc1,
  33901. 0x1d,
  33902. 0x9e,
  33903. 0xe1,
  33904. 0xf8,
  33905. 0x98,
  33906. 0x11,
  33907. 0x69,
  33908. 0xd9,
  33909. 0x8e,
  33910. 0x94,
  33911. 0x9b,
  33912. 0x1e,
  33913. 0x87,
  33914. 0xe9,
  33915. 0xce,
  33916. 0x55,
  33917. 0x28,
  33918. 0xdf,
  33919. 0x8c,
  33920. 0xa1,
  33921. 0x89,
  33922. 0x0d,
  33923. 0xbf,
  33924. 0xe6,
  33925. 0x42,
  33926. 0x68,
  33927. 0x41,
  33928. 0x99,
  33929. 0x2d,
  33930. 0x0f,
  33931. 0xb0,
  33932. 0x54,
  33933. 0xbb,
  33934. 0x16
  33935. ]);
  33936. var inv_s = new Uint8Array([
  33937. 0x52,
  33938. 0x09,
  33939. 0x6a,
  33940. 0xd5,
  33941. 0x30,
  33942. 0x36,
  33943. 0xa5,
  33944. 0x38,
  33945. 0xbf,
  33946. 0x40,
  33947. 0xa3,
  33948. 0x9e,
  33949. 0x81,
  33950. 0xf3,
  33951. 0xd7,
  33952. 0xfb,
  33953. 0x7c,
  33954. 0xe3,
  33955. 0x39,
  33956. 0x82,
  33957. 0x9b,
  33958. 0x2f,
  33959. 0xff,
  33960. 0x87,
  33961. 0x34,
  33962. 0x8e,
  33963. 0x43,
  33964. 0x44,
  33965. 0xc4,
  33966. 0xde,
  33967. 0xe9,
  33968. 0xcb,
  33969. 0x54,
  33970. 0x7b,
  33971. 0x94,
  33972. 0x32,
  33973. 0xa6,
  33974. 0xc2,
  33975. 0x23,
  33976. 0x3d,
  33977. 0xee,
  33978. 0x4c,
  33979. 0x95,
  33980. 0x0b,
  33981. 0x42,
  33982. 0xfa,
  33983. 0xc3,
  33984. 0x4e,
  33985. 0x08,
  33986. 0x2e,
  33987. 0xa1,
  33988. 0x66,
  33989. 0x28,
  33990. 0xd9,
  33991. 0x24,
  33992. 0xb2,
  33993. 0x76,
  33994. 0x5b,
  33995. 0xa2,
  33996. 0x49,
  33997. 0x6d,
  33998. 0x8b,
  33999. 0xd1,
  34000. 0x25,
  34001. 0x72,
  34002. 0xf8,
  34003. 0xf6,
  34004. 0x64,
  34005. 0x86,
  34006. 0x68,
  34007. 0x98,
  34008. 0x16,
  34009. 0xd4,
  34010. 0xa4,
  34011. 0x5c,
  34012. 0xcc,
  34013. 0x5d,
  34014. 0x65,
  34015. 0xb6,
  34016. 0x92,
  34017. 0x6c,
  34018. 0x70,
  34019. 0x48,
  34020. 0x50,
  34021. 0xfd,
  34022. 0xed,
  34023. 0xb9,
  34024. 0xda,
  34025. 0x5e,
  34026. 0x15,
  34027. 0x46,
  34028. 0x57,
  34029. 0xa7,
  34030. 0x8d,
  34031. 0x9d,
  34032. 0x84,
  34033. 0x90,
  34034. 0xd8,
  34035. 0xab,
  34036. 0x00,
  34037. 0x8c,
  34038. 0xbc,
  34039. 0xd3,
  34040. 0x0a,
  34041. 0xf7,
  34042. 0xe4,
  34043. 0x58,
  34044. 0x05,
  34045. 0xb8,
  34046. 0xb3,
  34047. 0x45,
  34048. 0x06,
  34049. 0xd0,
  34050. 0x2c,
  34051. 0x1e,
  34052. 0x8f,
  34053. 0xca,
  34054. 0x3f,
  34055. 0x0f,
  34056. 0x02,
  34057. 0xc1,
  34058. 0xaf,
  34059. 0xbd,
  34060. 0x03,
  34061. 0x01,
  34062. 0x13,
  34063. 0x8a,
  34064. 0x6b,
  34065. 0x3a,
  34066. 0x91,
  34067. 0x11,
  34068. 0x41,
  34069. 0x4f,
  34070. 0x67,
  34071. 0xdc,
  34072. 0xea,
  34073. 0x97,
  34074. 0xf2,
  34075. 0xcf,
  34076. 0xce,
  34077. 0xf0,
  34078. 0xb4,
  34079. 0xe6,
  34080. 0x73,
  34081. 0x96,
  34082. 0xac,
  34083. 0x74,
  34084. 0x22,
  34085. 0xe7,
  34086. 0xad,
  34087. 0x35,
  34088. 0x85,
  34089. 0xe2,
  34090. 0xf9,
  34091. 0x37,
  34092. 0xe8,
  34093. 0x1c,
  34094. 0x75,
  34095. 0xdf,
  34096. 0x6e,
  34097. 0x47,
  34098. 0xf1,
  34099. 0x1a,
  34100. 0x71,
  34101. 0x1d,
  34102. 0x29,
  34103. 0xc5,
  34104. 0x89,
  34105. 0x6f,
  34106. 0xb7,
  34107. 0x62,
  34108. 0x0e,
  34109. 0xaa,
  34110. 0x18,
  34111. 0xbe,
  34112. 0x1b,
  34113. 0xfc,
  34114. 0x56,
  34115. 0x3e,
  34116. 0x4b,
  34117. 0xc6,
  34118. 0xd2,
  34119. 0x79,
  34120. 0x20,
  34121. 0x9a,
  34122. 0xdb,
  34123. 0xc0,
  34124. 0xfe,
  34125. 0x78,
  34126. 0xcd,
  34127. 0x5a,
  34128. 0xf4,
  34129. 0x1f,
  34130. 0xdd,
  34131. 0xa8,
  34132. 0x33,
  34133. 0x88,
  34134. 0x07,
  34135. 0xc7,
  34136. 0x31,
  34137. 0xb1,
  34138. 0x12,
  34139. 0x10,
  34140. 0x59,
  34141. 0x27,
  34142. 0x80,
  34143. 0xec,
  34144. 0x5f,
  34145. 0x60,
  34146. 0x51,
  34147. 0x7f,
  34148. 0xa9,
  34149. 0x19,
  34150. 0xb5,
  34151. 0x4a,
  34152. 0x0d,
  34153. 0x2d,
  34154. 0xe5,
  34155. 0x7a,
  34156. 0x9f,
  34157. 0x93,
  34158. 0xc9,
  34159. 0x9c,
  34160. 0xef,
  34161. 0xa0,
  34162. 0xe0,
  34163. 0x3b,
  34164. 0x4d,
  34165. 0xae,
  34166. 0x2a,
  34167. 0xf5,
  34168. 0xb0,
  34169. 0xc8,
  34170. 0xeb,
  34171. 0xbb,
  34172. 0x3c,
  34173. 0x83,
  34174. 0x53,
  34175. 0x99,
  34176. 0x61,
  34177. 0x17,
  34178. 0x2b,
  34179. 0x04,
  34180. 0x7e,
  34181. 0xba,
  34182. 0x77,
  34183. 0xd6,
  34184. 0x26,
  34185. 0xe1,
  34186. 0x69,
  34187. 0x14,
  34188. 0x63,
  34189. 0x55,
  34190. 0x21,
  34191. 0x0c,
  34192. 0x7d
  34193. ]);
  34194. var mixCol = new Uint8Array(256);
  34195. for (var i = 0; i < 256; i++) {
  34196. if (i < 128) {
  34197. mixCol[i] = i << 1;
  34198. } else {
  34199. mixCol[i] = i << 1 ^ 0x1b;
  34200. }
  34201. }
  34202. var mix = new Uint32Array([
  34203. 0x00000000,
  34204. 0x0e090d0b,
  34205. 0x1c121a16,
  34206. 0x121b171d,
  34207. 0x3824342c,
  34208. 0x362d3927,
  34209. 0x24362e3a,
  34210. 0x2a3f2331,
  34211. 0x70486858,
  34212. 0x7e416553,
  34213. 0x6c5a724e,
  34214. 0x62537f45,
  34215. 0x486c5c74,
  34216. 0x4665517f,
  34217. 0x547e4662,
  34218. 0x5a774b69,
  34219. 0xe090d0b0,
  34220. 0xee99ddbb,
  34221. 0xfc82caa6,
  34222. 0xf28bc7ad,
  34223. 0xd8b4e49c,
  34224. 0xd6bde997,
  34225. 0xc4a6fe8a,
  34226. 0xcaaff381,
  34227. 0x90d8b8e8,
  34228. 0x9ed1b5e3,
  34229. 0x8ccaa2fe,
  34230. 0x82c3aff5,
  34231. 0xa8fc8cc4,
  34232. 0xa6f581cf,
  34233. 0xb4ee96d2,
  34234. 0xbae79bd9,
  34235. 0xdb3bbb7b,
  34236. 0xd532b670,
  34237. 0xc729a16d,
  34238. 0xc920ac66,
  34239. 0xe31f8f57,
  34240. 0xed16825c,
  34241. 0xff0d9541,
  34242. 0xf104984a,
  34243. 0xab73d323,
  34244. 0xa57ade28,
  34245. 0xb761c935,
  34246. 0xb968c43e,
  34247. 0x9357e70f,
  34248. 0x9d5eea04,
  34249. 0x8f45fd19,
  34250. 0x814cf012,
  34251. 0x3bab6bcb,
  34252. 0x35a266c0,
  34253. 0x27b971dd,
  34254. 0x29b07cd6,
  34255. 0x038f5fe7,
  34256. 0x0d8652ec,
  34257. 0x1f9d45f1,
  34258. 0x119448fa,
  34259. 0x4be30393,
  34260. 0x45ea0e98,
  34261. 0x57f11985,
  34262. 0x59f8148e,
  34263. 0x73c737bf,
  34264. 0x7dce3ab4,
  34265. 0x6fd52da9,
  34266. 0x61dc20a2,
  34267. 0xad766df6,
  34268. 0xa37f60fd,
  34269. 0xb16477e0,
  34270. 0xbf6d7aeb,
  34271. 0x955259da,
  34272. 0x9b5b54d1,
  34273. 0x894043cc,
  34274. 0x87494ec7,
  34275. 0xdd3e05ae,
  34276. 0xd33708a5,
  34277. 0xc12c1fb8,
  34278. 0xcf2512b3,
  34279. 0xe51a3182,
  34280. 0xeb133c89,
  34281. 0xf9082b94,
  34282. 0xf701269f,
  34283. 0x4de6bd46,
  34284. 0x43efb04d,
  34285. 0x51f4a750,
  34286. 0x5ffdaa5b,
  34287. 0x75c2896a,
  34288. 0x7bcb8461,
  34289. 0x69d0937c,
  34290. 0x67d99e77,
  34291. 0x3daed51e,
  34292. 0x33a7d815,
  34293. 0x21bccf08,
  34294. 0x2fb5c203,
  34295. 0x058ae132,
  34296. 0x0b83ec39,
  34297. 0x1998fb24,
  34298. 0x1791f62f,
  34299. 0x764dd68d,
  34300. 0x7844db86,
  34301. 0x6a5fcc9b,
  34302. 0x6456c190,
  34303. 0x4e69e2a1,
  34304. 0x4060efaa,
  34305. 0x527bf8b7,
  34306. 0x5c72f5bc,
  34307. 0x0605bed5,
  34308. 0x080cb3de,
  34309. 0x1a17a4c3,
  34310. 0x141ea9c8,
  34311. 0x3e218af9,
  34312. 0x302887f2,
  34313. 0x223390ef,
  34314. 0x2c3a9de4,
  34315. 0x96dd063d,
  34316. 0x98d40b36,
  34317. 0x8acf1c2b,
  34318. 0x84c61120,
  34319. 0xaef93211,
  34320. 0xa0f03f1a,
  34321. 0xb2eb2807,
  34322. 0xbce2250c,
  34323. 0xe6956e65,
  34324. 0xe89c636e,
  34325. 0xfa877473,
  34326. 0xf48e7978,
  34327. 0xdeb15a49,
  34328. 0xd0b85742,
  34329. 0xc2a3405f,
  34330. 0xccaa4d54,
  34331. 0x41ecdaf7,
  34332. 0x4fe5d7fc,
  34333. 0x5dfec0e1,
  34334. 0x53f7cdea,
  34335. 0x79c8eedb,
  34336. 0x77c1e3d0,
  34337. 0x65daf4cd,
  34338. 0x6bd3f9c6,
  34339. 0x31a4b2af,
  34340. 0x3fadbfa4,
  34341. 0x2db6a8b9,
  34342. 0x23bfa5b2,
  34343. 0x09808683,
  34344. 0x07898b88,
  34345. 0x15929c95,
  34346. 0x1b9b919e,
  34347. 0xa17c0a47,
  34348. 0xaf75074c,
  34349. 0xbd6e1051,
  34350. 0xb3671d5a,
  34351. 0x99583e6b,
  34352. 0x97513360,
  34353. 0x854a247d,
  34354. 0x8b432976,
  34355. 0xd134621f,
  34356. 0xdf3d6f14,
  34357. 0xcd267809,
  34358. 0xc32f7502,
  34359. 0xe9105633,
  34360. 0xe7195b38,
  34361. 0xf5024c25,
  34362. 0xfb0b412e,
  34363. 0x9ad7618c,
  34364. 0x94de6c87,
  34365. 0x86c57b9a,
  34366. 0x88cc7691,
  34367. 0xa2f355a0,
  34368. 0xacfa58ab,
  34369. 0xbee14fb6,
  34370. 0xb0e842bd,
  34371. 0xea9f09d4,
  34372. 0xe49604df,
  34373. 0xf68d13c2,
  34374. 0xf8841ec9,
  34375. 0xd2bb3df8,
  34376. 0xdcb230f3,
  34377. 0xcea927ee,
  34378. 0xc0a02ae5,
  34379. 0x7a47b13c,
  34380. 0x744ebc37,
  34381. 0x6655ab2a,
  34382. 0x685ca621,
  34383. 0x42638510,
  34384. 0x4c6a881b,
  34385. 0x5e719f06,
  34386. 0x5078920d,
  34387. 0x0a0fd964,
  34388. 0x0406d46f,
  34389. 0x161dc372,
  34390. 0x1814ce79,
  34391. 0x322bed48,
  34392. 0x3c22e043,
  34393. 0x2e39f75e,
  34394. 0x2030fa55,
  34395. 0xec9ab701,
  34396. 0xe293ba0a,
  34397. 0xf088ad17,
  34398. 0xfe81a01c,
  34399. 0xd4be832d,
  34400. 0xdab78e26,
  34401. 0xc8ac993b,
  34402. 0xc6a59430,
  34403. 0x9cd2df59,
  34404. 0x92dbd252,
  34405. 0x80c0c54f,
  34406. 0x8ec9c844,
  34407. 0xa4f6eb75,
  34408. 0xaaffe67e,
  34409. 0xb8e4f163,
  34410. 0xb6edfc68,
  34411. 0x0c0a67b1,
  34412. 0x02036aba,
  34413. 0x10187da7,
  34414. 0x1e1170ac,
  34415. 0x342e539d,
  34416. 0x3a275e96,
  34417. 0x283c498b,
  34418. 0x26354480,
  34419. 0x7c420fe9,
  34420. 0x724b02e2,
  34421. 0x605015ff,
  34422. 0x6e5918f4,
  34423. 0x44663bc5,
  34424. 0x4a6f36ce,
  34425. 0x587421d3,
  34426. 0x567d2cd8,
  34427. 0x37a10c7a,
  34428. 0x39a80171,
  34429. 0x2bb3166c,
  34430. 0x25ba1b67,
  34431. 0x0f853856,
  34432. 0x018c355d,
  34433. 0x13972240,
  34434. 0x1d9e2f4b,
  34435. 0x47e96422,
  34436. 0x49e06929,
  34437. 0x5bfb7e34,
  34438. 0x55f2733f,
  34439. 0x7fcd500e,
  34440. 0x71c45d05,
  34441. 0x63df4a18,
  34442. 0x6dd64713,
  34443. 0xd731dcca,
  34444. 0xd938d1c1,
  34445. 0xcb23c6dc,
  34446. 0xc52acbd7,
  34447. 0xef15e8e6,
  34448. 0xe11ce5ed,
  34449. 0xf307f2f0,
  34450. 0xfd0efffb,
  34451. 0xa779b492,
  34452. 0xa970b999,
  34453. 0xbb6bae84,
  34454. 0xb562a38f,
  34455. 0x9f5d80be,
  34456. 0x91548db5,
  34457. 0x834f9aa8,
  34458. 0x8d4697a3
  34459. ]);
  34460. function expandKey128(cipherKey) {
  34461. var b = 176, result = new Uint8Array(b);
  34462. result.set(cipherKey);
  34463. for (var j = 16, i = 1; j < b; ++i) {
  34464. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  34465. t1 = s[t1];
  34466. t2 = s[t2];
  34467. t3 = s[t3];
  34468. t4 = s[t4];
  34469. t1 = t1 ^ rcon[i];
  34470. for (var n = 0; n < 4; ++n) {
  34471. result[j] = t1 ^= result[j - 16];
  34472. j++;
  34473. result[j] = t2 ^= result[j - 16];
  34474. j++;
  34475. result[j] = t3 ^= result[j - 16];
  34476. j++;
  34477. result[j] = t4 ^= result[j - 16];
  34478. j++;
  34479. }
  34480. }
  34481. return result;
  34482. }
  34483. function decrypt128(input, key) {
  34484. var state = new Uint8Array(16);
  34485. state.set(input);
  34486. var i, j, k;
  34487. var t, u, v;
  34488. for (j = 0, k = 160; j < 16; ++j, ++k) {
  34489. state[j] ^= key[k];
  34490. }
  34491. for (i = 9; i >= 1; --i) {
  34492. t = state[13];
  34493. state[13] = state[9];
  34494. state[9] = state[5];
  34495. state[5] = state[1];
  34496. state[1] = t;
  34497. t = state[14];
  34498. u = state[10];
  34499. state[14] = state[6];
  34500. state[10] = state[2];
  34501. state[6] = t;
  34502. state[2] = u;
  34503. t = state[15];
  34504. u = state[11];
  34505. v = state[7];
  34506. state[15] = state[3];
  34507. state[11] = t;
  34508. state[7] = u;
  34509. state[3] = v;
  34510. for (j = 0; j < 16; ++j) {
  34511. state[j] = inv_s[state[j]];
  34512. }
  34513. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  34514. state[j] ^= key[k];
  34515. }
  34516. for (j = 0; j < 16; j += 4) {
  34517. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  34518. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  34519. state[j] = t >>> 24 & 0xFF;
  34520. state[j + 1] = t >> 16 & 0xFF;
  34521. state[j + 2] = t >> 8 & 0xFF;
  34522. state[j + 3] = t & 0xFF;
  34523. }
  34524. }
  34525. t = state[13];
  34526. state[13] = state[9];
  34527. state[9] = state[5];
  34528. state[5] = state[1];
  34529. state[1] = t;
  34530. t = state[14];
  34531. u = state[10];
  34532. state[14] = state[6];
  34533. state[10] = state[2];
  34534. state[6] = t;
  34535. state[2] = u;
  34536. t = state[15];
  34537. u = state[11];
  34538. v = state[7];
  34539. state[15] = state[3];
  34540. state[11] = t;
  34541. state[7] = u;
  34542. state[3] = v;
  34543. for (j = 0; j < 16; ++j) {
  34544. state[j] = inv_s[state[j]];
  34545. state[j] ^= key[j];
  34546. }
  34547. return state;
  34548. }
  34549. function encrypt128(input, key) {
  34550. var t, u, v, k;
  34551. var state = new Uint8Array(16);
  34552. state.set(input);
  34553. for (j = 0; j < 16; ++j) {
  34554. state[j] ^= key[j];
  34555. }
  34556. for (i = 1; i < 10; i++) {
  34557. for (j = 0; j < 16; ++j) {
  34558. state[j] = s[state[j]];
  34559. }
  34560. v = state[1];
  34561. state[1] = state[5];
  34562. state[5] = state[9];
  34563. state[9] = state[13];
  34564. state[13] = v;
  34565. v = state[2];
  34566. u = state[6];
  34567. state[2] = state[10];
  34568. state[6] = state[14];
  34569. state[10] = v;
  34570. state[14] = u;
  34571. v = state[3];
  34572. u = state[7];
  34573. t = state[11];
  34574. state[3] = state[15];
  34575. state[7] = v;
  34576. state[11] = u;
  34577. state[15] = t;
  34578. for (var j = 0; j < 16; j += 4) {
  34579. var s0 = state[j + 0], s1 = state[j + 1];
  34580. var s2 = state[j + 2], s3 = state[j + 3];
  34581. t = s0 ^ s1 ^ s2 ^ s3;
  34582. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  34583. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  34584. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  34585. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  34586. }
  34587. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  34588. state[j] ^= key[k];
  34589. }
  34590. }
  34591. for (j = 0; j < 16; ++j) {
  34592. state[j] = s[state[j]];
  34593. }
  34594. v = state[1];
  34595. state[1] = state[5];
  34596. state[5] = state[9];
  34597. state[9] = state[13];
  34598. state[13] = v;
  34599. v = state[2];
  34600. u = state[6];
  34601. state[2] = state[10];
  34602. state[6] = state[14];
  34603. state[10] = v;
  34604. state[14] = u;
  34605. v = state[3];
  34606. u = state[7];
  34607. t = state[11];
  34608. state[3] = state[15];
  34609. state[7] = v;
  34610. state[11] = u;
  34611. state[15] = t;
  34612. for (j = 0, k = 160; j < 16; ++j, ++k) {
  34613. state[j] ^= key[k];
  34614. }
  34615. return state;
  34616. }
  34617. function AES128Cipher(key) {
  34618. this.key = expandKey128(key);
  34619. this.buffer = new Uint8Array(16);
  34620. this.bufferPosition = 0;
  34621. }
  34622. function decryptBlock2(data, finalize) {
  34623. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  34624. for (i = 0; i < sourceLength; ++i) {
  34625. buffer[bufferLength] = data[i];
  34626. ++bufferLength;
  34627. if (bufferLength < 16) {
  34628. continue;
  34629. }
  34630. var plain = decrypt128(buffer, this.key);
  34631. for (j = 0; j < 16; ++j) {
  34632. plain[j] ^= iv[j];
  34633. }
  34634. iv = buffer;
  34635. result.push(plain);
  34636. buffer = new Uint8Array(16);
  34637. bufferLength = 0;
  34638. }
  34639. this.buffer = buffer;
  34640. this.bufferLength = bufferLength;
  34641. this.iv = iv;
  34642. if (result.length === 0) {
  34643. return new Uint8Array([]);
  34644. }
  34645. var outputLength = 16 * result.length;
  34646. if (finalize) {
  34647. var lastBlock = result[result.length - 1];
  34648. var psLen = lastBlock[15];
  34649. if (psLen <= 16) {
  34650. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  34651. if (lastBlock[i] !== psLen) {
  34652. psLen = 0;
  34653. break;
  34654. }
  34655. }
  34656. outputLength -= psLen;
  34657. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  34658. }
  34659. }
  34660. var output = new Uint8Array(outputLength);
  34661. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  34662. output.set(result[i], j);
  34663. }
  34664. return output;
  34665. }
  34666. AES128Cipher.prototype = {
  34667. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  34668. var i, sourceLength = data.length;
  34669. var buffer = this.buffer, bufferLength = this.bufferPosition;
  34670. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  34671. buffer[bufferLength] = data[i];
  34672. }
  34673. if (bufferLength < 16) {
  34674. this.bufferLength = bufferLength;
  34675. return new Uint8Array([]);
  34676. }
  34677. this.iv = buffer;
  34678. this.buffer = new Uint8Array(16);
  34679. this.bufferLength = 0;
  34680. this.decryptBlock = decryptBlock2;
  34681. return this.decryptBlock(data.subarray(16), finalize);
  34682. },
  34683. encrypt: function AES128Cipher_encrypt(data, iv) {
  34684. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  34685. if (!iv) {
  34686. iv = new Uint8Array(16);
  34687. }
  34688. for (i = 0; i < sourceLength; ++i) {
  34689. buffer[bufferLength] = data[i];
  34690. ++bufferLength;
  34691. if (bufferLength < 16) {
  34692. continue;
  34693. }
  34694. for (j = 0; j < 16; ++j) {
  34695. buffer[j] ^= iv[j];
  34696. }
  34697. var cipher = encrypt128(buffer, this.key);
  34698. iv = cipher;
  34699. result.push(cipher);
  34700. buffer = new Uint8Array(16);
  34701. bufferLength = 0;
  34702. }
  34703. this.buffer = buffer;
  34704. this.bufferLength = bufferLength;
  34705. this.iv = iv;
  34706. if (result.length === 0) {
  34707. return new Uint8Array([]);
  34708. }
  34709. var outputLength = 16 * result.length;
  34710. var output = new Uint8Array(outputLength);
  34711. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  34712. output.set(result[i], j);
  34713. }
  34714. return output;
  34715. }
  34716. };
  34717. return AES128Cipher;
  34718. }();
  34719. var AES256Cipher = function AES256CipherClosure() {
  34720. var rcon = new Uint8Array([
  34721. 0x8d,
  34722. 0x01,
  34723. 0x02,
  34724. 0x04,
  34725. 0x08,
  34726. 0x10,
  34727. 0x20,
  34728. 0x40,
  34729. 0x80,
  34730. 0x1b,
  34731. 0x36,
  34732. 0x6c,
  34733. 0xd8,
  34734. 0xab,
  34735. 0x4d,
  34736. 0x9a,
  34737. 0x2f,
  34738. 0x5e,
  34739. 0xbc,
  34740. 0x63,
  34741. 0xc6,
  34742. 0x97,
  34743. 0x35,
  34744. 0x6a,
  34745. 0xd4,
  34746. 0xb3,
  34747. 0x7d,
  34748. 0xfa,
  34749. 0xef,
  34750. 0xc5,
  34751. 0x91,
  34752. 0x39,
  34753. 0x72,
  34754. 0xe4,
  34755. 0xd3,
  34756. 0xbd,
  34757. 0x61,
  34758. 0xc2,
  34759. 0x9f,
  34760. 0x25,
  34761. 0x4a,
  34762. 0x94,
  34763. 0x33,
  34764. 0x66,
  34765. 0xcc,
  34766. 0x83,
  34767. 0x1d,
  34768. 0x3a,
  34769. 0x74,
  34770. 0xe8,
  34771. 0xcb,
  34772. 0x8d,
  34773. 0x01,
  34774. 0x02,
  34775. 0x04,
  34776. 0x08,
  34777. 0x10,
  34778. 0x20,
  34779. 0x40,
  34780. 0x80,
  34781. 0x1b,
  34782. 0x36,
  34783. 0x6c,
  34784. 0xd8,
  34785. 0xab,
  34786. 0x4d,
  34787. 0x9a,
  34788. 0x2f,
  34789. 0x5e,
  34790. 0xbc,
  34791. 0x63,
  34792. 0xc6,
  34793. 0x97,
  34794. 0x35,
  34795. 0x6a,
  34796. 0xd4,
  34797. 0xb3,
  34798. 0x7d,
  34799. 0xfa,
  34800. 0xef,
  34801. 0xc5,
  34802. 0x91,
  34803. 0x39,
  34804. 0x72,
  34805. 0xe4,
  34806. 0xd3,
  34807. 0xbd,
  34808. 0x61,
  34809. 0xc2,
  34810. 0x9f,
  34811. 0x25,
  34812. 0x4a,
  34813. 0x94,
  34814. 0x33,
  34815. 0x66,
  34816. 0xcc,
  34817. 0x83,
  34818. 0x1d,
  34819. 0x3a,
  34820. 0x74,
  34821. 0xe8,
  34822. 0xcb,
  34823. 0x8d,
  34824. 0x01,
  34825. 0x02,
  34826. 0x04,
  34827. 0x08,
  34828. 0x10,
  34829. 0x20,
  34830. 0x40,
  34831. 0x80,
  34832. 0x1b,
  34833. 0x36,
  34834. 0x6c,
  34835. 0xd8,
  34836. 0xab,
  34837. 0x4d,
  34838. 0x9a,
  34839. 0x2f,
  34840. 0x5e,
  34841. 0xbc,
  34842. 0x63,
  34843. 0xc6,
  34844. 0x97,
  34845. 0x35,
  34846. 0x6a,
  34847. 0xd4,
  34848. 0xb3,
  34849. 0x7d,
  34850. 0xfa,
  34851. 0xef,
  34852. 0xc5,
  34853. 0x91,
  34854. 0x39,
  34855. 0x72,
  34856. 0xe4,
  34857. 0xd3,
  34858. 0xbd,
  34859. 0x61,
  34860. 0xc2,
  34861. 0x9f,
  34862. 0x25,
  34863. 0x4a,
  34864. 0x94,
  34865. 0x33,
  34866. 0x66,
  34867. 0xcc,
  34868. 0x83,
  34869. 0x1d,
  34870. 0x3a,
  34871. 0x74,
  34872. 0xe8,
  34873. 0xcb,
  34874. 0x8d,
  34875. 0x01,
  34876. 0x02,
  34877. 0x04,
  34878. 0x08,
  34879. 0x10,
  34880. 0x20,
  34881. 0x40,
  34882. 0x80,
  34883. 0x1b,
  34884. 0x36,
  34885. 0x6c,
  34886. 0xd8,
  34887. 0xab,
  34888. 0x4d,
  34889. 0x9a,
  34890. 0x2f,
  34891. 0x5e,
  34892. 0xbc,
  34893. 0x63,
  34894. 0xc6,
  34895. 0x97,
  34896. 0x35,
  34897. 0x6a,
  34898. 0xd4,
  34899. 0xb3,
  34900. 0x7d,
  34901. 0xfa,
  34902. 0xef,
  34903. 0xc5,
  34904. 0x91,
  34905. 0x39,
  34906. 0x72,
  34907. 0xe4,
  34908. 0xd3,
  34909. 0xbd,
  34910. 0x61,
  34911. 0xc2,
  34912. 0x9f,
  34913. 0x25,
  34914. 0x4a,
  34915. 0x94,
  34916. 0x33,
  34917. 0x66,
  34918. 0xcc,
  34919. 0x83,
  34920. 0x1d,
  34921. 0x3a,
  34922. 0x74,
  34923. 0xe8,
  34924. 0xcb,
  34925. 0x8d,
  34926. 0x01,
  34927. 0x02,
  34928. 0x04,
  34929. 0x08,
  34930. 0x10,
  34931. 0x20,
  34932. 0x40,
  34933. 0x80,
  34934. 0x1b,
  34935. 0x36,
  34936. 0x6c,
  34937. 0xd8,
  34938. 0xab,
  34939. 0x4d,
  34940. 0x9a,
  34941. 0x2f,
  34942. 0x5e,
  34943. 0xbc,
  34944. 0x63,
  34945. 0xc6,
  34946. 0x97,
  34947. 0x35,
  34948. 0x6a,
  34949. 0xd4,
  34950. 0xb3,
  34951. 0x7d,
  34952. 0xfa,
  34953. 0xef,
  34954. 0xc5,
  34955. 0x91,
  34956. 0x39,
  34957. 0x72,
  34958. 0xe4,
  34959. 0xd3,
  34960. 0xbd,
  34961. 0x61,
  34962. 0xc2,
  34963. 0x9f,
  34964. 0x25,
  34965. 0x4a,
  34966. 0x94,
  34967. 0x33,
  34968. 0x66,
  34969. 0xcc,
  34970. 0x83,
  34971. 0x1d,
  34972. 0x3a,
  34973. 0x74,
  34974. 0xe8,
  34975. 0xcb,
  34976. 0x8d
  34977. ]);
  34978. var s = new Uint8Array([
  34979. 0x63,
  34980. 0x7c,
  34981. 0x77,
  34982. 0x7b,
  34983. 0xf2,
  34984. 0x6b,
  34985. 0x6f,
  34986. 0xc5,
  34987. 0x30,
  34988. 0x01,
  34989. 0x67,
  34990. 0x2b,
  34991. 0xfe,
  34992. 0xd7,
  34993. 0xab,
  34994. 0x76,
  34995. 0xca,
  34996. 0x82,
  34997. 0xc9,
  34998. 0x7d,
  34999. 0xfa,
  35000. 0x59,
  35001. 0x47,
  35002. 0xf0,
  35003. 0xad,
  35004. 0xd4,
  35005. 0xa2,
  35006. 0xaf,
  35007. 0x9c,
  35008. 0xa4,
  35009. 0x72,
  35010. 0xc0,
  35011. 0xb7,
  35012. 0xfd,
  35013. 0x93,
  35014. 0x26,
  35015. 0x36,
  35016. 0x3f,
  35017. 0xf7,
  35018. 0xcc,
  35019. 0x34,
  35020. 0xa5,
  35021. 0xe5,
  35022. 0xf1,
  35023. 0x71,
  35024. 0xd8,
  35025. 0x31,
  35026. 0x15,
  35027. 0x04,
  35028. 0xc7,
  35029. 0x23,
  35030. 0xc3,
  35031. 0x18,
  35032. 0x96,
  35033. 0x05,
  35034. 0x9a,
  35035. 0x07,
  35036. 0x12,
  35037. 0x80,
  35038. 0xe2,
  35039. 0xeb,
  35040. 0x27,
  35041. 0xb2,
  35042. 0x75,
  35043. 0x09,
  35044. 0x83,
  35045. 0x2c,
  35046. 0x1a,
  35047. 0x1b,
  35048. 0x6e,
  35049. 0x5a,
  35050. 0xa0,
  35051. 0x52,
  35052. 0x3b,
  35053. 0xd6,
  35054. 0xb3,
  35055. 0x29,
  35056. 0xe3,
  35057. 0x2f,
  35058. 0x84,
  35059. 0x53,
  35060. 0xd1,
  35061. 0x00,
  35062. 0xed,
  35063. 0x20,
  35064. 0xfc,
  35065. 0xb1,
  35066. 0x5b,
  35067. 0x6a,
  35068. 0xcb,
  35069. 0xbe,
  35070. 0x39,
  35071. 0x4a,
  35072. 0x4c,
  35073. 0x58,
  35074. 0xcf,
  35075. 0xd0,
  35076. 0xef,
  35077. 0xaa,
  35078. 0xfb,
  35079. 0x43,
  35080. 0x4d,
  35081. 0x33,
  35082. 0x85,
  35083. 0x45,
  35084. 0xf9,
  35085. 0x02,
  35086. 0x7f,
  35087. 0x50,
  35088. 0x3c,
  35089. 0x9f,
  35090. 0xa8,
  35091. 0x51,
  35092. 0xa3,
  35093. 0x40,
  35094. 0x8f,
  35095. 0x92,
  35096. 0x9d,
  35097. 0x38,
  35098. 0xf5,
  35099. 0xbc,
  35100. 0xb6,
  35101. 0xda,
  35102. 0x21,
  35103. 0x10,
  35104. 0xff,
  35105. 0xf3,
  35106. 0xd2,
  35107. 0xcd,
  35108. 0x0c,
  35109. 0x13,
  35110. 0xec,
  35111. 0x5f,
  35112. 0x97,
  35113. 0x44,
  35114. 0x17,
  35115. 0xc4,
  35116. 0xa7,
  35117. 0x7e,
  35118. 0x3d,
  35119. 0x64,
  35120. 0x5d,
  35121. 0x19,
  35122. 0x73,
  35123. 0x60,
  35124. 0x81,
  35125. 0x4f,
  35126. 0xdc,
  35127. 0x22,
  35128. 0x2a,
  35129. 0x90,
  35130. 0x88,
  35131. 0x46,
  35132. 0xee,
  35133. 0xb8,
  35134. 0x14,
  35135. 0xde,
  35136. 0x5e,
  35137. 0x0b,
  35138. 0xdb,
  35139. 0xe0,
  35140. 0x32,
  35141. 0x3a,
  35142. 0x0a,
  35143. 0x49,
  35144. 0x06,
  35145. 0x24,
  35146. 0x5c,
  35147. 0xc2,
  35148. 0xd3,
  35149. 0xac,
  35150. 0x62,
  35151. 0x91,
  35152. 0x95,
  35153. 0xe4,
  35154. 0x79,
  35155. 0xe7,
  35156. 0xc8,
  35157. 0x37,
  35158. 0x6d,
  35159. 0x8d,
  35160. 0xd5,
  35161. 0x4e,
  35162. 0xa9,
  35163. 0x6c,
  35164. 0x56,
  35165. 0xf4,
  35166. 0xea,
  35167. 0x65,
  35168. 0x7a,
  35169. 0xae,
  35170. 0x08,
  35171. 0xba,
  35172. 0x78,
  35173. 0x25,
  35174. 0x2e,
  35175. 0x1c,
  35176. 0xa6,
  35177. 0xb4,
  35178. 0xc6,
  35179. 0xe8,
  35180. 0xdd,
  35181. 0x74,
  35182. 0x1f,
  35183. 0x4b,
  35184. 0xbd,
  35185. 0x8b,
  35186. 0x8a,
  35187. 0x70,
  35188. 0x3e,
  35189. 0xb5,
  35190. 0x66,
  35191. 0x48,
  35192. 0x03,
  35193. 0xf6,
  35194. 0x0e,
  35195. 0x61,
  35196. 0x35,
  35197. 0x57,
  35198. 0xb9,
  35199. 0x86,
  35200. 0xc1,
  35201. 0x1d,
  35202. 0x9e,
  35203. 0xe1,
  35204. 0xf8,
  35205. 0x98,
  35206. 0x11,
  35207. 0x69,
  35208. 0xd9,
  35209. 0x8e,
  35210. 0x94,
  35211. 0x9b,
  35212. 0x1e,
  35213. 0x87,
  35214. 0xe9,
  35215. 0xce,
  35216. 0x55,
  35217. 0x28,
  35218. 0xdf,
  35219. 0x8c,
  35220. 0xa1,
  35221. 0x89,
  35222. 0x0d,
  35223. 0xbf,
  35224. 0xe6,
  35225. 0x42,
  35226. 0x68,
  35227. 0x41,
  35228. 0x99,
  35229. 0x2d,
  35230. 0x0f,
  35231. 0xb0,
  35232. 0x54,
  35233. 0xbb,
  35234. 0x16
  35235. ]);
  35236. var inv_s = new Uint8Array([
  35237. 0x52,
  35238. 0x09,
  35239. 0x6a,
  35240. 0xd5,
  35241. 0x30,
  35242. 0x36,
  35243. 0xa5,
  35244. 0x38,
  35245. 0xbf,
  35246. 0x40,
  35247. 0xa3,
  35248. 0x9e,
  35249. 0x81,
  35250. 0xf3,
  35251. 0xd7,
  35252. 0xfb,
  35253. 0x7c,
  35254. 0xe3,
  35255. 0x39,
  35256. 0x82,
  35257. 0x9b,
  35258. 0x2f,
  35259. 0xff,
  35260. 0x87,
  35261. 0x34,
  35262. 0x8e,
  35263. 0x43,
  35264. 0x44,
  35265. 0xc4,
  35266. 0xde,
  35267. 0xe9,
  35268. 0xcb,
  35269. 0x54,
  35270. 0x7b,
  35271. 0x94,
  35272. 0x32,
  35273. 0xa6,
  35274. 0xc2,
  35275. 0x23,
  35276. 0x3d,
  35277. 0xee,
  35278. 0x4c,
  35279. 0x95,
  35280. 0x0b,
  35281. 0x42,
  35282. 0xfa,
  35283. 0xc3,
  35284. 0x4e,
  35285. 0x08,
  35286. 0x2e,
  35287. 0xa1,
  35288. 0x66,
  35289. 0x28,
  35290. 0xd9,
  35291. 0x24,
  35292. 0xb2,
  35293. 0x76,
  35294. 0x5b,
  35295. 0xa2,
  35296. 0x49,
  35297. 0x6d,
  35298. 0x8b,
  35299. 0xd1,
  35300. 0x25,
  35301. 0x72,
  35302. 0xf8,
  35303. 0xf6,
  35304. 0x64,
  35305. 0x86,
  35306. 0x68,
  35307. 0x98,
  35308. 0x16,
  35309. 0xd4,
  35310. 0xa4,
  35311. 0x5c,
  35312. 0xcc,
  35313. 0x5d,
  35314. 0x65,
  35315. 0xb6,
  35316. 0x92,
  35317. 0x6c,
  35318. 0x70,
  35319. 0x48,
  35320. 0x50,
  35321. 0xfd,
  35322. 0xed,
  35323. 0xb9,
  35324. 0xda,
  35325. 0x5e,
  35326. 0x15,
  35327. 0x46,
  35328. 0x57,
  35329. 0xa7,
  35330. 0x8d,
  35331. 0x9d,
  35332. 0x84,
  35333. 0x90,
  35334. 0xd8,
  35335. 0xab,
  35336. 0x00,
  35337. 0x8c,
  35338. 0xbc,
  35339. 0xd3,
  35340. 0x0a,
  35341. 0xf7,
  35342. 0xe4,
  35343. 0x58,
  35344. 0x05,
  35345. 0xb8,
  35346. 0xb3,
  35347. 0x45,
  35348. 0x06,
  35349. 0xd0,
  35350. 0x2c,
  35351. 0x1e,
  35352. 0x8f,
  35353. 0xca,
  35354. 0x3f,
  35355. 0x0f,
  35356. 0x02,
  35357. 0xc1,
  35358. 0xaf,
  35359. 0xbd,
  35360. 0x03,
  35361. 0x01,
  35362. 0x13,
  35363. 0x8a,
  35364. 0x6b,
  35365. 0x3a,
  35366. 0x91,
  35367. 0x11,
  35368. 0x41,
  35369. 0x4f,
  35370. 0x67,
  35371. 0xdc,
  35372. 0xea,
  35373. 0x97,
  35374. 0xf2,
  35375. 0xcf,
  35376. 0xce,
  35377. 0xf0,
  35378. 0xb4,
  35379. 0xe6,
  35380. 0x73,
  35381. 0x96,
  35382. 0xac,
  35383. 0x74,
  35384. 0x22,
  35385. 0xe7,
  35386. 0xad,
  35387. 0x35,
  35388. 0x85,
  35389. 0xe2,
  35390. 0xf9,
  35391. 0x37,
  35392. 0xe8,
  35393. 0x1c,
  35394. 0x75,
  35395. 0xdf,
  35396. 0x6e,
  35397. 0x47,
  35398. 0xf1,
  35399. 0x1a,
  35400. 0x71,
  35401. 0x1d,
  35402. 0x29,
  35403. 0xc5,
  35404. 0x89,
  35405. 0x6f,
  35406. 0xb7,
  35407. 0x62,
  35408. 0x0e,
  35409. 0xaa,
  35410. 0x18,
  35411. 0xbe,
  35412. 0x1b,
  35413. 0xfc,
  35414. 0x56,
  35415. 0x3e,
  35416. 0x4b,
  35417. 0xc6,
  35418. 0xd2,
  35419. 0x79,
  35420. 0x20,
  35421. 0x9a,
  35422. 0xdb,
  35423. 0xc0,
  35424. 0xfe,
  35425. 0x78,
  35426. 0xcd,
  35427. 0x5a,
  35428. 0xf4,
  35429. 0x1f,
  35430. 0xdd,
  35431. 0xa8,
  35432. 0x33,
  35433. 0x88,
  35434. 0x07,
  35435. 0xc7,
  35436. 0x31,
  35437. 0xb1,
  35438. 0x12,
  35439. 0x10,
  35440. 0x59,
  35441. 0x27,
  35442. 0x80,
  35443. 0xec,
  35444. 0x5f,
  35445. 0x60,
  35446. 0x51,
  35447. 0x7f,
  35448. 0xa9,
  35449. 0x19,
  35450. 0xb5,
  35451. 0x4a,
  35452. 0x0d,
  35453. 0x2d,
  35454. 0xe5,
  35455. 0x7a,
  35456. 0x9f,
  35457. 0x93,
  35458. 0xc9,
  35459. 0x9c,
  35460. 0xef,
  35461. 0xa0,
  35462. 0xe0,
  35463. 0x3b,
  35464. 0x4d,
  35465. 0xae,
  35466. 0x2a,
  35467. 0xf5,
  35468. 0xb0,
  35469. 0xc8,
  35470. 0xeb,
  35471. 0xbb,
  35472. 0x3c,
  35473. 0x83,
  35474. 0x53,
  35475. 0x99,
  35476. 0x61,
  35477. 0x17,
  35478. 0x2b,
  35479. 0x04,
  35480. 0x7e,
  35481. 0xba,
  35482. 0x77,
  35483. 0xd6,
  35484. 0x26,
  35485. 0xe1,
  35486. 0x69,
  35487. 0x14,
  35488. 0x63,
  35489. 0x55,
  35490. 0x21,
  35491. 0x0c,
  35492. 0x7d
  35493. ]);
  35494. var mixCol = new Uint8Array(256);
  35495. for (var i = 0; i < 256; i++) {
  35496. if (i < 128) {
  35497. mixCol[i] = i << 1;
  35498. } else {
  35499. mixCol[i] = i << 1 ^ 0x1b;
  35500. }
  35501. }
  35502. var mix = new Uint32Array([
  35503. 0x00000000,
  35504. 0x0e090d0b,
  35505. 0x1c121a16,
  35506. 0x121b171d,
  35507. 0x3824342c,
  35508. 0x362d3927,
  35509. 0x24362e3a,
  35510. 0x2a3f2331,
  35511. 0x70486858,
  35512. 0x7e416553,
  35513. 0x6c5a724e,
  35514. 0x62537f45,
  35515. 0x486c5c74,
  35516. 0x4665517f,
  35517. 0x547e4662,
  35518. 0x5a774b69,
  35519. 0xe090d0b0,
  35520. 0xee99ddbb,
  35521. 0xfc82caa6,
  35522. 0xf28bc7ad,
  35523. 0xd8b4e49c,
  35524. 0xd6bde997,
  35525. 0xc4a6fe8a,
  35526. 0xcaaff381,
  35527. 0x90d8b8e8,
  35528. 0x9ed1b5e3,
  35529. 0x8ccaa2fe,
  35530. 0x82c3aff5,
  35531. 0xa8fc8cc4,
  35532. 0xa6f581cf,
  35533. 0xb4ee96d2,
  35534. 0xbae79bd9,
  35535. 0xdb3bbb7b,
  35536. 0xd532b670,
  35537. 0xc729a16d,
  35538. 0xc920ac66,
  35539. 0xe31f8f57,
  35540. 0xed16825c,
  35541. 0xff0d9541,
  35542. 0xf104984a,
  35543. 0xab73d323,
  35544. 0xa57ade28,
  35545. 0xb761c935,
  35546. 0xb968c43e,
  35547. 0x9357e70f,
  35548. 0x9d5eea04,
  35549. 0x8f45fd19,
  35550. 0x814cf012,
  35551. 0x3bab6bcb,
  35552. 0x35a266c0,
  35553. 0x27b971dd,
  35554. 0x29b07cd6,
  35555. 0x038f5fe7,
  35556. 0x0d8652ec,
  35557. 0x1f9d45f1,
  35558. 0x119448fa,
  35559. 0x4be30393,
  35560. 0x45ea0e98,
  35561. 0x57f11985,
  35562. 0x59f8148e,
  35563. 0x73c737bf,
  35564. 0x7dce3ab4,
  35565. 0x6fd52da9,
  35566. 0x61dc20a2,
  35567. 0xad766df6,
  35568. 0xa37f60fd,
  35569. 0xb16477e0,
  35570. 0xbf6d7aeb,
  35571. 0x955259da,
  35572. 0x9b5b54d1,
  35573. 0x894043cc,
  35574. 0x87494ec7,
  35575. 0xdd3e05ae,
  35576. 0xd33708a5,
  35577. 0xc12c1fb8,
  35578. 0xcf2512b3,
  35579. 0xe51a3182,
  35580. 0xeb133c89,
  35581. 0xf9082b94,
  35582. 0xf701269f,
  35583. 0x4de6bd46,
  35584. 0x43efb04d,
  35585. 0x51f4a750,
  35586. 0x5ffdaa5b,
  35587. 0x75c2896a,
  35588. 0x7bcb8461,
  35589. 0x69d0937c,
  35590. 0x67d99e77,
  35591. 0x3daed51e,
  35592. 0x33a7d815,
  35593. 0x21bccf08,
  35594. 0x2fb5c203,
  35595. 0x058ae132,
  35596. 0x0b83ec39,
  35597. 0x1998fb24,
  35598. 0x1791f62f,
  35599. 0x764dd68d,
  35600. 0x7844db86,
  35601. 0x6a5fcc9b,
  35602. 0x6456c190,
  35603. 0x4e69e2a1,
  35604. 0x4060efaa,
  35605. 0x527bf8b7,
  35606. 0x5c72f5bc,
  35607. 0x0605bed5,
  35608. 0x080cb3de,
  35609. 0x1a17a4c3,
  35610. 0x141ea9c8,
  35611. 0x3e218af9,
  35612. 0x302887f2,
  35613. 0x223390ef,
  35614. 0x2c3a9de4,
  35615. 0x96dd063d,
  35616. 0x98d40b36,
  35617. 0x8acf1c2b,
  35618. 0x84c61120,
  35619. 0xaef93211,
  35620. 0xa0f03f1a,
  35621. 0xb2eb2807,
  35622. 0xbce2250c,
  35623. 0xe6956e65,
  35624. 0xe89c636e,
  35625. 0xfa877473,
  35626. 0xf48e7978,
  35627. 0xdeb15a49,
  35628. 0xd0b85742,
  35629. 0xc2a3405f,
  35630. 0xccaa4d54,
  35631. 0x41ecdaf7,
  35632. 0x4fe5d7fc,
  35633. 0x5dfec0e1,
  35634. 0x53f7cdea,
  35635. 0x79c8eedb,
  35636. 0x77c1e3d0,
  35637. 0x65daf4cd,
  35638. 0x6bd3f9c6,
  35639. 0x31a4b2af,
  35640. 0x3fadbfa4,
  35641. 0x2db6a8b9,
  35642. 0x23bfa5b2,
  35643. 0x09808683,
  35644. 0x07898b88,
  35645. 0x15929c95,
  35646. 0x1b9b919e,
  35647. 0xa17c0a47,
  35648. 0xaf75074c,
  35649. 0xbd6e1051,
  35650. 0xb3671d5a,
  35651. 0x99583e6b,
  35652. 0x97513360,
  35653. 0x854a247d,
  35654. 0x8b432976,
  35655. 0xd134621f,
  35656. 0xdf3d6f14,
  35657. 0xcd267809,
  35658. 0xc32f7502,
  35659. 0xe9105633,
  35660. 0xe7195b38,
  35661. 0xf5024c25,
  35662. 0xfb0b412e,
  35663. 0x9ad7618c,
  35664. 0x94de6c87,
  35665. 0x86c57b9a,
  35666. 0x88cc7691,
  35667. 0xa2f355a0,
  35668. 0xacfa58ab,
  35669. 0xbee14fb6,
  35670. 0xb0e842bd,
  35671. 0xea9f09d4,
  35672. 0xe49604df,
  35673. 0xf68d13c2,
  35674. 0xf8841ec9,
  35675. 0xd2bb3df8,
  35676. 0xdcb230f3,
  35677. 0xcea927ee,
  35678. 0xc0a02ae5,
  35679. 0x7a47b13c,
  35680. 0x744ebc37,
  35681. 0x6655ab2a,
  35682. 0x685ca621,
  35683. 0x42638510,
  35684. 0x4c6a881b,
  35685. 0x5e719f06,
  35686. 0x5078920d,
  35687. 0x0a0fd964,
  35688. 0x0406d46f,
  35689. 0x161dc372,
  35690. 0x1814ce79,
  35691. 0x322bed48,
  35692. 0x3c22e043,
  35693. 0x2e39f75e,
  35694. 0x2030fa55,
  35695. 0xec9ab701,
  35696. 0xe293ba0a,
  35697. 0xf088ad17,
  35698. 0xfe81a01c,
  35699. 0xd4be832d,
  35700. 0xdab78e26,
  35701. 0xc8ac993b,
  35702. 0xc6a59430,
  35703. 0x9cd2df59,
  35704. 0x92dbd252,
  35705. 0x80c0c54f,
  35706. 0x8ec9c844,
  35707. 0xa4f6eb75,
  35708. 0xaaffe67e,
  35709. 0xb8e4f163,
  35710. 0xb6edfc68,
  35711. 0x0c0a67b1,
  35712. 0x02036aba,
  35713. 0x10187da7,
  35714. 0x1e1170ac,
  35715. 0x342e539d,
  35716. 0x3a275e96,
  35717. 0x283c498b,
  35718. 0x26354480,
  35719. 0x7c420fe9,
  35720. 0x724b02e2,
  35721. 0x605015ff,
  35722. 0x6e5918f4,
  35723. 0x44663bc5,
  35724. 0x4a6f36ce,
  35725. 0x587421d3,
  35726. 0x567d2cd8,
  35727. 0x37a10c7a,
  35728. 0x39a80171,
  35729. 0x2bb3166c,
  35730. 0x25ba1b67,
  35731. 0x0f853856,
  35732. 0x018c355d,
  35733. 0x13972240,
  35734. 0x1d9e2f4b,
  35735. 0x47e96422,
  35736. 0x49e06929,
  35737. 0x5bfb7e34,
  35738. 0x55f2733f,
  35739. 0x7fcd500e,
  35740. 0x71c45d05,
  35741. 0x63df4a18,
  35742. 0x6dd64713,
  35743. 0xd731dcca,
  35744. 0xd938d1c1,
  35745. 0xcb23c6dc,
  35746. 0xc52acbd7,
  35747. 0xef15e8e6,
  35748. 0xe11ce5ed,
  35749. 0xf307f2f0,
  35750. 0xfd0efffb,
  35751. 0xa779b492,
  35752. 0xa970b999,
  35753. 0xbb6bae84,
  35754. 0xb562a38f,
  35755. 0x9f5d80be,
  35756. 0x91548db5,
  35757. 0x834f9aa8,
  35758. 0x8d4697a3
  35759. ]);
  35760. function expandKey256(cipherKey) {
  35761. var b = 240, result = new Uint8Array(b);
  35762. var r = 1;
  35763. result.set(cipherKey);
  35764. for (var j = 32, i = 1; j < b; ++i) {
  35765. if (j % 32 === 16) {
  35766. t1 = s[t1];
  35767. t2 = s[t2];
  35768. t3 = s[t3];
  35769. t4 = s[t4];
  35770. } else if (j % 32 === 0) {
  35771. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  35772. t1 = s[t1];
  35773. t2 = s[t2];
  35774. t3 = s[t3];
  35775. t4 = s[t4];
  35776. t1 = t1 ^ r;
  35777. if ((r <<= 1) >= 256) {
  35778. r = (r ^ 0x1b) & 0xFF;
  35779. }
  35780. }
  35781. for (var n = 0; n < 4; ++n) {
  35782. result[j] = t1 ^= result[j - 32];
  35783. j++;
  35784. result[j] = t2 ^= result[j - 32];
  35785. j++;
  35786. result[j] = t3 ^= result[j - 32];
  35787. j++;
  35788. result[j] = t4 ^= result[j - 32];
  35789. j++;
  35790. }
  35791. }
  35792. return result;
  35793. }
  35794. function decrypt256(input, key) {
  35795. var state = new Uint8Array(16);
  35796. state.set(input);
  35797. var i, j, k;
  35798. var t, u, v;
  35799. for (j = 0, k = 224; j < 16; ++j, ++k) {
  35800. state[j] ^= key[k];
  35801. }
  35802. for (i = 13; i >= 1; --i) {
  35803. t = state[13];
  35804. state[13] = state[9];
  35805. state[9] = state[5];
  35806. state[5] = state[1];
  35807. state[1] = t;
  35808. t = state[14];
  35809. u = state[10];
  35810. state[14] = state[6];
  35811. state[10] = state[2];
  35812. state[6] = t;
  35813. state[2] = u;
  35814. t = state[15];
  35815. u = state[11];
  35816. v = state[7];
  35817. state[15] = state[3];
  35818. state[11] = t;
  35819. state[7] = u;
  35820. state[3] = v;
  35821. for (j = 0; j < 16; ++j) {
  35822. state[j] = inv_s[state[j]];
  35823. }
  35824. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  35825. state[j] ^= key[k];
  35826. }
  35827. for (j = 0; j < 16; j += 4) {
  35828. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  35829. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  35830. state[j] = t >>> 24 & 0xFF;
  35831. state[j + 1] = t >> 16 & 0xFF;
  35832. state[j + 2] = t >> 8 & 0xFF;
  35833. state[j + 3] = t & 0xFF;
  35834. }
  35835. }
  35836. t = state[13];
  35837. state[13] = state[9];
  35838. state[9] = state[5];
  35839. state[5] = state[1];
  35840. state[1] = t;
  35841. t = state[14];
  35842. u = state[10];
  35843. state[14] = state[6];
  35844. state[10] = state[2];
  35845. state[6] = t;
  35846. state[2] = u;
  35847. t = state[15];
  35848. u = state[11];
  35849. v = state[7];
  35850. state[15] = state[3];
  35851. state[11] = t;
  35852. state[7] = u;
  35853. state[3] = v;
  35854. for (j = 0; j < 16; ++j) {
  35855. state[j] = inv_s[state[j]];
  35856. state[j] ^= key[j];
  35857. }
  35858. return state;
  35859. }
  35860. function encrypt256(input, key) {
  35861. var t, u, v, k;
  35862. var state = new Uint8Array(16);
  35863. state.set(input);
  35864. for (j = 0; j < 16; ++j) {
  35865. state[j] ^= key[j];
  35866. }
  35867. for (i = 1; i < 14; i++) {
  35868. for (j = 0; j < 16; ++j) {
  35869. state[j] = s[state[j]];
  35870. }
  35871. v = state[1];
  35872. state[1] = state[5];
  35873. state[5] = state[9];
  35874. state[9] = state[13];
  35875. state[13] = v;
  35876. v = state[2];
  35877. u = state[6];
  35878. state[2] = state[10];
  35879. state[6] = state[14];
  35880. state[10] = v;
  35881. state[14] = u;
  35882. v = state[3];
  35883. u = state[7];
  35884. t = state[11];
  35885. state[3] = state[15];
  35886. state[7] = v;
  35887. state[11] = u;
  35888. state[15] = t;
  35889. for (var j = 0; j < 16; j += 4) {
  35890. var s0 = state[j + 0], s1 = state[j + 1];
  35891. var s2 = state[j + 2], s3 = state[j + 3];
  35892. t = s0 ^ s1 ^ s2 ^ s3;
  35893. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  35894. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  35895. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  35896. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  35897. }
  35898. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  35899. state[j] ^= key[k];
  35900. }
  35901. }
  35902. for (j = 0; j < 16; ++j) {
  35903. state[j] = s[state[j]];
  35904. }
  35905. v = state[1];
  35906. state[1] = state[5];
  35907. state[5] = state[9];
  35908. state[9] = state[13];
  35909. state[13] = v;
  35910. v = state[2];
  35911. u = state[6];
  35912. state[2] = state[10];
  35913. state[6] = state[14];
  35914. state[10] = v;
  35915. state[14] = u;
  35916. v = state[3];
  35917. u = state[7];
  35918. t = state[11];
  35919. state[3] = state[15];
  35920. state[7] = v;
  35921. state[11] = u;
  35922. state[15] = t;
  35923. for (j = 0, k = 224; j < 16; ++j, ++k) {
  35924. state[j] ^= key[k];
  35925. }
  35926. return state;
  35927. }
  35928. function AES256Cipher(key) {
  35929. this.key = expandKey256(key);
  35930. this.buffer = new Uint8Array(16);
  35931. this.bufferPosition = 0;
  35932. }
  35933. function decryptBlock2(data, finalize) {
  35934. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  35935. for (i = 0; i < sourceLength; ++i) {
  35936. buffer[bufferLength] = data[i];
  35937. ++bufferLength;
  35938. if (bufferLength < 16) {
  35939. continue;
  35940. }
  35941. var plain = decrypt256(buffer, this.key);
  35942. for (j = 0; j < 16; ++j) {
  35943. plain[j] ^= iv[j];
  35944. }
  35945. iv = buffer;
  35946. result.push(plain);
  35947. buffer = new Uint8Array(16);
  35948. bufferLength = 0;
  35949. }
  35950. this.buffer = buffer;
  35951. this.bufferLength = bufferLength;
  35952. this.iv = iv;
  35953. if (result.length === 0) {
  35954. return new Uint8Array([]);
  35955. }
  35956. var outputLength = 16 * result.length;
  35957. if (finalize) {
  35958. var lastBlock = result[result.length - 1];
  35959. var psLen = lastBlock[15];
  35960. if (psLen <= 16) {
  35961. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  35962. if (lastBlock[i] !== psLen) {
  35963. psLen = 0;
  35964. break;
  35965. }
  35966. }
  35967. outputLength -= psLen;
  35968. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  35969. }
  35970. }
  35971. var output = new Uint8Array(outputLength);
  35972. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  35973. output.set(result[i], j);
  35974. }
  35975. return output;
  35976. }
  35977. AES256Cipher.prototype = {
  35978. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  35979. var i, sourceLength = data.length;
  35980. var buffer = this.buffer, bufferLength = this.bufferPosition;
  35981. if (iv) {
  35982. this.iv = iv;
  35983. } else {
  35984. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  35985. buffer[bufferLength] = data[i];
  35986. }
  35987. if (bufferLength < 16) {
  35988. this.bufferLength = bufferLength;
  35989. return new Uint8Array([]);
  35990. }
  35991. this.iv = buffer;
  35992. data = data.subarray(16);
  35993. }
  35994. this.buffer = new Uint8Array(16);
  35995. this.bufferLength = 0;
  35996. this.decryptBlock = decryptBlock2;
  35997. return this.decryptBlock(data, finalize);
  35998. },
  35999. encrypt: function AES256Cipher_encrypt(data, iv) {
  36000. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  36001. if (!iv) {
  36002. iv = new Uint8Array(16);
  36003. }
  36004. for (i = 0; i < sourceLength; ++i) {
  36005. buffer[bufferLength] = data[i];
  36006. ++bufferLength;
  36007. if (bufferLength < 16) {
  36008. continue;
  36009. }
  36010. for (j = 0; j < 16; ++j) {
  36011. buffer[j] ^= iv[j];
  36012. }
  36013. var cipher = encrypt256(buffer, this.key);
  36014. this.iv = cipher;
  36015. result.push(cipher);
  36016. buffer = new Uint8Array(16);
  36017. bufferLength = 0;
  36018. }
  36019. this.buffer = buffer;
  36020. this.bufferLength = bufferLength;
  36021. this.iv = iv;
  36022. if (result.length === 0) {
  36023. return new Uint8Array([]);
  36024. }
  36025. var outputLength = 16 * result.length;
  36026. var output = new Uint8Array(outputLength);
  36027. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  36028. output.set(result[i], j);
  36029. }
  36030. return output;
  36031. }
  36032. };
  36033. return AES256Cipher;
  36034. }();
  36035. var PDF17 = function PDF17Closure() {
  36036. function compareByteArrays(array1, array2) {
  36037. if (array1.length !== array2.length) {
  36038. return false;
  36039. }
  36040. for (var i = 0; i < array1.length; i++) {
  36041. if (array1[i] !== array2[i]) {
  36042. return false;
  36043. }
  36044. }
  36045. return true;
  36046. }
  36047. function PDF17() {
  36048. }
  36049. PDF17.prototype = {
  36050. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  36051. var hashData = new Uint8Array(password.length + 56);
  36052. hashData.set(password, 0);
  36053. hashData.set(ownerValidationSalt, password.length);
  36054. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  36055. var result = calculateSHA256(hashData, 0, hashData.length);
  36056. return compareByteArrays(result, ownerPassword);
  36057. },
  36058. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  36059. var hashData = new Uint8Array(password.length + 8);
  36060. hashData.set(password, 0);
  36061. hashData.set(userValidationSalt, password.length);
  36062. var result = calculateSHA256(hashData, 0, hashData.length);
  36063. return compareByteArrays(result, userPassword);
  36064. },
  36065. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  36066. var hashData = new Uint8Array(password.length + 56);
  36067. hashData.set(password, 0);
  36068. hashData.set(ownerKeySalt, password.length);
  36069. hashData.set(userBytes, password.length + ownerKeySalt.length);
  36070. var key = calculateSHA256(hashData, 0, hashData.length);
  36071. var cipher = new AES256Cipher(key);
  36072. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  36073. },
  36074. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  36075. var hashData = new Uint8Array(password.length + 8);
  36076. hashData.set(password, 0);
  36077. hashData.set(userKeySalt, password.length);
  36078. var key = calculateSHA256(hashData, 0, hashData.length);
  36079. var cipher = new AES256Cipher(key);
  36080. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  36081. }
  36082. };
  36083. return PDF17;
  36084. }();
  36085. var PDF20 = function PDF20Closure() {
  36086. function concatArrays(array1, array2) {
  36087. var t = new Uint8Array(array1.length + array2.length);
  36088. t.set(array1, 0);
  36089. t.set(array2, array1.length);
  36090. return t;
  36091. }
  36092. function calculatePDF20Hash(password, input, userBytes) {
  36093. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  36094. var e = [0];
  36095. var i = 0;
  36096. while (i < 64 || e[e.length - 1] > i - 32) {
  36097. var arrayLength = password.length + k.length + userBytes.length;
  36098. var k1 = new Uint8Array(arrayLength * 64);
  36099. var array = concatArrays(password, k);
  36100. array = concatArrays(array, userBytes);
  36101. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  36102. k1.set(array, pos);
  36103. }
  36104. var cipher = new AES128Cipher(k.subarray(0, 16));
  36105. e = cipher.encrypt(k1, k.subarray(16, 32));
  36106. var remainder = 0;
  36107. for (var z = 0; z < 16; z++) {
  36108. remainder *= 256 % 3;
  36109. remainder %= 3;
  36110. remainder += (e[z] >>> 0) % 3;
  36111. remainder %= 3;
  36112. }
  36113. if (remainder === 0) {
  36114. k = calculateSHA256(e, 0, e.length);
  36115. } else if (remainder === 1) {
  36116. k = calculateSHA384(e, 0, e.length);
  36117. } else if (remainder === 2) {
  36118. k = calculateSHA512(e, 0, e.length);
  36119. }
  36120. i++;
  36121. }
  36122. return k.subarray(0, 32);
  36123. }
  36124. function PDF20() {
  36125. }
  36126. function compareByteArrays(array1, array2) {
  36127. if (array1.length !== array2.length) {
  36128. return false;
  36129. }
  36130. for (var i = 0; i < array1.length; i++) {
  36131. if (array1[i] !== array2[i]) {
  36132. return false;
  36133. }
  36134. }
  36135. return true;
  36136. }
  36137. PDF20.prototype = {
  36138. hash: function PDF20_hash(password, concatBytes, userBytes) {
  36139. return calculatePDF20Hash(password, concatBytes, userBytes);
  36140. },
  36141. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  36142. var hashData = new Uint8Array(password.length + 56);
  36143. hashData.set(password, 0);
  36144. hashData.set(ownerValidationSalt, password.length);
  36145. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  36146. var result = calculatePDF20Hash(password, hashData, userBytes);
  36147. return compareByteArrays(result, ownerPassword);
  36148. },
  36149. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  36150. var hashData = new Uint8Array(password.length + 8);
  36151. hashData.set(password, 0);
  36152. hashData.set(userValidationSalt, password.length);
  36153. var result = calculatePDF20Hash(password, hashData, []);
  36154. return compareByteArrays(result, userPassword);
  36155. },
  36156. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  36157. var hashData = new Uint8Array(password.length + 56);
  36158. hashData.set(password, 0);
  36159. hashData.set(ownerKeySalt, password.length);
  36160. hashData.set(userBytes, password.length + ownerKeySalt.length);
  36161. var key = calculatePDF20Hash(password, hashData, userBytes);
  36162. var cipher = new AES256Cipher(key);
  36163. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  36164. },
  36165. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  36166. var hashData = new Uint8Array(password.length + 8);
  36167. hashData.set(password, 0);
  36168. hashData.set(userKeySalt, password.length);
  36169. var key = calculatePDF20Hash(password, hashData, []);
  36170. var cipher = new AES256Cipher(key);
  36171. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  36172. }
  36173. };
  36174. return PDF20;
  36175. }();
  36176. var CipherTransform = function CipherTransformClosure() {
  36177. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  36178. this.stringCipherConstructor = stringCipherConstructor;
  36179. this.streamCipherConstructor = streamCipherConstructor;
  36180. }
  36181. CipherTransform.prototype = {
  36182. createStream: function CipherTransform_createStream(stream, length) {
  36183. var cipher = new this.streamCipherConstructor();
  36184. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  36185. return cipher.decryptBlock(data, finalize);
  36186. });
  36187. },
  36188. decryptString: function CipherTransform_decryptString(s) {
  36189. var cipher = new this.stringCipherConstructor();
  36190. var data = stringToBytes(s);
  36191. data = cipher.decryptBlock(data, true);
  36192. return bytesToString(data);
  36193. }
  36194. };
  36195. return CipherTransform;
  36196. }();
  36197. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  36198. var defaultPasswordBytes = new Uint8Array([
  36199. 0x28,
  36200. 0xBF,
  36201. 0x4E,
  36202. 0x5E,
  36203. 0x4E,
  36204. 0x75,
  36205. 0x8A,
  36206. 0x41,
  36207. 0x64,
  36208. 0x00,
  36209. 0x4E,
  36210. 0x56,
  36211. 0xFF,
  36212. 0xFA,
  36213. 0x01,
  36214. 0x08,
  36215. 0x2E,
  36216. 0x2E,
  36217. 0x00,
  36218. 0xB6,
  36219. 0xD0,
  36220. 0x68,
  36221. 0x3E,
  36222. 0x80,
  36223. 0x2F,
  36224. 0x0C,
  36225. 0xA9,
  36226. 0xFE,
  36227. 0x64,
  36228. 0x53,
  36229. 0x69,
  36230. 0x7A
  36231. ]);
  36232. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  36233. if (password) {
  36234. var passwordLength = Math.min(127, password.length);
  36235. password = password.subarray(0, passwordLength);
  36236. } else {
  36237. password = [];
  36238. }
  36239. var pdfAlgorithm;
  36240. if (revision === 6) {
  36241. pdfAlgorithm = new PDF20();
  36242. } else {
  36243. pdfAlgorithm = new PDF17();
  36244. }
  36245. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  36246. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  36247. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  36248. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  36249. }
  36250. return null;
  36251. }
  36252. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  36253. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  36254. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  36255. if (password) {
  36256. n = Math.min(32, password.length);
  36257. for (; i < n; ++i) {
  36258. hashData[i] = password[i];
  36259. }
  36260. }
  36261. j = 0;
  36262. while (i < 32) {
  36263. hashData[i++] = defaultPasswordBytes[j++];
  36264. }
  36265. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  36266. hashData[i++] = ownerPassword[j];
  36267. }
  36268. hashData[i++] = flags & 0xFF;
  36269. hashData[i++] = flags >> 8 & 0xFF;
  36270. hashData[i++] = flags >> 16 & 0xFF;
  36271. hashData[i++] = flags >>> 24 & 0xFF;
  36272. for (j = 0, n = fileId.length; j < n; ++j) {
  36273. hashData[i++] = fileId[j];
  36274. }
  36275. if (revision >= 4 && !encryptMetadata) {
  36276. hashData[i++] = 0xFF;
  36277. hashData[i++] = 0xFF;
  36278. hashData[i++] = 0xFF;
  36279. hashData[i++] = 0xFF;
  36280. }
  36281. var hash = calculateMD5(hashData, 0, i);
  36282. var keyLengthInBytes = keyLength >> 3;
  36283. if (revision >= 3) {
  36284. for (j = 0; j < 50; ++j) {
  36285. hash = calculateMD5(hash, 0, keyLengthInBytes);
  36286. }
  36287. }
  36288. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  36289. var cipher, checkData;
  36290. if (revision >= 3) {
  36291. for (i = 0; i < 32; ++i) {
  36292. hashData[i] = defaultPasswordBytes[i];
  36293. }
  36294. for (j = 0, n = fileId.length; j < n; ++j) {
  36295. hashData[i++] = fileId[j];
  36296. }
  36297. cipher = new ARCFourCipher(encryptionKey);
  36298. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  36299. n = encryptionKey.length;
  36300. var derivedKey = new Uint8Array(n), k;
  36301. for (j = 1; j <= 19; ++j) {
  36302. for (k = 0; k < n; ++k) {
  36303. derivedKey[k] = encryptionKey[k] ^ j;
  36304. }
  36305. cipher = new ARCFourCipher(derivedKey);
  36306. checkData = cipher.encryptBlock(checkData);
  36307. }
  36308. for (j = 0, n = checkData.length; j < n; ++j) {
  36309. if (userPassword[j] !== checkData[j]) {
  36310. return null;
  36311. }
  36312. }
  36313. } else {
  36314. cipher = new ARCFourCipher(encryptionKey);
  36315. checkData = cipher.encryptBlock(defaultPasswordBytes);
  36316. for (j = 0, n = checkData.length; j < n; ++j) {
  36317. if (userPassword[j] !== checkData[j]) {
  36318. return null;
  36319. }
  36320. }
  36321. }
  36322. return encryptionKey;
  36323. }
  36324. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  36325. var hashData = new Uint8Array(32), i = 0, j, n;
  36326. n = Math.min(32, password.length);
  36327. for (; i < n; ++i) {
  36328. hashData[i] = password[i];
  36329. }
  36330. j = 0;
  36331. while (i < 32) {
  36332. hashData[i++] = defaultPasswordBytes[j++];
  36333. }
  36334. var hash = calculateMD5(hashData, 0, i);
  36335. var keyLengthInBytes = keyLength >> 3;
  36336. if (revision >= 3) {
  36337. for (j = 0; j < 50; ++j) {
  36338. hash = calculateMD5(hash, 0, hash.length);
  36339. }
  36340. }
  36341. var cipher, userPassword;
  36342. if (revision >= 3) {
  36343. userPassword = ownerPassword;
  36344. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  36345. for (j = 19; j >= 0; j--) {
  36346. for (k = 0; k < keyLengthInBytes; ++k) {
  36347. derivedKey[k] = hash[k] ^ j;
  36348. }
  36349. cipher = new ARCFourCipher(derivedKey);
  36350. userPassword = cipher.encryptBlock(userPassword);
  36351. }
  36352. } else {
  36353. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  36354. userPassword = cipher.encryptBlock(ownerPassword);
  36355. }
  36356. return userPassword;
  36357. }
  36358. var identityName = Name.get('Identity');
  36359. function CipherTransformFactory(dict, fileId, password) {
  36360. var filter = dict.get('Filter');
  36361. if (!isName(filter, 'Standard')) {
  36362. error('unknown encryption method');
  36363. }
  36364. this.dict = dict;
  36365. var algorithm = dict.get('V');
  36366. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  36367. error('unsupported encryption algorithm');
  36368. }
  36369. this.algorithm = algorithm;
  36370. var keyLength = dict.get('Length');
  36371. if (!keyLength) {
  36372. if (algorithm <= 3) {
  36373. keyLength = 40;
  36374. } else {
  36375. var cfDict = dict.get('CF');
  36376. var streamCryptoName = dict.get('StmF');
  36377. if (isDict(cfDict) && isName(streamCryptoName)) {
  36378. cfDict.suppressEncryption = true;
  36379. var handlerDict = cfDict.get(streamCryptoName.name);
  36380. keyLength = handlerDict && handlerDict.get('Length') || 128;
  36381. if (keyLength < 40) {
  36382. keyLength <<= 3;
  36383. }
  36384. }
  36385. }
  36386. }
  36387. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  36388. error('invalid key length');
  36389. }
  36390. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  36391. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  36392. var flags = dict.get('P');
  36393. var revision = dict.get('R');
  36394. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  36395. this.encryptMetadata = encryptMetadata;
  36396. var fileIdBytes = stringToBytes(fileId);
  36397. var passwordBytes;
  36398. if (password) {
  36399. if (revision === 6) {
  36400. try {
  36401. password = utf8StringToString(password);
  36402. } catch (ex) {
  36403. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  36404. }
  36405. }
  36406. passwordBytes = stringToBytes(password);
  36407. }
  36408. var encryptionKey;
  36409. if (algorithm !== 5) {
  36410. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  36411. } else {
  36412. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  36413. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  36414. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  36415. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  36416. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  36417. var ownerEncryption = stringToBytes(dict.get('OE'));
  36418. var userEncryption = stringToBytes(dict.get('UE'));
  36419. var perms = stringToBytes(dict.get('Perms'));
  36420. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  36421. }
  36422. if (!encryptionKey && !password) {
  36423. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  36424. } else if (!encryptionKey && password) {
  36425. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  36426. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  36427. }
  36428. if (!encryptionKey) {
  36429. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  36430. }
  36431. this.encryptionKey = encryptionKey;
  36432. if (algorithm >= 4) {
  36433. var cf = dict.get('CF');
  36434. if (isDict(cf)) {
  36435. cf.suppressEncryption = true;
  36436. }
  36437. this.cf = cf;
  36438. this.stmf = dict.get('StmF') || identityName;
  36439. this.strf = dict.get('StrF') || identityName;
  36440. this.eff = dict.get('EFF') || this.stmf;
  36441. }
  36442. }
  36443. function buildObjectKey(num, gen, encryptionKey, isAes) {
  36444. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  36445. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  36446. key[i] = encryptionKey[i];
  36447. }
  36448. key[i++] = num & 0xFF;
  36449. key[i++] = num >> 8 & 0xFF;
  36450. key[i++] = num >> 16 & 0xFF;
  36451. key[i++] = gen & 0xFF;
  36452. key[i++] = gen >> 8 & 0xFF;
  36453. if (isAes) {
  36454. key[i++] = 0x73;
  36455. key[i++] = 0x41;
  36456. key[i++] = 0x6C;
  36457. key[i++] = 0x54;
  36458. }
  36459. var hash = calculateMD5(key, 0, i);
  36460. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  36461. }
  36462. function buildCipherConstructor(cf, name, num, gen, key) {
  36463. assert(isName(name), 'Invalid crypt filter name.');
  36464. var cryptFilter = cf.get(name.name);
  36465. var cfm;
  36466. if (cryptFilter !== null && cryptFilter !== undefined) {
  36467. cfm = cryptFilter.get('CFM');
  36468. }
  36469. if (!cfm || cfm.name === 'None') {
  36470. return function cipherTransformFactoryBuildCipherConstructorNone() {
  36471. return new NullCipher();
  36472. };
  36473. }
  36474. if ('V2' === cfm.name) {
  36475. return function cipherTransformFactoryBuildCipherConstructorV2() {
  36476. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  36477. };
  36478. }
  36479. if ('AESV2' === cfm.name) {
  36480. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  36481. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  36482. };
  36483. }
  36484. if ('AESV3' === cfm.name) {
  36485. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  36486. return new AES256Cipher(key);
  36487. };
  36488. }
  36489. error('Unknown crypto method');
  36490. }
  36491. CipherTransformFactory.prototype = {
  36492. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  36493. if (this.algorithm === 4 || this.algorithm === 5) {
  36494. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  36495. }
  36496. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  36497. var cipherConstructor = function buildCipherCipherConstructor() {
  36498. return new ARCFourCipher(key);
  36499. };
  36500. return new CipherTransform(cipherConstructor, cipherConstructor);
  36501. }
  36502. };
  36503. return CipherTransformFactory;
  36504. }();
  36505. exports.AES128Cipher = AES128Cipher;
  36506. exports.AES256Cipher = AES256Cipher;
  36507. exports.ARCFourCipher = ARCFourCipher;
  36508. exports.CipherTransformFactory = CipherTransformFactory;
  36509. exports.PDF17 = PDF17;
  36510. exports.PDF20 = PDF20;
  36511. exports.calculateMD5 = calculateMD5;
  36512. exports.calculateSHA256 = calculateSHA256;
  36513. exports.calculateSHA384 = calculateSHA384;
  36514. exports.calculateSHA512 = calculateSHA512;
  36515. }));
  36516. (function (root, factory) {
  36517. factory(root.pdfjsCoreFontRenderer = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreEncodings, root.pdfjsCoreCFFParser);
  36518. }(this, function (exports, sharedUtil, coreStream, coreGlyphList, coreEncodings, coreCFFParser) {
  36519. var Util = sharedUtil.Util;
  36520. var bytesToString = sharedUtil.bytesToString;
  36521. var error = sharedUtil.error;
  36522. var Stream = coreStream.Stream;
  36523. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  36524. var StandardEncoding = coreEncodings.StandardEncoding;
  36525. var CFFParser = coreCFFParser.CFFParser;
  36526. var FontRendererFactory = function FontRendererFactoryClosure() {
  36527. function getLong(data, offset) {
  36528. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  36529. }
  36530. function getUshort(data, offset) {
  36531. return data[offset] << 8 | data[offset + 1];
  36532. }
  36533. function parseCmap(data, start, end) {
  36534. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  36535. var format = getUshort(data, start + offset);
  36536. var length, ranges, p, i;
  36537. if (format === 4) {
  36538. length = getUshort(data, start + offset + 2);
  36539. var segCount = getUshort(data, start + offset + 6) >> 1;
  36540. p = start + offset + 14;
  36541. ranges = [];
  36542. for (i = 0; i < segCount; i++, p += 2) {
  36543. ranges[i] = { end: getUshort(data, p) };
  36544. }
  36545. p += 2;
  36546. for (i = 0; i < segCount; i++, p += 2) {
  36547. ranges[i].start = getUshort(data, p);
  36548. }
  36549. for (i = 0; i < segCount; i++, p += 2) {
  36550. ranges[i].idDelta = getUshort(data, p);
  36551. }
  36552. for (i = 0; i < segCount; i++, p += 2) {
  36553. var idOffset = getUshort(data, p);
  36554. if (idOffset === 0) {
  36555. continue;
  36556. }
  36557. ranges[i].ids = [];
  36558. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  36559. ranges[i].ids[j] = getUshort(data, p + idOffset);
  36560. idOffset += 2;
  36561. }
  36562. }
  36563. return ranges;
  36564. } else if (format === 12) {
  36565. length = getLong(data, start + offset + 4);
  36566. var groups = getLong(data, start + offset + 12);
  36567. p = start + offset + 16;
  36568. ranges = [];
  36569. for (i = 0; i < groups; i++) {
  36570. ranges.push({
  36571. start: getLong(data, p),
  36572. end: getLong(data, p + 4),
  36573. idDelta: getLong(data, p + 8) - getLong(data, p)
  36574. });
  36575. p += 12;
  36576. }
  36577. return ranges;
  36578. }
  36579. error('not supported cmap: ' + format);
  36580. }
  36581. function parseCff(data, start, end, seacAnalysisEnabled) {
  36582. var properties = {};
  36583. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  36584. var cff = parser.parse();
  36585. return {
  36586. glyphs: cff.charStrings.objects,
  36587. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  36588. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  36589. };
  36590. }
  36591. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  36592. var itemSize, itemDecode;
  36593. if (isGlyphLocationsLong) {
  36594. itemSize = 4;
  36595. itemDecode = function fontItemDecodeLong(data, offset) {
  36596. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  36597. };
  36598. } else {
  36599. itemSize = 2;
  36600. itemDecode = function fontItemDecode(data, offset) {
  36601. return data[offset] << 9 | data[offset + 1] << 1;
  36602. };
  36603. }
  36604. var glyphs = [];
  36605. var startOffset = itemDecode(loca, 0);
  36606. for (var j = itemSize; j < loca.length; j += itemSize) {
  36607. var endOffset = itemDecode(loca, j);
  36608. glyphs.push(glyf.subarray(startOffset, endOffset));
  36609. startOffset = endOffset;
  36610. }
  36611. return glyphs;
  36612. }
  36613. function lookupCmap(ranges, unicode) {
  36614. var code = unicode.charCodeAt(0), gid = 0;
  36615. var l = 0, r = ranges.length - 1;
  36616. while (l < r) {
  36617. var c = l + r + 1 >> 1;
  36618. if (code < ranges[c].start) {
  36619. r = c - 1;
  36620. } else {
  36621. l = c;
  36622. }
  36623. }
  36624. if (ranges[l].start <= code && code <= ranges[l].end) {
  36625. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  36626. }
  36627. return {
  36628. charCode: code,
  36629. glyphId: gid
  36630. };
  36631. }
  36632. function compileGlyf(code, cmds, font) {
  36633. function moveTo(x, y) {
  36634. cmds.push({
  36635. cmd: 'moveTo',
  36636. args: [
  36637. x,
  36638. y
  36639. ]
  36640. });
  36641. }
  36642. function lineTo(x, y) {
  36643. cmds.push({
  36644. cmd: 'lineTo',
  36645. args: [
  36646. x,
  36647. y
  36648. ]
  36649. });
  36650. }
  36651. function quadraticCurveTo(xa, ya, x, y) {
  36652. cmds.push({
  36653. cmd: 'quadraticCurveTo',
  36654. args: [
  36655. xa,
  36656. ya,
  36657. x,
  36658. y
  36659. ]
  36660. });
  36661. }
  36662. var i = 0;
  36663. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  36664. var flags;
  36665. var x = 0, y = 0;
  36666. i += 10;
  36667. if (numberOfContours < 0) {
  36668. do {
  36669. flags = code[i] << 8 | code[i + 1];
  36670. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  36671. i += 4;
  36672. var arg1, arg2;
  36673. if (flags & 0x01) {
  36674. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  36675. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  36676. i += 4;
  36677. } else {
  36678. arg1 = code[i++];
  36679. arg2 = code[i++];
  36680. }
  36681. if (flags & 0x02) {
  36682. x = arg1;
  36683. y = arg2;
  36684. } else {
  36685. x = 0;
  36686. y = 0;
  36687. }
  36688. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  36689. if (flags & 0x08) {
  36690. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36691. i += 2;
  36692. } else if (flags & 0x40) {
  36693. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36694. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  36695. i += 4;
  36696. } else if (flags & 0x80) {
  36697. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36698. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  36699. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  36700. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  36701. i += 8;
  36702. }
  36703. var subglyph = font.glyphs[glyphIndex];
  36704. if (subglyph) {
  36705. cmds.push({ cmd: 'save' });
  36706. cmds.push({
  36707. cmd: 'transform',
  36708. args: [
  36709. scaleX,
  36710. scale01,
  36711. scale10,
  36712. scaleY,
  36713. x,
  36714. y
  36715. ]
  36716. });
  36717. compileGlyf(subglyph, cmds, font);
  36718. cmds.push({ cmd: 'restore' });
  36719. }
  36720. } while (flags & 0x20);
  36721. } else {
  36722. var endPtsOfContours = [];
  36723. var j, jj;
  36724. for (j = 0; j < numberOfContours; j++) {
  36725. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  36726. i += 2;
  36727. }
  36728. var instructionLength = code[i] << 8 | code[i + 1];
  36729. i += 2 + instructionLength;
  36730. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  36731. var points = [];
  36732. while (points.length < numberOfPoints) {
  36733. flags = code[i++];
  36734. var repeat = 1;
  36735. if (flags & 0x08) {
  36736. repeat += code[i++];
  36737. }
  36738. while (repeat-- > 0) {
  36739. points.push({ flags: flags });
  36740. }
  36741. }
  36742. for (j = 0; j < numberOfPoints; j++) {
  36743. switch (points[j].flags & 0x12) {
  36744. case 0x00:
  36745. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  36746. i += 2;
  36747. break;
  36748. case 0x02:
  36749. x -= code[i++];
  36750. break;
  36751. case 0x12:
  36752. x += code[i++];
  36753. break;
  36754. }
  36755. points[j].x = x;
  36756. }
  36757. for (j = 0; j < numberOfPoints; j++) {
  36758. switch (points[j].flags & 0x24) {
  36759. case 0x00:
  36760. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  36761. i += 2;
  36762. break;
  36763. case 0x04:
  36764. y -= code[i++];
  36765. break;
  36766. case 0x24:
  36767. y += code[i++];
  36768. break;
  36769. }
  36770. points[j].y = y;
  36771. }
  36772. var startPoint = 0;
  36773. for (i = 0; i < numberOfContours; i++) {
  36774. var endPoint = endPtsOfContours[i];
  36775. var contour = points.slice(startPoint, endPoint + 1);
  36776. if (contour[0].flags & 1) {
  36777. contour.push(contour[0]);
  36778. } else if (contour[contour.length - 1].flags & 1) {
  36779. contour.unshift(contour[contour.length - 1]);
  36780. } else {
  36781. var p = {
  36782. flags: 1,
  36783. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  36784. y: (contour[0].y + contour[contour.length - 1].y) / 2
  36785. };
  36786. contour.unshift(p);
  36787. contour.push(p);
  36788. }
  36789. moveTo(contour[0].x, contour[0].y);
  36790. for (j = 1, jj = contour.length; j < jj; j++) {
  36791. if (contour[j].flags & 1) {
  36792. lineTo(contour[j].x, contour[j].y);
  36793. } else if (contour[j + 1].flags & 1) {
  36794. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  36795. j++;
  36796. } else {
  36797. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  36798. }
  36799. }
  36800. startPoint = endPoint + 1;
  36801. }
  36802. }
  36803. }
  36804. function compileCharString(code, cmds, font) {
  36805. var stack = [];
  36806. var x = 0, y = 0;
  36807. var stems = 0;
  36808. function moveTo(x, y) {
  36809. cmds.push({
  36810. cmd: 'moveTo',
  36811. args: [
  36812. x,
  36813. y
  36814. ]
  36815. });
  36816. }
  36817. function lineTo(x, y) {
  36818. cmds.push({
  36819. cmd: 'lineTo',
  36820. args: [
  36821. x,
  36822. y
  36823. ]
  36824. });
  36825. }
  36826. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  36827. cmds.push({
  36828. cmd: 'bezierCurveTo',
  36829. args: [
  36830. x1,
  36831. y1,
  36832. x2,
  36833. y2,
  36834. x,
  36835. y
  36836. ]
  36837. });
  36838. }
  36839. function parse(code) {
  36840. var i = 0;
  36841. while (i < code.length) {
  36842. var stackClean = false;
  36843. var v = code[i++];
  36844. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  36845. switch (v) {
  36846. case 1:
  36847. stems += stack.length >> 1;
  36848. stackClean = true;
  36849. break;
  36850. case 3:
  36851. stems += stack.length >> 1;
  36852. stackClean = true;
  36853. break;
  36854. case 4:
  36855. y += stack.pop();
  36856. moveTo(x, y);
  36857. stackClean = true;
  36858. break;
  36859. case 5:
  36860. while (stack.length > 0) {
  36861. x += stack.shift();
  36862. y += stack.shift();
  36863. lineTo(x, y);
  36864. }
  36865. break;
  36866. case 6:
  36867. while (stack.length > 0) {
  36868. x += stack.shift();
  36869. lineTo(x, y);
  36870. if (stack.length === 0) {
  36871. break;
  36872. }
  36873. y += stack.shift();
  36874. lineTo(x, y);
  36875. }
  36876. break;
  36877. case 7:
  36878. while (stack.length > 0) {
  36879. y += stack.shift();
  36880. lineTo(x, y);
  36881. if (stack.length === 0) {
  36882. break;
  36883. }
  36884. x += stack.shift();
  36885. lineTo(x, y);
  36886. }
  36887. break;
  36888. case 8:
  36889. while (stack.length > 0) {
  36890. xa = x + stack.shift();
  36891. ya = y + stack.shift();
  36892. xb = xa + stack.shift();
  36893. yb = ya + stack.shift();
  36894. x = xb + stack.shift();
  36895. y = yb + stack.shift();
  36896. bezierCurveTo(xa, ya, xb, yb, x, y);
  36897. }
  36898. break;
  36899. case 10:
  36900. n = stack.pop() + font.subrsBias;
  36901. subrCode = font.subrs[n];
  36902. if (subrCode) {
  36903. parse(subrCode);
  36904. }
  36905. break;
  36906. case 11:
  36907. return;
  36908. case 12:
  36909. v = code[i++];
  36910. switch (v) {
  36911. case 34:
  36912. xa = x + stack.shift();
  36913. xb = xa + stack.shift();
  36914. y1 = y + stack.shift();
  36915. x = xb + stack.shift();
  36916. bezierCurveTo(xa, y, xb, y1, x, y1);
  36917. xa = x + stack.shift();
  36918. xb = xa + stack.shift();
  36919. x = xb + stack.shift();
  36920. bezierCurveTo(xa, y1, xb, y, x, y);
  36921. break;
  36922. case 35:
  36923. xa = x + stack.shift();
  36924. ya = y + stack.shift();
  36925. xb = xa + stack.shift();
  36926. yb = ya + stack.shift();
  36927. x = xb + stack.shift();
  36928. y = yb + stack.shift();
  36929. bezierCurveTo(xa, ya, xb, yb, x, y);
  36930. xa = x + stack.shift();
  36931. ya = y + stack.shift();
  36932. xb = xa + stack.shift();
  36933. yb = ya + stack.shift();
  36934. x = xb + stack.shift();
  36935. y = yb + stack.shift();
  36936. bezierCurveTo(xa, ya, xb, yb, x, y);
  36937. stack.pop();
  36938. break;
  36939. case 36:
  36940. xa = x + stack.shift();
  36941. y1 = y + stack.shift();
  36942. xb = xa + stack.shift();
  36943. y2 = y1 + stack.shift();
  36944. x = xb + stack.shift();
  36945. bezierCurveTo(xa, y1, xb, y2, x, y2);
  36946. xa = x + stack.shift();
  36947. xb = xa + stack.shift();
  36948. y3 = y2 + stack.shift();
  36949. x = xb + stack.shift();
  36950. bezierCurveTo(xa, y2, xb, y3, x, y);
  36951. break;
  36952. case 37:
  36953. var x0 = x, y0 = y;
  36954. xa = x + stack.shift();
  36955. ya = y + stack.shift();
  36956. xb = xa + stack.shift();
  36957. yb = ya + stack.shift();
  36958. x = xb + stack.shift();
  36959. y = yb + stack.shift();
  36960. bezierCurveTo(xa, ya, xb, yb, x, y);
  36961. xa = x + stack.shift();
  36962. ya = y + stack.shift();
  36963. xb = xa + stack.shift();
  36964. yb = ya + stack.shift();
  36965. x = xb;
  36966. y = yb;
  36967. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  36968. x += stack.shift();
  36969. } else {
  36970. y += stack.shift();
  36971. }
  36972. bezierCurveTo(xa, ya, xb, yb, x, y);
  36973. break;
  36974. default:
  36975. error('unknown operator: 12 ' + v);
  36976. }
  36977. break;
  36978. case 14:
  36979. if (stack.length >= 4) {
  36980. var achar = stack.pop();
  36981. var bchar = stack.pop();
  36982. y = stack.pop();
  36983. x = stack.pop();
  36984. cmds.push({ cmd: 'save' });
  36985. cmds.push({
  36986. cmd: 'translate',
  36987. args: [
  36988. x,
  36989. y
  36990. ]
  36991. });
  36992. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  36993. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  36994. cmds.push({ cmd: 'restore' });
  36995. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  36996. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  36997. }
  36998. return;
  36999. case 18:
  37000. stems += stack.length >> 1;
  37001. stackClean = true;
  37002. break;
  37003. case 19:
  37004. stems += stack.length >> 1;
  37005. i += stems + 7 >> 3;
  37006. stackClean = true;
  37007. break;
  37008. case 20:
  37009. stems += stack.length >> 1;
  37010. i += stems + 7 >> 3;
  37011. stackClean = true;
  37012. break;
  37013. case 21:
  37014. y += stack.pop();
  37015. x += stack.pop();
  37016. moveTo(x, y);
  37017. stackClean = true;
  37018. break;
  37019. case 22:
  37020. x += stack.pop();
  37021. moveTo(x, y);
  37022. stackClean = true;
  37023. break;
  37024. case 23:
  37025. stems += stack.length >> 1;
  37026. stackClean = true;
  37027. break;
  37028. case 24:
  37029. while (stack.length > 2) {
  37030. xa = x + stack.shift();
  37031. ya = y + stack.shift();
  37032. xb = xa + stack.shift();
  37033. yb = ya + stack.shift();
  37034. x = xb + stack.shift();
  37035. y = yb + stack.shift();
  37036. bezierCurveTo(xa, ya, xb, yb, x, y);
  37037. }
  37038. x += stack.shift();
  37039. y += stack.shift();
  37040. lineTo(x, y);
  37041. break;
  37042. case 25:
  37043. while (stack.length > 6) {
  37044. x += stack.shift();
  37045. y += stack.shift();
  37046. lineTo(x, y);
  37047. }
  37048. xa = x + stack.shift();
  37049. ya = y + stack.shift();
  37050. xb = xa + stack.shift();
  37051. yb = ya + stack.shift();
  37052. x = xb + stack.shift();
  37053. y = yb + stack.shift();
  37054. bezierCurveTo(xa, ya, xb, yb, x, y);
  37055. break;
  37056. case 26:
  37057. if (stack.length % 2) {
  37058. x += stack.shift();
  37059. }
  37060. while (stack.length > 0) {
  37061. xa = x;
  37062. ya = y + stack.shift();
  37063. xb = xa + stack.shift();
  37064. yb = ya + stack.shift();
  37065. x = xb;
  37066. y = yb + stack.shift();
  37067. bezierCurveTo(xa, ya, xb, yb, x, y);
  37068. }
  37069. break;
  37070. case 27:
  37071. if (stack.length % 2) {
  37072. y += stack.shift();
  37073. }
  37074. while (stack.length > 0) {
  37075. xa = x + stack.shift();
  37076. ya = y;
  37077. xb = xa + stack.shift();
  37078. yb = ya + stack.shift();
  37079. x = xb + stack.shift();
  37080. y = yb;
  37081. bezierCurveTo(xa, ya, xb, yb, x, y);
  37082. }
  37083. break;
  37084. case 28:
  37085. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  37086. i += 2;
  37087. break;
  37088. case 29:
  37089. n = stack.pop() + font.gsubrsBias;
  37090. subrCode = font.gsubrs[n];
  37091. if (subrCode) {
  37092. parse(subrCode);
  37093. }
  37094. break;
  37095. case 30:
  37096. while (stack.length > 0) {
  37097. xa = x;
  37098. ya = y + stack.shift();
  37099. xb = xa + stack.shift();
  37100. yb = ya + stack.shift();
  37101. x = xb + stack.shift();
  37102. y = yb + (stack.length === 1 ? stack.shift() : 0);
  37103. bezierCurveTo(xa, ya, xb, yb, x, y);
  37104. if (stack.length === 0) {
  37105. break;
  37106. }
  37107. xa = x + stack.shift();
  37108. ya = y;
  37109. xb = xa + stack.shift();
  37110. yb = ya + stack.shift();
  37111. y = yb + stack.shift();
  37112. x = xb + (stack.length === 1 ? stack.shift() : 0);
  37113. bezierCurveTo(xa, ya, xb, yb, x, y);
  37114. }
  37115. break;
  37116. case 31:
  37117. while (stack.length > 0) {
  37118. xa = x + stack.shift();
  37119. ya = y;
  37120. xb = xa + stack.shift();
  37121. yb = ya + stack.shift();
  37122. y = yb + stack.shift();
  37123. x = xb + (stack.length === 1 ? stack.shift() : 0);
  37124. bezierCurveTo(xa, ya, xb, yb, x, y);
  37125. if (stack.length === 0) {
  37126. break;
  37127. }
  37128. xa = x;
  37129. ya = y + stack.shift();
  37130. xb = xa + stack.shift();
  37131. yb = ya + stack.shift();
  37132. x = xb + stack.shift();
  37133. y = yb + (stack.length === 1 ? stack.shift() : 0);
  37134. bezierCurveTo(xa, ya, xb, yb, x, y);
  37135. }
  37136. break;
  37137. default:
  37138. if (v < 32) {
  37139. error('unknown operator: ' + v);
  37140. }
  37141. if (v < 247) {
  37142. stack.push(v - 139);
  37143. } else if (v < 251) {
  37144. stack.push((v - 247) * 256 + code[i++] + 108);
  37145. } else if (v < 255) {
  37146. stack.push(-(v - 251) * 256 - code[i++] - 108);
  37147. } else {
  37148. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  37149. i += 4;
  37150. }
  37151. break;
  37152. }
  37153. if (stackClean) {
  37154. stack.length = 0;
  37155. }
  37156. }
  37157. }
  37158. parse(code);
  37159. }
  37160. var noop = '';
  37161. function CompiledFont(fontMatrix) {
  37162. this.compiledGlyphs = Object.create(null);
  37163. this.compiledCharCodeToGlyphId = Object.create(null);
  37164. this.fontMatrix = fontMatrix;
  37165. }
  37166. CompiledFont.prototype = {
  37167. getPathJs: function (unicode) {
  37168. var cmap = lookupCmap(this.cmap, unicode);
  37169. var fn = this.compiledGlyphs[cmap.glyphId];
  37170. if (!fn) {
  37171. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  37172. this.compiledGlyphs[cmap.glyphId] = fn;
  37173. }
  37174. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  37175. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  37176. }
  37177. return fn;
  37178. },
  37179. compileGlyph: function (code) {
  37180. if (!code || code.length === 0 || code[0] === 14) {
  37181. return noop;
  37182. }
  37183. var cmds = [];
  37184. cmds.push({ cmd: 'save' });
  37185. cmds.push({
  37186. cmd: 'transform',
  37187. args: this.fontMatrix.slice()
  37188. });
  37189. cmds.push({
  37190. cmd: 'scale',
  37191. args: [
  37192. 'size',
  37193. '-size'
  37194. ]
  37195. });
  37196. this.compileGlyphImpl(code, cmds);
  37197. cmds.push({ cmd: 'restore' });
  37198. return cmds;
  37199. },
  37200. compileGlyphImpl: function () {
  37201. error('Children classes should implement this.');
  37202. },
  37203. hasBuiltPath: function (unicode) {
  37204. var cmap = lookupCmap(this.cmap, unicode);
  37205. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  37206. }
  37207. };
  37208. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  37209. fontMatrix = fontMatrix || [
  37210. 0.000488,
  37211. 0,
  37212. 0,
  37213. 0.000488,
  37214. 0,
  37215. 0
  37216. ];
  37217. CompiledFont.call(this, fontMatrix);
  37218. this.glyphs = glyphs;
  37219. this.cmap = cmap;
  37220. }
  37221. Util.inherit(TrueTypeCompiled, CompiledFont, {
  37222. compileGlyphImpl: function (code, cmds) {
  37223. compileGlyf(code, cmds, this);
  37224. }
  37225. });
  37226. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  37227. fontMatrix = fontMatrix || [
  37228. 0.001,
  37229. 0,
  37230. 0,
  37231. 0.001,
  37232. 0,
  37233. 0
  37234. ];
  37235. CompiledFont.call(this, fontMatrix);
  37236. this.glyphs = cffInfo.glyphs;
  37237. this.gsubrs = cffInfo.gsubrs || [];
  37238. this.subrs = cffInfo.subrs || [];
  37239. this.cmap = cmap;
  37240. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  37241. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  37242. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  37243. }
  37244. Util.inherit(Type2Compiled, CompiledFont, {
  37245. compileGlyphImpl: function (code, cmds) {
  37246. compileCharString(code, cmds, this);
  37247. }
  37248. });
  37249. return {
  37250. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  37251. var data = new Uint8Array(font.data);
  37252. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  37253. var numTables = getUshort(data, 4);
  37254. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  37255. var tag = bytesToString(data.subarray(p, p + 4));
  37256. var offset = getLong(data, p + 8);
  37257. var length = getLong(data, p + 12);
  37258. switch (tag) {
  37259. case 'cmap':
  37260. cmap = parseCmap(data, offset, offset + length);
  37261. break;
  37262. case 'glyf':
  37263. glyf = data.subarray(offset, offset + length);
  37264. break;
  37265. case 'loca':
  37266. loca = data.subarray(offset, offset + length);
  37267. break;
  37268. case 'head':
  37269. unitsPerEm = getUshort(data, offset + 18);
  37270. indexToLocFormat = getUshort(data, offset + 50);
  37271. break;
  37272. case 'CFF ':
  37273. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  37274. break;
  37275. }
  37276. }
  37277. if (glyf) {
  37278. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  37279. 1 / unitsPerEm,
  37280. 0,
  37281. 0,
  37282. 1 / unitsPerEm,
  37283. 0,
  37284. 0
  37285. ];
  37286. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  37287. } else {
  37288. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  37289. }
  37290. }
  37291. };
  37292. }();
  37293. exports.FontRendererFactory = FontRendererFactory;
  37294. }));
  37295. (function (root, factory) {
  37296. factory(root.pdfjsCoreParser = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  37297. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  37298. var MissingDataException = sharedUtil.MissingDataException;
  37299. var StreamType = sharedUtil.StreamType;
  37300. var assert = sharedUtil.assert;
  37301. var error = sharedUtil.error;
  37302. var info = sharedUtil.info;
  37303. var isArray = sharedUtil.isArray;
  37304. var isInt = sharedUtil.isInt;
  37305. var isNum = sharedUtil.isNum;
  37306. var isString = sharedUtil.isString;
  37307. var warn = sharedUtil.warn;
  37308. var Cmd = corePrimitives.Cmd;
  37309. var Dict = corePrimitives.Dict;
  37310. var Name = corePrimitives.Name;
  37311. var Ref = corePrimitives.Ref;
  37312. var isCmd = corePrimitives.isCmd;
  37313. var isDict = corePrimitives.isDict;
  37314. var isName = corePrimitives.isName;
  37315. var Ascii85Stream = coreStream.Ascii85Stream;
  37316. var AsciiHexStream = coreStream.AsciiHexStream;
  37317. var CCITTFaxStream = coreStream.CCITTFaxStream;
  37318. var FlateStream = coreStream.FlateStream;
  37319. var Jbig2Stream = coreStream.Jbig2Stream;
  37320. var JpegStream = coreStream.JpegStream;
  37321. var JpxStream = coreStream.JpxStream;
  37322. var LZWStream = coreStream.LZWStream;
  37323. var NullStream = coreStream.NullStream;
  37324. var PredictorStream = coreStream.PredictorStream;
  37325. var RunLengthStream = coreStream.RunLengthStream;
  37326. var EOF = {};
  37327. function isEOF(v) {
  37328. return v === EOF;
  37329. }
  37330. var MAX_LENGTH_TO_CACHE = 1000;
  37331. var Parser = function ParserClosure() {
  37332. function Parser(lexer, allowStreams, xref, recoveryMode) {
  37333. this.lexer = lexer;
  37334. this.allowStreams = allowStreams;
  37335. this.xref = xref;
  37336. this.recoveryMode = recoveryMode || false;
  37337. this.imageCache = Object.create(null);
  37338. this.refill();
  37339. }
  37340. Parser.prototype = {
  37341. refill: function Parser_refill() {
  37342. this.buf1 = this.lexer.getObj();
  37343. this.buf2 = this.lexer.getObj();
  37344. },
  37345. shift: function Parser_shift() {
  37346. if (isCmd(this.buf2, 'ID')) {
  37347. this.buf1 = this.buf2;
  37348. this.buf2 = null;
  37349. } else {
  37350. this.buf1 = this.buf2;
  37351. this.buf2 = this.lexer.getObj();
  37352. }
  37353. },
  37354. tryShift: function Parser_tryShift() {
  37355. try {
  37356. this.shift();
  37357. return true;
  37358. } catch (e) {
  37359. if (e instanceof MissingDataException) {
  37360. throw e;
  37361. }
  37362. return false;
  37363. }
  37364. },
  37365. getObj: function Parser_getObj(cipherTransform) {
  37366. var buf1 = this.buf1;
  37367. this.shift();
  37368. if (buf1 instanceof Cmd) {
  37369. switch (buf1.cmd) {
  37370. case 'BI':
  37371. return this.makeInlineImage(cipherTransform);
  37372. case '[':
  37373. var array = [];
  37374. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  37375. array.push(this.getObj(cipherTransform));
  37376. }
  37377. if (isEOF(this.buf1)) {
  37378. if (!this.recoveryMode) {
  37379. error('End of file inside array');
  37380. }
  37381. return array;
  37382. }
  37383. this.shift();
  37384. return array;
  37385. case '<<':
  37386. var dict = new Dict(this.xref);
  37387. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  37388. if (!isName(this.buf1)) {
  37389. info('Malformed dictionary: key must be a name object');
  37390. this.shift();
  37391. continue;
  37392. }
  37393. var key = this.buf1.name;
  37394. this.shift();
  37395. if (isEOF(this.buf1)) {
  37396. break;
  37397. }
  37398. dict.set(key, this.getObj(cipherTransform));
  37399. }
  37400. if (isEOF(this.buf1)) {
  37401. if (!this.recoveryMode) {
  37402. error('End of file inside dictionary');
  37403. }
  37404. return dict;
  37405. }
  37406. if (isCmd(this.buf2, 'stream')) {
  37407. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  37408. }
  37409. this.shift();
  37410. return dict;
  37411. default:
  37412. return buf1;
  37413. }
  37414. }
  37415. if (isInt(buf1)) {
  37416. var num = buf1;
  37417. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  37418. var ref = new Ref(num, this.buf1);
  37419. this.shift();
  37420. this.shift();
  37421. return ref;
  37422. }
  37423. return num;
  37424. }
  37425. if (isString(buf1)) {
  37426. var str = buf1;
  37427. if (cipherTransform) {
  37428. str = cipherTransform.decryptString(str);
  37429. }
  37430. return str;
  37431. }
  37432. return buf1;
  37433. },
  37434. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  37435. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  37436. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  37437. while ((ch = stream.getByte()) !== -1) {
  37438. if (state === 0) {
  37439. state = ch === E ? 1 : 0;
  37440. } else if (state === 1) {
  37441. state = ch === I ? 2 : 0;
  37442. } else {
  37443. assert(state === 2);
  37444. if (ch === SPACE || ch === LF || ch === CR) {
  37445. n = 5;
  37446. followingBytes = stream.peekBytes(n);
  37447. for (i = 0; i < n; i++) {
  37448. ch = followingBytes[i];
  37449. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  37450. state = 0;
  37451. break;
  37452. }
  37453. }
  37454. if (state === 2) {
  37455. break;
  37456. }
  37457. } else
  37458. {
  37459. state = 0;
  37460. }
  37461. }
  37462. }
  37463. return stream.pos - 4 - startPos;
  37464. },
  37465. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  37466. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  37467. while ((b = stream.getByte()) !== -1) {
  37468. if (b !== 0xFF) {
  37469. continue;
  37470. }
  37471. switch (stream.getByte()) {
  37472. case 0x00:
  37473. break;
  37474. case 0xFF:
  37475. stream.skip(-1);
  37476. break;
  37477. case 0xD9:
  37478. foundEOI = true;
  37479. break;
  37480. case 0xC0:
  37481. case 0xC1:
  37482. case 0xC2:
  37483. case 0xC3:
  37484. case 0xC5:
  37485. case 0xC6:
  37486. case 0xC7:
  37487. case 0xC9:
  37488. case 0xCA:
  37489. case 0xCB:
  37490. case 0xCD:
  37491. case 0xCE:
  37492. case 0xCF:
  37493. case 0xC4:
  37494. case 0xCC:
  37495. case 0xDA:
  37496. case 0xDB:
  37497. case 0xDC:
  37498. case 0xDD:
  37499. case 0xDE:
  37500. case 0xDF:
  37501. case 0xE0:
  37502. case 0xE1:
  37503. case 0xE2:
  37504. case 0xE3:
  37505. case 0xE4:
  37506. case 0xE5:
  37507. case 0xE6:
  37508. case 0xE7:
  37509. case 0xE8:
  37510. case 0xE9:
  37511. case 0xEA:
  37512. case 0xEB:
  37513. case 0xEC:
  37514. case 0xED:
  37515. case 0xEE:
  37516. case 0xEF:
  37517. case 0xFE:
  37518. markerLength = stream.getUint16();
  37519. if (markerLength > 2) {
  37520. stream.skip(markerLength - 2);
  37521. } else
  37522. {
  37523. stream.skip(-2);
  37524. }
  37525. break;
  37526. }
  37527. if (foundEOI) {
  37528. break;
  37529. }
  37530. }
  37531. length = stream.pos - startPos;
  37532. if (b === -1) {
  37533. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  37534. stream.skip(-length);
  37535. return this.findDefaultInlineStreamEnd(stream);
  37536. }
  37537. this.inlineStreamSkipEI(stream);
  37538. return length;
  37539. },
  37540. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  37541. var TILDE = 0x7E, GT = 0x3E;
  37542. var startPos = stream.pos, ch, length;
  37543. while ((ch = stream.getByte()) !== -1) {
  37544. if (ch === TILDE && stream.peekByte() === GT) {
  37545. stream.skip();
  37546. break;
  37547. }
  37548. }
  37549. length = stream.pos - startPos;
  37550. if (ch === -1) {
  37551. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  37552. stream.skip(-length);
  37553. return this.findDefaultInlineStreamEnd(stream);
  37554. }
  37555. this.inlineStreamSkipEI(stream);
  37556. return length;
  37557. },
  37558. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  37559. var GT = 0x3E;
  37560. var startPos = stream.pos, ch, length;
  37561. while ((ch = stream.getByte()) !== -1) {
  37562. if (ch === GT) {
  37563. break;
  37564. }
  37565. }
  37566. length = stream.pos - startPos;
  37567. if (ch === -1) {
  37568. warn('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  37569. stream.skip(-length);
  37570. return this.findDefaultInlineStreamEnd(stream);
  37571. }
  37572. this.inlineStreamSkipEI(stream);
  37573. return length;
  37574. },
  37575. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  37576. var E = 0x45, I = 0x49;
  37577. var state = 0, ch;
  37578. while ((ch = stream.getByte()) !== -1) {
  37579. if (state === 0) {
  37580. state = ch === E ? 1 : 0;
  37581. } else if (state === 1) {
  37582. state = ch === I ? 2 : 0;
  37583. } else if (state === 2) {
  37584. break;
  37585. }
  37586. }
  37587. },
  37588. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  37589. var lexer = this.lexer;
  37590. var stream = lexer.stream;
  37591. var dict = new Dict(this.xref);
  37592. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  37593. if (!isName(this.buf1)) {
  37594. error('Dictionary key must be a name object');
  37595. }
  37596. var key = this.buf1.name;
  37597. this.shift();
  37598. if (isEOF(this.buf1)) {
  37599. break;
  37600. }
  37601. dict.set(key, this.getObj(cipherTransform));
  37602. }
  37603. var filter = dict.get('Filter', 'F'), filterName;
  37604. if (isName(filter)) {
  37605. filterName = filter.name;
  37606. } else if (isArray(filter) && isName(filter[0])) {
  37607. filterName = filter[0].name;
  37608. }
  37609. var startPos = stream.pos, length, i, ii;
  37610. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  37611. length = this.findDCTDecodeInlineStreamEnd(stream);
  37612. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  37613. length = this.findASCII85DecodeInlineStreamEnd(stream);
  37614. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  37615. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  37616. } else {
  37617. length = this.findDefaultInlineStreamEnd(stream);
  37618. }
  37619. var imageStream = stream.makeSubStream(startPos, length, dict);
  37620. var adler32;
  37621. if (length < MAX_LENGTH_TO_CACHE) {
  37622. var imageBytes = imageStream.getBytes();
  37623. imageStream.reset();
  37624. var a = 1;
  37625. var b = 0;
  37626. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  37627. a += imageBytes[i] & 0xff;
  37628. b += a;
  37629. }
  37630. adler32 = b % 65521 << 16 | a % 65521;
  37631. if (this.imageCache.adler32 === adler32) {
  37632. this.buf2 = Cmd.get('EI');
  37633. this.shift();
  37634. this.imageCache[adler32].reset();
  37635. return this.imageCache[adler32];
  37636. }
  37637. }
  37638. if (cipherTransform) {
  37639. imageStream = cipherTransform.createStream(imageStream, length);
  37640. }
  37641. imageStream = this.filter(imageStream, dict, length);
  37642. imageStream.dict = dict;
  37643. if (adler32 !== undefined) {
  37644. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  37645. this.imageCache[adler32] = imageStream;
  37646. }
  37647. this.buf2 = Cmd.get('EI');
  37648. this.shift();
  37649. return imageStream;
  37650. },
  37651. makeStream: function Parser_makeStream(dict, cipherTransform) {
  37652. var lexer = this.lexer;
  37653. var stream = lexer.stream;
  37654. lexer.skipToNextLine();
  37655. var pos = stream.pos - 1;
  37656. var length = dict.get('Length');
  37657. if (!isInt(length)) {
  37658. info('Bad ' + length + ' attribute in stream');
  37659. length = 0;
  37660. }
  37661. stream.pos = pos + length;
  37662. lexer.nextChar();
  37663. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  37664. this.shift();
  37665. } else
  37666. {
  37667. stream.pos = pos;
  37668. var SCAN_BLOCK_SIZE = 2048;
  37669. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  37670. var ENDSTREAM_SIGNATURE = [
  37671. 0x65,
  37672. 0x6E,
  37673. 0x64,
  37674. 0x73,
  37675. 0x74,
  37676. 0x72,
  37677. 0x65,
  37678. 0x61,
  37679. 0x6D
  37680. ];
  37681. var skipped = 0, found = false, i, j;
  37682. while (stream.pos < stream.end) {
  37683. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  37684. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  37685. if (scanLength <= 0) {
  37686. break;
  37687. }
  37688. found = false;
  37689. i = 0;
  37690. while (i < scanLength) {
  37691. j = 0;
  37692. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  37693. j++;
  37694. }
  37695. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  37696. found = true;
  37697. break;
  37698. }
  37699. i++;
  37700. }
  37701. if (found) {
  37702. skipped += i;
  37703. stream.pos += i;
  37704. break;
  37705. }
  37706. skipped += scanLength;
  37707. stream.pos += scanLength;
  37708. }
  37709. if (!found) {
  37710. error('Missing endstream');
  37711. }
  37712. length = skipped;
  37713. lexer.nextChar();
  37714. this.shift();
  37715. this.shift();
  37716. }
  37717. this.shift();
  37718. stream = stream.makeSubStream(pos, length, dict);
  37719. if (cipherTransform) {
  37720. stream = cipherTransform.createStream(stream, length);
  37721. }
  37722. stream = this.filter(stream, dict, length);
  37723. stream.dict = dict;
  37724. return stream;
  37725. },
  37726. filter: function Parser_filter(stream, dict, length) {
  37727. var filter = dict.get('Filter', 'F');
  37728. var params = dict.get('DecodeParms', 'DP');
  37729. if (isName(filter)) {
  37730. if (isArray(params)) {
  37731. params = params[0];
  37732. }
  37733. return this.makeFilter(stream, filter.name, length, params);
  37734. }
  37735. var maybeLength = length;
  37736. if (isArray(filter)) {
  37737. var filterArray = filter;
  37738. var paramsArray = params;
  37739. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  37740. filter = filterArray[i];
  37741. if (!isName(filter)) {
  37742. error('Bad filter name: ' + filter);
  37743. }
  37744. params = null;
  37745. if (isArray(paramsArray) && i in paramsArray) {
  37746. params = paramsArray[i];
  37747. }
  37748. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  37749. maybeLength = null;
  37750. }
  37751. }
  37752. return stream;
  37753. },
  37754. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  37755. if (maybeLength === 0) {
  37756. warn('Empty "' + name + '" stream.');
  37757. return new NullStream(stream);
  37758. }
  37759. try {
  37760. if (params && this.xref) {
  37761. params = this.xref.fetchIfRef(params);
  37762. }
  37763. var xrefStreamStats = this.xref.stats.streamTypes;
  37764. if (name === 'FlateDecode' || name === 'Fl') {
  37765. xrefStreamStats[StreamType.FLATE] = true;
  37766. if (params) {
  37767. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  37768. }
  37769. return new FlateStream(stream, maybeLength);
  37770. }
  37771. if (name === 'LZWDecode' || name === 'LZW') {
  37772. xrefStreamStats[StreamType.LZW] = true;
  37773. var earlyChange = 1;
  37774. if (params) {
  37775. if (params.has('EarlyChange')) {
  37776. earlyChange = params.get('EarlyChange');
  37777. }
  37778. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  37779. }
  37780. return new LZWStream(stream, maybeLength, earlyChange);
  37781. }
  37782. if (name === 'DCTDecode' || name === 'DCT') {
  37783. xrefStreamStats[StreamType.DCT] = true;
  37784. return new JpegStream(stream, maybeLength, stream.dict, params);
  37785. }
  37786. if (name === 'JPXDecode' || name === 'JPX') {
  37787. xrefStreamStats[StreamType.JPX] = true;
  37788. return new JpxStream(stream, maybeLength, stream.dict, params);
  37789. }
  37790. if (name === 'ASCII85Decode' || name === 'A85') {
  37791. xrefStreamStats[StreamType.A85] = true;
  37792. return new Ascii85Stream(stream, maybeLength);
  37793. }
  37794. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  37795. xrefStreamStats[StreamType.AHX] = true;
  37796. return new AsciiHexStream(stream, maybeLength);
  37797. }
  37798. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  37799. xrefStreamStats[StreamType.CCF] = true;
  37800. return new CCITTFaxStream(stream, maybeLength, params);
  37801. }
  37802. if (name === 'RunLengthDecode' || name === 'RL') {
  37803. xrefStreamStats[StreamType.RL] = true;
  37804. return new RunLengthStream(stream, maybeLength);
  37805. }
  37806. if (name === 'JBIG2Decode') {
  37807. xrefStreamStats[StreamType.JBIG] = true;
  37808. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  37809. }
  37810. warn('filter "' + name + '" not supported yet');
  37811. return stream;
  37812. } catch (ex) {
  37813. if (ex instanceof MissingDataException) {
  37814. throw ex;
  37815. }
  37816. warn('Invalid stream: \"' + ex + '\"');
  37817. return new NullStream(stream);
  37818. }
  37819. }
  37820. };
  37821. return Parser;
  37822. }();
  37823. var Lexer = function LexerClosure() {
  37824. function Lexer(stream, knownCommands) {
  37825. this.stream = stream;
  37826. this.nextChar();
  37827. this.strBuf = [];
  37828. this.knownCommands = knownCommands;
  37829. }
  37830. var specialChars = [
  37831. 1,
  37832. 0,
  37833. 0,
  37834. 0,
  37835. 0,
  37836. 0,
  37837. 0,
  37838. 0,
  37839. 0,
  37840. 1,
  37841. 1,
  37842. 0,
  37843. 1,
  37844. 1,
  37845. 0,
  37846. 0,
  37847. 0,
  37848. 0,
  37849. 0,
  37850. 0,
  37851. 0,
  37852. 0,
  37853. 0,
  37854. 0,
  37855. 0,
  37856. 0,
  37857. 0,
  37858. 0,
  37859. 0,
  37860. 0,
  37861. 0,
  37862. 0,
  37863. 1,
  37864. 0,
  37865. 0,
  37866. 0,
  37867. 0,
  37868. 2,
  37869. 0,
  37870. 0,
  37871. 2,
  37872. 2,
  37873. 0,
  37874. 0,
  37875. 0,
  37876. 0,
  37877. 0,
  37878. 2,
  37879. 0,
  37880. 0,
  37881. 0,
  37882. 0,
  37883. 0,
  37884. 0,
  37885. 0,
  37886. 0,
  37887. 0,
  37888. 0,
  37889. 0,
  37890. 0,
  37891. 2,
  37892. 0,
  37893. 2,
  37894. 0,
  37895. 0,
  37896. 0,
  37897. 0,
  37898. 0,
  37899. 0,
  37900. 0,
  37901. 0,
  37902. 0,
  37903. 0,
  37904. 0,
  37905. 0,
  37906. 0,
  37907. 0,
  37908. 0,
  37909. 0,
  37910. 0,
  37911. 0,
  37912. 0,
  37913. 0,
  37914. 0,
  37915. 0,
  37916. 0,
  37917. 0,
  37918. 0,
  37919. 0,
  37920. 0,
  37921. 0,
  37922. 2,
  37923. 0,
  37924. 2,
  37925. 0,
  37926. 0,
  37927. 0,
  37928. 0,
  37929. 0,
  37930. 0,
  37931. 0,
  37932. 0,
  37933. 0,
  37934. 0,
  37935. 0,
  37936. 0,
  37937. 0,
  37938. 0,
  37939. 0,
  37940. 0,
  37941. 0,
  37942. 0,
  37943. 0,
  37944. 0,
  37945. 0,
  37946. 0,
  37947. 0,
  37948. 0,
  37949. 0,
  37950. 0,
  37951. 0,
  37952. 0,
  37953. 0,
  37954. 2,
  37955. 0,
  37956. 2,
  37957. 0,
  37958. 0,
  37959. 0,
  37960. 0,
  37961. 0,
  37962. 0,
  37963. 0,
  37964. 0,
  37965. 0,
  37966. 0,
  37967. 0,
  37968. 0,
  37969. 0,
  37970. 0,
  37971. 0,
  37972. 0,
  37973. 0,
  37974. 0,
  37975. 0,
  37976. 0,
  37977. 0,
  37978. 0,
  37979. 0,
  37980. 0,
  37981. 0,
  37982. 0,
  37983. 0,
  37984. 0,
  37985. 0,
  37986. 0,
  37987. 0,
  37988. 0,
  37989. 0,
  37990. 0,
  37991. 0,
  37992. 0,
  37993. 0,
  37994. 0,
  37995. 0,
  37996. 0,
  37997. 0,
  37998. 0,
  37999. 0,
  38000. 0,
  38001. 0,
  38002. 0,
  38003. 0,
  38004. 0,
  38005. 0,
  38006. 0,
  38007. 0,
  38008. 0,
  38009. 0,
  38010. 0,
  38011. 0,
  38012. 0,
  38013. 0,
  38014. 0,
  38015. 0,
  38016. 0,
  38017. 0,
  38018. 0,
  38019. 0,
  38020. 0,
  38021. 0,
  38022. 0,
  38023. 0,
  38024. 0,
  38025. 0,
  38026. 0,
  38027. 0,
  38028. 0,
  38029. 0,
  38030. 0,
  38031. 0,
  38032. 0,
  38033. 0,
  38034. 0,
  38035. 0,
  38036. 0,
  38037. 0,
  38038. 0,
  38039. 0,
  38040. 0,
  38041. 0,
  38042. 0,
  38043. 0,
  38044. 0,
  38045. 0,
  38046. 0,
  38047. 0,
  38048. 0,
  38049. 0,
  38050. 0,
  38051. 0,
  38052. 0,
  38053. 0,
  38054. 0,
  38055. 0,
  38056. 0,
  38057. 0,
  38058. 0,
  38059. 0,
  38060. 0,
  38061. 0,
  38062. 0,
  38063. 0,
  38064. 0,
  38065. 0,
  38066. 0,
  38067. 0,
  38068. 0,
  38069. 0,
  38070. 0,
  38071. 0,
  38072. 0,
  38073. 0,
  38074. 0,
  38075. 0,
  38076. 0,
  38077. 0,
  38078. 0,
  38079. 0,
  38080. 0,
  38081. 0,
  38082. 0,
  38083. 0,
  38084. 0,
  38085. 0,
  38086. 0
  38087. ];
  38088. function toHexDigit(ch) {
  38089. if (ch >= 0x30 && ch <= 0x39) {
  38090. return ch & 0x0F;
  38091. }
  38092. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  38093. return (ch & 0x0F) + 9;
  38094. }
  38095. return -1;
  38096. }
  38097. Lexer.prototype = {
  38098. nextChar: function Lexer_nextChar() {
  38099. return this.currentChar = this.stream.getByte();
  38100. },
  38101. peekChar: function Lexer_peekChar() {
  38102. return this.stream.peekByte();
  38103. },
  38104. getNumber: function Lexer_getNumber() {
  38105. var ch = this.currentChar;
  38106. var eNotation = false;
  38107. var divideBy = 0;
  38108. var sign = 1;
  38109. if (ch === 0x2D) {
  38110. sign = -1;
  38111. ch = this.nextChar();
  38112. if (ch === 0x2D) {
  38113. ch = this.nextChar();
  38114. }
  38115. } else if (ch === 0x2B) {
  38116. ch = this.nextChar();
  38117. }
  38118. if (ch === 0x2E) {
  38119. divideBy = 10;
  38120. ch = this.nextChar();
  38121. }
  38122. if (ch < 0x30 || ch > 0x39) {
  38123. error('Invalid number: ' + String.fromCharCode(ch));
  38124. return 0;
  38125. }
  38126. var baseValue = ch - 0x30;
  38127. var powerValue = 0;
  38128. var powerValueSign = 1;
  38129. while ((ch = this.nextChar()) >= 0) {
  38130. if (0x30 <= ch && ch <= 0x39) {
  38131. var currentDigit = ch - 0x30;
  38132. if (eNotation) {
  38133. powerValue = powerValue * 10 + currentDigit;
  38134. } else {
  38135. if (divideBy !== 0) {
  38136. divideBy *= 10;
  38137. }
  38138. baseValue = baseValue * 10 + currentDigit;
  38139. }
  38140. } else if (ch === 0x2E) {
  38141. if (divideBy === 0) {
  38142. divideBy = 1;
  38143. } else {
  38144. break;
  38145. }
  38146. } else if (ch === 0x2D) {
  38147. warn('Badly formatted number');
  38148. } else if (ch === 0x45 || ch === 0x65) {
  38149. ch = this.peekChar();
  38150. if (ch === 0x2B || ch === 0x2D) {
  38151. powerValueSign = ch === 0x2D ? -1 : 1;
  38152. this.nextChar();
  38153. } else if (ch < 0x30 || ch > 0x39) {
  38154. break;
  38155. }
  38156. eNotation = true;
  38157. } else {
  38158. break;
  38159. }
  38160. }
  38161. if (divideBy !== 0) {
  38162. baseValue /= divideBy;
  38163. }
  38164. if (eNotation) {
  38165. baseValue *= Math.pow(10, powerValueSign * powerValue);
  38166. }
  38167. return sign * baseValue;
  38168. },
  38169. getString: function Lexer_getString() {
  38170. var numParen = 1;
  38171. var done = false;
  38172. var strBuf = this.strBuf;
  38173. strBuf.length = 0;
  38174. var ch = this.nextChar();
  38175. while (true) {
  38176. var charBuffered = false;
  38177. switch (ch | 0) {
  38178. case -1:
  38179. warn('Unterminated string');
  38180. done = true;
  38181. break;
  38182. case 0x28:
  38183. ++numParen;
  38184. strBuf.push('(');
  38185. break;
  38186. case 0x29:
  38187. if (--numParen === 0) {
  38188. this.nextChar();
  38189. done = true;
  38190. } else {
  38191. strBuf.push(')');
  38192. }
  38193. break;
  38194. case 0x5C:
  38195. ch = this.nextChar();
  38196. switch (ch) {
  38197. case -1:
  38198. warn('Unterminated string');
  38199. done = true;
  38200. break;
  38201. case 0x6E:
  38202. strBuf.push('\n');
  38203. break;
  38204. case 0x72:
  38205. strBuf.push('\r');
  38206. break;
  38207. case 0x74:
  38208. strBuf.push('\t');
  38209. break;
  38210. case 0x62:
  38211. strBuf.push('\b');
  38212. break;
  38213. case 0x66:
  38214. strBuf.push('\f');
  38215. break;
  38216. case 0x5C:
  38217. case 0x28:
  38218. case 0x29:
  38219. strBuf.push(String.fromCharCode(ch));
  38220. break;
  38221. case 0x30:
  38222. case 0x31:
  38223. case 0x32:
  38224. case 0x33:
  38225. case 0x34:
  38226. case 0x35:
  38227. case 0x36:
  38228. case 0x37:
  38229. var x = ch & 0x0F;
  38230. ch = this.nextChar();
  38231. charBuffered = true;
  38232. if (ch >= 0x30 && ch <= 0x37) {
  38233. x = (x << 3) + (ch & 0x0F);
  38234. ch = this.nextChar();
  38235. if (ch >= 0x30 && ch <= 0x37) {
  38236. charBuffered = false;
  38237. x = (x << 3) + (ch & 0x0F);
  38238. }
  38239. }
  38240. strBuf.push(String.fromCharCode(x));
  38241. break;
  38242. case 0x0D:
  38243. if (this.peekChar() === 0x0A) {
  38244. this.nextChar();
  38245. }
  38246. break;
  38247. case 0x0A:
  38248. break;
  38249. default:
  38250. strBuf.push(String.fromCharCode(ch));
  38251. break;
  38252. }
  38253. break;
  38254. default:
  38255. strBuf.push(String.fromCharCode(ch));
  38256. break;
  38257. }
  38258. if (done) {
  38259. break;
  38260. }
  38261. if (!charBuffered) {
  38262. ch = this.nextChar();
  38263. }
  38264. }
  38265. return strBuf.join('');
  38266. },
  38267. getName: function Lexer_getName() {
  38268. var ch, previousCh;
  38269. var strBuf = this.strBuf;
  38270. strBuf.length = 0;
  38271. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  38272. if (ch === 0x23) {
  38273. ch = this.nextChar();
  38274. if (specialChars[ch]) {
  38275. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  38276. strBuf.push('#');
  38277. break;
  38278. }
  38279. var x = toHexDigit(ch);
  38280. if (x !== -1) {
  38281. previousCh = ch;
  38282. ch = this.nextChar();
  38283. var x2 = toHexDigit(ch);
  38284. if (x2 === -1) {
  38285. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  38286. strBuf.push('#', String.fromCharCode(previousCh));
  38287. if (specialChars[ch]) {
  38288. break;
  38289. }
  38290. strBuf.push(String.fromCharCode(ch));
  38291. continue;
  38292. }
  38293. strBuf.push(String.fromCharCode(x << 4 | x2));
  38294. } else {
  38295. strBuf.push('#', String.fromCharCode(ch));
  38296. }
  38297. } else {
  38298. strBuf.push(String.fromCharCode(ch));
  38299. }
  38300. }
  38301. if (strBuf.length > 127) {
  38302. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  38303. }
  38304. return Name.get(strBuf.join(''));
  38305. },
  38306. getHexString: function Lexer_getHexString() {
  38307. var strBuf = this.strBuf;
  38308. strBuf.length = 0;
  38309. var ch = this.currentChar;
  38310. var isFirstHex = true;
  38311. var firstDigit;
  38312. var secondDigit;
  38313. while (true) {
  38314. if (ch < 0) {
  38315. warn('Unterminated hex string');
  38316. break;
  38317. } else if (ch === 0x3E) {
  38318. this.nextChar();
  38319. break;
  38320. } else if (specialChars[ch] === 1) {
  38321. ch = this.nextChar();
  38322. continue;
  38323. } else {
  38324. if (isFirstHex) {
  38325. firstDigit = toHexDigit(ch);
  38326. if (firstDigit === -1) {
  38327. warn('Ignoring invalid character "' + ch + '" in hex string');
  38328. ch = this.nextChar();
  38329. continue;
  38330. }
  38331. } else {
  38332. secondDigit = toHexDigit(ch);
  38333. if (secondDigit === -1) {
  38334. warn('Ignoring invalid character "' + ch + '" in hex string');
  38335. ch = this.nextChar();
  38336. continue;
  38337. }
  38338. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  38339. }
  38340. isFirstHex = !isFirstHex;
  38341. ch = this.nextChar();
  38342. }
  38343. }
  38344. return strBuf.join('');
  38345. },
  38346. getObj: function Lexer_getObj() {
  38347. var comment = false;
  38348. var ch = this.currentChar;
  38349. while (true) {
  38350. if (ch < 0) {
  38351. return EOF;
  38352. }
  38353. if (comment) {
  38354. if (ch === 0x0A || ch === 0x0D) {
  38355. comment = false;
  38356. }
  38357. } else if (ch === 0x25) {
  38358. comment = true;
  38359. } else if (specialChars[ch] !== 1) {
  38360. break;
  38361. }
  38362. ch = this.nextChar();
  38363. }
  38364. switch (ch | 0) {
  38365. case 0x30:
  38366. case 0x31:
  38367. case 0x32:
  38368. case 0x33:
  38369. case 0x34:
  38370. case 0x35:
  38371. case 0x36:
  38372. case 0x37:
  38373. case 0x38:
  38374. case 0x39:
  38375. case 0x2B:
  38376. case 0x2D:
  38377. case 0x2E:
  38378. return this.getNumber();
  38379. case 0x28:
  38380. return this.getString();
  38381. case 0x2F:
  38382. return this.getName();
  38383. case 0x5B:
  38384. this.nextChar();
  38385. return Cmd.get('[');
  38386. case 0x5D:
  38387. this.nextChar();
  38388. return Cmd.get(']');
  38389. case 0x3C:
  38390. ch = this.nextChar();
  38391. if (ch === 0x3C) {
  38392. this.nextChar();
  38393. return Cmd.get('<<');
  38394. }
  38395. return this.getHexString();
  38396. case 0x3E:
  38397. ch = this.nextChar();
  38398. if (ch === 0x3E) {
  38399. this.nextChar();
  38400. return Cmd.get('>>');
  38401. }
  38402. return Cmd.get('>');
  38403. case 0x7B:
  38404. this.nextChar();
  38405. return Cmd.get('{');
  38406. case 0x7D:
  38407. this.nextChar();
  38408. return Cmd.get('}');
  38409. case 0x29:
  38410. error('Illegal character: ' + ch);
  38411. break;
  38412. }
  38413. var str = String.fromCharCode(ch);
  38414. var knownCommands = this.knownCommands;
  38415. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  38416. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  38417. var possibleCommand = str + String.fromCharCode(ch);
  38418. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  38419. break;
  38420. }
  38421. if (str.length === 128) {
  38422. error('Command token too long: ' + str.length);
  38423. }
  38424. str = possibleCommand;
  38425. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  38426. }
  38427. if (str === 'true') {
  38428. return true;
  38429. }
  38430. if (str === 'false') {
  38431. return false;
  38432. }
  38433. if (str === 'null') {
  38434. return null;
  38435. }
  38436. return Cmd.get(str);
  38437. },
  38438. skipToNextLine: function Lexer_skipToNextLine() {
  38439. var ch = this.currentChar;
  38440. while (ch >= 0) {
  38441. if (ch === 0x0D) {
  38442. ch = this.nextChar();
  38443. if (ch === 0x0A) {
  38444. this.nextChar();
  38445. }
  38446. break;
  38447. } else if (ch === 0x0A) {
  38448. this.nextChar();
  38449. break;
  38450. }
  38451. ch = this.nextChar();
  38452. }
  38453. }
  38454. };
  38455. return Lexer;
  38456. }();
  38457. var Linearization = {
  38458. create: function LinearizationCreate(stream) {
  38459. function getInt(name, allowZeroValue) {
  38460. var obj = linDict.get(name);
  38461. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  38462. return obj;
  38463. }
  38464. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  38465. }
  38466. function getHints() {
  38467. var hints = linDict.get('H'), hintsLength, item;
  38468. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  38469. for (var index = 0; index < hintsLength; index++) {
  38470. if (!(isInt(item = hints[index]) && item > 0)) {
  38471. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  38472. }
  38473. }
  38474. return hints;
  38475. }
  38476. throw new Error('Hint array in the linearization dictionary is invalid.');
  38477. }
  38478. var parser = new Parser(new Lexer(stream), false, null);
  38479. var obj1 = parser.getObj();
  38480. var obj2 = parser.getObj();
  38481. var obj3 = parser.getObj();
  38482. var linDict = parser.getObj();
  38483. var obj, length;
  38484. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  38485. return null;
  38486. } else if ((length = getInt('L')) !== stream.length) {
  38487. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  38488. }
  38489. return {
  38490. length: length,
  38491. hints: getHints(),
  38492. objectNumberFirst: getInt('O'),
  38493. endFirst: getInt('E'),
  38494. numPages: getInt('N'),
  38495. mainXRefEntriesOffset: getInt('T'),
  38496. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  38497. };
  38498. }
  38499. };
  38500. exports.EOF = EOF;
  38501. exports.Lexer = Lexer;
  38502. exports.Linearization = Linearization;
  38503. exports.Parser = Parser;
  38504. exports.isEOF = isEOF;
  38505. }));
  38506. (function (root, factory) {
  38507. factory(root.pdfjsCoreType1Parser = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreEncodings);
  38508. }(this, function (exports, sharedUtil, coreStream, coreEncodings) {
  38509. var warn = sharedUtil.warn;
  38510. var isSpace = sharedUtil.isSpace;
  38511. var Stream = coreStream.Stream;
  38512. var getEncoding = coreEncodings.getEncoding;
  38513. var HINTING_ENABLED = false;
  38514. var Type1CharString = function Type1CharStringClosure() {
  38515. var COMMAND_MAP = {
  38516. 'hstem': [1],
  38517. 'vstem': [3],
  38518. 'vmoveto': [4],
  38519. 'rlineto': [5],
  38520. 'hlineto': [6],
  38521. 'vlineto': [7],
  38522. 'rrcurveto': [8],
  38523. 'callsubr': [10],
  38524. 'flex': [
  38525. 12,
  38526. 35
  38527. ],
  38528. 'drop': [
  38529. 12,
  38530. 18
  38531. ],
  38532. 'endchar': [14],
  38533. 'rmoveto': [21],
  38534. 'hmoveto': [22],
  38535. 'vhcurveto': [30],
  38536. 'hvcurveto': [31]
  38537. };
  38538. function Type1CharString() {
  38539. this.width = 0;
  38540. this.lsb = 0;
  38541. this.flexing = false;
  38542. this.output = [];
  38543. this.stack = [];
  38544. }
  38545. Type1CharString.prototype = {
  38546. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  38547. var count = encoded.length;
  38548. var error = false;
  38549. var wx, sbx, subrNumber;
  38550. for (var i = 0; i < count; i++) {
  38551. var value = encoded[i];
  38552. if (value < 32) {
  38553. if (value === 12) {
  38554. value = (value << 8) + encoded[++i];
  38555. }
  38556. switch (value) {
  38557. case 1:
  38558. if (!HINTING_ENABLED) {
  38559. this.stack = [];
  38560. break;
  38561. }
  38562. error = this.executeCommand(2, COMMAND_MAP.hstem);
  38563. break;
  38564. case 3:
  38565. if (!HINTING_ENABLED) {
  38566. this.stack = [];
  38567. break;
  38568. }
  38569. error = this.executeCommand(2, COMMAND_MAP.vstem);
  38570. break;
  38571. case 4:
  38572. if (this.flexing) {
  38573. if (this.stack.length < 1) {
  38574. error = true;
  38575. break;
  38576. }
  38577. var dy = this.stack.pop();
  38578. this.stack.push(0, dy);
  38579. break;
  38580. }
  38581. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  38582. break;
  38583. case 5:
  38584. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  38585. break;
  38586. case 6:
  38587. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  38588. break;
  38589. case 7:
  38590. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  38591. break;
  38592. case 8:
  38593. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  38594. break;
  38595. case 9:
  38596. this.stack = [];
  38597. break;
  38598. case 10:
  38599. if (this.stack.length < 1) {
  38600. error = true;
  38601. break;
  38602. }
  38603. subrNumber = this.stack.pop();
  38604. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  38605. break;
  38606. case 11:
  38607. return error;
  38608. case 13:
  38609. if (this.stack.length < 2) {
  38610. error = true;
  38611. break;
  38612. }
  38613. wx = this.stack.pop();
  38614. sbx = this.stack.pop();
  38615. this.lsb = sbx;
  38616. this.width = wx;
  38617. this.stack.push(wx, sbx);
  38618. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  38619. break;
  38620. case 14:
  38621. this.output.push(COMMAND_MAP.endchar[0]);
  38622. break;
  38623. case 21:
  38624. if (this.flexing) {
  38625. break;
  38626. }
  38627. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  38628. break;
  38629. case 22:
  38630. if (this.flexing) {
  38631. this.stack.push(0);
  38632. break;
  38633. }
  38634. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  38635. break;
  38636. case 30:
  38637. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  38638. break;
  38639. case 31:
  38640. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  38641. break;
  38642. case (12 << 8) + 0:
  38643. this.stack = [];
  38644. break;
  38645. case (12 << 8) + 1:
  38646. if (!HINTING_ENABLED) {
  38647. this.stack = [];
  38648. break;
  38649. }
  38650. error = this.executeCommand(2, COMMAND_MAP.vstem);
  38651. break;
  38652. case (12 << 8) + 2:
  38653. if (!HINTING_ENABLED) {
  38654. this.stack = [];
  38655. break;
  38656. }
  38657. error = this.executeCommand(2, COMMAND_MAP.hstem);
  38658. break;
  38659. case (12 << 8) + 6:
  38660. if (seacAnalysisEnabled) {
  38661. this.seac = this.stack.splice(-4, 4);
  38662. error = this.executeCommand(0, COMMAND_MAP.endchar);
  38663. } else {
  38664. error = this.executeCommand(4, COMMAND_MAP.endchar);
  38665. }
  38666. break;
  38667. case (12 << 8) + 7:
  38668. if (this.stack.length < 4) {
  38669. error = true;
  38670. break;
  38671. }
  38672. var wy = this.stack.pop();
  38673. wx = this.stack.pop();
  38674. var sby = this.stack.pop();
  38675. sbx = this.stack.pop();
  38676. this.lsb = sbx;
  38677. this.width = wx;
  38678. this.stack.push(wx, sbx, sby);
  38679. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  38680. break;
  38681. case (12 << 8) + 12:
  38682. if (this.stack.length < 2) {
  38683. error = true;
  38684. break;
  38685. }
  38686. var num2 = this.stack.pop();
  38687. var num1 = this.stack.pop();
  38688. this.stack.push(num1 / num2);
  38689. break;
  38690. case (12 << 8) + 16:
  38691. if (this.stack.length < 2) {
  38692. error = true;
  38693. break;
  38694. }
  38695. subrNumber = this.stack.pop();
  38696. var numArgs = this.stack.pop();
  38697. if (subrNumber === 0 && numArgs === 3) {
  38698. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  38699. 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]);
  38700. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  38701. this.flexing = false;
  38702. this.stack.push(flexArgs[15], flexArgs[16]);
  38703. } else if (subrNumber === 1 && numArgs === 0) {
  38704. this.flexing = true;
  38705. }
  38706. break;
  38707. case (12 << 8) + 17:
  38708. break;
  38709. case (12 << 8) + 33:
  38710. this.stack = [];
  38711. break;
  38712. default:
  38713. warn('Unknown type 1 charstring command of "' + value + '"');
  38714. break;
  38715. }
  38716. if (error) {
  38717. break;
  38718. }
  38719. continue;
  38720. } else if (value <= 246) {
  38721. value = value - 139;
  38722. } else if (value <= 250) {
  38723. value = (value - 247) * 256 + encoded[++i] + 108;
  38724. } else if (value <= 254) {
  38725. value = -((value - 251) * 256) - encoded[++i] - 108;
  38726. } else {
  38727. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  38728. }
  38729. this.stack.push(value);
  38730. }
  38731. return error;
  38732. },
  38733. executeCommand: function (howManyArgs, command, keepStack) {
  38734. var stackLength = this.stack.length;
  38735. if (howManyArgs > stackLength) {
  38736. return true;
  38737. }
  38738. var start = stackLength - howManyArgs;
  38739. for (var i = start; i < stackLength; i++) {
  38740. var value = this.stack[i];
  38741. if (value === (value | 0)) {
  38742. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  38743. } else {
  38744. value = 65536 * value | 0;
  38745. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  38746. }
  38747. }
  38748. this.output.push.apply(this.output, command);
  38749. if (keepStack) {
  38750. this.stack.splice(start, howManyArgs);
  38751. } else {
  38752. this.stack.length = 0;
  38753. }
  38754. return false;
  38755. }
  38756. };
  38757. return Type1CharString;
  38758. }();
  38759. var Type1Parser = function Type1ParserClosure() {
  38760. var EEXEC_ENCRYPT_KEY = 55665;
  38761. var CHAR_STRS_ENCRYPT_KEY = 4330;
  38762. function isHexDigit(code) {
  38763. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  38764. }
  38765. function decrypt(data, key, discardNumber) {
  38766. if (discardNumber >= data.length) {
  38767. return new Uint8Array(0);
  38768. }
  38769. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  38770. for (i = 0; i < discardNumber; i++) {
  38771. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  38772. }
  38773. var count = data.length - discardNumber;
  38774. var decrypted = new Uint8Array(count);
  38775. for (i = discardNumber, j = 0; j < count; i++, j++) {
  38776. var value = data[i];
  38777. decrypted[j] = value ^ r >> 8;
  38778. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  38779. }
  38780. return decrypted;
  38781. }
  38782. function decryptAscii(data, key, discardNumber) {
  38783. var r = key | 0, c1 = 52845, c2 = 22719;
  38784. var count = data.length, maybeLength = count >>> 1;
  38785. var decrypted = new Uint8Array(maybeLength);
  38786. var i, j;
  38787. for (i = 0, j = 0; i < count; i++) {
  38788. var digit1 = data[i];
  38789. if (!isHexDigit(digit1)) {
  38790. continue;
  38791. }
  38792. i++;
  38793. var digit2;
  38794. while (i < count && !isHexDigit(digit2 = data[i])) {
  38795. i++;
  38796. }
  38797. if (i < count) {
  38798. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  38799. decrypted[j++] = value ^ r >> 8;
  38800. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  38801. }
  38802. }
  38803. return Array.prototype.slice.call(decrypted, discardNumber, j);
  38804. }
  38805. function isSpecial(c) {
  38806. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  38807. }
  38808. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  38809. if (encrypted) {
  38810. var data = stream.getBytes();
  38811. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  38812. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  38813. }
  38814. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  38815. this.stream = stream;
  38816. this.nextChar();
  38817. }
  38818. Type1Parser.prototype = {
  38819. readNumberArray: function Type1Parser_readNumberArray() {
  38820. this.getToken();
  38821. var array = [];
  38822. while (true) {
  38823. var token = this.getToken();
  38824. if (token === null || token === ']' || token === '}') {
  38825. break;
  38826. }
  38827. array.push(parseFloat(token || 0));
  38828. }
  38829. return array;
  38830. },
  38831. readNumber: function Type1Parser_readNumber() {
  38832. var token = this.getToken();
  38833. return parseFloat(token || 0);
  38834. },
  38835. readInt: function Type1Parser_readInt() {
  38836. var token = this.getToken();
  38837. return parseInt(token || 0, 10) | 0;
  38838. },
  38839. readBoolean: function Type1Parser_readBoolean() {
  38840. var token = this.getToken();
  38841. return token === 'true' ? 1 : 0;
  38842. },
  38843. nextChar: function Type1_nextChar() {
  38844. return this.currentChar = this.stream.getByte();
  38845. },
  38846. getToken: function Type1Parser_getToken() {
  38847. var comment = false;
  38848. var ch = this.currentChar;
  38849. while (true) {
  38850. if (ch === -1) {
  38851. return null;
  38852. }
  38853. if (comment) {
  38854. if (ch === 0x0A || ch === 0x0D) {
  38855. comment = false;
  38856. }
  38857. } else if (ch === 0x25) {
  38858. comment = true;
  38859. } else if (!isSpace(ch)) {
  38860. break;
  38861. }
  38862. ch = this.nextChar();
  38863. }
  38864. if (isSpecial(ch)) {
  38865. this.nextChar();
  38866. return String.fromCharCode(ch);
  38867. }
  38868. var token = '';
  38869. do {
  38870. token += String.fromCharCode(ch);
  38871. ch = this.nextChar();
  38872. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  38873. return token;
  38874. },
  38875. extractFontProgram: function Type1Parser_extractFontProgram() {
  38876. var stream = this.stream;
  38877. var subrs = [], charstrings = [];
  38878. var privateData = Object.create(null);
  38879. privateData['lenIV'] = 4;
  38880. var program = {
  38881. subrs: [],
  38882. charstrings: [],
  38883. properties: { 'privateData': privateData }
  38884. };
  38885. var token, length, data, lenIV, encoded;
  38886. while ((token = this.getToken()) !== null) {
  38887. if (token !== '/') {
  38888. continue;
  38889. }
  38890. token = this.getToken();
  38891. switch (token) {
  38892. case 'CharStrings':
  38893. this.getToken();
  38894. this.getToken();
  38895. this.getToken();
  38896. this.getToken();
  38897. while (true) {
  38898. token = this.getToken();
  38899. if (token === null || token === 'end') {
  38900. break;
  38901. }
  38902. if (token !== '/') {
  38903. continue;
  38904. }
  38905. var glyph = this.getToken();
  38906. length = this.readInt();
  38907. this.getToken();
  38908. data = stream.makeSubStream(stream.pos, length);
  38909. lenIV = program.properties.privateData['lenIV'];
  38910. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  38911. stream.skip(length);
  38912. this.nextChar();
  38913. token = this.getToken();
  38914. if (token === 'noaccess') {
  38915. this.getToken();
  38916. }
  38917. charstrings.push({
  38918. glyph: glyph,
  38919. encoded: encoded
  38920. });
  38921. }
  38922. break;
  38923. case 'Subrs':
  38924. var num = this.readInt();
  38925. this.getToken();
  38926. while ((token = this.getToken()) === 'dup') {
  38927. var index = this.readInt();
  38928. length = this.readInt();
  38929. this.getToken();
  38930. data = stream.makeSubStream(stream.pos, length);
  38931. lenIV = program.properties.privateData['lenIV'];
  38932. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  38933. stream.skip(length);
  38934. this.nextChar();
  38935. token = this.getToken();
  38936. if (token === 'noaccess') {
  38937. this.getToken();
  38938. }
  38939. subrs[index] = encoded;
  38940. }
  38941. break;
  38942. case 'BlueValues':
  38943. case 'OtherBlues':
  38944. case 'FamilyBlues':
  38945. case 'FamilyOtherBlues':
  38946. var blueArray = this.readNumberArray();
  38947. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  38948. program.properties.privateData[token] = blueArray;
  38949. }
  38950. break;
  38951. case 'StemSnapH':
  38952. case 'StemSnapV':
  38953. program.properties.privateData[token] = this.readNumberArray();
  38954. break;
  38955. case 'StdHW':
  38956. case 'StdVW':
  38957. program.properties.privateData[token] = this.readNumberArray()[0];
  38958. break;
  38959. case 'BlueShift':
  38960. case 'lenIV':
  38961. case 'BlueFuzz':
  38962. case 'BlueScale':
  38963. case 'LanguageGroup':
  38964. case 'ExpansionFactor':
  38965. program.properties.privateData[token] = this.readNumber();
  38966. break;
  38967. case 'ForceBold':
  38968. program.properties.privateData[token] = this.readBoolean();
  38969. break;
  38970. }
  38971. }
  38972. for (var i = 0; i < charstrings.length; i++) {
  38973. glyph = charstrings[i].glyph;
  38974. encoded = charstrings[i].encoded;
  38975. var charString = new Type1CharString();
  38976. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  38977. var output = charString.output;
  38978. if (error) {
  38979. output = [14];
  38980. }
  38981. program.charstrings.push({
  38982. glyphName: glyph,
  38983. charstring: output,
  38984. width: charString.width,
  38985. lsb: charString.lsb,
  38986. seac: charString.seac
  38987. });
  38988. }
  38989. return program;
  38990. },
  38991. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  38992. var token;
  38993. while ((token = this.getToken()) !== null) {
  38994. if (token !== '/') {
  38995. continue;
  38996. }
  38997. token = this.getToken();
  38998. switch (token) {
  38999. case 'FontMatrix':
  39000. var matrix = this.readNumberArray();
  39001. properties.fontMatrix = matrix;
  39002. break;
  39003. case 'Encoding':
  39004. var encodingArg = this.getToken();
  39005. var encoding;
  39006. if (!/^\d+$/.test(encodingArg)) {
  39007. encoding = getEncoding(encodingArg);
  39008. } else {
  39009. encoding = [];
  39010. var size = parseInt(encodingArg, 10) | 0;
  39011. this.getToken();
  39012. for (var j = 0; j < size; j++) {
  39013. token = this.getToken();
  39014. while (token !== 'dup' && token !== 'def') {
  39015. token = this.getToken();
  39016. if (token === null) {
  39017. return;
  39018. }
  39019. }
  39020. if (token === 'def') {
  39021. break;
  39022. }
  39023. var index = this.readInt();
  39024. this.getToken();
  39025. var glyph = this.getToken();
  39026. encoding[index] = glyph;
  39027. this.getToken();
  39028. }
  39029. }
  39030. properties.builtInEncoding = encoding;
  39031. break;
  39032. case 'FontBBox':
  39033. var fontBBox = this.readNumberArray();
  39034. properties.ascent = fontBBox[3];
  39035. properties.descent = fontBBox[1];
  39036. properties.ascentScaled = true;
  39037. break;
  39038. }
  39039. }
  39040. }
  39041. };
  39042. return Type1Parser;
  39043. }();
  39044. exports.Type1Parser = Type1Parser;
  39045. }));
  39046. (function (root, factory) {
  39047. factory(root.pdfjsDisplayPatternHelper = {}, root.pdfjsSharedUtil, root.pdfjsDisplayWebGL);
  39048. }(this, function (exports, sharedUtil, displayWebGL) {
  39049. var Util = sharedUtil.Util;
  39050. var info = sharedUtil.info;
  39051. var isArray = sharedUtil.isArray;
  39052. var error = sharedUtil.error;
  39053. var WebGLUtils = displayWebGL.WebGLUtils;
  39054. var ShadingIRs = {};
  39055. ShadingIRs.RadialAxial = {
  39056. fromIR: function RadialAxial_fromIR(raw) {
  39057. var type = raw[1];
  39058. var colorStops = raw[2];
  39059. var p0 = raw[3];
  39060. var p1 = raw[4];
  39061. var r0 = raw[5];
  39062. var r1 = raw[6];
  39063. return {
  39064. type: 'Pattern',
  39065. getPattern: function RadialAxial_getPattern(ctx) {
  39066. var grad;
  39067. if (type === 'axial') {
  39068. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  39069. } else if (type === 'radial') {
  39070. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  39071. }
  39072. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  39073. var c = colorStops[i];
  39074. grad.addColorStop(c[0], c[1]);
  39075. }
  39076. return grad;
  39077. }
  39078. };
  39079. }
  39080. };
  39081. var createMeshCanvas = function createMeshCanvasClosure() {
  39082. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  39083. var coords = context.coords, colors = context.colors;
  39084. var bytes = data.data, rowSize = data.width * 4;
  39085. var tmp;
  39086. if (coords[p1 + 1] > coords[p2 + 1]) {
  39087. tmp = p1;
  39088. p1 = p2;
  39089. p2 = tmp;
  39090. tmp = c1;
  39091. c1 = c2;
  39092. c2 = tmp;
  39093. }
  39094. if (coords[p2 + 1] > coords[p3 + 1]) {
  39095. tmp = p2;
  39096. p2 = p3;
  39097. p3 = tmp;
  39098. tmp = c2;
  39099. c2 = c3;
  39100. c3 = tmp;
  39101. }
  39102. if (coords[p1 + 1] > coords[p2 + 1]) {
  39103. tmp = p1;
  39104. p1 = p2;
  39105. p2 = tmp;
  39106. tmp = c1;
  39107. c1 = c2;
  39108. c2 = tmp;
  39109. }
  39110. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  39111. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  39112. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  39113. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  39114. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  39115. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  39116. if (y1 >= y3) {
  39117. return;
  39118. }
  39119. var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
  39120. var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
  39121. var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
  39122. var minY = Math.round(y1), maxY = Math.round(y3);
  39123. var xa, car, cag, cab;
  39124. var xb, cbr, cbg, cbb;
  39125. var k;
  39126. for (var y = minY; y <= maxY; y++) {
  39127. if (y < y2) {
  39128. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  39129. xa = x1 - (x1 - x2) * k;
  39130. car = c1r - (c1r - c2r) * k;
  39131. cag = c1g - (c1g - c2g) * k;
  39132. cab = c1b - (c1b - c2b) * k;
  39133. } else {
  39134. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  39135. xa = x2 - (x2 - x3) * k;
  39136. car = c2r - (c2r - c3r) * k;
  39137. cag = c2g - (c2g - c3g) * k;
  39138. cab = c2b - (c2b - c3b) * k;
  39139. }
  39140. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  39141. xb = x1 - (x1 - x3) * k;
  39142. cbr = c1r - (c1r - c3r) * k;
  39143. cbg = c1g - (c1g - c3g) * k;
  39144. cbb = c1b - (c1b - c3b) * k;
  39145. var x1_ = Math.round(Math.min(xa, xb));
  39146. var x2_ = Math.round(Math.max(xa, xb));
  39147. var j = rowSize * y + x1_ * 4;
  39148. for (var x = x1_; x <= x2_; x++) {
  39149. k = (xa - x) / (xa - xb);
  39150. k = k < 0 ? 0 : k > 1 ? 1 : k;
  39151. bytes[j++] = car - (car - cbr) * k | 0;
  39152. bytes[j++] = cag - (cag - cbg) * k | 0;
  39153. bytes[j++] = cab - (cab - cbb) * k | 0;
  39154. bytes[j++] = 255;
  39155. }
  39156. }
  39157. }
  39158. function drawFigure(data, figure, context) {
  39159. var ps = figure.coords;
  39160. var cs = figure.colors;
  39161. var i, ii;
  39162. switch (figure.type) {
  39163. case 'lattice':
  39164. var verticesPerRow = figure.verticesPerRow;
  39165. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  39166. var cols = verticesPerRow - 1;
  39167. for (i = 0; i < rows; i++) {
  39168. var q = i * verticesPerRow;
  39169. for (var j = 0; j < cols; j++, q++) {
  39170. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  39171. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  39172. }
  39173. }
  39174. break;
  39175. case 'triangles':
  39176. for (i = 0, ii = ps.length; i < ii; i += 3) {
  39177. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  39178. }
  39179. break;
  39180. default:
  39181. error('illigal figure');
  39182. break;
  39183. }
  39184. }
  39185. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  39186. var EXPECTED_SCALE = 1.1;
  39187. var MAX_PATTERN_SIZE = 3000;
  39188. var BORDER_SIZE = 2;
  39189. var offsetX = Math.floor(bounds[0]);
  39190. var offsetY = Math.floor(bounds[1]);
  39191. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  39192. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  39193. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  39194. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  39195. var scaleX = boundsWidth / width;
  39196. var scaleY = boundsHeight / height;
  39197. var context = {
  39198. coords: coords,
  39199. colors: colors,
  39200. offsetX: -offsetX,
  39201. offsetY: -offsetY,
  39202. scaleX: 1 / scaleX,
  39203. scaleY: 1 / scaleY
  39204. };
  39205. var paddedWidth = width + BORDER_SIZE * 2;
  39206. var paddedHeight = height + BORDER_SIZE * 2;
  39207. var canvas, tmpCanvas, i, ii;
  39208. if (WebGLUtils.isEnabled) {
  39209. canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  39210. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  39211. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  39212. canvas = tmpCanvas.canvas;
  39213. } else {
  39214. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  39215. var tmpCtx = tmpCanvas.context;
  39216. var data = tmpCtx.createImageData(width, height);
  39217. if (backgroundColor) {
  39218. var bytes = data.data;
  39219. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  39220. bytes[i] = backgroundColor[0];
  39221. bytes[i + 1] = backgroundColor[1];
  39222. bytes[i + 2] = backgroundColor[2];
  39223. bytes[i + 3] = 255;
  39224. }
  39225. }
  39226. for (i = 0; i < figures.length; i++) {
  39227. drawFigure(data, figures[i], context);
  39228. }
  39229. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  39230. canvas = tmpCanvas.canvas;
  39231. }
  39232. return {
  39233. canvas: canvas,
  39234. offsetX: offsetX - BORDER_SIZE * scaleX,
  39235. offsetY: offsetY - BORDER_SIZE * scaleY,
  39236. scaleX: scaleX,
  39237. scaleY: scaleY
  39238. };
  39239. }
  39240. return createMeshCanvas;
  39241. }();
  39242. ShadingIRs.Mesh = {
  39243. fromIR: function Mesh_fromIR(raw) {
  39244. var coords = raw[2];
  39245. var colors = raw[3];
  39246. var figures = raw[4];
  39247. var bounds = raw[5];
  39248. var matrix = raw[6];
  39249. var background = raw[8];
  39250. return {
  39251. type: 'Pattern',
  39252. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  39253. var scale;
  39254. if (shadingFill) {
  39255. scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  39256. } else {
  39257. scale = Util.singularValueDecompose2dScale(owner.baseTransform);
  39258. if (matrix) {
  39259. var matrixScale = Util.singularValueDecompose2dScale(matrix);
  39260. scale = [
  39261. scale[0] * matrixScale[0],
  39262. scale[1] * matrixScale[1]
  39263. ];
  39264. }
  39265. }
  39266. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  39267. if (!shadingFill) {
  39268. ctx.setTransform.apply(ctx, owner.baseTransform);
  39269. if (matrix) {
  39270. ctx.transform.apply(ctx, matrix);
  39271. }
  39272. }
  39273. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  39274. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  39275. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  39276. }
  39277. };
  39278. }
  39279. };
  39280. ShadingIRs.Dummy = {
  39281. fromIR: function Dummy_fromIR() {
  39282. return {
  39283. type: 'Pattern',
  39284. getPattern: function Dummy_fromIR_getPattern() {
  39285. return 'hotpink';
  39286. }
  39287. };
  39288. }
  39289. };
  39290. function getShadingPatternFromIR(raw) {
  39291. var shadingIR = ShadingIRs[raw[0]];
  39292. if (!shadingIR) {
  39293. error('Unknown IR type: ' + raw[0]);
  39294. }
  39295. return shadingIR.fromIR(raw);
  39296. }
  39297. var TilingPattern = function TilingPatternClosure() {
  39298. var PaintType = {
  39299. COLORED: 1,
  39300. UNCOLORED: 2
  39301. };
  39302. var MAX_PATTERN_SIZE = 3000;
  39303. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  39304. this.operatorList = IR[2];
  39305. this.matrix = IR[3] || [
  39306. 1,
  39307. 0,
  39308. 0,
  39309. 1,
  39310. 0,
  39311. 0
  39312. ];
  39313. this.bbox = IR[4];
  39314. this.xstep = IR[5];
  39315. this.ystep = IR[6];
  39316. this.paintType = IR[7];
  39317. this.tilingType = IR[8];
  39318. this.color = color;
  39319. this.canvasGraphicsFactory = canvasGraphicsFactory;
  39320. this.baseTransform = baseTransform;
  39321. this.type = 'Pattern';
  39322. this.ctx = ctx;
  39323. }
  39324. TilingPattern.prototype = {
  39325. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  39326. var operatorList = this.operatorList;
  39327. var bbox = this.bbox;
  39328. var xstep = this.xstep;
  39329. var ystep = this.ystep;
  39330. var paintType = this.paintType;
  39331. var tilingType = this.tilingType;
  39332. var color = this.color;
  39333. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  39334. info('TilingType: ' + tilingType);
  39335. var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
  39336. var topLeft = [
  39337. x0,
  39338. y0
  39339. ];
  39340. var botRight = [
  39341. x0 + xstep,
  39342. y0 + ystep
  39343. ];
  39344. var width = botRight[0] - topLeft[0];
  39345. var height = botRight[1] - topLeft[1];
  39346. var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
  39347. var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
  39348. var combinedScale = [
  39349. matrixScale[0] * curMatrixScale[0],
  39350. matrixScale[1] * curMatrixScale[1]
  39351. ];
  39352. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  39353. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  39354. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  39355. var tmpCtx = tmpCanvas.context;
  39356. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  39357. graphics.groupLevel = owner.groupLevel;
  39358. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  39359. this.setScale(width, height, xstep, ystep);
  39360. this.transformToScale(graphics);
  39361. var tmpTranslate = [
  39362. 1,
  39363. 0,
  39364. 0,
  39365. 1,
  39366. -topLeft[0],
  39367. -topLeft[1]
  39368. ];
  39369. graphics.transform.apply(graphics, tmpTranslate);
  39370. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  39371. graphics.executeOperatorList(operatorList);
  39372. return tmpCanvas.canvas;
  39373. },
  39374. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  39375. this.scale = [
  39376. width / xstep,
  39377. height / ystep
  39378. ];
  39379. },
  39380. transformToScale: function TilingPattern_transformToScale(graphics) {
  39381. var scale = this.scale;
  39382. var tmpScale = [
  39383. scale[0],
  39384. 0,
  39385. 0,
  39386. scale[1],
  39387. 0,
  39388. 0
  39389. ];
  39390. graphics.transform.apply(graphics, tmpScale);
  39391. },
  39392. scaleToContext: function TilingPattern_scaleToContext() {
  39393. var scale = this.scale;
  39394. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  39395. },
  39396. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  39397. if (bbox && isArray(bbox) && bbox.length === 4) {
  39398. var bboxWidth = x1 - x0;
  39399. var bboxHeight = y1 - y0;
  39400. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  39401. graphics.clip();
  39402. graphics.endPath();
  39403. }
  39404. },
  39405. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  39406. switch (paintType) {
  39407. case PaintType.COLORED:
  39408. var ctx = this.ctx;
  39409. context.fillStyle = ctx.fillStyle;
  39410. context.strokeStyle = ctx.strokeStyle;
  39411. break;
  39412. case PaintType.UNCOLORED:
  39413. var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
  39414. context.fillStyle = cssColor;
  39415. context.strokeStyle = cssColor;
  39416. break;
  39417. default:
  39418. error('Unsupported paint type: ' + paintType);
  39419. }
  39420. },
  39421. getPattern: function TilingPattern_getPattern(ctx, owner) {
  39422. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  39423. ctx = this.ctx;
  39424. ctx.setTransform.apply(ctx, this.baseTransform);
  39425. ctx.transform.apply(ctx, this.matrix);
  39426. this.scaleToContext();
  39427. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  39428. }
  39429. };
  39430. return TilingPattern;
  39431. }();
  39432. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  39433. exports.TilingPattern = TilingPattern;
  39434. }));
  39435. (function (root, factory) {
  39436. factory(root.pdfjsCoreCMap = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreParser);
  39437. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser) {
  39438. var Util = sharedUtil.Util;
  39439. var assert = sharedUtil.assert;
  39440. var warn = sharedUtil.warn;
  39441. var error = sharedUtil.error;
  39442. var isInt = sharedUtil.isInt;
  39443. var isString = sharedUtil.isString;
  39444. var MissingDataException = sharedUtil.MissingDataException;
  39445. var isName = corePrimitives.isName;
  39446. var isCmd = corePrimitives.isCmd;
  39447. var isStream = corePrimitives.isStream;
  39448. var StringStream = coreStream.StringStream;
  39449. var Lexer = coreParser.Lexer;
  39450. var isEOF = coreParser.isEOF;
  39451. var BUILT_IN_CMAPS = [
  39452. 'Adobe-GB1-UCS2',
  39453. 'Adobe-CNS1-UCS2',
  39454. 'Adobe-Japan1-UCS2',
  39455. 'Adobe-Korea1-UCS2',
  39456. '78-EUC-H',
  39457. '78-EUC-V',
  39458. '78-H',
  39459. '78-RKSJ-H',
  39460. '78-RKSJ-V',
  39461. '78-V',
  39462. '78ms-RKSJ-H',
  39463. '78ms-RKSJ-V',
  39464. '83pv-RKSJ-H',
  39465. '90ms-RKSJ-H',
  39466. '90ms-RKSJ-V',
  39467. '90msp-RKSJ-H',
  39468. '90msp-RKSJ-V',
  39469. '90pv-RKSJ-H',
  39470. '90pv-RKSJ-V',
  39471. 'Add-H',
  39472. 'Add-RKSJ-H',
  39473. 'Add-RKSJ-V',
  39474. 'Add-V',
  39475. 'Adobe-CNS1-0',
  39476. 'Adobe-CNS1-1',
  39477. 'Adobe-CNS1-2',
  39478. 'Adobe-CNS1-3',
  39479. 'Adobe-CNS1-4',
  39480. 'Adobe-CNS1-5',
  39481. 'Adobe-CNS1-6',
  39482. 'Adobe-GB1-0',
  39483. 'Adobe-GB1-1',
  39484. 'Adobe-GB1-2',
  39485. 'Adobe-GB1-3',
  39486. 'Adobe-GB1-4',
  39487. 'Adobe-GB1-5',
  39488. 'Adobe-Japan1-0',
  39489. 'Adobe-Japan1-1',
  39490. 'Adobe-Japan1-2',
  39491. 'Adobe-Japan1-3',
  39492. 'Adobe-Japan1-4',
  39493. 'Adobe-Japan1-5',
  39494. 'Adobe-Japan1-6',
  39495. 'Adobe-Korea1-0',
  39496. 'Adobe-Korea1-1',
  39497. 'Adobe-Korea1-2',
  39498. 'B5-H',
  39499. 'B5-V',
  39500. 'B5pc-H',
  39501. 'B5pc-V',
  39502. 'CNS-EUC-H',
  39503. 'CNS-EUC-V',
  39504. 'CNS1-H',
  39505. 'CNS1-V',
  39506. 'CNS2-H',
  39507. 'CNS2-V',
  39508. 'ETHK-B5-H',
  39509. 'ETHK-B5-V',
  39510. 'ETen-B5-H',
  39511. 'ETen-B5-V',
  39512. 'ETenms-B5-H',
  39513. 'ETenms-B5-V',
  39514. 'EUC-H',
  39515. 'EUC-V',
  39516. 'Ext-H',
  39517. 'Ext-RKSJ-H',
  39518. 'Ext-RKSJ-V',
  39519. 'Ext-V',
  39520. 'GB-EUC-H',
  39521. 'GB-EUC-V',
  39522. 'GB-H',
  39523. 'GB-V',
  39524. 'GBK-EUC-H',
  39525. 'GBK-EUC-V',
  39526. 'GBK2K-H',
  39527. 'GBK2K-V',
  39528. 'GBKp-EUC-H',
  39529. 'GBKp-EUC-V',
  39530. 'GBT-EUC-H',
  39531. 'GBT-EUC-V',
  39532. 'GBT-H',
  39533. 'GBT-V',
  39534. 'GBTpc-EUC-H',
  39535. 'GBTpc-EUC-V',
  39536. 'GBpc-EUC-H',
  39537. 'GBpc-EUC-V',
  39538. 'H',
  39539. 'HKdla-B5-H',
  39540. 'HKdla-B5-V',
  39541. 'HKdlb-B5-H',
  39542. 'HKdlb-B5-V',
  39543. 'HKgccs-B5-H',
  39544. 'HKgccs-B5-V',
  39545. 'HKm314-B5-H',
  39546. 'HKm314-B5-V',
  39547. 'HKm471-B5-H',
  39548. 'HKm471-B5-V',
  39549. 'HKscs-B5-H',
  39550. 'HKscs-B5-V',
  39551. 'Hankaku',
  39552. 'Hiragana',
  39553. 'KSC-EUC-H',
  39554. 'KSC-EUC-V',
  39555. 'KSC-H',
  39556. 'KSC-Johab-H',
  39557. 'KSC-Johab-V',
  39558. 'KSC-V',
  39559. 'KSCms-UHC-H',
  39560. 'KSCms-UHC-HW-H',
  39561. 'KSCms-UHC-HW-V',
  39562. 'KSCms-UHC-V',
  39563. 'KSCpc-EUC-H',
  39564. 'KSCpc-EUC-V',
  39565. 'Katakana',
  39566. 'NWP-H',
  39567. 'NWP-V',
  39568. 'RKSJ-H',
  39569. 'RKSJ-V',
  39570. 'Roman',
  39571. 'UniCNS-UCS2-H',
  39572. 'UniCNS-UCS2-V',
  39573. 'UniCNS-UTF16-H',
  39574. 'UniCNS-UTF16-V',
  39575. 'UniCNS-UTF32-H',
  39576. 'UniCNS-UTF32-V',
  39577. 'UniCNS-UTF8-H',
  39578. 'UniCNS-UTF8-V',
  39579. 'UniGB-UCS2-H',
  39580. 'UniGB-UCS2-V',
  39581. 'UniGB-UTF16-H',
  39582. 'UniGB-UTF16-V',
  39583. 'UniGB-UTF32-H',
  39584. 'UniGB-UTF32-V',
  39585. 'UniGB-UTF8-H',
  39586. 'UniGB-UTF8-V',
  39587. 'UniJIS-UCS2-H',
  39588. 'UniJIS-UCS2-HW-H',
  39589. 'UniJIS-UCS2-HW-V',
  39590. 'UniJIS-UCS2-V',
  39591. 'UniJIS-UTF16-H',
  39592. 'UniJIS-UTF16-V',
  39593. 'UniJIS-UTF32-H',
  39594. 'UniJIS-UTF32-V',
  39595. 'UniJIS-UTF8-H',
  39596. 'UniJIS-UTF8-V',
  39597. 'UniJIS2004-UTF16-H',
  39598. 'UniJIS2004-UTF16-V',
  39599. 'UniJIS2004-UTF32-H',
  39600. 'UniJIS2004-UTF32-V',
  39601. 'UniJIS2004-UTF8-H',
  39602. 'UniJIS2004-UTF8-V',
  39603. 'UniJISPro-UCS2-HW-V',
  39604. 'UniJISPro-UCS2-V',
  39605. 'UniJISPro-UTF8-V',
  39606. 'UniJISX0213-UTF32-H',
  39607. 'UniJISX0213-UTF32-V',
  39608. 'UniJISX02132004-UTF32-H',
  39609. 'UniJISX02132004-UTF32-V',
  39610. 'UniKS-UCS2-H',
  39611. 'UniKS-UCS2-V',
  39612. 'UniKS-UTF16-H',
  39613. 'UniKS-UTF16-V',
  39614. 'UniKS-UTF32-H',
  39615. 'UniKS-UTF32-V',
  39616. 'UniKS-UTF8-H',
  39617. 'UniKS-UTF8-V',
  39618. 'V',
  39619. 'WP-Symbol'
  39620. ];
  39621. var CMap = function CMapClosure() {
  39622. function CMap(builtInCMap) {
  39623. this.codespaceRanges = [
  39624. [],
  39625. [],
  39626. [],
  39627. []
  39628. ];
  39629. this.numCodespaceRanges = 0;
  39630. this._map = [];
  39631. this.name = '';
  39632. this.vertical = false;
  39633. this.useCMap = null;
  39634. this.builtInCMap = builtInCMap;
  39635. }
  39636. CMap.prototype = {
  39637. addCodespaceRange: function (n, low, high) {
  39638. this.codespaceRanges[n - 1].push(low, high);
  39639. this.numCodespaceRanges++;
  39640. },
  39641. mapCidRange: function (low, high, dstLow) {
  39642. while (low <= high) {
  39643. this._map[low++] = dstLow++;
  39644. }
  39645. },
  39646. mapBfRange: function (low, high, dstLow) {
  39647. var lastByte = dstLow.length - 1;
  39648. while (low <= high) {
  39649. this._map[low++] = dstLow;
  39650. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  39651. }
  39652. },
  39653. mapBfRangeToArray: function (low, high, array) {
  39654. var i = 0, ii = array.length;
  39655. while (low <= high && i < ii) {
  39656. this._map[low] = array[i++];
  39657. ++low;
  39658. }
  39659. },
  39660. mapOne: function (src, dst) {
  39661. this._map[src] = dst;
  39662. },
  39663. lookup: function (code) {
  39664. return this._map[code];
  39665. },
  39666. contains: function (code) {
  39667. return this._map[code] !== undefined;
  39668. },
  39669. forEach: function (callback) {
  39670. var map = this._map;
  39671. var length = map.length;
  39672. var i;
  39673. if (length <= 0x10000) {
  39674. for (i = 0; i < length; i++) {
  39675. if (map[i] !== undefined) {
  39676. callback(i, map[i]);
  39677. }
  39678. }
  39679. } else {
  39680. for (i in this._map) {
  39681. callback(i, map[i]);
  39682. }
  39683. }
  39684. },
  39685. charCodeOf: function (value) {
  39686. return this._map.indexOf(value);
  39687. },
  39688. getMap: function () {
  39689. return this._map;
  39690. },
  39691. readCharCode: function (str, offset, out) {
  39692. var c = 0;
  39693. var codespaceRanges = this.codespaceRanges;
  39694. var codespaceRangesLen = this.codespaceRanges.length;
  39695. for (var n = 0; n < codespaceRangesLen; n++) {
  39696. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  39697. var codespaceRange = codespaceRanges[n];
  39698. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  39699. var low = codespaceRange[k++];
  39700. var high = codespaceRange[k++];
  39701. if (c >= low && c <= high) {
  39702. out.charcode = c;
  39703. out.length = n + 1;
  39704. return;
  39705. }
  39706. }
  39707. }
  39708. out.charcode = 0;
  39709. out.length = 1;
  39710. },
  39711. get length() {
  39712. return this._map.length;
  39713. },
  39714. get isIdentityCMap() {
  39715. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  39716. return false;
  39717. }
  39718. if (this._map.length !== 0x10000) {
  39719. return false;
  39720. }
  39721. for (var i = 0; i < 0x10000; i++) {
  39722. if (this._map[i] !== i) {
  39723. return false;
  39724. }
  39725. }
  39726. return true;
  39727. }
  39728. };
  39729. return CMap;
  39730. }();
  39731. var IdentityCMap = function IdentityCMapClosure() {
  39732. function IdentityCMap(vertical, n) {
  39733. CMap.call(this);
  39734. this.vertical = vertical;
  39735. this.addCodespaceRange(n, 0, 0xffff);
  39736. }
  39737. Util.inherit(IdentityCMap, CMap, {});
  39738. IdentityCMap.prototype = {
  39739. addCodespaceRange: CMap.prototype.addCodespaceRange,
  39740. mapCidRange: function (low, high, dstLow) {
  39741. error('should not call mapCidRange');
  39742. },
  39743. mapBfRange: function (low, high, dstLow) {
  39744. error('should not call mapBfRange');
  39745. },
  39746. mapBfRangeToArray: function (low, high, array) {
  39747. error('should not call mapBfRangeToArray');
  39748. },
  39749. mapOne: function (src, dst) {
  39750. error('should not call mapCidOne');
  39751. },
  39752. lookup: function (code) {
  39753. return isInt(code) && code <= 0xffff ? code : undefined;
  39754. },
  39755. contains: function (code) {
  39756. return isInt(code) && code <= 0xffff;
  39757. },
  39758. forEach: function (callback) {
  39759. for (var i = 0; i <= 0xffff; i++) {
  39760. callback(i, i);
  39761. }
  39762. },
  39763. charCodeOf: function (value) {
  39764. return isInt(value) && value <= 0xffff ? value : -1;
  39765. },
  39766. getMap: function () {
  39767. var map = new Array(0x10000);
  39768. for (var i = 0; i <= 0xffff; i++) {
  39769. map[i] = i;
  39770. }
  39771. return map;
  39772. },
  39773. readCharCode: CMap.prototype.readCharCode,
  39774. get length() {
  39775. return 0x10000;
  39776. },
  39777. get isIdentityCMap() {
  39778. error('should not access .isIdentityCMap');
  39779. }
  39780. };
  39781. return IdentityCMap;
  39782. }();
  39783. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  39784. function fetchBinaryData(url) {
  39785. return new Promise(function (resolve, reject) {
  39786. var request = new XMLHttpRequest();
  39787. request.open('GET', url, true);
  39788. request.responseType = 'arraybuffer';
  39789. request.onreadystatechange = function () {
  39790. if (request.readyState === XMLHttpRequest.DONE) {
  39791. if (!request.response || request.status !== 200 && request.status !== 0) {
  39792. reject(new Error('Unable to get binary cMap at: ' + url));
  39793. } else {
  39794. resolve(new Uint8Array(request.response));
  39795. }
  39796. }
  39797. };
  39798. request.send(null);
  39799. });
  39800. }
  39801. function hexToInt(a, size) {
  39802. var n = 0;
  39803. for (var i = 0; i <= size; i++) {
  39804. n = n << 8 | a[i];
  39805. }
  39806. return n >>> 0;
  39807. }
  39808. function hexToStr(a, size) {
  39809. if (size === 1) {
  39810. return String.fromCharCode(a[0], a[1]);
  39811. }
  39812. if (size === 3) {
  39813. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  39814. }
  39815. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  39816. }
  39817. function addHex(a, b, size) {
  39818. var c = 0;
  39819. for (var i = size; i >= 0; i--) {
  39820. c += a[i] + b[i];
  39821. a[i] = c & 255;
  39822. c >>= 8;
  39823. }
  39824. }
  39825. function incHex(a, size) {
  39826. var c = 1;
  39827. for (var i = size; i >= 0 && c > 0; i--) {
  39828. c += a[i];
  39829. a[i] = c & 255;
  39830. c >>= 8;
  39831. }
  39832. }
  39833. var MAX_NUM_SIZE = 16;
  39834. var MAX_ENCODED_NUM_SIZE = 19;
  39835. function BinaryCMapStream(data) {
  39836. this.buffer = data;
  39837. this.pos = 0;
  39838. this.end = data.length;
  39839. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  39840. }
  39841. BinaryCMapStream.prototype = {
  39842. readByte: function () {
  39843. if (this.pos >= this.end) {
  39844. return -1;
  39845. }
  39846. return this.buffer[this.pos++];
  39847. },
  39848. readNumber: function () {
  39849. var n = 0;
  39850. var last;
  39851. do {
  39852. var b = this.readByte();
  39853. if (b < 0) {
  39854. error('unexpected EOF in bcmap');
  39855. }
  39856. last = !(b & 0x80);
  39857. n = n << 7 | b & 0x7F;
  39858. } while (!last);
  39859. return n;
  39860. },
  39861. readSigned: function () {
  39862. var n = this.readNumber();
  39863. return n & 1 ? ~(n >>> 1) : n >>> 1;
  39864. },
  39865. readHex: function (num, size) {
  39866. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  39867. this.pos += size + 1;
  39868. },
  39869. readHexNumber: function (num, size) {
  39870. var last;
  39871. var stack = this.tmpBuf, sp = 0;
  39872. do {
  39873. var b = this.readByte();
  39874. if (b < 0) {
  39875. error('unexpected EOF in bcmap');
  39876. }
  39877. last = !(b & 0x80);
  39878. stack[sp++] = b & 0x7F;
  39879. } while (!last);
  39880. var i = size, buffer = 0, bufferSize = 0;
  39881. while (i >= 0) {
  39882. while (bufferSize < 8 && stack.length > 0) {
  39883. buffer = stack[--sp] << bufferSize | buffer;
  39884. bufferSize += 7;
  39885. }
  39886. num[i] = buffer & 255;
  39887. i--;
  39888. buffer >>= 8;
  39889. bufferSize -= 8;
  39890. }
  39891. },
  39892. readHexSigned: function (num, size) {
  39893. this.readHexNumber(num, size);
  39894. var sign = num[size] & 1 ? 255 : 0;
  39895. var c = 0;
  39896. for (var i = 0; i <= size; i++) {
  39897. c = (c & 1) << 8 | num[i];
  39898. num[i] = c >> 1 ^ sign;
  39899. }
  39900. },
  39901. readString: function () {
  39902. var len = this.readNumber();
  39903. var s = '';
  39904. for (var i = 0; i < len; i++) {
  39905. s += String.fromCharCode(this.readNumber());
  39906. }
  39907. return s;
  39908. }
  39909. };
  39910. function processBinaryCMap(url, cMap, extend) {
  39911. return fetchBinaryData(url).then(function (data) {
  39912. var stream = new BinaryCMapStream(data);
  39913. var header = stream.readByte();
  39914. cMap.vertical = !!(header & 1);
  39915. var useCMap = null;
  39916. var start = new Uint8Array(MAX_NUM_SIZE);
  39917. var end = new Uint8Array(MAX_NUM_SIZE);
  39918. var char = new Uint8Array(MAX_NUM_SIZE);
  39919. var charCode = new Uint8Array(MAX_NUM_SIZE);
  39920. var tmp = new Uint8Array(MAX_NUM_SIZE);
  39921. var code;
  39922. var b;
  39923. while ((b = stream.readByte()) >= 0) {
  39924. var type = b >> 5;
  39925. if (type === 7) {
  39926. switch (b & 0x1F) {
  39927. case 0:
  39928. stream.readString();
  39929. break;
  39930. case 1:
  39931. useCMap = stream.readString();
  39932. break;
  39933. }
  39934. continue;
  39935. }
  39936. var sequence = !!(b & 0x10);
  39937. var dataSize = b & 15;
  39938. assert(dataSize + 1 <= MAX_NUM_SIZE);
  39939. var ucs2DataSize = 1;
  39940. var subitemsCount = stream.readNumber();
  39941. var i;
  39942. switch (type) {
  39943. case 0:
  39944. stream.readHex(start, dataSize);
  39945. stream.readHexNumber(end, dataSize);
  39946. addHex(end, start, dataSize);
  39947. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  39948. for (i = 1; i < subitemsCount; i++) {
  39949. incHex(end, dataSize);
  39950. stream.readHexNumber(start, dataSize);
  39951. addHex(start, end, dataSize);
  39952. stream.readHexNumber(end, dataSize);
  39953. addHex(end, start, dataSize);
  39954. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  39955. }
  39956. break;
  39957. case 1:
  39958. stream.readHex(start, dataSize);
  39959. stream.readHexNumber(end, dataSize);
  39960. addHex(end, start, dataSize);
  39961. code = stream.readNumber();
  39962. for (i = 1; i < subitemsCount; i++) {
  39963. incHex(end, dataSize);
  39964. stream.readHexNumber(start, dataSize);
  39965. addHex(start, end, dataSize);
  39966. stream.readHexNumber(end, dataSize);
  39967. addHex(end, start, dataSize);
  39968. code = stream.readNumber();
  39969. }
  39970. break;
  39971. case 2:
  39972. stream.readHex(char, dataSize);
  39973. code = stream.readNumber();
  39974. cMap.mapOne(hexToInt(char, dataSize), code);
  39975. for (i = 1; i < subitemsCount; i++) {
  39976. incHex(char, dataSize);
  39977. if (!sequence) {
  39978. stream.readHexNumber(tmp, dataSize);
  39979. addHex(char, tmp, dataSize);
  39980. }
  39981. code = stream.readSigned() + (code + 1);
  39982. cMap.mapOne(hexToInt(char, dataSize), code);
  39983. }
  39984. break;
  39985. case 3:
  39986. stream.readHex(start, dataSize);
  39987. stream.readHexNumber(end, dataSize);
  39988. addHex(end, start, dataSize);
  39989. code = stream.readNumber();
  39990. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  39991. for (i = 1; i < subitemsCount; i++) {
  39992. incHex(end, dataSize);
  39993. if (!sequence) {
  39994. stream.readHexNumber(start, dataSize);
  39995. addHex(start, end, dataSize);
  39996. } else {
  39997. start.set(end);
  39998. }
  39999. stream.readHexNumber(end, dataSize);
  40000. addHex(end, start, dataSize);
  40001. code = stream.readNumber();
  40002. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  40003. }
  40004. break;
  40005. case 4:
  40006. stream.readHex(char, ucs2DataSize);
  40007. stream.readHex(charCode, dataSize);
  40008. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  40009. for (i = 1; i < subitemsCount; i++) {
  40010. incHex(char, ucs2DataSize);
  40011. if (!sequence) {
  40012. stream.readHexNumber(tmp, ucs2DataSize);
  40013. addHex(char, tmp, ucs2DataSize);
  40014. }
  40015. incHex(charCode, dataSize);
  40016. stream.readHexSigned(tmp, dataSize);
  40017. addHex(charCode, tmp, dataSize);
  40018. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  40019. }
  40020. break;
  40021. case 5:
  40022. stream.readHex(start, ucs2DataSize);
  40023. stream.readHexNumber(end, ucs2DataSize);
  40024. addHex(end, start, ucs2DataSize);
  40025. stream.readHex(charCode, dataSize);
  40026. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  40027. for (i = 1; i < subitemsCount; i++) {
  40028. incHex(end, ucs2DataSize);
  40029. if (!sequence) {
  40030. stream.readHexNumber(start, ucs2DataSize);
  40031. addHex(start, end, ucs2DataSize);
  40032. } else {
  40033. start.set(end);
  40034. }
  40035. stream.readHexNumber(end, ucs2DataSize);
  40036. addHex(end, start, ucs2DataSize);
  40037. stream.readHex(charCode, dataSize);
  40038. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  40039. }
  40040. break;
  40041. default:
  40042. error('Unknown type: ' + type);
  40043. break;
  40044. }
  40045. }
  40046. if (useCMap) {
  40047. return extend(useCMap);
  40048. }
  40049. return cMap;
  40050. });
  40051. }
  40052. function BinaryCMapReader() {
  40053. }
  40054. BinaryCMapReader.prototype = { read: processBinaryCMap };
  40055. return BinaryCMapReader;
  40056. }();
  40057. var CMapFactory = function CMapFactoryClosure() {
  40058. function strToInt(str) {
  40059. var a = 0;
  40060. for (var i = 0; i < str.length; i++) {
  40061. a = a << 8 | str.charCodeAt(i);
  40062. }
  40063. return a >>> 0;
  40064. }
  40065. function expectString(obj) {
  40066. if (!isString(obj)) {
  40067. error('Malformed CMap: expected string.');
  40068. }
  40069. }
  40070. function expectInt(obj) {
  40071. if (!isInt(obj)) {
  40072. error('Malformed CMap: expected int.');
  40073. }
  40074. }
  40075. function parseBfChar(cMap, lexer) {
  40076. while (true) {
  40077. var obj = lexer.getObj();
  40078. if (isEOF(obj)) {
  40079. break;
  40080. }
  40081. if (isCmd(obj, 'endbfchar')) {
  40082. return;
  40083. }
  40084. expectString(obj);
  40085. var src = strToInt(obj);
  40086. obj = lexer.getObj();
  40087. expectString(obj);
  40088. var dst = obj;
  40089. cMap.mapOne(src, dst);
  40090. }
  40091. }
  40092. function parseBfRange(cMap, lexer) {
  40093. while (true) {
  40094. var obj = lexer.getObj();
  40095. if (isEOF(obj)) {
  40096. break;
  40097. }
  40098. if (isCmd(obj, 'endbfrange')) {
  40099. return;
  40100. }
  40101. expectString(obj);
  40102. var low = strToInt(obj);
  40103. obj = lexer.getObj();
  40104. expectString(obj);
  40105. var high = strToInt(obj);
  40106. obj = lexer.getObj();
  40107. if (isInt(obj) || isString(obj)) {
  40108. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  40109. cMap.mapBfRange(low, high, dstLow);
  40110. } else if (isCmd(obj, '[')) {
  40111. obj = lexer.getObj();
  40112. var array = [];
  40113. while (!isCmd(obj, ']') && !isEOF(obj)) {
  40114. array.push(obj);
  40115. obj = lexer.getObj();
  40116. }
  40117. cMap.mapBfRangeToArray(low, high, array);
  40118. } else {
  40119. break;
  40120. }
  40121. }
  40122. error('Invalid bf range.');
  40123. }
  40124. function parseCidChar(cMap, lexer) {
  40125. while (true) {
  40126. var obj = lexer.getObj();
  40127. if (isEOF(obj)) {
  40128. break;
  40129. }
  40130. if (isCmd(obj, 'endcidchar')) {
  40131. return;
  40132. }
  40133. expectString(obj);
  40134. var src = strToInt(obj);
  40135. obj = lexer.getObj();
  40136. expectInt(obj);
  40137. var dst = obj;
  40138. cMap.mapOne(src, dst);
  40139. }
  40140. }
  40141. function parseCidRange(cMap, lexer) {
  40142. while (true) {
  40143. var obj = lexer.getObj();
  40144. if (isEOF(obj)) {
  40145. break;
  40146. }
  40147. if (isCmd(obj, 'endcidrange')) {
  40148. return;
  40149. }
  40150. expectString(obj);
  40151. var low = strToInt(obj);
  40152. obj = lexer.getObj();
  40153. expectString(obj);
  40154. var high = strToInt(obj);
  40155. obj = lexer.getObj();
  40156. expectInt(obj);
  40157. var dstLow = obj;
  40158. cMap.mapCidRange(low, high, dstLow);
  40159. }
  40160. }
  40161. function parseCodespaceRange(cMap, lexer) {
  40162. while (true) {
  40163. var obj = lexer.getObj();
  40164. if (isEOF(obj)) {
  40165. break;
  40166. }
  40167. if (isCmd(obj, 'endcodespacerange')) {
  40168. return;
  40169. }
  40170. if (!isString(obj)) {
  40171. break;
  40172. }
  40173. var low = strToInt(obj);
  40174. obj = lexer.getObj();
  40175. if (!isString(obj)) {
  40176. break;
  40177. }
  40178. var high = strToInt(obj);
  40179. cMap.addCodespaceRange(obj.length, low, high);
  40180. }
  40181. error('Invalid codespace range.');
  40182. }
  40183. function parseWMode(cMap, lexer) {
  40184. var obj = lexer.getObj();
  40185. if (isInt(obj)) {
  40186. cMap.vertical = !!obj;
  40187. }
  40188. }
  40189. function parseCMapName(cMap, lexer) {
  40190. var obj = lexer.getObj();
  40191. if (isName(obj) && isString(obj.name)) {
  40192. cMap.name = obj.name;
  40193. }
  40194. }
  40195. function parseCMap(cMap, lexer, builtInCMapParams, useCMap) {
  40196. var previous;
  40197. var embededUseCMap;
  40198. objLoop:
  40199. while (true) {
  40200. try {
  40201. var obj = lexer.getObj();
  40202. if (isEOF(obj)) {
  40203. break;
  40204. } else if (isName(obj)) {
  40205. if (obj.name === 'WMode') {
  40206. parseWMode(cMap, lexer);
  40207. } else if (obj.name === 'CMapName') {
  40208. parseCMapName(cMap, lexer);
  40209. }
  40210. previous = obj;
  40211. } else if (isCmd(obj)) {
  40212. switch (obj.cmd) {
  40213. case 'endcmap':
  40214. break objLoop;
  40215. case 'usecmap':
  40216. if (isName(previous)) {
  40217. embededUseCMap = previous.name;
  40218. }
  40219. break;
  40220. case 'begincodespacerange':
  40221. parseCodespaceRange(cMap, lexer);
  40222. break;
  40223. case 'beginbfchar':
  40224. parseBfChar(cMap, lexer);
  40225. break;
  40226. case 'begincidchar':
  40227. parseCidChar(cMap, lexer);
  40228. break;
  40229. case 'beginbfrange':
  40230. parseBfRange(cMap, lexer);
  40231. break;
  40232. case 'begincidrange':
  40233. parseCidRange(cMap, lexer);
  40234. break;
  40235. }
  40236. }
  40237. } catch (ex) {
  40238. if (ex instanceof MissingDataException) {
  40239. throw ex;
  40240. }
  40241. warn('Invalid cMap data: ' + ex);
  40242. continue;
  40243. }
  40244. }
  40245. if (!useCMap && embededUseCMap) {
  40246. useCMap = embededUseCMap;
  40247. }
  40248. if (useCMap) {
  40249. return extendCMap(cMap, builtInCMapParams, useCMap);
  40250. }
  40251. return Promise.resolve(cMap);
  40252. }
  40253. function extendCMap(cMap, builtInCMapParams, useCMap) {
  40254. return createBuiltInCMap(useCMap, builtInCMapParams).then(function (newCMap) {
  40255. cMap.useCMap = newCMap;
  40256. if (cMap.numCodespaceRanges === 0) {
  40257. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  40258. for (var i = 0; i < useCodespaceRanges.length; i++) {
  40259. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  40260. }
  40261. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  40262. }
  40263. cMap.useCMap.forEach(function (key, value) {
  40264. if (!cMap.contains(key)) {
  40265. cMap.mapOne(key, cMap.useCMap.lookup(key));
  40266. }
  40267. });
  40268. return cMap;
  40269. });
  40270. }
  40271. function parseBinaryCMap(name, builtInCMapParams) {
  40272. var url = builtInCMapParams.url + name + '.bcmap';
  40273. var cMap = new CMap(true);
  40274. return new BinaryCMapReader().read(url, cMap, function (useCMap) {
  40275. return extendCMap(cMap, builtInCMapParams, useCMap);
  40276. });
  40277. }
  40278. function createBuiltInCMap(name, builtInCMapParams) {
  40279. if (name === 'Identity-H') {
  40280. return Promise.resolve(new IdentityCMap(false, 2));
  40281. } else if (name === 'Identity-V') {
  40282. return Promise.resolve(new IdentityCMap(true, 2));
  40283. }
  40284. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  40285. return Promise.reject(new Error('Unknown cMap name: ' + name));
  40286. }
  40287. assert(builtInCMapParams, 'built-in cMap parameters are not provided');
  40288. if (builtInCMapParams.packed) {
  40289. return parseBinaryCMap(name, builtInCMapParams);
  40290. }
  40291. return new Promise(function (resolve, reject) {
  40292. var url = builtInCMapParams.url + name;
  40293. var request = new XMLHttpRequest();
  40294. request.onreadystatechange = function () {
  40295. if (request.readyState === XMLHttpRequest.DONE) {
  40296. if (request.status === 200 || request.status === 0) {
  40297. var cMap = new CMap(true);
  40298. var lexer = new Lexer(new StringStream(request.responseText));
  40299. parseCMap(cMap, lexer, builtInCMapParams, null).then(function (parsedCMap) {
  40300. resolve(parsedCMap);
  40301. });
  40302. } else {
  40303. reject(new Error('Unable to get cMap at: ' + url));
  40304. }
  40305. }
  40306. };
  40307. request.open('GET', url, true);
  40308. request.send(null);
  40309. });
  40310. }
  40311. return {
  40312. create: function (encoding, builtInCMapParams, useCMap) {
  40313. if (isName(encoding)) {
  40314. return createBuiltInCMap(encoding.name, builtInCMapParams);
  40315. } else if (isStream(encoding)) {
  40316. var cMap = new CMap();
  40317. var lexer = new Lexer(encoding);
  40318. return parseCMap(cMap, lexer, builtInCMapParams, useCMap).then(function (parsedCMap) {
  40319. if (parsedCMap.isIdentityCMap) {
  40320. return createBuiltInCMap(parsedCMap.name, builtInCMapParams);
  40321. }
  40322. return parsedCMap;
  40323. });
  40324. }
  40325. return Promise.reject(new Error('Encoding required.'));
  40326. }
  40327. };
  40328. }();
  40329. exports.CMap = CMap;
  40330. exports.CMapFactory = CMapFactory;
  40331. exports.IdentityCMap = IdentityCMap;
  40332. }));
  40333. (function (root, factory) {
  40334. factory(root.pdfjsCoreFonts = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreFontRenderer, root.pdfjsCoreEncodings, root.pdfjsCoreStandardFonts, root.pdfjsCoreUnicode, root.pdfjsCoreType1Parser, root.pdfjsCoreCFFParser);
  40335. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreGlyphList, coreFontRenderer, coreEncodings, coreStandardFonts, coreUnicode, coreType1Parser, coreCFFParser) {
  40336. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  40337. var FontType = sharedUtil.FontType;
  40338. var assert = sharedUtil.assert;
  40339. var bytesToString = sharedUtil.bytesToString;
  40340. var error = sharedUtil.error;
  40341. var info = sharedUtil.info;
  40342. var isArray = sharedUtil.isArray;
  40343. var isInt = sharedUtil.isInt;
  40344. var isNum = sharedUtil.isNum;
  40345. var readUint32 = sharedUtil.readUint32;
  40346. var shadow = sharedUtil.shadow;
  40347. var string32 = sharedUtil.string32;
  40348. var warn = sharedUtil.warn;
  40349. var MissingDataException = sharedUtil.MissingDataException;
  40350. var isSpace = sharedUtil.isSpace;
  40351. var Stream = coreStream.Stream;
  40352. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  40353. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  40354. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  40355. var StandardEncoding = coreEncodings.StandardEncoding;
  40356. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  40357. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  40358. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  40359. var getEncoding = coreEncodings.getEncoding;
  40360. var getStdFontMap = coreStandardFonts.getStdFontMap;
  40361. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  40362. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  40363. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  40364. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  40365. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  40366. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  40367. var Type1Parser = coreType1Parser.Type1Parser;
  40368. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  40369. var CFFParser = coreCFFParser.CFFParser;
  40370. var CFFCompiler = coreCFFParser.CFFCompiler;
  40371. var CFF = coreCFFParser.CFF;
  40372. var CFFHeader = coreCFFParser.CFFHeader;
  40373. var CFFTopDict = coreCFFParser.CFFTopDict;
  40374. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  40375. var CFFStrings = coreCFFParser.CFFStrings;
  40376. var CFFIndex = coreCFFParser.CFFIndex;
  40377. var CFFCharset = coreCFFParser.CFFCharset;
  40378. var PRIVATE_USE_OFFSET_START = 0xE000;
  40379. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  40380. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  40381. var PDF_GLYPH_SPACE_UNITS = 1000;
  40382. var SEAC_ANALYSIS_ENABLED = false;
  40383. var FontFlags = {
  40384. FixedPitch: 1,
  40385. Serif: 2,
  40386. Symbolic: 4,
  40387. Script: 8,
  40388. Nonsymbolic: 32,
  40389. Italic: 64,
  40390. AllCap: 65536,
  40391. SmallCap: 131072,
  40392. ForceBold: 262144
  40393. };
  40394. var MacStandardGlyphOrdering = [
  40395. '.notdef',
  40396. '.null',
  40397. 'nonmarkingreturn',
  40398. 'space',
  40399. 'exclam',
  40400. 'quotedbl',
  40401. 'numbersign',
  40402. 'dollar',
  40403. 'percent',
  40404. 'ampersand',
  40405. 'quotesingle',
  40406. 'parenleft',
  40407. 'parenright',
  40408. 'asterisk',
  40409. 'plus',
  40410. 'comma',
  40411. 'hyphen',
  40412. 'period',
  40413. 'slash',
  40414. 'zero',
  40415. 'one',
  40416. 'two',
  40417. 'three',
  40418. 'four',
  40419. 'five',
  40420. 'six',
  40421. 'seven',
  40422. 'eight',
  40423. 'nine',
  40424. 'colon',
  40425. 'semicolon',
  40426. 'less',
  40427. 'equal',
  40428. 'greater',
  40429. 'question',
  40430. 'at',
  40431. 'A',
  40432. 'B',
  40433. 'C',
  40434. 'D',
  40435. 'E',
  40436. 'F',
  40437. 'G',
  40438. 'H',
  40439. 'I',
  40440. 'J',
  40441. 'K',
  40442. 'L',
  40443. 'M',
  40444. 'N',
  40445. 'O',
  40446. 'P',
  40447. 'Q',
  40448. 'R',
  40449. 'S',
  40450. 'T',
  40451. 'U',
  40452. 'V',
  40453. 'W',
  40454. 'X',
  40455. 'Y',
  40456. 'Z',
  40457. 'bracketleft',
  40458. 'backslash',
  40459. 'bracketright',
  40460. 'asciicircum',
  40461. 'underscore',
  40462. 'grave',
  40463. 'a',
  40464. 'b',
  40465. 'c',
  40466. 'd',
  40467. 'e',
  40468. 'f',
  40469. 'g',
  40470. 'h',
  40471. 'i',
  40472. 'j',
  40473. 'k',
  40474. 'l',
  40475. 'm',
  40476. 'n',
  40477. 'o',
  40478. 'p',
  40479. 'q',
  40480. 'r',
  40481. 's',
  40482. 't',
  40483. 'u',
  40484. 'v',
  40485. 'w',
  40486. 'x',
  40487. 'y',
  40488. 'z',
  40489. 'braceleft',
  40490. 'bar',
  40491. 'braceright',
  40492. 'asciitilde',
  40493. 'Adieresis',
  40494. 'Aring',
  40495. 'Ccedilla',
  40496. 'Eacute',
  40497. 'Ntilde',
  40498. 'Odieresis',
  40499. 'Udieresis',
  40500. 'aacute',
  40501. 'agrave',
  40502. 'acircumflex',
  40503. 'adieresis',
  40504. 'atilde',
  40505. 'aring',
  40506. 'ccedilla',
  40507. 'eacute',
  40508. 'egrave',
  40509. 'ecircumflex',
  40510. 'edieresis',
  40511. 'iacute',
  40512. 'igrave',
  40513. 'icircumflex',
  40514. 'idieresis',
  40515. 'ntilde',
  40516. 'oacute',
  40517. 'ograve',
  40518. 'ocircumflex',
  40519. 'odieresis',
  40520. 'otilde',
  40521. 'uacute',
  40522. 'ugrave',
  40523. 'ucircumflex',
  40524. 'udieresis',
  40525. 'dagger',
  40526. 'degree',
  40527. 'cent',
  40528. 'sterling',
  40529. 'section',
  40530. 'bullet',
  40531. 'paragraph',
  40532. 'germandbls',
  40533. 'registered',
  40534. 'copyright',
  40535. 'trademark',
  40536. 'acute',
  40537. 'dieresis',
  40538. 'notequal',
  40539. 'AE',
  40540. 'Oslash',
  40541. 'infinity',
  40542. 'plusminus',
  40543. 'lessequal',
  40544. 'greaterequal',
  40545. 'yen',
  40546. 'mu',
  40547. 'partialdiff',
  40548. 'summation',
  40549. 'product',
  40550. 'pi',
  40551. 'integral',
  40552. 'ordfeminine',
  40553. 'ordmasculine',
  40554. 'Omega',
  40555. 'ae',
  40556. 'oslash',
  40557. 'questiondown',
  40558. 'exclamdown',
  40559. 'logicalnot',
  40560. 'radical',
  40561. 'florin',
  40562. 'approxequal',
  40563. 'Delta',
  40564. 'guillemotleft',
  40565. 'guillemotright',
  40566. 'ellipsis',
  40567. 'nonbreakingspace',
  40568. 'Agrave',
  40569. 'Atilde',
  40570. 'Otilde',
  40571. 'OE',
  40572. 'oe',
  40573. 'endash',
  40574. 'emdash',
  40575. 'quotedblleft',
  40576. 'quotedblright',
  40577. 'quoteleft',
  40578. 'quoteright',
  40579. 'divide',
  40580. 'lozenge',
  40581. 'ydieresis',
  40582. 'Ydieresis',
  40583. 'fraction',
  40584. 'currency',
  40585. 'guilsinglleft',
  40586. 'guilsinglright',
  40587. 'fi',
  40588. 'fl',
  40589. 'daggerdbl',
  40590. 'periodcentered',
  40591. 'quotesinglbase',
  40592. 'quotedblbase',
  40593. 'perthousand',
  40594. 'Acircumflex',
  40595. 'Ecircumflex',
  40596. 'Aacute',
  40597. 'Edieresis',
  40598. 'Egrave',
  40599. 'Iacute',
  40600. 'Icircumflex',
  40601. 'Idieresis',
  40602. 'Igrave',
  40603. 'Oacute',
  40604. 'Ocircumflex',
  40605. 'apple',
  40606. 'Ograve',
  40607. 'Uacute',
  40608. 'Ucircumflex',
  40609. 'Ugrave',
  40610. 'dotlessi',
  40611. 'circumflex',
  40612. 'tilde',
  40613. 'macron',
  40614. 'breve',
  40615. 'dotaccent',
  40616. 'ring',
  40617. 'cedilla',
  40618. 'hungarumlaut',
  40619. 'ogonek',
  40620. 'caron',
  40621. 'Lslash',
  40622. 'lslash',
  40623. 'Scaron',
  40624. 'scaron',
  40625. 'Zcaron',
  40626. 'zcaron',
  40627. 'brokenbar',
  40628. 'Eth',
  40629. 'eth',
  40630. 'Yacute',
  40631. 'yacute',
  40632. 'Thorn',
  40633. 'thorn',
  40634. 'minus',
  40635. 'multiply',
  40636. 'onesuperior',
  40637. 'twosuperior',
  40638. 'threesuperior',
  40639. 'onehalf',
  40640. 'onequarter',
  40641. 'threequarters',
  40642. 'franc',
  40643. 'Gbreve',
  40644. 'gbreve',
  40645. 'Idotaccent',
  40646. 'Scedilla',
  40647. 'scedilla',
  40648. 'Cacute',
  40649. 'cacute',
  40650. 'Ccaron',
  40651. 'ccaron',
  40652. 'dcroat'
  40653. ];
  40654. function adjustWidths(properties) {
  40655. if (!properties.fontMatrix) {
  40656. return;
  40657. }
  40658. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  40659. return;
  40660. }
  40661. var scale = 0.001 / properties.fontMatrix[0];
  40662. var glyphsWidths = properties.widths;
  40663. for (var glyph in glyphsWidths) {
  40664. glyphsWidths[glyph] *= scale;
  40665. }
  40666. properties.defaultWidth *= scale;
  40667. }
  40668. function adjustToUnicode(properties, builtInEncoding) {
  40669. if (properties.hasIncludedToUnicodeMap) {
  40670. return;
  40671. }
  40672. if (properties.hasEncoding) {
  40673. return;
  40674. }
  40675. if (builtInEncoding === properties.defaultEncoding) {
  40676. return;
  40677. }
  40678. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  40679. return;
  40680. }
  40681. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  40682. for (var charCode in builtInEncoding) {
  40683. var glyphName = builtInEncoding[charCode];
  40684. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  40685. if (unicode !== -1) {
  40686. toUnicode[charCode] = String.fromCharCode(unicode);
  40687. }
  40688. }
  40689. properties.toUnicode.amend(toUnicode);
  40690. }
  40691. function getFontType(type, subtype) {
  40692. switch (type) {
  40693. case 'Type1':
  40694. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  40695. case 'CIDFontType0':
  40696. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  40697. case 'OpenType':
  40698. return FontType.OPENTYPE;
  40699. case 'TrueType':
  40700. return FontType.TRUETYPE;
  40701. case 'CIDFontType2':
  40702. return FontType.CIDFONTTYPE2;
  40703. case 'MMType1':
  40704. return FontType.MMTYPE1;
  40705. case 'Type0':
  40706. return FontType.TYPE0;
  40707. default:
  40708. return FontType.UNKNOWN;
  40709. }
  40710. }
  40711. function recoverGlyphName(name, glyphsUnicodeMap) {
  40712. if (glyphsUnicodeMap[name] !== undefined) {
  40713. return name;
  40714. }
  40715. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  40716. if (unicode !== -1) {
  40717. for (var key in glyphsUnicodeMap) {
  40718. if (glyphsUnicodeMap[key] === unicode) {
  40719. return key;
  40720. }
  40721. }
  40722. }
  40723. info('Unable to recover a standard glyph name for: ' + name);
  40724. return name;
  40725. }
  40726. var Glyph = function GlyphClosure() {
  40727. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  40728. this.fontChar = fontChar;
  40729. this.unicode = unicode;
  40730. this.accent = accent;
  40731. this.width = width;
  40732. this.vmetric = vmetric;
  40733. this.operatorListId = operatorListId;
  40734. this.isSpace = isSpace;
  40735. this.isInFont = isInFont;
  40736. }
  40737. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  40738. 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;
  40739. };
  40740. return Glyph;
  40741. }();
  40742. var ToUnicodeMap = function ToUnicodeMapClosure() {
  40743. function ToUnicodeMap(cmap) {
  40744. this._map = cmap;
  40745. }
  40746. ToUnicodeMap.prototype = {
  40747. get length() {
  40748. return this._map.length;
  40749. },
  40750. forEach: function (callback) {
  40751. for (var charCode in this._map) {
  40752. callback(charCode, this._map[charCode].charCodeAt(0));
  40753. }
  40754. },
  40755. has: function (i) {
  40756. return this._map[i] !== undefined;
  40757. },
  40758. get: function (i) {
  40759. return this._map[i];
  40760. },
  40761. charCodeOf: function (v) {
  40762. return this._map.indexOf(v);
  40763. },
  40764. amend: function (map) {
  40765. for (var charCode in map) {
  40766. this._map[charCode] = map[charCode];
  40767. }
  40768. }
  40769. };
  40770. return ToUnicodeMap;
  40771. }();
  40772. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  40773. function IdentityToUnicodeMap(firstChar, lastChar) {
  40774. this.firstChar = firstChar;
  40775. this.lastChar = lastChar;
  40776. }
  40777. IdentityToUnicodeMap.prototype = {
  40778. get length() {
  40779. return this.lastChar + 1 - this.firstChar;
  40780. },
  40781. forEach: function (callback) {
  40782. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  40783. callback(i, i);
  40784. }
  40785. },
  40786. has: function (i) {
  40787. return this.firstChar <= i && i <= this.lastChar;
  40788. },
  40789. get: function (i) {
  40790. if (this.firstChar <= i && i <= this.lastChar) {
  40791. return String.fromCharCode(i);
  40792. }
  40793. return undefined;
  40794. },
  40795. charCodeOf: function (v) {
  40796. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  40797. },
  40798. amend: function (map) {
  40799. error('Should not call amend()');
  40800. }
  40801. };
  40802. return IdentityToUnicodeMap;
  40803. }();
  40804. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  40805. function writeInt16(dest, offset, num) {
  40806. dest[offset] = num >> 8 & 0xFF;
  40807. dest[offset + 1] = num & 0xFF;
  40808. }
  40809. function writeInt32(dest, offset, num) {
  40810. dest[offset] = num >> 24 & 0xFF;
  40811. dest[offset + 1] = num >> 16 & 0xFF;
  40812. dest[offset + 2] = num >> 8 & 0xFF;
  40813. dest[offset + 3] = num & 0xFF;
  40814. }
  40815. function writeData(dest, offset, data) {
  40816. var i, ii;
  40817. if (data instanceof Uint8Array) {
  40818. dest.set(data, offset);
  40819. } else if (typeof data === 'string') {
  40820. for (i = 0, ii = data.length; i < ii; i++) {
  40821. dest[offset++] = data.charCodeAt(i) & 0xFF;
  40822. }
  40823. } else {
  40824. for (i = 0, ii = data.length; i < ii; i++) {
  40825. dest[offset++] = data[i] & 0xFF;
  40826. }
  40827. }
  40828. }
  40829. function OpenTypeFileBuilder(sfnt) {
  40830. this.sfnt = sfnt;
  40831. this.tables = Object.create(null);
  40832. }
  40833. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  40834. var maxPower2 = 1, log2 = 0;
  40835. while ((maxPower2 ^ entriesCount) > maxPower2) {
  40836. maxPower2 <<= 1;
  40837. log2++;
  40838. }
  40839. var searchRange = maxPower2 * entrySize;
  40840. return {
  40841. range: searchRange,
  40842. entry: log2,
  40843. rangeShift: entrySize * entriesCount - searchRange
  40844. };
  40845. };
  40846. var OTF_HEADER_SIZE = 12;
  40847. var OTF_TABLE_ENTRY_SIZE = 16;
  40848. OpenTypeFileBuilder.prototype = {
  40849. toArray: function OpenTypeFileBuilder_toArray() {
  40850. var sfnt = this.sfnt;
  40851. var tables = this.tables;
  40852. var tablesNames = Object.keys(tables);
  40853. tablesNames.sort();
  40854. var numTables = tablesNames.length;
  40855. var i, j, jj, table, tableName;
  40856. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  40857. var tableOffsets = [offset];
  40858. for (i = 0; i < numTables; i++) {
  40859. table = tables[tablesNames[i]];
  40860. var paddedLength = (table.length + 3 & ~3) >>> 0;
  40861. offset += paddedLength;
  40862. tableOffsets.push(offset);
  40863. }
  40864. var file = new Uint8Array(offset);
  40865. for (i = 0; i < numTables; i++) {
  40866. table = tables[tablesNames[i]];
  40867. writeData(file, tableOffsets[i], table);
  40868. }
  40869. if (sfnt === 'true') {
  40870. sfnt = string32(0x00010000);
  40871. }
  40872. file[0] = sfnt.charCodeAt(0) & 0xFF;
  40873. file[1] = sfnt.charCodeAt(1) & 0xFF;
  40874. file[2] = sfnt.charCodeAt(2) & 0xFF;
  40875. file[3] = sfnt.charCodeAt(3) & 0xFF;
  40876. writeInt16(file, 4, numTables);
  40877. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  40878. writeInt16(file, 6, searchParams.range);
  40879. writeInt16(file, 8, searchParams.entry);
  40880. writeInt16(file, 10, searchParams.rangeShift);
  40881. offset = OTF_HEADER_SIZE;
  40882. for (i = 0; i < numTables; i++) {
  40883. tableName = tablesNames[i];
  40884. file[offset] = tableName.charCodeAt(0) & 0xFF;
  40885. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  40886. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  40887. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  40888. var checksum = 0;
  40889. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  40890. var quad = readUint32(file, j);
  40891. checksum = checksum + quad >>> 0;
  40892. }
  40893. writeInt32(file, offset + 4, checksum);
  40894. writeInt32(file, offset + 8, tableOffsets[i]);
  40895. writeInt32(file, offset + 12, tables[tableName].length);
  40896. offset += OTF_TABLE_ENTRY_SIZE;
  40897. }
  40898. return file;
  40899. },
  40900. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  40901. if (tag in this.tables) {
  40902. throw new Error('Table ' + tag + ' already exists');
  40903. }
  40904. this.tables[tag] = data;
  40905. }
  40906. };
  40907. return OpenTypeFileBuilder;
  40908. }();
  40909. var ProblematicCharRanges = new Int32Array([
  40910. 0x0000,
  40911. 0x0020,
  40912. 0x007F,
  40913. 0x00A1,
  40914. 0x00AD,
  40915. 0x00AE,
  40916. 0x0600,
  40917. 0x0780,
  40918. 0x08A0,
  40919. 0x10A0,
  40920. 0x1780,
  40921. 0x1800,
  40922. 0x1C00,
  40923. 0x1C50,
  40924. 0x2000,
  40925. 0x2010,
  40926. 0x2011,
  40927. 0x2012,
  40928. 0x2028,
  40929. 0x2030,
  40930. 0x205F,
  40931. 0x2070,
  40932. 0x25CC,
  40933. 0x25CD,
  40934. 0x3000,
  40935. 0x3001,
  40936. 0xAA60,
  40937. 0xAA80,
  40938. 0xFFF0,
  40939. 0x10000
  40940. ]);
  40941. var Font = function FontClosure() {
  40942. function Font(name, file, properties) {
  40943. var charCode, glyphName, unicode;
  40944. this.name = name;
  40945. this.loadedName = properties.loadedName;
  40946. this.isType3Font = properties.isType3Font;
  40947. this.sizes = [];
  40948. this.missingFile = false;
  40949. this.glyphCache = Object.create(null);
  40950. var names = name.split('+');
  40951. names = names.length > 1 ? names[1] : names[0];
  40952. names = names.split(/[-,_]/g)[0];
  40953. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  40954. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  40955. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  40956. var type = properties.type;
  40957. var subtype = properties.subtype;
  40958. this.type = type;
  40959. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  40960. this.differences = properties.differences;
  40961. this.widths = properties.widths;
  40962. this.defaultWidth = properties.defaultWidth;
  40963. this.composite = properties.composite;
  40964. this.wideChars = properties.wideChars;
  40965. this.cMap = properties.cMap;
  40966. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  40967. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  40968. this.fontMatrix = properties.fontMatrix;
  40969. this.bbox = properties.bbox;
  40970. this.toUnicode = properties.toUnicode;
  40971. this.toFontChar = [];
  40972. if (properties.type === 'Type3') {
  40973. for (charCode = 0; charCode < 256; charCode++) {
  40974. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  40975. }
  40976. this.fontType = FontType.TYPE3;
  40977. return;
  40978. }
  40979. this.cidEncoding = properties.cidEncoding;
  40980. this.vertical = properties.vertical;
  40981. if (this.vertical) {
  40982. this.vmetrics = properties.vmetrics;
  40983. this.defaultVMetrics = properties.defaultVMetrics;
  40984. }
  40985. var glyphsUnicodeMap;
  40986. if (!file || file.isEmpty) {
  40987. if (file) {
  40988. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  40989. }
  40990. this.missingFile = true;
  40991. var fontName = name.replace(/[,_]/g, '-');
  40992. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  40993. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  40994. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  40995. this.bold = fontName.search(/bold/gi) !== -1;
  40996. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  40997. this.black = name.search(/Black/g) !== -1;
  40998. this.remeasure = Object.keys(this.widths).length > 0;
  40999. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  41000. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  41001. var map = [];
  41002. for (charCode in GlyphMapForStandardFonts) {
  41003. map[+charCode] = GlyphMapForStandardFonts[charCode];
  41004. }
  41005. if (/Arial-?Black/i.test(name)) {
  41006. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  41007. for (charCode in SupplementalGlyphMapForArialBlack) {
  41008. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  41009. }
  41010. }
  41011. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  41012. if (!isIdentityUnicode) {
  41013. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  41014. map[+charCode] = unicodeCharCode;
  41015. });
  41016. }
  41017. this.toFontChar = map;
  41018. this.toUnicode = new ToUnicodeMap(map);
  41019. } else if (/Symbol/i.test(fontName)) {
  41020. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  41021. } else if (/Dingbats/i.test(fontName)) {
  41022. if (/Wingdings/i.test(name)) {
  41023. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  41024. }
  41025. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  41026. } else if (isStandardFont) {
  41027. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  41028. } else {
  41029. glyphsUnicodeMap = getGlyphsUnicode();
  41030. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  41031. if (!this.composite) {
  41032. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  41033. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  41034. if (unicode !== -1) {
  41035. unicodeCharCode = unicode;
  41036. }
  41037. }
  41038. this.toFontChar[charCode] = unicodeCharCode;
  41039. }.bind(this));
  41040. }
  41041. this.loadedName = fontName.split('-')[0];
  41042. this.loading = false;
  41043. this.fontType = getFontType(type, subtype);
  41044. return;
  41045. }
  41046. if (subtype === 'Type1C') {
  41047. if (type !== 'Type1' && type !== 'MMType1') {
  41048. if (isTrueTypeFile(file)) {
  41049. subtype = 'TrueType';
  41050. } else {
  41051. type = 'Type1';
  41052. }
  41053. } else if (isOpenTypeFile(file)) {
  41054. type = subtype = 'OpenType';
  41055. }
  41056. }
  41057. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  41058. type = 'CIDFontType0';
  41059. }
  41060. if (subtype === 'OpenType') {
  41061. type = 'OpenType';
  41062. }
  41063. if (type === 'CIDFontType0') {
  41064. if (isType1File(file)) {
  41065. subtype = 'CIDFontType0';
  41066. } else if (isOpenTypeFile(file)) {
  41067. type = subtype = 'OpenType';
  41068. } else {
  41069. subtype = 'CIDFontType0C';
  41070. }
  41071. }
  41072. var data;
  41073. switch (type) {
  41074. case 'MMType1':
  41075. info('MMType1 font (' + name + '), falling back to Type1.');
  41076. case 'Type1':
  41077. case 'CIDFontType0':
  41078. this.mimetype = 'font/opentype';
  41079. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  41080. adjustWidths(properties);
  41081. data = this.convert(name, cff, properties);
  41082. break;
  41083. case 'OpenType':
  41084. case 'TrueType':
  41085. case 'CIDFontType2':
  41086. this.mimetype = 'font/opentype';
  41087. data = this.checkAndRepair(name, file, properties);
  41088. if (this.isOpenType) {
  41089. adjustWidths(properties);
  41090. type = 'OpenType';
  41091. }
  41092. break;
  41093. default:
  41094. error('Font ' + type + ' is not supported');
  41095. break;
  41096. }
  41097. this.data = data;
  41098. this.fontType = getFontType(type, subtype);
  41099. this.fontMatrix = properties.fontMatrix;
  41100. this.widths = properties.widths;
  41101. this.defaultWidth = properties.defaultWidth;
  41102. this.toUnicode = properties.toUnicode;
  41103. this.encoding = properties.baseEncoding;
  41104. this.seacMap = properties.seacMap;
  41105. this.loading = true;
  41106. }
  41107. Font.getFontID = function () {
  41108. var ID = 1;
  41109. return function Font_getFontID() {
  41110. return String(ID++);
  41111. };
  41112. }();
  41113. function int16(b0, b1) {
  41114. return (b0 << 8) + b1;
  41115. }
  41116. function signedInt16(b0, b1) {
  41117. var value = (b0 << 8) + b1;
  41118. return value & 1 << 15 ? value - 0x10000 : value;
  41119. }
  41120. function int32(b0, b1, b2, b3) {
  41121. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  41122. }
  41123. function string16(value) {
  41124. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  41125. }
  41126. function safeString16(value) {
  41127. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  41128. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  41129. }
  41130. function isTrueTypeFile(file) {
  41131. var header = file.peekBytes(4);
  41132. return readUint32(header, 0) === 0x00010000;
  41133. }
  41134. function isOpenTypeFile(file) {
  41135. var header = file.peekBytes(4);
  41136. return bytesToString(header) === 'OTTO';
  41137. }
  41138. function isType1File(file) {
  41139. var header = file.peekBytes(2);
  41140. if (header[0] === 0x25 && header[1] === 0x21) {
  41141. return true;
  41142. }
  41143. if (header[0] === 0x80 && header[1] === 0x01) {
  41144. return true;
  41145. }
  41146. return false;
  41147. }
  41148. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  41149. var toFontChar = [], unicode;
  41150. for (var i = 0, ii = encoding.length; i < ii; i++) {
  41151. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  41152. if (unicode !== -1) {
  41153. toFontChar[i] = unicode;
  41154. }
  41155. }
  41156. for (var charCode in differences) {
  41157. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  41158. if (unicode !== -1) {
  41159. toFontChar[+charCode] = unicode;
  41160. }
  41161. }
  41162. return toFontChar;
  41163. }
  41164. function isProblematicUnicodeLocation(code) {
  41165. var i = 0, j = ProblematicCharRanges.length - 1;
  41166. while (i < j) {
  41167. var c = i + j + 1 >> 1;
  41168. if (code < ProblematicCharRanges[c]) {
  41169. j = c - 1;
  41170. } else {
  41171. i = c;
  41172. }
  41173. }
  41174. return !(i & 1);
  41175. }
  41176. function adjustMapping(charCodeToGlyphId, properties) {
  41177. var toUnicode = properties.toUnicode;
  41178. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  41179. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  41180. var newMap = Object.create(null);
  41181. var toFontChar = [];
  41182. var usedFontCharCodes = [];
  41183. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  41184. for (var originalCharCode in charCodeToGlyphId) {
  41185. originalCharCode |= 0;
  41186. var glyphId = charCodeToGlyphId[originalCharCode];
  41187. var fontCharCode = originalCharCode;
  41188. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  41189. var unicode = toUnicode.get(fontCharCode);
  41190. if (unicode.length === 1) {
  41191. fontCharCode = unicode.charCodeAt(0);
  41192. }
  41193. }
  41194. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && isIdentityUnicode) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  41195. do {
  41196. fontCharCode = nextAvailableFontCharCode++;
  41197. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  41198. fontCharCode = 0xF020;
  41199. nextAvailableFontCharCode = fontCharCode + 1;
  41200. }
  41201. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  41202. }
  41203. newMap[fontCharCode] = glyphId;
  41204. toFontChar[originalCharCode] = fontCharCode;
  41205. usedFontCharCodes[fontCharCode] = true;
  41206. }
  41207. return {
  41208. toFontChar: toFontChar,
  41209. charCodeToGlyphId: newMap,
  41210. nextAvailableFontCharCode: nextAvailableFontCharCode
  41211. };
  41212. }
  41213. function getRanges(glyphs, numGlyphs) {
  41214. var codes = [];
  41215. for (var charCode in glyphs) {
  41216. if (glyphs[charCode] >= numGlyphs) {
  41217. continue;
  41218. }
  41219. codes.push({
  41220. fontCharCode: charCode | 0,
  41221. glyphId: glyphs[charCode]
  41222. });
  41223. }
  41224. codes.sort(function fontGetRangesSort(a, b) {
  41225. return a.fontCharCode - b.fontCharCode;
  41226. });
  41227. var ranges = [];
  41228. var length = codes.length;
  41229. for (var n = 0; n < length;) {
  41230. var start = codes[n].fontCharCode;
  41231. var codeIndices = [codes[n].glyphId];
  41232. ++n;
  41233. var end = start;
  41234. while (n < length && end + 1 === codes[n].fontCharCode) {
  41235. codeIndices.push(codes[n].glyphId);
  41236. ++end;
  41237. ++n;
  41238. if (end === 0xFFFF) {
  41239. break;
  41240. }
  41241. }
  41242. ranges.push([
  41243. start,
  41244. end,
  41245. codeIndices
  41246. ]);
  41247. }
  41248. return ranges;
  41249. }
  41250. function createCmapTable(glyphs, numGlyphs) {
  41251. var ranges = getRanges(glyphs, numGlyphs);
  41252. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  41253. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  41254. var i, ii, j, jj;
  41255. for (i = ranges.length - 1; i >= 0; --i) {
  41256. if (ranges[i][0] <= 0xFFFF) {
  41257. break;
  41258. }
  41259. }
  41260. var bmpLength = i + 1;
  41261. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  41262. ranges[i][1] = 0xFFFE;
  41263. }
  41264. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  41265. var segCount = bmpLength + trailingRangesCount;
  41266. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  41267. var startCount = '';
  41268. var endCount = '';
  41269. var idDeltas = '';
  41270. var idRangeOffsets = '';
  41271. var glyphsIds = '';
  41272. var bias = 0;
  41273. var range, start, end, codes;
  41274. for (i = 0, ii = bmpLength; i < ii; i++) {
  41275. range = ranges[i];
  41276. start = range[0];
  41277. end = range[1];
  41278. startCount += string16(start);
  41279. endCount += string16(end);
  41280. codes = range[2];
  41281. var contiguous = true;
  41282. for (j = 1, jj = codes.length; j < jj; ++j) {
  41283. if (codes[j] !== codes[j - 1] + 1) {
  41284. contiguous = false;
  41285. break;
  41286. }
  41287. }
  41288. if (!contiguous) {
  41289. var offset = (segCount - i) * 2 + bias * 2;
  41290. bias += end - start + 1;
  41291. idDeltas += string16(0);
  41292. idRangeOffsets += string16(offset);
  41293. for (j = 0, jj = codes.length; j < jj; ++j) {
  41294. glyphsIds += string16(codes[j]);
  41295. }
  41296. } else {
  41297. var startCode = codes[0];
  41298. idDeltas += string16(startCode - start & 0xFFFF);
  41299. idRangeOffsets += string16(0);
  41300. }
  41301. }
  41302. if (trailingRangesCount > 0) {
  41303. endCount += '\xFF\xFF';
  41304. startCount += '\xFF\xFF';
  41305. idDeltas += '\x00\x01';
  41306. idRangeOffsets += '\x00\x00';
  41307. }
  41308. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  41309. var format31012 = '';
  41310. var header31012 = '';
  41311. if (numTables > 1) {
  41312. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  41313. format31012 = '';
  41314. for (i = 0, ii = ranges.length; i < ii; i++) {
  41315. range = ranges[i];
  41316. start = range[0];
  41317. codes = range[2];
  41318. var code = codes[0];
  41319. for (j = 1, jj = codes.length; j < jj; ++j) {
  41320. if (codes[j] !== codes[j - 1] + 1) {
  41321. end = range[0] + j - 1;
  41322. format31012 += string32(start) + string32(end) + string32(code);
  41323. start = end + 1;
  41324. code = codes[j];
  41325. }
  41326. }
  41327. format31012 += string32(start) + string32(range[1]) + string32(code);
  41328. }
  41329. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  41330. }
  41331. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  41332. }
  41333. function validateOS2Table(os2) {
  41334. var stream = new Stream(os2.data);
  41335. var version = stream.getUint16();
  41336. stream.getBytes(60);
  41337. var selection = stream.getUint16();
  41338. if (version < 4 && selection & 0x0300) {
  41339. return false;
  41340. }
  41341. var firstChar = stream.getUint16();
  41342. var lastChar = stream.getUint16();
  41343. if (firstChar > lastChar) {
  41344. return false;
  41345. }
  41346. stream.getBytes(6);
  41347. var usWinAscent = stream.getUint16();
  41348. if (usWinAscent === 0) {
  41349. return false;
  41350. }
  41351. os2.data[8] = os2.data[9] = 0;
  41352. return true;
  41353. }
  41354. function createOS2Table(properties, charstrings, override) {
  41355. override = override || {
  41356. unitsPerEm: 0,
  41357. yMax: 0,
  41358. yMin: 0,
  41359. ascent: 0,
  41360. descent: 0
  41361. };
  41362. var ulUnicodeRange1 = 0;
  41363. var ulUnicodeRange2 = 0;
  41364. var ulUnicodeRange3 = 0;
  41365. var ulUnicodeRange4 = 0;
  41366. var firstCharIndex = null;
  41367. var lastCharIndex = 0;
  41368. if (charstrings) {
  41369. for (var code in charstrings) {
  41370. code |= 0;
  41371. if (firstCharIndex > code || !firstCharIndex) {
  41372. firstCharIndex = code;
  41373. }
  41374. if (lastCharIndex < code) {
  41375. lastCharIndex = code;
  41376. }
  41377. var position = getUnicodeRangeFor(code);
  41378. if (position < 32) {
  41379. ulUnicodeRange1 |= 1 << position;
  41380. } else if (position < 64) {
  41381. ulUnicodeRange2 |= 1 << position - 32;
  41382. } else if (position < 96) {
  41383. ulUnicodeRange3 |= 1 << position - 64;
  41384. } else if (position < 123) {
  41385. ulUnicodeRange4 |= 1 << position - 96;
  41386. } else {
  41387. error('Unicode ranges Bits > 123 are reserved for internal usage');
  41388. }
  41389. }
  41390. } else {
  41391. firstCharIndex = 0;
  41392. lastCharIndex = 255;
  41393. }
  41394. var bbox = properties.bbox || [
  41395. 0,
  41396. 0,
  41397. 0,
  41398. 0
  41399. ];
  41400. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  41401. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  41402. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  41403. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  41404. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  41405. typoDescent = -typoDescent;
  41406. }
  41407. var winAscent = override.yMax || typoAscent;
  41408. var winDescent = -override.yMin || -typoDescent;
  41409. 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';
  41410. }
  41411. function createPostTable(properties) {
  41412. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  41413. 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';
  41414. }
  41415. function createNameTable(name, proto) {
  41416. if (!proto) {
  41417. proto = [
  41418. [],
  41419. []
  41420. ];
  41421. }
  41422. var strings = [
  41423. proto[0][0] || 'Original licence',
  41424. proto[0][1] || name,
  41425. proto[0][2] || 'Unknown',
  41426. proto[0][3] || 'uniqueID',
  41427. proto[0][4] || name,
  41428. proto[0][5] || 'Version 0.11',
  41429. proto[0][6] || '',
  41430. proto[0][7] || 'Unknown',
  41431. proto[0][8] || 'Unknown',
  41432. proto[0][9] || 'Unknown'
  41433. ];
  41434. var stringsUnicode = [];
  41435. var i, ii, j, jj, str;
  41436. for (i = 0, ii = strings.length; i < ii; i++) {
  41437. str = proto[1][i] || strings[i];
  41438. var strBufUnicode = [];
  41439. for (j = 0, jj = str.length; j < jj; j++) {
  41440. strBufUnicode.push(string16(str.charCodeAt(j)));
  41441. }
  41442. stringsUnicode.push(strBufUnicode.join(''));
  41443. }
  41444. var names = [
  41445. strings,
  41446. stringsUnicode
  41447. ];
  41448. var platforms = [
  41449. '\x00\x01',
  41450. '\x00\x03'
  41451. ];
  41452. var encodings = [
  41453. '\x00\x00',
  41454. '\x00\x01'
  41455. ];
  41456. var languages = [
  41457. '\x00\x00',
  41458. '\x04\x09'
  41459. ];
  41460. var namesRecordCount = strings.length * platforms.length;
  41461. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  41462. var strOffset = 0;
  41463. for (i = 0, ii = platforms.length; i < ii; i++) {
  41464. var strs = names[i];
  41465. for (j = 0, jj = strs.length; j < jj; j++) {
  41466. str = strs[j];
  41467. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  41468. nameTable += nameRecord;
  41469. strOffset += str.length;
  41470. }
  41471. }
  41472. nameTable += strings.join('') + stringsUnicode.join('');
  41473. return nameTable;
  41474. }
  41475. Font.prototype = {
  41476. name: null,
  41477. font: null,
  41478. mimetype: null,
  41479. encoding: null,
  41480. get renderer() {
  41481. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  41482. return shadow(this, 'renderer', renderer);
  41483. },
  41484. exportData: function Font_exportData() {
  41485. var data = {};
  41486. for (var i in this) {
  41487. if (this.hasOwnProperty(i)) {
  41488. data[i] = this[i];
  41489. }
  41490. }
  41491. return data;
  41492. },
  41493. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  41494. function readTableEntry(file) {
  41495. var tag = bytesToString(file.getBytes(4));
  41496. var checksum = file.getInt32() >>> 0;
  41497. var offset = file.getInt32() >>> 0;
  41498. var length = file.getInt32() >>> 0;
  41499. var previousPosition = file.pos;
  41500. file.pos = file.start ? file.start : 0;
  41501. file.skip(offset);
  41502. var data = file.getBytes(length);
  41503. file.pos = previousPosition;
  41504. if (tag === 'head') {
  41505. data[8] = data[9] = data[10] = data[11] = 0;
  41506. data[17] |= 0x20;
  41507. }
  41508. return {
  41509. tag: tag,
  41510. checksum: checksum,
  41511. length: length,
  41512. offset: offset,
  41513. data: data
  41514. };
  41515. }
  41516. function readOpenTypeHeader(ttf) {
  41517. return {
  41518. version: bytesToString(ttf.getBytes(4)),
  41519. numTables: ttf.getUint16(),
  41520. searchRange: ttf.getUint16(),
  41521. entrySelector: ttf.getUint16(),
  41522. rangeShift: ttf.getUint16()
  41523. };
  41524. }
  41525. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  41526. if (!cmap) {
  41527. warn('No cmap table available.');
  41528. return {
  41529. platformId: -1,
  41530. encodingId: -1,
  41531. mappings: [],
  41532. hasShortCmap: false
  41533. };
  41534. }
  41535. var segment;
  41536. var start = (font.start ? font.start : 0) + cmap.offset;
  41537. font.pos = start;
  41538. var version = font.getUint16();
  41539. var numTables = font.getUint16();
  41540. var potentialTable;
  41541. var canBreak = false;
  41542. for (var i = 0; i < numTables; i++) {
  41543. var platformId = font.getUint16();
  41544. var encodingId = font.getUint16();
  41545. var offset = font.getInt32() >>> 0;
  41546. var useTable = false;
  41547. if (platformId === 0 && encodingId === 0) {
  41548. useTable = true;
  41549. } else if (platformId === 1 && encodingId === 0) {
  41550. useTable = true;
  41551. } else if (platformId === 3 && encodingId === 1 && (!isSymbolicFont && hasEncoding || !potentialTable)) {
  41552. useTable = true;
  41553. if (!isSymbolicFont) {
  41554. canBreak = true;
  41555. }
  41556. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  41557. useTable = true;
  41558. canBreak = true;
  41559. }
  41560. if (useTable) {
  41561. potentialTable = {
  41562. platformId: platformId,
  41563. encodingId: encodingId,
  41564. offset: offset
  41565. };
  41566. }
  41567. if (canBreak) {
  41568. break;
  41569. }
  41570. }
  41571. if (potentialTable) {
  41572. font.pos = start + potentialTable.offset;
  41573. }
  41574. if (!potentialTable || font.peekByte() === -1) {
  41575. warn('Could not find a preferred cmap table.');
  41576. return {
  41577. platformId: -1,
  41578. encodingId: -1,
  41579. mappings: [],
  41580. hasShortCmap: false
  41581. };
  41582. }
  41583. var format = font.getUint16();
  41584. var length = font.getUint16();
  41585. var language = font.getUint16();
  41586. var hasShortCmap = false;
  41587. var mappings = [];
  41588. var j, glyphId;
  41589. if (format === 0) {
  41590. for (j = 0; j < 256; j++) {
  41591. var index = font.getByte();
  41592. if (!index) {
  41593. continue;
  41594. }
  41595. mappings.push({
  41596. charCode: j,
  41597. glyphId: index
  41598. });
  41599. }
  41600. hasShortCmap = true;
  41601. } else if (format === 4) {
  41602. var segCount = font.getUint16() >> 1;
  41603. font.getBytes(6);
  41604. var segIndex, segments = [];
  41605. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41606. segments.push({ end: font.getUint16() });
  41607. }
  41608. font.getUint16();
  41609. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41610. segments[segIndex].start = font.getUint16();
  41611. }
  41612. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41613. segments[segIndex].delta = font.getUint16();
  41614. }
  41615. var offsetsCount = 0;
  41616. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41617. segment = segments[segIndex];
  41618. var rangeOffset = font.getUint16();
  41619. if (!rangeOffset) {
  41620. segment.offsetIndex = -1;
  41621. continue;
  41622. }
  41623. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  41624. segment.offsetIndex = offsetIndex;
  41625. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  41626. }
  41627. var offsets = [];
  41628. for (j = 0; j < offsetsCount; j++) {
  41629. offsets.push(font.getUint16());
  41630. }
  41631. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41632. segment = segments[segIndex];
  41633. start = segment.start;
  41634. var end = segment.end;
  41635. var delta = segment.delta;
  41636. offsetIndex = segment.offsetIndex;
  41637. for (j = start; j <= end; j++) {
  41638. if (j === 0xFFFF) {
  41639. continue;
  41640. }
  41641. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  41642. glyphId = glyphId + delta & 0xFFFF;
  41643. if (glyphId === 0) {
  41644. continue;
  41645. }
  41646. mappings.push({
  41647. charCode: j,
  41648. glyphId: glyphId
  41649. });
  41650. }
  41651. }
  41652. } else if (format === 6) {
  41653. var firstCode = font.getUint16();
  41654. var entryCount = font.getUint16();
  41655. for (j = 0; j < entryCount; j++) {
  41656. glyphId = font.getUint16();
  41657. var charCode = firstCode + j;
  41658. mappings.push({
  41659. charCode: charCode,
  41660. glyphId: glyphId
  41661. });
  41662. }
  41663. } else {
  41664. warn('cmap table has unsupported format: ' + format);
  41665. return {
  41666. platformId: -1,
  41667. encodingId: -1,
  41668. mappings: [],
  41669. hasShortCmap: false
  41670. };
  41671. }
  41672. mappings.sort(function (a, b) {
  41673. return a.charCode - b.charCode;
  41674. });
  41675. for (i = 1; i < mappings.length; i++) {
  41676. if (mappings[i - 1].charCode === mappings[i].charCode) {
  41677. mappings.splice(i, 1);
  41678. i--;
  41679. }
  41680. }
  41681. return {
  41682. platformId: potentialTable.platformId,
  41683. encodingId: potentialTable.encodingId,
  41684. mappings: mappings,
  41685. hasShortCmap: hasShortCmap
  41686. };
  41687. }
  41688. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  41689. if (!header) {
  41690. if (metrics) {
  41691. metrics.data = null;
  41692. }
  41693. return;
  41694. }
  41695. font.pos = (font.start ? font.start : 0) + header.offset;
  41696. font.pos += header.length - 2;
  41697. var numOfMetrics = font.getUint16();
  41698. if (numOfMetrics > numGlyphs) {
  41699. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  41700. numOfMetrics = numGlyphs;
  41701. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  41702. header.data[35] = numOfMetrics & 0x00ff;
  41703. }
  41704. var numOfSidebearings = numGlyphs - numOfMetrics;
  41705. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  41706. if (numMissing > 0) {
  41707. var entries = new Uint8Array(metrics.length + numMissing * 2);
  41708. entries.set(metrics.data);
  41709. metrics.data = entries;
  41710. }
  41711. }
  41712. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  41713. if (sourceEnd - sourceStart <= 12) {
  41714. return 0;
  41715. }
  41716. var glyf = source.subarray(sourceStart, sourceEnd);
  41717. var contoursCount = glyf[0] << 8 | glyf[1];
  41718. if (contoursCount & 0x8000) {
  41719. dest.set(glyf, destStart);
  41720. return glyf.length;
  41721. }
  41722. var i, j = 10, flagsCount = 0;
  41723. for (i = 0; i < contoursCount; i++) {
  41724. var endPoint = glyf[j] << 8 | glyf[j + 1];
  41725. flagsCount = endPoint + 1;
  41726. j += 2;
  41727. }
  41728. var instructionsStart = j;
  41729. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  41730. j += 2 + instructionsLength;
  41731. var instructionsEnd = j;
  41732. var coordinatesLength = 0;
  41733. for (i = 0; i < flagsCount; i++) {
  41734. var flag = glyf[j++];
  41735. if (flag & 0xC0) {
  41736. glyf[j - 1] = flag & 0x3F;
  41737. }
  41738. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  41739. coordinatesLength += xyLength;
  41740. if (flag & 8) {
  41741. var repeat = glyf[j++];
  41742. i += repeat;
  41743. coordinatesLength += repeat * xyLength;
  41744. }
  41745. }
  41746. if (coordinatesLength === 0) {
  41747. return 0;
  41748. }
  41749. var glyphDataLength = j + coordinatesLength;
  41750. if (glyphDataLength > glyf.length) {
  41751. return 0;
  41752. }
  41753. if (!hintsValid && instructionsLength > 0) {
  41754. dest.set(glyf.subarray(0, instructionsStart), destStart);
  41755. dest.set([
  41756. 0,
  41757. 0
  41758. ], destStart + instructionsStart);
  41759. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  41760. glyphDataLength -= instructionsLength;
  41761. if (glyf.length - glyphDataLength > 3) {
  41762. glyphDataLength = glyphDataLength + 3 & ~3;
  41763. }
  41764. return glyphDataLength;
  41765. }
  41766. if (glyf.length - glyphDataLength > 3) {
  41767. glyphDataLength = glyphDataLength + 3 & ~3;
  41768. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  41769. return glyphDataLength;
  41770. }
  41771. dest.set(glyf, destStart);
  41772. return glyf.length;
  41773. }
  41774. function sanitizeHead(head, numGlyphs, locaLength) {
  41775. var data = head.data;
  41776. var version = int32(data[0], data[1], data[2], data[3]);
  41777. if (version >> 16 !== 1) {
  41778. info('Attempting to fix invalid version in head table: ' + version);
  41779. data[0] = 0;
  41780. data[1] = 1;
  41781. data[2] = 0;
  41782. data[3] = 0;
  41783. }
  41784. var indexToLocFormat = int16(data[50], data[51]);
  41785. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  41786. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  41787. var numGlyphsPlusOne = numGlyphs + 1;
  41788. if (locaLength === numGlyphsPlusOne << 1) {
  41789. data[50] = 0;
  41790. data[51] = 0;
  41791. } else if (locaLength === numGlyphsPlusOne << 2) {
  41792. data[50] = 0;
  41793. data[51] = 1;
  41794. } else {
  41795. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  41796. }
  41797. }
  41798. }
  41799. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  41800. var itemSize, itemDecode, itemEncode;
  41801. if (isGlyphLocationsLong) {
  41802. itemSize = 4;
  41803. itemDecode = function fontItemDecodeLong(data, offset) {
  41804. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  41805. };
  41806. itemEncode = function fontItemEncodeLong(data, offset, value) {
  41807. data[offset] = value >>> 24 & 0xFF;
  41808. data[offset + 1] = value >> 16 & 0xFF;
  41809. data[offset + 2] = value >> 8 & 0xFF;
  41810. data[offset + 3] = value & 0xFF;
  41811. };
  41812. } else {
  41813. itemSize = 2;
  41814. itemDecode = function fontItemDecode(data, offset) {
  41815. return data[offset] << 9 | data[offset + 1] << 1;
  41816. };
  41817. itemEncode = function fontItemEncode(data, offset, value) {
  41818. data[offset] = value >> 9 & 0xFF;
  41819. data[offset + 1] = value >> 1 & 0xFF;
  41820. };
  41821. }
  41822. var locaData = loca.data;
  41823. var locaDataSize = itemSize * (1 + numGlyphs);
  41824. if (locaData.length !== locaDataSize) {
  41825. locaData = new Uint8Array(locaDataSize);
  41826. locaData.set(loca.data.subarray(0, locaDataSize));
  41827. loca.data = locaData;
  41828. }
  41829. var oldGlyfData = glyf.data;
  41830. var oldGlyfDataLength = oldGlyfData.length;
  41831. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  41832. var startOffset = itemDecode(locaData, 0);
  41833. var writeOffset = 0;
  41834. var missingGlyphData = Object.create(null);
  41835. itemEncode(locaData, 0, writeOffset);
  41836. var i, j;
  41837. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  41838. var endOffset = itemDecode(locaData, j);
  41839. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  41840. endOffset = oldGlyfDataLength;
  41841. }
  41842. if (endOffset > oldGlyfDataLength) {
  41843. itemEncode(locaData, j, writeOffset);
  41844. startOffset = endOffset;
  41845. continue;
  41846. }
  41847. if (startOffset === endOffset) {
  41848. missingGlyphData[i] = true;
  41849. }
  41850. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  41851. writeOffset += newLength;
  41852. itemEncode(locaData, j, writeOffset);
  41853. startOffset = endOffset;
  41854. }
  41855. if (writeOffset === 0) {
  41856. var simpleGlyph = new Uint8Array([
  41857. 0,
  41858. 1,
  41859. 0,
  41860. 0,
  41861. 0,
  41862. 0,
  41863. 0,
  41864. 0,
  41865. 0,
  41866. 0,
  41867. 0,
  41868. 0,
  41869. 0,
  41870. 0,
  41871. 49,
  41872. 0
  41873. ]);
  41874. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  41875. itemEncode(locaData, j, simpleGlyph.length);
  41876. }
  41877. glyf.data = simpleGlyph;
  41878. return missingGlyphData;
  41879. }
  41880. if (dupFirstEntry) {
  41881. var firstEntryLength = itemDecode(locaData, itemSize);
  41882. if (newGlyfData.length > firstEntryLength + writeOffset) {
  41883. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  41884. } else {
  41885. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  41886. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  41887. }
  41888. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  41889. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  41890. } else {
  41891. glyf.data = newGlyfData.subarray(0, writeOffset);
  41892. }
  41893. return missingGlyphData;
  41894. }
  41895. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  41896. var start = (font.start ? font.start : 0) + post.offset;
  41897. font.pos = start;
  41898. var length = post.length, end = start + length;
  41899. var version = font.getInt32();
  41900. font.getBytes(28);
  41901. var glyphNames;
  41902. var valid = true;
  41903. var i;
  41904. switch (version) {
  41905. case 0x00010000:
  41906. glyphNames = MacStandardGlyphOrdering;
  41907. break;
  41908. case 0x00020000:
  41909. var numGlyphs = font.getUint16();
  41910. if (numGlyphs !== maxpNumGlyphs) {
  41911. valid = false;
  41912. break;
  41913. }
  41914. var glyphNameIndexes = [];
  41915. for (i = 0; i < numGlyphs; ++i) {
  41916. var index = font.getUint16();
  41917. if (index >= 32768) {
  41918. valid = false;
  41919. break;
  41920. }
  41921. glyphNameIndexes.push(index);
  41922. }
  41923. if (!valid) {
  41924. break;
  41925. }
  41926. var customNames = [];
  41927. var strBuf = [];
  41928. while (font.pos < end) {
  41929. var stringLength = font.getByte();
  41930. strBuf.length = stringLength;
  41931. for (i = 0; i < stringLength; ++i) {
  41932. strBuf[i] = String.fromCharCode(font.getByte());
  41933. }
  41934. customNames.push(strBuf.join(''));
  41935. }
  41936. glyphNames = [];
  41937. for (i = 0; i < numGlyphs; ++i) {
  41938. var j = glyphNameIndexes[i];
  41939. if (j < 258) {
  41940. glyphNames.push(MacStandardGlyphOrdering[j]);
  41941. continue;
  41942. }
  41943. glyphNames.push(customNames[j - 258]);
  41944. }
  41945. break;
  41946. case 0x00030000:
  41947. break;
  41948. default:
  41949. warn('Unknown/unsupported post table version ' + version);
  41950. valid = false;
  41951. if (properties.defaultEncoding) {
  41952. glyphNames = properties.defaultEncoding;
  41953. }
  41954. break;
  41955. }
  41956. properties.glyphNames = glyphNames;
  41957. return valid;
  41958. }
  41959. function readNameTable(nameTable) {
  41960. var start = (font.start ? font.start : 0) + nameTable.offset;
  41961. font.pos = start;
  41962. var names = [
  41963. [],
  41964. []
  41965. ];
  41966. var length = nameTable.length, end = start + length;
  41967. var format = font.getUint16();
  41968. var FORMAT_0_HEADER_LENGTH = 6;
  41969. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  41970. return names;
  41971. }
  41972. var numRecords = font.getUint16();
  41973. var stringsStart = font.getUint16();
  41974. var records = [];
  41975. var NAME_RECORD_LENGTH = 12;
  41976. var i, ii;
  41977. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  41978. var r = {
  41979. platform: font.getUint16(),
  41980. encoding: font.getUint16(),
  41981. language: font.getUint16(),
  41982. name: font.getUint16(),
  41983. length: font.getUint16(),
  41984. offset: font.getUint16()
  41985. };
  41986. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  41987. records.push(r);
  41988. }
  41989. }
  41990. for (i = 0, ii = records.length; i < ii; i++) {
  41991. var record = records[i];
  41992. if (record.length <= 0) {
  41993. continue;
  41994. }
  41995. var pos = start + stringsStart + record.offset;
  41996. if (pos + record.length > end) {
  41997. continue;
  41998. }
  41999. font.pos = pos;
  42000. var nameIndex = record.name;
  42001. if (record.encoding) {
  42002. var str = '';
  42003. for (var j = 0, jj = record.length; j < jj; j += 2) {
  42004. str += String.fromCharCode(font.getUint16());
  42005. }
  42006. names[1][nameIndex] = str;
  42007. } else {
  42008. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  42009. }
  42010. }
  42011. return names;
  42012. }
  42013. var TTOpsStackDeltas = [
  42014. 0,
  42015. 0,
  42016. 0,
  42017. 0,
  42018. 0,
  42019. 0,
  42020. 0,
  42021. 0,
  42022. -2,
  42023. -2,
  42024. -2,
  42025. -2,
  42026. 0,
  42027. 0,
  42028. -2,
  42029. -5,
  42030. -1,
  42031. -1,
  42032. -1,
  42033. -1,
  42034. -1,
  42035. -1,
  42036. -1,
  42037. -1,
  42038. 0,
  42039. 0,
  42040. -1,
  42041. 0,
  42042. -1,
  42043. -1,
  42044. -1,
  42045. -1,
  42046. 1,
  42047. -1,
  42048. -999,
  42049. 0,
  42050. 1,
  42051. 0,
  42052. -1,
  42053. -2,
  42054. 0,
  42055. -1,
  42056. -2,
  42057. -1,
  42058. -1,
  42059. 0,
  42060. -1,
  42061. -1,
  42062. 0,
  42063. 0,
  42064. -999,
  42065. -999,
  42066. -1,
  42067. -1,
  42068. -1,
  42069. -1,
  42070. -2,
  42071. -999,
  42072. -2,
  42073. -2,
  42074. -999,
  42075. 0,
  42076. -2,
  42077. -2,
  42078. 0,
  42079. 0,
  42080. -2,
  42081. 0,
  42082. -2,
  42083. 0,
  42084. 0,
  42085. 0,
  42086. -2,
  42087. -1,
  42088. -1,
  42089. 1,
  42090. 1,
  42091. 0,
  42092. 0,
  42093. -1,
  42094. -1,
  42095. -1,
  42096. -1,
  42097. -1,
  42098. -1,
  42099. -1,
  42100. 0,
  42101. 0,
  42102. -1,
  42103. 0,
  42104. -1,
  42105. -1,
  42106. 0,
  42107. -999,
  42108. -1,
  42109. -1,
  42110. -1,
  42111. -1,
  42112. -1,
  42113. -1,
  42114. 0,
  42115. 0,
  42116. 0,
  42117. 0,
  42118. 0,
  42119. 0,
  42120. 0,
  42121. 0,
  42122. 0,
  42123. 0,
  42124. 0,
  42125. 0,
  42126. -2,
  42127. -999,
  42128. -999,
  42129. -999,
  42130. -999,
  42131. -999,
  42132. -1,
  42133. -1,
  42134. -2,
  42135. -2,
  42136. 0,
  42137. 0,
  42138. 0,
  42139. 0,
  42140. -1,
  42141. -1,
  42142. -999,
  42143. -2,
  42144. -2,
  42145. 0,
  42146. 0,
  42147. -1,
  42148. -2,
  42149. -2,
  42150. 0,
  42151. 0,
  42152. 0,
  42153. -1,
  42154. -1,
  42155. -1,
  42156. -2
  42157. ];
  42158. function sanitizeTTProgram(table, ttContext) {
  42159. var data = table.data;
  42160. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  42161. var stack = [];
  42162. var callstack = [];
  42163. var functionsCalled = [];
  42164. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  42165. var inFDEF = false, ifLevel = 0, inELSE = 0;
  42166. for (var ii = data.length; i < ii;) {
  42167. var op = data[i++];
  42168. if (op === 0x40) {
  42169. n = data[i++];
  42170. if (inFDEF || inELSE) {
  42171. i += n;
  42172. } else {
  42173. for (j = 0; j < n; j++) {
  42174. stack.push(data[i++]);
  42175. }
  42176. }
  42177. } else if (op === 0x41) {
  42178. n = data[i++];
  42179. if (inFDEF || inELSE) {
  42180. i += n * 2;
  42181. } else {
  42182. for (j = 0; j < n; j++) {
  42183. b = data[i++];
  42184. stack.push(b << 8 | data[i++]);
  42185. }
  42186. }
  42187. } else if ((op & 0xF8) === 0xB0) {
  42188. n = op - 0xB0 + 1;
  42189. if (inFDEF || inELSE) {
  42190. i += n;
  42191. } else {
  42192. for (j = 0; j < n; j++) {
  42193. stack.push(data[i++]);
  42194. }
  42195. }
  42196. } else if ((op & 0xF8) === 0xB8) {
  42197. n = op - 0xB8 + 1;
  42198. if (inFDEF || inELSE) {
  42199. i += n * 2;
  42200. } else {
  42201. for (j = 0; j < n; j++) {
  42202. b = data[i++];
  42203. stack.push(b << 8 | data[i++]);
  42204. }
  42205. }
  42206. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  42207. if (!inFDEF && !inELSE) {
  42208. funcId = stack[stack.length - 1];
  42209. ttContext.functionsUsed[funcId] = true;
  42210. if (funcId in ttContext.functionsStackDeltas) {
  42211. stack.length += ttContext.functionsStackDeltas[funcId];
  42212. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  42213. callstack.push({
  42214. data: data,
  42215. i: i,
  42216. stackTop: stack.length - 1
  42217. });
  42218. functionsCalled.push(funcId);
  42219. pc = ttContext.functionsDefined[funcId];
  42220. if (!pc) {
  42221. warn('TT: CALL non-existent function');
  42222. ttContext.hintsValid = false;
  42223. return;
  42224. }
  42225. data = pc.data;
  42226. i = pc.i;
  42227. }
  42228. }
  42229. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  42230. if (inFDEF || inELSE) {
  42231. warn('TT: nested FDEFs not allowed');
  42232. tooComplexToFollowFunctions = true;
  42233. }
  42234. inFDEF = true;
  42235. lastDeff = i;
  42236. funcId = stack.pop();
  42237. ttContext.functionsDefined[funcId] = {
  42238. data: data,
  42239. i: i
  42240. };
  42241. } else if (op === 0x2D) {
  42242. if (inFDEF) {
  42243. inFDEF = false;
  42244. lastEndf = i;
  42245. } else {
  42246. pc = callstack.pop();
  42247. if (!pc) {
  42248. warn('TT: ENDF bad stack');
  42249. ttContext.hintsValid = false;
  42250. return;
  42251. }
  42252. funcId = functionsCalled.pop();
  42253. data = pc.data;
  42254. i = pc.i;
  42255. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  42256. }
  42257. } else if (op === 0x89) {
  42258. if (inFDEF || inELSE) {
  42259. warn('TT: nested IDEFs not allowed');
  42260. tooComplexToFollowFunctions = true;
  42261. }
  42262. inFDEF = true;
  42263. lastDeff = i;
  42264. } else if (op === 0x58) {
  42265. ++ifLevel;
  42266. } else if (op === 0x1B) {
  42267. inELSE = ifLevel;
  42268. } else if (op === 0x59) {
  42269. if (inELSE === ifLevel) {
  42270. inELSE = 0;
  42271. }
  42272. --ifLevel;
  42273. } else if (op === 0x1C) {
  42274. if (!inFDEF && !inELSE) {
  42275. var offset = stack[stack.length - 1];
  42276. if (offset > 0) {
  42277. i += offset - 1;
  42278. }
  42279. }
  42280. }
  42281. if (!inFDEF && !inELSE) {
  42282. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  42283. if (op >= 0x71 && op <= 0x75) {
  42284. n = stack.pop();
  42285. if (n === n) {
  42286. stackDelta = -n * 2;
  42287. }
  42288. }
  42289. while (stackDelta < 0 && stack.length > 0) {
  42290. stack.pop();
  42291. stackDelta++;
  42292. }
  42293. while (stackDelta > 0) {
  42294. stack.push(NaN);
  42295. stackDelta--;
  42296. }
  42297. }
  42298. }
  42299. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  42300. var content = [data];
  42301. if (i > data.length) {
  42302. content.push(new Uint8Array(i - data.length));
  42303. }
  42304. if (lastDeff > lastEndf) {
  42305. warn('TT: complementing a missing function tail');
  42306. content.push(new Uint8Array([
  42307. 0x22,
  42308. 0x2D
  42309. ]));
  42310. }
  42311. foldTTTable(table, content);
  42312. }
  42313. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  42314. if (ttContext.tooComplexToFollowFunctions) {
  42315. return;
  42316. }
  42317. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  42318. warn('TT: more functions defined than expected');
  42319. ttContext.hintsValid = false;
  42320. return;
  42321. }
  42322. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  42323. if (j > maxFunctionDefs) {
  42324. warn('TT: invalid function id: ' + j);
  42325. ttContext.hintsValid = false;
  42326. return;
  42327. }
  42328. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  42329. warn('TT: undefined function: ' + j);
  42330. ttContext.hintsValid = false;
  42331. return;
  42332. }
  42333. }
  42334. }
  42335. function foldTTTable(table, content) {
  42336. if (content.length > 1) {
  42337. var newLength = 0;
  42338. var j, jj;
  42339. for (j = 0, jj = content.length; j < jj; j++) {
  42340. newLength += content[j].length;
  42341. }
  42342. newLength = newLength + 3 & ~3;
  42343. var result = new Uint8Array(newLength);
  42344. var pos = 0;
  42345. for (j = 0, jj = content.length; j < jj; j++) {
  42346. result.set(content[j], pos);
  42347. pos += content[j].length;
  42348. }
  42349. table.data = result;
  42350. table.length = newLength;
  42351. }
  42352. }
  42353. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  42354. var ttContext = {
  42355. functionsDefined: [],
  42356. functionsUsed: [],
  42357. functionsStackDeltas: [],
  42358. tooComplexToFollowFunctions: false,
  42359. hintsValid: true
  42360. };
  42361. if (fpgm) {
  42362. sanitizeTTProgram(fpgm, ttContext);
  42363. }
  42364. if (prep) {
  42365. sanitizeTTProgram(prep, ttContext);
  42366. }
  42367. if (fpgm) {
  42368. checkInvalidFunctions(ttContext, maxFunctionDefs);
  42369. }
  42370. if (cvt && cvt.length & 1) {
  42371. var cvtData = new Uint8Array(cvt.length + 1);
  42372. cvtData.set(cvt.data);
  42373. cvt.data = cvtData;
  42374. }
  42375. return ttContext.hintsValid;
  42376. }
  42377. font = new Stream(new Uint8Array(font.getBytes()));
  42378. var VALID_TABLES = [
  42379. 'OS/2',
  42380. 'cmap',
  42381. 'head',
  42382. 'hhea',
  42383. 'hmtx',
  42384. 'maxp',
  42385. 'name',
  42386. 'post',
  42387. 'loca',
  42388. 'glyf',
  42389. 'fpgm',
  42390. 'prep',
  42391. 'cvt ',
  42392. 'CFF '
  42393. ];
  42394. var header = readOpenTypeHeader(font);
  42395. var numTables = header.numTables;
  42396. var cff, cffFile;
  42397. var tables = Object.create(null);
  42398. tables['OS/2'] = null;
  42399. tables['cmap'] = null;
  42400. tables['head'] = null;
  42401. tables['hhea'] = null;
  42402. tables['hmtx'] = null;
  42403. tables['maxp'] = null;
  42404. tables['name'] = null;
  42405. tables['post'] = null;
  42406. var table;
  42407. for (var i = 0; i < numTables; i++) {
  42408. table = readTableEntry(font);
  42409. if (VALID_TABLES.indexOf(table.tag) < 0) {
  42410. continue;
  42411. }
  42412. if (table.length === 0) {
  42413. continue;
  42414. }
  42415. tables[table.tag] = table;
  42416. }
  42417. var isTrueType = !tables['CFF '];
  42418. if (!isTrueType) {
  42419. if (header.version === 'OTTO' && properties.type !== 'CIDFontType2' || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  42420. cffFile = new Stream(tables['CFF '].data);
  42421. cff = new CFFFont(cffFile, properties);
  42422. adjustWidths(properties);
  42423. return this.convert(name, cff, properties);
  42424. }
  42425. delete tables['glyf'];
  42426. delete tables['loca'];
  42427. delete tables['fpgm'];
  42428. delete tables['prep'];
  42429. delete tables['cvt '];
  42430. this.isOpenType = true;
  42431. } else {
  42432. if (!tables['loca']) {
  42433. error('Required "loca" table is not found');
  42434. }
  42435. if (!tables['glyf']) {
  42436. warn('Required "glyf" table is not found -- trying to recover.');
  42437. tables['glyf'] = {
  42438. tag: 'glyf',
  42439. data: new Uint8Array(0)
  42440. };
  42441. }
  42442. this.isOpenType = false;
  42443. }
  42444. if (!tables['maxp']) {
  42445. error('Required "maxp" table is not found');
  42446. }
  42447. font.pos = (font.start || 0) + tables['maxp'].offset;
  42448. var version = font.getInt32();
  42449. var numGlyphs = font.getUint16();
  42450. var maxFunctionDefs = 0;
  42451. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  42452. font.pos += 8;
  42453. var maxZones = font.getUint16();
  42454. if (maxZones > 2) {
  42455. tables['maxp'].data[14] = 0;
  42456. tables['maxp'].data[15] = 2;
  42457. }
  42458. font.pos += 4;
  42459. maxFunctionDefs = font.getUint16();
  42460. }
  42461. var dupFirstEntry = false;
  42462. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  42463. dupFirstEntry = true;
  42464. numGlyphs++;
  42465. tables['maxp'].data[4] = numGlyphs >> 8;
  42466. tables['maxp'].data[5] = numGlyphs & 255;
  42467. }
  42468. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  42469. if (!hintsValid) {
  42470. delete tables['fpgm'];
  42471. delete tables['prep'];
  42472. delete tables['cvt '];
  42473. }
  42474. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  42475. if (!tables['head']) {
  42476. error('Required "head" table is not found');
  42477. }
  42478. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  42479. var missingGlyphs = Object.create(null);
  42480. if (isTrueType) {
  42481. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  42482. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  42483. }
  42484. if (!tables['hhea']) {
  42485. error('Required "hhea" table is not found');
  42486. }
  42487. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  42488. tables['hhea'].data[10] = 0xFF;
  42489. tables['hhea'].data[11] = 0xFF;
  42490. }
  42491. var metricsOverride = {
  42492. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  42493. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  42494. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  42495. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  42496. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  42497. };
  42498. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  42499. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  42500. if (tables['post']) {
  42501. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  42502. if (!valid) {
  42503. tables['post'] = null;
  42504. }
  42505. }
  42506. var charCodeToGlyphId = [], charCode;
  42507. var toUnicode = properties.toUnicode, widths = properties.widths;
  42508. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  42509. function hasGlyph(glyphId, charCode, widthCode) {
  42510. if (!missingGlyphs[glyphId]) {
  42511. return true;
  42512. }
  42513. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  42514. return true;
  42515. }
  42516. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  42517. return true;
  42518. }
  42519. return false;
  42520. }
  42521. if (properties.type === 'CIDFontType2') {
  42522. var cidToGidMap = properties.cidToGidMap || [];
  42523. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  42524. properties.cMap.forEach(function (charCode, cid) {
  42525. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  42526. var glyphId = -1;
  42527. if (isCidToGidMapEmpty) {
  42528. glyphId = cid;
  42529. } else if (cidToGidMap[cid] !== undefined) {
  42530. glyphId = cidToGidMap[cid];
  42531. }
  42532. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  42533. charCodeToGlyphId[charCode] = glyphId;
  42534. }
  42535. });
  42536. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  42537. charCodeToGlyphId[0] = numGlyphs - 1;
  42538. }
  42539. } else {
  42540. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  42541. var cmapPlatformId = cmapTable.platformId;
  42542. var cmapEncodingId = cmapTable.encodingId;
  42543. var cmapMappings = cmapTable.mappings;
  42544. var cmapMappingsLength = cmapMappings.length;
  42545. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  42546. var baseEncoding = [];
  42547. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  42548. baseEncoding = getEncoding(properties.baseEncodingName);
  42549. }
  42550. var glyphsUnicodeMap = getGlyphsUnicode();
  42551. for (charCode = 0; charCode < 256; charCode++) {
  42552. var glyphName, standardGlyphName;
  42553. if (this.differences && charCode in this.differences) {
  42554. glyphName = this.differences[charCode];
  42555. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  42556. glyphName = baseEncoding[charCode];
  42557. } else {
  42558. glyphName = StandardEncoding[charCode];
  42559. }
  42560. if (!glyphName) {
  42561. continue;
  42562. }
  42563. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  42564. var unicodeOrCharCode, isUnicode = false;
  42565. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  42566. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  42567. isUnicode = true;
  42568. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  42569. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  42570. }
  42571. var found = false;
  42572. for (i = 0; i < cmapMappingsLength; ++i) {
  42573. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  42574. continue;
  42575. }
  42576. var code = isUnicode ? charCode : unicodeOrCharCode;
  42577. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  42578. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  42579. found = true;
  42580. break;
  42581. }
  42582. }
  42583. if (!found && properties.glyphNames) {
  42584. var glyphId = properties.glyphNames.indexOf(glyphName);
  42585. if (glyphId === -1 && standardGlyphName !== glyphName) {
  42586. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  42587. }
  42588. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  42589. charCodeToGlyphId[charCode] = glyphId;
  42590. found = true;
  42591. }
  42592. }
  42593. if (!found) {
  42594. charCodeToGlyphId[charCode] = 0;
  42595. }
  42596. }
  42597. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  42598. for (i = 0; i < cmapMappingsLength; ++i) {
  42599. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  42600. }
  42601. } else {
  42602. for (i = 0; i < cmapMappingsLength; ++i) {
  42603. charCode = cmapMappings[i].charCode & 0xFF;
  42604. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  42605. }
  42606. }
  42607. }
  42608. if (charCodeToGlyphId.length === 0) {
  42609. charCodeToGlyphId[0] = 0;
  42610. }
  42611. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  42612. this.toFontChar = newMapping.toFontChar;
  42613. tables['cmap'] = {
  42614. tag: 'cmap',
  42615. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  42616. };
  42617. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  42618. tables['OS/2'] = {
  42619. tag: 'OS/2',
  42620. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  42621. };
  42622. }
  42623. if (!tables['post']) {
  42624. tables['post'] = {
  42625. tag: 'post',
  42626. data: createPostTable(properties)
  42627. };
  42628. }
  42629. if (!isTrueType) {
  42630. try {
  42631. cffFile = new Stream(tables['CFF '].data);
  42632. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  42633. cff = parser.parse();
  42634. var compiler = new CFFCompiler(cff);
  42635. tables['CFF '].data = compiler.compile();
  42636. } catch (e) {
  42637. warn('Failed to compile font ' + properties.loadedName);
  42638. }
  42639. }
  42640. if (!tables['name']) {
  42641. tables['name'] = {
  42642. tag: 'name',
  42643. data: createNameTable(this.name)
  42644. };
  42645. } else {
  42646. var namePrototype = readNameTable(tables['name']);
  42647. tables['name'].data = createNameTable(name, namePrototype);
  42648. }
  42649. var builder = new OpenTypeFileBuilder(header.version);
  42650. for (var tableTag in tables) {
  42651. builder.addTable(tableTag, tables[tableTag].data);
  42652. }
  42653. return builder.toArray();
  42654. },
  42655. convert: function Font_convert(fontName, font, properties) {
  42656. properties.fixedPitch = false;
  42657. if (properties.builtInEncoding) {
  42658. adjustToUnicode(properties, properties.builtInEncoding);
  42659. }
  42660. var mapping = font.getGlyphMapping(properties);
  42661. var newMapping = adjustMapping(mapping, properties);
  42662. this.toFontChar = newMapping.toFontChar;
  42663. var numGlyphs = font.numGlyphs;
  42664. function getCharCodes(charCodeToGlyphId, glyphId) {
  42665. var charCodes = null;
  42666. for (var charCode in charCodeToGlyphId) {
  42667. if (glyphId === charCodeToGlyphId[charCode]) {
  42668. if (!charCodes) {
  42669. charCodes = [];
  42670. }
  42671. charCodes.push(charCode | 0);
  42672. }
  42673. }
  42674. return charCodes;
  42675. }
  42676. function createCharCode(charCodeToGlyphId, glyphId) {
  42677. for (var charCode in charCodeToGlyphId) {
  42678. if (glyphId === charCodeToGlyphId[charCode]) {
  42679. return charCode | 0;
  42680. }
  42681. }
  42682. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  42683. return newMapping.nextAvailableFontCharCode++;
  42684. }
  42685. var seacs = font.seacs;
  42686. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  42687. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  42688. var charset = font.getCharset();
  42689. var seacMap = Object.create(null);
  42690. for (var glyphId in seacs) {
  42691. glyphId |= 0;
  42692. var seac = seacs[glyphId];
  42693. var baseGlyphName = StandardEncoding[seac[2]];
  42694. var accentGlyphName = StandardEncoding[seac[3]];
  42695. var baseGlyphId = charset.indexOf(baseGlyphName);
  42696. var accentGlyphId = charset.indexOf(accentGlyphName);
  42697. if (baseGlyphId < 0 || accentGlyphId < 0) {
  42698. continue;
  42699. }
  42700. var accentOffset = {
  42701. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  42702. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  42703. };
  42704. var charCodes = getCharCodes(mapping, glyphId);
  42705. if (!charCodes) {
  42706. continue;
  42707. }
  42708. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  42709. var charCode = charCodes[i];
  42710. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  42711. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  42712. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  42713. seacMap[charCode] = {
  42714. baseFontCharCode: baseFontCharCode,
  42715. accentFontCharCode: accentFontCharCode,
  42716. accentOffset: accentOffset
  42717. };
  42718. }
  42719. }
  42720. properties.seacMap = seacMap;
  42721. }
  42722. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  42723. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  42724. builder.addTable('CFF ', font.data);
  42725. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  42726. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  42727. 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');
  42728. 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));
  42729. builder.addTable('hmtx', function fontFieldsHmtx() {
  42730. var charstrings = font.charstrings;
  42731. var cffWidths = font.cff ? font.cff.widths : null;
  42732. var hmtx = '\x00\x00\x00\x00';
  42733. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  42734. var width = 0;
  42735. if (charstrings) {
  42736. var charstring = charstrings[i - 1];
  42737. width = 'width' in charstring ? charstring.width : 0;
  42738. } else if (cffWidths) {
  42739. width = Math.ceil(cffWidths[i] || 0);
  42740. }
  42741. hmtx += string16(width) + string16(0);
  42742. }
  42743. return hmtx;
  42744. }());
  42745. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  42746. builder.addTable('name', createNameTable(fontName));
  42747. builder.addTable('post', createPostTable(properties));
  42748. return builder.toArray();
  42749. },
  42750. get spaceWidth() {
  42751. if ('_shadowWidth' in this) {
  42752. return this._shadowWidth;
  42753. }
  42754. var possibleSpaceReplacements = [
  42755. 'space',
  42756. 'minus',
  42757. 'one',
  42758. 'i',
  42759. 'I'
  42760. ];
  42761. var width;
  42762. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  42763. var glyphName = possibleSpaceReplacements[i];
  42764. if (glyphName in this.widths) {
  42765. width = this.widths[glyphName];
  42766. break;
  42767. }
  42768. var glyphsUnicodeMap = getGlyphsUnicode();
  42769. var glyphUnicode = glyphsUnicodeMap[glyphName];
  42770. var charcode = 0;
  42771. if (this.composite) {
  42772. if (this.cMap.contains(glyphUnicode)) {
  42773. charcode = this.cMap.lookup(glyphUnicode);
  42774. }
  42775. }
  42776. if (!charcode && this.toUnicode) {
  42777. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  42778. }
  42779. if (charcode <= 0) {
  42780. charcode = glyphUnicode;
  42781. }
  42782. width = this.widths[charcode];
  42783. if (width) {
  42784. break;
  42785. }
  42786. }
  42787. width = width || this.defaultWidth;
  42788. this._shadowWidth = width;
  42789. return width;
  42790. },
  42791. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  42792. var fontCharCode, width, operatorListId;
  42793. var widthCode = charcode;
  42794. if (this.cMap && this.cMap.contains(charcode)) {
  42795. widthCode = this.cMap.lookup(charcode);
  42796. }
  42797. width = this.widths[widthCode];
  42798. width = isNum(width) ? width : this.defaultWidth;
  42799. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  42800. var unicode = this.toUnicode.get(charcode) || charcode;
  42801. if (typeof unicode === 'number') {
  42802. unicode = String.fromCharCode(unicode);
  42803. }
  42804. var isInFont = charcode in this.toFontChar;
  42805. fontCharCode = this.toFontChar[charcode] || charcode;
  42806. if (this.missingFile) {
  42807. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  42808. }
  42809. if (this.isType3Font) {
  42810. operatorListId = fontCharCode;
  42811. }
  42812. var accent = null;
  42813. if (this.seacMap && this.seacMap[charcode]) {
  42814. isInFont = true;
  42815. var seac = this.seacMap[charcode];
  42816. fontCharCode = seac.baseFontCharCode;
  42817. accent = {
  42818. fontChar: String.fromCharCode(seac.accentFontCharCode),
  42819. offset: seac.accentOffset
  42820. };
  42821. }
  42822. var fontChar = String.fromCharCode(fontCharCode);
  42823. var glyph = this.glyphCache[charcode];
  42824. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  42825. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  42826. this.glyphCache[charcode] = glyph;
  42827. }
  42828. return glyph;
  42829. },
  42830. charsToGlyphs: function Font_charsToGlyphs(chars) {
  42831. var charsCache = this.charsCache;
  42832. var glyphs, glyph, charcode;
  42833. if (charsCache) {
  42834. glyphs = charsCache[chars];
  42835. if (glyphs) {
  42836. return glyphs;
  42837. }
  42838. }
  42839. if (!charsCache) {
  42840. charsCache = this.charsCache = Object.create(null);
  42841. }
  42842. glyphs = [];
  42843. var charsCacheKey = chars;
  42844. var i = 0, ii;
  42845. if (this.cMap) {
  42846. var c = Object.create(null);
  42847. while (i < chars.length) {
  42848. this.cMap.readCharCode(chars, i, c);
  42849. charcode = c.charcode;
  42850. var length = c.length;
  42851. i += length;
  42852. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  42853. glyph = this.charToGlyph(charcode, isSpace);
  42854. glyphs.push(glyph);
  42855. }
  42856. } else {
  42857. for (i = 0, ii = chars.length; i < ii; ++i) {
  42858. charcode = chars.charCodeAt(i);
  42859. glyph = this.charToGlyph(charcode, charcode === 0x20);
  42860. glyphs.push(glyph);
  42861. }
  42862. }
  42863. return charsCache[charsCacheKey] = glyphs;
  42864. }
  42865. };
  42866. return Font;
  42867. }();
  42868. var ErrorFont = function ErrorFontClosure() {
  42869. function ErrorFont(error) {
  42870. this.error = error;
  42871. this.loadedName = 'g_font_error';
  42872. this.loading = false;
  42873. }
  42874. ErrorFont.prototype = {
  42875. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  42876. return [];
  42877. },
  42878. exportData: function ErrorFont_exportData() {
  42879. return { error: this.error };
  42880. }
  42881. };
  42882. return ErrorFont;
  42883. }();
  42884. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  42885. var charCodeToGlyphId = Object.create(null);
  42886. var glyphId, charCode, baseEncoding;
  42887. if (properties.baseEncodingName) {
  42888. baseEncoding = getEncoding(properties.baseEncodingName);
  42889. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  42890. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  42891. if (glyphId >= 0) {
  42892. charCodeToGlyphId[charCode] = glyphId;
  42893. } else {
  42894. charCodeToGlyphId[charCode] = 0;
  42895. }
  42896. }
  42897. } else if (!!(properties.flags & FontFlags.Symbolic)) {
  42898. for (charCode in builtInEncoding) {
  42899. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  42900. }
  42901. } else {
  42902. baseEncoding = StandardEncoding;
  42903. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  42904. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  42905. if (glyphId >= 0) {
  42906. charCodeToGlyphId[charCode] = glyphId;
  42907. } else {
  42908. charCodeToGlyphId[charCode] = 0;
  42909. }
  42910. }
  42911. }
  42912. var differences = properties.differences, glyphsUnicodeMap;
  42913. if (differences) {
  42914. for (charCode in differences) {
  42915. var glyphName = differences[charCode];
  42916. glyphId = glyphNames.indexOf(glyphName);
  42917. if (glyphId === -1) {
  42918. if (!glyphsUnicodeMap) {
  42919. glyphsUnicodeMap = getGlyphsUnicode();
  42920. }
  42921. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  42922. if (standardGlyphName !== glyphName) {
  42923. glyphId = glyphNames.indexOf(standardGlyphName);
  42924. }
  42925. }
  42926. if (glyphId >= 0) {
  42927. charCodeToGlyphId[charCode] = glyphId;
  42928. } else {
  42929. charCodeToGlyphId[charCode] = 0;
  42930. }
  42931. }
  42932. }
  42933. return charCodeToGlyphId;
  42934. }
  42935. var Type1Font = function Type1FontClosure() {
  42936. function findBlock(streamBytes, signature, startIndex) {
  42937. var streamBytesLength = streamBytes.length;
  42938. var signatureLength = signature.length;
  42939. var scanLength = streamBytesLength - signatureLength;
  42940. var i = startIndex, j, found = false;
  42941. while (i < scanLength) {
  42942. j = 0;
  42943. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  42944. j++;
  42945. }
  42946. if (j >= signatureLength) {
  42947. i += j;
  42948. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  42949. i++;
  42950. }
  42951. found = true;
  42952. break;
  42953. }
  42954. i++;
  42955. }
  42956. return {
  42957. found: found,
  42958. length: i
  42959. };
  42960. }
  42961. function getHeaderBlock(stream, suggestedLength) {
  42962. var EEXEC_SIGNATURE = [
  42963. 0x65,
  42964. 0x65,
  42965. 0x78,
  42966. 0x65,
  42967. 0x63
  42968. ];
  42969. var streamStartPos = stream.pos;
  42970. var headerBytes, headerBytesLength, block;
  42971. try {
  42972. headerBytes = stream.getBytes(suggestedLength);
  42973. headerBytesLength = headerBytes.length;
  42974. } catch (ex) {
  42975. if (ex instanceof MissingDataException) {
  42976. throw ex;
  42977. }
  42978. }
  42979. if (headerBytesLength === suggestedLength) {
  42980. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  42981. if (block.found && block.length === suggestedLength) {
  42982. return {
  42983. stream: new Stream(headerBytes),
  42984. length: suggestedLength
  42985. };
  42986. }
  42987. }
  42988. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  42989. stream.pos = streamStartPos;
  42990. var SCAN_BLOCK_LENGTH = 2048;
  42991. var actualLength;
  42992. while (true) {
  42993. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  42994. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  42995. if (block.length === 0) {
  42996. break;
  42997. }
  42998. stream.pos += block.length;
  42999. if (block.found) {
  43000. actualLength = stream.pos - streamStartPos;
  43001. break;
  43002. }
  43003. }
  43004. stream.pos = streamStartPos;
  43005. if (actualLength) {
  43006. return {
  43007. stream: new Stream(stream.getBytes(actualLength)),
  43008. length: actualLength
  43009. };
  43010. }
  43011. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  43012. return {
  43013. stream: new Stream(stream.getBytes(suggestedLength)),
  43014. length: suggestedLength
  43015. };
  43016. }
  43017. function getEexecBlock(stream, suggestedLength) {
  43018. var eexecBytes = stream.getBytes();
  43019. return {
  43020. stream: new Stream(eexecBytes),
  43021. length: eexecBytes.length
  43022. };
  43023. }
  43024. function Type1Font(name, file, properties) {
  43025. var PFB_HEADER_SIZE = 6;
  43026. var headerBlockLength = properties.length1;
  43027. var eexecBlockLength = properties.length2;
  43028. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  43029. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  43030. if (pfbHeaderPresent) {
  43031. file.skip(PFB_HEADER_SIZE);
  43032. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  43033. }
  43034. var headerBlock = getHeaderBlock(file, headerBlockLength);
  43035. headerBlockLength = headerBlock.length;
  43036. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  43037. headerBlockParser.extractFontHeader(properties);
  43038. if (pfbHeaderPresent) {
  43039. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  43040. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  43041. }
  43042. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  43043. eexecBlockLength = eexecBlock.length;
  43044. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  43045. var data = eexecBlockParser.extractFontProgram();
  43046. for (var info in data.properties) {
  43047. properties[info] = data.properties[info];
  43048. }
  43049. var charstrings = data.charstrings;
  43050. var type2Charstrings = this.getType2Charstrings(charstrings);
  43051. var subrs = this.getType2Subrs(data.subrs);
  43052. this.charstrings = charstrings;
  43053. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  43054. this.seacs = this.getSeacs(data.charstrings);
  43055. }
  43056. Type1Font.prototype = {
  43057. get numGlyphs() {
  43058. return this.charstrings.length + 1;
  43059. },
  43060. getCharset: function Type1Font_getCharset() {
  43061. var charset = ['.notdef'];
  43062. var charstrings = this.charstrings;
  43063. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  43064. charset.push(charstrings[glyphId].glyphName);
  43065. }
  43066. return charset;
  43067. },
  43068. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  43069. var charstrings = this.charstrings;
  43070. var glyphNames = ['.notdef'], glyphId;
  43071. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  43072. glyphNames.push(charstrings[glyphId].glyphName);
  43073. }
  43074. var encoding = properties.builtInEncoding;
  43075. if (encoding) {
  43076. var builtInEncoding = Object.create(null);
  43077. for (var charCode in encoding) {
  43078. glyphId = glyphNames.indexOf(encoding[charCode]);
  43079. if (glyphId >= 0) {
  43080. builtInEncoding[charCode] = glyphId;
  43081. }
  43082. }
  43083. }
  43084. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  43085. },
  43086. getSeacs: function Type1Font_getSeacs(charstrings) {
  43087. var i, ii;
  43088. var seacMap = [];
  43089. for (i = 0, ii = charstrings.length; i < ii; i++) {
  43090. var charstring = charstrings[i];
  43091. if (charstring.seac) {
  43092. seacMap[i + 1] = charstring.seac;
  43093. }
  43094. }
  43095. return seacMap;
  43096. },
  43097. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  43098. var type2Charstrings = [];
  43099. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  43100. type2Charstrings.push(type1Charstrings[i].charstring);
  43101. }
  43102. return type2Charstrings;
  43103. },
  43104. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  43105. var bias = 0;
  43106. var count = type1Subrs.length;
  43107. if (count < 1133) {
  43108. bias = 107;
  43109. } else if (count < 33769) {
  43110. bias = 1131;
  43111. } else {
  43112. bias = 32768;
  43113. }
  43114. var type2Subrs = [];
  43115. var i;
  43116. for (i = 0; i < bias; i++) {
  43117. type2Subrs.push([0x0B]);
  43118. }
  43119. for (i = 0; i < count; i++) {
  43120. type2Subrs.push(type1Subrs[i]);
  43121. }
  43122. return type2Subrs;
  43123. },
  43124. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  43125. var cff = new CFF();
  43126. cff.header = new CFFHeader(1, 0, 4, 4);
  43127. cff.names = [name];
  43128. var topDict = new CFFTopDict();
  43129. topDict.setByName('version', 391);
  43130. topDict.setByName('Notice', 392);
  43131. topDict.setByName('FullName', 393);
  43132. topDict.setByName('FamilyName', 394);
  43133. topDict.setByName('Weight', 395);
  43134. topDict.setByName('Encoding', null);
  43135. topDict.setByName('FontMatrix', properties.fontMatrix);
  43136. topDict.setByName('FontBBox', properties.bbox);
  43137. topDict.setByName('charset', null);
  43138. topDict.setByName('CharStrings', null);
  43139. topDict.setByName('Private', null);
  43140. cff.topDict = topDict;
  43141. var strings = new CFFStrings();
  43142. strings.add('Version 0.11');
  43143. strings.add('See original notice');
  43144. strings.add(name);
  43145. strings.add(name);
  43146. strings.add('Medium');
  43147. cff.strings = strings;
  43148. cff.globalSubrIndex = new CFFIndex();
  43149. var count = glyphs.length;
  43150. var charsetArray = [0];
  43151. var i, ii;
  43152. for (i = 0; i < count; i++) {
  43153. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  43154. if (index === -1) {
  43155. index = 0;
  43156. }
  43157. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  43158. }
  43159. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  43160. var charStringsIndex = new CFFIndex();
  43161. charStringsIndex.add([
  43162. 0x8B,
  43163. 0x0E
  43164. ]);
  43165. for (i = 0; i < count; i++) {
  43166. var glyph = glyphs[i];
  43167. if (glyph.length === 0) {
  43168. charStringsIndex.add([
  43169. 0x8B,
  43170. 0x0E
  43171. ]);
  43172. continue;
  43173. }
  43174. charStringsIndex.add(glyph);
  43175. }
  43176. cff.charStrings = charStringsIndex;
  43177. var privateDict = new CFFPrivateDict();
  43178. privateDict.setByName('Subrs', null);
  43179. var fields = [
  43180. 'BlueValues',
  43181. 'OtherBlues',
  43182. 'FamilyBlues',
  43183. 'FamilyOtherBlues',
  43184. 'StemSnapH',
  43185. 'StemSnapV',
  43186. 'BlueShift',
  43187. 'BlueFuzz',
  43188. 'BlueScale',
  43189. 'LanguageGroup',
  43190. 'ExpansionFactor',
  43191. 'ForceBold',
  43192. 'StdHW',
  43193. 'StdVW'
  43194. ];
  43195. for (i = 0, ii = fields.length; i < ii; i++) {
  43196. var field = fields[i];
  43197. if (!(field in properties.privateData)) {
  43198. continue;
  43199. }
  43200. var value = properties.privateData[field];
  43201. if (isArray(value)) {
  43202. for (var j = value.length - 1; j > 0; j--) {
  43203. value[j] -= value[j - 1];
  43204. }
  43205. }
  43206. privateDict.setByName(field, value);
  43207. }
  43208. cff.topDict.privateDict = privateDict;
  43209. var subrIndex = new CFFIndex();
  43210. for (i = 0, ii = subrs.length; i < ii; i++) {
  43211. subrIndex.add(subrs[i]);
  43212. }
  43213. privateDict.subrsIndex = subrIndex;
  43214. var compiler = new CFFCompiler(cff);
  43215. return compiler.compile();
  43216. }
  43217. };
  43218. return Type1Font;
  43219. }();
  43220. var CFFFont = function CFFFontClosure() {
  43221. function CFFFont(file, properties) {
  43222. this.properties = properties;
  43223. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  43224. this.cff = parser.parse();
  43225. var compiler = new CFFCompiler(this.cff);
  43226. this.seacs = this.cff.seacs;
  43227. try {
  43228. this.data = compiler.compile();
  43229. } catch (e) {
  43230. warn('Failed to compile font ' + properties.loadedName);
  43231. this.data = file;
  43232. }
  43233. }
  43234. CFFFont.prototype = {
  43235. get numGlyphs() {
  43236. return this.cff.charStrings.count;
  43237. },
  43238. getCharset: function CFFFont_getCharset() {
  43239. return this.cff.charset.charset;
  43240. },
  43241. getGlyphMapping: function CFFFont_getGlyphMapping() {
  43242. var cff = this.cff;
  43243. var properties = this.properties;
  43244. var charsets = cff.charset.charset;
  43245. var charCodeToGlyphId;
  43246. var glyphId;
  43247. if (properties.composite) {
  43248. charCodeToGlyphId = Object.create(null);
  43249. if (cff.isCIDFont) {
  43250. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  43251. var cid = charsets[glyphId];
  43252. var charCode = properties.cMap.charCodeOf(cid);
  43253. charCodeToGlyphId[charCode] = glyphId;
  43254. }
  43255. } else {
  43256. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  43257. charCodeToGlyphId[glyphId] = glyphId;
  43258. }
  43259. }
  43260. return charCodeToGlyphId;
  43261. }
  43262. var encoding = cff.encoding ? cff.encoding.encoding : null;
  43263. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  43264. return charCodeToGlyphId;
  43265. }
  43266. };
  43267. return CFFFont;
  43268. }();
  43269. (function checkSeacSupport() {
  43270. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  43271. SEAC_ANALYSIS_ENABLED = true;
  43272. }
  43273. }());
  43274. (function checkChromeWindows() {
  43275. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  43276. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  43277. }
  43278. }());
  43279. exports.ErrorFont = ErrorFont;
  43280. exports.Font = Font;
  43281. exports.FontFlags = FontFlags;
  43282. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  43283. exports.ToUnicodeMap = ToUnicodeMap;
  43284. exports.getFontType = getFontType;
  43285. }));
  43286. (function (root, factory) {
  43287. factory(root.pdfjsCorePsParser = {}, root.pdfjsSharedUtil, root.pdfjsCoreParser);
  43288. }(this, function (exports, sharedUtil, coreParser) {
  43289. var error = sharedUtil.error;
  43290. var isSpace = sharedUtil.isSpace;
  43291. var EOF = coreParser.EOF;
  43292. var PostScriptParser = function PostScriptParserClosure() {
  43293. function PostScriptParser(lexer) {
  43294. this.lexer = lexer;
  43295. this.operators = [];
  43296. this.token = null;
  43297. this.prev = null;
  43298. }
  43299. PostScriptParser.prototype = {
  43300. nextToken: function PostScriptParser_nextToken() {
  43301. this.prev = this.token;
  43302. this.token = this.lexer.getToken();
  43303. },
  43304. accept: function PostScriptParser_accept(type) {
  43305. if (this.token.type === type) {
  43306. this.nextToken();
  43307. return true;
  43308. }
  43309. return false;
  43310. },
  43311. expect: function PostScriptParser_expect(type) {
  43312. if (this.accept(type)) {
  43313. return true;
  43314. }
  43315. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  43316. },
  43317. parse: function PostScriptParser_parse() {
  43318. this.nextToken();
  43319. this.expect(PostScriptTokenTypes.LBRACE);
  43320. this.parseBlock();
  43321. this.expect(PostScriptTokenTypes.RBRACE);
  43322. return this.operators;
  43323. },
  43324. parseBlock: function PostScriptParser_parseBlock() {
  43325. while (true) {
  43326. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  43327. this.operators.push(this.prev.value);
  43328. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  43329. this.operators.push(this.prev.value);
  43330. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  43331. this.parseCondition();
  43332. } else {
  43333. return;
  43334. }
  43335. }
  43336. },
  43337. parseCondition: function PostScriptParser_parseCondition() {
  43338. var conditionLocation = this.operators.length;
  43339. this.operators.push(null, null);
  43340. this.parseBlock();
  43341. this.expect(PostScriptTokenTypes.RBRACE);
  43342. if (this.accept(PostScriptTokenTypes.IF)) {
  43343. this.operators[conditionLocation] = this.operators.length;
  43344. this.operators[conditionLocation + 1] = 'jz';
  43345. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  43346. var jumpLocation = this.operators.length;
  43347. this.operators.push(null, null);
  43348. var endOfTrue = this.operators.length;
  43349. this.parseBlock();
  43350. this.expect(PostScriptTokenTypes.RBRACE);
  43351. this.expect(PostScriptTokenTypes.IFELSE);
  43352. this.operators[jumpLocation] = this.operators.length;
  43353. this.operators[jumpLocation + 1] = 'j';
  43354. this.operators[conditionLocation] = endOfTrue;
  43355. this.operators[conditionLocation + 1] = 'jz';
  43356. } else {
  43357. error('PS Function: error parsing conditional.');
  43358. }
  43359. }
  43360. };
  43361. return PostScriptParser;
  43362. }();
  43363. var PostScriptTokenTypes = {
  43364. LBRACE: 0,
  43365. RBRACE: 1,
  43366. NUMBER: 2,
  43367. OPERATOR: 3,
  43368. IF: 4,
  43369. IFELSE: 5
  43370. };
  43371. var PostScriptToken = function PostScriptTokenClosure() {
  43372. function PostScriptToken(type, value) {
  43373. this.type = type;
  43374. this.value = value;
  43375. }
  43376. var opCache = Object.create(null);
  43377. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  43378. var opValue = opCache[op];
  43379. if (opValue) {
  43380. return opValue;
  43381. }
  43382. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  43383. };
  43384. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  43385. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  43386. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  43387. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  43388. return PostScriptToken;
  43389. }();
  43390. var PostScriptLexer = function PostScriptLexerClosure() {
  43391. function PostScriptLexer(stream) {
  43392. this.stream = stream;
  43393. this.nextChar();
  43394. this.strBuf = [];
  43395. }
  43396. PostScriptLexer.prototype = {
  43397. nextChar: function PostScriptLexer_nextChar() {
  43398. return this.currentChar = this.stream.getByte();
  43399. },
  43400. getToken: function PostScriptLexer_getToken() {
  43401. var comment = false;
  43402. var ch = this.currentChar;
  43403. while (true) {
  43404. if (ch < 0) {
  43405. return EOF;
  43406. }
  43407. if (comment) {
  43408. if (ch === 0x0A || ch === 0x0D) {
  43409. comment = false;
  43410. }
  43411. } else if (ch === 0x25) {
  43412. comment = true;
  43413. } else if (!isSpace(ch)) {
  43414. break;
  43415. }
  43416. ch = this.nextChar();
  43417. }
  43418. switch (ch | 0) {
  43419. case 0x30:
  43420. case 0x31:
  43421. case 0x32:
  43422. case 0x33:
  43423. case 0x34:
  43424. case 0x35:
  43425. case 0x36:
  43426. case 0x37:
  43427. case 0x38:
  43428. case 0x39:
  43429. case 0x2B:
  43430. case 0x2D:
  43431. case 0x2E:
  43432. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  43433. case 0x7B:
  43434. this.nextChar();
  43435. return PostScriptToken.LBRACE;
  43436. case 0x7D:
  43437. this.nextChar();
  43438. return PostScriptToken.RBRACE;
  43439. }
  43440. var strBuf = this.strBuf;
  43441. strBuf.length = 0;
  43442. strBuf[0] = String.fromCharCode(ch);
  43443. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  43444. strBuf.push(String.fromCharCode(ch));
  43445. }
  43446. var str = strBuf.join('');
  43447. switch (str.toLowerCase()) {
  43448. case 'if':
  43449. return PostScriptToken.IF;
  43450. case 'ifelse':
  43451. return PostScriptToken.IFELSE;
  43452. default:
  43453. return PostScriptToken.getOperator(str);
  43454. }
  43455. },
  43456. getNumber: function PostScriptLexer_getNumber() {
  43457. var ch = this.currentChar;
  43458. var strBuf = this.strBuf;
  43459. strBuf.length = 0;
  43460. strBuf[0] = String.fromCharCode(ch);
  43461. while ((ch = this.nextChar()) >= 0) {
  43462. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  43463. strBuf.push(String.fromCharCode(ch));
  43464. } else {
  43465. break;
  43466. }
  43467. }
  43468. var value = parseFloat(strBuf.join(''));
  43469. if (isNaN(value)) {
  43470. error('Invalid floating point number: ' + value);
  43471. }
  43472. return value;
  43473. }
  43474. };
  43475. return PostScriptLexer;
  43476. }();
  43477. exports.PostScriptLexer = PostScriptLexer;
  43478. exports.PostScriptParser = PostScriptParser;
  43479. }));
  43480. (function (root, factory) {
  43481. factory(root.pdfjsDisplayCanvas = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils, root.pdfjsDisplayPatternHelper, root.pdfjsDisplayWebGL);
  43482. }(this, function (exports, sharedUtil, displayDOMUtils, displayPatternHelper, displayWebGL) {
  43483. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  43484. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  43485. var ImageKind = sharedUtil.ImageKind;
  43486. var OPS = sharedUtil.OPS;
  43487. var TextRenderingMode = sharedUtil.TextRenderingMode;
  43488. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  43489. var Util = sharedUtil.Util;
  43490. var assert = sharedUtil.assert;
  43491. var info = sharedUtil.info;
  43492. var isNum = sharedUtil.isNum;
  43493. var isArray = sharedUtil.isArray;
  43494. var isLittleEndian = sharedUtil.isLittleEndian;
  43495. var error = sharedUtil.error;
  43496. var shadow = sharedUtil.shadow;
  43497. var warn = sharedUtil.warn;
  43498. var TilingPattern = displayPatternHelper.TilingPattern;
  43499. var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
  43500. var WebGLUtils = displayWebGL.WebGLUtils;
  43501. var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
  43502. var MIN_FONT_SIZE = 16;
  43503. var MAX_FONT_SIZE = 100;
  43504. var MAX_GROUP_SIZE = 4096;
  43505. var MIN_WIDTH_FACTOR = 0.65;
  43506. var COMPILE_TYPE3_GLYPHS = true;
  43507. var MAX_SIZE_TO_COMPILE = 1000;
  43508. var FULL_CHUNK_HEIGHT = 16;
  43509. var HasCanvasTypedArraysCached = {
  43510. get value() {
  43511. return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
  43512. }
  43513. };
  43514. var IsLittleEndianCached = {
  43515. get value() {
  43516. return shadow(IsLittleEndianCached, 'value', isLittleEndian());
  43517. }
  43518. };
  43519. function createScratchCanvas(width, height) {
  43520. var canvas = document.createElement('canvas');
  43521. canvas.width = width;
  43522. canvas.height = height;
  43523. return canvas;
  43524. }
  43525. function addContextCurrentTransform(ctx) {
  43526. if (!ctx.mozCurrentTransform) {
  43527. ctx._originalSave = ctx.save;
  43528. ctx._originalRestore = ctx.restore;
  43529. ctx._originalRotate = ctx.rotate;
  43530. ctx._originalScale = ctx.scale;
  43531. ctx._originalTranslate = ctx.translate;
  43532. ctx._originalTransform = ctx.transform;
  43533. ctx._originalSetTransform = ctx.setTransform;
  43534. ctx._transformMatrix = ctx._transformMatrix || [
  43535. 1,
  43536. 0,
  43537. 0,
  43538. 1,
  43539. 0,
  43540. 0
  43541. ];
  43542. ctx._transformStack = [];
  43543. Object.defineProperty(ctx, 'mozCurrentTransform', {
  43544. get: function getCurrentTransform() {
  43545. return this._transformMatrix;
  43546. }
  43547. });
  43548. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  43549. get: function getCurrentTransformInverse() {
  43550. var m = this._transformMatrix;
  43551. var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
  43552. var ad_bc = a * d - b * c;
  43553. var bc_ad = b * c - a * d;
  43554. return [
  43555. d / ad_bc,
  43556. b / bc_ad,
  43557. c / bc_ad,
  43558. a / ad_bc,
  43559. (d * e - c * f) / bc_ad,
  43560. (b * e - a * f) / ad_bc
  43561. ];
  43562. }
  43563. });
  43564. ctx.save = function ctxSave() {
  43565. var old = this._transformMatrix;
  43566. this._transformStack.push(old);
  43567. this._transformMatrix = old.slice(0, 6);
  43568. this._originalSave();
  43569. };
  43570. ctx.restore = function ctxRestore() {
  43571. var prev = this._transformStack.pop();
  43572. if (prev) {
  43573. this._transformMatrix = prev;
  43574. this._originalRestore();
  43575. }
  43576. };
  43577. ctx.translate = function ctxTranslate(x, y) {
  43578. var m = this._transformMatrix;
  43579. m[4] = m[0] * x + m[2] * y + m[4];
  43580. m[5] = m[1] * x + m[3] * y + m[5];
  43581. this._originalTranslate(x, y);
  43582. };
  43583. ctx.scale = function ctxScale(x, y) {
  43584. var m = this._transformMatrix;
  43585. m[0] = m[0] * x;
  43586. m[1] = m[1] * x;
  43587. m[2] = m[2] * y;
  43588. m[3] = m[3] * y;
  43589. this._originalScale(x, y);
  43590. };
  43591. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  43592. var m = this._transformMatrix;
  43593. this._transformMatrix = [
  43594. m[0] * a + m[2] * b,
  43595. m[1] * a + m[3] * b,
  43596. m[0] * c + m[2] * d,
  43597. m[1] * c + m[3] * d,
  43598. m[0] * e + m[2] * f + m[4],
  43599. m[1] * e + m[3] * f + m[5]
  43600. ];
  43601. ctx._originalTransform(a, b, c, d, e, f);
  43602. };
  43603. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  43604. this._transformMatrix = [
  43605. a,
  43606. b,
  43607. c,
  43608. d,
  43609. e,
  43610. f
  43611. ];
  43612. ctx._originalSetTransform(a, b, c, d, e, f);
  43613. };
  43614. ctx.rotate = function ctxRotate(angle) {
  43615. var cosValue = Math.cos(angle);
  43616. var sinValue = Math.sin(angle);
  43617. var m = this._transformMatrix;
  43618. this._transformMatrix = [
  43619. m[0] * cosValue + m[2] * sinValue,
  43620. m[1] * cosValue + m[3] * sinValue,
  43621. m[0] * -sinValue + m[2] * cosValue,
  43622. m[1] * -sinValue + m[3] * cosValue,
  43623. m[4],
  43624. m[5]
  43625. ];
  43626. this._originalRotate(angle);
  43627. };
  43628. }
  43629. }
  43630. var CachedCanvases = function CachedCanvasesClosure() {
  43631. function CachedCanvases() {
  43632. this.cache = Object.create(null);
  43633. }
  43634. CachedCanvases.prototype = {
  43635. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  43636. var canvasEntry;
  43637. if (this.cache[id] !== undefined) {
  43638. canvasEntry = this.cache[id];
  43639. canvasEntry.canvas.width = width;
  43640. canvasEntry.canvas.height = height;
  43641. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  43642. } else {
  43643. var canvas = createScratchCanvas(width, height);
  43644. var ctx = canvas.getContext('2d');
  43645. if (trackTransform) {
  43646. addContextCurrentTransform(ctx);
  43647. }
  43648. this.cache[id] = canvasEntry = {
  43649. canvas: canvas,
  43650. context: ctx
  43651. };
  43652. }
  43653. return canvasEntry;
  43654. },
  43655. clear: function () {
  43656. for (var id in this.cache) {
  43657. var canvasEntry = this.cache[id];
  43658. canvasEntry.canvas.width = 0;
  43659. canvasEntry.canvas.height = 0;
  43660. delete this.cache[id];
  43661. }
  43662. }
  43663. };
  43664. return CachedCanvases;
  43665. }();
  43666. function compileType3Glyph(imgData) {
  43667. var POINT_TO_PROCESS_LIMIT = 1000;
  43668. var width = imgData.width, height = imgData.height;
  43669. var i, j, j0, width1 = width + 1;
  43670. var points = new Uint8Array(width1 * (height + 1));
  43671. var POINT_TYPES = new Uint8Array([
  43672. 0,
  43673. 2,
  43674. 4,
  43675. 0,
  43676. 1,
  43677. 0,
  43678. 5,
  43679. 4,
  43680. 8,
  43681. 10,
  43682. 0,
  43683. 8,
  43684. 0,
  43685. 2,
  43686. 1,
  43687. 0
  43688. ]);
  43689. var lineSize = width + 7 & ~7, data0 = imgData.data;
  43690. var data = new Uint8Array(lineSize * height), pos = 0, ii;
  43691. for (i = 0, ii = data0.length; i < ii; i++) {
  43692. var mask = 128, elem = data0[i];
  43693. while (mask > 0) {
  43694. data[pos++] = elem & mask ? 0 : 255;
  43695. mask >>= 1;
  43696. }
  43697. }
  43698. var count = 0;
  43699. pos = 0;
  43700. if (data[pos] !== 0) {
  43701. points[0] = 1;
  43702. ++count;
  43703. }
  43704. for (j = 1; j < width; j++) {
  43705. if (data[pos] !== data[pos + 1]) {
  43706. points[j] = data[pos] ? 2 : 1;
  43707. ++count;
  43708. }
  43709. pos++;
  43710. }
  43711. if (data[pos] !== 0) {
  43712. points[j] = 2;
  43713. ++count;
  43714. }
  43715. for (i = 1; i < height; i++) {
  43716. pos = i * lineSize;
  43717. j0 = i * width1;
  43718. if (data[pos - lineSize] !== data[pos]) {
  43719. points[j0] = data[pos] ? 1 : 8;
  43720. ++count;
  43721. }
  43722. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  43723. for (j = 1; j < width; j++) {
  43724. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  43725. if (POINT_TYPES[sum]) {
  43726. points[j0 + j] = POINT_TYPES[sum];
  43727. ++count;
  43728. }
  43729. pos++;
  43730. }
  43731. if (data[pos - lineSize] !== data[pos]) {
  43732. points[j0 + j] = data[pos] ? 2 : 4;
  43733. ++count;
  43734. }
  43735. if (count > POINT_TO_PROCESS_LIMIT) {
  43736. return null;
  43737. }
  43738. }
  43739. pos = lineSize * (height - 1);
  43740. j0 = i * width1;
  43741. if (data[pos] !== 0) {
  43742. points[j0] = 8;
  43743. ++count;
  43744. }
  43745. for (j = 1; j < width; j++) {
  43746. if (data[pos] !== data[pos + 1]) {
  43747. points[j0 + j] = data[pos] ? 4 : 8;
  43748. ++count;
  43749. }
  43750. pos++;
  43751. }
  43752. if (data[pos] !== 0) {
  43753. points[j0 + j] = 4;
  43754. ++count;
  43755. }
  43756. if (count > POINT_TO_PROCESS_LIMIT) {
  43757. return null;
  43758. }
  43759. var steps = new Int32Array([
  43760. 0,
  43761. width1,
  43762. -1,
  43763. 0,
  43764. -width1,
  43765. 0,
  43766. 0,
  43767. 0,
  43768. 1
  43769. ]);
  43770. var outlines = [];
  43771. for (i = 0; count && i <= height; i++) {
  43772. var p = i * width1;
  43773. var end = p + width;
  43774. while (p < end && !points[p]) {
  43775. p++;
  43776. }
  43777. if (p === end) {
  43778. continue;
  43779. }
  43780. var coords = [
  43781. p % width1,
  43782. i
  43783. ];
  43784. var type = points[p], p0 = p, pp;
  43785. do {
  43786. var step = steps[type];
  43787. do {
  43788. p += step;
  43789. } while (!points[p]);
  43790. pp = points[p];
  43791. if (pp !== 5 && pp !== 10) {
  43792. type = pp;
  43793. points[p] = 0;
  43794. } else {
  43795. type = pp & 0x33 * type >> 4;
  43796. points[p] &= type >> 2 | type << 2;
  43797. }
  43798. coords.push(p % width1);
  43799. coords.push(p / width1 | 0);
  43800. --count;
  43801. } while (p0 !== p);
  43802. outlines.push(coords);
  43803. --i;
  43804. }
  43805. var drawOutline = function (c) {
  43806. c.save();
  43807. c.scale(1 / width, -1 / height);
  43808. c.translate(0, -height);
  43809. c.beginPath();
  43810. for (var i = 0, ii = outlines.length; i < ii; i++) {
  43811. var o = outlines[i];
  43812. c.moveTo(o[0], o[1]);
  43813. for (var j = 2, jj = o.length; j < jj; j += 2) {
  43814. c.lineTo(o[j], o[j + 1]);
  43815. }
  43816. }
  43817. c.fill();
  43818. c.beginPath();
  43819. c.restore();
  43820. };
  43821. return drawOutline;
  43822. }
  43823. var CanvasExtraState = function CanvasExtraStateClosure() {
  43824. function CanvasExtraState(old) {
  43825. this.alphaIsShape = false;
  43826. this.fontSize = 0;
  43827. this.fontSizeScale = 1;
  43828. this.textMatrix = IDENTITY_MATRIX;
  43829. this.textMatrixScale = 1;
  43830. this.fontMatrix = FONT_IDENTITY_MATRIX;
  43831. this.leading = 0;
  43832. this.x = 0;
  43833. this.y = 0;
  43834. this.lineX = 0;
  43835. this.lineY = 0;
  43836. this.charSpacing = 0;
  43837. this.wordSpacing = 0;
  43838. this.textHScale = 1;
  43839. this.textRenderingMode = TextRenderingMode.FILL;
  43840. this.textRise = 0;
  43841. this.fillColor = '#000000';
  43842. this.strokeColor = '#000000';
  43843. this.patternFill = false;
  43844. this.fillAlpha = 1;
  43845. this.strokeAlpha = 1;
  43846. this.lineWidth = 1;
  43847. this.activeSMask = null;
  43848. this.resumeSMaskCtx = null;
  43849. this.old = old;
  43850. }
  43851. CanvasExtraState.prototype = {
  43852. clone: function CanvasExtraState_clone() {
  43853. return Object.create(this);
  43854. },
  43855. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  43856. this.x = x;
  43857. this.y = y;
  43858. }
  43859. };
  43860. return CanvasExtraState;
  43861. }();
  43862. var CanvasGraphics = function CanvasGraphicsClosure() {
  43863. var EXECUTION_TIME = 15;
  43864. var EXECUTION_STEPS = 10;
  43865. function CanvasGraphics(canvasCtx, commonObjs, objs, imageLayer) {
  43866. this.ctx = canvasCtx;
  43867. this.current = new CanvasExtraState();
  43868. this.stateStack = [];
  43869. this.pendingClip = null;
  43870. this.pendingEOFill = false;
  43871. this.res = null;
  43872. this.xobjs = null;
  43873. this.commonObjs = commonObjs;
  43874. this.objs = objs;
  43875. this.imageLayer = imageLayer;
  43876. this.groupStack = [];
  43877. this.processingType3 = null;
  43878. this.baseTransform = null;
  43879. this.baseTransformStack = [];
  43880. this.groupLevel = 0;
  43881. this.smaskStack = [];
  43882. this.smaskCounter = 0;
  43883. this.tempSMask = null;
  43884. this.cachedCanvases = new CachedCanvases();
  43885. if (canvasCtx) {
  43886. addContextCurrentTransform(canvasCtx);
  43887. }
  43888. this.cachedGetSinglePixelWidth = null;
  43889. }
  43890. function putBinaryImageData(ctx, imgData) {
  43891. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  43892. ctx.putImageData(imgData, 0, 0);
  43893. return;
  43894. }
  43895. var height = imgData.height, width = imgData.width;
  43896. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  43897. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  43898. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  43899. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  43900. var srcPos = 0, destPos;
  43901. var src = imgData.data;
  43902. var dest = chunkImgData.data;
  43903. var i, j, thisChunkHeight, elemsInThisChunk;
  43904. if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
  43905. var srcLength = src.byteLength;
  43906. var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
  43907. var dest32DataLength = dest32.length;
  43908. var fullSrcDiff = width + 7 >> 3;
  43909. var white = 0xFFFFFFFF;
  43910. var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
  43911. for (i = 0; i < totalChunks; i++) {
  43912. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  43913. destPos = 0;
  43914. for (j = 0; j < thisChunkHeight; j++) {
  43915. var srcDiff = srcLength - srcPos;
  43916. var k = 0;
  43917. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  43918. var kEndUnrolled = kEnd & ~7;
  43919. var mask = 0;
  43920. var srcByte = 0;
  43921. for (; k < kEndUnrolled; k += 8) {
  43922. srcByte = src[srcPos++];
  43923. dest32[destPos++] = srcByte & 128 ? white : black;
  43924. dest32[destPos++] = srcByte & 64 ? white : black;
  43925. dest32[destPos++] = srcByte & 32 ? white : black;
  43926. dest32[destPos++] = srcByte & 16 ? white : black;
  43927. dest32[destPos++] = srcByte & 8 ? white : black;
  43928. dest32[destPos++] = srcByte & 4 ? white : black;
  43929. dest32[destPos++] = srcByte & 2 ? white : black;
  43930. dest32[destPos++] = srcByte & 1 ? white : black;
  43931. }
  43932. for (; k < kEnd; k++) {
  43933. if (mask === 0) {
  43934. srcByte = src[srcPos++];
  43935. mask = 128;
  43936. }
  43937. dest32[destPos++] = srcByte & mask ? white : black;
  43938. mask >>= 1;
  43939. }
  43940. }
  43941. while (destPos < dest32DataLength) {
  43942. dest32[destPos++] = 0;
  43943. }
  43944. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  43945. }
  43946. } else if (imgData.kind === ImageKind.RGBA_32BPP) {
  43947. j = 0;
  43948. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  43949. for (i = 0; i < fullChunks; i++) {
  43950. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  43951. srcPos += elemsInThisChunk;
  43952. ctx.putImageData(chunkImgData, 0, j);
  43953. j += FULL_CHUNK_HEIGHT;
  43954. }
  43955. if (i < totalChunks) {
  43956. elemsInThisChunk = width * partialChunkHeight * 4;
  43957. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  43958. ctx.putImageData(chunkImgData, 0, j);
  43959. }
  43960. } else if (imgData.kind === ImageKind.RGB_24BPP) {
  43961. thisChunkHeight = FULL_CHUNK_HEIGHT;
  43962. elemsInThisChunk = width * thisChunkHeight;
  43963. for (i = 0; i < totalChunks; i++) {
  43964. if (i >= fullChunks) {
  43965. thisChunkHeight = partialChunkHeight;
  43966. elemsInThisChunk = width * thisChunkHeight;
  43967. }
  43968. destPos = 0;
  43969. for (j = elemsInThisChunk; j--;) {
  43970. dest[destPos++] = src[srcPos++];
  43971. dest[destPos++] = src[srcPos++];
  43972. dest[destPos++] = src[srcPos++];
  43973. dest[destPos++] = 255;
  43974. }
  43975. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  43976. }
  43977. } else {
  43978. error('bad image kind: ' + imgData.kind);
  43979. }
  43980. }
  43981. function putBinaryImageMask(ctx, imgData) {
  43982. var height = imgData.height, width = imgData.width;
  43983. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  43984. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  43985. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  43986. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  43987. var srcPos = 0;
  43988. var src = imgData.data;
  43989. var dest = chunkImgData.data;
  43990. for (var i = 0; i < totalChunks; i++) {
  43991. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  43992. var destPos = 3;
  43993. for (var j = 0; j < thisChunkHeight; j++) {
  43994. var mask = 0;
  43995. for (var k = 0; k < width; k++) {
  43996. if (!mask) {
  43997. var elem = src[srcPos++];
  43998. mask = 128;
  43999. }
  44000. dest[destPos] = elem & mask ? 0 : 255;
  44001. destPos += 4;
  44002. mask >>= 1;
  44003. }
  44004. }
  44005. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  44006. }
  44007. }
  44008. function copyCtxState(sourceCtx, destCtx) {
  44009. var properties = [
  44010. 'strokeStyle',
  44011. 'fillStyle',
  44012. 'fillRule',
  44013. 'globalAlpha',
  44014. 'lineWidth',
  44015. 'lineCap',
  44016. 'lineJoin',
  44017. 'miterLimit',
  44018. 'globalCompositeOperation',
  44019. 'font'
  44020. ];
  44021. for (var i = 0, ii = properties.length; i < ii; i++) {
  44022. var property = properties[i];
  44023. if (sourceCtx[property] !== undefined) {
  44024. destCtx[property] = sourceCtx[property];
  44025. }
  44026. }
  44027. if (sourceCtx.setLineDash !== undefined) {
  44028. destCtx.setLineDash(sourceCtx.getLineDash());
  44029. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  44030. }
  44031. }
  44032. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  44033. var length = bytes.length;
  44034. for (var i = 3; i < length; i += 4) {
  44035. var alpha = bytes[i];
  44036. if (alpha === 0) {
  44037. bytes[i - 3] = r0;
  44038. bytes[i - 2] = g0;
  44039. bytes[i - 1] = b0;
  44040. } else if (alpha < 255) {
  44041. var alpha_ = 255 - alpha;
  44042. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  44043. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  44044. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  44045. }
  44046. }
  44047. }
  44048. function composeSMaskAlpha(maskData, layerData, transferMap) {
  44049. var length = maskData.length;
  44050. var scale = 1 / 255;
  44051. for (var i = 3; i < length; i += 4) {
  44052. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  44053. layerData[i] = layerData[i] * alpha * scale | 0;
  44054. }
  44055. }
  44056. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  44057. var length = maskData.length;
  44058. for (var i = 3; i < length; i += 4) {
  44059. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  44060. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  44061. }
  44062. }
  44063. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  44064. var hasBackdrop = !!backdrop;
  44065. var r0 = hasBackdrop ? backdrop[0] : 0;
  44066. var g0 = hasBackdrop ? backdrop[1] : 0;
  44067. var b0 = hasBackdrop ? backdrop[2] : 0;
  44068. var composeFn;
  44069. if (subtype === 'Luminosity') {
  44070. composeFn = composeSMaskLuminosity;
  44071. } else {
  44072. composeFn = composeSMaskAlpha;
  44073. }
  44074. var PIXELS_TO_PROCESS = 1048576;
  44075. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  44076. for (var row = 0; row < height; row += chunkSize) {
  44077. var chunkHeight = Math.min(chunkSize, height - row);
  44078. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  44079. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  44080. if (hasBackdrop) {
  44081. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  44082. }
  44083. composeFn(maskData.data, layerData.data, transferMap);
  44084. maskCtx.putImageData(layerData, 0, row);
  44085. }
  44086. }
  44087. function composeSMask(ctx, smask, layerCtx) {
  44088. var mask = smask.canvas;
  44089. var maskCtx = smask.context;
  44090. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  44091. var backdrop = smask.backdrop || null;
  44092. if (!smask.transferMap && WebGLUtils.isEnabled) {
  44093. var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  44094. subtype: smask.subtype,
  44095. backdrop: backdrop
  44096. });
  44097. ctx.setTransform(1, 0, 0, 1, 0, 0);
  44098. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  44099. return;
  44100. }
  44101. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  44102. ctx.drawImage(mask, 0, 0);
  44103. }
  44104. var LINE_CAP_STYLES = [
  44105. 'butt',
  44106. 'round',
  44107. 'square'
  44108. ];
  44109. var LINE_JOIN_STYLES = [
  44110. 'miter',
  44111. 'round',
  44112. 'bevel'
  44113. ];
  44114. var NORMAL_CLIP = {};
  44115. var EO_CLIP = {};
  44116. CanvasGraphics.prototype = {
  44117. beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
  44118. var width = this.ctx.canvas.width;
  44119. var height = this.ctx.canvas.height;
  44120. this.ctx.save();
  44121. this.ctx.fillStyle = 'rgb(255, 255, 255)';
  44122. this.ctx.fillRect(0, 0, width, height);
  44123. this.ctx.restore();
  44124. if (transparency) {
  44125. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  44126. this.compositeCtx = this.ctx;
  44127. this.transparentCanvas = transparentCanvas.canvas;
  44128. this.ctx = transparentCanvas.context;
  44129. this.ctx.save();
  44130. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  44131. }
  44132. this.ctx.save();
  44133. if (transform) {
  44134. this.ctx.transform.apply(this.ctx, transform);
  44135. }
  44136. this.ctx.transform.apply(this.ctx, viewport.transform);
  44137. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  44138. if (this.imageLayer) {
  44139. this.imageLayer.beginLayout();
  44140. }
  44141. },
  44142. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  44143. var argsArray = operatorList.argsArray;
  44144. var fnArray = operatorList.fnArray;
  44145. var i = executionStartIdx || 0;
  44146. var argsArrayLen = argsArray.length;
  44147. if (argsArrayLen === i) {
  44148. return i;
  44149. }
  44150. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  44151. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  44152. var steps = 0;
  44153. var commonObjs = this.commonObjs;
  44154. var objs = this.objs;
  44155. var fnId;
  44156. while (true) {
  44157. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  44158. stepper.breakIt(i, continueCallback);
  44159. return i;
  44160. }
  44161. fnId = fnArray[i];
  44162. if (fnId !== OPS.dependency) {
  44163. this[fnId].apply(this, argsArray[i]);
  44164. } else {
  44165. var deps = argsArray[i];
  44166. for (var n = 0, nn = deps.length; n < nn; n++) {
  44167. var depObjId = deps[n];
  44168. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  44169. var objsPool = common ? commonObjs : objs;
  44170. if (!objsPool.isResolved(depObjId)) {
  44171. objsPool.get(depObjId, continueCallback);
  44172. return i;
  44173. }
  44174. }
  44175. }
  44176. i++;
  44177. if (i === argsArrayLen) {
  44178. return i;
  44179. }
  44180. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  44181. if (Date.now() > endTime) {
  44182. continueCallback();
  44183. return i;
  44184. }
  44185. steps = 0;
  44186. }
  44187. }
  44188. },
  44189. endDrawing: function CanvasGraphics_endDrawing() {
  44190. if (this.current.activeSMask !== null) {
  44191. this.endSMaskGroup();
  44192. }
  44193. this.ctx.restore();
  44194. if (this.transparentCanvas) {
  44195. this.ctx = this.compositeCtx;
  44196. this.ctx.save();
  44197. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  44198. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  44199. this.ctx.restore();
  44200. this.transparentCanvas = null;
  44201. }
  44202. this.cachedCanvases.clear();
  44203. WebGLUtils.clear();
  44204. if (this.imageLayer) {
  44205. this.imageLayer.endLayout();
  44206. }
  44207. },
  44208. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  44209. this.current.lineWidth = width;
  44210. this.ctx.lineWidth = width;
  44211. },
  44212. setLineCap: function CanvasGraphics_setLineCap(style) {
  44213. this.ctx.lineCap = LINE_CAP_STYLES[style];
  44214. },
  44215. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  44216. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  44217. },
  44218. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  44219. this.ctx.miterLimit = limit;
  44220. },
  44221. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  44222. var ctx = this.ctx;
  44223. if (ctx.setLineDash !== undefined) {
  44224. ctx.setLineDash(dashArray);
  44225. ctx.lineDashOffset = dashPhase;
  44226. }
  44227. },
  44228. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
  44229. },
  44230. setFlatness: function CanvasGraphics_setFlatness(flatness) {
  44231. },
  44232. setGState: function CanvasGraphics_setGState(states) {
  44233. for (var i = 0, ii = states.length; i < ii; i++) {
  44234. var state = states[i];
  44235. var key = state[0];
  44236. var value = state[1];
  44237. switch (key) {
  44238. case 'LW':
  44239. this.setLineWidth(value);
  44240. break;
  44241. case 'LC':
  44242. this.setLineCap(value);
  44243. break;
  44244. case 'LJ':
  44245. this.setLineJoin(value);
  44246. break;
  44247. case 'ML':
  44248. this.setMiterLimit(value);
  44249. break;
  44250. case 'D':
  44251. this.setDash(value[0], value[1]);
  44252. break;
  44253. case 'RI':
  44254. this.setRenderingIntent(value);
  44255. break;
  44256. case 'FL':
  44257. this.setFlatness(value);
  44258. break;
  44259. case 'Font':
  44260. this.setFont(value[0], value[1]);
  44261. break;
  44262. case 'CA':
  44263. this.current.strokeAlpha = state[1];
  44264. break;
  44265. case 'ca':
  44266. this.current.fillAlpha = state[1];
  44267. this.ctx.globalAlpha = state[1];
  44268. break;
  44269. case 'BM':
  44270. if (value && value.name && value.name !== 'Normal') {
  44271. var mode = value.name.replace(/([A-Z])/g, function (c) {
  44272. return '-' + c.toLowerCase();
  44273. }).substring(1);
  44274. this.ctx.globalCompositeOperation = mode;
  44275. if (this.ctx.globalCompositeOperation !== mode) {
  44276. warn('globalCompositeOperation "' + mode + '" is not supported');
  44277. }
  44278. } else {
  44279. this.ctx.globalCompositeOperation = 'source-over';
  44280. }
  44281. break;
  44282. case 'SMask':
  44283. if (this.current.activeSMask) {
  44284. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  44285. this.suspendSMaskGroup();
  44286. } else {
  44287. this.endSMaskGroup();
  44288. }
  44289. }
  44290. this.current.activeSMask = value ? this.tempSMask : null;
  44291. if (this.current.activeSMask) {
  44292. this.beginSMaskGroup();
  44293. }
  44294. this.tempSMask = null;
  44295. break;
  44296. }
  44297. }
  44298. },
  44299. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  44300. var activeSMask = this.current.activeSMask;
  44301. var drawnWidth = activeSMask.canvas.width;
  44302. var drawnHeight = activeSMask.canvas.height;
  44303. var cacheId = 'smaskGroupAt' + this.groupLevel;
  44304. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  44305. var currentCtx = this.ctx;
  44306. var currentTransform = currentCtx.mozCurrentTransform;
  44307. this.ctx.save();
  44308. var groupCtx = scratchCanvas.context;
  44309. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  44310. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  44311. groupCtx.transform.apply(groupCtx, currentTransform);
  44312. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  44313. copyCtxState(currentCtx, groupCtx);
  44314. this.ctx = groupCtx;
  44315. this.setGState([
  44316. [
  44317. 'BM',
  44318. 'Normal'
  44319. ],
  44320. [
  44321. 'ca',
  44322. 1
  44323. ],
  44324. [
  44325. 'CA',
  44326. 1
  44327. ]
  44328. ]);
  44329. this.groupStack.push(currentCtx);
  44330. this.groupLevel++;
  44331. },
  44332. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  44333. var groupCtx = this.ctx;
  44334. this.groupLevel--;
  44335. this.ctx = this.groupStack.pop();
  44336. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  44337. this.ctx.restore();
  44338. this.ctx.save();
  44339. copyCtxState(groupCtx, this.ctx);
  44340. this.current.resumeSMaskCtx = groupCtx;
  44341. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  44342. this.ctx.transform.apply(this.ctx, deltaTransform);
  44343. groupCtx.save();
  44344. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  44345. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  44346. groupCtx.restore();
  44347. },
  44348. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  44349. var groupCtx = this.current.resumeSMaskCtx;
  44350. var currentCtx = this.ctx;
  44351. this.ctx = groupCtx;
  44352. this.groupStack.push(currentCtx);
  44353. this.groupLevel++;
  44354. },
  44355. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  44356. var groupCtx = this.ctx;
  44357. this.groupLevel--;
  44358. this.ctx = this.groupStack.pop();
  44359. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  44360. this.ctx.restore();
  44361. copyCtxState(groupCtx, this.ctx);
  44362. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  44363. this.ctx.transform.apply(this.ctx, deltaTransform);
  44364. },
  44365. save: function CanvasGraphics_save() {
  44366. this.ctx.save();
  44367. var old = this.current;
  44368. this.stateStack.push(old);
  44369. this.current = old.clone();
  44370. this.current.resumeSMaskCtx = null;
  44371. },
  44372. restore: function CanvasGraphics_restore() {
  44373. if (this.current.resumeSMaskCtx) {
  44374. this.resumeSMaskGroup();
  44375. }
  44376. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  44377. this.endSMaskGroup();
  44378. }
  44379. if (this.stateStack.length !== 0) {
  44380. this.current = this.stateStack.pop();
  44381. this.ctx.restore();
  44382. this.pendingClip = null;
  44383. this.cachedGetSinglePixelWidth = null;
  44384. }
  44385. },
  44386. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  44387. this.ctx.transform(a, b, c, d, e, f);
  44388. this.cachedGetSinglePixelWidth = null;
  44389. },
  44390. constructPath: function CanvasGraphics_constructPath(ops, args) {
  44391. var ctx = this.ctx;
  44392. var current = this.current;
  44393. var x = current.x, y = current.y;
  44394. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  44395. switch (ops[i] | 0) {
  44396. case OPS.rectangle:
  44397. x = args[j++];
  44398. y = args[j++];
  44399. var width = args[j++];
  44400. var height = args[j++];
  44401. if (width === 0) {
  44402. width = this.getSinglePixelWidth();
  44403. }
  44404. if (height === 0) {
  44405. height = this.getSinglePixelWidth();
  44406. }
  44407. var xw = x + width;
  44408. var yh = y + height;
  44409. this.ctx.moveTo(x, y);
  44410. this.ctx.lineTo(xw, y);
  44411. this.ctx.lineTo(xw, yh);
  44412. this.ctx.lineTo(x, yh);
  44413. this.ctx.lineTo(x, y);
  44414. this.ctx.closePath();
  44415. break;
  44416. case OPS.moveTo:
  44417. x = args[j++];
  44418. y = args[j++];
  44419. ctx.moveTo(x, y);
  44420. break;
  44421. case OPS.lineTo:
  44422. x = args[j++];
  44423. y = args[j++];
  44424. ctx.lineTo(x, y);
  44425. break;
  44426. case OPS.curveTo:
  44427. x = args[j + 4];
  44428. y = args[j + 5];
  44429. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  44430. j += 6;
  44431. break;
  44432. case OPS.curveTo2:
  44433. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  44434. x = args[j + 2];
  44435. y = args[j + 3];
  44436. j += 4;
  44437. break;
  44438. case OPS.curveTo3:
  44439. x = args[j + 2];
  44440. y = args[j + 3];
  44441. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  44442. j += 4;
  44443. break;
  44444. case OPS.closePath:
  44445. ctx.closePath();
  44446. break;
  44447. }
  44448. }
  44449. current.setCurrentPoint(x, y);
  44450. },
  44451. closePath: function CanvasGraphics_closePath() {
  44452. this.ctx.closePath();
  44453. },
  44454. stroke: function CanvasGraphics_stroke(consumePath) {
  44455. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  44456. var ctx = this.ctx;
  44457. var strokeColor = this.current.strokeColor;
  44458. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  44459. ctx.globalAlpha = this.current.strokeAlpha;
  44460. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  44461. ctx.save();
  44462. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  44463. ctx.stroke();
  44464. ctx.restore();
  44465. } else {
  44466. ctx.stroke();
  44467. }
  44468. if (consumePath) {
  44469. this.consumePath();
  44470. }
  44471. ctx.globalAlpha = this.current.fillAlpha;
  44472. },
  44473. closeStroke: function CanvasGraphics_closeStroke() {
  44474. this.closePath();
  44475. this.stroke();
  44476. },
  44477. fill: function CanvasGraphics_fill(consumePath) {
  44478. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  44479. var ctx = this.ctx;
  44480. var fillColor = this.current.fillColor;
  44481. var isPatternFill = this.current.patternFill;
  44482. var needRestore = false;
  44483. if (isPatternFill) {
  44484. ctx.save();
  44485. if (this.baseTransform) {
  44486. ctx.setTransform.apply(ctx, this.baseTransform);
  44487. }
  44488. ctx.fillStyle = fillColor.getPattern(ctx, this);
  44489. needRestore = true;
  44490. }
  44491. if (this.pendingEOFill) {
  44492. if (ctx.mozFillRule !== undefined) {
  44493. ctx.mozFillRule = 'evenodd';
  44494. ctx.fill();
  44495. ctx.mozFillRule = 'nonzero';
  44496. } else {
  44497. ctx.fill('evenodd');
  44498. }
  44499. this.pendingEOFill = false;
  44500. } else {
  44501. ctx.fill();
  44502. }
  44503. if (needRestore) {
  44504. ctx.restore();
  44505. }
  44506. if (consumePath) {
  44507. this.consumePath();
  44508. }
  44509. },
  44510. eoFill: function CanvasGraphics_eoFill() {
  44511. this.pendingEOFill = true;
  44512. this.fill();
  44513. },
  44514. fillStroke: function CanvasGraphics_fillStroke() {
  44515. this.fill(false);
  44516. this.stroke(false);
  44517. this.consumePath();
  44518. },
  44519. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  44520. this.pendingEOFill = true;
  44521. this.fillStroke();
  44522. },
  44523. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  44524. this.closePath();
  44525. this.fillStroke();
  44526. },
  44527. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  44528. this.pendingEOFill = true;
  44529. this.closePath();
  44530. this.fillStroke();
  44531. },
  44532. endPath: function CanvasGraphics_endPath() {
  44533. this.consumePath();
  44534. },
  44535. clip: function CanvasGraphics_clip() {
  44536. this.pendingClip = NORMAL_CLIP;
  44537. },
  44538. eoClip: function CanvasGraphics_eoClip() {
  44539. this.pendingClip = EO_CLIP;
  44540. },
  44541. beginText: function CanvasGraphics_beginText() {
  44542. this.current.textMatrix = IDENTITY_MATRIX;
  44543. this.current.textMatrixScale = 1;
  44544. this.current.x = this.current.lineX = 0;
  44545. this.current.y = this.current.lineY = 0;
  44546. },
  44547. endText: function CanvasGraphics_endText() {
  44548. var paths = this.pendingTextPaths;
  44549. var ctx = this.ctx;
  44550. if (paths === undefined) {
  44551. ctx.beginPath();
  44552. return;
  44553. }
  44554. ctx.save();
  44555. ctx.beginPath();
  44556. for (var i = 0; i < paths.length; i++) {
  44557. var path = paths[i];
  44558. ctx.setTransform.apply(ctx, path.transform);
  44559. ctx.translate(path.x, path.y);
  44560. path.addToPath(ctx, path.fontSize);
  44561. }
  44562. ctx.restore();
  44563. ctx.clip();
  44564. ctx.beginPath();
  44565. delete this.pendingTextPaths;
  44566. },
  44567. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  44568. this.current.charSpacing = spacing;
  44569. },
  44570. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  44571. this.current.wordSpacing = spacing;
  44572. },
  44573. setHScale: function CanvasGraphics_setHScale(scale) {
  44574. this.current.textHScale = scale / 100;
  44575. },
  44576. setLeading: function CanvasGraphics_setLeading(leading) {
  44577. this.current.leading = -leading;
  44578. },
  44579. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  44580. var fontObj = this.commonObjs.get(fontRefName);
  44581. var current = this.current;
  44582. if (!fontObj) {
  44583. error('Can\'t find font for ' + fontRefName);
  44584. }
  44585. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  44586. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  44587. warn('Invalid font matrix for font ' + fontRefName);
  44588. }
  44589. if (size < 0) {
  44590. size = -size;
  44591. current.fontDirection = -1;
  44592. } else {
  44593. current.fontDirection = 1;
  44594. }
  44595. this.current.font = fontObj;
  44596. this.current.fontSize = size;
  44597. if (fontObj.isType3Font) {
  44598. return;
  44599. }
  44600. var name = fontObj.loadedName || 'sans-serif';
  44601. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  44602. var italic = fontObj.italic ? 'italic' : 'normal';
  44603. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  44604. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  44605. this.current.fontSizeScale = size / browserFontSize;
  44606. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  44607. this.ctx.font = rule;
  44608. },
  44609. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  44610. this.current.textRenderingMode = mode;
  44611. },
  44612. setTextRise: function CanvasGraphics_setTextRise(rise) {
  44613. this.current.textRise = rise;
  44614. },
  44615. moveText: function CanvasGraphics_moveText(x, y) {
  44616. this.current.x = this.current.lineX += x;
  44617. this.current.y = this.current.lineY += y;
  44618. },
  44619. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  44620. this.setLeading(-y);
  44621. this.moveText(x, y);
  44622. },
  44623. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  44624. this.current.textMatrix = [
  44625. a,
  44626. b,
  44627. c,
  44628. d,
  44629. e,
  44630. f
  44631. ];
  44632. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  44633. this.current.x = this.current.lineX = 0;
  44634. this.current.y = this.current.lineY = 0;
  44635. },
  44636. nextLine: function CanvasGraphics_nextLine() {
  44637. this.moveText(0, this.current.leading);
  44638. },
  44639. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  44640. var ctx = this.ctx;
  44641. var current = this.current;
  44642. var font = current.font;
  44643. var textRenderingMode = current.textRenderingMode;
  44644. var fontSize = current.fontSize / current.fontSizeScale;
  44645. var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  44646. var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  44647. var addToPath;
  44648. if (font.disableFontFace || isAddToPathSet) {
  44649. addToPath = font.getPathGenerator(this.commonObjs, character);
  44650. }
  44651. if (font.disableFontFace) {
  44652. ctx.save();
  44653. ctx.translate(x, y);
  44654. ctx.beginPath();
  44655. addToPath(ctx, fontSize);
  44656. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44657. ctx.fill();
  44658. }
  44659. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44660. ctx.stroke();
  44661. }
  44662. ctx.restore();
  44663. } else {
  44664. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44665. ctx.fillText(character, x, y);
  44666. }
  44667. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44668. ctx.strokeText(character, x, y);
  44669. }
  44670. }
  44671. if (isAddToPathSet) {
  44672. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  44673. paths.push({
  44674. transform: ctx.mozCurrentTransform,
  44675. x: x,
  44676. y: y,
  44677. fontSize: fontSize,
  44678. addToPath: addToPath
  44679. });
  44680. }
  44681. },
  44682. get isFontSubpixelAAEnabled() {
  44683. var ctx = document.createElement('canvas').getContext('2d');
  44684. ctx.scale(1.5, 1);
  44685. ctx.fillText('I', 0, 10);
  44686. var data = ctx.getImageData(0, 0, 10, 10).data;
  44687. var enabled = false;
  44688. for (var i = 3; i < data.length; i += 4) {
  44689. if (data[i] > 0 && data[i] < 255) {
  44690. enabled = true;
  44691. break;
  44692. }
  44693. }
  44694. return shadow(this, 'isFontSubpixelAAEnabled', enabled);
  44695. },
  44696. showText: function CanvasGraphics_showText(glyphs) {
  44697. var current = this.current;
  44698. var font = current.font;
  44699. if (font.isType3Font) {
  44700. return this.showType3Text(glyphs);
  44701. }
  44702. var fontSize = current.fontSize;
  44703. if (fontSize === 0) {
  44704. return;
  44705. }
  44706. var ctx = this.ctx;
  44707. var fontSizeScale = current.fontSizeScale;
  44708. var charSpacing = current.charSpacing;
  44709. var wordSpacing = current.wordSpacing;
  44710. var fontDirection = current.fontDirection;
  44711. var textHScale = current.textHScale * fontDirection;
  44712. var glyphsLength = glyphs.length;
  44713. var vertical = font.vertical;
  44714. var spacingDir = vertical ? 1 : -1;
  44715. var defaultVMetrics = font.defaultVMetrics;
  44716. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  44717. var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
  44718. ctx.save();
  44719. ctx.transform.apply(ctx, current.textMatrix);
  44720. ctx.translate(current.x, current.y + current.textRise);
  44721. if (current.patternFill) {
  44722. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  44723. }
  44724. if (fontDirection > 0) {
  44725. ctx.scale(textHScale, -1);
  44726. } else {
  44727. ctx.scale(textHScale, 1);
  44728. }
  44729. var lineWidth = current.lineWidth;
  44730. var scale = current.textMatrixScale;
  44731. if (scale === 0 || lineWidth === 0) {
  44732. var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  44733. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44734. this.cachedGetSinglePixelWidth = null;
  44735. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  44736. }
  44737. } else {
  44738. lineWidth /= scale;
  44739. }
  44740. if (fontSizeScale !== 1.0) {
  44741. ctx.scale(fontSizeScale, fontSizeScale);
  44742. lineWidth /= fontSizeScale;
  44743. }
  44744. ctx.lineWidth = lineWidth;
  44745. var x = 0, i;
  44746. for (i = 0; i < glyphsLength; ++i) {
  44747. var glyph = glyphs[i];
  44748. if (isNum(glyph)) {
  44749. x += spacingDir * glyph * fontSize / 1000;
  44750. continue;
  44751. }
  44752. var restoreNeeded = false;
  44753. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  44754. var character = glyph.fontChar;
  44755. var accent = glyph.accent;
  44756. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  44757. var width = glyph.width;
  44758. if (vertical) {
  44759. var vmetric, vx, vy;
  44760. vmetric = glyph.vmetric || defaultVMetrics;
  44761. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  44762. vx = -vx * widthAdvanceScale;
  44763. vy = vmetric[2] * widthAdvanceScale;
  44764. width = vmetric ? -vmetric[0] : width;
  44765. scaledX = vx / fontSizeScale;
  44766. scaledY = (x + vy) / fontSizeScale;
  44767. } else {
  44768. scaledX = x / fontSizeScale;
  44769. scaledY = 0;
  44770. }
  44771. if (font.remeasure && width > 0) {
  44772. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  44773. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  44774. var characterScaleX = width / measuredWidth;
  44775. restoreNeeded = true;
  44776. ctx.save();
  44777. ctx.scale(characterScaleX, 1);
  44778. scaledX /= characterScaleX;
  44779. } else if (width !== measuredWidth) {
  44780. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  44781. }
  44782. }
  44783. if (glyph.isInFont || font.missingFile) {
  44784. if (simpleFillText && !accent) {
  44785. ctx.fillText(character, scaledX, scaledY);
  44786. } else {
  44787. this.paintChar(character, scaledX, scaledY);
  44788. if (accent) {
  44789. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  44790. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  44791. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  44792. }
  44793. }
  44794. }
  44795. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  44796. x += charWidth;
  44797. if (restoreNeeded) {
  44798. ctx.restore();
  44799. }
  44800. }
  44801. if (vertical) {
  44802. current.y -= x * textHScale;
  44803. } else {
  44804. current.x += x * textHScale;
  44805. }
  44806. ctx.restore();
  44807. },
  44808. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  44809. var ctx = this.ctx;
  44810. var current = this.current;
  44811. var font = current.font;
  44812. var fontSize = current.fontSize;
  44813. var fontDirection = current.fontDirection;
  44814. var spacingDir = font.vertical ? 1 : -1;
  44815. var charSpacing = current.charSpacing;
  44816. var wordSpacing = current.wordSpacing;
  44817. var textHScale = current.textHScale * fontDirection;
  44818. var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
  44819. var glyphsLength = glyphs.length;
  44820. var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
  44821. var i, glyph, width, spacingLength;
  44822. if (isTextInvisible || fontSize === 0) {
  44823. return;
  44824. }
  44825. this.cachedGetSinglePixelWidth = null;
  44826. ctx.save();
  44827. ctx.transform.apply(ctx, current.textMatrix);
  44828. ctx.translate(current.x, current.y);
  44829. ctx.scale(textHScale, fontDirection);
  44830. for (i = 0; i < glyphsLength; ++i) {
  44831. glyph = glyphs[i];
  44832. if (isNum(glyph)) {
  44833. spacingLength = spacingDir * glyph * fontSize / 1000;
  44834. this.ctx.translate(spacingLength, 0);
  44835. current.x += spacingLength * textHScale;
  44836. continue;
  44837. }
  44838. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  44839. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  44840. if (!operatorList) {
  44841. warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
  44842. continue;
  44843. }
  44844. this.processingType3 = glyph;
  44845. this.save();
  44846. ctx.scale(fontSize, fontSize);
  44847. ctx.transform.apply(ctx, fontMatrix);
  44848. this.executeOperatorList(operatorList);
  44849. this.restore();
  44850. var transformed = Util.applyTransform([
  44851. glyph.width,
  44852. 0
  44853. ], fontMatrix);
  44854. width = transformed[0] * fontSize + spacing;
  44855. ctx.translate(width, 0);
  44856. current.x += width * textHScale;
  44857. }
  44858. ctx.restore();
  44859. this.processingType3 = null;
  44860. },
  44861. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
  44862. },
  44863. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  44864. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  44865. this.clip();
  44866. this.endPath();
  44867. },
  44868. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  44869. var pattern;
  44870. if (IR[0] === 'TilingPattern') {
  44871. var color = IR[1];
  44872. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  44873. var self = this;
  44874. var canvasGraphicsFactory = {
  44875. createCanvasGraphics: function (ctx) {
  44876. return new CanvasGraphics(ctx, self.commonObjs, self.objs);
  44877. }
  44878. };
  44879. pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  44880. } else {
  44881. pattern = getShadingPatternFromIR(IR);
  44882. }
  44883. return pattern;
  44884. },
  44885. setStrokeColorN: function CanvasGraphics_setStrokeColorN()
  44886. {
  44887. this.current.strokeColor = this.getColorN_Pattern(arguments);
  44888. },
  44889. setFillColorN: function CanvasGraphics_setFillColorN()
  44890. {
  44891. this.current.fillColor = this.getColorN_Pattern(arguments);
  44892. this.current.patternFill = true;
  44893. },
  44894. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  44895. var color = Util.makeCssRgb(r, g, b);
  44896. this.ctx.strokeStyle = color;
  44897. this.current.strokeColor = color;
  44898. },
  44899. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  44900. var color = Util.makeCssRgb(r, g, b);
  44901. this.ctx.fillStyle = color;
  44902. this.current.fillColor = color;
  44903. this.current.patternFill = false;
  44904. },
  44905. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  44906. var ctx = this.ctx;
  44907. this.save();
  44908. var pattern = getShadingPatternFromIR(patternIR);
  44909. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  44910. var inv = ctx.mozCurrentTransformInverse;
  44911. if (inv) {
  44912. var canvas = ctx.canvas;
  44913. var width = canvas.width;
  44914. var height = canvas.height;
  44915. var bl = Util.applyTransform([
  44916. 0,
  44917. 0
  44918. ], inv);
  44919. var br = Util.applyTransform([
  44920. 0,
  44921. height
  44922. ], inv);
  44923. var ul = Util.applyTransform([
  44924. width,
  44925. 0
  44926. ], inv);
  44927. var ur = Util.applyTransform([
  44928. width,
  44929. height
  44930. ], inv);
  44931. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  44932. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  44933. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  44934. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  44935. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  44936. } else {
  44937. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  44938. }
  44939. this.restore();
  44940. },
  44941. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  44942. error('Should not call beginInlineImage');
  44943. },
  44944. beginImageData: function CanvasGraphics_beginImageData() {
  44945. error('Should not call beginImageData');
  44946. },
  44947. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  44948. this.save();
  44949. this.baseTransformStack.push(this.baseTransform);
  44950. if (isArray(matrix) && 6 === matrix.length) {
  44951. this.transform.apply(this, matrix);
  44952. }
  44953. this.baseTransform = this.ctx.mozCurrentTransform;
  44954. if (isArray(bbox) && 4 === bbox.length) {
  44955. var width = bbox[2] - bbox[0];
  44956. var height = bbox[3] - bbox[1];
  44957. this.ctx.rect(bbox[0], bbox[1], width, height);
  44958. this.clip();
  44959. this.endPath();
  44960. }
  44961. },
  44962. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  44963. this.restore();
  44964. this.baseTransform = this.baseTransformStack.pop();
  44965. },
  44966. beginGroup: function CanvasGraphics_beginGroup(group) {
  44967. this.save();
  44968. var currentCtx = this.ctx;
  44969. if (!group.isolated) {
  44970. info('TODO: Support non-isolated groups.');
  44971. }
  44972. if (group.knockout) {
  44973. warn('Knockout groups not supported.');
  44974. }
  44975. var currentTransform = currentCtx.mozCurrentTransform;
  44976. if (group.matrix) {
  44977. currentCtx.transform.apply(currentCtx, group.matrix);
  44978. }
  44979. assert(group.bbox, 'Bounding box is required.');
  44980. var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  44981. var canvasBounds = [
  44982. 0,
  44983. 0,
  44984. currentCtx.canvas.width,
  44985. currentCtx.canvas.height
  44986. ];
  44987. bounds = Util.intersect(bounds, canvasBounds) || [
  44988. 0,
  44989. 0,
  44990. 0,
  44991. 0
  44992. ];
  44993. var offsetX = Math.floor(bounds[0]);
  44994. var offsetY = Math.floor(bounds[1]);
  44995. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  44996. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  44997. var scaleX = 1, scaleY = 1;
  44998. if (drawnWidth > MAX_GROUP_SIZE) {
  44999. scaleX = drawnWidth / MAX_GROUP_SIZE;
  45000. drawnWidth = MAX_GROUP_SIZE;
  45001. }
  45002. if (drawnHeight > MAX_GROUP_SIZE) {
  45003. scaleY = drawnHeight / MAX_GROUP_SIZE;
  45004. drawnHeight = MAX_GROUP_SIZE;
  45005. }
  45006. var cacheId = 'groupAt' + this.groupLevel;
  45007. if (group.smask) {
  45008. cacheId += '_smask_' + this.smaskCounter++ % 2;
  45009. }
  45010. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  45011. var groupCtx = scratchCanvas.context;
  45012. groupCtx.scale(1 / scaleX, 1 / scaleY);
  45013. groupCtx.translate(-offsetX, -offsetY);
  45014. groupCtx.transform.apply(groupCtx, currentTransform);
  45015. if (group.smask) {
  45016. this.smaskStack.push({
  45017. canvas: scratchCanvas.canvas,
  45018. context: groupCtx,
  45019. offsetX: offsetX,
  45020. offsetY: offsetY,
  45021. scaleX: scaleX,
  45022. scaleY: scaleY,
  45023. subtype: group.smask.subtype,
  45024. backdrop: group.smask.backdrop,
  45025. transferMap: group.smask.transferMap || null,
  45026. startTransformInverse: null
  45027. });
  45028. } else
  45029. {
  45030. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  45031. currentCtx.translate(offsetX, offsetY);
  45032. currentCtx.scale(scaleX, scaleY);
  45033. }
  45034. copyCtxState(currentCtx, groupCtx);
  45035. this.ctx = groupCtx;
  45036. this.setGState([
  45037. [
  45038. 'BM',
  45039. 'Normal'
  45040. ],
  45041. [
  45042. 'ca',
  45043. 1
  45044. ],
  45045. [
  45046. 'CA',
  45047. 1
  45048. ]
  45049. ]);
  45050. this.groupStack.push(currentCtx);
  45051. this.groupLevel++;
  45052. this.current.activeSMask = null;
  45053. },
  45054. endGroup: function CanvasGraphics_endGroup(group) {
  45055. this.groupLevel--;
  45056. var groupCtx = this.ctx;
  45057. this.ctx = this.groupStack.pop();
  45058. if (this.ctx.imageSmoothingEnabled !== undefined) {
  45059. this.ctx.imageSmoothingEnabled = false;
  45060. } else {
  45061. this.ctx.mozImageSmoothingEnabled = false;
  45062. }
  45063. if (group.smask) {
  45064. this.tempSMask = this.smaskStack.pop();
  45065. } else {
  45066. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  45067. }
  45068. this.restore();
  45069. },
  45070. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  45071. this.save();
  45072. this.current = new CanvasExtraState();
  45073. if (this.baseTransform) {
  45074. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  45075. }
  45076. },
  45077. endAnnotations: function CanvasGraphics_endAnnotations() {
  45078. this.restore();
  45079. },
  45080. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  45081. this.save();
  45082. if (isArray(rect) && 4 === rect.length) {
  45083. var width = rect[2] - rect[0];
  45084. var height = rect[3] - rect[1];
  45085. this.ctx.rect(rect[0], rect[1], width, height);
  45086. this.clip();
  45087. this.endPath();
  45088. }
  45089. this.transform.apply(this, transform);
  45090. this.transform.apply(this, matrix);
  45091. },
  45092. endAnnotation: function CanvasGraphics_endAnnotation() {
  45093. this.restore();
  45094. },
  45095. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  45096. var domImage = this.objs.get(objId);
  45097. if (!domImage) {
  45098. warn('Dependent image isn\'t ready yet');
  45099. return;
  45100. }
  45101. this.save();
  45102. var ctx = this.ctx;
  45103. ctx.scale(1 / w, -1 / h);
  45104. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  45105. if (this.imageLayer) {
  45106. var currentTransform = ctx.mozCurrentTransformInverse;
  45107. var position = this.getCanvasPosition(0, 0);
  45108. this.imageLayer.appendImage({
  45109. objId: objId,
  45110. left: position[0],
  45111. top: position[1],
  45112. width: w / currentTransform[0],
  45113. height: h / currentTransform[3]
  45114. });
  45115. }
  45116. this.restore();
  45117. },
  45118. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  45119. var ctx = this.ctx;
  45120. var width = img.width, height = img.height;
  45121. var fillColor = this.current.fillColor;
  45122. var isPatternFill = this.current.patternFill;
  45123. var glyph = this.processingType3;
  45124. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  45125. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  45126. glyph.compiled = compileType3Glyph({
  45127. data: img.data,
  45128. width: width,
  45129. height: height
  45130. });
  45131. } else {
  45132. glyph.compiled = null;
  45133. }
  45134. }
  45135. if (glyph && glyph.compiled) {
  45136. glyph.compiled(ctx);
  45137. return;
  45138. }
  45139. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  45140. var maskCtx = maskCanvas.context;
  45141. maskCtx.save();
  45142. putBinaryImageMask(maskCtx, img);
  45143. maskCtx.globalCompositeOperation = 'source-in';
  45144. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  45145. maskCtx.fillRect(0, 0, width, height);
  45146. maskCtx.restore();
  45147. this.paintInlineImageXObject(maskCanvas.canvas);
  45148. },
  45149. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  45150. var width = imgData.width;
  45151. var height = imgData.height;
  45152. var fillColor = this.current.fillColor;
  45153. var isPatternFill = this.current.patternFill;
  45154. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  45155. var maskCtx = maskCanvas.context;
  45156. maskCtx.save();
  45157. putBinaryImageMask(maskCtx, imgData);
  45158. maskCtx.globalCompositeOperation = 'source-in';
  45159. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  45160. maskCtx.fillRect(0, 0, width, height);
  45161. maskCtx.restore();
  45162. var ctx = this.ctx;
  45163. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  45164. ctx.save();
  45165. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  45166. ctx.scale(1, -1);
  45167. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  45168. ctx.restore();
  45169. }
  45170. },
  45171. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  45172. var ctx = this.ctx;
  45173. var fillColor = this.current.fillColor;
  45174. var isPatternFill = this.current.patternFill;
  45175. for (var i = 0, ii = images.length; i < ii; i++) {
  45176. var image = images[i];
  45177. var width = image.width, height = image.height;
  45178. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  45179. var maskCtx = maskCanvas.context;
  45180. maskCtx.save();
  45181. putBinaryImageMask(maskCtx, image);
  45182. maskCtx.globalCompositeOperation = 'source-in';
  45183. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  45184. maskCtx.fillRect(0, 0, width, height);
  45185. maskCtx.restore();
  45186. ctx.save();
  45187. ctx.transform.apply(ctx, image.transform);
  45188. ctx.scale(1, -1);
  45189. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  45190. ctx.restore();
  45191. }
  45192. },
  45193. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  45194. var imgData = this.objs.get(objId);
  45195. if (!imgData) {
  45196. warn('Dependent image isn\'t ready yet');
  45197. return;
  45198. }
  45199. this.paintInlineImageXObject(imgData);
  45200. },
  45201. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  45202. var imgData = this.objs.get(objId);
  45203. if (!imgData) {
  45204. warn('Dependent image isn\'t ready yet');
  45205. return;
  45206. }
  45207. var width = imgData.width;
  45208. var height = imgData.height;
  45209. var map = [];
  45210. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  45211. map.push({
  45212. transform: [
  45213. scaleX,
  45214. 0,
  45215. 0,
  45216. scaleY,
  45217. positions[i],
  45218. positions[i + 1]
  45219. ],
  45220. x: 0,
  45221. y: 0,
  45222. w: width,
  45223. h: height
  45224. });
  45225. }
  45226. this.paintInlineImageXObjectGroup(imgData, map);
  45227. },
  45228. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  45229. var width = imgData.width;
  45230. var height = imgData.height;
  45231. var ctx = this.ctx;
  45232. this.save();
  45233. ctx.scale(1 / width, -1 / height);
  45234. var currentTransform = ctx.mozCurrentTransformInverse;
  45235. var a = currentTransform[0], b = currentTransform[1];
  45236. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  45237. var c = currentTransform[2], d = currentTransform[3];
  45238. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  45239. var imgToPaint, tmpCanvas;
  45240. if (imgData instanceof HTMLElement || !imgData.data) {
  45241. imgToPaint = imgData;
  45242. } else {
  45243. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  45244. var tmpCtx = tmpCanvas.context;
  45245. putBinaryImageData(tmpCtx, imgData);
  45246. imgToPaint = tmpCanvas.canvas;
  45247. }
  45248. var paintWidth = width, paintHeight = height;
  45249. var tmpCanvasId = 'prescale1';
  45250. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  45251. var newWidth = paintWidth, newHeight = paintHeight;
  45252. if (widthScale > 2 && paintWidth > 1) {
  45253. newWidth = Math.ceil(paintWidth / 2);
  45254. widthScale /= paintWidth / newWidth;
  45255. }
  45256. if (heightScale > 2 && paintHeight > 1) {
  45257. newHeight = Math.ceil(paintHeight / 2);
  45258. heightScale /= paintHeight / newHeight;
  45259. }
  45260. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  45261. tmpCtx = tmpCanvas.context;
  45262. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  45263. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  45264. imgToPaint = tmpCanvas.canvas;
  45265. paintWidth = newWidth;
  45266. paintHeight = newHeight;
  45267. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  45268. }
  45269. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  45270. if (this.imageLayer) {
  45271. var position = this.getCanvasPosition(0, -height);
  45272. this.imageLayer.appendImage({
  45273. imgData: imgData,
  45274. left: position[0],
  45275. top: position[1],
  45276. width: width / currentTransform[0],
  45277. height: height / currentTransform[3]
  45278. });
  45279. }
  45280. this.restore();
  45281. },
  45282. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  45283. var ctx = this.ctx;
  45284. var w = imgData.width;
  45285. var h = imgData.height;
  45286. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  45287. var tmpCtx = tmpCanvas.context;
  45288. putBinaryImageData(tmpCtx, imgData);
  45289. for (var i = 0, ii = map.length; i < ii; i++) {
  45290. var entry = map[i];
  45291. ctx.save();
  45292. ctx.transform.apply(ctx, entry.transform);
  45293. ctx.scale(1, -1);
  45294. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  45295. if (this.imageLayer) {
  45296. var position = this.getCanvasPosition(entry.x, entry.y);
  45297. this.imageLayer.appendImage({
  45298. imgData: imgData,
  45299. left: position[0],
  45300. top: position[1],
  45301. width: w,
  45302. height: h
  45303. });
  45304. }
  45305. ctx.restore();
  45306. }
  45307. },
  45308. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  45309. this.ctx.fillRect(0, 0, 1, 1);
  45310. },
  45311. paintXObject: function CanvasGraphics_paintXObject() {
  45312. warn('Unsupported \'paintXObject\' command.');
  45313. },
  45314. markPoint: function CanvasGraphics_markPoint(tag) {
  45315. },
  45316. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
  45317. },
  45318. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  45319. },
  45320. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  45321. },
  45322. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  45323. },
  45324. beginCompat: function CanvasGraphics_beginCompat() {
  45325. },
  45326. endCompat: function CanvasGraphics_endCompat() {
  45327. },
  45328. consumePath: function CanvasGraphics_consumePath() {
  45329. var ctx = this.ctx;
  45330. if (this.pendingClip) {
  45331. if (this.pendingClip === EO_CLIP) {
  45332. if (ctx.mozFillRule !== undefined) {
  45333. ctx.mozFillRule = 'evenodd';
  45334. ctx.clip();
  45335. ctx.mozFillRule = 'nonzero';
  45336. } else {
  45337. ctx.clip('evenodd');
  45338. }
  45339. } else {
  45340. ctx.clip();
  45341. }
  45342. this.pendingClip = null;
  45343. }
  45344. ctx.beginPath();
  45345. },
  45346. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  45347. if (this.cachedGetSinglePixelWidth === null) {
  45348. this.ctx.save();
  45349. var inverse = this.ctx.mozCurrentTransformInverse;
  45350. this.ctx.restore();
  45351. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  45352. }
  45353. return this.cachedGetSinglePixelWidth;
  45354. },
  45355. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  45356. var transform = this.ctx.mozCurrentTransform;
  45357. return [
  45358. transform[0] * x + transform[2] * y + transform[4],
  45359. transform[1] * x + transform[3] * y + transform[5]
  45360. ];
  45361. }
  45362. };
  45363. for (var op in OPS) {
  45364. CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
  45365. }
  45366. return CanvasGraphics;
  45367. }();
  45368. exports.CanvasGraphics = CanvasGraphics;
  45369. exports.createScratchCanvas = createScratchCanvas;
  45370. }));
  45371. (function (root, factory) {
  45372. factory(root.pdfjsCoreFunction = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePsParser);
  45373. }(this, function (exports, sharedUtil, corePrimitives, corePsParser) {
  45374. var error = sharedUtil.error;
  45375. var info = sharedUtil.info;
  45376. var isArray = sharedUtil.isArray;
  45377. var isBool = sharedUtil.isBool;
  45378. var isDict = corePrimitives.isDict;
  45379. var isStream = corePrimitives.isStream;
  45380. var PostScriptLexer = corePsParser.PostScriptLexer;
  45381. var PostScriptParser = corePsParser.PostScriptParser;
  45382. var PDFFunction = function PDFFunctionClosure() {
  45383. var CONSTRUCT_SAMPLED = 0;
  45384. var CONSTRUCT_INTERPOLATED = 2;
  45385. var CONSTRUCT_STICHED = 3;
  45386. var CONSTRUCT_POSTSCRIPT = 4;
  45387. return {
  45388. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  45389. var i, ii;
  45390. var length = 1;
  45391. for (i = 0, ii = size.length; i < ii; i++) {
  45392. length *= size[i];
  45393. }
  45394. length *= outputSize;
  45395. var array = new Array(length);
  45396. var codeSize = 0;
  45397. var codeBuf = 0;
  45398. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  45399. var strBytes = str.getBytes((length * bps + 7) / 8);
  45400. var strIdx = 0;
  45401. for (i = 0; i < length; i++) {
  45402. while (codeSize < bps) {
  45403. codeBuf <<= 8;
  45404. codeBuf |= strBytes[strIdx++];
  45405. codeSize += 8;
  45406. }
  45407. codeSize -= bps;
  45408. array[i] = (codeBuf >> codeSize) * sampleMul;
  45409. codeBuf &= (1 << codeSize) - 1;
  45410. }
  45411. return array;
  45412. },
  45413. getIR: function PDFFunction_getIR(xref, fn) {
  45414. var dict = fn.dict;
  45415. if (!dict) {
  45416. dict = fn;
  45417. }
  45418. var types = [
  45419. this.constructSampled,
  45420. null,
  45421. this.constructInterpolated,
  45422. this.constructStiched,
  45423. this.constructPostScript
  45424. ];
  45425. var typeNum = dict.get('FunctionType');
  45426. var typeFn = types[typeNum];
  45427. if (!typeFn) {
  45428. error('Unknown type of function');
  45429. }
  45430. return typeFn.call(this, fn, dict, xref);
  45431. },
  45432. fromIR: function PDFFunction_fromIR(IR) {
  45433. var type = IR[0];
  45434. switch (type) {
  45435. case CONSTRUCT_SAMPLED:
  45436. return this.constructSampledFromIR(IR);
  45437. case CONSTRUCT_INTERPOLATED:
  45438. return this.constructInterpolatedFromIR(IR);
  45439. case CONSTRUCT_STICHED:
  45440. return this.constructStichedFromIR(IR);
  45441. default:
  45442. return this.constructPostScriptFromIR(IR);
  45443. }
  45444. },
  45445. parse: function PDFFunction_parse(xref, fn) {
  45446. var IR = this.getIR(xref, fn);
  45447. return this.fromIR(IR);
  45448. },
  45449. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  45450. if (!isArray(fnObj)) {
  45451. return this.parse(xref, fnObj);
  45452. }
  45453. var fnArray = [];
  45454. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  45455. var obj = xref.fetchIfRef(fnObj[j]);
  45456. fnArray.push(PDFFunction.parse(xref, obj));
  45457. }
  45458. return function (src, srcOffset, dest, destOffset) {
  45459. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  45460. fnArray[i](src, srcOffset, dest, destOffset + i);
  45461. }
  45462. };
  45463. },
  45464. constructSampled: function PDFFunction_constructSampled(str, dict) {
  45465. function toMultiArray(arr) {
  45466. var inputLength = arr.length;
  45467. var out = [];
  45468. var index = 0;
  45469. for (var i = 0; i < inputLength; i += 2) {
  45470. out[index] = [
  45471. arr[i],
  45472. arr[i + 1]
  45473. ];
  45474. ++index;
  45475. }
  45476. return out;
  45477. }
  45478. var domain = dict.getArray('Domain');
  45479. var range = dict.getArray('Range');
  45480. if (!domain || !range) {
  45481. error('No domain or range');
  45482. }
  45483. var inputSize = domain.length / 2;
  45484. var outputSize = range.length / 2;
  45485. domain = toMultiArray(domain);
  45486. range = toMultiArray(range);
  45487. var size = dict.get('Size');
  45488. var bps = dict.get('BitsPerSample');
  45489. var order = dict.get('Order') || 1;
  45490. if (order !== 1) {
  45491. info('No support for cubic spline interpolation: ' + order);
  45492. }
  45493. var encode = dict.getArray('Encode');
  45494. if (!encode) {
  45495. encode = [];
  45496. for (var i = 0; i < inputSize; ++i) {
  45497. encode.push(0);
  45498. encode.push(size[i] - 1);
  45499. }
  45500. }
  45501. encode = toMultiArray(encode);
  45502. var decode = dict.getArray('Decode');
  45503. if (!decode) {
  45504. decode = range;
  45505. } else {
  45506. decode = toMultiArray(decode);
  45507. }
  45508. var samples = this.getSampleArray(size, outputSize, bps, str);
  45509. return [
  45510. CONSTRUCT_SAMPLED,
  45511. inputSize,
  45512. domain,
  45513. encode,
  45514. decode,
  45515. samples,
  45516. size,
  45517. outputSize,
  45518. Math.pow(2, bps) - 1,
  45519. range
  45520. ];
  45521. },
  45522. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  45523. function interpolate(x, xmin, xmax, ymin, ymax) {
  45524. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  45525. }
  45526. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  45527. var m = IR[1];
  45528. var domain = IR[2];
  45529. var encode = IR[3];
  45530. var decode = IR[4];
  45531. var samples = IR[5];
  45532. var size = IR[6];
  45533. var n = IR[7];
  45534. var range = IR[9];
  45535. var cubeVertices = 1 << m;
  45536. var cubeN = new Float64Array(cubeVertices);
  45537. var cubeVertex = new Uint32Array(cubeVertices);
  45538. var i, j;
  45539. for (j = 0; j < cubeVertices; j++) {
  45540. cubeN[j] = 1;
  45541. }
  45542. var k = n, pos = 1;
  45543. for (i = 0; i < m; ++i) {
  45544. var domain_2i = domain[i][0];
  45545. var domain_2i_1 = domain[i][1];
  45546. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  45547. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  45548. var size_i = size[i];
  45549. e = Math.min(Math.max(e, 0), size_i - 1);
  45550. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  45551. var n0 = e0 + 1 - e;
  45552. var n1 = e - e0;
  45553. var offset0 = e0 * k;
  45554. var offset1 = offset0 + k;
  45555. for (j = 0; j < cubeVertices; j++) {
  45556. if (j & pos) {
  45557. cubeN[j] *= n1;
  45558. cubeVertex[j] += offset1;
  45559. } else {
  45560. cubeN[j] *= n0;
  45561. cubeVertex[j] += offset0;
  45562. }
  45563. }
  45564. k *= size_i;
  45565. pos <<= 1;
  45566. }
  45567. for (j = 0; j < n; ++j) {
  45568. var rj = 0;
  45569. for (i = 0; i < cubeVertices; i++) {
  45570. rj += samples[cubeVertex[i] + j] * cubeN[i];
  45571. }
  45572. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  45573. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  45574. }
  45575. };
  45576. },
  45577. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  45578. var c0 = dict.getArray('C0') || [0];
  45579. var c1 = dict.getArray('C1') || [1];
  45580. var n = dict.get('N');
  45581. if (!isArray(c0) || !isArray(c1)) {
  45582. error('Illegal dictionary for interpolated function');
  45583. }
  45584. var length = c0.length;
  45585. var diff = [];
  45586. for (var i = 0; i < length; ++i) {
  45587. diff.push(c1[i] - c0[i]);
  45588. }
  45589. return [
  45590. CONSTRUCT_INTERPOLATED,
  45591. c0,
  45592. diff,
  45593. n
  45594. ];
  45595. },
  45596. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  45597. var c0 = IR[1];
  45598. var diff = IR[2];
  45599. var n = IR[3];
  45600. var length = diff.length;
  45601. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  45602. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  45603. for (var j = 0; j < length; ++j) {
  45604. dest[destOffset + j] = c0[j] + x * diff[j];
  45605. }
  45606. };
  45607. },
  45608. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  45609. var domain = dict.getArray('Domain');
  45610. if (!domain) {
  45611. error('No domain');
  45612. }
  45613. var inputSize = domain.length / 2;
  45614. if (inputSize !== 1) {
  45615. error('Bad domain for stiched function');
  45616. }
  45617. var fnRefs = dict.get('Functions');
  45618. var fns = [];
  45619. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  45620. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  45621. }
  45622. var bounds = dict.getArray('Bounds');
  45623. var encode = dict.getArray('Encode');
  45624. return [
  45625. CONSTRUCT_STICHED,
  45626. domain,
  45627. bounds,
  45628. encode,
  45629. fns
  45630. ];
  45631. },
  45632. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  45633. var domain = IR[1];
  45634. var bounds = IR[2];
  45635. var encode = IR[3];
  45636. var fnsIR = IR[4];
  45637. var fns = [];
  45638. var tmpBuf = new Float32Array(1);
  45639. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  45640. fns.push(PDFFunction.fromIR(fnsIR[i]));
  45641. }
  45642. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  45643. var clip = function constructStichedFromIRClip(v, min, max) {
  45644. if (v > max) {
  45645. v = max;
  45646. } else if (v < min) {
  45647. v = min;
  45648. }
  45649. return v;
  45650. };
  45651. var v = clip(src[srcOffset], domain[0], domain[1]);
  45652. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  45653. if (v < bounds[i]) {
  45654. break;
  45655. }
  45656. }
  45657. var dmin = domain[0];
  45658. if (i > 0) {
  45659. dmin = bounds[i - 1];
  45660. }
  45661. var dmax = domain[1];
  45662. if (i < bounds.length) {
  45663. dmax = bounds[i];
  45664. }
  45665. var rmin = encode[2 * i];
  45666. var rmax = encode[2 * i + 1];
  45667. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  45668. fns[i](tmpBuf, 0, dest, destOffset);
  45669. };
  45670. },
  45671. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  45672. var domain = dict.getArray('Domain');
  45673. var range = dict.getArray('Range');
  45674. if (!domain) {
  45675. error('No domain.');
  45676. }
  45677. if (!range) {
  45678. error('No range.');
  45679. }
  45680. var lexer = new PostScriptLexer(fn);
  45681. var parser = new PostScriptParser(lexer);
  45682. var code = parser.parse();
  45683. return [
  45684. CONSTRUCT_POSTSCRIPT,
  45685. domain,
  45686. range,
  45687. code
  45688. ];
  45689. },
  45690. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  45691. var domain = IR[1];
  45692. var range = IR[2];
  45693. var code = IR[3];
  45694. var compiled = new PostScriptCompiler().compile(code, domain, range);
  45695. if (compiled) {
  45696. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  45697. }
  45698. info('Unable to compile PS function');
  45699. var numOutputs = range.length >> 1;
  45700. var numInputs = domain.length >> 1;
  45701. var evaluator = new PostScriptEvaluator(code);
  45702. var cache = Object.create(null);
  45703. var MAX_CACHE_SIZE = 2048 * 4;
  45704. var cache_available = MAX_CACHE_SIZE;
  45705. var tmpBuf = new Float32Array(numInputs);
  45706. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  45707. var i, value;
  45708. var key = '';
  45709. var input = tmpBuf;
  45710. for (i = 0; i < numInputs; i++) {
  45711. value = src[srcOffset + i];
  45712. input[i] = value;
  45713. key += value + '_';
  45714. }
  45715. var cachedValue = cache[key];
  45716. if (cachedValue !== undefined) {
  45717. dest.set(cachedValue, destOffset);
  45718. return;
  45719. }
  45720. var output = new Float32Array(numOutputs);
  45721. var stack = evaluator.execute(input);
  45722. var stackIndex = stack.length - numOutputs;
  45723. for (i = 0; i < numOutputs; i++) {
  45724. value = stack[stackIndex + i];
  45725. var bound = range[i * 2];
  45726. if (value < bound) {
  45727. value = bound;
  45728. } else {
  45729. bound = range[i * 2 + 1];
  45730. if (value > bound) {
  45731. value = bound;
  45732. }
  45733. }
  45734. output[i] = value;
  45735. }
  45736. if (cache_available > 0) {
  45737. cache_available--;
  45738. cache[key] = output;
  45739. }
  45740. dest.set(output, destOffset);
  45741. };
  45742. }
  45743. };
  45744. }();
  45745. function isPDFFunction(v) {
  45746. var fnDict;
  45747. if (typeof v !== 'object') {
  45748. return false;
  45749. } else if (isDict(v)) {
  45750. fnDict = v;
  45751. } else if (isStream(v)) {
  45752. fnDict = v.dict;
  45753. } else {
  45754. return false;
  45755. }
  45756. return fnDict.has('FunctionType');
  45757. }
  45758. var PostScriptStack = function PostScriptStackClosure() {
  45759. var MAX_STACK_SIZE = 100;
  45760. function PostScriptStack(initialStack) {
  45761. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  45762. }
  45763. PostScriptStack.prototype = {
  45764. push: function PostScriptStack_push(value) {
  45765. if (this.stack.length >= MAX_STACK_SIZE) {
  45766. error('PostScript function stack overflow.');
  45767. }
  45768. this.stack.push(value);
  45769. },
  45770. pop: function PostScriptStack_pop() {
  45771. if (this.stack.length <= 0) {
  45772. error('PostScript function stack underflow.');
  45773. }
  45774. return this.stack.pop();
  45775. },
  45776. copy: function PostScriptStack_copy(n) {
  45777. if (this.stack.length + n >= MAX_STACK_SIZE) {
  45778. error('PostScript function stack overflow.');
  45779. }
  45780. var stack = this.stack;
  45781. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  45782. stack.push(stack[i]);
  45783. }
  45784. },
  45785. index: function PostScriptStack_index(n) {
  45786. this.push(this.stack[this.stack.length - n - 1]);
  45787. },
  45788. roll: function PostScriptStack_roll(n, p) {
  45789. var stack = this.stack;
  45790. var l = stack.length - n;
  45791. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  45792. for (i = l, j = r; i < j; i++, j--) {
  45793. t = stack[i];
  45794. stack[i] = stack[j];
  45795. stack[j] = t;
  45796. }
  45797. for (i = l, j = c - 1; i < j; i++, j--) {
  45798. t = stack[i];
  45799. stack[i] = stack[j];
  45800. stack[j] = t;
  45801. }
  45802. for (i = c, j = r; i < j; i++, j--) {
  45803. t = stack[i];
  45804. stack[i] = stack[j];
  45805. stack[j] = t;
  45806. }
  45807. }
  45808. };
  45809. return PostScriptStack;
  45810. }();
  45811. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  45812. function PostScriptEvaluator(operators) {
  45813. this.operators = operators;
  45814. }
  45815. PostScriptEvaluator.prototype = {
  45816. execute: function PostScriptEvaluator_execute(initialStack) {
  45817. var stack = new PostScriptStack(initialStack);
  45818. var counter = 0;
  45819. var operators = this.operators;
  45820. var length = operators.length;
  45821. var operator, a, b;
  45822. while (counter < length) {
  45823. operator = operators[counter++];
  45824. if (typeof operator === 'number') {
  45825. stack.push(operator);
  45826. continue;
  45827. }
  45828. switch (operator) {
  45829. case 'jz':
  45830. b = stack.pop();
  45831. a = stack.pop();
  45832. if (!a) {
  45833. counter = b;
  45834. }
  45835. break;
  45836. case 'j':
  45837. a = stack.pop();
  45838. counter = a;
  45839. break;
  45840. case 'abs':
  45841. a = stack.pop();
  45842. stack.push(Math.abs(a));
  45843. break;
  45844. case 'add':
  45845. b = stack.pop();
  45846. a = stack.pop();
  45847. stack.push(a + b);
  45848. break;
  45849. case 'and':
  45850. b = stack.pop();
  45851. a = stack.pop();
  45852. if (isBool(a) && isBool(b)) {
  45853. stack.push(a && b);
  45854. } else {
  45855. stack.push(a & b);
  45856. }
  45857. break;
  45858. case 'atan':
  45859. a = stack.pop();
  45860. stack.push(Math.atan(a));
  45861. break;
  45862. case 'bitshift':
  45863. b = stack.pop();
  45864. a = stack.pop();
  45865. if (a > 0) {
  45866. stack.push(a << b);
  45867. } else {
  45868. stack.push(a >> b);
  45869. }
  45870. break;
  45871. case 'ceiling':
  45872. a = stack.pop();
  45873. stack.push(Math.ceil(a));
  45874. break;
  45875. case 'copy':
  45876. a = stack.pop();
  45877. stack.copy(a);
  45878. break;
  45879. case 'cos':
  45880. a = stack.pop();
  45881. stack.push(Math.cos(a));
  45882. break;
  45883. case 'cvi':
  45884. a = stack.pop() | 0;
  45885. stack.push(a);
  45886. break;
  45887. case 'cvr':
  45888. break;
  45889. case 'div':
  45890. b = stack.pop();
  45891. a = stack.pop();
  45892. stack.push(a / b);
  45893. break;
  45894. case 'dup':
  45895. stack.copy(1);
  45896. break;
  45897. case 'eq':
  45898. b = stack.pop();
  45899. a = stack.pop();
  45900. stack.push(a === b);
  45901. break;
  45902. case 'exch':
  45903. stack.roll(2, 1);
  45904. break;
  45905. case 'exp':
  45906. b = stack.pop();
  45907. a = stack.pop();
  45908. stack.push(Math.pow(a, b));
  45909. break;
  45910. case 'false':
  45911. stack.push(false);
  45912. break;
  45913. case 'floor':
  45914. a = stack.pop();
  45915. stack.push(Math.floor(a));
  45916. break;
  45917. case 'ge':
  45918. b = stack.pop();
  45919. a = stack.pop();
  45920. stack.push(a >= b);
  45921. break;
  45922. case 'gt':
  45923. b = stack.pop();
  45924. a = stack.pop();
  45925. stack.push(a > b);
  45926. break;
  45927. case 'idiv':
  45928. b = stack.pop();
  45929. a = stack.pop();
  45930. stack.push(a / b | 0);
  45931. break;
  45932. case 'index':
  45933. a = stack.pop();
  45934. stack.index(a);
  45935. break;
  45936. case 'le':
  45937. b = stack.pop();
  45938. a = stack.pop();
  45939. stack.push(a <= b);
  45940. break;
  45941. case 'ln':
  45942. a = stack.pop();
  45943. stack.push(Math.log(a));
  45944. break;
  45945. case 'log':
  45946. a = stack.pop();
  45947. stack.push(Math.log(a) / Math.LN10);
  45948. break;
  45949. case 'lt':
  45950. b = stack.pop();
  45951. a = stack.pop();
  45952. stack.push(a < b);
  45953. break;
  45954. case 'mod':
  45955. b = stack.pop();
  45956. a = stack.pop();
  45957. stack.push(a % b);
  45958. break;
  45959. case 'mul':
  45960. b = stack.pop();
  45961. a = stack.pop();
  45962. stack.push(a * b);
  45963. break;
  45964. case 'ne':
  45965. b = stack.pop();
  45966. a = stack.pop();
  45967. stack.push(a !== b);
  45968. break;
  45969. case 'neg':
  45970. a = stack.pop();
  45971. stack.push(-a);
  45972. break;
  45973. case 'not':
  45974. a = stack.pop();
  45975. if (isBool(a)) {
  45976. stack.push(!a);
  45977. } else {
  45978. stack.push(~a);
  45979. }
  45980. break;
  45981. case 'or':
  45982. b = stack.pop();
  45983. a = stack.pop();
  45984. if (isBool(a) && isBool(b)) {
  45985. stack.push(a || b);
  45986. } else {
  45987. stack.push(a | b);
  45988. }
  45989. break;
  45990. case 'pop':
  45991. stack.pop();
  45992. break;
  45993. case 'roll':
  45994. b = stack.pop();
  45995. a = stack.pop();
  45996. stack.roll(a, b);
  45997. break;
  45998. case 'round':
  45999. a = stack.pop();
  46000. stack.push(Math.round(a));
  46001. break;
  46002. case 'sin':
  46003. a = stack.pop();
  46004. stack.push(Math.sin(a));
  46005. break;
  46006. case 'sqrt':
  46007. a = stack.pop();
  46008. stack.push(Math.sqrt(a));
  46009. break;
  46010. case 'sub':
  46011. b = stack.pop();
  46012. a = stack.pop();
  46013. stack.push(a - b);
  46014. break;
  46015. case 'true':
  46016. stack.push(true);
  46017. break;
  46018. case 'truncate':
  46019. a = stack.pop();
  46020. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  46021. stack.push(a);
  46022. break;
  46023. case 'xor':
  46024. b = stack.pop();
  46025. a = stack.pop();
  46026. if (isBool(a) && isBool(b)) {
  46027. stack.push(a !== b);
  46028. } else {
  46029. stack.push(a ^ b);
  46030. }
  46031. break;
  46032. default:
  46033. error('Unknown operator ' + operator);
  46034. break;
  46035. }
  46036. }
  46037. return stack.stack;
  46038. }
  46039. };
  46040. return PostScriptEvaluator;
  46041. }();
  46042. var PostScriptCompiler = function PostScriptCompilerClosure() {
  46043. function AstNode(type) {
  46044. this.type = type;
  46045. }
  46046. AstNode.prototype.visit = function (visitor) {
  46047. throw new Error('abstract method');
  46048. };
  46049. function AstArgument(index, min, max) {
  46050. AstNode.call(this, 'args');
  46051. this.index = index;
  46052. this.min = min;
  46053. this.max = max;
  46054. }
  46055. AstArgument.prototype = Object.create(AstNode.prototype);
  46056. AstArgument.prototype.visit = function (visitor) {
  46057. visitor.visitArgument(this);
  46058. };
  46059. function AstLiteral(number) {
  46060. AstNode.call(this, 'literal');
  46061. this.number = number;
  46062. this.min = number;
  46063. this.max = number;
  46064. }
  46065. AstLiteral.prototype = Object.create(AstNode.prototype);
  46066. AstLiteral.prototype.visit = function (visitor) {
  46067. visitor.visitLiteral(this);
  46068. };
  46069. function AstBinaryOperation(op, arg1, arg2, min, max) {
  46070. AstNode.call(this, 'binary');
  46071. this.op = op;
  46072. this.arg1 = arg1;
  46073. this.arg2 = arg2;
  46074. this.min = min;
  46075. this.max = max;
  46076. }
  46077. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  46078. AstBinaryOperation.prototype.visit = function (visitor) {
  46079. visitor.visitBinaryOperation(this);
  46080. };
  46081. function AstMin(arg, max) {
  46082. AstNode.call(this, 'max');
  46083. this.arg = arg;
  46084. this.min = arg.min;
  46085. this.max = max;
  46086. }
  46087. AstMin.prototype = Object.create(AstNode.prototype);
  46088. AstMin.prototype.visit = function (visitor) {
  46089. visitor.visitMin(this);
  46090. };
  46091. function AstVariable(index, min, max) {
  46092. AstNode.call(this, 'var');
  46093. this.index = index;
  46094. this.min = min;
  46095. this.max = max;
  46096. }
  46097. AstVariable.prototype = Object.create(AstNode.prototype);
  46098. AstVariable.prototype.visit = function (visitor) {
  46099. visitor.visitVariable(this);
  46100. };
  46101. function AstVariableDefinition(variable, arg) {
  46102. AstNode.call(this, 'definition');
  46103. this.variable = variable;
  46104. this.arg = arg;
  46105. }
  46106. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  46107. AstVariableDefinition.prototype.visit = function (visitor) {
  46108. visitor.visitVariableDefinition(this);
  46109. };
  46110. function ExpressionBuilderVisitor() {
  46111. this.parts = [];
  46112. }
  46113. ExpressionBuilderVisitor.prototype = {
  46114. visitArgument: function (arg) {
  46115. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  46116. },
  46117. visitVariable: function (variable) {
  46118. this.parts.push('v', variable.index);
  46119. },
  46120. visitLiteral: function (literal) {
  46121. this.parts.push(literal.number);
  46122. },
  46123. visitBinaryOperation: function (operation) {
  46124. this.parts.push('(');
  46125. operation.arg1.visit(this);
  46126. this.parts.push(' ', operation.op, ' ');
  46127. operation.arg2.visit(this);
  46128. this.parts.push(')');
  46129. },
  46130. visitVariableDefinition: function (definition) {
  46131. this.parts.push('var ');
  46132. definition.variable.visit(this);
  46133. this.parts.push(' = ');
  46134. definition.arg.visit(this);
  46135. this.parts.push(';');
  46136. },
  46137. visitMin: function (max) {
  46138. this.parts.push('Math.min(');
  46139. max.arg.visit(this);
  46140. this.parts.push(', ', max.max, ')');
  46141. },
  46142. toString: function () {
  46143. return this.parts.join('');
  46144. }
  46145. };
  46146. function buildAddOperation(num1, num2) {
  46147. if (num2.type === 'literal' && num2.number === 0) {
  46148. return num1;
  46149. }
  46150. if (num1.type === 'literal' && num1.number === 0) {
  46151. return num2;
  46152. }
  46153. if (num2.type === 'literal' && num1.type === 'literal') {
  46154. return new AstLiteral(num1.number + num2.number);
  46155. }
  46156. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  46157. }
  46158. function buildMulOperation(num1, num2) {
  46159. if (num2.type === 'literal') {
  46160. if (num2.number === 0) {
  46161. return new AstLiteral(0);
  46162. } else if (num2.number === 1) {
  46163. return num1;
  46164. } else if (num1.type === 'literal') {
  46165. return new AstLiteral(num1.number * num2.number);
  46166. }
  46167. }
  46168. if (num1.type === 'literal') {
  46169. if (num1.number === 0) {
  46170. return new AstLiteral(0);
  46171. } else if (num1.number === 1) {
  46172. return num2;
  46173. }
  46174. }
  46175. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  46176. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  46177. return new AstBinaryOperation('*', num1, num2, min, max);
  46178. }
  46179. function buildSubOperation(num1, num2) {
  46180. if (num2.type === 'literal') {
  46181. if (num2.number === 0) {
  46182. return num1;
  46183. } else if (num1.type === 'literal') {
  46184. return new AstLiteral(num1.number - num2.number);
  46185. }
  46186. }
  46187. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  46188. return num2.arg2;
  46189. }
  46190. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  46191. }
  46192. function buildMinOperation(num1, max) {
  46193. if (num1.min >= max) {
  46194. return new AstLiteral(max);
  46195. } else if (num1.max <= max) {
  46196. return num1;
  46197. }
  46198. return new AstMin(num1, max);
  46199. }
  46200. function PostScriptCompiler() {
  46201. }
  46202. PostScriptCompiler.prototype = {
  46203. compile: function PostScriptCompiler_compile(code, domain, range) {
  46204. var stack = [];
  46205. var i, ii;
  46206. var instructions = [];
  46207. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  46208. var lastRegister = 0;
  46209. var n, j;
  46210. var num1, num2, ast1, ast2, tmpVar, item;
  46211. for (i = 0; i < inputSize; i++) {
  46212. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  46213. }
  46214. for (i = 0, ii = code.length; i < ii; i++) {
  46215. item = code[i];
  46216. if (typeof item === 'number') {
  46217. stack.push(new AstLiteral(item));
  46218. continue;
  46219. }
  46220. switch (item) {
  46221. case 'add':
  46222. if (stack.length < 2) {
  46223. return null;
  46224. }
  46225. num2 = stack.pop();
  46226. num1 = stack.pop();
  46227. stack.push(buildAddOperation(num1, num2));
  46228. break;
  46229. case 'cvr':
  46230. if (stack.length < 1) {
  46231. return null;
  46232. }
  46233. break;
  46234. case 'mul':
  46235. if (stack.length < 2) {
  46236. return null;
  46237. }
  46238. num2 = stack.pop();
  46239. num1 = stack.pop();
  46240. stack.push(buildMulOperation(num1, num2));
  46241. break;
  46242. case 'sub':
  46243. if (stack.length < 2) {
  46244. return null;
  46245. }
  46246. num2 = stack.pop();
  46247. num1 = stack.pop();
  46248. stack.push(buildSubOperation(num1, num2));
  46249. break;
  46250. case 'exch':
  46251. if (stack.length < 2) {
  46252. return null;
  46253. }
  46254. ast1 = stack.pop();
  46255. ast2 = stack.pop();
  46256. stack.push(ast1, ast2);
  46257. break;
  46258. case 'pop':
  46259. if (stack.length < 1) {
  46260. return null;
  46261. }
  46262. stack.pop();
  46263. break;
  46264. case 'index':
  46265. if (stack.length < 1) {
  46266. return null;
  46267. }
  46268. num1 = stack.pop();
  46269. if (num1.type !== 'literal') {
  46270. return null;
  46271. }
  46272. n = num1.number;
  46273. if (n < 0 || (n | 0) !== n || stack.length < n) {
  46274. return null;
  46275. }
  46276. ast1 = stack[stack.length - n - 1];
  46277. if (ast1.type === 'literal' || ast1.type === 'var') {
  46278. stack.push(ast1);
  46279. break;
  46280. }
  46281. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  46282. stack[stack.length - n - 1] = tmpVar;
  46283. stack.push(tmpVar);
  46284. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  46285. break;
  46286. case 'dup':
  46287. if (stack.length < 1) {
  46288. return null;
  46289. }
  46290. 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]) {
  46291. num1 = stack.pop();
  46292. stack.push(buildMinOperation(num1, code[i + 1]));
  46293. i += 6;
  46294. break;
  46295. }
  46296. ast1 = stack[stack.length - 1];
  46297. if (ast1.type === 'literal' || ast1.type === 'var') {
  46298. stack.push(ast1);
  46299. break;
  46300. }
  46301. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  46302. stack[stack.length - 1] = tmpVar;
  46303. stack.push(tmpVar);
  46304. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  46305. break;
  46306. case 'roll':
  46307. if (stack.length < 2) {
  46308. return null;
  46309. }
  46310. num2 = stack.pop();
  46311. num1 = stack.pop();
  46312. if (num2.type !== 'literal' || num1.type !== 'literal') {
  46313. return null;
  46314. }
  46315. j = num2.number;
  46316. n = num1.number;
  46317. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  46318. return null;
  46319. }
  46320. j = (j % n + n) % n;
  46321. if (j === 0) {
  46322. break;
  46323. }
  46324. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  46325. break;
  46326. default:
  46327. return null;
  46328. }
  46329. }
  46330. if (stack.length !== outputSize) {
  46331. return null;
  46332. }
  46333. var result = [];
  46334. instructions.forEach(function (instruction) {
  46335. var statementBuilder = new ExpressionBuilderVisitor();
  46336. instruction.visit(statementBuilder);
  46337. result.push(statementBuilder.toString());
  46338. });
  46339. stack.forEach(function (expr, i) {
  46340. var statementBuilder = new ExpressionBuilderVisitor();
  46341. expr.visit(statementBuilder);
  46342. var min = range[i * 2], max = range[i * 2 + 1];
  46343. var out = [statementBuilder.toString()];
  46344. if (min > expr.min) {
  46345. out.unshift('Math.max(', min, ', ');
  46346. out.push(')');
  46347. }
  46348. if (max < expr.max) {
  46349. out.unshift('Math.min(', max, ', ');
  46350. out.push(')');
  46351. }
  46352. out.unshift('dest[destOffset + ', i, '] = ');
  46353. out.push(';');
  46354. result.push(out.join(''));
  46355. });
  46356. return result.join('\n');
  46357. }
  46358. };
  46359. return PostScriptCompiler;
  46360. }();
  46361. exports.isPDFFunction = isPDFFunction;
  46362. exports.PDFFunction = PDFFunction;
  46363. exports.PostScriptEvaluator = PostScriptEvaluator;
  46364. exports.PostScriptCompiler = PostScriptCompiler;
  46365. }));
  46366. (function (root, factory) {
  46367. factory(root.pdfjsDisplayAPI = {}, root.pdfjsSharedUtil, root.pdfjsDisplayFontLoader, root.pdfjsDisplayCanvas, root.pdfjsDisplayMetadata, root.pdfjsDisplayDOMUtils);
  46368. }(this, function (exports, sharedUtil, displayFontLoader, displayCanvas, displayMetadata, displayDOMUtils, amdRequire) {
  46369. var InvalidPDFException = sharedUtil.InvalidPDFException;
  46370. var MessageHandler = sharedUtil.MessageHandler;
  46371. var MissingPDFException = sharedUtil.MissingPDFException;
  46372. var PageViewport = sharedUtil.PageViewport;
  46373. var PasswordResponses = sharedUtil.PasswordResponses;
  46374. var PasswordException = sharedUtil.PasswordException;
  46375. var StatTimer = sharedUtil.StatTimer;
  46376. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  46377. var UnknownErrorException = sharedUtil.UnknownErrorException;
  46378. var Util = sharedUtil.Util;
  46379. var createPromiseCapability = sharedUtil.createPromiseCapability;
  46380. var error = sharedUtil.error;
  46381. var deprecated = sharedUtil.deprecated;
  46382. var getVerbosityLevel = sharedUtil.getVerbosityLevel;
  46383. var info = sharedUtil.info;
  46384. var isInt = sharedUtil.isInt;
  46385. var isArray = sharedUtil.isArray;
  46386. var isArrayBuffer = sharedUtil.isArrayBuffer;
  46387. var isSameOrigin = sharedUtil.isSameOrigin;
  46388. var loadJpegStream = sharedUtil.loadJpegStream;
  46389. var stringToBytes = sharedUtil.stringToBytes;
  46390. var globalScope = sharedUtil.globalScope;
  46391. var warn = sharedUtil.warn;
  46392. var FontFaceObject = displayFontLoader.FontFaceObject;
  46393. var FontLoader = displayFontLoader.FontLoader;
  46394. var CanvasGraphics = displayCanvas.CanvasGraphics;
  46395. var createScratchCanvas = displayCanvas.createScratchCanvas;
  46396. var Metadata = displayMetadata.Metadata;
  46397. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  46398. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  46399. var isWorkerDisabled = false;
  46400. var workerSrc;
  46401. var isPostMessageTransfersDisabled = false;
  46402. var fakeWorkerFilesLoader = null;
  46403. var useRequireEnsure = false;
  46404. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  46405. var task = new PDFDocumentLoadingTask();
  46406. if (arguments.length > 1) {
  46407. deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  46408. }
  46409. if (pdfDataRangeTransport) {
  46410. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  46411. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  46412. pdfDataRangeTransport.length = src.length;
  46413. pdfDataRangeTransport.initialData = src.initialData;
  46414. if (!pdfDataRangeTransport.abort) {
  46415. pdfDataRangeTransport.abort = function () {
  46416. };
  46417. }
  46418. }
  46419. src = Object.create(src);
  46420. src.range = pdfDataRangeTransport;
  46421. }
  46422. task.onPassword = passwordCallback || null;
  46423. task.onProgress = progressCallback || null;
  46424. var source;
  46425. if (typeof src === 'string') {
  46426. source = { url: src };
  46427. } else if (isArrayBuffer(src)) {
  46428. source = { data: src };
  46429. } else if (src instanceof PDFDataRangeTransport) {
  46430. source = { range: src };
  46431. } else {
  46432. if (typeof src !== 'object') {
  46433. error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
  46434. }
  46435. if (!src.url && !src.data && !src.range) {
  46436. error('Invalid parameter object: need either .data, .range or .url');
  46437. }
  46438. source = src;
  46439. }
  46440. var params = {};
  46441. var rangeTransport = null;
  46442. var worker = null;
  46443. for (var key in source) {
  46444. if (key === 'url' && typeof window !== 'undefined') {
  46445. params[key] = new URL(source[key], window.location).href;
  46446. continue;
  46447. } else if (key === 'range') {
  46448. rangeTransport = source[key];
  46449. continue;
  46450. } else if (key === 'worker') {
  46451. worker = source[key];
  46452. continue;
  46453. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  46454. var pdfBytes = source[key];
  46455. if (typeof pdfBytes === 'string') {
  46456. params[key] = stringToBytes(pdfBytes);
  46457. } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  46458. params[key] = new Uint8Array(pdfBytes);
  46459. } else if (isArrayBuffer(pdfBytes)) {
  46460. params[key] = new Uint8Array(pdfBytes);
  46461. } else {
  46462. error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
  46463. }
  46464. continue;
  46465. }
  46466. params[key] = source[key];
  46467. }
  46468. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  46469. if (!worker) {
  46470. worker = new PDFWorker();
  46471. task._worker = worker;
  46472. }
  46473. var docId = task.docId;
  46474. worker.promise.then(function () {
  46475. if (task.destroyed) {
  46476. throw new Error('Loading aborted');
  46477. }
  46478. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  46479. if (task.destroyed) {
  46480. throw new Error('Loading aborted');
  46481. }
  46482. var messageHandler = new MessageHandler(docId, workerId, worker.port);
  46483. var transport = new WorkerTransport(messageHandler, task, rangeTransport);
  46484. task._transport = transport;
  46485. messageHandler.send('Ready', null);
  46486. });
  46487. }).catch(task._capability.reject);
  46488. return task;
  46489. }
  46490. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  46491. if (worker.destroyed) {
  46492. return Promise.reject(new Error('Worker was destroyed'));
  46493. }
  46494. source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
  46495. source.disableStream = getDefaultSetting('disableStream');
  46496. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  46497. if (pdfDataRangeTransport) {
  46498. source.length = pdfDataRangeTransport.length;
  46499. source.initialData = pdfDataRangeTransport.initialData;
  46500. }
  46501. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  46502. docId: docId,
  46503. source: source,
  46504. disableRange: getDefaultSetting('disableRange'),
  46505. maxImageSize: getDefaultSetting('maxImageSize'),
  46506. cMapUrl: getDefaultSetting('cMapUrl'),
  46507. cMapPacked: getDefaultSetting('cMapPacked'),
  46508. disableFontFace: getDefaultSetting('disableFontFace'),
  46509. disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
  46510. postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
  46511. docBaseUrl: source.docBaseUrl
  46512. }).then(function (workerId) {
  46513. if (worker.destroyed) {
  46514. throw new Error('Worker was destroyed');
  46515. }
  46516. return workerId;
  46517. });
  46518. }
  46519. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  46520. var nextDocumentId = 0;
  46521. function PDFDocumentLoadingTask() {
  46522. this._capability = createPromiseCapability();
  46523. this._transport = null;
  46524. this._worker = null;
  46525. this.docId = 'd' + nextDocumentId++;
  46526. this.destroyed = false;
  46527. this.onPassword = null;
  46528. this.onProgress = null;
  46529. this.onUnsupportedFeature = null;
  46530. }
  46531. PDFDocumentLoadingTask.prototype = {
  46532. get promise() {
  46533. return this._capability.promise;
  46534. },
  46535. destroy: function () {
  46536. this.destroyed = true;
  46537. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  46538. return transportDestroyed.then(function () {
  46539. this._transport = null;
  46540. if (this._worker) {
  46541. this._worker.destroy();
  46542. this._worker = null;
  46543. }
  46544. }.bind(this));
  46545. },
  46546. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  46547. return this.promise.then.apply(this.promise, arguments);
  46548. }
  46549. };
  46550. return PDFDocumentLoadingTask;
  46551. }();
  46552. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  46553. function PDFDataRangeTransport(length, initialData) {
  46554. this.length = length;
  46555. this.initialData = initialData;
  46556. this._rangeListeners = [];
  46557. this._progressListeners = [];
  46558. this._progressiveReadListeners = [];
  46559. this._readyCapability = createPromiseCapability();
  46560. }
  46561. PDFDataRangeTransport.prototype = {
  46562. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  46563. this._rangeListeners.push(listener);
  46564. },
  46565. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  46566. this._progressListeners.push(listener);
  46567. },
  46568. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  46569. this._progressiveReadListeners.push(listener);
  46570. },
  46571. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  46572. var listeners = this._rangeListeners;
  46573. for (var i = 0, n = listeners.length; i < n; ++i) {
  46574. listeners[i](begin, chunk);
  46575. }
  46576. },
  46577. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  46578. this._readyCapability.promise.then(function () {
  46579. var listeners = this._progressListeners;
  46580. for (var i = 0, n = listeners.length; i < n; ++i) {
  46581. listeners[i](loaded);
  46582. }
  46583. }.bind(this));
  46584. },
  46585. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  46586. this._readyCapability.promise.then(function () {
  46587. var listeners = this._progressiveReadListeners;
  46588. for (var i = 0, n = listeners.length; i < n; ++i) {
  46589. listeners[i](chunk);
  46590. }
  46591. }.bind(this));
  46592. },
  46593. transportReady: function PDFDataRangeTransport_transportReady() {
  46594. this._readyCapability.resolve();
  46595. },
  46596. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  46597. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  46598. },
  46599. abort: function PDFDataRangeTransport_abort() {
  46600. }
  46601. };
  46602. return PDFDataRangeTransport;
  46603. }();
  46604. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  46605. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  46606. this.pdfInfo = pdfInfo;
  46607. this.transport = transport;
  46608. this.loadingTask = loadingTask;
  46609. }
  46610. PDFDocumentProxy.prototype = {
  46611. get numPages() {
  46612. return this.pdfInfo.numPages;
  46613. },
  46614. get fingerprint() {
  46615. return this.pdfInfo.fingerprint;
  46616. },
  46617. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  46618. return this.transport.getPage(pageNumber);
  46619. },
  46620. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  46621. return this.transport.getPageIndex(ref);
  46622. },
  46623. getDestinations: function PDFDocumentProxy_getDestinations() {
  46624. return this.transport.getDestinations();
  46625. },
  46626. getDestination: function PDFDocumentProxy_getDestination(id) {
  46627. return this.transport.getDestination(id);
  46628. },
  46629. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  46630. return this.transport.getPageLabels();
  46631. },
  46632. getAttachments: function PDFDocumentProxy_getAttachments() {
  46633. return this.transport.getAttachments();
  46634. },
  46635. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  46636. return this.transport.getJavaScript();
  46637. },
  46638. getOutline: function PDFDocumentProxy_getOutline() {
  46639. return this.transport.getOutline();
  46640. },
  46641. getMetadata: function PDFDocumentProxy_getMetadata() {
  46642. return this.transport.getMetadata();
  46643. },
  46644. getData: function PDFDocumentProxy_getData() {
  46645. return this.transport.getData();
  46646. },
  46647. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  46648. return this.transport.downloadInfoCapability.promise;
  46649. },
  46650. getStats: function PDFDocumentProxy_getStats() {
  46651. return this.transport.getStats();
  46652. },
  46653. cleanup: function PDFDocumentProxy_cleanup() {
  46654. this.transport.startCleanup();
  46655. },
  46656. destroy: function PDFDocumentProxy_destroy() {
  46657. return this.loadingTask.destroy();
  46658. }
  46659. };
  46660. return PDFDocumentProxy;
  46661. }();
  46662. var PDFPageProxy = function PDFPageProxyClosure() {
  46663. function PDFPageProxy(pageIndex, pageInfo, transport) {
  46664. this.pageIndex = pageIndex;
  46665. this.pageInfo = pageInfo;
  46666. this.transport = transport;
  46667. this.stats = new StatTimer();
  46668. this.stats.enabled = getDefaultSetting('enableStats');
  46669. this.commonObjs = transport.commonObjs;
  46670. this.objs = new PDFObjects();
  46671. this.cleanupAfterRender = false;
  46672. this.pendingCleanup = false;
  46673. this.intentStates = Object.create(null);
  46674. this.destroyed = false;
  46675. }
  46676. PDFPageProxy.prototype = {
  46677. get pageNumber() {
  46678. return this.pageIndex + 1;
  46679. },
  46680. get rotate() {
  46681. return this.pageInfo.rotate;
  46682. },
  46683. get ref() {
  46684. return this.pageInfo.ref;
  46685. },
  46686. get userUnit() {
  46687. return this.pageInfo.userUnit;
  46688. },
  46689. get view() {
  46690. return this.pageInfo.view;
  46691. },
  46692. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  46693. if (arguments.length < 2) {
  46694. rotate = this.rotate;
  46695. }
  46696. return new PageViewport(this.view, scale, rotate, 0, 0);
  46697. },
  46698. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  46699. var intent = params && params.intent || null;
  46700. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  46701. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  46702. this.annotationsIntent = intent;
  46703. }
  46704. return this.annotationsPromise;
  46705. },
  46706. render: function PDFPageProxy_render(params) {
  46707. var stats = this.stats;
  46708. stats.time('Overall');
  46709. this.pendingCleanup = false;
  46710. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  46711. var renderInteractiveForms = params.renderInteractiveForms === true ? true : false;
  46712. if (!this.intentStates[renderingIntent]) {
  46713. this.intentStates[renderingIntent] = Object.create(null);
  46714. }
  46715. var intentState = this.intentStates[renderingIntent];
  46716. if (!intentState.displayReadyCapability) {
  46717. intentState.receivingOperatorList = true;
  46718. intentState.displayReadyCapability = createPromiseCapability();
  46719. intentState.operatorList = {
  46720. fnArray: [],
  46721. argsArray: [],
  46722. lastChunk: false
  46723. };
  46724. this.stats.time('Page Request');
  46725. this.transport.messageHandler.send('RenderPageRequest', {
  46726. pageIndex: this.pageNumber - 1,
  46727. intent: renderingIntent,
  46728. renderInteractiveForms: renderInteractiveForms
  46729. });
  46730. }
  46731. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber);
  46732. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  46733. if (!intentState.renderTasks) {
  46734. intentState.renderTasks = [];
  46735. }
  46736. intentState.renderTasks.push(internalRenderTask);
  46737. var renderTask = internalRenderTask.task;
  46738. if (params.continueCallback) {
  46739. deprecated('render is used with continueCallback parameter');
  46740. renderTask.onContinue = params.continueCallback;
  46741. }
  46742. var self = this;
  46743. intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) {
  46744. if (self.pendingCleanup) {
  46745. complete();
  46746. return;
  46747. }
  46748. stats.time('Rendering');
  46749. internalRenderTask.initializeGraphics(transparency);
  46750. internalRenderTask.operatorListChanged();
  46751. }, function pageDisplayReadPromiseError(reason) {
  46752. complete(reason);
  46753. });
  46754. function complete(error) {
  46755. var i = intentState.renderTasks.indexOf(internalRenderTask);
  46756. if (i >= 0) {
  46757. intentState.renderTasks.splice(i, 1);
  46758. }
  46759. if (self.cleanupAfterRender) {
  46760. self.pendingCleanup = true;
  46761. }
  46762. self._tryCleanup();
  46763. if (error) {
  46764. internalRenderTask.capability.reject(error);
  46765. } else {
  46766. internalRenderTask.capability.resolve();
  46767. }
  46768. stats.timeEnd('Rendering');
  46769. stats.timeEnd('Overall');
  46770. }
  46771. return renderTask;
  46772. },
  46773. getOperatorList: function PDFPageProxy_getOperatorList() {
  46774. function operatorListChanged() {
  46775. if (intentState.operatorList.lastChunk) {
  46776. intentState.opListReadCapability.resolve(intentState.operatorList);
  46777. var i = intentState.renderTasks.indexOf(opListTask);
  46778. if (i >= 0) {
  46779. intentState.renderTasks.splice(i, 1);
  46780. }
  46781. }
  46782. }
  46783. var renderingIntent = 'oplist';
  46784. if (!this.intentStates[renderingIntent]) {
  46785. this.intentStates[renderingIntent] = Object.create(null);
  46786. }
  46787. var intentState = this.intentStates[renderingIntent];
  46788. var opListTask;
  46789. if (!intentState.opListReadCapability) {
  46790. opListTask = {};
  46791. opListTask.operatorListChanged = operatorListChanged;
  46792. intentState.receivingOperatorList = true;
  46793. intentState.opListReadCapability = createPromiseCapability();
  46794. intentState.renderTasks = [];
  46795. intentState.renderTasks.push(opListTask);
  46796. intentState.operatorList = {
  46797. fnArray: [],
  46798. argsArray: [],
  46799. lastChunk: false
  46800. };
  46801. this.transport.messageHandler.send('RenderPageRequest', {
  46802. pageIndex: this.pageIndex,
  46803. intent: renderingIntent
  46804. });
  46805. }
  46806. return intentState.opListReadCapability.promise;
  46807. },
  46808. getTextContent: function PDFPageProxy_getTextContent(params) {
  46809. return this.transport.messageHandler.sendWithPromise('GetTextContent', {
  46810. pageIndex: this.pageNumber - 1,
  46811. normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false,
  46812. combineTextItems: params && params.disableCombineTextItems === true ? false : true
  46813. });
  46814. },
  46815. _destroy: function PDFPageProxy_destroy() {
  46816. this.destroyed = true;
  46817. this.transport.pageCache[this.pageIndex] = null;
  46818. var waitOn = [];
  46819. Object.keys(this.intentStates).forEach(function (intent) {
  46820. if (intent === 'oplist') {
  46821. return;
  46822. }
  46823. var intentState = this.intentStates[intent];
  46824. intentState.renderTasks.forEach(function (renderTask) {
  46825. var renderCompleted = renderTask.capability.promise.catch(function () {
  46826. });
  46827. waitOn.push(renderCompleted);
  46828. renderTask.cancel();
  46829. });
  46830. }, this);
  46831. this.objs.clear();
  46832. this.annotationsPromise = null;
  46833. this.pendingCleanup = false;
  46834. return Promise.all(waitOn);
  46835. },
  46836. destroy: function () {
  46837. deprecated('page destroy method, use cleanup() instead');
  46838. this.cleanup();
  46839. },
  46840. cleanup: function PDFPageProxy_cleanup() {
  46841. this.pendingCleanup = true;
  46842. this._tryCleanup();
  46843. },
  46844. _tryCleanup: function PDFPageProxy_tryCleanup() {
  46845. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  46846. var intentState = this.intentStates[intent];
  46847. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  46848. }, this)) {
  46849. return;
  46850. }
  46851. Object.keys(this.intentStates).forEach(function (intent) {
  46852. delete this.intentStates[intent];
  46853. }, this);
  46854. this.objs.clear();
  46855. this.annotationsPromise = null;
  46856. this.pendingCleanup = false;
  46857. },
  46858. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  46859. var intentState = this.intentStates[intent];
  46860. if (intentState.displayReadyCapability) {
  46861. intentState.displayReadyCapability.resolve(transparency);
  46862. }
  46863. },
  46864. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  46865. var intentState = this.intentStates[intent];
  46866. var i, ii;
  46867. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  46868. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  46869. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  46870. }
  46871. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  46872. for (i = 0; i < intentState.renderTasks.length; i++) {
  46873. intentState.renderTasks[i].operatorListChanged();
  46874. }
  46875. if (operatorListChunk.lastChunk) {
  46876. intentState.receivingOperatorList = false;
  46877. this._tryCleanup();
  46878. }
  46879. }
  46880. };
  46881. return PDFPageProxy;
  46882. }();
  46883. var PDFWorker = function PDFWorkerClosure() {
  46884. var nextFakeWorkerId = 0;
  46885. function getWorkerSrc() {
  46886. if (typeof workerSrc !== 'undefined') {
  46887. return workerSrc;
  46888. }
  46889. if (getDefaultSetting('workerSrc')) {
  46890. return getDefaultSetting('workerSrc');
  46891. }
  46892. if (pdfjsFilePath) {
  46893. return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
  46894. }
  46895. error('No PDFJS.workerSrc specified');
  46896. }
  46897. var fakeWorkerFilesLoadedCapability;
  46898. function setupFakeWorkerGlobal() {
  46899. var WorkerMessageHandler;
  46900. if (fakeWorkerFilesLoadedCapability) {
  46901. return fakeWorkerFilesLoadedCapability.promise;
  46902. }
  46903. fakeWorkerFilesLoadedCapability = createPromiseCapability();
  46904. WorkerMessageHandler = pdfjsLibs.pdfjsCoreWorker.WorkerMessageHandler;
  46905. fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
  46906. return fakeWorkerFilesLoadedCapability.promise;
  46907. }
  46908. function FakeWorkerPort(defer) {
  46909. this._listeners = [];
  46910. this._defer = defer;
  46911. this._deferred = Promise.resolve(undefined);
  46912. }
  46913. FakeWorkerPort.prototype = {
  46914. postMessage: function (obj, transfers) {
  46915. function cloneValue(value) {
  46916. if (typeof value !== 'object' || value === null) {
  46917. return value;
  46918. }
  46919. if (cloned.has(value)) {
  46920. return cloned.get(value);
  46921. }
  46922. var result;
  46923. var buffer;
  46924. if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
  46925. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  46926. if (value === buffer) {
  46927. result = value;
  46928. } else if (transferable) {
  46929. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  46930. } else {
  46931. result = new value.constructor(value);
  46932. }
  46933. cloned.set(value, result);
  46934. return result;
  46935. }
  46936. result = isArray(value) ? [] : {};
  46937. cloned.set(value, result);
  46938. for (var i in value) {
  46939. var desc, p = value;
  46940. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  46941. p = Object.getPrototypeOf(p);
  46942. }
  46943. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  46944. continue;
  46945. }
  46946. result[i] = cloneValue(desc.value);
  46947. }
  46948. return result;
  46949. }
  46950. if (!this._defer) {
  46951. this._listeners.forEach(function (listener) {
  46952. listener.call(this, { data: obj });
  46953. }, this);
  46954. return;
  46955. }
  46956. var cloned = new WeakMap();
  46957. var e = { data: cloneValue(obj) };
  46958. this._deferred.then(function () {
  46959. this._listeners.forEach(function (listener) {
  46960. listener.call(this, e);
  46961. }, this);
  46962. }.bind(this));
  46963. },
  46964. addEventListener: function (name, listener) {
  46965. this._listeners.push(listener);
  46966. },
  46967. removeEventListener: function (name, listener) {
  46968. var i = this._listeners.indexOf(listener);
  46969. this._listeners.splice(i, 1);
  46970. },
  46971. terminate: function () {
  46972. this._listeners = [];
  46973. }
  46974. };
  46975. function createCDNWrapper(url) {
  46976. var wrapper = 'importScripts(\'' + url + '\');';
  46977. return URL.createObjectURL(new Blob([wrapper]));
  46978. }
  46979. function PDFWorker(name) {
  46980. this.name = name;
  46981. this.destroyed = false;
  46982. this._readyCapability = createPromiseCapability();
  46983. this._port = null;
  46984. this._webWorker = null;
  46985. this._messageHandler = null;
  46986. this._initialize();
  46987. }
  46988. PDFWorker.prototype = {
  46989. get promise() {
  46990. return this._readyCapability.promise;
  46991. },
  46992. get port() {
  46993. return this._port;
  46994. },
  46995. get messageHandler() {
  46996. return this._messageHandler;
  46997. },
  46998. _initialize: function PDFWorker_initialize() {
  46999. this._setupFakeWorker();
  47000. },
  47001. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  47002. if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
  47003. warn('Setting up fake worker.');
  47004. isWorkerDisabled = true;
  47005. }
  47006. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  47007. if (this.destroyed) {
  47008. this._readyCapability.reject(new Error('Worker was destroyed'));
  47009. return;
  47010. }
  47011. var isTypedArraysPresent = Uint8Array !== Float32Array;
  47012. var port = new FakeWorkerPort(isTypedArraysPresent);
  47013. this._port = port;
  47014. var id = 'fake' + nextFakeWorkerId++;
  47015. var workerHandler = new MessageHandler(id + '_worker', id, port);
  47016. WorkerMessageHandler.setup(workerHandler, port);
  47017. var messageHandler = new MessageHandler(id, id + '_worker', port);
  47018. this._messageHandler = messageHandler;
  47019. this._readyCapability.resolve();
  47020. }.bind(this));
  47021. },
  47022. destroy: function PDFWorker_destroy() {
  47023. this.destroyed = true;
  47024. if (this._webWorker) {
  47025. this._webWorker.terminate();
  47026. this._webWorker = null;
  47027. }
  47028. this._port = null;
  47029. if (this._messageHandler) {
  47030. this._messageHandler.destroy();
  47031. this._messageHandler = null;
  47032. }
  47033. }
  47034. };
  47035. return PDFWorker;
  47036. }();
  47037. var WorkerTransport = function WorkerTransportClosure() {
  47038. function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport) {
  47039. this.messageHandler = messageHandler;
  47040. this.loadingTask = loadingTask;
  47041. this.pdfDataRangeTransport = pdfDataRangeTransport;
  47042. this.commonObjs = new PDFObjects();
  47043. this.fontLoader = new FontLoader(loadingTask.docId);
  47044. this.destroyed = false;
  47045. this.destroyCapability = null;
  47046. this.pageCache = [];
  47047. this.pagePromises = [];
  47048. this.downloadInfoCapability = createPromiseCapability();
  47049. this.setupMessageHandler();
  47050. }
  47051. WorkerTransport.prototype = {
  47052. destroy: function WorkerTransport_destroy() {
  47053. if (this.destroyCapability) {
  47054. return this.destroyCapability.promise;
  47055. }
  47056. this.destroyed = true;
  47057. this.destroyCapability = createPromiseCapability();
  47058. var waitOn = [];
  47059. this.pageCache.forEach(function (page) {
  47060. if (page) {
  47061. waitOn.push(page._destroy());
  47062. }
  47063. });
  47064. this.pageCache = [];
  47065. this.pagePromises = [];
  47066. var self = this;
  47067. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  47068. waitOn.push(terminated);
  47069. Promise.all(waitOn).then(function () {
  47070. self.fontLoader.clear();
  47071. if (self.pdfDataRangeTransport) {
  47072. self.pdfDataRangeTransport.abort();
  47073. self.pdfDataRangeTransport = null;
  47074. }
  47075. if (self.messageHandler) {
  47076. self.messageHandler.destroy();
  47077. self.messageHandler = null;
  47078. }
  47079. self.destroyCapability.resolve();
  47080. }, this.destroyCapability.reject);
  47081. return this.destroyCapability.promise;
  47082. },
  47083. setupMessageHandler: function WorkerTransport_setupMessageHandler() {
  47084. var messageHandler = this.messageHandler;
  47085. function updatePassword(password) {
  47086. messageHandler.send('UpdatePassword', password);
  47087. }
  47088. var pdfDataRangeTransport = this.pdfDataRangeTransport;
  47089. if (pdfDataRangeTransport) {
  47090. pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  47091. messageHandler.send('OnDataRange', {
  47092. begin: begin,
  47093. chunk: chunk
  47094. });
  47095. });
  47096. pdfDataRangeTransport.addProgressListener(function (loaded) {
  47097. messageHandler.send('OnDataProgress', { loaded: loaded });
  47098. });
  47099. pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  47100. messageHandler.send('OnDataRange', { chunk: chunk });
  47101. });
  47102. messageHandler.on('RequestDataRange', function transportDataRange(data) {
  47103. pdfDataRangeTransport.requestDataRange(data.begin, data.end);
  47104. }, this);
  47105. }
  47106. messageHandler.on('GetDoc', function transportDoc(data) {
  47107. var pdfInfo = data.pdfInfo;
  47108. this.numPages = data.pdfInfo.numPages;
  47109. var loadingTask = this.loadingTask;
  47110. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  47111. this.pdfDocument = pdfDocument;
  47112. loadingTask._capability.resolve(pdfDocument);
  47113. }, this);
  47114. messageHandler.on('NeedPassword', function transportNeedPassword(exception) {
  47115. var loadingTask = this.loadingTask;
  47116. if (loadingTask.onPassword) {
  47117. return loadingTask.onPassword(updatePassword, PasswordResponses.NEED_PASSWORD);
  47118. }
  47119. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  47120. }, this);
  47121. messageHandler.on('IncorrectPassword', function transportIncorrectPassword(exception) {
  47122. var loadingTask = this.loadingTask;
  47123. if (loadingTask.onPassword) {
  47124. return loadingTask.onPassword(updatePassword, PasswordResponses.INCORRECT_PASSWORD);
  47125. }
  47126. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  47127. }, this);
  47128. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  47129. this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
  47130. }, this);
  47131. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  47132. this.loadingTask._capability.reject(new MissingPDFException(exception.message));
  47133. }, this);
  47134. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  47135. this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status));
  47136. }, this);
  47137. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  47138. this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
  47139. }, this);
  47140. messageHandler.on('DataLoaded', function transportPage(data) {
  47141. this.downloadInfoCapability.resolve(data);
  47142. }, this);
  47143. messageHandler.on('PDFManagerReady', function transportPage(data) {
  47144. if (this.pdfDataRangeTransport) {
  47145. this.pdfDataRangeTransport.transportReady();
  47146. }
  47147. }, this);
  47148. messageHandler.on('StartRenderPage', function transportRender(data) {
  47149. if (this.destroyed) {
  47150. return;
  47151. }
  47152. var page = this.pageCache[data.pageIndex];
  47153. page.stats.timeEnd('Page Request');
  47154. page._startRenderPage(data.transparency, data.intent);
  47155. }, this);
  47156. messageHandler.on('RenderPageChunk', function transportRender(data) {
  47157. if (this.destroyed) {
  47158. return;
  47159. }
  47160. var page = this.pageCache[data.pageIndex];
  47161. page._renderPageChunk(data.operatorList, data.intent);
  47162. }, this);
  47163. messageHandler.on('commonobj', function transportObj(data) {
  47164. if (this.destroyed) {
  47165. return;
  47166. }
  47167. var id = data[0];
  47168. var type = data[1];
  47169. if (this.commonObjs.hasData(id)) {
  47170. return;
  47171. }
  47172. switch (type) {
  47173. case 'Font':
  47174. var exportedData = data[2];
  47175. if ('error' in exportedData) {
  47176. var exportedError = exportedData.error;
  47177. warn('Error during font loading: ' + exportedError);
  47178. this.commonObjs.resolve(id, exportedError);
  47179. break;
  47180. }
  47181. var fontRegistry = null;
  47182. if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
  47183. fontRegistry = {
  47184. registerFont: function (font, url) {
  47185. globalScope['FontInspector'].fontAdded(font, url);
  47186. }
  47187. };
  47188. }
  47189. var font = new FontFaceObject(exportedData, {
  47190. isEvalSuported: getDefaultSetting('isEvalSupported'),
  47191. disableFontFace: getDefaultSetting('disableFontFace'),
  47192. fontRegistry: fontRegistry
  47193. });
  47194. this.fontLoader.bind([font], function fontReady(fontObjs) {
  47195. this.commonObjs.resolve(id, font);
  47196. }.bind(this));
  47197. break;
  47198. case 'FontPath':
  47199. this.commonObjs.resolve(id, data[2]);
  47200. break;
  47201. default:
  47202. error('Got unknown common object type ' + type);
  47203. }
  47204. }, this);
  47205. messageHandler.on('obj', function transportObj(data) {
  47206. if (this.destroyed) {
  47207. return;
  47208. }
  47209. var id = data[0];
  47210. var pageIndex = data[1];
  47211. var type = data[2];
  47212. var pageProxy = this.pageCache[pageIndex];
  47213. var imageData;
  47214. if (pageProxy.objs.hasData(id)) {
  47215. return;
  47216. }
  47217. switch (type) {
  47218. case 'JpegStream':
  47219. imageData = data[3];
  47220. loadJpegStream(id, imageData, pageProxy.objs);
  47221. break;
  47222. case 'Image':
  47223. imageData = data[3];
  47224. pageProxy.objs.resolve(id, imageData);
  47225. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  47226. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  47227. pageProxy.cleanupAfterRender = true;
  47228. }
  47229. break;
  47230. default:
  47231. error('Got unknown object type ' + type);
  47232. }
  47233. }, this);
  47234. messageHandler.on('DocProgress', function transportDocProgress(data) {
  47235. if (this.destroyed) {
  47236. return;
  47237. }
  47238. var loadingTask = this.loadingTask;
  47239. if (loadingTask.onProgress) {
  47240. loadingTask.onProgress({
  47241. loaded: data.loaded,
  47242. total: data.total
  47243. });
  47244. }
  47245. }, this);
  47246. messageHandler.on('PageError', function transportError(data) {
  47247. if (this.destroyed) {
  47248. return;
  47249. }
  47250. var page = this.pageCache[data.pageNum - 1];
  47251. var intentState = page.intentStates[data.intent];
  47252. if (intentState.displayReadyCapability) {
  47253. intentState.displayReadyCapability.reject(data.error);
  47254. } else {
  47255. error(data.error);
  47256. }
  47257. if (intentState.operatorList) {
  47258. intentState.operatorList.lastChunk = true;
  47259. for (var i = 0; i < intentState.renderTasks.length; i++) {
  47260. intentState.renderTasks[i].operatorListChanged();
  47261. }
  47262. }
  47263. }, this);
  47264. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  47265. if (this.destroyed) {
  47266. return;
  47267. }
  47268. var featureId = data.featureId;
  47269. var loadingTask = this.loadingTask;
  47270. if (loadingTask.onUnsupportedFeature) {
  47271. loadingTask.onUnsupportedFeature(featureId);
  47272. }
  47273. _UnsupportedManager.notify(featureId);
  47274. }, this);
  47275. messageHandler.on('JpegDecode', function (data) {
  47276. if (this.destroyed) {
  47277. return Promise.reject(new Error('Worker was destroyed'));
  47278. }
  47279. var imageUrl = data[0];
  47280. var components = data[1];
  47281. if (components !== 3 && components !== 1) {
  47282. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  47283. }
  47284. return new Promise(function (resolve, reject) {
  47285. var img = new Image();
  47286. img.onload = function () {
  47287. var width = img.width;
  47288. var height = img.height;
  47289. var size = width * height;
  47290. var rgbaLength = size * 4;
  47291. var buf = new Uint8Array(size * components);
  47292. var tmpCanvas = createScratchCanvas(width, height);
  47293. var tmpCtx = tmpCanvas.getContext('2d');
  47294. tmpCtx.drawImage(img, 0, 0);
  47295. var data = tmpCtx.getImageData(0, 0, width, height).data;
  47296. var i, j;
  47297. if (components === 3) {
  47298. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  47299. buf[j] = data[i];
  47300. buf[j + 1] = data[i + 1];
  47301. buf[j + 2] = data[i + 2];
  47302. }
  47303. } else if (components === 1) {
  47304. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  47305. buf[j] = data[i];
  47306. }
  47307. }
  47308. resolve({
  47309. data: buf,
  47310. width: width,
  47311. height: height
  47312. });
  47313. };
  47314. img.onerror = function () {
  47315. reject(new Error('JpegDecode failed to load image'));
  47316. };
  47317. img.src = imageUrl;
  47318. });
  47319. }, this);
  47320. },
  47321. getData: function WorkerTransport_getData() {
  47322. return this.messageHandler.sendWithPromise('GetData', null);
  47323. },
  47324. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  47325. if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  47326. return Promise.reject(new Error('Invalid page request'));
  47327. }
  47328. var pageIndex = pageNumber - 1;
  47329. if (pageIndex in this.pagePromises) {
  47330. return this.pagePromises[pageIndex];
  47331. }
  47332. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  47333. if (this.destroyed) {
  47334. throw new Error('Transport destroyed');
  47335. }
  47336. var page = new PDFPageProxy(pageIndex, pageInfo, this);
  47337. this.pageCache[pageIndex] = page;
  47338. return page;
  47339. }.bind(this));
  47340. this.pagePromises[pageIndex] = promise;
  47341. return promise;
  47342. },
  47343. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  47344. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  47345. return Promise.reject(new Error(reason));
  47346. });
  47347. },
  47348. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  47349. return this.messageHandler.sendWithPromise('GetAnnotations', {
  47350. pageIndex: pageIndex,
  47351. intent: intent
  47352. });
  47353. },
  47354. getDestinations: function WorkerTransport_getDestinations() {
  47355. return this.messageHandler.sendWithPromise('GetDestinations', null);
  47356. },
  47357. getDestination: function WorkerTransport_getDestination(id) {
  47358. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  47359. },
  47360. getPageLabels: function WorkerTransport_getPageLabels() {
  47361. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  47362. },
  47363. getAttachments: function WorkerTransport_getAttachments() {
  47364. return this.messageHandler.sendWithPromise('GetAttachments', null);
  47365. },
  47366. getJavaScript: function WorkerTransport_getJavaScript() {
  47367. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  47368. },
  47369. getOutline: function WorkerTransport_getOutline() {
  47370. return this.messageHandler.sendWithPromise('GetOutline', null);
  47371. },
  47372. getMetadata: function WorkerTransport_getMetadata() {
  47373. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  47374. return {
  47375. info: results[0],
  47376. metadata: results[1] ? new Metadata(results[1]) : null
  47377. };
  47378. });
  47379. },
  47380. getStats: function WorkerTransport_getStats() {
  47381. return this.messageHandler.sendWithPromise('GetStats', null);
  47382. },
  47383. startCleanup: function WorkerTransport_startCleanup() {
  47384. this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() {
  47385. for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
  47386. var page = this.pageCache[i];
  47387. if (page) {
  47388. page.cleanup();
  47389. }
  47390. }
  47391. this.commonObjs.clear();
  47392. this.fontLoader.clear();
  47393. }.bind(this));
  47394. }
  47395. };
  47396. return WorkerTransport;
  47397. }();
  47398. var PDFObjects = function PDFObjectsClosure() {
  47399. function PDFObjects() {
  47400. this.objs = Object.create(null);
  47401. }
  47402. PDFObjects.prototype = {
  47403. ensureObj: function PDFObjects_ensureObj(objId) {
  47404. if (this.objs[objId]) {
  47405. return this.objs[objId];
  47406. }
  47407. var obj = {
  47408. capability: createPromiseCapability(),
  47409. data: null,
  47410. resolved: false
  47411. };
  47412. this.objs[objId] = obj;
  47413. return obj;
  47414. },
  47415. get: function PDFObjects_get(objId, callback) {
  47416. if (callback) {
  47417. this.ensureObj(objId).capability.promise.then(callback);
  47418. return null;
  47419. }
  47420. var obj = this.objs[objId];
  47421. if (!obj || !obj.resolved) {
  47422. error('Requesting object that isn\'t resolved yet ' + objId);
  47423. }
  47424. return obj.data;
  47425. },
  47426. resolve: function PDFObjects_resolve(objId, data) {
  47427. var obj = this.ensureObj(objId);
  47428. obj.resolved = true;
  47429. obj.data = data;
  47430. obj.capability.resolve(data);
  47431. },
  47432. isResolved: function PDFObjects_isResolved(objId) {
  47433. var objs = this.objs;
  47434. if (!objs[objId]) {
  47435. return false;
  47436. } else {
  47437. return objs[objId].resolved;
  47438. }
  47439. },
  47440. hasData: function PDFObjects_hasData(objId) {
  47441. return this.isResolved(objId);
  47442. },
  47443. getData: function PDFObjects_getData(objId) {
  47444. var objs = this.objs;
  47445. if (!objs[objId] || !objs[objId].resolved) {
  47446. return null;
  47447. } else {
  47448. return objs[objId].data;
  47449. }
  47450. },
  47451. clear: function PDFObjects_clear() {
  47452. this.objs = Object.create(null);
  47453. }
  47454. };
  47455. return PDFObjects;
  47456. }();
  47457. var RenderTask = function RenderTaskClosure() {
  47458. function RenderTask(internalRenderTask) {
  47459. this._internalRenderTask = internalRenderTask;
  47460. this.onContinue = null;
  47461. }
  47462. RenderTask.prototype = {
  47463. get promise() {
  47464. return this._internalRenderTask.capability.promise;
  47465. },
  47466. cancel: function RenderTask_cancel() {
  47467. this._internalRenderTask.cancel();
  47468. },
  47469. then: function RenderTask_then(onFulfilled, onRejected) {
  47470. return this.promise.then.apply(this.promise, arguments);
  47471. }
  47472. };
  47473. return RenderTask;
  47474. }();
  47475. var InternalRenderTask = function InternalRenderTaskClosure() {
  47476. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber) {
  47477. this.callback = callback;
  47478. this.params = params;
  47479. this.objs = objs;
  47480. this.commonObjs = commonObjs;
  47481. this.operatorListIdx = null;
  47482. this.operatorList = operatorList;
  47483. this.pageNumber = pageNumber;
  47484. this.running = false;
  47485. this.graphicsReadyCallback = null;
  47486. this.graphicsReady = false;
  47487. this.useRequestAnimationFrame = false;
  47488. this.cancelled = false;
  47489. this.capability = createPromiseCapability();
  47490. this.task = new RenderTask(this);
  47491. this._continueBound = this._continue.bind(this);
  47492. this._scheduleNextBound = this._scheduleNext.bind(this);
  47493. this._nextBound = this._next.bind(this);
  47494. }
  47495. InternalRenderTask.prototype = {
  47496. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  47497. if (this.cancelled) {
  47498. return;
  47499. }
  47500. if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
  47501. this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
  47502. this.stepper.init(this.operatorList);
  47503. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  47504. }
  47505. var params = this.params;
  47506. this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, params.imageLayer);
  47507. this.gfx.beginDrawing(params.transform, params.viewport, transparency);
  47508. this.operatorListIdx = 0;
  47509. this.graphicsReady = true;
  47510. if (this.graphicsReadyCallback) {
  47511. this.graphicsReadyCallback();
  47512. }
  47513. },
  47514. cancel: function InternalRenderTask_cancel() {
  47515. this.running = false;
  47516. this.cancelled = true;
  47517. this.callback('cancelled');
  47518. },
  47519. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  47520. if (!this.graphicsReady) {
  47521. if (!this.graphicsReadyCallback) {
  47522. this.graphicsReadyCallback = this._continueBound;
  47523. }
  47524. return;
  47525. }
  47526. if (this.stepper) {
  47527. this.stepper.updateOperatorList(this.operatorList);
  47528. }
  47529. if (this.running) {
  47530. return;
  47531. }
  47532. this._continue();
  47533. },
  47534. _continue: function InternalRenderTask__continue() {
  47535. this.running = true;
  47536. if (this.cancelled) {
  47537. return;
  47538. }
  47539. if (this.task.onContinue) {
  47540. this.task.onContinue.call(this.task, this._scheduleNextBound);
  47541. } else {
  47542. this._scheduleNext();
  47543. }
  47544. },
  47545. _scheduleNext: function InternalRenderTask__scheduleNext() {
  47546. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  47547. window.requestAnimationFrame(this._nextBound);
  47548. } else {
  47549. Promise.resolve(undefined).then(this._nextBound);
  47550. }
  47551. },
  47552. _next: function InternalRenderTask__next() {
  47553. if (this.cancelled) {
  47554. return;
  47555. }
  47556. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  47557. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  47558. this.running = false;
  47559. if (this.operatorList.lastChunk) {
  47560. this.gfx.endDrawing();
  47561. this.callback();
  47562. }
  47563. }
  47564. }
  47565. };
  47566. return InternalRenderTask;
  47567. }();
  47568. var _UnsupportedManager = function UnsupportedManagerClosure() {
  47569. var listeners = [];
  47570. return {
  47571. listen: function (cb) {
  47572. deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  47573. listeners.push(cb);
  47574. },
  47575. notify: function (featureId) {
  47576. for (var i = 0, ii = listeners.length; i < ii; i++) {
  47577. listeners[i](featureId);
  47578. }
  47579. }
  47580. };
  47581. }();
  47582. if (typeof pdfjsVersion !== 'undefined') {
  47583. exports.version = pdfjsVersion;
  47584. }
  47585. if (typeof pdfjsBuild !== 'undefined') {
  47586. exports.build = pdfjsBuild;
  47587. }
  47588. exports.getDocument = getDocument;
  47589. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  47590. exports.PDFWorker = PDFWorker;
  47591. exports.PDFDocumentProxy = PDFDocumentProxy;
  47592. exports.PDFPageProxy = PDFPageProxy;
  47593. exports._UnsupportedManager = _UnsupportedManager;
  47594. }));
  47595. (function (root, factory) {
  47596. factory(root.pdfjsCoreColorSpace = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction);
  47597. }(this, function (exports, sharedUtil, corePrimitives, coreFunction) {
  47598. var error = sharedUtil.error;
  47599. var info = sharedUtil.info;
  47600. var isArray = sharedUtil.isArray;
  47601. var isString = sharedUtil.isString;
  47602. var shadow = sharedUtil.shadow;
  47603. var warn = sharedUtil.warn;
  47604. var isDict = corePrimitives.isDict;
  47605. var isName = corePrimitives.isName;
  47606. var isStream = corePrimitives.isStream;
  47607. var PDFFunction = coreFunction.PDFFunction;
  47608. var ColorSpace = function ColorSpaceClosure() {
  47609. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  47610. var COMPONENTS = 3;
  47611. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  47612. var xRatio = w1 / w2;
  47613. var yRatio = h1 / h2;
  47614. var i, j, py, newIndex = 0, oldIndex;
  47615. var xScaled = new Uint16Array(w2);
  47616. var w1Scanline = w1 * COMPONENTS;
  47617. for (i = 0; i < w2; i++) {
  47618. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  47619. }
  47620. for (i = 0; i < h2; i++) {
  47621. py = Math.floor(i * yRatio) * w1Scanline;
  47622. for (j = 0; j < w2; j++) {
  47623. oldIndex = py + xScaled[j];
  47624. dest[newIndex++] = src[oldIndex++];
  47625. dest[newIndex++] = src[oldIndex++];
  47626. dest[newIndex++] = src[oldIndex++];
  47627. newIndex += alpha01;
  47628. }
  47629. }
  47630. }
  47631. function ColorSpace() {
  47632. error('should not call ColorSpace constructor');
  47633. }
  47634. ColorSpace.prototype = {
  47635. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  47636. var rgb = new Uint8Array(3);
  47637. this.getRgbItem(src, srcOffset, rgb, 0);
  47638. return rgb;
  47639. },
  47640. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  47641. error('Should not call ColorSpace.getRgbItem');
  47642. },
  47643. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  47644. error('Should not call ColorSpace.getRgbBuffer');
  47645. },
  47646. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  47647. error('Should not call ColorSpace.getOutputLength');
  47648. },
  47649. isPassthrough: function ColorSpace_isPassthrough(bits) {
  47650. return false;
  47651. },
  47652. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  47653. var count = originalWidth * originalHeight;
  47654. var rgbBuf = null;
  47655. var numComponentColors = 1 << bpc;
  47656. var needsResizing = originalHeight !== height || originalWidth !== width;
  47657. var i, ii;
  47658. if (this.isPassthrough(bpc)) {
  47659. rgbBuf = comps;
  47660. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  47661. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  47662. var key;
  47663. for (i = 0; i < numComponentColors; i++) {
  47664. allColors[i] = i;
  47665. }
  47666. var colorMap = new Uint8Array(numComponentColors * 3);
  47667. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  47668. var destPos, rgbPos;
  47669. if (!needsResizing) {
  47670. destPos = 0;
  47671. for (i = 0; i < count; ++i) {
  47672. key = comps[i] * 3;
  47673. dest[destPos++] = colorMap[key];
  47674. dest[destPos++] = colorMap[key + 1];
  47675. dest[destPos++] = colorMap[key + 2];
  47676. destPos += alpha01;
  47677. }
  47678. } else {
  47679. rgbBuf = new Uint8Array(count * 3);
  47680. rgbPos = 0;
  47681. for (i = 0; i < count; ++i) {
  47682. key = comps[i] * 3;
  47683. rgbBuf[rgbPos++] = colorMap[key];
  47684. rgbBuf[rgbPos++] = colorMap[key + 1];
  47685. rgbBuf[rgbPos++] = colorMap[key + 2];
  47686. }
  47687. }
  47688. } else {
  47689. if (!needsResizing) {
  47690. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  47691. } else {
  47692. rgbBuf = new Uint8Array(count * 3);
  47693. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  47694. }
  47695. }
  47696. if (rgbBuf) {
  47697. if (needsResizing) {
  47698. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  47699. } else {
  47700. rgbPos = 0;
  47701. destPos = 0;
  47702. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  47703. dest[destPos++] = rgbBuf[rgbPos++];
  47704. dest[destPos++] = rgbBuf[rgbPos++];
  47705. dest[destPos++] = rgbBuf[rgbPos++];
  47706. destPos += alpha01;
  47707. }
  47708. }
  47709. }
  47710. },
  47711. usesZeroToOneRange: true
  47712. };
  47713. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  47714. var IR = ColorSpace.parseToIR(cs, xref, res);
  47715. if (IR instanceof AlternateCS) {
  47716. return IR;
  47717. }
  47718. return ColorSpace.fromIR(IR);
  47719. };
  47720. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  47721. var name = isArray(IR) ? IR[0] : IR;
  47722. var whitePoint, blackPoint, gamma;
  47723. switch (name) {
  47724. case 'DeviceGrayCS':
  47725. return this.singletons.gray;
  47726. case 'DeviceRgbCS':
  47727. return this.singletons.rgb;
  47728. case 'DeviceCmykCS':
  47729. return this.singletons.cmyk;
  47730. case 'CalGrayCS':
  47731. whitePoint = IR[1];
  47732. blackPoint = IR[2];
  47733. gamma = IR[3];
  47734. return new CalGrayCS(whitePoint, blackPoint, gamma);
  47735. case 'CalRGBCS':
  47736. whitePoint = IR[1];
  47737. blackPoint = IR[2];
  47738. gamma = IR[3];
  47739. var matrix = IR[4];
  47740. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  47741. case 'PatternCS':
  47742. var basePatternCS = IR[1];
  47743. if (basePatternCS) {
  47744. basePatternCS = ColorSpace.fromIR(basePatternCS);
  47745. }
  47746. return new PatternCS(basePatternCS);
  47747. case 'IndexedCS':
  47748. var baseIndexedCS = IR[1];
  47749. var hiVal = IR[2];
  47750. var lookup = IR[3];
  47751. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  47752. case 'AlternateCS':
  47753. var numComps = IR[1];
  47754. var alt = IR[2];
  47755. var tintFnIR = IR[3];
  47756. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  47757. case 'LabCS':
  47758. whitePoint = IR[1];
  47759. blackPoint = IR[2];
  47760. var range = IR[3];
  47761. return new LabCS(whitePoint, blackPoint, range);
  47762. default:
  47763. error('Unknown name ' + name);
  47764. }
  47765. return null;
  47766. };
  47767. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  47768. if (isName(cs)) {
  47769. var colorSpaces = res.get('ColorSpace');
  47770. if (isDict(colorSpaces)) {
  47771. var refcs = colorSpaces.get(cs.name);
  47772. if (refcs) {
  47773. cs = refcs;
  47774. }
  47775. }
  47776. }
  47777. cs = xref.fetchIfRef(cs);
  47778. var mode;
  47779. if (isName(cs)) {
  47780. mode = cs.name;
  47781. this.mode = mode;
  47782. switch (mode) {
  47783. case 'DeviceGray':
  47784. case 'G':
  47785. return 'DeviceGrayCS';
  47786. case 'DeviceRGB':
  47787. case 'RGB':
  47788. return 'DeviceRgbCS';
  47789. case 'DeviceCMYK':
  47790. case 'CMYK':
  47791. return 'DeviceCmykCS';
  47792. case 'Pattern':
  47793. return [
  47794. 'PatternCS',
  47795. null
  47796. ];
  47797. default:
  47798. error('unrecognized colorspace ' + mode);
  47799. }
  47800. } else if (isArray(cs)) {
  47801. mode = xref.fetchIfRef(cs[0]).name;
  47802. this.mode = mode;
  47803. var numComps, params, alt, whitePoint, blackPoint, gamma;
  47804. switch (mode) {
  47805. case 'DeviceGray':
  47806. case 'G':
  47807. return 'DeviceGrayCS';
  47808. case 'DeviceRGB':
  47809. case 'RGB':
  47810. return 'DeviceRgbCS';
  47811. case 'DeviceCMYK':
  47812. case 'CMYK':
  47813. return 'DeviceCmykCS';
  47814. case 'CalGray':
  47815. params = xref.fetchIfRef(cs[1]);
  47816. whitePoint = params.getArray('WhitePoint');
  47817. blackPoint = params.getArray('BlackPoint');
  47818. gamma = params.get('Gamma');
  47819. return [
  47820. 'CalGrayCS',
  47821. whitePoint,
  47822. blackPoint,
  47823. gamma
  47824. ];
  47825. case 'CalRGB':
  47826. params = xref.fetchIfRef(cs[1]);
  47827. whitePoint = params.getArray('WhitePoint');
  47828. blackPoint = params.getArray('BlackPoint');
  47829. gamma = params.getArray('Gamma');
  47830. var matrix = params.getArray('Matrix');
  47831. return [
  47832. 'CalRGBCS',
  47833. whitePoint,
  47834. blackPoint,
  47835. gamma,
  47836. matrix
  47837. ];
  47838. case 'ICCBased':
  47839. var stream = xref.fetchIfRef(cs[1]);
  47840. var dict = stream.dict;
  47841. numComps = dict.get('N');
  47842. alt = dict.get('Alternate');
  47843. if (alt) {
  47844. var altIR = ColorSpace.parseToIR(alt, xref, res);
  47845. var altCS = ColorSpace.fromIR(altIR);
  47846. if (altCS.numComps === numComps) {
  47847. return altIR;
  47848. }
  47849. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  47850. }
  47851. if (numComps === 1) {
  47852. return 'DeviceGrayCS';
  47853. } else if (numComps === 3) {
  47854. return 'DeviceRgbCS';
  47855. } else if (numComps === 4) {
  47856. return 'DeviceCmykCS';
  47857. }
  47858. break;
  47859. case 'Pattern':
  47860. var basePatternCS = cs[1] || null;
  47861. if (basePatternCS) {
  47862. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  47863. }
  47864. return [
  47865. 'PatternCS',
  47866. basePatternCS
  47867. ];
  47868. case 'Indexed':
  47869. case 'I':
  47870. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  47871. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  47872. var lookup = xref.fetchIfRef(cs[3]);
  47873. if (isStream(lookup)) {
  47874. lookup = lookup.getBytes();
  47875. }
  47876. return [
  47877. 'IndexedCS',
  47878. baseIndexedCS,
  47879. hiVal,
  47880. lookup
  47881. ];
  47882. case 'Separation':
  47883. case 'DeviceN':
  47884. var name = xref.fetchIfRef(cs[1]);
  47885. numComps = 1;
  47886. if (isName(name)) {
  47887. numComps = 1;
  47888. } else if (isArray(name)) {
  47889. numComps = name.length;
  47890. }
  47891. alt = ColorSpace.parseToIR(cs[2], xref, res);
  47892. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  47893. return [
  47894. 'AlternateCS',
  47895. numComps,
  47896. alt,
  47897. tintFnIR
  47898. ];
  47899. case 'Lab':
  47900. params = xref.fetchIfRef(cs[1]);
  47901. whitePoint = params.getArray('WhitePoint');
  47902. blackPoint = params.getArray('BlackPoint');
  47903. var range = params.getArray('Range');
  47904. return [
  47905. 'LabCS',
  47906. whitePoint,
  47907. blackPoint,
  47908. range
  47909. ];
  47910. default:
  47911. error('unimplemented color space object "' + mode + '"');
  47912. }
  47913. } else {
  47914. error('unrecognized color space object: "' + cs + '"');
  47915. }
  47916. return null;
  47917. };
  47918. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  47919. if (!isArray(decode)) {
  47920. return true;
  47921. }
  47922. if (n * 2 !== decode.length) {
  47923. warn('The decode map is not the correct length');
  47924. return true;
  47925. }
  47926. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  47927. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  47928. return false;
  47929. }
  47930. }
  47931. return true;
  47932. };
  47933. ColorSpace.singletons = {
  47934. get gray() {
  47935. return shadow(this, 'gray', new DeviceGrayCS());
  47936. },
  47937. get rgb() {
  47938. return shadow(this, 'rgb', new DeviceRgbCS());
  47939. },
  47940. get cmyk() {
  47941. return shadow(this, 'cmyk', new DeviceCmykCS());
  47942. }
  47943. };
  47944. return ColorSpace;
  47945. }();
  47946. var AlternateCS = function AlternateCSClosure() {
  47947. function AlternateCS(numComps, base, tintFn) {
  47948. this.name = 'Alternate';
  47949. this.numComps = numComps;
  47950. this.defaultColor = new Float32Array(numComps);
  47951. for (var i = 0; i < numComps; ++i) {
  47952. this.defaultColor[i] = 1;
  47953. }
  47954. this.base = base;
  47955. this.tintFn = tintFn;
  47956. this.tmpBuf = new Float32Array(base.numComps);
  47957. }
  47958. AlternateCS.prototype = {
  47959. getRgb: ColorSpace.prototype.getRgb,
  47960. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  47961. var tmpBuf = this.tmpBuf;
  47962. this.tintFn(src, srcOffset, tmpBuf, 0);
  47963. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  47964. },
  47965. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  47966. var tintFn = this.tintFn;
  47967. var base = this.base;
  47968. var scale = 1 / ((1 << bits) - 1);
  47969. var baseNumComps = base.numComps;
  47970. var usesZeroToOneRange = base.usesZeroToOneRange;
  47971. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  47972. var pos = isPassthrough ? destOffset : 0;
  47973. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  47974. var numComps = this.numComps;
  47975. var scaled = new Float32Array(numComps);
  47976. var tinted = new Float32Array(baseNumComps);
  47977. var i, j;
  47978. if (usesZeroToOneRange) {
  47979. for (i = 0; i < count; i++) {
  47980. for (j = 0; j < numComps; j++) {
  47981. scaled[j] = src[srcOffset++] * scale;
  47982. }
  47983. tintFn(scaled, 0, tinted, 0);
  47984. for (j = 0; j < baseNumComps; j++) {
  47985. baseBuf[pos++] = tinted[j] * 255;
  47986. }
  47987. }
  47988. } else {
  47989. for (i = 0; i < count; i++) {
  47990. for (j = 0; j < numComps; j++) {
  47991. scaled[j] = src[srcOffset++] * scale;
  47992. }
  47993. tintFn(scaled, 0, tinted, 0);
  47994. base.getRgbItem(tinted, 0, baseBuf, pos);
  47995. pos += baseNumComps;
  47996. }
  47997. }
  47998. if (!isPassthrough) {
  47999. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  48000. }
  48001. },
  48002. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  48003. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  48004. },
  48005. isPassthrough: ColorSpace.prototype.isPassthrough,
  48006. fillRgb: ColorSpace.prototype.fillRgb,
  48007. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  48008. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48009. },
  48010. usesZeroToOneRange: true
  48011. };
  48012. return AlternateCS;
  48013. }();
  48014. var PatternCS = function PatternCSClosure() {
  48015. function PatternCS(baseCS) {
  48016. this.name = 'Pattern';
  48017. this.base = baseCS;
  48018. }
  48019. PatternCS.prototype = {};
  48020. return PatternCS;
  48021. }();
  48022. var IndexedCS = function IndexedCSClosure() {
  48023. function IndexedCS(base, highVal, lookup) {
  48024. this.name = 'Indexed';
  48025. this.numComps = 1;
  48026. this.defaultColor = new Uint8Array([0]);
  48027. this.base = base;
  48028. this.highVal = highVal;
  48029. var baseNumComps = base.numComps;
  48030. var length = baseNumComps * highVal;
  48031. var lookupArray;
  48032. if (isStream(lookup)) {
  48033. lookupArray = new Uint8Array(length);
  48034. var bytes = lookup.getBytes(length);
  48035. lookupArray.set(bytes);
  48036. } else if (isString(lookup)) {
  48037. lookupArray = new Uint8Array(length);
  48038. for (var i = 0; i < length; ++i) {
  48039. lookupArray[i] = lookup.charCodeAt(i);
  48040. }
  48041. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  48042. lookupArray = lookup;
  48043. } else {
  48044. error('Unrecognized lookup table: ' + lookup);
  48045. }
  48046. this.lookup = lookupArray;
  48047. }
  48048. IndexedCS.prototype = {
  48049. getRgb: ColorSpace.prototype.getRgb,
  48050. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48051. var numComps = this.base.numComps;
  48052. var start = src[srcOffset] * numComps;
  48053. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  48054. },
  48055. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48056. var base = this.base;
  48057. var numComps = base.numComps;
  48058. var outputDelta = base.getOutputLength(numComps, alpha01);
  48059. var lookup = this.lookup;
  48060. for (var i = 0; i < count; ++i) {
  48061. var lookupPos = src[srcOffset++] * numComps;
  48062. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  48063. destOffset += outputDelta;
  48064. }
  48065. },
  48066. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  48067. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  48068. },
  48069. isPassthrough: ColorSpace.prototype.isPassthrough,
  48070. fillRgb: ColorSpace.prototype.fillRgb,
  48071. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  48072. return true;
  48073. },
  48074. usesZeroToOneRange: true
  48075. };
  48076. return IndexedCS;
  48077. }();
  48078. var DeviceGrayCS = function DeviceGrayCSClosure() {
  48079. function DeviceGrayCS() {
  48080. this.name = 'DeviceGray';
  48081. this.numComps = 1;
  48082. this.defaultColor = new Float32Array([0]);
  48083. }
  48084. DeviceGrayCS.prototype = {
  48085. getRgb: ColorSpace.prototype.getRgb,
  48086. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48087. var c = src[srcOffset] * 255 | 0;
  48088. c = c < 0 ? 0 : c > 255 ? 255 : c;
  48089. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  48090. },
  48091. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48092. var scale = 255 / ((1 << bits) - 1);
  48093. var j = srcOffset, q = destOffset;
  48094. for (var i = 0; i < count; ++i) {
  48095. var c = scale * src[j++] | 0;
  48096. dest[q++] = c;
  48097. dest[q++] = c;
  48098. dest[q++] = c;
  48099. q += alpha01;
  48100. }
  48101. },
  48102. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  48103. return inputLength * (3 + alpha01);
  48104. },
  48105. isPassthrough: ColorSpace.prototype.isPassthrough,
  48106. fillRgb: ColorSpace.prototype.fillRgb,
  48107. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  48108. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48109. },
  48110. usesZeroToOneRange: true
  48111. };
  48112. return DeviceGrayCS;
  48113. }();
  48114. var DeviceRgbCS = function DeviceRgbCSClosure() {
  48115. function DeviceRgbCS() {
  48116. this.name = 'DeviceRGB';
  48117. this.numComps = 3;
  48118. this.defaultColor = new Float32Array([
  48119. 0,
  48120. 0,
  48121. 0
  48122. ]);
  48123. }
  48124. DeviceRgbCS.prototype = {
  48125. getRgb: ColorSpace.prototype.getRgb,
  48126. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48127. var r = src[srcOffset] * 255 | 0;
  48128. var g = src[srcOffset + 1] * 255 | 0;
  48129. var b = src[srcOffset + 2] * 255 | 0;
  48130. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  48131. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  48132. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  48133. },
  48134. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48135. if (bits === 8 && alpha01 === 0) {
  48136. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  48137. return;
  48138. }
  48139. var scale = 255 / ((1 << bits) - 1);
  48140. var j = srcOffset, q = destOffset;
  48141. for (var i = 0; i < count; ++i) {
  48142. dest[q++] = scale * src[j++] | 0;
  48143. dest[q++] = scale * src[j++] | 0;
  48144. dest[q++] = scale * src[j++] | 0;
  48145. q += alpha01;
  48146. }
  48147. },
  48148. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  48149. return inputLength * (3 + alpha01) / 3 | 0;
  48150. },
  48151. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  48152. return bits === 8;
  48153. },
  48154. fillRgb: ColorSpace.prototype.fillRgb,
  48155. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  48156. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48157. },
  48158. usesZeroToOneRange: true
  48159. };
  48160. return DeviceRgbCS;
  48161. }();
  48162. var DeviceCmykCS = function DeviceCmykCSClosure() {
  48163. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  48164. var c = src[srcOffset + 0] * srcScale;
  48165. var m = src[srcOffset + 1] * srcScale;
  48166. var y = src[srcOffset + 2] * srcScale;
  48167. var k = src[srcOffset + 3] * srcScale;
  48168. 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;
  48169. 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;
  48170. 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;
  48171. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  48172. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  48173. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  48174. }
  48175. function DeviceCmykCS() {
  48176. this.name = 'DeviceCMYK';
  48177. this.numComps = 4;
  48178. this.defaultColor = new Float32Array([
  48179. 0,
  48180. 0,
  48181. 0,
  48182. 1
  48183. ]);
  48184. }
  48185. DeviceCmykCS.prototype = {
  48186. getRgb: ColorSpace.prototype.getRgb,
  48187. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48188. convertToRgb(src, srcOffset, 1, dest, destOffset);
  48189. },
  48190. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48191. var scale = 1 / ((1 << bits) - 1);
  48192. for (var i = 0; i < count; i++) {
  48193. convertToRgb(src, srcOffset, scale, dest, destOffset);
  48194. srcOffset += 4;
  48195. destOffset += 3 + alpha01;
  48196. }
  48197. },
  48198. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  48199. return inputLength / 4 * (3 + alpha01) | 0;
  48200. },
  48201. isPassthrough: ColorSpace.prototype.isPassthrough,
  48202. fillRgb: ColorSpace.prototype.fillRgb,
  48203. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  48204. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48205. },
  48206. usesZeroToOneRange: true
  48207. };
  48208. return DeviceCmykCS;
  48209. }();
  48210. var CalGrayCS = function CalGrayCSClosure() {
  48211. function CalGrayCS(whitePoint, blackPoint, gamma) {
  48212. this.name = 'CalGray';
  48213. this.numComps = 1;
  48214. this.defaultColor = new Float32Array([0]);
  48215. if (!whitePoint) {
  48216. error('WhitePoint missing - required for color space CalGray');
  48217. }
  48218. blackPoint = blackPoint || [
  48219. 0,
  48220. 0,
  48221. 0
  48222. ];
  48223. gamma = gamma || 1;
  48224. this.XW = whitePoint[0];
  48225. this.YW = whitePoint[1];
  48226. this.ZW = whitePoint[2];
  48227. this.XB = blackPoint[0];
  48228. this.YB = blackPoint[1];
  48229. this.ZB = blackPoint[2];
  48230. this.G = gamma;
  48231. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  48232. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  48233. }
  48234. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  48235. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  48236. this.XB = this.YB = this.ZB = 0;
  48237. }
  48238. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  48239. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  48240. }
  48241. if (this.G < 1) {
  48242. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  48243. this.G = 1;
  48244. }
  48245. }
  48246. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  48247. var A = src[srcOffset] * scale;
  48248. var AG = Math.pow(A, cs.G);
  48249. var L = cs.YW * AG;
  48250. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  48251. dest[destOffset] = val;
  48252. dest[destOffset + 1] = val;
  48253. dest[destOffset + 2] = val;
  48254. }
  48255. CalGrayCS.prototype = {
  48256. getRgb: ColorSpace.prototype.getRgb,
  48257. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48258. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  48259. },
  48260. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48261. var scale = 1 / ((1 << bits) - 1);
  48262. for (var i = 0; i < count; ++i) {
  48263. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  48264. srcOffset += 1;
  48265. destOffset += 3 + alpha01;
  48266. }
  48267. },
  48268. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  48269. return inputLength * (3 + alpha01);
  48270. },
  48271. isPassthrough: ColorSpace.prototype.isPassthrough,
  48272. fillRgb: ColorSpace.prototype.fillRgb,
  48273. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  48274. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48275. },
  48276. usesZeroToOneRange: true
  48277. };
  48278. return CalGrayCS;
  48279. }();
  48280. var CalRGBCS = function CalRGBCSClosure() {
  48281. var BRADFORD_SCALE_MATRIX = new Float32Array([
  48282. 0.8951,
  48283. 0.2664,
  48284. -0.1614,
  48285. -0.7502,
  48286. 1.7135,
  48287. 0.0367,
  48288. 0.0389,
  48289. -0.0685,
  48290. 1.0296
  48291. ]);
  48292. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  48293. 0.9869929,
  48294. -0.1470543,
  48295. 0.1599627,
  48296. 0.4323053,
  48297. 0.5183603,
  48298. 0.0492912,
  48299. -0.0085287,
  48300. 0.0400428,
  48301. 0.9684867
  48302. ]);
  48303. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  48304. 3.2404542,
  48305. -1.5371385,
  48306. -0.4985314,
  48307. -0.9692660,
  48308. 1.8760108,
  48309. 0.0415560,
  48310. 0.0556434,
  48311. -0.2040259,
  48312. 1.0572252
  48313. ]);
  48314. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  48315. 1,
  48316. 1,
  48317. 1
  48318. ]);
  48319. var tempNormalizeMatrix = new Float32Array(3);
  48320. var tempConvertMatrix1 = new Float32Array(3);
  48321. var tempConvertMatrix2 = new Float32Array(3);
  48322. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  48323. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  48324. this.name = 'CalRGB';
  48325. this.numComps = 3;
  48326. this.defaultColor = new Float32Array(3);
  48327. if (!whitePoint) {
  48328. error('WhitePoint missing - required for color space CalRGB');
  48329. }
  48330. blackPoint = blackPoint || new Float32Array(3);
  48331. gamma = gamma || new Float32Array([
  48332. 1,
  48333. 1,
  48334. 1
  48335. ]);
  48336. matrix = matrix || new Float32Array([
  48337. 1,
  48338. 0,
  48339. 0,
  48340. 0,
  48341. 1,
  48342. 0,
  48343. 0,
  48344. 0,
  48345. 1
  48346. ]);
  48347. var XW = whitePoint[0];
  48348. var YW = whitePoint[1];
  48349. var ZW = whitePoint[2];
  48350. this.whitePoint = whitePoint;
  48351. var XB = blackPoint[0];
  48352. var YB = blackPoint[1];
  48353. var ZB = blackPoint[2];
  48354. this.blackPoint = blackPoint;
  48355. this.GR = gamma[0];
  48356. this.GG = gamma[1];
  48357. this.GB = gamma[2];
  48358. this.MXA = matrix[0];
  48359. this.MYA = matrix[1];
  48360. this.MZA = matrix[2];
  48361. this.MXB = matrix[3];
  48362. this.MYB = matrix[4];
  48363. this.MZB = matrix[5];
  48364. this.MXC = matrix[6];
  48365. this.MYC = matrix[7];
  48366. this.MZC = matrix[8];
  48367. if (XW < 0 || ZW < 0 || YW !== 1) {
  48368. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  48369. }
  48370. if (XB < 0 || YB < 0 || ZB < 0) {
  48371. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  48372. this.blackPoint = new Float32Array(3);
  48373. }
  48374. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  48375. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  48376. this.GR = this.GG = this.GB = 1;
  48377. }
  48378. 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) {
  48379. 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');
  48380. this.MXA = this.MYB = this.MZC = 1;
  48381. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  48382. }
  48383. }
  48384. function matrixProduct(a, b, result) {
  48385. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  48386. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  48387. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  48388. }
  48389. function convertToFlat(sourceWhitePoint, LMS, result) {
  48390. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  48391. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  48392. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  48393. }
  48394. function convertToD65(sourceWhitePoint, LMS, result) {
  48395. var D65X = 0.95047;
  48396. var D65Y = 1;
  48397. var D65Z = 1.08883;
  48398. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  48399. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  48400. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  48401. }
  48402. function sRGBTransferFunction(color) {
  48403. if (color <= 0.0031308) {
  48404. return adjustToRange(0, 1, 12.92 * color);
  48405. }
  48406. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  48407. }
  48408. function adjustToRange(min, max, value) {
  48409. return Math.max(min, Math.min(max, value));
  48410. }
  48411. function decodeL(L) {
  48412. if (L < 0) {
  48413. return -decodeL(-L);
  48414. }
  48415. if (L > 8.0) {
  48416. return Math.pow((L + 16) / 116, 3);
  48417. }
  48418. return L * DECODE_L_CONSTANT;
  48419. }
  48420. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  48421. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  48422. result[0] = XYZ_Flat[0];
  48423. result[1] = XYZ_Flat[1];
  48424. result[2] = XYZ_Flat[2];
  48425. return;
  48426. }
  48427. var zeroDecodeL = decodeL(0);
  48428. var X_DST = zeroDecodeL;
  48429. var X_SRC = decodeL(sourceBlackPoint[0]);
  48430. var Y_DST = zeroDecodeL;
  48431. var Y_SRC = decodeL(sourceBlackPoint[1]);
  48432. var Z_DST = zeroDecodeL;
  48433. var Z_SRC = decodeL(sourceBlackPoint[2]);
  48434. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  48435. var X_Offset = 1 - X_Scale;
  48436. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  48437. var Y_Offset = 1 - Y_Scale;
  48438. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  48439. var Z_Offset = 1 - Z_Scale;
  48440. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  48441. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  48442. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  48443. }
  48444. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  48445. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  48446. result[0] = XYZ_In[0];
  48447. result[1] = XYZ_In[1];
  48448. result[2] = XYZ_In[2];
  48449. return;
  48450. }
  48451. var LMS = result;
  48452. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  48453. var LMS_Flat = tempNormalizeMatrix;
  48454. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  48455. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  48456. }
  48457. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  48458. var LMS = result;
  48459. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  48460. var LMS_D65 = tempNormalizeMatrix;
  48461. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  48462. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  48463. }
  48464. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  48465. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  48466. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  48467. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  48468. var AGR = Math.pow(A, cs.GR);
  48469. var BGG = Math.pow(B, cs.GG);
  48470. var CGB = Math.pow(C, cs.GB);
  48471. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  48472. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  48473. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  48474. var XYZ = tempConvertMatrix1;
  48475. XYZ[0] = X;
  48476. XYZ[1] = Y;
  48477. XYZ[2] = Z;
  48478. var XYZ_Flat = tempConvertMatrix2;
  48479. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  48480. var XYZ_Black = tempConvertMatrix1;
  48481. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  48482. var XYZ_D65 = tempConvertMatrix2;
  48483. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  48484. var SRGB = tempConvertMatrix1;
  48485. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  48486. var sR = sRGBTransferFunction(SRGB[0]);
  48487. var sG = sRGBTransferFunction(SRGB[1]);
  48488. var sB = sRGBTransferFunction(SRGB[2]);
  48489. dest[destOffset] = Math.round(sR * 255);
  48490. dest[destOffset + 1] = Math.round(sG * 255);
  48491. dest[destOffset + 2] = Math.round(sB * 255);
  48492. }
  48493. CalRGBCS.prototype = {
  48494. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  48495. var rgb = new Uint8Array(3);
  48496. this.getRgbItem(src, srcOffset, rgb, 0);
  48497. return rgb;
  48498. },
  48499. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48500. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  48501. },
  48502. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48503. var scale = 1 / ((1 << bits) - 1);
  48504. for (var i = 0; i < count; ++i) {
  48505. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  48506. srcOffset += 3;
  48507. destOffset += 3 + alpha01;
  48508. }
  48509. },
  48510. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  48511. return inputLength * (3 + alpha01) / 3 | 0;
  48512. },
  48513. isPassthrough: ColorSpace.prototype.isPassthrough,
  48514. fillRgb: ColorSpace.prototype.fillRgb,
  48515. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  48516. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48517. },
  48518. usesZeroToOneRange: true
  48519. };
  48520. return CalRGBCS;
  48521. }();
  48522. var LabCS = function LabCSClosure() {
  48523. function LabCS(whitePoint, blackPoint, range) {
  48524. this.name = 'Lab';
  48525. this.numComps = 3;
  48526. this.defaultColor = new Float32Array([
  48527. 0,
  48528. 0,
  48529. 0
  48530. ]);
  48531. if (!whitePoint) {
  48532. error('WhitePoint missing - required for color space Lab');
  48533. }
  48534. blackPoint = blackPoint || [
  48535. 0,
  48536. 0,
  48537. 0
  48538. ];
  48539. range = range || [
  48540. -100,
  48541. 100,
  48542. -100,
  48543. 100
  48544. ];
  48545. this.XW = whitePoint[0];
  48546. this.YW = whitePoint[1];
  48547. this.ZW = whitePoint[2];
  48548. this.amin = range[0];
  48549. this.amax = range[1];
  48550. this.bmin = range[2];
  48551. this.bmax = range[3];
  48552. this.XB = blackPoint[0];
  48553. this.YB = blackPoint[1];
  48554. this.ZB = blackPoint[2];
  48555. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  48556. error('Invalid WhitePoint components, no fallback available');
  48557. }
  48558. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  48559. info('Invalid BlackPoint, falling back to default');
  48560. this.XB = this.YB = this.ZB = 0;
  48561. }
  48562. if (this.amin > this.amax || this.bmin > this.bmax) {
  48563. info('Invalid Range, falling back to defaults');
  48564. this.amin = -100;
  48565. this.amax = 100;
  48566. this.bmin = -100;
  48567. this.bmax = 100;
  48568. }
  48569. }
  48570. function fn_g(x) {
  48571. if (x >= 6 / 29) {
  48572. return x * x * x;
  48573. } else {
  48574. return 108 / 841 * (x - 4 / 29);
  48575. }
  48576. }
  48577. function decode(value, high1, low2, high2) {
  48578. return low2 + value * (high2 - low2) / high1;
  48579. }
  48580. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  48581. var Ls = src[srcOffset];
  48582. var as = src[srcOffset + 1];
  48583. var bs = src[srcOffset + 2];
  48584. if (maxVal !== false) {
  48585. Ls = decode(Ls, maxVal, 0, 100);
  48586. as = decode(as, maxVal, cs.amin, cs.amax);
  48587. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  48588. }
  48589. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  48590. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  48591. var M = (Ls + 16) / 116;
  48592. var L = M + as / 500;
  48593. var N = M - bs / 200;
  48594. var X = cs.XW * fn_g(L);
  48595. var Y = cs.YW * fn_g(M);
  48596. var Z = cs.ZW * fn_g(N);
  48597. var r, g, b;
  48598. if (cs.ZW < 1) {
  48599. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  48600. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  48601. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  48602. } else {
  48603. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  48604. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  48605. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  48606. }
  48607. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  48608. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  48609. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  48610. }
  48611. LabCS.prototype = {
  48612. getRgb: ColorSpace.prototype.getRgb,
  48613. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48614. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  48615. },
  48616. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48617. var maxVal = (1 << bits) - 1;
  48618. for (var i = 0; i < count; i++) {
  48619. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  48620. srcOffset += 3;
  48621. destOffset += 3 + alpha01;
  48622. }
  48623. },
  48624. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  48625. return inputLength * (3 + alpha01) / 3 | 0;
  48626. },
  48627. isPassthrough: ColorSpace.prototype.isPassthrough,
  48628. fillRgb: ColorSpace.prototype.fillRgb,
  48629. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  48630. return true;
  48631. },
  48632. usesZeroToOneRange: false
  48633. };
  48634. return LabCS;
  48635. }();
  48636. exports.ColorSpace = ColorSpace;
  48637. }));
  48638. (function (root, factory) {
  48639. factory(root.pdfjsDisplayGlobal = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils, root.pdfjsDisplayAPI, root.pdfjsDisplayAnnotationLayer, root.pdfjsDisplayTextLayer, root.pdfjsDisplayMetadata, root.pdfjsDisplaySVG);
  48640. }(this, function (exports, sharedUtil, displayDOMUtils, displayAPI, displayAnnotationLayer, displayTextLayer, displayMetadata, displaySVG) {
  48641. var globalScope = sharedUtil.globalScope;
  48642. var deprecated = sharedUtil.deprecated;
  48643. var warn = sharedUtil.warn;
  48644. var LinkTarget = displayDOMUtils.LinkTarget;
  48645. var isWorker = typeof window === 'undefined';
  48646. if (!globalScope.PDFJS) {
  48647. globalScope.PDFJS = {};
  48648. }
  48649. var PDFJS = globalScope.PDFJS;
  48650. if (typeof pdfjsVersion !== 'undefined') {
  48651. PDFJS.version = pdfjsVersion;
  48652. }
  48653. if (typeof pdfjsBuild !== 'undefined') {
  48654. PDFJS.build = pdfjsBuild;
  48655. }
  48656. PDFJS.pdfBug = false;
  48657. if (PDFJS.verbosity !== undefined) {
  48658. sharedUtil.setVerbosityLevel(PDFJS.verbosity);
  48659. }
  48660. delete PDFJS.verbosity;
  48661. Object.defineProperty(PDFJS, 'verbosity', {
  48662. get: function () {
  48663. return sharedUtil.getVerbosityLevel();
  48664. },
  48665. set: function (level) {
  48666. sharedUtil.setVerbosityLevel(level);
  48667. },
  48668. enumerable: true,
  48669. configurable: true
  48670. });
  48671. PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
  48672. PDFJS.OPS = sharedUtil.OPS;
  48673. PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  48674. PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
  48675. PDFJS.shadow = sharedUtil.shadow;
  48676. PDFJS.createBlob = sharedUtil.createBlob;
  48677. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  48678. return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
  48679. };
  48680. Object.defineProperty(PDFJS, 'isLittleEndian', {
  48681. configurable: true,
  48682. get: function PDFJS_isLittleEndian() {
  48683. var value = sharedUtil.isLittleEndian();
  48684. return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
  48685. }
  48686. });
  48687. PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
  48688. PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
  48689. PDFJS.PasswordException = sharedUtil.PasswordException;
  48690. PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
  48691. PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
  48692. PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
  48693. PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  48694. PDFJS.Util = sharedUtil.Util;
  48695. PDFJS.PageViewport = sharedUtil.PageViewport;
  48696. PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
  48697. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  48698. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  48699. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  48700. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  48701. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  48702. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  48703. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  48704. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  48705. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  48706. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  48707. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  48708. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  48709. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  48710. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  48711. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
  48712. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? 'noreferrer' : PDFJS.externalLinkRel;
  48713. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  48714. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  48715. delete PDFJS.openExternalLinksInNewWindow;
  48716. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  48717. get: function () {
  48718. return PDFJS.externalLinkTarget === LinkTarget.BLANK;
  48719. },
  48720. set: function (value) {
  48721. if (value) {
  48722. deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  48723. }
  48724. if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
  48725. warn('PDFJS.externalLinkTarget is already initialized');
  48726. return;
  48727. }
  48728. PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
  48729. },
  48730. enumerable: true,
  48731. configurable: true
  48732. });
  48733. if (savedOpenExternalLinksInNewWindow) {
  48734. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  48735. }
  48736. PDFJS.getDocument = displayAPI.getDocument;
  48737. PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
  48738. PDFJS.PDFWorker = displayAPI.PDFWorker;
  48739. Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
  48740. configurable: true,
  48741. get: function PDFJS_hasCanvasTypedArrays() {
  48742. var value = displayDOMUtils.hasCanvasTypedArrays();
  48743. return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
  48744. }
  48745. });
  48746. PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
  48747. PDFJS.LinkTarget = LinkTarget;
  48748. PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
  48749. PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  48750. PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
  48751. PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
  48752. PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
  48753. PDFJS.Metadata = displayMetadata.Metadata;
  48754. PDFJS.SVGGraphics = displaySVG.SVGGraphics;
  48755. PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
  48756. exports.globalScope = globalScope;
  48757. exports.isWorker = isWorker;
  48758. exports.PDFJS = globalScope.PDFJS;
  48759. }));
  48760. (function (root, factory) {
  48761. factory(root.pdfjsCoreImage = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreColorSpace, root.pdfjsCoreStream, root.pdfjsCoreJpx);
  48762. }(this, function (exports, sharedUtil, corePrimitives, coreColorSpace, coreStream, coreJpx) {
  48763. var ImageKind = sharedUtil.ImageKind;
  48764. var assert = sharedUtil.assert;
  48765. var error = sharedUtil.error;
  48766. var info = sharedUtil.info;
  48767. var isArray = sharedUtil.isArray;
  48768. var warn = sharedUtil.warn;
  48769. var Name = corePrimitives.Name;
  48770. var isStream = corePrimitives.isStream;
  48771. var ColorSpace = coreColorSpace.ColorSpace;
  48772. var DecodeStream = coreStream.DecodeStream;
  48773. var JpegStream = coreStream.JpegStream;
  48774. var JpxImage = coreJpx.JpxImage;
  48775. var PDFImage = function PDFImageClosure() {
  48776. function handleImageData(image, nativeDecoder) {
  48777. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  48778. return nativeDecoder.decode(image);
  48779. } else {
  48780. return Promise.resolve(image);
  48781. }
  48782. }
  48783. function decodeAndClamp(value, addend, coefficient, max) {
  48784. value = addend + value * coefficient;
  48785. return value < 0 ? 0 : value > max ? max : value;
  48786. }
  48787. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  48788. var length = w2 * h2;
  48789. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  48790. var xRatio = w1 / w2;
  48791. var yRatio = h1 / h2;
  48792. var i, j, py, newIndex = 0, oldIndex;
  48793. var xScaled = new Uint16Array(w2);
  48794. var w1Scanline = w1;
  48795. for (i = 0; i < w2; i++) {
  48796. xScaled[i] = Math.floor(i * xRatio);
  48797. }
  48798. for (i = 0; i < h2; i++) {
  48799. py = Math.floor(i * yRatio) * w1Scanline;
  48800. for (j = 0; j < w2; j++) {
  48801. oldIndex = py + xScaled[j];
  48802. dest[newIndex++] = src[oldIndex];
  48803. }
  48804. }
  48805. return dest;
  48806. }
  48807. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  48808. this.image = image;
  48809. var dict = image.dict;
  48810. if (dict.has('Filter')) {
  48811. var filter = dict.get('Filter').name;
  48812. if (filter === 'JPXDecode') {
  48813. var jpxImage = new JpxImage();
  48814. jpxImage.parseImageProperties(image.stream);
  48815. image.stream.reset();
  48816. image.bitsPerComponent = jpxImage.bitsPerComponent;
  48817. image.numComps = jpxImage.componentsCount;
  48818. } else if (filter === 'JBIG2Decode') {
  48819. image.bitsPerComponent = 1;
  48820. image.numComps = 1;
  48821. }
  48822. }
  48823. this.width = dict.get('Width', 'W');
  48824. this.height = dict.get('Height', 'H');
  48825. if (this.width < 1 || this.height < 1) {
  48826. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  48827. }
  48828. this.interpolate = dict.get('Interpolate', 'I') || false;
  48829. this.imageMask = dict.get('ImageMask', 'IM') || false;
  48830. this.matte = dict.get('Matte') || false;
  48831. var bitsPerComponent = image.bitsPerComponent;
  48832. if (!bitsPerComponent) {
  48833. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  48834. if (!bitsPerComponent) {
  48835. if (this.imageMask) {
  48836. bitsPerComponent = 1;
  48837. } else {
  48838. error('Bits per component missing in image: ' + this.imageMask);
  48839. }
  48840. }
  48841. }
  48842. this.bpc = bitsPerComponent;
  48843. if (!this.imageMask) {
  48844. var colorSpace = dict.get('ColorSpace', 'CS');
  48845. if (!colorSpace) {
  48846. info('JPX images (which do not require color spaces)');
  48847. switch (image.numComps) {
  48848. case 1:
  48849. colorSpace = Name.get('DeviceGray');
  48850. break;
  48851. case 3:
  48852. colorSpace = Name.get('DeviceRGB');
  48853. break;
  48854. case 4:
  48855. colorSpace = Name.get('DeviceCMYK');
  48856. break;
  48857. default:
  48858. error('JPX images with ' + this.numComps + ' color components not supported.');
  48859. }
  48860. }
  48861. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  48862. this.numComps = this.colorSpace.numComps;
  48863. }
  48864. this.decode = dict.getArray('Decode', 'D');
  48865. this.needsDecode = false;
  48866. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  48867. this.needsDecode = true;
  48868. var max = (1 << bitsPerComponent) - 1;
  48869. this.decodeCoefficients = [];
  48870. this.decodeAddends = [];
  48871. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  48872. var dmin = this.decode[i];
  48873. var dmax = this.decode[i + 1];
  48874. this.decodeCoefficients[j] = dmax - dmin;
  48875. this.decodeAddends[j] = max * dmin;
  48876. }
  48877. }
  48878. if (smask) {
  48879. this.smask = new PDFImage(xref, res, smask, false);
  48880. } else if (mask) {
  48881. if (isStream(mask)) {
  48882. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  48883. if (!imageMask) {
  48884. warn('Ignoring /Mask in image without /ImageMask.');
  48885. } else {
  48886. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  48887. }
  48888. } else {
  48889. this.mask = mask;
  48890. }
  48891. }
  48892. }
  48893. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  48894. var imagePromise = handleImageData(image, nativeDecoder);
  48895. var smaskPromise;
  48896. var maskPromise;
  48897. var smask = image.dict.get('SMask');
  48898. var mask = image.dict.get('Mask');
  48899. if (smask) {
  48900. smaskPromise = handleImageData(smask, nativeDecoder);
  48901. maskPromise = Promise.resolve(null);
  48902. } else {
  48903. smaskPromise = Promise.resolve(null);
  48904. if (mask) {
  48905. if (isStream(mask)) {
  48906. maskPromise = handleImageData(mask, nativeDecoder);
  48907. } else if (isArray(mask)) {
  48908. maskPromise = Promise.resolve(mask);
  48909. } else {
  48910. warn('Unsupported mask format.');
  48911. maskPromise = Promise.resolve(null);
  48912. }
  48913. } else {
  48914. maskPromise = Promise.resolve(null);
  48915. }
  48916. }
  48917. return Promise.all([
  48918. imagePromise,
  48919. smaskPromise,
  48920. maskPromise
  48921. ]).then(function (results) {
  48922. var imageData = results[0];
  48923. var smaskData = results[1];
  48924. var maskData = results[2];
  48925. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  48926. });
  48927. };
  48928. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  48929. var computedLength = (width + 7 >> 3) * height;
  48930. var actualLength = imgArray.byteLength;
  48931. var haveFullData = computedLength === actualLength;
  48932. var data, i;
  48933. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  48934. data = imgArray;
  48935. } else if (!inverseDecode) {
  48936. data = new Uint8Array(actualLength);
  48937. data.set(imgArray);
  48938. } else {
  48939. data = new Uint8Array(computedLength);
  48940. data.set(imgArray);
  48941. for (i = actualLength; i < computedLength; i++) {
  48942. data[i] = 0xff;
  48943. }
  48944. }
  48945. if (inverseDecode) {
  48946. for (i = 0; i < actualLength; i++) {
  48947. data[i] = ~data[i];
  48948. }
  48949. }
  48950. return {
  48951. data: data,
  48952. width: width,
  48953. height: height
  48954. };
  48955. };
  48956. PDFImage.prototype = {
  48957. get drawWidth() {
  48958. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  48959. },
  48960. get drawHeight() {
  48961. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  48962. },
  48963. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  48964. var bpc = this.bpc;
  48965. var numComps = this.numComps;
  48966. var decodeAddends = this.decodeAddends;
  48967. var decodeCoefficients = this.decodeCoefficients;
  48968. var max = (1 << bpc) - 1;
  48969. var i, ii;
  48970. if (bpc === 1) {
  48971. for (i = 0, ii = buffer.length; i < ii; i++) {
  48972. buffer[i] = +!buffer[i];
  48973. }
  48974. return;
  48975. }
  48976. var index = 0;
  48977. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  48978. for (var j = 0; j < numComps; j++) {
  48979. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  48980. index++;
  48981. }
  48982. }
  48983. },
  48984. getComponents: function PDFImage_getComponents(buffer) {
  48985. var bpc = this.bpc;
  48986. if (bpc === 8) {
  48987. return buffer;
  48988. }
  48989. var width = this.width;
  48990. var height = this.height;
  48991. var numComps = this.numComps;
  48992. var length = width * height * numComps;
  48993. var bufferPos = 0;
  48994. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  48995. var rowComps = width * numComps;
  48996. var max = (1 << bpc) - 1;
  48997. var i = 0, ii, buf;
  48998. if (bpc === 1) {
  48999. var mask, loop1End, loop2End;
  49000. for (var j = 0; j < height; j++) {
  49001. loop1End = i + (rowComps & ~7);
  49002. loop2End = i + rowComps;
  49003. while (i < loop1End) {
  49004. buf = buffer[bufferPos++];
  49005. output[i] = buf >> 7 & 1;
  49006. output[i + 1] = buf >> 6 & 1;
  49007. output[i + 2] = buf >> 5 & 1;
  49008. output[i + 3] = buf >> 4 & 1;
  49009. output[i + 4] = buf >> 3 & 1;
  49010. output[i + 5] = buf >> 2 & 1;
  49011. output[i + 6] = buf >> 1 & 1;
  49012. output[i + 7] = buf & 1;
  49013. i += 8;
  49014. }
  49015. if (i < loop2End) {
  49016. buf = buffer[bufferPos++];
  49017. mask = 128;
  49018. while (i < loop2End) {
  49019. output[i++] = +!!(buf & mask);
  49020. mask >>= 1;
  49021. }
  49022. }
  49023. }
  49024. } else {
  49025. var bits = 0;
  49026. buf = 0;
  49027. for (i = 0, ii = length; i < ii; ++i) {
  49028. if (i % rowComps === 0) {
  49029. buf = 0;
  49030. bits = 0;
  49031. }
  49032. while (bits < bpc) {
  49033. buf = buf << 8 | buffer[bufferPos++];
  49034. bits += 8;
  49035. }
  49036. var remainingBits = bits - bpc;
  49037. var value = buf >> remainingBits;
  49038. output[i] = value < 0 ? 0 : value > max ? max : value;
  49039. buf = buf & (1 << remainingBits) - 1;
  49040. bits = remainingBits;
  49041. }
  49042. }
  49043. return output;
  49044. },
  49045. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  49046. var smask = this.smask;
  49047. var mask = this.mask;
  49048. var alphaBuf, sw, sh, i, ii, j;
  49049. if (smask) {
  49050. sw = smask.width;
  49051. sh = smask.height;
  49052. alphaBuf = new Uint8Array(sw * sh);
  49053. smask.fillGrayBuffer(alphaBuf);
  49054. if (sw !== width || sh !== height) {
  49055. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  49056. }
  49057. } else if (mask) {
  49058. if (mask instanceof PDFImage) {
  49059. sw = mask.width;
  49060. sh = mask.height;
  49061. alphaBuf = new Uint8Array(sw * sh);
  49062. mask.numComps = 1;
  49063. mask.fillGrayBuffer(alphaBuf);
  49064. for (i = 0, ii = sw * sh; i < ii; ++i) {
  49065. alphaBuf[i] = 255 - alphaBuf[i];
  49066. }
  49067. if (sw !== width || sh !== height) {
  49068. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  49069. }
  49070. } else if (isArray(mask)) {
  49071. alphaBuf = new Uint8Array(width * height);
  49072. var numComps = this.numComps;
  49073. for (i = 0, ii = width * height; i < ii; ++i) {
  49074. var opacity = 0;
  49075. var imageOffset = i * numComps;
  49076. for (j = 0; j < numComps; ++j) {
  49077. var color = image[imageOffset + j];
  49078. var maskOffset = j * 2;
  49079. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  49080. opacity = 255;
  49081. break;
  49082. }
  49083. }
  49084. alphaBuf[i] = opacity;
  49085. }
  49086. } else {
  49087. error('Unknown mask format.');
  49088. }
  49089. }
  49090. if (alphaBuf) {
  49091. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  49092. rgbaBuf[j] = alphaBuf[i];
  49093. }
  49094. } else {
  49095. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  49096. rgbaBuf[j] = 255;
  49097. }
  49098. }
  49099. },
  49100. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  49101. var matte = this.smask && this.smask.matte;
  49102. if (!matte) {
  49103. return;
  49104. }
  49105. var matteRgb = this.colorSpace.getRgb(matte, 0);
  49106. var matteR = matteRgb[0];
  49107. var matteG = matteRgb[1];
  49108. var matteB = matteRgb[2];
  49109. var length = width * height * 4;
  49110. var r, g, b;
  49111. for (var i = 0; i < length; i += 4) {
  49112. var alpha = buffer[i + 3];
  49113. if (alpha === 0) {
  49114. buffer[i] = 255;
  49115. buffer[i + 1] = 255;
  49116. buffer[i + 2] = 255;
  49117. continue;
  49118. }
  49119. var k = 255 / alpha;
  49120. r = (buffer[i] - matteR) * k + matteR;
  49121. g = (buffer[i + 1] - matteG) * k + matteG;
  49122. b = (buffer[i + 2] - matteB) * k + matteB;
  49123. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  49124. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  49125. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  49126. }
  49127. },
  49128. createImageData: function PDFImage_createImageData(forceRGBA) {
  49129. var drawWidth = this.drawWidth;
  49130. var drawHeight = this.drawHeight;
  49131. var imgData = {
  49132. width: drawWidth,
  49133. height: drawHeight
  49134. };
  49135. var numComps = this.numComps;
  49136. var originalWidth = this.width;
  49137. var originalHeight = this.height;
  49138. var bpc = this.bpc;
  49139. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  49140. var imgArray;
  49141. if (!forceRGBA) {
  49142. var kind;
  49143. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  49144. kind = ImageKind.GRAYSCALE_1BPP;
  49145. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  49146. kind = ImageKind.RGB_24BPP;
  49147. }
  49148. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  49149. imgData.kind = kind;
  49150. imgArray = this.getImageBytes(originalHeight * rowBytes);
  49151. if (this.image instanceof DecodeStream) {
  49152. imgData.data = imgArray;
  49153. } else {
  49154. var newArray = new Uint8Array(imgArray.length);
  49155. newArray.set(imgArray);
  49156. imgData.data = newArray;
  49157. }
  49158. if (this.needsDecode) {
  49159. assert(kind === ImageKind.GRAYSCALE_1BPP);
  49160. var buffer = imgData.data;
  49161. for (var i = 0, ii = buffer.length; i < ii; i++) {
  49162. buffer[i] ^= 0xff;
  49163. }
  49164. }
  49165. return imgData;
  49166. }
  49167. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  49168. imgData.kind = ImageKind.RGB_24BPP;
  49169. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  49170. return imgData;
  49171. }
  49172. }
  49173. imgArray = this.getImageBytes(originalHeight * rowBytes);
  49174. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  49175. var comps = this.getComponents(imgArray);
  49176. var alpha01, maybeUndoPreblend;
  49177. if (!forceRGBA && !this.smask && !this.mask) {
  49178. imgData.kind = ImageKind.RGB_24BPP;
  49179. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  49180. alpha01 = 0;
  49181. maybeUndoPreblend = false;
  49182. } else {
  49183. imgData.kind = ImageKind.RGBA_32BPP;
  49184. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  49185. alpha01 = 1;
  49186. maybeUndoPreblend = true;
  49187. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  49188. }
  49189. if (this.needsDecode) {
  49190. this.decodeBuffer(comps);
  49191. }
  49192. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  49193. if (maybeUndoPreblend) {
  49194. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  49195. }
  49196. return imgData;
  49197. },
  49198. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  49199. var numComps = this.numComps;
  49200. if (numComps !== 1) {
  49201. error('Reading gray scale from a color image: ' + numComps);
  49202. }
  49203. var width = this.width;
  49204. var height = this.height;
  49205. var bpc = this.bpc;
  49206. var rowBytes = width * numComps * bpc + 7 >> 3;
  49207. var imgArray = this.getImageBytes(height * rowBytes);
  49208. var comps = this.getComponents(imgArray);
  49209. var i, length;
  49210. if (bpc === 1) {
  49211. length = width * height;
  49212. if (this.needsDecode) {
  49213. for (i = 0; i < length; ++i) {
  49214. buffer[i] = comps[i] - 1 & 255;
  49215. }
  49216. } else {
  49217. for (i = 0; i < length; ++i) {
  49218. buffer[i] = -comps[i] & 255;
  49219. }
  49220. }
  49221. return;
  49222. }
  49223. if (this.needsDecode) {
  49224. this.decodeBuffer(comps);
  49225. }
  49226. length = width * height;
  49227. var scale = 255 / ((1 << bpc) - 1);
  49228. for (i = 0; i < length; ++i) {
  49229. buffer[i] = scale * comps[i] | 0;
  49230. }
  49231. },
  49232. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  49233. this.image.reset();
  49234. this.image.drawWidth = drawWidth || this.width;
  49235. this.image.drawHeight = drawHeight || this.height;
  49236. this.image.forceRGB = !!forceRGB;
  49237. return this.image.getBytes(length);
  49238. }
  49239. };
  49240. return PDFImage;
  49241. }();
  49242. exports.PDFImage = PDFImage;
  49243. }));
  49244. (function (root, factory) {
  49245. factory(root.pdfjsCoreObj = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreCrypto, root.pdfjsCoreParser, root.pdfjsCoreChunkedStream, root.pdfjsCoreColorSpace);
  49246. }(this, function (exports, sharedUtil, corePrimitives, coreCrypto, coreParser, coreChunkedStream, coreColorSpace) {
  49247. var InvalidPDFException = sharedUtil.InvalidPDFException;
  49248. var MissingDataException = sharedUtil.MissingDataException;
  49249. var XRefParseException = sharedUtil.XRefParseException;
  49250. var assert = sharedUtil.assert;
  49251. var bytesToString = sharedUtil.bytesToString;
  49252. var createPromiseCapability = sharedUtil.createPromiseCapability;
  49253. var error = sharedUtil.error;
  49254. var info = sharedUtil.info;
  49255. var isArray = sharedUtil.isArray;
  49256. var isBool = sharedUtil.isBool;
  49257. var isInt = sharedUtil.isInt;
  49258. var isString = sharedUtil.isString;
  49259. var shadow = sharedUtil.shadow;
  49260. var stringToPDFString = sharedUtil.stringToPDFString;
  49261. var stringToUTF8String = sharedUtil.stringToUTF8String;
  49262. var warn = sharedUtil.warn;
  49263. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  49264. var Util = sharedUtil.Util;
  49265. var Ref = corePrimitives.Ref;
  49266. var RefSet = corePrimitives.RefSet;
  49267. var RefSetCache = corePrimitives.RefSetCache;
  49268. var isName = corePrimitives.isName;
  49269. var isCmd = corePrimitives.isCmd;
  49270. var isDict = corePrimitives.isDict;
  49271. var isRef = corePrimitives.isRef;
  49272. var isRefsEqual = corePrimitives.isRefsEqual;
  49273. var isStream = corePrimitives.isStream;
  49274. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  49275. var Lexer = coreParser.Lexer;
  49276. var Parser = coreParser.Parser;
  49277. var ChunkedStream = coreChunkedStream.ChunkedStream;
  49278. var ColorSpace = coreColorSpace.ColorSpace;
  49279. var Catalog = function CatalogClosure() {
  49280. function Catalog(pdfManager, xref, pageFactory) {
  49281. this.pdfManager = pdfManager;
  49282. this.xref = xref;
  49283. this.catDict = xref.getCatalogObj();
  49284. this.fontCache = new RefSetCache();
  49285. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  49286. this.pageFactory = pageFactory;
  49287. this.pagePromises = [];
  49288. }
  49289. Catalog.prototype = {
  49290. get metadata() {
  49291. var streamRef = this.catDict.getRaw('Metadata');
  49292. if (!isRef(streamRef)) {
  49293. return shadow(this, 'metadata', null);
  49294. }
  49295. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  49296. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  49297. var metadata;
  49298. if (stream && isDict(stream.dict)) {
  49299. var type = stream.dict.get('Type');
  49300. var subtype = stream.dict.get('Subtype');
  49301. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  49302. try {
  49303. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  49304. } catch (e) {
  49305. info('Skipping invalid metadata.');
  49306. }
  49307. }
  49308. }
  49309. return shadow(this, 'metadata', metadata);
  49310. },
  49311. get toplevelPagesDict() {
  49312. var pagesObj = this.catDict.get('Pages');
  49313. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  49314. return shadow(this, 'toplevelPagesDict', pagesObj);
  49315. },
  49316. get documentOutline() {
  49317. var obj = null;
  49318. try {
  49319. obj = this.readDocumentOutline();
  49320. } catch (ex) {
  49321. if (ex instanceof MissingDataException) {
  49322. throw ex;
  49323. }
  49324. warn('Unable to read document outline');
  49325. }
  49326. return shadow(this, 'documentOutline', obj);
  49327. },
  49328. readDocumentOutline: function Catalog_readDocumentOutline() {
  49329. var obj = this.catDict.get('Outlines');
  49330. if (!isDict(obj)) {
  49331. return null;
  49332. }
  49333. obj = obj.getRaw('First');
  49334. if (!isRef(obj)) {
  49335. return null;
  49336. }
  49337. var root = { items: [] };
  49338. var queue = [{
  49339. obj: obj,
  49340. parent: root
  49341. }];
  49342. var processed = new RefSet();
  49343. processed.put(obj);
  49344. var xref = this.xref, blackColor = new Uint8Array(3);
  49345. while (queue.length > 0) {
  49346. var i = queue.shift();
  49347. var outlineDict = xref.fetchIfRef(i.obj);
  49348. if (outlineDict === null) {
  49349. continue;
  49350. }
  49351. assert(outlineDict.has('Title'), 'Invalid outline item');
  49352. var data = {
  49353. url: null,
  49354. dest: null
  49355. };
  49356. Catalog.parseDestDictionary({
  49357. destDict: outlineDict,
  49358. resultObj: data,
  49359. docBaseUrl: this.pdfManager.docBaseUrl
  49360. });
  49361. var title = outlineDict.get('Title');
  49362. var flags = outlineDict.get('F') || 0;
  49363. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  49364. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  49365. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  49366. }
  49367. var outlineItem = {
  49368. dest: data.dest,
  49369. url: data.url,
  49370. unsafeUrl: data.unsafeUrl,
  49371. newWindow: data.newWindow,
  49372. title: stringToPDFString(title),
  49373. color: rgbColor,
  49374. count: outlineDict.get('Count'),
  49375. bold: !!(flags & 2),
  49376. italic: !!(flags & 1),
  49377. items: []
  49378. };
  49379. i.parent.items.push(outlineItem);
  49380. obj = outlineDict.getRaw('First');
  49381. if (isRef(obj) && !processed.has(obj)) {
  49382. queue.push({
  49383. obj: obj,
  49384. parent: outlineItem
  49385. });
  49386. processed.put(obj);
  49387. }
  49388. obj = outlineDict.getRaw('Next');
  49389. if (isRef(obj) && !processed.has(obj)) {
  49390. queue.push({
  49391. obj: obj,
  49392. parent: i.parent
  49393. });
  49394. processed.put(obj);
  49395. }
  49396. }
  49397. return root.items.length > 0 ? root.items : null;
  49398. },
  49399. get numPages() {
  49400. var obj = this.toplevelPagesDict.get('Count');
  49401. assert(isInt(obj), 'page count in top level pages object is not an integer');
  49402. return shadow(this, 'num', obj);
  49403. },
  49404. get destinations() {
  49405. function fetchDestination(dest) {
  49406. return isDict(dest) ? dest.get('D') : dest;
  49407. }
  49408. var xref = this.xref;
  49409. var dests = {}, nameTreeRef, nameDictionaryRef;
  49410. var obj = this.catDict.get('Names');
  49411. if (obj && obj.has('Dests')) {
  49412. nameTreeRef = obj.getRaw('Dests');
  49413. } else if (this.catDict.has('Dests')) {
  49414. nameDictionaryRef = this.catDict.get('Dests');
  49415. }
  49416. if (nameDictionaryRef) {
  49417. obj = nameDictionaryRef;
  49418. obj.forEach(function catalogForEach(key, value) {
  49419. if (!value) {
  49420. return;
  49421. }
  49422. dests[key] = fetchDestination(value);
  49423. });
  49424. }
  49425. if (nameTreeRef) {
  49426. var nameTree = new NameTree(nameTreeRef, xref);
  49427. var names = nameTree.getAll();
  49428. for (var name in names) {
  49429. dests[name] = fetchDestination(names[name]);
  49430. }
  49431. }
  49432. return shadow(this, 'destinations', dests);
  49433. },
  49434. getDestination: function Catalog_getDestination(destinationId) {
  49435. function fetchDestination(dest) {
  49436. return isDict(dest) ? dest.get('D') : dest;
  49437. }
  49438. var xref = this.xref;
  49439. var dest = null, nameTreeRef, nameDictionaryRef;
  49440. var obj = this.catDict.get('Names');
  49441. if (obj && obj.has('Dests')) {
  49442. nameTreeRef = obj.getRaw('Dests');
  49443. } else if (this.catDict.has('Dests')) {
  49444. nameDictionaryRef = this.catDict.get('Dests');
  49445. }
  49446. if (nameDictionaryRef) {
  49447. var value = nameDictionaryRef.get(destinationId);
  49448. if (value) {
  49449. dest = fetchDestination(value);
  49450. }
  49451. }
  49452. if (nameTreeRef) {
  49453. var nameTree = new NameTree(nameTreeRef, xref);
  49454. dest = fetchDestination(nameTree.get(destinationId));
  49455. }
  49456. return dest;
  49457. },
  49458. get pageLabels() {
  49459. var obj = null;
  49460. try {
  49461. obj = this.readPageLabels();
  49462. } catch (ex) {
  49463. if (ex instanceof MissingDataException) {
  49464. throw ex;
  49465. }
  49466. warn('Unable to read page labels.');
  49467. }
  49468. return shadow(this, 'pageLabels', obj);
  49469. },
  49470. readPageLabels: function Catalog_readPageLabels() {
  49471. var obj = this.catDict.getRaw('PageLabels');
  49472. if (!obj) {
  49473. return null;
  49474. }
  49475. var pageLabels = new Array(this.numPages);
  49476. var style = null;
  49477. var prefix = '';
  49478. var numberTree = new NumberTree(obj, this.xref);
  49479. var nums = numberTree.getAll();
  49480. var currentLabel = '', currentIndex = 1;
  49481. for (var i = 0, ii = this.numPages; i < ii; i++) {
  49482. if (i in nums) {
  49483. var labelDict = nums[i];
  49484. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  49485. var type = labelDict.get('Type');
  49486. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  49487. var s = labelDict.get('S');
  49488. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  49489. style = s ? s.name : null;
  49490. var p = labelDict.get('P');
  49491. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  49492. prefix = p ? stringToPDFString(p) : '';
  49493. var st = labelDict.get('St');
  49494. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  49495. currentIndex = st || 1;
  49496. }
  49497. switch (style) {
  49498. case 'D':
  49499. currentLabel = currentIndex;
  49500. break;
  49501. case 'R':
  49502. case 'r':
  49503. currentLabel = Util.toRoman(currentIndex, style === 'r');
  49504. break;
  49505. case 'A':
  49506. case 'a':
  49507. var LIMIT = 26;
  49508. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  49509. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  49510. var letterIndex = currentIndex - 1;
  49511. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  49512. var charBuf = [];
  49513. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  49514. charBuf.push(character);
  49515. }
  49516. currentLabel = charBuf.join('');
  49517. break;
  49518. default:
  49519. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  49520. }
  49521. pageLabels[i] = prefix + currentLabel;
  49522. currentLabel = '';
  49523. currentIndex++;
  49524. }
  49525. return pageLabels;
  49526. },
  49527. get attachments() {
  49528. var xref = this.xref;
  49529. var attachments = null, nameTreeRef;
  49530. var obj = this.catDict.get('Names');
  49531. if (obj) {
  49532. nameTreeRef = obj.getRaw('EmbeddedFiles');
  49533. }
  49534. if (nameTreeRef) {
  49535. var nameTree = new NameTree(nameTreeRef, xref);
  49536. var names = nameTree.getAll();
  49537. for (var name in names) {
  49538. var fs = new FileSpec(names[name], xref);
  49539. if (!attachments) {
  49540. attachments = Object.create(null);
  49541. }
  49542. attachments[stringToPDFString(name)] = fs.serializable;
  49543. }
  49544. }
  49545. return shadow(this, 'attachments', attachments);
  49546. },
  49547. get javaScript() {
  49548. var xref = this.xref;
  49549. var obj = this.catDict.get('Names');
  49550. var javaScript = [];
  49551. function appendIfJavaScriptDict(jsDict) {
  49552. var type = jsDict.get('S');
  49553. if (!isName(type, 'JavaScript')) {
  49554. return;
  49555. }
  49556. var js = jsDict.get('JS');
  49557. if (isStream(js)) {
  49558. js = bytesToString(js.getBytes());
  49559. } else if (!isString(js)) {
  49560. return;
  49561. }
  49562. javaScript.push(stringToPDFString(js));
  49563. }
  49564. if (obj && obj.has('JavaScript')) {
  49565. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  49566. var names = nameTree.getAll();
  49567. for (var name in names) {
  49568. var jsDict = names[name];
  49569. if (isDict(jsDict)) {
  49570. appendIfJavaScriptDict(jsDict);
  49571. }
  49572. }
  49573. }
  49574. var openactionDict = this.catDict.get('OpenAction');
  49575. if (isDict(openactionDict, 'Action')) {
  49576. var actionType = openactionDict.get('S');
  49577. if (isName(actionType, 'Named')) {
  49578. var action = openactionDict.get('N');
  49579. if (isName(action, 'Print')) {
  49580. javaScript.push('print({});');
  49581. }
  49582. } else {
  49583. appendIfJavaScriptDict(openactionDict);
  49584. }
  49585. }
  49586. return shadow(this, 'javaScript', javaScript);
  49587. },
  49588. cleanup: function Catalog_cleanup() {
  49589. var promises = [];
  49590. this.fontCache.forEach(function (promise) {
  49591. promises.push(promise);
  49592. });
  49593. return Promise.all(promises).then(function (translatedFonts) {
  49594. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  49595. var font = translatedFonts[i].dict;
  49596. delete font.translated;
  49597. }
  49598. this.fontCache.clear();
  49599. }.bind(this));
  49600. },
  49601. getPage: function Catalog_getPage(pageIndex) {
  49602. if (!(pageIndex in this.pagePromises)) {
  49603. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  49604. var dict = a[0];
  49605. var ref = a[1];
  49606. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache);
  49607. }.bind(this));
  49608. }
  49609. return this.pagePromises[pageIndex];
  49610. },
  49611. getPageDict: function Catalog_getPageDict(pageIndex) {
  49612. var capability = createPromiseCapability();
  49613. var nodesToVisit = [this.catDict.getRaw('Pages')];
  49614. var currentPageIndex = 0;
  49615. var xref = this.xref;
  49616. var checkAllKids = false;
  49617. function next() {
  49618. while (nodesToVisit.length) {
  49619. var currentNode = nodesToVisit.pop();
  49620. if (isRef(currentNode)) {
  49621. xref.fetchAsync(currentNode).then(function (obj) {
  49622. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  49623. if (pageIndex === currentPageIndex) {
  49624. capability.resolve([
  49625. obj,
  49626. currentNode
  49627. ]);
  49628. } else {
  49629. currentPageIndex++;
  49630. next();
  49631. }
  49632. return;
  49633. }
  49634. nodesToVisit.push(obj);
  49635. next();
  49636. }, capability.reject);
  49637. return;
  49638. }
  49639. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  49640. var count = currentNode.get('Count');
  49641. if (count === 0) {
  49642. checkAllKids = true;
  49643. }
  49644. if (currentPageIndex + count <= pageIndex) {
  49645. currentPageIndex += count;
  49646. continue;
  49647. }
  49648. var kids = currentNode.get('Kids');
  49649. assert(isArray(kids), 'page dictionary kids object is not an array');
  49650. if (!checkAllKids && count === kids.length) {
  49651. nodesToVisit = [kids[pageIndex - currentPageIndex]];
  49652. currentPageIndex = pageIndex;
  49653. continue;
  49654. } else {
  49655. for (var last = kids.length - 1; last >= 0; last--) {
  49656. nodesToVisit.push(kids[last]);
  49657. }
  49658. }
  49659. }
  49660. capability.reject('Page index ' + pageIndex + ' not found.');
  49661. }
  49662. next();
  49663. return capability.promise;
  49664. },
  49665. getPageIndex: function Catalog_getPageIndex(pageRef) {
  49666. var xref = this.xref;
  49667. function pagesBeforeRef(kidRef) {
  49668. var total = 0;
  49669. var parentRef;
  49670. return xref.fetchAsync(kidRef).then(function (node) {
  49671. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  49672. throw new Error('The reference does not point to a /Page Dict.');
  49673. }
  49674. if (!node) {
  49675. return null;
  49676. }
  49677. assert(isDict(node), 'node must be a Dict.');
  49678. parentRef = node.getRaw('Parent');
  49679. return node.getAsync('Parent');
  49680. }).then(function (parent) {
  49681. if (!parent) {
  49682. return null;
  49683. }
  49684. assert(isDict(parent), 'parent must be a Dict.');
  49685. return parent.getAsync('Kids');
  49686. }).then(function (kids) {
  49687. if (!kids) {
  49688. return null;
  49689. }
  49690. var kidPromises = [];
  49691. var found = false;
  49692. for (var i = 0; i < kids.length; i++) {
  49693. var kid = kids[i];
  49694. assert(isRef(kid), 'kid must be a Ref.');
  49695. if (kid.num === kidRef.num) {
  49696. found = true;
  49697. break;
  49698. }
  49699. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  49700. if (kid.has('Count')) {
  49701. var count = kid.get('Count');
  49702. total += count;
  49703. } else {
  49704. total++;
  49705. }
  49706. }));
  49707. }
  49708. if (!found) {
  49709. error('kid ref not found in parents kids');
  49710. }
  49711. return Promise.all(kidPromises).then(function () {
  49712. return [
  49713. total,
  49714. parentRef
  49715. ];
  49716. });
  49717. });
  49718. }
  49719. var total = 0;
  49720. function next(ref) {
  49721. return pagesBeforeRef(ref).then(function (args) {
  49722. if (!args) {
  49723. return total;
  49724. }
  49725. var count = args[0];
  49726. var parentRef = args[1];
  49727. total += count;
  49728. return next(parentRef);
  49729. });
  49730. }
  49731. return next(pageRef);
  49732. }
  49733. };
  49734. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  49735. function addDefaultProtocolToUrl(url) {
  49736. if (url.indexOf('www.') === 0) {
  49737. return 'http://' + url;
  49738. }
  49739. return url;
  49740. }
  49741. function tryConvertUrlEncoding(url) {
  49742. try {
  49743. return stringToUTF8String(url);
  49744. } catch (e) {
  49745. return url;
  49746. }
  49747. }
  49748. var destDict = params.destDict;
  49749. if (!isDict(destDict)) {
  49750. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  49751. return;
  49752. }
  49753. var resultObj = params.resultObj;
  49754. if (typeof resultObj !== 'object') {
  49755. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  49756. return;
  49757. }
  49758. var docBaseUrl = params.docBaseUrl || null;
  49759. var action = destDict.get('A'), url, dest;
  49760. if (isDict(action)) {
  49761. var linkType = action.get('S').name;
  49762. switch (linkType) {
  49763. case 'URI':
  49764. url = action.get('URI');
  49765. if (isName(url)) {
  49766. url = '/' + url.name;
  49767. } else if (isString(url)) {
  49768. url = addDefaultProtocolToUrl(url);
  49769. }
  49770. break;
  49771. case 'GoTo':
  49772. dest = action.get('D');
  49773. break;
  49774. case 'Launch':
  49775. case 'GoToR':
  49776. var urlDict = action.get('F');
  49777. if (isDict(urlDict)) {
  49778. url = urlDict.get('F') || null;
  49779. } else if (isString(urlDict)) {
  49780. url = urlDict;
  49781. }
  49782. var remoteDest = action.get('D');
  49783. if (remoteDest) {
  49784. if (isName(remoteDest)) {
  49785. remoteDest = remoteDest.name;
  49786. }
  49787. if (isString(url)) {
  49788. var baseUrl = url.split('#')[0];
  49789. if (isString(remoteDest)) {
  49790. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  49791. } else if (isArray(remoteDest)) {
  49792. url = baseUrl + '#' + JSON.stringify(remoteDest);
  49793. }
  49794. }
  49795. }
  49796. var newWindow = action.get('NewWindow');
  49797. if (isBool(newWindow)) {
  49798. resultObj.newWindow = newWindow;
  49799. }
  49800. break;
  49801. case 'Named':
  49802. var namedAction = action.get('N');
  49803. if (isName(namedAction)) {
  49804. resultObj.action = namedAction.name;
  49805. }
  49806. break;
  49807. case 'JavaScript':
  49808. var jsAction = action.get('JS'), js;
  49809. if (isStream(jsAction)) {
  49810. js = bytesToString(jsAction.getBytes());
  49811. } else if (isString(jsAction)) {
  49812. js = jsAction;
  49813. }
  49814. if (js) {
  49815. var URL_OPEN_METHODS = [
  49816. 'app.launchURL',
  49817. 'window.open'
  49818. ];
  49819. var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  49820. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  49821. if (jsUrl && jsUrl[1]) {
  49822. url = jsUrl[1];
  49823. break;
  49824. }
  49825. }
  49826. default:
  49827. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  49828. break;
  49829. }
  49830. } else if (destDict.has('Dest')) {
  49831. dest = destDict.get('Dest');
  49832. }
  49833. if (isString(url)) {
  49834. url = tryConvertUrlEncoding(url);
  49835. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  49836. if (absoluteUrl) {
  49837. resultObj.url = absoluteUrl.href;
  49838. }
  49839. resultObj.unsafeUrl = url;
  49840. }
  49841. if (dest) {
  49842. if (isName(dest)) {
  49843. dest = dest.name;
  49844. }
  49845. if (isString(dest) || isArray(dest)) {
  49846. resultObj.dest = dest;
  49847. }
  49848. }
  49849. };
  49850. return Catalog;
  49851. }();
  49852. var XRef = function XRefClosure() {
  49853. function XRef(stream, password) {
  49854. this.stream = stream;
  49855. this.entries = [];
  49856. this.xrefstms = Object.create(null);
  49857. this.cache = [];
  49858. this.password = password;
  49859. this.stats = {
  49860. streamTypes: [],
  49861. fontTypes: []
  49862. };
  49863. }
  49864. XRef.prototype = {
  49865. setStartXRef: function XRef_setStartXRef(startXRef) {
  49866. this.startXRefQueue = [startXRef];
  49867. },
  49868. parse: function XRef_parse(recoveryMode) {
  49869. var trailerDict;
  49870. if (!recoveryMode) {
  49871. trailerDict = this.readXRef();
  49872. } else {
  49873. warn('Indexing all PDF objects');
  49874. trailerDict = this.indexObjects();
  49875. }
  49876. trailerDict.assignXref(this);
  49877. this.trailer = trailerDict;
  49878. var encrypt = trailerDict.get('Encrypt');
  49879. if (encrypt) {
  49880. var ids = trailerDict.get('ID');
  49881. var fileId = ids && ids.length ? ids[0] : '';
  49882. encrypt.suppressEncryption = true;
  49883. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.password);
  49884. }
  49885. if (!(this.root = trailerDict.get('Root'))) {
  49886. error('Invalid root reference');
  49887. }
  49888. },
  49889. processXRefTable: function XRef_processXRefTable(parser) {
  49890. if (!('tableState' in this)) {
  49891. this.tableState = {
  49892. entryNum: 0,
  49893. streamPos: parser.lexer.stream.pos,
  49894. parserBuf1: parser.buf1,
  49895. parserBuf2: parser.buf2
  49896. };
  49897. }
  49898. var obj = this.readXRefTable(parser);
  49899. if (!isCmd(obj, 'trailer')) {
  49900. error('Invalid XRef table: could not find trailer dictionary');
  49901. }
  49902. var dict = parser.getObj();
  49903. if (!isDict(dict) && dict.dict) {
  49904. dict = dict.dict;
  49905. }
  49906. if (!isDict(dict)) {
  49907. error('Invalid XRef table: could not parse trailer dictionary');
  49908. }
  49909. delete this.tableState;
  49910. return dict;
  49911. },
  49912. readXRefTable: function XRef_readXRefTable(parser) {
  49913. var stream = parser.lexer.stream;
  49914. var tableState = this.tableState;
  49915. stream.pos = tableState.streamPos;
  49916. parser.buf1 = tableState.parserBuf1;
  49917. parser.buf2 = tableState.parserBuf2;
  49918. var obj;
  49919. while (true) {
  49920. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  49921. if (isCmd(obj = parser.getObj(), 'trailer')) {
  49922. break;
  49923. }
  49924. tableState.firstEntryNum = obj;
  49925. tableState.entryCount = parser.getObj();
  49926. }
  49927. var first = tableState.firstEntryNum;
  49928. var count = tableState.entryCount;
  49929. if (!isInt(first) || !isInt(count)) {
  49930. error('Invalid XRef table: wrong types in subsection header');
  49931. }
  49932. for (var i = tableState.entryNum; i < count; i++) {
  49933. tableState.streamPos = stream.pos;
  49934. tableState.entryNum = i;
  49935. tableState.parserBuf1 = parser.buf1;
  49936. tableState.parserBuf2 = parser.buf2;
  49937. var entry = {};
  49938. entry.offset = parser.getObj();
  49939. entry.gen = parser.getObj();
  49940. var type = parser.getObj();
  49941. if (isCmd(type, 'f')) {
  49942. entry.free = true;
  49943. } else if (isCmd(type, 'n')) {
  49944. entry.uncompressed = true;
  49945. }
  49946. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  49947. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  49948. }
  49949. if (i === 0 && entry.free && first === 1) {
  49950. first = 0;
  49951. }
  49952. if (!this.entries[i + first]) {
  49953. this.entries[i + first] = entry;
  49954. }
  49955. }
  49956. tableState.entryNum = 0;
  49957. tableState.streamPos = stream.pos;
  49958. tableState.parserBuf1 = parser.buf1;
  49959. tableState.parserBuf2 = parser.buf2;
  49960. delete tableState.firstEntryNum;
  49961. delete tableState.entryCount;
  49962. }
  49963. if (this.entries[0] && !this.entries[0].free) {
  49964. error('Invalid XRef table: unexpected first object');
  49965. }
  49966. return obj;
  49967. },
  49968. processXRefStream: function XRef_processXRefStream(stream) {
  49969. if (!('streamState' in this)) {
  49970. var streamParameters = stream.dict;
  49971. var byteWidths = streamParameters.get('W');
  49972. var range = streamParameters.get('Index');
  49973. if (!range) {
  49974. range = [
  49975. 0,
  49976. streamParameters.get('Size')
  49977. ];
  49978. }
  49979. this.streamState = {
  49980. entryRanges: range,
  49981. byteWidths: byteWidths,
  49982. entryNum: 0,
  49983. streamPos: stream.pos
  49984. };
  49985. }
  49986. this.readXRefStream(stream);
  49987. delete this.streamState;
  49988. return stream.dict;
  49989. },
  49990. readXRefStream: function XRef_readXRefStream(stream) {
  49991. var i, j;
  49992. var streamState = this.streamState;
  49993. stream.pos = streamState.streamPos;
  49994. var byteWidths = streamState.byteWidths;
  49995. var typeFieldWidth = byteWidths[0];
  49996. var offsetFieldWidth = byteWidths[1];
  49997. var generationFieldWidth = byteWidths[2];
  49998. var entryRanges = streamState.entryRanges;
  49999. while (entryRanges.length > 0) {
  50000. var first = entryRanges[0];
  50001. var n = entryRanges[1];
  50002. if (!isInt(first) || !isInt(n)) {
  50003. error('Invalid XRef range fields: ' + first + ', ' + n);
  50004. }
  50005. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  50006. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  50007. }
  50008. for (i = streamState.entryNum; i < n; ++i) {
  50009. streamState.entryNum = i;
  50010. streamState.streamPos = stream.pos;
  50011. var type = 0, offset = 0, generation = 0;
  50012. for (j = 0; j < typeFieldWidth; ++j) {
  50013. type = type << 8 | stream.getByte();
  50014. }
  50015. if (typeFieldWidth === 0) {
  50016. type = 1;
  50017. }
  50018. for (j = 0; j < offsetFieldWidth; ++j) {
  50019. offset = offset << 8 | stream.getByte();
  50020. }
  50021. for (j = 0; j < generationFieldWidth; ++j) {
  50022. generation = generation << 8 | stream.getByte();
  50023. }
  50024. var entry = {};
  50025. entry.offset = offset;
  50026. entry.gen = generation;
  50027. switch (type) {
  50028. case 0:
  50029. entry.free = true;
  50030. break;
  50031. case 1:
  50032. entry.uncompressed = true;
  50033. break;
  50034. case 2:
  50035. break;
  50036. default:
  50037. error('Invalid XRef entry type: ' + type);
  50038. }
  50039. if (!this.entries[first + i]) {
  50040. this.entries[first + i] = entry;
  50041. }
  50042. }
  50043. streamState.entryNum = 0;
  50044. streamState.streamPos = stream.pos;
  50045. entryRanges.splice(0, 2);
  50046. }
  50047. },
  50048. indexObjects: function XRef_indexObjects() {
  50049. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  50050. var PERCENT = 0x25, LT = 0x3C;
  50051. function readToken(data, offset) {
  50052. var token = '', ch = data[offset];
  50053. while (ch !== LF && ch !== CR && ch !== LT) {
  50054. if (++offset >= data.length) {
  50055. break;
  50056. }
  50057. token += String.fromCharCode(ch);
  50058. ch = data[offset];
  50059. }
  50060. return token;
  50061. }
  50062. function skipUntil(data, offset, what) {
  50063. var length = what.length, dataLength = data.length;
  50064. var skipped = 0;
  50065. while (offset < dataLength) {
  50066. var i = 0;
  50067. while (i < length && data[offset + i] === what[i]) {
  50068. ++i;
  50069. }
  50070. if (i >= length) {
  50071. break;
  50072. }
  50073. offset++;
  50074. skipped++;
  50075. }
  50076. return skipped;
  50077. }
  50078. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  50079. var trailerBytes = new Uint8Array([
  50080. 116,
  50081. 114,
  50082. 97,
  50083. 105,
  50084. 108,
  50085. 101,
  50086. 114
  50087. ]);
  50088. var startxrefBytes = new Uint8Array([
  50089. 115,
  50090. 116,
  50091. 97,
  50092. 114,
  50093. 116,
  50094. 120,
  50095. 114,
  50096. 101,
  50097. 102
  50098. ]);
  50099. var endobjBytes = new Uint8Array([
  50100. 101,
  50101. 110,
  50102. 100,
  50103. 111,
  50104. 98,
  50105. 106
  50106. ]);
  50107. var xrefBytes = new Uint8Array([
  50108. 47,
  50109. 88,
  50110. 82,
  50111. 101,
  50112. 102
  50113. ]);
  50114. this.entries.length = 0;
  50115. var stream = this.stream;
  50116. stream.pos = 0;
  50117. var buffer = stream.getBytes();
  50118. var position = stream.start, length = buffer.length;
  50119. var trailers = [], xrefStms = [];
  50120. while (position < length) {
  50121. var ch = buffer[position];
  50122. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  50123. ++position;
  50124. continue;
  50125. }
  50126. if (ch === PERCENT) {
  50127. do {
  50128. ++position;
  50129. if (position >= length) {
  50130. break;
  50131. }
  50132. ch = buffer[position];
  50133. } while (ch !== LF && ch !== CR);
  50134. continue;
  50135. }
  50136. var token = readToken(buffer, position);
  50137. var m;
  50138. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  50139. position += skipUntil(buffer, position, trailerBytes);
  50140. trailers.push(position);
  50141. position += skipUntil(buffer, position, startxrefBytes);
  50142. } else if (m = objRegExp.exec(token)) {
  50143. if (typeof this.entries[m[1]] === 'undefined') {
  50144. this.entries[m[1]] = {
  50145. offset: position - stream.start,
  50146. gen: m[2] | 0,
  50147. uncompressed: true
  50148. };
  50149. }
  50150. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  50151. var content = buffer.subarray(position, position + contentLength);
  50152. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  50153. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  50154. xrefStms.push(position - stream.start);
  50155. this.xrefstms[position - stream.start] = 1;
  50156. }
  50157. position += contentLength;
  50158. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  50159. trailers.push(position);
  50160. position += skipUntil(buffer, position, startxrefBytes);
  50161. } else {
  50162. position += token.length + 1;
  50163. }
  50164. }
  50165. var i, ii;
  50166. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  50167. this.startXRefQueue.push(xrefStms[i]);
  50168. this.readXRef(true);
  50169. }
  50170. var dict;
  50171. for (i = 0, ii = trailers.length; i < ii; ++i) {
  50172. stream.pos = trailers[i];
  50173. var parser = new Parser(new Lexer(stream), true, this, true);
  50174. var obj = parser.getObj();
  50175. if (!isCmd(obj, 'trailer')) {
  50176. continue;
  50177. }
  50178. dict = parser.getObj();
  50179. if (!isDict(dict)) {
  50180. continue;
  50181. }
  50182. if (dict.has('ID')) {
  50183. return dict;
  50184. }
  50185. }
  50186. if (dict) {
  50187. return dict;
  50188. }
  50189. throw new InvalidPDFException('Invalid PDF structure');
  50190. },
  50191. readXRef: function XRef_readXRef(recoveryMode) {
  50192. var stream = this.stream;
  50193. try {
  50194. while (this.startXRefQueue.length) {
  50195. var startXRef = this.startXRefQueue[0];
  50196. stream.pos = startXRef + stream.start;
  50197. var parser = new Parser(new Lexer(stream), true, this);
  50198. var obj = parser.getObj();
  50199. var dict;
  50200. if (isCmd(obj, 'xref')) {
  50201. dict = this.processXRefTable(parser);
  50202. if (!this.topDict) {
  50203. this.topDict = dict;
  50204. }
  50205. obj = dict.get('XRefStm');
  50206. if (isInt(obj)) {
  50207. var pos = obj;
  50208. if (!(pos in this.xrefstms)) {
  50209. this.xrefstms[pos] = 1;
  50210. this.startXRefQueue.push(pos);
  50211. }
  50212. }
  50213. } else if (isInt(obj)) {
  50214. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  50215. error('Invalid XRef stream');
  50216. }
  50217. dict = this.processXRefStream(obj);
  50218. if (!this.topDict) {
  50219. this.topDict = dict;
  50220. }
  50221. if (!dict) {
  50222. error('Failed to read XRef stream');
  50223. }
  50224. } else {
  50225. error('Invalid XRef stream header');
  50226. }
  50227. obj = dict.get('Prev');
  50228. if (isInt(obj)) {
  50229. this.startXRefQueue.push(obj);
  50230. } else if (isRef(obj)) {
  50231. this.startXRefQueue.push(obj.num);
  50232. }
  50233. this.startXRefQueue.shift();
  50234. }
  50235. return this.topDict;
  50236. } catch (e) {
  50237. if (e instanceof MissingDataException) {
  50238. throw e;
  50239. }
  50240. info('(while reading XRef): ' + e);
  50241. }
  50242. if (recoveryMode) {
  50243. return;
  50244. }
  50245. throw new XRefParseException();
  50246. },
  50247. getEntry: function XRef_getEntry(i) {
  50248. var xrefEntry = this.entries[i];
  50249. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  50250. return xrefEntry;
  50251. }
  50252. return null;
  50253. },
  50254. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  50255. if (!isRef(obj)) {
  50256. return obj;
  50257. }
  50258. return this.fetch(obj, suppressEncryption);
  50259. },
  50260. fetch: function XRef_fetch(ref, suppressEncryption) {
  50261. assert(isRef(ref), 'ref object is not a reference');
  50262. var num = ref.num;
  50263. if (num in this.cache) {
  50264. var cacheEntry = this.cache[num];
  50265. return cacheEntry;
  50266. }
  50267. var xrefEntry = this.getEntry(num);
  50268. if (xrefEntry === null) {
  50269. return this.cache[num] = null;
  50270. }
  50271. if (xrefEntry.uncompressed) {
  50272. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  50273. } else {
  50274. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  50275. }
  50276. if (isDict(xrefEntry)) {
  50277. xrefEntry.objId = ref.toString();
  50278. } else if (isStream(xrefEntry)) {
  50279. xrefEntry.dict.objId = ref.toString();
  50280. }
  50281. return xrefEntry;
  50282. },
  50283. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  50284. var gen = ref.gen;
  50285. var num = ref.num;
  50286. if (xrefEntry.gen !== gen) {
  50287. error('inconsistent generation in XRef');
  50288. }
  50289. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  50290. var parser = new Parser(new Lexer(stream), true, this);
  50291. var obj1 = parser.getObj();
  50292. var obj2 = parser.getObj();
  50293. var obj3 = parser.getObj();
  50294. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  50295. error('bad XRef entry');
  50296. }
  50297. if (!isCmd(obj3, 'obj')) {
  50298. if (obj3.cmd.indexOf('obj') === 0) {
  50299. num = parseInt(obj3.cmd.substring(3), 10);
  50300. if (!isNaN(num)) {
  50301. return num;
  50302. }
  50303. }
  50304. error('bad XRef entry');
  50305. }
  50306. if (this.encrypt && !suppressEncryption) {
  50307. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  50308. } else {
  50309. xrefEntry = parser.getObj();
  50310. }
  50311. if (!isStream(xrefEntry)) {
  50312. this.cache[num] = xrefEntry;
  50313. }
  50314. return xrefEntry;
  50315. },
  50316. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  50317. var tableOffset = xrefEntry.offset;
  50318. var stream = this.fetch(new Ref(tableOffset, 0));
  50319. if (!isStream(stream)) {
  50320. error('bad ObjStm stream');
  50321. }
  50322. var first = stream.dict.get('First');
  50323. var n = stream.dict.get('N');
  50324. if (!isInt(first) || !isInt(n)) {
  50325. error('invalid first and n parameters for ObjStm stream');
  50326. }
  50327. var parser = new Parser(new Lexer(stream), false, this);
  50328. parser.allowStreams = true;
  50329. var i, entries = [], num, nums = [];
  50330. for (i = 0; i < n; ++i) {
  50331. num = parser.getObj();
  50332. if (!isInt(num)) {
  50333. error('invalid object number in the ObjStm stream: ' + num);
  50334. }
  50335. nums.push(num);
  50336. var offset = parser.getObj();
  50337. if (!isInt(offset)) {
  50338. error('invalid object offset in the ObjStm stream: ' + offset);
  50339. }
  50340. }
  50341. for (i = 0; i < n; ++i) {
  50342. entries.push(parser.getObj());
  50343. if (isCmd(parser.buf1, 'endobj')) {
  50344. parser.shift();
  50345. }
  50346. num = nums[i];
  50347. var entry = this.entries[num];
  50348. if (entry && entry.offset === tableOffset && entry.gen === i) {
  50349. this.cache[num] = entries[i];
  50350. }
  50351. }
  50352. xrefEntry = entries[xrefEntry.gen];
  50353. if (xrefEntry === undefined) {
  50354. error('bad XRef entry for compressed object');
  50355. }
  50356. return xrefEntry;
  50357. },
  50358. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  50359. if (!isRef(obj)) {
  50360. return Promise.resolve(obj);
  50361. }
  50362. return this.fetchAsync(obj, suppressEncryption);
  50363. },
  50364. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  50365. var streamManager = this.stream.manager;
  50366. var xref = this;
  50367. return new Promise(function tryFetch(resolve, reject) {
  50368. try {
  50369. resolve(xref.fetch(ref, suppressEncryption));
  50370. } catch (e) {
  50371. if (e instanceof MissingDataException) {
  50372. streamManager.requestRange(e.begin, e.end).then(function () {
  50373. tryFetch(resolve, reject);
  50374. }, reject);
  50375. return;
  50376. }
  50377. reject(e);
  50378. }
  50379. });
  50380. },
  50381. getCatalogObj: function XRef_getCatalogObj() {
  50382. return this.root;
  50383. }
  50384. };
  50385. return XRef;
  50386. }();
  50387. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  50388. function NameOrNumberTree(root, xref) {
  50389. throw new Error('Cannot initialize NameOrNumberTree.');
  50390. }
  50391. NameOrNumberTree.prototype = {
  50392. getAll: function NameOrNumberTree_getAll() {
  50393. var dict = Object.create(null);
  50394. if (!this.root) {
  50395. return dict;
  50396. }
  50397. var xref = this.xref;
  50398. var processed = new RefSet();
  50399. processed.put(this.root);
  50400. var queue = [this.root];
  50401. while (queue.length > 0) {
  50402. var i, n;
  50403. var obj = xref.fetchIfRef(queue.shift());
  50404. if (!isDict(obj)) {
  50405. continue;
  50406. }
  50407. if (obj.has('Kids')) {
  50408. var kids = obj.get('Kids');
  50409. for (i = 0, n = kids.length; i < n; i++) {
  50410. var kid = kids[i];
  50411. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  50412. queue.push(kid);
  50413. processed.put(kid);
  50414. }
  50415. continue;
  50416. }
  50417. var entries = obj.get(this._type);
  50418. if (isArray(entries)) {
  50419. for (i = 0, n = entries.length; i < n; i += 2) {
  50420. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  50421. }
  50422. }
  50423. }
  50424. return dict;
  50425. },
  50426. get: function NameOrNumberTree_get(key) {
  50427. if (!this.root) {
  50428. return null;
  50429. }
  50430. var xref = this.xref;
  50431. var kidsOrEntries = xref.fetchIfRef(this.root);
  50432. var loopCount = 0;
  50433. var MAX_LEVELS = 10;
  50434. var l, r, m;
  50435. while (kidsOrEntries.has('Kids')) {
  50436. if (++loopCount > MAX_LEVELS) {
  50437. warn('Search depth limit reached for "' + this._type + '" tree.');
  50438. return null;
  50439. }
  50440. var kids = kidsOrEntries.get('Kids');
  50441. if (!isArray(kids)) {
  50442. return null;
  50443. }
  50444. l = 0;
  50445. r = kids.length - 1;
  50446. while (l <= r) {
  50447. m = l + r >> 1;
  50448. var kid = xref.fetchIfRef(kids[m]);
  50449. var limits = kid.get('Limits');
  50450. if (key < xref.fetchIfRef(limits[0])) {
  50451. r = m - 1;
  50452. } else if (key > xref.fetchIfRef(limits[1])) {
  50453. l = m + 1;
  50454. } else {
  50455. kidsOrEntries = xref.fetchIfRef(kids[m]);
  50456. break;
  50457. }
  50458. }
  50459. if (l > r) {
  50460. return null;
  50461. }
  50462. }
  50463. var entries = kidsOrEntries.get(this._type);
  50464. if (isArray(entries)) {
  50465. l = 0;
  50466. r = entries.length - 2;
  50467. while (l <= r) {
  50468. m = l + r & ~1;
  50469. var currentKey = xref.fetchIfRef(entries[m]);
  50470. if (key < currentKey) {
  50471. r = m - 2;
  50472. } else if (key > currentKey) {
  50473. l = m + 2;
  50474. } else {
  50475. return xref.fetchIfRef(entries[m + 1]);
  50476. }
  50477. }
  50478. }
  50479. return null;
  50480. }
  50481. };
  50482. return NameOrNumberTree;
  50483. }();
  50484. var NameTree = function NameTreeClosure() {
  50485. function NameTree(root, xref) {
  50486. this.root = root;
  50487. this.xref = xref;
  50488. this._type = 'Names';
  50489. }
  50490. Util.inherit(NameTree, NameOrNumberTree, {});
  50491. return NameTree;
  50492. }();
  50493. var NumberTree = function NumberTreeClosure() {
  50494. function NumberTree(root, xref) {
  50495. this.root = root;
  50496. this.xref = xref;
  50497. this._type = 'Nums';
  50498. }
  50499. Util.inherit(NumberTree, NameOrNumberTree, {});
  50500. return NumberTree;
  50501. }();
  50502. var FileSpec = function FileSpecClosure() {
  50503. function FileSpec(root, xref) {
  50504. if (!root || !isDict(root)) {
  50505. return;
  50506. }
  50507. this.xref = xref;
  50508. this.root = root;
  50509. if (root.has('FS')) {
  50510. this.fs = root.get('FS');
  50511. }
  50512. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  50513. if (root.has('RF')) {
  50514. warn('Related file specifications are not supported');
  50515. }
  50516. this.contentAvailable = true;
  50517. if (!root.has('EF')) {
  50518. this.contentAvailable = false;
  50519. warn('Non-embedded file specifications are not supported');
  50520. }
  50521. }
  50522. function pickPlatformItem(dict) {
  50523. if (dict.has('UF')) {
  50524. return dict.get('UF');
  50525. } else if (dict.has('F')) {
  50526. return dict.get('F');
  50527. } else if (dict.has('Unix')) {
  50528. return dict.get('Unix');
  50529. } else if (dict.has('Mac')) {
  50530. return dict.get('Mac');
  50531. } else if (dict.has('DOS')) {
  50532. return dict.get('DOS');
  50533. } else {
  50534. return null;
  50535. }
  50536. }
  50537. FileSpec.prototype = {
  50538. get filename() {
  50539. if (!this._filename && this.root) {
  50540. var filename = pickPlatformItem(this.root) || 'unnamed';
  50541. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  50542. }
  50543. return this._filename;
  50544. },
  50545. get content() {
  50546. if (!this.contentAvailable) {
  50547. return null;
  50548. }
  50549. if (!this.contentRef && this.root) {
  50550. this.contentRef = pickPlatformItem(this.root.get('EF'));
  50551. }
  50552. var content = null;
  50553. if (this.contentRef) {
  50554. var xref = this.xref;
  50555. var fileObj = xref.fetchIfRef(this.contentRef);
  50556. if (fileObj && isStream(fileObj)) {
  50557. content = fileObj.getBytes();
  50558. } else {
  50559. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  50560. }
  50561. } else {
  50562. warn('Embedded file specification does not have a content');
  50563. }
  50564. return content;
  50565. },
  50566. get serializable() {
  50567. return {
  50568. filename: this.filename,
  50569. content: this.content
  50570. };
  50571. }
  50572. };
  50573. return FileSpec;
  50574. }();
  50575. var ObjectLoader = function () {
  50576. function mayHaveChildren(value) {
  50577. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  50578. }
  50579. function addChildren(node, nodesToVisit) {
  50580. var value;
  50581. if (isDict(node) || isStream(node)) {
  50582. var map;
  50583. if (isDict(node)) {
  50584. map = node.map;
  50585. } else {
  50586. map = node.dict.map;
  50587. }
  50588. for (var key in map) {
  50589. value = map[key];
  50590. if (mayHaveChildren(value)) {
  50591. nodesToVisit.push(value);
  50592. }
  50593. }
  50594. } else if (isArray(node)) {
  50595. for (var i = 0, ii = node.length; i < ii; i++) {
  50596. value = node[i];
  50597. if (mayHaveChildren(value)) {
  50598. nodesToVisit.push(value);
  50599. }
  50600. }
  50601. }
  50602. }
  50603. function ObjectLoader(obj, keys, xref) {
  50604. this.obj = obj;
  50605. this.keys = keys;
  50606. this.xref = xref;
  50607. this.refSet = null;
  50608. this.capability = null;
  50609. }
  50610. ObjectLoader.prototype = {
  50611. load: function ObjectLoader_load() {
  50612. var keys = this.keys;
  50613. this.capability = createPromiseCapability();
  50614. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  50615. this.capability.resolve();
  50616. return this.capability.promise;
  50617. }
  50618. this.refSet = new RefSet();
  50619. var nodesToVisit = [];
  50620. for (var i = 0; i < keys.length; i++) {
  50621. nodesToVisit.push(this.obj[keys[i]]);
  50622. }
  50623. this._walk(nodesToVisit);
  50624. return this.capability.promise;
  50625. },
  50626. _walk: function ObjectLoader_walk(nodesToVisit) {
  50627. var nodesToRevisit = [];
  50628. var pendingRequests = [];
  50629. while (nodesToVisit.length) {
  50630. var currentNode = nodesToVisit.pop();
  50631. if (isRef(currentNode)) {
  50632. if (this.refSet.has(currentNode)) {
  50633. continue;
  50634. }
  50635. try {
  50636. var ref = currentNode;
  50637. this.refSet.put(ref);
  50638. currentNode = this.xref.fetch(currentNode);
  50639. } catch (e) {
  50640. if (!(e instanceof MissingDataException)) {
  50641. throw e;
  50642. }
  50643. nodesToRevisit.push(currentNode);
  50644. pendingRequests.push({
  50645. begin: e.begin,
  50646. end: e.end
  50647. });
  50648. }
  50649. }
  50650. if (currentNode && currentNode.getBaseStreams) {
  50651. var baseStreams = currentNode.getBaseStreams();
  50652. var foundMissingData = false;
  50653. for (var i = 0; i < baseStreams.length; i++) {
  50654. var stream = baseStreams[i];
  50655. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  50656. foundMissingData = true;
  50657. pendingRequests.push({
  50658. begin: stream.start,
  50659. end: stream.end
  50660. });
  50661. }
  50662. }
  50663. if (foundMissingData) {
  50664. nodesToRevisit.push(currentNode);
  50665. }
  50666. }
  50667. addChildren(currentNode, nodesToVisit);
  50668. }
  50669. if (pendingRequests.length) {
  50670. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  50671. nodesToVisit = nodesToRevisit;
  50672. for (var i = 0; i < nodesToRevisit.length; i++) {
  50673. var node = nodesToRevisit[i];
  50674. if (isRef(node)) {
  50675. this.refSet.remove(node);
  50676. }
  50677. }
  50678. this._walk(nodesToVisit);
  50679. }.bind(this), this.capability.reject);
  50680. return;
  50681. }
  50682. this.refSet = null;
  50683. this.capability.resolve();
  50684. }
  50685. };
  50686. return ObjectLoader;
  50687. }();
  50688. exports.Catalog = Catalog;
  50689. exports.ObjectLoader = ObjectLoader;
  50690. exports.XRef = XRef;
  50691. exports.FileSpec = FileSpec;
  50692. }));
  50693. (function (root, factory) {
  50694. factory(root.pdfjsCorePattern = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction, root.pdfjsCoreColorSpace);
  50695. }(this, function (exports, sharedUtil, corePrimitives, coreFunction, coreColorSpace) {
  50696. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  50697. var MissingDataException = sharedUtil.MissingDataException;
  50698. var Util = sharedUtil.Util;
  50699. var assert = sharedUtil.assert;
  50700. var error = sharedUtil.error;
  50701. var info = sharedUtil.info;
  50702. var warn = sharedUtil.warn;
  50703. var isStream = corePrimitives.isStream;
  50704. var PDFFunction = coreFunction.PDFFunction;
  50705. var ColorSpace = coreColorSpace.ColorSpace;
  50706. var ShadingType = {
  50707. FUNCTION_BASED: 1,
  50708. AXIAL: 2,
  50709. RADIAL: 3,
  50710. FREE_FORM_MESH: 4,
  50711. LATTICE_FORM_MESH: 5,
  50712. COONS_PATCH_MESH: 6,
  50713. TENSOR_PATCH_MESH: 7
  50714. };
  50715. var Pattern = function PatternClosure() {
  50716. function Pattern() {
  50717. error('should not call Pattern constructor');
  50718. }
  50719. Pattern.prototype = {
  50720. getPattern: function Pattern_getPattern(ctx) {
  50721. error('Should not call Pattern.getStyle: ' + ctx);
  50722. }
  50723. };
  50724. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  50725. var dict = isStream(shading) ? shading.dict : shading;
  50726. var type = dict.get('ShadingType');
  50727. try {
  50728. switch (type) {
  50729. case ShadingType.AXIAL:
  50730. case ShadingType.RADIAL:
  50731. return new Shadings.RadialAxial(dict, matrix, xref, res);
  50732. case ShadingType.FREE_FORM_MESH:
  50733. case ShadingType.LATTICE_FORM_MESH:
  50734. case ShadingType.COONS_PATCH_MESH:
  50735. case ShadingType.TENSOR_PATCH_MESH:
  50736. return new Shadings.Mesh(shading, matrix, xref, res);
  50737. default:
  50738. throw new Error('Unsupported ShadingType: ' + type);
  50739. }
  50740. } catch (ex) {
  50741. if (ex instanceof MissingDataException) {
  50742. throw ex;
  50743. }
  50744. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  50745. warn(ex);
  50746. return new Shadings.Dummy();
  50747. }
  50748. };
  50749. return Pattern;
  50750. }();
  50751. var Shadings = {};
  50752. Shadings.SMALL_NUMBER = 1e-6;
  50753. Shadings.RadialAxial = function RadialAxialClosure() {
  50754. function RadialAxial(dict, matrix, xref, res) {
  50755. this.matrix = matrix;
  50756. this.coordsArr = dict.getArray('Coords');
  50757. this.shadingType = dict.get('ShadingType');
  50758. this.type = 'Pattern';
  50759. var cs = dict.get('ColorSpace', 'CS');
  50760. cs = ColorSpace.parse(cs, xref, res);
  50761. this.cs = cs;
  50762. var t0 = 0.0, t1 = 1.0;
  50763. if (dict.has('Domain')) {
  50764. var domainArr = dict.getArray('Domain');
  50765. t0 = domainArr[0];
  50766. t1 = domainArr[1];
  50767. }
  50768. var extendStart = false, extendEnd = false;
  50769. if (dict.has('Extend')) {
  50770. var extendArr = dict.getArray('Extend');
  50771. extendStart = extendArr[0];
  50772. extendEnd = extendArr[1];
  50773. }
  50774. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  50775. var x1 = this.coordsArr[0];
  50776. var y1 = this.coordsArr[1];
  50777. var r1 = this.coordsArr[2];
  50778. var x2 = this.coordsArr[3];
  50779. var y2 = this.coordsArr[4];
  50780. var r2 = this.coordsArr[5];
  50781. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  50782. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  50783. warn('Unsupported radial gradient.');
  50784. }
  50785. }
  50786. this.extendStart = extendStart;
  50787. this.extendEnd = extendEnd;
  50788. var fnObj = dict.get('Function');
  50789. var fn = PDFFunction.parseArray(xref, fnObj);
  50790. var diff = t1 - t0;
  50791. var step = diff / 10;
  50792. var colorStops = this.colorStops = [];
  50793. if (t0 >= t1 || step <= 0) {
  50794. info('Bad shading domain.');
  50795. return;
  50796. }
  50797. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  50798. var rgbColor;
  50799. for (var i = t0; i <= t1; i += step) {
  50800. ratio[0] = i;
  50801. fn(ratio, 0, color, 0);
  50802. rgbColor = cs.getRgb(color, 0);
  50803. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  50804. colorStops.push([
  50805. (i - t0) / diff,
  50806. cssColor
  50807. ]);
  50808. }
  50809. var background = 'transparent';
  50810. if (dict.has('Background')) {
  50811. rgbColor = cs.getRgb(dict.get('Background'), 0);
  50812. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  50813. }
  50814. if (!extendStart) {
  50815. colorStops.unshift([
  50816. 0,
  50817. background
  50818. ]);
  50819. colorStops[1][0] += Shadings.SMALL_NUMBER;
  50820. }
  50821. if (!extendEnd) {
  50822. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  50823. colorStops.push([
  50824. 1,
  50825. background
  50826. ]);
  50827. }
  50828. this.colorStops = colorStops;
  50829. }
  50830. RadialAxial.prototype = {
  50831. getIR: function RadialAxial_getIR() {
  50832. var coordsArr = this.coordsArr;
  50833. var shadingType = this.shadingType;
  50834. var type, p0, p1, r0, r1;
  50835. if (shadingType === ShadingType.AXIAL) {
  50836. p0 = [
  50837. coordsArr[0],
  50838. coordsArr[1]
  50839. ];
  50840. p1 = [
  50841. coordsArr[2],
  50842. coordsArr[3]
  50843. ];
  50844. r0 = null;
  50845. r1 = null;
  50846. type = 'axial';
  50847. } else if (shadingType === ShadingType.RADIAL) {
  50848. p0 = [
  50849. coordsArr[0],
  50850. coordsArr[1]
  50851. ];
  50852. p1 = [
  50853. coordsArr[3],
  50854. coordsArr[4]
  50855. ];
  50856. r0 = coordsArr[2];
  50857. r1 = coordsArr[5];
  50858. type = 'radial';
  50859. } else {
  50860. error('getPattern type unknown: ' + shadingType);
  50861. }
  50862. var matrix = this.matrix;
  50863. if (matrix) {
  50864. p0 = Util.applyTransform(p0, matrix);
  50865. p1 = Util.applyTransform(p1, matrix);
  50866. if (shadingType === ShadingType.RADIAL) {
  50867. var scale = Util.singularValueDecompose2dScale(matrix);
  50868. r0 *= scale[0];
  50869. r1 *= scale[1];
  50870. }
  50871. }
  50872. return [
  50873. 'RadialAxial',
  50874. type,
  50875. this.colorStops,
  50876. p0,
  50877. p1,
  50878. r0,
  50879. r1
  50880. ];
  50881. }
  50882. };
  50883. return RadialAxial;
  50884. }();
  50885. Shadings.Mesh = function MeshClosure() {
  50886. function MeshStreamReader(stream, context) {
  50887. this.stream = stream;
  50888. this.context = context;
  50889. this.buffer = 0;
  50890. this.bufferLength = 0;
  50891. var numComps = context.numComps;
  50892. this.tmpCompsBuf = new Float32Array(numComps);
  50893. var csNumComps = context.colorSpace.numComps;
  50894. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  50895. }
  50896. MeshStreamReader.prototype = {
  50897. get hasData() {
  50898. if (this.stream.end) {
  50899. return this.stream.pos < this.stream.end;
  50900. }
  50901. if (this.bufferLength > 0) {
  50902. return true;
  50903. }
  50904. var nextByte = this.stream.getByte();
  50905. if (nextByte < 0) {
  50906. return false;
  50907. }
  50908. this.buffer = nextByte;
  50909. this.bufferLength = 8;
  50910. return true;
  50911. },
  50912. readBits: function MeshStreamReader_readBits(n) {
  50913. var buffer = this.buffer;
  50914. var bufferLength = this.bufferLength;
  50915. if (n === 32) {
  50916. if (bufferLength === 0) {
  50917. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  50918. }
  50919. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  50920. var nextByte = this.stream.getByte();
  50921. this.buffer = nextByte & (1 << bufferLength) - 1;
  50922. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  50923. }
  50924. if (n === 8 && bufferLength === 0) {
  50925. return this.stream.getByte();
  50926. }
  50927. while (bufferLength < n) {
  50928. buffer = buffer << 8 | this.stream.getByte();
  50929. bufferLength += 8;
  50930. }
  50931. bufferLength -= n;
  50932. this.bufferLength = bufferLength;
  50933. this.buffer = buffer & (1 << bufferLength) - 1;
  50934. return buffer >> bufferLength;
  50935. },
  50936. align: function MeshStreamReader_align() {
  50937. this.buffer = 0;
  50938. this.bufferLength = 0;
  50939. },
  50940. readFlag: function MeshStreamReader_readFlag() {
  50941. return this.readBits(this.context.bitsPerFlag);
  50942. },
  50943. readCoordinate: function MeshStreamReader_readCoordinate() {
  50944. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  50945. var xi = this.readBits(bitsPerCoordinate);
  50946. var yi = this.readBits(bitsPerCoordinate);
  50947. var decode = this.context.decode;
  50948. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  50949. return [
  50950. xi * scale * (decode[1] - decode[0]) + decode[0],
  50951. yi * scale * (decode[3] - decode[2]) + decode[2]
  50952. ];
  50953. },
  50954. readComponents: function MeshStreamReader_readComponents() {
  50955. var numComps = this.context.numComps;
  50956. var bitsPerComponent = this.context.bitsPerComponent;
  50957. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  50958. var decode = this.context.decode;
  50959. var components = this.tmpCompsBuf;
  50960. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  50961. var ci = this.readBits(bitsPerComponent);
  50962. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  50963. }
  50964. var color = this.tmpCsCompsBuf;
  50965. if (this.context.colorFn) {
  50966. this.context.colorFn(components, 0, color, 0);
  50967. }
  50968. return this.context.colorSpace.getRgb(color, 0);
  50969. }
  50970. };
  50971. function decodeType4Shading(mesh, reader) {
  50972. var coords = mesh.coords;
  50973. var colors = mesh.colors;
  50974. var operators = [];
  50975. var ps = [];
  50976. var verticesLeft = 0;
  50977. while (reader.hasData) {
  50978. var f = reader.readFlag();
  50979. var coord = reader.readCoordinate();
  50980. var color = reader.readComponents();
  50981. if (verticesLeft === 0) {
  50982. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  50983. switch (f) {
  50984. case 0:
  50985. verticesLeft = 3;
  50986. break;
  50987. case 1:
  50988. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  50989. verticesLeft = 1;
  50990. break;
  50991. case 2:
  50992. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  50993. verticesLeft = 1;
  50994. break;
  50995. }
  50996. operators.push(f);
  50997. }
  50998. ps.push(coords.length);
  50999. coords.push(coord);
  51000. colors.push(color);
  51001. verticesLeft--;
  51002. reader.align();
  51003. }
  51004. mesh.figures.push({
  51005. type: 'triangles',
  51006. coords: new Int32Array(ps),
  51007. colors: new Int32Array(ps)
  51008. });
  51009. }
  51010. function decodeType5Shading(mesh, reader, verticesPerRow) {
  51011. var coords = mesh.coords;
  51012. var colors = mesh.colors;
  51013. var ps = [];
  51014. while (reader.hasData) {
  51015. var coord = reader.readCoordinate();
  51016. var color = reader.readComponents();
  51017. ps.push(coords.length);
  51018. coords.push(coord);
  51019. colors.push(color);
  51020. }
  51021. mesh.figures.push({
  51022. type: 'lattice',
  51023. coords: new Int32Array(ps),
  51024. colors: new Int32Array(ps),
  51025. verticesPerRow: verticesPerRow
  51026. });
  51027. }
  51028. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  51029. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  51030. var TRIANGLE_DENSITY = 20;
  51031. var getB = function getBClosure() {
  51032. function buildB(count) {
  51033. var lut = [];
  51034. for (var i = 0; i <= count; i++) {
  51035. var t = i / count, t_ = 1 - t;
  51036. lut.push(new Float32Array([
  51037. t_ * t_ * t_,
  51038. 3 * t * t_ * t_,
  51039. 3 * t * t * t_,
  51040. t * t * t
  51041. ]));
  51042. }
  51043. return lut;
  51044. }
  51045. var cache = [];
  51046. return function getB(count) {
  51047. if (!cache[count]) {
  51048. cache[count] = buildB(count);
  51049. }
  51050. return cache[count];
  51051. };
  51052. }();
  51053. function buildFigureFromPatch(mesh, index) {
  51054. var figure = mesh.figures[index];
  51055. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  51056. var coords = mesh.coords, colors = mesh.colors;
  51057. var pi = figure.coords;
  51058. var ci = figure.colors;
  51059. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  51060. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  51061. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  51062. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  51063. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  51064. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  51065. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  51066. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  51067. var verticesPerRow = splitXBy + 1;
  51068. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  51069. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  51070. var k = 0;
  51071. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  51072. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  51073. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  51074. for (var row = 0; row <= splitYBy; row++) {
  51075. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  51076. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  51077. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  51078. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  51079. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  51080. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  51081. for (var col = 0; col <= splitXBy; col++, k++) {
  51082. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  51083. continue;
  51084. }
  51085. var x = 0, y = 0;
  51086. var q = 0;
  51087. for (var i = 0; i <= 3; i++) {
  51088. for (var j = 0; j <= 3; j++, q++) {
  51089. var m = bRow[row][i] * bCol[col][j];
  51090. x += coords[pi[q]][0] * m;
  51091. y += coords[pi[q]][1] * m;
  51092. }
  51093. }
  51094. figureCoords[k] = coords.length;
  51095. coords.push([
  51096. x,
  51097. y
  51098. ]);
  51099. figureColors[k] = colors.length;
  51100. var newColor = new Uint8Array(3);
  51101. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  51102. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  51103. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  51104. colors.push(newColor);
  51105. }
  51106. }
  51107. figureCoords[0] = pi[0];
  51108. figureColors[0] = ci[0];
  51109. figureCoords[splitXBy] = pi[3];
  51110. figureColors[splitXBy] = ci[1];
  51111. figureCoords[verticesPerRow * splitYBy] = pi[12];
  51112. figureColors[verticesPerRow * splitYBy] = ci[2];
  51113. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  51114. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  51115. mesh.figures[index] = {
  51116. type: 'lattice',
  51117. coords: figureCoords,
  51118. colors: figureColors,
  51119. verticesPerRow: verticesPerRow
  51120. };
  51121. }
  51122. function decodeType6Shading(mesh, reader) {
  51123. var coords = mesh.coords;
  51124. var colors = mesh.colors;
  51125. var ps = new Int32Array(16);
  51126. var cs = new Int32Array(4);
  51127. while (reader.hasData) {
  51128. var f = reader.readFlag();
  51129. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  51130. var i, ii;
  51131. var pi = coords.length;
  51132. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  51133. coords.push(reader.readCoordinate());
  51134. }
  51135. var ci = colors.length;
  51136. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  51137. colors.push(reader.readComponents());
  51138. }
  51139. var tmp1, tmp2, tmp3, tmp4;
  51140. switch (f) {
  51141. case 0:
  51142. ps[12] = pi + 3;
  51143. ps[13] = pi + 4;
  51144. ps[14] = pi + 5;
  51145. ps[15] = pi + 6;
  51146. ps[8] = pi + 2;
  51147. ps[11] = pi + 7;
  51148. ps[4] = pi + 1;
  51149. ps[7] = pi + 8;
  51150. ps[0] = pi;
  51151. ps[1] = pi + 11;
  51152. ps[2] = pi + 10;
  51153. ps[3] = pi + 9;
  51154. cs[2] = ci + 1;
  51155. cs[3] = ci + 2;
  51156. cs[0] = ci;
  51157. cs[1] = ci + 3;
  51158. break;
  51159. case 1:
  51160. tmp1 = ps[12];
  51161. tmp2 = ps[13];
  51162. tmp3 = ps[14];
  51163. tmp4 = ps[15];
  51164. ps[12] = tmp4;
  51165. ps[13] = pi + 0;
  51166. ps[14] = pi + 1;
  51167. ps[15] = pi + 2;
  51168. ps[8] = tmp3;
  51169. ps[11] = pi + 3;
  51170. ps[4] = tmp2;
  51171. ps[7] = pi + 4;
  51172. ps[0] = tmp1;
  51173. ps[1] = pi + 7;
  51174. ps[2] = pi + 6;
  51175. ps[3] = pi + 5;
  51176. tmp1 = cs[2];
  51177. tmp2 = cs[3];
  51178. cs[2] = tmp2;
  51179. cs[3] = ci;
  51180. cs[0] = tmp1;
  51181. cs[1] = ci + 1;
  51182. break;
  51183. case 2:
  51184. tmp1 = ps[15];
  51185. tmp2 = ps[11];
  51186. ps[12] = ps[3];
  51187. ps[13] = pi + 0;
  51188. ps[14] = pi + 1;
  51189. ps[15] = pi + 2;
  51190. ps[8] = ps[7];
  51191. ps[11] = pi + 3;
  51192. ps[4] = tmp2;
  51193. ps[7] = pi + 4;
  51194. ps[0] = tmp1;
  51195. ps[1] = pi + 7;
  51196. ps[2] = pi + 6;
  51197. ps[3] = pi + 5;
  51198. tmp1 = cs[3];
  51199. cs[2] = cs[1];
  51200. cs[3] = ci;
  51201. cs[0] = tmp1;
  51202. cs[1] = ci + 1;
  51203. break;
  51204. case 3:
  51205. ps[12] = ps[0];
  51206. ps[13] = pi + 0;
  51207. ps[14] = pi + 1;
  51208. ps[15] = pi + 2;
  51209. ps[8] = ps[1];
  51210. ps[11] = pi + 3;
  51211. ps[4] = ps[2];
  51212. ps[7] = pi + 4;
  51213. ps[0] = ps[3];
  51214. ps[1] = pi + 7;
  51215. ps[2] = pi + 6;
  51216. ps[3] = pi + 5;
  51217. cs[2] = cs[0];
  51218. cs[3] = ci;
  51219. cs[0] = cs[1];
  51220. cs[1] = ci + 1;
  51221. break;
  51222. }
  51223. ps[5] = coords.length;
  51224. coords.push([
  51225. (-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,
  51226. (-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
  51227. ]);
  51228. ps[6] = coords.length;
  51229. coords.push([
  51230. (-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,
  51231. (-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
  51232. ]);
  51233. ps[9] = coords.length;
  51234. coords.push([
  51235. (-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,
  51236. (-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
  51237. ]);
  51238. ps[10] = coords.length;
  51239. coords.push([
  51240. (-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,
  51241. (-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
  51242. ]);
  51243. mesh.figures.push({
  51244. type: 'patch',
  51245. coords: new Int32Array(ps),
  51246. colors: new Int32Array(cs)
  51247. });
  51248. }
  51249. }
  51250. function decodeType7Shading(mesh, reader) {
  51251. var coords = mesh.coords;
  51252. var colors = mesh.colors;
  51253. var ps = new Int32Array(16);
  51254. var cs = new Int32Array(4);
  51255. while (reader.hasData) {
  51256. var f = reader.readFlag();
  51257. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  51258. var i, ii;
  51259. var pi = coords.length;
  51260. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  51261. coords.push(reader.readCoordinate());
  51262. }
  51263. var ci = colors.length;
  51264. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  51265. colors.push(reader.readComponents());
  51266. }
  51267. var tmp1, tmp2, tmp3, tmp4;
  51268. switch (f) {
  51269. case 0:
  51270. ps[12] = pi + 3;
  51271. ps[13] = pi + 4;
  51272. ps[14] = pi + 5;
  51273. ps[15] = pi + 6;
  51274. ps[8] = pi + 2;
  51275. ps[9] = pi + 13;
  51276. ps[10] = pi + 14;
  51277. ps[11] = pi + 7;
  51278. ps[4] = pi + 1;
  51279. ps[5] = pi + 12;
  51280. ps[6] = pi + 15;
  51281. ps[7] = pi + 8;
  51282. ps[0] = pi;
  51283. ps[1] = pi + 11;
  51284. ps[2] = pi + 10;
  51285. ps[3] = pi + 9;
  51286. cs[2] = ci + 1;
  51287. cs[3] = ci + 2;
  51288. cs[0] = ci;
  51289. cs[1] = ci + 3;
  51290. break;
  51291. case 1:
  51292. tmp1 = ps[12];
  51293. tmp2 = ps[13];
  51294. tmp3 = ps[14];
  51295. tmp4 = ps[15];
  51296. ps[12] = tmp4;
  51297. ps[13] = pi + 0;
  51298. ps[14] = pi + 1;
  51299. ps[15] = pi + 2;
  51300. ps[8] = tmp3;
  51301. ps[9] = pi + 9;
  51302. ps[10] = pi + 10;
  51303. ps[11] = pi + 3;
  51304. ps[4] = tmp2;
  51305. ps[5] = pi + 8;
  51306. ps[6] = pi + 11;
  51307. ps[7] = pi + 4;
  51308. ps[0] = tmp1;
  51309. ps[1] = pi + 7;
  51310. ps[2] = pi + 6;
  51311. ps[3] = pi + 5;
  51312. tmp1 = cs[2];
  51313. tmp2 = cs[3];
  51314. cs[2] = tmp2;
  51315. cs[3] = ci;
  51316. cs[0] = tmp1;
  51317. cs[1] = ci + 1;
  51318. break;
  51319. case 2:
  51320. tmp1 = ps[15];
  51321. tmp2 = ps[11];
  51322. ps[12] = ps[3];
  51323. ps[13] = pi + 0;
  51324. ps[14] = pi + 1;
  51325. ps[15] = pi + 2;
  51326. ps[8] = ps[7];
  51327. ps[9] = pi + 9;
  51328. ps[10] = pi + 10;
  51329. ps[11] = pi + 3;
  51330. ps[4] = tmp2;
  51331. ps[5] = pi + 8;
  51332. ps[6] = pi + 11;
  51333. ps[7] = pi + 4;
  51334. ps[0] = tmp1;
  51335. ps[1] = pi + 7;
  51336. ps[2] = pi + 6;
  51337. ps[3] = pi + 5;
  51338. tmp1 = cs[3];
  51339. cs[2] = cs[1];
  51340. cs[3] = ci;
  51341. cs[0] = tmp1;
  51342. cs[1] = ci + 1;
  51343. break;
  51344. case 3:
  51345. ps[12] = ps[0];
  51346. ps[13] = pi + 0;
  51347. ps[14] = pi + 1;
  51348. ps[15] = pi + 2;
  51349. ps[8] = ps[1];
  51350. ps[9] = pi + 9;
  51351. ps[10] = pi + 10;
  51352. ps[11] = pi + 3;
  51353. ps[4] = ps[2];
  51354. ps[5] = pi + 8;
  51355. ps[6] = pi + 11;
  51356. ps[7] = pi + 4;
  51357. ps[0] = ps[3];
  51358. ps[1] = pi + 7;
  51359. ps[2] = pi + 6;
  51360. ps[3] = pi + 5;
  51361. cs[2] = cs[0];
  51362. cs[3] = ci;
  51363. cs[0] = cs[1];
  51364. cs[1] = ci + 1;
  51365. break;
  51366. }
  51367. mesh.figures.push({
  51368. type: 'patch',
  51369. coords: new Int32Array(ps),
  51370. colors: new Int32Array(cs)
  51371. });
  51372. }
  51373. }
  51374. function updateBounds(mesh) {
  51375. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  51376. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  51377. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  51378. minX = minX > x ? x : minX;
  51379. minY = minY > y ? y : minY;
  51380. maxX = maxX < x ? x : maxX;
  51381. maxY = maxY < y ? y : maxY;
  51382. }
  51383. mesh.bounds = [
  51384. minX,
  51385. minY,
  51386. maxX,
  51387. maxY
  51388. ];
  51389. }
  51390. function packData(mesh) {
  51391. var i, ii, j, jj;
  51392. var coords = mesh.coords;
  51393. var coordsPacked = new Float32Array(coords.length * 2);
  51394. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  51395. var xy = coords[i];
  51396. coordsPacked[j++] = xy[0];
  51397. coordsPacked[j++] = xy[1];
  51398. }
  51399. mesh.coords = coordsPacked;
  51400. var colors = mesh.colors;
  51401. var colorsPacked = new Uint8Array(colors.length * 3);
  51402. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  51403. var c = colors[i];
  51404. colorsPacked[j++] = c[0];
  51405. colorsPacked[j++] = c[1];
  51406. colorsPacked[j++] = c[2];
  51407. }
  51408. mesh.colors = colorsPacked;
  51409. var figures = mesh.figures;
  51410. for (i = 0, ii = figures.length; i < ii; i++) {
  51411. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  51412. for (j = 0, jj = ps.length; j < jj; j++) {
  51413. ps[j] *= 2;
  51414. cs[j] *= 3;
  51415. }
  51416. }
  51417. }
  51418. function Mesh(stream, matrix, xref, res) {
  51419. assert(isStream(stream), 'Mesh data is not a stream');
  51420. var dict = stream.dict;
  51421. this.matrix = matrix;
  51422. this.shadingType = dict.get('ShadingType');
  51423. this.type = 'Pattern';
  51424. this.bbox = dict.getArray('BBox');
  51425. var cs = dict.get('ColorSpace', 'CS');
  51426. cs = ColorSpace.parse(cs, xref, res);
  51427. this.cs = cs;
  51428. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  51429. var fnObj = dict.get('Function');
  51430. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  51431. this.coords = [];
  51432. this.colors = [];
  51433. this.figures = [];
  51434. var decodeContext = {
  51435. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  51436. bitsPerComponent: dict.get('BitsPerComponent'),
  51437. bitsPerFlag: dict.get('BitsPerFlag'),
  51438. decode: dict.getArray('Decode'),
  51439. colorFn: fn,
  51440. colorSpace: cs,
  51441. numComps: fn ? 1 : cs.numComps
  51442. };
  51443. var reader = new MeshStreamReader(stream, decodeContext);
  51444. var patchMesh = false;
  51445. switch (this.shadingType) {
  51446. case ShadingType.FREE_FORM_MESH:
  51447. decodeType4Shading(this, reader);
  51448. break;
  51449. case ShadingType.LATTICE_FORM_MESH:
  51450. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  51451. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  51452. decodeType5Shading(this, reader, verticesPerRow);
  51453. break;
  51454. case ShadingType.COONS_PATCH_MESH:
  51455. decodeType6Shading(this, reader);
  51456. patchMesh = true;
  51457. break;
  51458. case ShadingType.TENSOR_PATCH_MESH:
  51459. decodeType7Shading(this, reader);
  51460. patchMesh = true;
  51461. break;
  51462. default:
  51463. error('Unsupported mesh type.');
  51464. break;
  51465. }
  51466. if (patchMesh) {
  51467. updateBounds(this);
  51468. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  51469. buildFigureFromPatch(this, i);
  51470. }
  51471. }
  51472. updateBounds(this);
  51473. packData(this);
  51474. }
  51475. Mesh.prototype = {
  51476. getIR: function Mesh_getIR() {
  51477. return [
  51478. 'Mesh',
  51479. this.shadingType,
  51480. this.coords,
  51481. this.colors,
  51482. this.figures,
  51483. this.bounds,
  51484. this.matrix,
  51485. this.bbox,
  51486. this.background
  51487. ];
  51488. }
  51489. };
  51490. return Mesh;
  51491. }();
  51492. Shadings.Dummy = function DummyClosure() {
  51493. function Dummy() {
  51494. this.type = 'Pattern';
  51495. }
  51496. Dummy.prototype = {
  51497. getIR: function Dummy_getIR() {
  51498. return ['Dummy'];
  51499. }
  51500. };
  51501. return Dummy;
  51502. }();
  51503. function getTilingPatternIR(operatorList, dict, args) {
  51504. var matrix = dict.getArray('Matrix');
  51505. var bbox = dict.getArray('BBox');
  51506. var xstep = dict.get('XStep');
  51507. var ystep = dict.get('YStep');
  51508. var paintType = dict.get('PaintType');
  51509. var tilingType = dict.get('TilingType');
  51510. return [
  51511. 'TilingPattern',
  51512. args,
  51513. operatorList,
  51514. matrix,
  51515. bbox,
  51516. xstep,
  51517. ystep,
  51518. paintType,
  51519. tilingType
  51520. ];
  51521. }
  51522. exports.Pattern = Pattern;
  51523. exports.getTilingPatternIR = getTilingPatternIR;
  51524. }));
  51525. (function (root, factory) {
  51526. factory(root.pdfjsCoreEvaluator = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreParser, root.pdfjsCoreImage, root.pdfjsCoreColorSpace, root.pdfjsCoreMurmurHash3, root.pdfjsCoreFonts, root.pdfjsCoreFunction, root.pdfjsCorePattern, root.pdfjsCoreCMap, root.pdfjsCoreMetrics, root.pdfjsCoreBidi, root.pdfjsCoreEncodings, root.pdfjsCoreStandardFonts, root.pdfjsCoreUnicode, root.pdfjsCoreGlyphList);
  51527. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser, coreImage, coreColorSpace, coreMurmurHash3, coreFonts, coreFunction, corePattern, coreCMap, coreMetrics, coreBidi, coreEncodings, coreStandardFonts, coreUnicode, coreGlyphList) {
  51528. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  51529. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  51530. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  51531. var ImageKind = sharedUtil.ImageKind;
  51532. var OPS = sharedUtil.OPS;
  51533. var TextRenderingMode = sharedUtil.TextRenderingMode;
  51534. var Util = sharedUtil.Util;
  51535. var assert = sharedUtil.assert;
  51536. var createPromiseCapability = sharedUtil.createPromiseCapability;
  51537. var error = sharedUtil.error;
  51538. var info = sharedUtil.info;
  51539. var isArray = sharedUtil.isArray;
  51540. var isNum = sharedUtil.isNum;
  51541. var isString = sharedUtil.isString;
  51542. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  51543. var warn = sharedUtil.warn;
  51544. var Dict = corePrimitives.Dict;
  51545. var Name = corePrimitives.Name;
  51546. var isCmd = corePrimitives.isCmd;
  51547. var isDict = corePrimitives.isDict;
  51548. var isName = corePrimitives.isName;
  51549. var isRef = corePrimitives.isRef;
  51550. var isStream = corePrimitives.isStream;
  51551. var DecodeStream = coreStream.DecodeStream;
  51552. var JpegStream = coreStream.JpegStream;
  51553. var Stream = coreStream.Stream;
  51554. var Lexer = coreParser.Lexer;
  51555. var Parser = coreParser.Parser;
  51556. var isEOF = coreParser.isEOF;
  51557. var PDFImage = coreImage.PDFImage;
  51558. var ColorSpace = coreColorSpace.ColorSpace;
  51559. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  51560. var ErrorFont = coreFonts.ErrorFont;
  51561. var FontFlags = coreFonts.FontFlags;
  51562. var Font = coreFonts.Font;
  51563. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  51564. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  51565. var getFontType = coreFonts.getFontType;
  51566. var isPDFFunction = coreFunction.isPDFFunction;
  51567. var PDFFunction = coreFunction.PDFFunction;
  51568. var Pattern = corePattern.Pattern;
  51569. var getTilingPatternIR = corePattern.getTilingPatternIR;
  51570. var CMapFactory = coreCMap.CMapFactory;
  51571. var IdentityCMap = coreCMap.IdentityCMap;
  51572. var getMetrics = coreMetrics.getMetrics;
  51573. var bidi = coreBidi.bidi;
  51574. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  51575. var StandardEncoding = coreEncodings.StandardEncoding;
  51576. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  51577. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  51578. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  51579. var getEncoding = coreEncodings.getEncoding;
  51580. var getStdFontMap = coreStandardFonts.getStdFontMap;
  51581. var getSerifFonts = coreStandardFonts.getSerifFonts;
  51582. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  51583. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  51584. var reverseIfRtl = coreUnicode.reverseIfRtl;
  51585. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  51586. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  51587. var PartialEvaluator = function PartialEvaluatorClosure() {
  51588. var DefaultPartialEvaluatorOptions = {
  51589. forceDataSchema: false,
  51590. maxImageSize: -1,
  51591. disableFontFace: false,
  51592. cMapOptions: {
  51593. url: null,
  51594. packed: false
  51595. }
  51596. };
  51597. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  51598. this.xref = xref;
  51599. this.resources = resources;
  51600. this.handler = handler;
  51601. this.forceDataSchema = forceDataSchema;
  51602. }
  51603. NativeImageDecoder.prototype = {
  51604. canDecode: function (image) {
  51605. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  51606. },
  51607. decode: function (image) {
  51608. var dict = image.dict;
  51609. var colorSpace = dict.get('ColorSpace', 'CS');
  51610. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  51611. var numComps = colorSpace.numComps;
  51612. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  51613. image.getIR(this.forceDataSchema),
  51614. numComps
  51615. ]);
  51616. return decodePromise.then(function (message) {
  51617. var data = message.data;
  51618. return new Stream(data, 0, data.length, image.dict);
  51619. });
  51620. }
  51621. };
  51622. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  51623. var dict = image.dict;
  51624. if (dict.has('DecodeParms') || dict.has('DP')) {
  51625. return false;
  51626. }
  51627. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  51628. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  51629. };
  51630. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  51631. var dict = image.dict;
  51632. if (dict.has('DecodeParms') || dict.has('DP')) {
  51633. return false;
  51634. }
  51635. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  51636. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  51637. };
  51638. function PartialEvaluator(pdfManager, xref, handler, pageIndex, uniquePrefix, idCounters, fontCache, options) {
  51639. this.pdfManager = pdfManager;
  51640. this.xref = xref;
  51641. this.handler = handler;
  51642. this.pageIndex = pageIndex;
  51643. this.uniquePrefix = uniquePrefix;
  51644. this.idCounters = idCounters;
  51645. this.fontCache = fontCache;
  51646. this.options = options || DefaultPartialEvaluatorOptions;
  51647. }
  51648. var TIME_SLOT_DURATION_MS = 20;
  51649. var CHECK_TIME_EVERY = 100;
  51650. function TimeSlotManager() {
  51651. this.reset();
  51652. }
  51653. TimeSlotManager.prototype = {
  51654. check: function TimeSlotManager_check() {
  51655. if (++this.checked < CHECK_TIME_EVERY) {
  51656. return false;
  51657. }
  51658. this.checked = 0;
  51659. return this.endTime <= Date.now();
  51660. },
  51661. reset: function TimeSlotManager_reset() {
  51662. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  51663. this.checked = 0;
  51664. }
  51665. };
  51666. var deferred = Promise.resolve();
  51667. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  51668. PartialEvaluator.prototype = {
  51669. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  51670. if (!isDict(resources)) {
  51671. return false;
  51672. }
  51673. var processed = Object.create(null);
  51674. if (resources.objId) {
  51675. processed[resources.objId] = true;
  51676. }
  51677. var nodes = [resources], xref = this.xref;
  51678. while (nodes.length) {
  51679. var key, i, ii;
  51680. var node = nodes.shift();
  51681. var graphicStates = node.get('ExtGState');
  51682. if (isDict(graphicStates)) {
  51683. var graphicStatesKeys = graphicStates.getKeys();
  51684. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  51685. key = graphicStatesKeys[i];
  51686. var graphicState = graphicStates.get(key);
  51687. var bm = graphicState.get('BM');
  51688. if (isName(bm) && bm.name !== 'Normal') {
  51689. return true;
  51690. }
  51691. }
  51692. }
  51693. var xObjects = node.get('XObject');
  51694. if (!isDict(xObjects)) {
  51695. continue;
  51696. }
  51697. var xObjectsKeys = xObjects.getKeys();
  51698. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  51699. key = xObjectsKeys[i];
  51700. var xObject = xObjects.getRaw(key);
  51701. if (isRef(xObject)) {
  51702. if (processed[xObject.toString()]) {
  51703. continue;
  51704. }
  51705. xObject = xref.fetch(xObject);
  51706. }
  51707. if (!isStream(xObject)) {
  51708. continue;
  51709. }
  51710. if (xObject.dict.objId) {
  51711. if (processed[xObject.dict.objId]) {
  51712. continue;
  51713. }
  51714. processed[xObject.dict.objId] = true;
  51715. }
  51716. var xResources = xObject.dict.get('Resources');
  51717. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  51718. nodes.push(xResources);
  51719. if (xResources.objId) {
  51720. processed[xResources.objId] = true;
  51721. }
  51722. }
  51723. }
  51724. }
  51725. return false;
  51726. },
  51727. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  51728. var matrix = xobj.dict.getArray('Matrix');
  51729. var bbox = xobj.dict.getArray('BBox');
  51730. var group = xobj.dict.get('Group');
  51731. if (group) {
  51732. var groupOptions = {
  51733. matrix: matrix,
  51734. bbox: bbox,
  51735. smask: smask,
  51736. isolated: false,
  51737. knockout: false
  51738. };
  51739. var groupSubtype = group.get('S');
  51740. var colorSpace;
  51741. if (isName(groupSubtype, 'Transparency')) {
  51742. groupOptions.isolated = group.get('I') || false;
  51743. groupOptions.knockout = group.get('K') || false;
  51744. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  51745. }
  51746. if (smask && smask.backdrop) {
  51747. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  51748. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  51749. }
  51750. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  51751. }
  51752. operatorList.addOp(OPS.paintFormXObjectBegin, [
  51753. matrix,
  51754. bbox
  51755. ]);
  51756. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  51757. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  51758. if (group) {
  51759. operatorList.addOp(OPS.endGroup, [groupOptions]);
  51760. }
  51761. });
  51762. },
  51763. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  51764. var self = this;
  51765. var dict = image.dict;
  51766. var w = dict.get('Width', 'W');
  51767. var h = dict.get('Height', 'H');
  51768. if (!(w && isNum(w)) || !(h && isNum(h))) {
  51769. warn('Image dimensions are missing, or not numbers.');
  51770. return;
  51771. }
  51772. var maxImageSize = this.options.maxImageSize;
  51773. if (maxImageSize !== -1 && w * h > maxImageSize) {
  51774. warn('Image exceeded maximum allowed size and was removed.');
  51775. return;
  51776. }
  51777. var imageMask = dict.get('ImageMask', 'IM') || false;
  51778. var imgData, args;
  51779. if (imageMask) {
  51780. var width = dict.get('Width', 'W');
  51781. var height = dict.get('Height', 'H');
  51782. var bitStrideLength = width + 7 >> 3;
  51783. var imgArray = image.getBytes(bitStrideLength * height);
  51784. var decode = dict.getArray('Decode', 'D');
  51785. var inverseDecode = !!decode && decode[0] > 0;
  51786. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  51787. imgData.cached = true;
  51788. args = [imgData];
  51789. operatorList.addOp(OPS.paintImageMaskXObject, args);
  51790. if (cacheKey) {
  51791. imageCache[cacheKey] = {
  51792. fn: OPS.paintImageMaskXObject,
  51793. args: args
  51794. };
  51795. }
  51796. return;
  51797. }
  51798. var softMask = dict.get('SMask', 'SM') || false;
  51799. var mask = dict.get('Mask') || false;
  51800. var SMALL_IMAGE_DIMENSIONS = 200;
  51801. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  51802. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  51803. imgData = imageObj.createImageData(true);
  51804. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  51805. return;
  51806. }
  51807. var uniquePrefix = this.uniquePrefix || '';
  51808. var objId = 'img_' + uniquePrefix + ++this.idCounters.obj;
  51809. operatorList.addDependency(objId);
  51810. args = [
  51811. objId,
  51812. w,
  51813. h
  51814. ];
  51815. if (!softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  51816. operatorList.addOp(OPS.paintJpegXObject, args);
  51817. this.handler.send('obj', [
  51818. objId,
  51819. this.pageIndex,
  51820. 'JpegStream',
  51821. image.getIR(this.options.forceDataSchema)
  51822. ]);
  51823. return;
  51824. }
  51825. var nativeImageDecoder = null;
  51826. if (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream) {
  51827. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  51828. }
  51829. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  51830. var imgData = imageObj.createImageData(false);
  51831. self.handler.send('obj', [
  51832. objId,
  51833. self.pageIndex,
  51834. 'Image',
  51835. imgData
  51836. ], [imgData.data.buffer]);
  51837. }).then(undefined, function (reason) {
  51838. warn('Unable to decode image: ' + reason);
  51839. self.handler.send('obj', [
  51840. objId,
  51841. self.pageIndex,
  51842. 'Image',
  51843. null
  51844. ]);
  51845. });
  51846. operatorList.addOp(OPS.paintImageXObject, args);
  51847. if (cacheKey) {
  51848. imageCache[cacheKey] = {
  51849. fn: OPS.paintImageXObject,
  51850. args: args
  51851. };
  51852. }
  51853. },
  51854. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  51855. var smaskContent = smask.get('G');
  51856. var smaskOptions = {
  51857. subtype: smask.get('S').name,
  51858. backdrop: smask.get('BC')
  51859. };
  51860. var transferObj = smask.get('TR');
  51861. if (isPDFFunction(transferObj)) {
  51862. var transferFn = PDFFunction.parse(this.xref, transferObj);
  51863. var transferMap = new Uint8Array(256);
  51864. var tmp = new Float32Array(1);
  51865. for (var i = 0; i < 256; i++) {
  51866. tmp[0] = i / 255;
  51867. transferFn(tmp, 0, tmp, 0);
  51868. transferMap[i] = tmp[0] * 255 | 0;
  51869. }
  51870. smaskOptions.transferMap = transferMap;
  51871. }
  51872. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  51873. },
  51874. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  51875. var tilingOpList = new OperatorList();
  51876. var resourcesArray = [
  51877. patternDict.get('Resources'),
  51878. resources
  51879. ];
  51880. var patternResources = Dict.merge(this.xref, resourcesArray);
  51881. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  51882. operatorList.addDependencies(tilingOpList.dependencies);
  51883. operatorList.addOp(fn, getTilingPatternIR({
  51884. fnArray: tilingOpList.fnArray,
  51885. argsArray: tilingOpList.argsArray
  51886. }, patternDict, args));
  51887. });
  51888. },
  51889. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  51890. var fontName;
  51891. if (fontArgs) {
  51892. fontArgs = fontArgs.slice();
  51893. fontName = fontArgs[0].name;
  51894. }
  51895. var self = this;
  51896. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  51897. if (!translated.font.isType3Font) {
  51898. return translated;
  51899. }
  51900. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  51901. return translated;
  51902. }, function (reason) {
  51903. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  51904. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  51905. });
  51906. }).then(function (translated) {
  51907. state.font = translated.font;
  51908. translated.send(self.handler);
  51909. return translated.loadedName;
  51910. });
  51911. },
  51912. handleText: function PartialEvaluator_handleText(chars, state) {
  51913. var font = state.font;
  51914. var glyphs = font.charsToGlyphs(chars);
  51915. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  51916. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  51917. var buildPath = function (fontChar) {
  51918. if (!font.renderer.hasBuiltPath(fontChar)) {
  51919. var path = font.renderer.getPathJs(fontChar);
  51920. this.handler.send('commonobj', [
  51921. font.loadedName + '_path_' + fontChar,
  51922. 'FontPath',
  51923. path
  51924. ]);
  51925. }
  51926. }.bind(this);
  51927. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  51928. var glyph = glyphs[i];
  51929. buildPath(glyph.fontChar);
  51930. var accent = glyph.accent;
  51931. if (accent && accent.fontChar) {
  51932. buildPath(accent.fontChar);
  51933. }
  51934. }
  51935. }
  51936. return glyphs;
  51937. },
  51938. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  51939. var gStateObj = [];
  51940. var gStateKeys = gState.getKeys();
  51941. var self = this;
  51942. var promise = Promise.resolve();
  51943. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  51944. var key = gStateKeys[i];
  51945. var value = gState.get(key);
  51946. switch (key) {
  51947. case 'Type':
  51948. break;
  51949. case 'LW':
  51950. case 'LC':
  51951. case 'LJ':
  51952. case 'ML':
  51953. case 'D':
  51954. case 'RI':
  51955. case 'FL':
  51956. case 'CA':
  51957. case 'ca':
  51958. gStateObj.push([
  51959. key,
  51960. value
  51961. ]);
  51962. break;
  51963. case 'Font':
  51964. promise = promise.then(function () {
  51965. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  51966. operatorList.addDependency(loadedName);
  51967. gStateObj.push([
  51968. key,
  51969. [
  51970. loadedName,
  51971. value[1]
  51972. ]
  51973. ]);
  51974. });
  51975. });
  51976. break;
  51977. case 'BM':
  51978. gStateObj.push([
  51979. key,
  51980. value
  51981. ]);
  51982. break;
  51983. case 'SMask':
  51984. if (isName(value, 'None')) {
  51985. gStateObj.push([
  51986. key,
  51987. false
  51988. ]);
  51989. break;
  51990. }
  51991. if (isDict(value)) {
  51992. promise = promise.then(function (dict) {
  51993. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  51994. }.bind(this, value));
  51995. gStateObj.push([
  51996. key,
  51997. true
  51998. ]);
  51999. } else {
  52000. warn('Unsupported SMask type');
  52001. }
  52002. break;
  52003. case 'OP':
  52004. case 'op':
  52005. case 'OPM':
  52006. case 'BG':
  52007. case 'BG2':
  52008. case 'UCR':
  52009. case 'UCR2':
  52010. case 'TR':
  52011. case 'TR2':
  52012. case 'HT':
  52013. case 'SM':
  52014. case 'SA':
  52015. case 'AIS':
  52016. case 'TK':
  52017. info('graphic state operator ' + key);
  52018. break;
  52019. default:
  52020. info('Unknown graphic state operator ' + key);
  52021. break;
  52022. }
  52023. }
  52024. return promise.then(function () {
  52025. if (gStateObj.length > 0) {
  52026. operatorList.addOp(OPS.setGState, [gStateObj]);
  52027. }
  52028. });
  52029. },
  52030. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  52031. function errorFont() {
  52032. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  52033. }
  52034. var fontRef;
  52035. if (font) {
  52036. assert(isRef(font));
  52037. fontRef = font;
  52038. } else {
  52039. var fontRes = resources.get('Font');
  52040. if (fontRes) {
  52041. fontRef = fontRes.getRaw(fontName);
  52042. } else {
  52043. warn('fontRes not available');
  52044. return errorFont();
  52045. }
  52046. }
  52047. if (!fontRef) {
  52048. warn('fontRef not available');
  52049. return errorFont();
  52050. }
  52051. if (this.fontCache.has(fontRef)) {
  52052. return this.fontCache.get(fontRef);
  52053. }
  52054. font = xref.fetchIfRef(fontRef);
  52055. if (!isDict(font)) {
  52056. return errorFont();
  52057. }
  52058. if (font.translated) {
  52059. return font.translated;
  52060. }
  52061. var fontCapability = createPromiseCapability();
  52062. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  52063. var descriptor = preEvaluatedFont.descriptor;
  52064. var fontRefIsRef = isRef(fontRef), fontID;
  52065. if (fontRefIsRef) {
  52066. fontID = fontRef.toString();
  52067. }
  52068. if (isDict(descriptor)) {
  52069. if (!descriptor.fontAliases) {
  52070. descriptor.fontAliases = Object.create(null);
  52071. }
  52072. var fontAliases = descriptor.fontAliases;
  52073. var hash = preEvaluatedFont.hash;
  52074. if (fontAliases[hash]) {
  52075. var aliasFontRef = fontAliases[hash].aliasRef;
  52076. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  52077. this.fontCache.putAlias(fontRef, aliasFontRef);
  52078. return this.fontCache.get(fontRef);
  52079. }
  52080. } else {
  52081. fontAliases[hash] = { fontID: Font.getFontID() };
  52082. }
  52083. if (fontRefIsRef) {
  52084. fontAliases[hash].aliasRef = fontRef;
  52085. }
  52086. fontID = fontAliases[hash].fontID;
  52087. }
  52088. if (fontRefIsRef) {
  52089. this.fontCache.put(fontRef, fontCapability.promise);
  52090. } else {
  52091. if (!fontID) {
  52092. fontID = (this.uniquePrefix || 'F_') + ++this.idCounters.obj;
  52093. }
  52094. this.fontCache.put('id_' + fontID, fontCapability.promise);
  52095. }
  52096. assert(fontID, 'The "fontID" must be defined.');
  52097. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  52098. font.translated = fontCapability.promise;
  52099. var translatedPromise;
  52100. try {
  52101. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  52102. } catch (e) {
  52103. translatedPromise = Promise.reject(e);
  52104. }
  52105. var self = this;
  52106. translatedPromise.then(function (translatedFont) {
  52107. if (translatedFont.fontType !== undefined) {
  52108. var xrefFontStats = xref.stats.fontTypes;
  52109. xrefFontStats[translatedFont.fontType] = true;
  52110. }
  52111. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  52112. }, function (reason) {
  52113. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  52114. try {
  52115. var descriptor = preEvaluatedFont.descriptor;
  52116. var fontFile3 = descriptor && descriptor.get('FontFile3');
  52117. var subtype = fontFile3 && fontFile3.get('Subtype');
  52118. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  52119. var xrefFontStats = xref.stats.fontTypes;
  52120. xrefFontStats[fontType] = true;
  52121. } catch (ex) {
  52122. }
  52123. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  52124. });
  52125. return fontCapability.promise;
  52126. },
  52127. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  52128. var lastIndex = operatorList.length - 1;
  52129. if (!args) {
  52130. args = [];
  52131. }
  52132. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  52133. operatorList.addOp(OPS.constructPath, [
  52134. [fn],
  52135. args
  52136. ]);
  52137. } else {
  52138. var opArgs = operatorList.argsArray[lastIndex];
  52139. opArgs[0].push(fn);
  52140. Array.prototype.push.apply(opArgs[1], args);
  52141. }
  52142. },
  52143. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  52144. var patternName = args[args.length - 1];
  52145. var pattern;
  52146. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  52147. var dict = isStream(pattern) ? pattern.dict : pattern;
  52148. var typeNum = dict.get('PatternType');
  52149. if (typeNum === TILING_PATTERN) {
  52150. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  52151. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  52152. } else if (typeNum === SHADING_PATTERN) {
  52153. var shading = dict.get('Shading');
  52154. var matrix = dict.getArray('Matrix');
  52155. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  52156. operatorList.addOp(fn, pattern.getIR());
  52157. return Promise.resolve();
  52158. } else {
  52159. return Promise.reject('Unknown PatternType: ' + typeNum);
  52160. }
  52161. }
  52162. operatorList.addOp(fn, args);
  52163. return Promise.resolve();
  52164. },
  52165. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  52166. var self = this;
  52167. var xref = this.xref;
  52168. var imageCache = Object.create(null);
  52169. assert(operatorList);
  52170. resources = resources || Dict.empty;
  52171. var xobjs = resources.get('XObject') || Dict.empty;
  52172. var patterns = resources.get('Pattern') || Dict.empty;
  52173. var stateManager = new StateManager(initialState || new EvalState());
  52174. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  52175. var timeSlotManager = new TimeSlotManager();
  52176. return new Promise(function promiseBody(resolve, reject) {
  52177. var next = function (promise) {
  52178. promise.then(function () {
  52179. try {
  52180. promiseBody(resolve, reject);
  52181. } catch (ex) {
  52182. reject(ex);
  52183. }
  52184. }, reject);
  52185. };
  52186. task.ensureNotTerminated();
  52187. timeSlotManager.reset();
  52188. var stop, operation = {}, i, ii, cs;
  52189. while (!(stop = timeSlotManager.check())) {
  52190. operation.args = null;
  52191. if (!preprocessor.read(operation)) {
  52192. break;
  52193. }
  52194. var args = operation.args;
  52195. var fn = operation.fn;
  52196. switch (fn | 0) {
  52197. case OPS.paintXObject:
  52198. if (args[0].code) {
  52199. break;
  52200. }
  52201. var name = args[0].name;
  52202. if (!name) {
  52203. warn('XObject must be referred to by name.');
  52204. continue;
  52205. }
  52206. if (imageCache[name] !== undefined) {
  52207. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  52208. args = null;
  52209. continue;
  52210. }
  52211. var xobj = xobjs.get(name);
  52212. if (xobj) {
  52213. assert(isStream(xobj), 'XObject should be a stream');
  52214. var type = xobj.dict.get('Subtype');
  52215. assert(isName(type), 'XObject should have a Name subtype');
  52216. if (type.name === 'Form') {
  52217. stateManager.save();
  52218. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  52219. stateManager.restore();
  52220. }));
  52221. return;
  52222. } else if (type.name === 'Image') {
  52223. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  52224. args = null;
  52225. continue;
  52226. } else if (type.name === 'PS') {
  52227. info('Ignored XObject subtype PS');
  52228. continue;
  52229. } else {
  52230. error('Unhandled XObject subtype ' + type.name);
  52231. }
  52232. }
  52233. break;
  52234. case OPS.setFont:
  52235. var fontSize = args[1];
  52236. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  52237. operatorList.addDependency(loadedName);
  52238. operatorList.addOp(OPS.setFont, [
  52239. loadedName,
  52240. fontSize
  52241. ]);
  52242. }));
  52243. return;
  52244. case OPS.endInlineImage:
  52245. var cacheKey = args[0].cacheKey;
  52246. if (cacheKey) {
  52247. var cacheEntry = imageCache[cacheKey];
  52248. if (cacheEntry !== undefined) {
  52249. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  52250. args = null;
  52251. continue;
  52252. }
  52253. }
  52254. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  52255. args = null;
  52256. continue;
  52257. case OPS.showText:
  52258. args[0] = self.handleText(args[0], stateManager.state);
  52259. break;
  52260. case OPS.showSpacedText:
  52261. var arr = args[0];
  52262. var combinedGlyphs = [];
  52263. var arrLength = arr.length;
  52264. var state = stateManager.state;
  52265. for (i = 0; i < arrLength; ++i) {
  52266. var arrItem = arr[i];
  52267. if (isString(arrItem)) {
  52268. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  52269. } else if (isNum(arrItem)) {
  52270. combinedGlyphs.push(arrItem);
  52271. }
  52272. }
  52273. args[0] = combinedGlyphs;
  52274. fn = OPS.showText;
  52275. break;
  52276. case OPS.nextLineShowText:
  52277. operatorList.addOp(OPS.nextLine);
  52278. args[0] = self.handleText(args[0], stateManager.state);
  52279. fn = OPS.showText;
  52280. break;
  52281. case OPS.nextLineSetSpacingShowText:
  52282. operatorList.addOp(OPS.nextLine);
  52283. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  52284. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  52285. args[0] = self.handleText(args[0], stateManager.state);
  52286. fn = OPS.showText;
  52287. break;
  52288. case OPS.setTextRenderingMode:
  52289. stateManager.state.textRenderingMode = args[0];
  52290. break;
  52291. case OPS.setFillColorSpace:
  52292. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  52293. continue;
  52294. case OPS.setStrokeColorSpace:
  52295. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  52296. continue;
  52297. case OPS.setFillColor:
  52298. cs = stateManager.state.fillColorSpace;
  52299. args = cs.getRgb(args, 0);
  52300. fn = OPS.setFillRGBColor;
  52301. break;
  52302. case OPS.setStrokeColor:
  52303. cs = stateManager.state.strokeColorSpace;
  52304. args = cs.getRgb(args, 0);
  52305. fn = OPS.setStrokeRGBColor;
  52306. break;
  52307. case OPS.setFillGray:
  52308. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  52309. args = ColorSpace.singletons.gray.getRgb(args, 0);
  52310. fn = OPS.setFillRGBColor;
  52311. break;
  52312. case OPS.setStrokeGray:
  52313. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  52314. args = ColorSpace.singletons.gray.getRgb(args, 0);
  52315. fn = OPS.setStrokeRGBColor;
  52316. break;
  52317. case OPS.setFillCMYKColor:
  52318. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  52319. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  52320. fn = OPS.setFillRGBColor;
  52321. break;
  52322. case OPS.setStrokeCMYKColor:
  52323. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  52324. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  52325. fn = OPS.setStrokeRGBColor;
  52326. break;
  52327. case OPS.setFillRGBColor:
  52328. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  52329. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  52330. break;
  52331. case OPS.setStrokeRGBColor:
  52332. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  52333. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  52334. break;
  52335. case OPS.setFillColorN:
  52336. cs = stateManager.state.fillColorSpace;
  52337. if (cs.name === 'Pattern') {
  52338. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  52339. return;
  52340. }
  52341. args = cs.getRgb(args, 0);
  52342. fn = OPS.setFillRGBColor;
  52343. break;
  52344. case OPS.setStrokeColorN:
  52345. cs = stateManager.state.strokeColorSpace;
  52346. if (cs.name === 'Pattern') {
  52347. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  52348. return;
  52349. }
  52350. args = cs.getRgb(args, 0);
  52351. fn = OPS.setStrokeRGBColor;
  52352. break;
  52353. case OPS.shadingFill:
  52354. var shadingRes = resources.get('Shading');
  52355. if (!shadingRes) {
  52356. error('No shading resource found');
  52357. }
  52358. var shading = shadingRes.get(args[0].name);
  52359. if (!shading) {
  52360. error('No shading object found');
  52361. }
  52362. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  52363. var patternIR = shadingFill.getIR();
  52364. args = [patternIR];
  52365. fn = OPS.shadingFill;
  52366. break;
  52367. case OPS.setGState:
  52368. var dictName = args[0];
  52369. var extGState = resources.get('ExtGState');
  52370. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  52371. break;
  52372. }
  52373. var gState = extGState.get(dictName.name);
  52374. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  52375. return;
  52376. case OPS.moveTo:
  52377. case OPS.lineTo:
  52378. case OPS.curveTo:
  52379. case OPS.curveTo2:
  52380. case OPS.curveTo3:
  52381. case OPS.closePath:
  52382. self.buildPath(operatorList, fn, args);
  52383. continue;
  52384. case OPS.rectangle:
  52385. self.buildPath(operatorList, fn, args);
  52386. continue;
  52387. case OPS.markPoint:
  52388. case OPS.markPointProps:
  52389. case OPS.beginMarkedContent:
  52390. case OPS.beginMarkedContentProps:
  52391. case OPS.endMarkedContent:
  52392. case OPS.beginCompat:
  52393. case OPS.endCompat:
  52394. continue;
  52395. default:
  52396. if (args !== null) {
  52397. for (i = 0, ii = args.length; i < ii; i++) {
  52398. if (args[i] instanceof Dict) {
  52399. break;
  52400. }
  52401. }
  52402. if (i < ii) {
  52403. warn('getOperatorList - ignoring operator: ' + fn);
  52404. continue;
  52405. }
  52406. }
  52407. }
  52408. operatorList.addOp(fn, args);
  52409. }
  52410. if (stop) {
  52411. next(deferred);
  52412. return;
  52413. }
  52414. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  52415. operatorList.addOp(OPS.restore, []);
  52416. }
  52417. resolve();
  52418. });
  52419. },
  52420. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  52421. stateManager = stateManager || new StateManager(new TextState());
  52422. var WhitespaceRegexp = /\s/g;
  52423. var textContent = {
  52424. items: [],
  52425. styles: Object.create(null)
  52426. };
  52427. var textContentItem = {
  52428. initialized: false,
  52429. str: [],
  52430. width: 0,
  52431. height: 0,
  52432. vertical: false,
  52433. lastAdvanceWidth: 0,
  52434. lastAdvanceHeight: 0,
  52435. textAdvanceScale: 0,
  52436. spaceWidth: 0,
  52437. fakeSpaceMin: Infinity,
  52438. fakeMultiSpaceMin: Infinity,
  52439. fakeMultiSpaceMax: -0,
  52440. textRunBreakAllowed: false,
  52441. transform: null,
  52442. fontName: null
  52443. };
  52444. var SPACE_FACTOR = 0.3;
  52445. var MULTI_SPACE_FACTOR = 1.5;
  52446. var MULTI_SPACE_FACTOR_MAX = 4;
  52447. var self = this;
  52448. var xref = this.xref;
  52449. resources = xref.fetchIfRef(resources) || Dict.empty;
  52450. var xobjs = null;
  52451. var xobjsCache = Object.create(null);
  52452. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  52453. var textState;
  52454. function ensureTextContentItem() {
  52455. if (textContentItem.initialized) {
  52456. return textContentItem;
  52457. }
  52458. var font = textState.font;
  52459. if (!(font.loadedName in textContent.styles)) {
  52460. textContent.styles[font.loadedName] = {
  52461. fontFamily: font.fallbackName,
  52462. ascent: font.ascent,
  52463. descent: font.descent,
  52464. vertical: font.vertical
  52465. };
  52466. }
  52467. textContentItem.fontName = font.loadedName;
  52468. var tsm = [
  52469. textState.fontSize * textState.textHScale,
  52470. 0,
  52471. 0,
  52472. textState.fontSize,
  52473. 0,
  52474. textState.textRise
  52475. ];
  52476. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  52477. var glyphHeight = font.bbox[3] - font.bbox[1];
  52478. if (glyphHeight > 0) {
  52479. glyphHeight = glyphHeight * textState.fontMatrix[3];
  52480. tsm[3] *= glyphHeight;
  52481. }
  52482. }
  52483. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  52484. textContentItem.transform = trm;
  52485. if (!font.vertical) {
  52486. textContentItem.width = 0;
  52487. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  52488. textContentItem.vertical = false;
  52489. } else {
  52490. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  52491. textContentItem.height = 0;
  52492. textContentItem.vertical = true;
  52493. }
  52494. var a = textState.textLineMatrix[0];
  52495. var b = textState.textLineMatrix[1];
  52496. var scaleLineX = Math.sqrt(a * a + b * b);
  52497. a = textState.ctm[0];
  52498. b = textState.ctm[1];
  52499. var scaleCtmX = Math.sqrt(a * a + b * b);
  52500. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  52501. textContentItem.lastAdvanceWidth = 0;
  52502. textContentItem.lastAdvanceHeight = 0;
  52503. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  52504. if (spaceWidth) {
  52505. textContentItem.spaceWidth = spaceWidth;
  52506. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  52507. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  52508. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  52509. textContentItem.textRunBreakAllowed = !font.isMonospace;
  52510. } else {
  52511. textContentItem.spaceWidth = 0;
  52512. textContentItem.fakeSpaceMin = Infinity;
  52513. textContentItem.fakeMultiSpaceMin = Infinity;
  52514. textContentItem.fakeMultiSpaceMax = 0;
  52515. textContentItem.textRunBreakAllowed = false;
  52516. }
  52517. textContentItem.initialized = true;
  52518. return textContentItem;
  52519. }
  52520. function replaceWhitespace(str) {
  52521. var i = 0, ii = str.length, code;
  52522. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  52523. i++;
  52524. }
  52525. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  52526. }
  52527. function runBidiTransform(textChunk) {
  52528. var str = textChunk.str.join('');
  52529. var bidiResult = bidi(str, -1, textChunk.vertical);
  52530. return {
  52531. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  52532. dir: bidiResult.dir,
  52533. width: textChunk.width,
  52534. height: textChunk.height,
  52535. transform: textChunk.transform,
  52536. fontName: textChunk.fontName
  52537. };
  52538. }
  52539. function handleSetFont(fontName, fontRef) {
  52540. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  52541. textState.font = translated.font;
  52542. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  52543. });
  52544. }
  52545. function buildTextContentItem(chars) {
  52546. var font = textState.font;
  52547. var textChunk = ensureTextContentItem();
  52548. var width = 0;
  52549. var height = 0;
  52550. var glyphs = font.charsToGlyphs(chars);
  52551. var defaultVMetrics = font.defaultVMetrics;
  52552. for (var i = 0; i < glyphs.length; i++) {
  52553. var glyph = glyphs[i];
  52554. var vMetricX = null;
  52555. var vMetricY = null;
  52556. var glyphWidth = null;
  52557. if (font.vertical) {
  52558. if (glyph.vmetric) {
  52559. glyphWidth = glyph.vmetric[0];
  52560. vMetricX = glyph.vmetric[1];
  52561. vMetricY = glyph.vmetric[2];
  52562. } else {
  52563. glyphWidth = glyph.width;
  52564. vMetricX = glyph.width * 0.5;
  52565. vMetricY = defaultVMetrics[2];
  52566. }
  52567. } else {
  52568. glyphWidth = glyph.width;
  52569. }
  52570. var glyphUnicode = glyph.unicode;
  52571. var NormalizedUnicodes = getNormalizedUnicodes();
  52572. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  52573. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  52574. }
  52575. glyphUnicode = reverseIfRtl(glyphUnicode);
  52576. var charSpacing = textState.charSpacing;
  52577. if (glyph.isSpace) {
  52578. var wordSpacing = textState.wordSpacing;
  52579. charSpacing += wordSpacing;
  52580. if (wordSpacing > 0) {
  52581. addFakeSpaces(wordSpacing, textChunk.str);
  52582. }
  52583. }
  52584. var tx = 0;
  52585. var ty = 0;
  52586. if (!font.vertical) {
  52587. var w0 = glyphWidth * textState.fontMatrix[0];
  52588. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  52589. width += tx;
  52590. } else {
  52591. var w1 = glyphWidth * textState.fontMatrix[0];
  52592. ty = w1 * textState.fontSize + charSpacing;
  52593. height += ty;
  52594. }
  52595. textState.translateTextMatrix(tx, ty);
  52596. textChunk.str.push(glyphUnicode);
  52597. }
  52598. if (!font.vertical) {
  52599. textChunk.lastAdvanceWidth = width;
  52600. textChunk.width += width * textChunk.textAdvanceScale;
  52601. } else {
  52602. textChunk.lastAdvanceHeight = height;
  52603. textChunk.height += Math.abs(height * textChunk.textAdvanceScale);
  52604. }
  52605. return textChunk;
  52606. }
  52607. function addFakeSpaces(width, strBuf) {
  52608. if (width < textContentItem.fakeSpaceMin) {
  52609. return;
  52610. }
  52611. if (width < textContentItem.fakeMultiSpaceMin) {
  52612. strBuf.push(' ');
  52613. return;
  52614. }
  52615. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  52616. while (fakeSpaces-- > 0) {
  52617. strBuf.push(' ');
  52618. }
  52619. }
  52620. function flushTextContentItem() {
  52621. if (!textContentItem.initialized) {
  52622. return;
  52623. }
  52624. textContent.items.push(runBidiTransform(textContentItem));
  52625. textContentItem.initialized = false;
  52626. textContentItem.str.length = 0;
  52627. }
  52628. var timeSlotManager = new TimeSlotManager();
  52629. return new Promise(function promiseBody(resolve, reject) {
  52630. var next = function (promise) {
  52631. promise.then(function () {
  52632. try {
  52633. promiseBody(resolve, reject);
  52634. } catch (ex) {
  52635. reject(ex);
  52636. }
  52637. }, reject);
  52638. };
  52639. task.ensureNotTerminated();
  52640. timeSlotManager.reset();
  52641. var stop, operation = {}, args = [];
  52642. while (!(stop = timeSlotManager.check())) {
  52643. args.length = 0;
  52644. operation.args = args;
  52645. if (!preprocessor.read(operation)) {
  52646. break;
  52647. }
  52648. textState = stateManager.state;
  52649. var fn = operation.fn;
  52650. args = operation.args;
  52651. var advance, diff;
  52652. switch (fn | 0) {
  52653. case OPS.setFont:
  52654. var fontNameArg = args[0].name, fontSizeArg = args[1];
  52655. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  52656. break;
  52657. }
  52658. flushTextContentItem();
  52659. textState.fontName = fontNameArg;
  52660. textState.fontSize = fontSizeArg;
  52661. next(handleSetFont(fontNameArg, null));
  52662. return;
  52663. case OPS.setTextRise:
  52664. flushTextContentItem();
  52665. textState.textRise = args[0];
  52666. break;
  52667. case OPS.setHScale:
  52668. flushTextContentItem();
  52669. textState.textHScale = args[0] / 100;
  52670. break;
  52671. case OPS.setLeading:
  52672. flushTextContentItem();
  52673. textState.leading = args[0];
  52674. break;
  52675. case OPS.moveText:
  52676. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  52677. advance = args[0] - args[1];
  52678. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  52679. textState.translateTextLineMatrix(args[0], args[1]);
  52680. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  52681. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  52682. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  52683. addFakeSpaces(diff, textContentItem.str);
  52684. break;
  52685. }
  52686. flushTextContentItem();
  52687. textState.translateTextLineMatrix(args[0], args[1]);
  52688. textState.textMatrix = textState.textLineMatrix.slice();
  52689. break;
  52690. case OPS.setLeadingMoveText:
  52691. flushTextContentItem();
  52692. textState.leading = -args[1];
  52693. textState.translateTextLineMatrix(args[0], args[1]);
  52694. textState.textMatrix = textState.textLineMatrix.slice();
  52695. break;
  52696. case OPS.nextLine:
  52697. flushTextContentItem();
  52698. textState.carriageReturn();
  52699. break;
  52700. case OPS.setTextMatrix:
  52701. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  52702. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  52703. textState.translateTextLineMatrix(advance.width, advance.height);
  52704. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  52705. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  52706. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  52707. addFakeSpaces(diff, textContentItem.str);
  52708. break;
  52709. }
  52710. flushTextContentItem();
  52711. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  52712. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  52713. break;
  52714. case OPS.setCharSpacing:
  52715. textState.charSpacing = args[0];
  52716. break;
  52717. case OPS.setWordSpacing:
  52718. textState.wordSpacing = args[0];
  52719. break;
  52720. case OPS.beginText:
  52721. flushTextContentItem();
  52722. textState.textMatrix = IDENTITY_MATRIX.slice();
  52723. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  52724. break;
  52725. case OPS.showSpacedText:
  52726. var items = args[0];
  52727. var offset;
  52728. for (var j = 0, jj = items.length; j < jj; j++) {
  52729. if (typeof items[j] === 'string') {
  52730. buildTextContentItem(items[j]);
  52731. } else if (isNum(items[j])) {
  52732. ensureTextContentItem();
  52733. advance = items[j] * textState.fontSize / 1000;
  52734. var breakTextRun = false;
  52735. if (textState.font.vertical) {
  52736. offset = advance * (textState.textHScale * textState.textMatrix[2] + textState.textMatrix[3]);
  52737. textState.translateTextMatrix(0, advance);
  52738. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  52739. if (!breakTextRun) {
  52740. textContentItem.height += offset;
  52741. }
  52742. } else {
  52743. advance = -advance;
  52744. offset = advance * (textState.textHScale * textState.textMatrix[0] + textState.textMatrix[1]);
  52745. textState.translateTextMatrix(advance, 0);
  52746. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  52747. if (!breakTextRun) {
  52748. textContentItem.width += offset;
  52749. }
  52750. }
  52751. if (breakTextRun) {
  52752. flushTextContentItem();
  52753. } else if (advance > 0) {
  52754. addFakeSpaces(advance, textContentItem.str);
  52755. }
  52756. }
  52757. }
  52758. break;
  52759. case OPS.showText:
  52760. buildTextContentItem(args[0]);
  52761. break;
  52762. case OPS.nextLineShowText:
  52763. flushTextContentItem();
  52764. textState.carriageReturn();
  52765. buildTextContentItem(args[0]);
  52766. break;
  52767. case OPS.nextLineSetSpacingShowText:
  52768. flushTextContentItem();
  52769. textState.wordSpacing = args[0];
  52770. textState.charSpacing = args[1];
  52771. textState.carriageReturn();
  52772. buildTextContentItem(args[2]);
  52773. break;
  52774. case OPS.paintXObject:
  52775. flushTextContentItem();
  52776. if (args[0].code) {
  52777. break;
  52778. }
  52779. if (!xobjs) {
  52780. xobjs = resources.get('XObject') || Dict.empty;
  52781. }
  52782. var name = args[0].name;
  52783. if (xobjsCache.key === name) {
  52784. if (xobjsCache.texts) {
  52785. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  52786. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  52787. }
  52788. break;
  52789. }
  52790. var xobj = xobjs.get(name);
  52791. if (!xobj) {
  52792. break;
  52793. }
  52794. assert(isStream(xobj), 'XObject should be a stream');
  52795. var type = xobj.dict.get('Subtype');
  52796. assert(isName(type), 'XObject should have a Name subtype');
  52797. if ('Form' !== type.name) {
  52798. xobjsCache.key = name;
  52799. xobjsCache.texts = null;
  52800. break;
  52801. }
  52802. stateManager.save();
  52803. var matrix = xobj.dict.getArray('Matrix');
  52804. if (isArray(matrix) && matrix.length === 6) {
  52805. stateManager.transform(matrix);
  52806. }
  52807. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  52808. Util.appendToArray(textContent.items, formTextContent.items);
  52809. Util.extendObj(textContent.styles, formTextContent.styles);
  52810. stateManager.restore();
  52811. xobjsCache.key = name;
  52812. xobjsCache.texts = formTextContent;
  52813. }));
  52814. return;
  52815. case OPS.setGState:
  52816. flushTextContentItem();
  52817. var dictName = args[0];
  52818. var extGState = resources.get('ExtGState');
  52819. if (!isDict(extGState) || !isName(dictName)) {
  52820. break;
  52821. }
  52822. var gState = extGState.get(dictName.name);
  52823. if (!isDict(gState)) {
  52824. break;
  52825. }
  52826. var gStateFont = gState.get('Font');
  52827. if (gStateFont) {
  52828. textState.fontName = null;
  52829. textState.fontSize = gStateFont[1];
  52830. next(handleSetFont(null, gStateFont[0]));
  52831. return;
  52832. }
  52833. break;
  52834. }
  52835. }
  52836. if (stop) {
  52837. next(deferred);
  52838. return;
  52839. }
  52840. flushTextContentItem();
  52841. resolve(textContent);
  52842. });
  52843. },
  52844. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  52845. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  52846. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  52847. if (properties.composite) {
  52848. var cidSystemInfo = dict.get('CIDSystemInfo');
  52849. if (isDict(cidSystemInfo)) {
  52850. properties.cidSystemInfo = {
  52851. registry: cidSystemInfo.get('Registry'),
  52852. ordering: cidSystemInfo.get('Ordering'),
  52853. supplement: cidSystemInfo.get('Supplement')
  52854. };
  52855. }
  52856. var cidToGidMap = dict.get('CIDToGIDMap');
  52857. if (isStream(cidToGidMap)) {
  52858. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  52859. }
  52860. }
  52861. var differences = [];
  52862. var baseEncodingName = null;
  52863. var encoding;
  52864. if (dict.has('Encoding')) {
  52865. encoding = dict.get('Encoding');
  52866. if (isDict(encoding)) {
  52867. baseEncodingName = encoding.get('BaseEncoding');
  52868. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  52869. if (encoding.has('Differences')) {
  52870. var diffEncoding = encoding.get('Differences');
  52871. var index = 0;
  52872. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  52873. var data = xref.fetchIfRef(diffEncoding[j]);
  52874. if (isNum(data)) {
  52875. index = data;
  52876. } else if (isName(data)) {
  52877. differences[index++] = data.name;
  52878. } else {
  52879. error('Invalid entry in \'Differences\' array: ' + data);
  52880. }
  52881. }
  52882. }
  52883. } else if (isName(encoding)) {
  52884. baseEncodingName = encoding.name;
  52885. } else {
  52886. error('Encoding is not a Name nor a Dict');
  52887. }
  52888. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  52889. baseEncodingName = null;
  52890. }
  52891. }
  52892. if (baseEncodingName) {
  52893. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  52894. } else {
  52895. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  52896. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  52897. encoding = StandardEncoding;
  52898. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  52899. encoding = WinAnsiEncoding;
  52900. }
  52901. if (isSymbolicFont) {
  52902. encoding = MacRomanEncoding;
  52903. if (!properties.file) {
  52904. if (/Symbol/i.test(properties.name)) {
  52905. encoding = SymbolSetEncoding;
  52906. } else if (/Dingbats/i.test(properties.name)) {
  52907. encoding = ZapfDingbatsEncoding;
  52908. }
  52909. }
  52910. }
  52911. properties.defaultEncoding = encoding;
  52912. }
  52913. properties.differences = differences;
  52914. properties.baseEncodingName = baseEncodingName;
  52915. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  52916. properties.dict = dict;
  52917. return toUnicodePromise.then(function (toUnicode) {
  52918. properties.toUnicode = toUnicode;
  52919. return this.buildToUnicode(properties);
  52920. }.bind(this)).then(function (toUnicode) {
  52921. properties.toUnicode = toUnicode;
  52922. return properties;
  52923. });
  52924. },
  52925. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  52926. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  52927. if (properties.hasIncludedToUnicodeMap) {
  52928. return Promise.resolve(properties.toUnicode);
  52929. }
  52930. var toUnicode, charcode, glyphName;
  52931. if (!properties.composite)
  52932. {
  52933. toUnicode = [];
  52934. var encoding = properties.defaultEncoding.slice();
  52935. var baseEncodingName = properties.baseEncodingName;
  52936. var differences = properties.differences;
  52937. for (charcode in differences) {
  52938. glyphName = differences[charcode];
  52939. if (glyphName === '.notdef') {
  52940. continue;
  52941. }
  52942. encoding[charcode] = glyphName;
  52943. }
  52944. var glyphsUnicodeMap = getGlyphsUnicode();
  52945. for (charcode in encoding) {
  52946. glyphName = encoding[charcode];
  52947. if (glyphName === '') {
  52948. continue;
  52949. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  52950. var code = 0;
  52951. switch (glyphName[0]) {
  52952. case 'G':
  52953. if (glyphName.length === 3) {
  52954. code = parseInt(glyphName.substr(1), 16);
  52955. }
  52956. break;
  52957. case 'g':
  52958. if (glyphName.length === 5) {
  52959. code = parseInt(glyphName.substr(1), 16);
  52960. }
  52961. break;
  52962. case 'C':
  52963. case 'c':
  52964. if (glyphName.length >= 3) {
  52965. code = +glyphName.substr(1);
  52966. }
  52967. break;
  52968. default:
  52969. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  52970. if (unicode !== -1) {
  52971. code = unicode;
  52972. }
  52973. }
  52974. if (code) {
  52975. if (baseEncodingName && code === +charcode) {
  52976. var baseEncoding = getEncoding(baseEncodingName);
  52977. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  52978. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  52979. continue;
  52980. }
  52981. }
  52982. toUnicode[charcode] = String.fromCharCode(code);
  52983. }
  52984. continue;
  52985. }
  52986. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  52987. }
  52988. return Promise.resolve(new ToUnicodeMap(toUnicode));
  52989. }
  52990. 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'))) {
  52991. var registry = properties.cidSystemInfo.registry;
  52992. var ordering = properties.cidSystemInfo.ordering;
  52993. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  52994. return CMapFactory.create(ucs2CMapName, this.options.cMapOptions, null).then(function (ucs2CMap) {
  52995. var cMap = properties.cMap;
  52996. toUnicode = [];
  52997. cMap.forEach(function (charcode, cid) {
  52998. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  52999. var ucs2 = ucs2CMap.lookup(cid);
  53000. if (ucs2) {
  53001. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  53002. }
  53003. });
  53004. return new ToUnicodeMap(toUnicode);
  53005. });
  53006. }
  53007. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  53008. },
  53009. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  53010. var cmapObj = toUnicode;
  53011. if (isName(cmapObj)) {
  53012. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  53013. if (cmap instanceof IdentityCMap) {
  53014. return new IdentityToUnicodeMap(0, 0xFFFF);
  53015. }
  53016. return new ToUnicodeMap(cmap.getMap());
  53017. });
  53018. } else if (isStream(cmapObj)) {
  53019. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  53020. if (cmap instanceof IdentityCMap) {
  53021. return new IdentityToUnicodeMap(0, 0xFFFF);
  53022. }
  53023. var map = new Array(cmap.length);
  53024. cmap.forEach(function (charCode, token) {
  53025. var str = [];
  53026. for (var k = 0; k < token.length; k += 2) {
  53027. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  53028. if ((w1 & 0xF800) !== 0xD800) {
  53029. str.push(w1);
  53030. continue;
  53031. }
  53032. k += 2;
  53033. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  53034. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  53035. }
  53036. map[charCode] = String.fromCharCode.apply(String, str);
  53037. });
  53038. return new ToUnicodeMap(map);
  53039. });
  53040. }
  53041. return Promise.resolve(null);
  53042. },
  53043. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  53044. var glyphsData = cidToGidStream.getBytes();
  53045. var result = [];
  53046. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  53047. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  53048. if (glyphID === 0) {
  53049. continue;
  53050. }
  53051. var code = j >> 1;
  53052. result[code] = glyphID;
  53053. }
  53054. return result;
  53055. },
  53056. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  53057. var glyphsWidths = [];
  53058. var defaultWidth = 0;
  53059. var glyphsVMetrics = [];
  53060. var defaultVMetrics;
  53061. var i, ii, j, jj, start, code, widths;
  53062. if (properties.composite) {
  53063. defaultWidth = dict.get('DW') || 1000;
  53064. widths = dict.get('W');
  53065. if (widths) {
  53066. for (i = 0, ii = widths.length; i < ii; i++) {
  53067. start = xref.fetchIfRef(widths[i++]);
  53068. code = xref.fetchIfRef(widths[i]);
  53069. if (isArray(code)) {
  53070. for (j = 0, jj = code.length; j < jj; j++) {
  53071. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  53072. }
  53073. } else {
  53074. var width = xref.fetchIfRef(widths[++i]);
  53075. for (j = start; j <= code; j++) {
  53076. glyphsWidths[j] = width;
  53077. }
  53078. }
  53079. }
  53080. }
  53081. if (properties.vertical) {
  53082. var vmetrics = dict.getArray('DW2') || [
  53083. 880,
  53084. -1000
  53085. ];
  53086. defaultVMetrics = [
  53087. vmetrics[1],
  53088. defaultWidth * 0.5,
  53089. vmetrics[0]
  53090. ];
  53091. vmetrics = dict.get('W2');
  53092. if (vmetrics) {
  53093. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  53094. start = xref.fetchIfRef(vmetrics[i++]);
  53095. code = xref.fetchIfRef(vmetrics[i]);
  53096. if (isArray(code)) {
  53097. for (j = 0, jj = code.length; j < jj; j++) {
  53098. glyphsVMetrics[start++] = [
  53099. xref.fetchIfRef(code[j++]),
  53100. xref.fetchIfRef(code[j++]),
  53101. xref.fetchIfRef(code[j])
  53102. ];
  53103. }
  53104. } else {
  53105. var vmetric = [
  53106. xref.fetchIfRef(vmetrics[++i]),
  53107. xref.fetchIfRef(vmetrics[++i]),
  53108. xref.fetchIfRef(vmetrics[++i])
  53109. ];
  53110. for (j = start; j <= code; j++) {
  53111. glyphsVMetrics[j] = vmetric;
  53112. }
  53113. }
  53114. }
  53115. }
  53116. }
  53117. } else {
  53118. var firstChar = properties.firstChar;
  53119. widths = dict.get('Widths');
  53120. if (widths) {
  53121. j = firstChar;
  53122. for (i = 0, ii = widths.length; i < ii; i++) {
  53123. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  53124. }
  53125. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  53126. } else {
  53127. var baseFontName = dict.get('BaseFont');
  53128. if (isName(baseFontName)) {
  53129. var metrics = this.getBaseFontMetrics(baseFontName.name);
  53130. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  53131. defaultWidth = metrics.defaultWidth;
  53132. }
  53133. }
  53134. }
  53135. var isMonospace = true;
  53136. var firstWidth = defaultWidth;
  53137. for (var glyph in glyphsWidths) {
  53138. var glyphWidth = glyphsWidths[glyph];
  53139. if (!glyphWidth) {
  53140. continue;
  53141. }
  53142. if (!firstWidth) {
  53143. firstWidth = glyphWidth;
  53144. continue;
  53145. }
  53146. if (firstWidth !== glyphWidth) {
  53147. isMonospace = false;
  53148. break;
  53149. }
  53150. }
  53151. if (isMonospace) {
  53152. properties.flags |= FontFlags.FixedPitch;
  53153. }
  53154. properties.defaultWidth = defaultWidth;
  53155. properties.widths = glyphsWidths;
  53156. properties.defaultVMetrics = defaultVMetrics;
  53157. properties.vmetrics = glyphsVMetrics;
  53158. },
  53159. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  53160. var fontNameWoStyle = baseFontName.split('-')[0];
  53161. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  53162. },
  53163. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  53164. var defaultWidth = 0;
  53165. var widths = [];
  53166. var monospace = false;
  53167. var stdFontMap = getStdFontMap();
  53168. var lookupName = stdFontMap[name] || name;
  53169. var Metrics = getMetrics();
  53170. if (!(lookupName in Metrics)) {
  53171. if (this.isSerifFont(name)) {
  53172. lookupName = 'Times-Roman';
  53173. } else {
  53174. lookupName = 'Helvetica';
  53175. }
  53176. }
  53177. var glyphWidths = Metrics[lookupName];
  53178. if (isNum(glyphWidths)) {
  53179. defaultWidth = glyphWidths;
  53180. monospace = true;
  53181. } else {
  53182. widths = glyphWidths();
  53183. }
  53184. return {
  53185. defaultWidth: defaultWidth,
  53186. monospace: monospace,
  53187. widths: widths
  53188. };
  53189. },
  53190. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  53191. var widths = Object.create(null);
  53192. var differences = properties.differences;
  53193. var encoding = properties.defaultEncoding;
  53194. for (var charCode = 0; charCode < 256; charCode++) {
  53195. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  53196. widths[charCode] = widthsByGlyphName[differences[charCode]];
  53197. continue;
  53198. }
  53199. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  53200. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  53201. continue;
  53202. }
  53203. }
  53204. return widths;
  53205. },
  53206. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  53207. var baseDict = dict;
  53208. var type = dict.get('Subtype');
  53209. assert(isName(type), 'invalid font Subtype');
  53210. var composite = false;
  53211. var uint8array;
  53212. if (type.name === 'Type0') {
  53213. var df = dict.get('DescendantFonts');
  53214. if (!df) {
  53215. error('Descendant fonts are not specified');
  53216. }
  53217. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  53218. type = dict.get('Subtype');
  53219. assert(isName(type), 'invalid font Subtype');
  53220. composite = true;
  53221. }
  53222. var descriptor = dict.get('FontDescriptor');
  53223. if (descriptor) {
  53224. var hash = new MurmurHash3_64();
  53225. var encoding = baseDict.getRaw('Encoding');
  53226. if (isName(encoding)) {
  53227. hash.update(encoding.name);
  53228. } else if (isRef(encoding)) {
  53229. hash.update(encoding.toString());
  53230. } else if (isDict(encoding)) {
  53231. var keys = encoding.getKeys();
  53232. for (var i = 0, ii = keys.length; i < ii; i++) {
  53233. var entry = encoding.getRaw(keys[i]);
  53234. if (isName(entry)) {
  53235. hash.update(entry.name);
  53236. } else if (isRef(entry)) {
  53237. hash.update(entry.toString());
  53238. } else if (isArray(entry)) {
  53239. hash.update(entry.length.toString());
  53240. }
  53241. }
  53242. }
  53243. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  53244. if (isStream(toUnicode)) {
  53245. var stream = toUnicode.str || toUnicode;
  53246. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  53247. hash.update(uint8array);
  53248. } else if (isName(toUnicode)) {
  53249. hash.update(toUnicode.name);
  53250. }
  53251. var widths = dict.get('Widths') || baseDict.get('Widths');
  53252. if (widths) {
  53253. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  53254. hash.update(uint8array);
  53255. }
  53256. }
  53257. return {
  53258. descriptor: descriptor,
  53259. dict: dict,
  53260. baseDict: baseDict,
  53261. composite: composite,
  53262. type: type.name,
  53263. hash: hash ? hash.hexdigest() : ''
  53264. };
  53265. },
  53266. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  53267. var baseDict = preEvaluatedFont.baseDict;
  53268. var dict = preEvaluatedFont.dict;
  53269. var composite = preEvaluatedFont.composite;
  53270. var descriptor = preEvaluatedFont.descriptor;
  53271. var type = preEvaluatedFont.type;
  53272. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  53273. var cMapOptions = this.options.cMapOptions;
  53274. var properties;
  53275. if (!descriptor) {
  53276. if (type === 'Type3') {
  53277. descriptor = new Dict(null);
  53278. descriptor.set('FontName', Name.get(type));
  53279. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  53280. } else {
  53281. var baseFontName = dict.get('BaseFont');
  53282. if (!isName(baseFontName)) {
  53283. error('Base font is not specified');
  53284. }
  53285. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  53286. var metrics = this.getBaseFontMetrics(baseFontName);
  53287. var fontNameWoStyle = baseFontName.split('-')[0];
  53288. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  53289. properties = {
  53290. type: type,
  53291. name: baseFontName,
  53292. widths: metrics.widths,
  53293. defaultWidth: metrics.defaultWidth,
  53294. flags: flags,
  53295. firstChar: 0,
  53296. lastChar: maxCharIndex
  53297. };
  53298. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  53299. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  53300. return new Font(baseFontName, null, properties);
  53301. }.bind(this));
  53302. }
  53303. }
  53304. var firstChar = dict.get('FirstChar') || 0;
  53305. var lastChar = dict.get('LastChar') || maxCharIndex;
  53306. var fontName = descriptor.get('FontName');
  53307. var baseFont = dict.get('BaseFont');
  53308. if (isString(fontName)) {
  53309. fontName = Name.get(fontName);
  53310. }
  53311. if (isString(baseFont)) {
  53312. baseFont = Name.get(baseFont);
  53313. }
  53314. if (type !== 'Type3') {
  53315. var fontNameStr = fontName && fontName.name;
  53316. var baseFontStr = baseFont && baseFont.name;
  53317. if (fontNameStr !== baseFontStr) {
  53318. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  53319. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  53320. fontName = baseFont;
  53321. }
  53322. }
  53323. }
  53324. fontName = fontName || baseFont;
  53325. assert(isName(fontName), 'invalid font name');
  53326. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  53327. if (fontFile) {
  53328. if (fontFile.dict) {
  53329. var subtype = fontFile.dict.get('Subtype');
  53330. if (subtype) {
  53331. subtype = subtype.name;
  53332. }
  53333. var length1 = fontFile.dict.get('Length1');
  53334. var length2 = fontFile.dict.get('Length2');
  53335. var length3 = fontFile.dict.get('Length3');
  53336. }
  53337. }
  53338. properties = {
  53339. type: type,
  53340. name: fontName.name,
  53341. subtype: subtype,
  53342. file: fontFile,
  53343. length1: length1,
  53344. length2: length2,
  53345. length3: length3,
  53346. loadedName: baseDict.loadedName,
  53347. composite: composite,
  53348. wideChars: composite,
  53349. fixedPitch: false,
  53350. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  53351. firstChar: firstChar || 0,
  53352. lastChar: lastChar || maxCharIndex,
  53353. bbox: descriptor.getArray('FontBBox'),
  53354. ascent: descriptor.get('Ascent'),
  53355. descent: descriptor.get('Descent'),
  53356. xHeight: descriptor.get('XHeight'),
  53357. capHeight: descriptor.get('CapHeight'),
  53358. flags: descriptor.get('Flags'),
  53359. italicAngle: descriptor.get('ItalicAngle'),
  53360. coded: false
  53361. };
  53362. var cMapPromise;
  53363. if (composite) {
  53364. var cidEncoding = baseDict.get('Encoding');
  53365. if (isName(cidEncoding)) {
  53366. properties.cidEncoding = cidEncoding.name;
  53367. }
  53368. cMapPromise = CMapFactory.create(cidEncoding, cMapOptions, null).then(function (cMap) {
  53369. properties.cMap = cMap;
  53370. properties.vertical = properties.cMap.vertical;
  53371. });
  53372. } else {
  53373. cMapPromise = Promise.resolve(undefined);
  53374. }
  53375. return cMapPromise.then(function () {
  53376. return this.extractDataStructures(dict, baseDict, xref, properties);
  53377. }.bind(this)).then(function (properties) {
  53378. this.extractWidths(dict, xref, descriptor, properties);
  53379. if (type === 'Type3') {
  53380. properties.isType3Font = true;
  53381. }
  53382. return new Font(fontName.name, fontFile, properties);
  53383. }.bind(this));
  53384. }
  53385. };
  53386. return PartialEvaluator;
  53387. }();
  53388. var TranslatedFont = function TranslatedFontClosure() {
  53389. function TranslatedFont(loadedName, font, dict) {
  53390. this.loadedName = loadedName;
  53391. this.font = font;
  53392. this.dict = dict;
  53393. this.type3Loaded = null;
  53394. this.sent = false;
  53395. }
  53396. TranslatedFont.prototype = {
  53397. send: function (handler) {
  53398. if (this.sent) {
  53399. return;
  53400. }
  53401. var fontData = this.font.exportData();
  53402. handler.send('commonobj', [
  53403. this.loadedName,
  53404. 'Font',
  53405. fontData
  53406. ]);
  53407. this.sent = true;
  53408. },
  53409. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  53410. assert(this.font.isType3Font);
  53411. if (this.type3Loaded) {
  53412. return this.type3Loaded;
  53413. }
  53414. var translatedFont = this.font;
  53415. var loadCharProcsPromise = Promise.resolve();
  53416. var charProcs = this.dict.get('CharProcs');
  53417. var fontResources = this.dict.get('Resources') || resources;
  53418. var charProcKeys = charProcs.getKeys();
  53419. var charProcOperatorList = Object.create(null);
  53420. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  53421. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  53422. var glyphStream = charProcs.get(key);
  53423. var operatorList = new OperatorList();
  53424. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  53425. charProcOperatorList[key] = operatorList.getIR();
  53426. parentOperatorList.addDependencies(operatorList.dependencies);
  53427. }, function (reason) {
  53428. warn('Type3 font resource \"' + key + '\" is not available');
  53429. var operatorList = new OperatorList();
  53430. charProcOperatorList[key] = operatorList.getIR();
  53431. });
  53432. }.bind(this, charProcKeys[i]));
  53433. }
  53434. this.type3Loaded = loadCharProcsPromise.then(function () {
  53435. translatedFont.charProcOperatorList = charProcOperatorList;
  53436. });
  53437. return this.type3Loaded;
  53438. }
  53439. };
  53440. return TranslatedFont;
  53441. }();
  53442. var OperatorList = function OperatorListClosure() {
  53443. var CHUNK_SIZE = 1000;
  53444. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  53445. function getTransfers(queue) {
  53446. var transfers = [];
  53447. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  53448. for (var i = 0, ii = queue.length; i < ii; i++) {
  53449. switch (fnArray[i]) {
  53450. case OPS.paintInlineImageXObject:
  53451. case OPS.paintInlineImageXObjectGroup:
  53452. case OPS.paintImageMaskXObject:
  53453. var arg = argsArray[i][0];
  53454. if (!arg.cached) {
  53455. transfers.push(arg.data.buffer);
  53456. }
  53457. break;
  53458. }
  53459. }
  53460. return transfers;
  53461. }
  53462. function OperatorList(intent, messageHandler, pageIndex) {
  53463. this.messageHandler = messageHandler;
  53464. this.fnArray = [];
  53465. this.argsArray = [];
  53466. this.dependencies = Object.create(null);
  53467. this._totalLength = 0;
  53468. this.pageIndex = pageIndex;
  53469. this.intent = intent;
  53470. }
  53471. OperatorList.prototype = {
  53472. get length() {
  53473. return this.argsArray.length;
  53474. },
  53475. get totalLength() {
  53476. return this._totalLength + this.length;
  53477. },
  53478. addOp: function (fn, args) {
  53479. this.fnArray.push(fn);
  53480. this.argsArray.push(args);
  53481. if (this.messageHandler) {
  53482. if (this.fnArray.length >= CHUNK_SIZE) {
  53483. this.flush();
  53484. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  53485. this.flush();
  53486. }
  53487. }
  53488. },
  53489. addDependency: function (dependency) {
  53490. if (dependency in this.dependencies) {
  53491. return;
  53492. }
  53493. this.dependencies[dependency] = true;
  53494. this.addOp(OPS.dependency, [dependency]);
  53495. },
  53496. addDependencies: function (dependencies) {
  53497. for (var key in dependencies) {
  53498. this.addDependency(key);
  53499. }
  53500. },
  53501. addOpList: function (opList) {
  53502. Util.extendObj(this.dependencies, opList.dependencies);
  53503. for (var i = 0, ii = opList.length; i < ii; i++) {
  53504. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  53505. }
  53506. },
  53507. getIR: function () {
  53508. return {
  53509. fnArray: this.fnArray,
  53510. argsArray: this.argsArray,
  53511. length: this.length
  53512. };
  53513. },
  53514. flush: function (lastChunk) {
  53515. if (this.intent !== 'oplist') {
  53516. new QueueOptimizer().optimize(this);
  53517. }
  53518. var transfers = getTransfers(this);
  53519. var length = this.length;
  53520. this._totalLength += length;
  53521. this.messageHandler.send('RenderPageChunk', {
  53522. operatorList: {
  53523. fnArray: this.fnArray,
  53524. argsArray: this.argsArray,
  53525. lastChunk: lastChunk,
  53526. length: length
  53527. },
  53528. pageIndex: this.pageIndex,
  53529. intent: this.intent
  53530. }, transfers);
  53531. this.dependencies = Object.create(null);
  53532. this.fnArray.length = 0;
  53533. this.argsArray.length = 0;
  53534. }
  53535. };
  53536. return OperatorList;
  53537. }();
  53538. var StateManager = function StateManagerClosure() {
  53539. function StateManager(initialState) {
  53540. this.state = initialState;
  53541. this.stateStack = [];
  53542. }
  53543. StateManager.prototype = {
  53544. save: function () {
  53545. var old = this.state;
  53546. this.stateStack.push(this.state);
  53547. this.state = old.clone();
  53548. },
  53549. restore: function () {
  53550. var prev = this.stateStack.pop();
  53551. if (prev) {
  53552. this.state = prev;
  53553. }
  53554. },
  53555. transform: function (args) {
  53556. this.state.ctm = Util.transform(this.state.ctm, args);
  53557. }
  53558. };
  53559. return StateManager;
  53560. }();
  53561. var TextState = function TextStateClosure() {
  53562. function TextState() {
  53563. this.ctm = new Float32Array(IDENTITY_MATRIX);
  53564. this.fontName = null;
  53565. this.fontSize = 0;
  53566. this.font = null;
  53567. this.fontMatrix = FONT_IDENTITY_MATRIX;
  53568. this.textMatrix = IDENTITY_MATRIX.slice();
  53569. this.textLineMatrix = IDENTITY_MATRIX.slice();
  53570. this.charSpacing = 0;
  53571. this.wordSpacing = 0;
  53572. this.leading = 0;
  53573. this.textHScale = 1;
  53574. this.textRise = 0;
  53575. }
  53576. TextState.prototype = {
  53577. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  53578. var m = this.textMatrix;
  53579. m[0] = a;
  53580. m[1] = b;
  53581. m[2] = c;
  53582. m[3] = d;
  53583. m[4] = e;
  53584. m[5] = f;
  53585. },
  53586. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  53587. var m = this.textLineMatrix;
  53588. m[0] = a;
  53589. m[1] = b;
  53590. m[2] = c;
  53591. m[3] = d;
  53592. m[4] = e;
  53593. m[5] = f;
  53594. },
  53595. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  53596. var m = this.textMatrix;
  53597. m[4] = m[0] * x + m[2] * y + m[4];
  53598. m[5] = m[1] * x + m[3] * y + m[5];
  53599. },
  53600. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  53601. var m = this.textLineMatrix;
  53602. m[4] = m[0] * x + m[2] * y + m[4];
  53603. m[5] = m[1] * x + m[3] * y + m[5];
  53604. },
  53605. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  53606. var font = this.font;
  53607. if (!font) {
  53608. return null;
  53609. }
  53610. var m = this.textLineMatrix;
  53611. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  53612. return null;
  53613. }
  53614. var txDiff = e - m[4], tyDiff = f - m[5];
  53615. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  53616. return null;
  53617. }
  53618. var tx, ty, denominator = a * d - b * c;
  53619. if (font.vertical) {
  53620. tx = -tyDiff * c / denominator;
  53621. ty = tyDiff * a / denominator;
  53622. } else {
  53623. tx = txDiff * d / denominator;
  53624. ty = -txDiff * b / denominator;
  53625. }
  53626. return {
  53627. width: tx,
  53628. height: ty,
  53629. value: font.vertical ? ty : tx
  53630. };
  53631. },
  53632. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  53633. var tsm = [
  53634. this.fontSize * this.textHScale,
  53635. 0,
  53636. 0,
  53637. this.fontSize,
  53638. 0,
  53639. this.textRise
  53640. ];
  53641. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  53642. },
  53643. carriageReturn: function TextState_carriageReturn() {
  53644. this.translateTextLineMatrix(0, -this.leading);
  53645. this.textMatrix = this.textLineMatrix.slice();
  53646. },
  53647. clone: function TextState_clone() {
  53648. var clone = Object.create(this);
  53649. clone.textMatrix = this.textMatrix.slice();
  53650. clone.textLineMatrix = this.textLineMatrix.slice();
  53651. clone.fontMatrix = this.fontMatrix.slice();
  53652. return clone;
  53653. }
  53654. };
  53655. return TextState;
  53656. }();
  53657. var EvalState = function EvalStateClosure() {
  53658. function EvalState() {
  53659. this.ctm = new Float32Array(IDENTITY_MATRIX);
  53660. this.font = null;
  53661. this.textRenderingMode = TextRenderingMode.FILL;
  53662. this.fillColorSpace = ColorSpace.singletons.gray;
  53663. this.strokeColorSpace = ColorSpace.singletons.gray;
  53664. }
  53665. EvalState.prototype = {
  53666. clone: function CanvasExtraState_clone() {
  53667. return Object.create(this);
  53668. }
  53669. };
  53670. return EvalState;
  53671. }();
  53672. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  53673. var getOPMap = getLookupTableFactory(function (t) {
  53674. t['w'] = {
  53675. id: OPS.setLineWidth,
  53676. numArgs: 1,
  53677. variableArgs: false
  53678. };
  53679. t['J'] = {
  53680. id: OPS.setLineCap,
  53681. numArgs: 1,
  53682. variableArgs: false
  53683. };
  53684. t['j'] = {
  53685. id: OPS.setLineJoin,
  53686. numArgs: 1,
  53687. variableArgs: false
  53688. };
  53689. t['M'] = {
  53690. id: OPS.setMiterLimit,
  53691. numArgs: 1,
  53692. variableArgs: false
  53693. };
  53694. t['d'] = {
  53695. id: OPS.setDash,
  53696. numArgs: 2,
  53697. variableArgs: false
  53698. };
  53699. t['ri'] = {
  53700. id: OPS.setRenderingIntent,
  53701. numArgs: 1,
  53702. variableArgs: false
  53703. };
  53704. t['i'] = {
  53705. id: OPS.setFlatness,
  53706. numArgs: 1,
  53707. variableArgs: false
  53708. };
  53709. t['gs'] = {
  53710. id: OPS.setGState,
  53711. numArgs: 1,
  53712. variableArgs: false
  53713. };
  53714. t['q'] = {
  53715. id: OPS.save,
  53716. numArgs: 0,
  53717. variableArgs: false
  53718. };
  53719. t['Q'] = {
  53720. id: OPS.restore,
  53721. numArgs: 0,
  53722. variableArgs: false
  53723. };
  53724. t['cm'] = {
  53725. id: OPS.transform,
  53726. numArgs: 6,
  53727. variableArgs: false
  53728. };
  53729. t['m'] = {
  53730. id: OPS.moveTo,
  53731. numArgs: 2,
  53732. variableArgs: false
  53733. };
  53734. t['l'] = {
  53735. id: OPS.lineTo,
  53736. numArgs: 2,
  53737. variableArgs: false
  53738. };
  53739. t['c'] = {
  53740. id: OPS.curveTo,
  53741. numArgs: 6,
  53742. variableArgs: false
  53743. };
  53744. t['v'] = {
  53745. id: OPS.curveTo2,
  53746. numArgs: 4,
  53747. variableArgs: false
  53748. };
  53749. t['y'] = {
  53750. id: OPS.curveTo3,
  53751. numArgs: 4,
  53752. variableArgs: false
  53753. };
  53754. t['h'] = {
  53755. id: OPS.closePath,
  53756. numArgs: 0,
  53757. variableArgs: false
  53758. };
  53759. t['re'] = {
  53760. id: OPS.rectangle,
  53761. numArgs: 4,
  53762. variableArgs: false
  53763. };
  53764. t['S'] = {
  53765. id: OPS.stroke,
  53766. numArgs: 0,
  53767. variableArgs: false
  53768. };
  53769. t['s'] = {
  53770. id: OPS.closeStroke,
  53771. numArgs: 0,
  53772. variableArgs: false
  53773. };
  53774. t['f'] = {
  53775. id: OPS.fill,
  53776. numArgs: 0,
  53777. variableArgs: false
  53778. };
  53779. t['F'] = {
  53780. id: OPS.fill,
  53781. numArgs: 0,
  53782. variableArgs: false
  53783. };
  53784. t['f*'] = {
  53785. id: OPS.eoFill,
  53786. numArgs: 0,
  53787. variableArgs: false
  53788. };
  53789. t['B'] = {
  53790. id: OPS.fillStroke,
  53791. numArgs: 0,
  53792. variableArgs: false
  53793. };
  53794. t['B*'] = {
  53795. id: OPS.eoFillStroke,
  53796. numArgs: 0,
  53797. variableArgs: false
  53798. };
  53799. t['b'] = {
  53800. id: OPS.closeFillStroke,
  53801. numArgs: 0,
  53802. variableArgs: false
  53803. };
  53804. t['b*'] = {
  53805. id: OPS.closeEOFillStroke,
  53806. numArgs: 0,
  53807. variableArgs: false
  53808. };
  53809. t['n'] = {
  53810. id: OPS.endPath,
  53811. numArgs: 0,
  53812. variableArgs: false
  53813. };
  53814. t['W'] = {
  53815. id: OPS.clip,
  53816. numArgs: 0,
  53817. variableArgs: false
  53818. };
  53819. t['W*'] = {
  53820. id: OPS.eoClip,
  53821. numArgs: 0,
  53822. variableArgs: false
  53823. };
  53824. t['BT'] = {
  53825. id: OPS.beginText,
  53826. numArgs: 0,
  53827. variableArgs: false
  53828. };
  53829. t['ET'] = {
  53830. id: OPS.endText,
  53831. numArgs: 0,
  53832. variableArgs: false
  53833. };
  53834. t['Tc'] = {
  53835. id: OPS.setCharSpacing,
  53836. numArgs: 1,
  53837. variableArgs: false
  53838. };
  53839. t['Tw'] = {
  53840. id: OPS.setWordSpacing,
  53841. numArgs: 1,
  53842. variableArgs: false
  53843. };
  53844. t['Tz'] = {
  53845. id: OPS.setHScale,
  53846. numArgs: 1,
  53847. variableArgs: false
  53848. };
  53849. t['TL'] = {
  53850. id: OPS.setLeading,
  53851. numArgs: 1,
  53852. variableArgs: false
  53853. };
  53854. t['Tf'] = {
  53855. id: OPS.setFont,
  53856. numArgs: 2,
  53857. variableArgs: false
  53858. };
  53859. t['Tr'] = {
  53860. id: OPS.setTextRenderingMode,
  53861. numArgs: 1,
  53862. variableArgs: false
  53863. };
  53864. t['Ts'] = {
  53865. id: OPS.setTextRise,
  53866. numArgs: 1,
  53867. variableArgs: false
  53868. };
  53869. t['Td'] = {
  53870. id: OPS.moveText,
  53871. numArgs: 2,
  53872. variableArgs: false
  53873. };
  53874. t['TD'] = {
  53875. id: OPS.setLeadingMoveText,
  53876. numArgs: 2,
  53877. variableArgs: false
  53878. };
  53879. t['Tm'] = {
  53880. id: OPS.setTextMatrix,
  53881. numArgs: 6,
  53882. variableArgs: false
  53883. };
  53884. t['T*'] = {
  53885. id: OPS.nextLine,
  53886. numArgs: 0,
  53887. variableArgs: false
  53888. };
  53889. t['Tj'] = {
  53890. id: OPS.showText,
  53891. numArgs: 1,
  53892. variableArgs: false
  53893. };
  53894. t['TJ'] = {
  53895. id: OPS.showSpacedText,
  53896. numArgs: 1,
  53897. variableArgs: false
  53898. };
  53899. t['\''] = {
  53900. id: OPS.nextLineShowText,
  53901. numArgs: 1,
  53902. variableArgs: false
  53903. };
  53904. t['"'] = {
  53905. id: OPS.nextLineSetSpacingShowText,
  53906. numArgs: 3,
  53907. variableArgs: false
  53908. };
  53909. t['d0'] = {
  53910. id: OPS.setCharWidth,
  53911. numArgs: 2,
  53912. variableArgs: false
  53913. };
  53914. t['d1'] = {
  53915. id: OPS.setCharWidthAndBounds,
  53916. numArgs: 6,
  53917. variableArgs: false
  53918. };
  53919. t['CS'] = {
  53920. id: OPS.setStrokeColorSpace,
  53921. numArgs: 1,
  53922. variableArgs: false
  53923. };
  53924. t['cs'] = {
  53925. id: OPS.setFillColorSpace,
  53926. numArgs: 1,
  53927. variableArgs: false
  53928. };
  53929. t['SC'] = {
  53930. id: OPS.setStrokeColor,
  53931. numArgs: 4,
  53932. variableArgs: true
  53933. };
  53934. t['SCN'] = {
  53935. id: OPS.setStrokeColorN,
  53936. numArgs: 33,
  53937. variableArgs: true
  53938. };
  53939. t['sc'] = {
  53940. id: OPS.setFillColor,
  53941. numArgs: 4,
  53942. variableArgs: true
  53943. };
  53944. t['scn'] = {
  53945. id: OPS.setFillColorN,
  53946. numArgs: 33,
  53947. variableArgs: true
  53948. };
  53949. t['G'] = {
  53950. id: OPS.setStrokeGray,
  53951. numArgs: 1,
  53952. variableArgs: false
  53953. };
  53954. t['g'] = {
  53955. id: OPS.setFillGray,
  53956. numArgs: 1,
  53957. variableArgs: false
  53958. };
  53959. t['RG'] = {
  53960. id: OPS.setStrokeRGBColor,
  53961. numArgs: 3,
  53962. variableArgs: false
  53963. };
  53964. t['rg'] = {
  53965. id: OPS.setFillRGBColor,
  53966. numArgs: 3,
  53967. variableArgs: false
  53968. };
  53969. t['K'] = {
  53970. id: OPS.setStrokeCMYKColor,
  53971. numArgs: 4,
  53972. variableArgs: false
  53973. };
  53974. t['k'] = {
  53975. id: OPS.setFillCMYKColor,
  53976. numArgs: 4,
  53977. variableArgs: false
  53978. };
  53979. t['sh'] = {
  53980. id: OPS.shadingFill,
  53981. numArgs: 1,
  53982. variableArgs: false
  53983. };
  53984. t['BI'] = {
  53985. id: OPS.beginInlineImage,
  53986. numArgs: 0,
  53987. variableArgs: false
  53988. };
  53989. t['ID'] = {
  53990. id: OPS.beginImageData,
  53991. numArgs: 0,
  53992. variableArgs: false
  53993. };
  53994. t['EI'] = {
  53995. id: OPS.endInlineImage,
  53996. numArgs: 1,
  53997. variableArgs: false
  53998. };
  53999. t['Do'] = {
  54000. id: OPS.paintXObject,
  54001. numArgs: 1,
  54002. variableArgs: false
  54003. };
  54004. t['MP'] = {
  54005. id: OPS.markPoint,
  54006. numArgs: 1,
  54007. variableArgs: false
  54008. };
  54009. t['DP'] = {
  54010. id: OPS.markPointProps,
  54011. numArgs: 2,
  54012. variableArgs: false
  54013. };
  54014. t['BMC'] = {
  54015. id: OPS.beginMarkedContent,
  54016. numArgs: 1,
  54017. variableArgs: false
  54018. };
  54019. t['BDC'] = {
  54020. id: OPS.beginMarkedContentProps,
  54021. numArgs: 2,
  54022. variableArgs: false
  54023. };
  54024. t['EMC'] = {
  54025. id: OPS.endMarkedContent,
  54026. numArgs: 0,
  54027. variableArgs: false
  54028. };
  54029. t['BX'] = {
  54030. id: OPS.beginCompat,
  54031. numArgs: 0,
  54032. variableArgs: false
  54033. };
  54034. t['EX'] = {
  54035. id: OPS.endCompat,
  54036. numArgs: 0,
  54037. variableArgs: false
  54038. };
  54039. t['BM'] = null;
  54040. t['BD'] = null;
  54041. t['true'] = null;
  54042. t['fa'] = null;
  54043. t['fal'] = null;
  54044. t['fals'] = null;
  54045. t['false'] = null;
  54046. t['nu'] = null;
  54047. t['nul'] = null;
  54048. t['null'] = null;
  54049. });
  54050. function EvaluatorPreprocessor(stream, xref, stateManager) {
  54051. this.opMap = getOPMap();
  54052. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  54053. this.stateManager = stateManager;
  54054. this.nonProcessedArgs = [];
  54055. }
  54056. EvaluatorPreprocessor.prototype = {
  54057. get savedStatesDepth() {
  54058. return this.stateManager.stateStack.length;
  54059. },
  54060. read: function EvaluatorPreprocessor_read(operation) {
  54061. var args = operation.args;
  54062. while (true) {
  54063. var obj = this.parser.getObj();
  54064. if (isCmd(obj)) {
  54065. var cmd = obj.cmd;
  54066. var opSpec = this.opMap[cmd];
  54067. if (!opSpec) {
  54068. warn('Unknown command "' + cmd + '"');
  54069. continue;
  54070. }
  54071. var fn = opSpec.id;
  54072. var numArgs = opSpec.numArgs;
  54073. var argsLength = args !== null ? args.length : 0;
  54074. if (!opSpec.variableArgs) {
  54075. if (argsLength !== numArgs) {
  54076. var nonProcessedArgs = this.nonProcessedArgs;
  54077. while (argsLength > numArgs) {
  54078. nonProcessedArgs.push(args.shift());
  54079. argsLength--;
  54080. }
  54081. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  54082. if (args === null) {
  54083. args = [];
  54084. }
  54085. args.unshift(nonProcessedArgs.pop());
  54086. argsLength++;
  54087. }
  54088. }
  54089. if (argsLength < numArgs) {
  54090. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  54091. if (args !== null) {
  54092. args.length = 0;
  54093. }
  54094. continue;
  54095. }
  54096. } else if (argsLength > numArgs) {
  54097. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  54098. }
  54099. this.preprocessCommand(fn, args);
  54100. operation.fn = fn;
  54101. operation.args = args;
  54102. return true;
  54103. } else {
  54104. if (isEOF(obj)) {
  54105. return false;
  54106. }
  54107. if (obj !== null) {
  54108. if (args === null) {
  54109. args = [];
  54110. }
  54111. args.push(obj);
  54112. assert(args.length <= 33, 'Too many arguments');
  54113. }
  54114. }
  54115. }
  54116. },
  54117. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  54118. switch (fn | 0) {
  54119. case OPS.save:
  54120. this.stateManager.save();
  54121. break;
  54122. case OPS.restore:
  54123. this.stateManager.restore();
  54124. break;
  54125. case OPS.transform:
  54126. this.stateManager.transform(args);
  54127. break;
  54128. }
  54129. }
  54130. };
  54131. return EvaluatorPreprocessor;
  54132. }();
  54133. var QueueOptimizer = function QueueOptimizerClosure() {
  54134. function addState(parentState, pattern, fn) {
  54135. var state = parentState;
  54136. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  54137. var item = pattern[i];
  54138. state = state[item] || (state[item] = []);
  54139. }
  54140. state[pattern[pattern.length - 1]] = fn;
  54141. }
  54142. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  54143. var iFirstPIMXO = iFirstSave + 2;
  54144. for (var i = 0; i < count; i++) {
  54145. var arg = argsArray[iFirstPIMXO + 4 * i];
  54146. var imageMask = arg.length === 1 && arg[0];
  54147. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  54148. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  54149. continue;
  54150. }
  54151. break;
  54152. }
  54153. return count - i;
  54154. }
  54155. var InitialState = [];
  54156. addState(InitialState, [
  54157. OPS.save,
  54158. OPS.transform,
  54159. OPS.paintInlineImageXObject,
  54160. OPS.restore
  54161. ], function foundInlineImageGroup(context) {
  54162. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  54163. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  54164. var MAX_WIDTH = 1000;
  54165. var IMAGE_PADDING = 1;
  54166. var fnArray = context.fnArray, argsArray = context.argsArray;
  54167. var curr = context.iCurr;
  54168. var iFirstSave = curr - 3;
  54169. var iFirstTransform = curr - 2;
  54170. var iFirstPIIXO = curr - 1;
  54171. var i = iFirstSave + 4;
  54172. var ii = fnArray.length;
  54173. while (i + 3 < ii) {
  54174. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  54175. break;
  54176. }
  54177. i += 4;
  54178. }
  54179. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  54180. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  54181. return i;
  54182. }
  54183. var maxX = 0;
  54184. var map = [], maxLineHeight = 0;
  54185. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  54186. var q;
  54187. for (q = 0; q < count; q++) {
  54188. var transform = argsArray[iFirstTransform + (q << 2)];
  54189. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  54190. if (currentX + img.width > MAX_WIDTH) {
  54191. maxX = Math.max(maxX, currentX);
  54192. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  54193. currentX = 0;
  54194. maxLineHeight = 0;
  54195. }
  54196. map.push({
  54197. transform: transform,
  54198. x: currentX,
  54199. y: currentY,
  54200. w: img.width,
  54201. h: img.height
  54202. });
  54203. currentX += img.width + 2 * IMAGE_PADDING;
  54204. maxLineHeight = Math.max(maxLineHeight, img.height);
  54205. }
  54206. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  54207. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  54208. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  54209. var imgRowSize = imgWidth << 2;
  54210. for (q = 0; q < count; q++) {
  54211. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  54212. var rowSize = map[q].w << 2;
  54213. var dataOffset = 0;
  54214. var offset = map[q].x + map[q].y * imgWidth << 2;
  54215. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  54216. for (var k = 0, kk = map[q].h; k < kk; k++) {
  54217. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  54218. dataOffset += rowSize;
  54219. offset += imgRowSize;
  54220. }
  54221. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  54222. while (offset >= 0) {
  54223. data[offset - 4] = data[offset];
  54224. data[offset - 3] = data[offset + 1];
  54225. data[offset - 2] = data[offset + 2];
  54226. data[offset - 1] = data[offset + 3];
  54227. data[offset + rowSize] = data[offset + rowSize - 4];
  54228. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  54229. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  54230. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  54231. offset -= imgRowSize;
  54232. }
  54233. }
  54234. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  54235. argsArray.splice(iFirstSave, count * 4, [
  54236. {
  54237. width: imgWidth,
  54238. height: imgHeight,
  54239. kind: ImageKind.RGBA_32BPP,
  54240. data: imgData
  54241. },
  54242. map
  54243. ]);
  54244. return iFirstSave + 1;
  54245. });
  54246. addState(InitialState, [
  54247. OPS.save,
  54248. OPS.transform,
  54249. OPS.paintImageMaskXObject,
  54250. OPS.restore
  54251. ], function foundImageMaskGroup(context) {
  54252. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  54253. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  54254. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  54255. var fnArray = context.fnArray, argsArray = context.argsArray;
  54256. var curr = context.iCurr;
  54257. var iFirstSave = curr - 3;
  54258. var iFirstTransform = curr - 2;
  54259. var iFirstPIMXO = curr - 1;
  54260. var i = iFirstSave + 4;
  54261. var ii = fnArray.length;
  54262. while (i + 3 < ii) {
  54263. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  54264. break;
  54265. }
  54266. i += 4;
  54267. }
  54268. var count = (i - iFirstSave) / 4;
  54269. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  54270. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  54271. return i;
  54272. }
  54273. var q;
  54274. var isSameImage = false;
  54275. var iTransform, transformArgs;
  54276. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  54277. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  54278. isSameImage = true;
  54279. var firstTransformArg0 = argsArray[iFirstTransform][0];
  54280. var firstTransformArg3 = argsArray[iFirstTransform][3];
  54281. iTransform = iFirstTransform + 4;
  54282. var iPIMXO = iFirstPIMXO + 4;
  54283. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  54284. transformArgs = argsArray[iTransform];
  54285. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  54286. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  54287. isSameImage = false;
  54288. } else {
  54289. count = q;
  54290. }
  54291. break;
  54292. }
  54293. }
  54294. }
  54295. if (isSameImage) {
  54296. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  54297. var positions = new Float32Array(count * 2);
  54298. iTransform = iFirstTransform;
  54299. for (q = 0; q < count; q++, iTransform += 4) {
  54300. transformArgs = argsArray[iTransform];
  54301. positions[q << 1] = transformArgs[4];
  54302. positions[(q << 1) + 1] = transformArgs[5];
  54303. }
  54304. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  54305. argsArray.splice(iFirstSave, count * 4, [
  54306. firstPIMXOArg0,
  54307. firstTransformArg0,
  54308. firstTransformArg3,
  54309. positions
  54310. ]);
  54311. } else {
  54312. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  54313. var images = [];
  54314. for (q = 0; q < count; q++) {
  54315. transformArgs = argsArray[iFirstTransform + (q << 2)];
  54316. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  54317. images.push({
  54318. data: maskParams.data,
  54319. width: maskParams.width,
  54320. height: maskParams.height,
  54321. transform: transformArgs
  54322. });
  54323. }
  54324. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  54325. argsArray.splice(iFirstSave, count * 4, [images]);
  54326. }
  54327. return iFirstSave + 1;
  54328. });
  54329. addState(InitialState, [
  54330. OPS.save,
  54331. OPS.transform,
  54332. OPS.paintImageXObject,
  54333. OPS.restore
  54334. ], function (context) {
  54335. var MIN_IMAGES_IN_BLOCK = 3;
  54336. var MAX_IMAGES_IN_BLOCK = 1000;
  54337. var fnArray = context.fnArray, argsArray = context.argsArray;
  54338. var curr = context.iCurr;
  54339. var iFirstSave = curr - 3;
  54340. var iFirstTransform = curr - 2;
  54341. var iFirstPIXO = curr - 1;
  54342. var iFirstRestore = curr;
  54343. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  54344. return iFirstRestore + 1;
  54345. }
  54346. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  54347. var firstTransformArg0 = argsArray[iFirstTransform][0];
  54348. var firstTransformArg3 = argsArray[iFirstTransform][3];
  54349. var i = iFirstSave + 4;
  54350. var ii = fnArray.length;
  54351. while (i + 3 < ii) {
  54352. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  54353. break;
  54354. }
  54355. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  54356. break;
  54357. }
  54358. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  54359. break;
  54360. }
  54361. i += 4;
  54362. }
  54363. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  54364. if (count < MIN_IMAGES_IN_BLOCK) {
  54365. return i;
  54366. }
  54367. var positions = new Float32Array(count * 2);
  54368. var iTransform = iFirstTransform;
  54369. for (var q = 0; q < count; q++, iTransform += 4) {
  54370. var transformArgs = argsArray[iTransform];
  54371. positions[q << 1] = transformArgs[4];
  54372. positions[(q << 1) + 1] = transformArgs[5];
  54373. }
  54374. var args = [
  54375. firstPIXOArg0,
  54376. firstTransformArg0,
  54377. firstTransformArg3,
  54378. positions
  54379. ];
  54380. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  54381. argsArray.splice(iFirstSave, count * 4, args);
  54382. return iFirstSave + 1;
  54383. });
  54384. addState(InitialState, [
  54385. OPS.beginText,
  54386. OPS.setFont,
  54387. OPS.setTextMatrix,
  54388. OPS.showText,
  54389. OPS.endText
  54390. ], function (context) {
  54391. var MIN_CHARS_IN_BLOCK = 3;
  54392. var MAX_CHARS_IN_BLOCK = 1000;
  54393. var fnArray = context.fnArray, argsArray = context.argsArray;
  54394. var curr = context.iCurr;
  54395. var iFirstBeginText = curr - 4;
  54396. var iFirstSetFont = curr - 3;
  54397. var iFirstSetTextMatrix = curr - 2;
  54398. var iFirstShowText = curr - 1;
  54399. var iFirstEndText = curr;
  54400. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  54401. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  54402. var i = iFirstBeginText + 5;
  54403. var ii = fnArray.length;
  54404. while (i + 4 < ii) {
  54405. 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) {
  54406. break;
  54407. }
  54408. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  54409. break;
  54410. }
  54411. i += 5;
  54412. }
  54413. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  54414. if (count < MIN_CHARS_IN_BLOCK) {
  54415. return i;
  54416. }
  54417. var iFirst = iFirstBeginText;
  54418. 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) {
  54419. count++;
  54420. iFirst -= 5;
  54421. }
  54422. var iEndText = iFirst + 4;
  54423. for (var q = 1; q < count; q++) {
  54424. fnArray.splice(iEndText, 3);
  54425. argsArray.splice(iEndText, 3);
  54426. iEndText += 2;
  54427. }
  54428. return iEndText + 1;
  54429. });
  54430. function QueueOptimizer() {
  54431. }
  54432. QueueOptimizer.prototype = {
  54433. optimize: function QueueOptimizer_optimize(queue) {
  54434. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  54435. var context = {
  54436. iCurr: 0,
  54437. fnArray: fnArray,
  54438. argsArray: argsArray
  54439. };
  54440. var state;
  54441. var i = 0, ii = fnArray.length;
  54442. while (i < ii) {
  54443. state = (state || InitialState)[fnArray[i]];
  54444. if (typeof state === 'function') {
  54445. context.iCurr = i;
  54446. i = state(context);
  54447. state = undefined;
  54448. ii = context.fnArray.length;
  54449. } else {
  54450. i++;
  54451. }
  54452. }
  54453. }
  54454. };
  54455. return QueueOptimizer;
  54456. }();
  54457. exports.OperatorList = OperatorList;
  54458. exports.PartialEvaluator = PartialEvaluator;
  54459. }));
  54460. (function (root, factory) {
  54461. factory(root.pdfjsCoreAnnotation = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreColorSpace, root.pdfjsCoreObj, root.pdfjsCoreEvaluator);
  54462. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreColorSpace, coreObj, coreEvaluator) {
  54463. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  54464. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  54465. var AnnotationFlag = sharedUtil.AnnotationFlag;
  54466. var AnnotationType = sharedUtil.AnnotationType;
  54467. var OPS = sharedUtil.OPS;
  54468. var Util = sharedUtil.Util;
  54469. var isString = sharedUtil.isString;
  54470. var isArray = sharedUtil.isArray;
  54471. var isInt = sharedUtil.isInt;
  54472. var stringToBytes = sharedUtil.stringToBytes;
  54473. var stringToPDFString = sharedUtil.stringToPDFString;
  54474. var warn = sharedUtil.warn;
  54475. var Dict = corePrimitives.Dict;
  54476. var isDict = corePrimitives.isDict;
  54477. var isName = corePrimitives.isName;
  54478. var isRef = corePrimitives.isRef;
  54479. var Stream = coreStream.Stream;
  54480. var ColorSpace = coreColorSpace.ColorSpace;
  54481. var Catalog = coreObj.Catalog;
  54482. var ObjectLoader = coreObj.ObjectLoader;
  54483. var FileSpec = coreObj.FileSpec;
  54484. var OperatorList = coreEvaluator.OperatorList;
  54485. function AnnotationFactory() {
  54486. }
  54487. AnnotationFactory.prototype = {
  54488. create: function AnnotationFactory_create(xref, ref, pdfManager, uniquePrefix, idCounters) {
  54489. var dict = xref.fetchIfRef(ref);
  54490. if (!isDict(dict)) {
  54491. return;
  54492. }
  54493. var id = isRef(ref) ? ref.toString() : 'annot_' + (uniquePrefix || '') + ++idCounters.obj;
  54494. var subtype = dict.get('Subtype');
  54495. subtype = isName(subtype) ? subtype.name : null;
  54496. var parameters = {
  54497. xref: xref,
  54498. dict: dict,
  54499. ref: isRef(ref) ? ref : null,
  54500. subtype: subtype,
  54501. id: id,
  54502. pdfManager: pdfManager
  54503. };
  54504. switch (subtype) {
  54505. case 'Link':
  54506. return new LinkAnnotation(parameters);
  54507. case 'Text':
  54508. return new TextAnnotation(parameters);
  54509. case 'Widget':
  54510. var fieldType = Util.getInheritableProperty(dict, 'FT');
  54511. fieldType = isName(fieldType) ? fieldType.name : null;
  54512. switch (fieldType) {
  54513. case 'Tx':
  54514. return new TextWidgetAnnotation(parameters);
  54515. case 'Ch':
  54516. return new ChoiceWidgetAnnotation(parameters);
  54517. }
  54518. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  54519. return new WidgetAnnotation(parameters);
  54520. case 'Popup':
  54521. return new PopupAnnotation(parameters);
  54522. case 'Highlight':
  54523. return new HighlightAnnotation(parameters);
  54524. case 'Underline':
  54525. return new UnderlineAnnotation(parameters);
  54526. case 'Squiggly':
  54527. return new SquigglyAnnotation(parameters);
  54528. case 'StrikeOut':
  54529. return new StrikeOutAnnotation(parameters);
  54530. case 'FileAttachment':
  54531. return new FileAttachmentAnnotation(parameters);
  54532. default:
  54533. if (!subtype) {
  54534. warn('Annotation is missing the required /Subtype.');
  54535. } else {
  54536. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  54537. }
  54538. return new Annotation(parameters);
  54539. }
  54540. }
  54541. };
  54542. var Annotation = function AnnotationClosure() {
  54543. function getTransformMatrix(rect, bbox, matrix) {
  54544. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  54545. var minX = bounds[0];
  54546. var minY = bounds[1];
  54547. var maxX = bounds[2];
  54548. var maxY = bounds[3];
  54549. if (minX === maxX || minY === maxY) {
  54550. return [
  54551. 1,
  54552. 0,
  54553. 0,
  54554. 1,
  54555. rect[0],
  54556. rect[1]
  54557. ];
  54558. }
  54559. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  54560. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  54561. return [
  54562. xRatio,
  54563. 0,
  54564. 0,
  54565. yRatio,
  54566. rect[0] - minX * xRatio,
  54567. rect[1] - minY * yRatio
  54568. ];
  54569. }
  54570. function getDefaultAppearance(dict) {
  54571. var appearanceState = dict.get('AP');
  54572. if (!isDict(appearanceState)) {
  54573. return;
  54574. }
  54575. var appearance;
  54576. var appearances = appearanceState.get('N');
  54577. if (isDict(appearances)) {
  54578. var as = dict.get('AS');
  54579. if (as && appearances.has(as.name)) {
  54580. appearance = appearances.get(as.name);
  54581. }
  54582. } else {
  54583. appearance = appearances;
  54584. }
  54585. return appearance;
  54586. }
  54587. function Annotation(params) {
  54588. var dict = params.dict;
  54589. this.setFlags(dict.get('F'));
  54590. this.setRectangle(dict.getArray('Rect'));
  54591. this.setColor(dict.getArray('C'));
  54592. this.setBorderStyle(dict);
  54593. this.appearance = getDefaultAppearance(dict);
  54594. this.data = {};
  54595. this.data.id = params.id;
  54596. this.data.subtype = params.subtype;
  54597. this.data.annotationFlags = this.flags;
  54598. this.data.rect = this.rectangle;
  54599. this.data.color = this.color;
  54600. this.data.borderStyle = this.borderStyle;
  54601. this.data.hasAppearance = !!this.appearance;
  54602. }
  54603. Annotation.prototype = {
  54604. _hasFlag: function Annotation_hasFlag(flags, flag) {
  54605. return !!(flags & flag);
  54606. },
  54607. _isViewable: function Annotation_isViewable(flags) {
  54608. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  54609. },
  54610. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  54611. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  54612. },
  54613. get viewable() {
  54614. if (this.flags === 0) {
  54615. return true;
  54616. }
  54617. return this._isViewable(this.flags);
  54618. },
  54619. get printable() {
  54620. if (this.flags === 0) {
  54621. return false;
  54622. }
  54623. return this._isPrintable(this.flags);
  54624. },
  54625. setFlags: function Annotation_setFlags(flags) {
  54626. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  54627. },
  54628. hasFlag: function Annotation_hasFlag(flag) {
  54629. return this._hasFlag(this.flags, flag);
  54630. },
  54631. setRectangle: function Annotation_setRectangle(rectangle) {
  54632. if (isArray(rectangle) && rectangle.length === 4) {
  54633. this.rectangle = Util.normalizeRect(rectangle);
  54634. } else {
  54635. this.rectangle = [
  54636. 0,
  54637. 0,
  54638. 0,
  54639. 0
  54640. ];
  54641. }
  54642. },
  54643. setColor: function Annotation_setColor(color) {
  54644. var rgbColor = new Uint8Array(3);
  54645. if (!isArray(color)) {
  54646. this.color = rgbColor;
  54647. return;
  54648. }
  54649. switch (color.length) {
  54650. case 0:
  54651. this.color = null;
  54652. break;
  54653. case 1:
  54654. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  54655. this.color = rgbColor;
  54656. break;
  54657. case 3:
  54658. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  54659. this.color = rgbColor;
  54660. break;
  54661. case 4:
  54662. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  54663. this.color = rgbColor;
  54664. break;
  54665. default:
  54666. this.color = rgbColor;
  54667. break;
  54668. }
  54669. },
  54670. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  54671. this.borderStyle = new AnnotationBorderStyle();
  54672. if (!isDict(borderStyle)) {
  54673. return;
  54674. }
  54675. if (borderStyle.has('BS')) {
  54676. var dict = borderStyle.get('BS');
  54677. var dictType = dict.get('Type');
  54678. if (!dictType || isName(dictType, 'Border')) {
  54679. this.borderStyle.setWidth(dict.get('W'));
  54680. this.borderStyle.setStyle(dict.get('S'));
  54681. this.borderStyle.setDashArray(dict.getArray('D'));
  54682. }
  54683. } else if (borderStyle.has('Border')) {
  54684. var array = borderStyle.getArray('Border');
  54685. if (isArray(array) && array.length >= 3) {
  54686. this.borderStyle.setHorizontalCornerRadius(array[0]);
  54687. this.borderStyle.setVerticalCornerRadius(array[1]);
  54688. this.borderStyle.setWidth(array[2]);
  54689. if (array.length === 4) {
  54690. this.borderStyle.setDashArray(array[3]);
  54691. }
  54692. }
  54693. } else {
  54694. this.borderStyle.setWidth(0);
  54695. }
  54696. },
  54697. _preparePopup: function Annotation_preparePopup(dict) {
  54698. if (!dict.has('C')) {
  54699. this.data.color = null;
  54700. }
  54701. this.data.hasPopup = dict.has('Popup');
  54702. this.data.title = stringToPDFString(dict.get('T') || '');
  54703. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  54704. },
  54705. loadResources: function Annotation_loadResources(keys) {
  54706. return new Promise(function (resolve, reject) {
  54707. this.appearance.dict.getAsync('Resources').then(function (resources) {
  54708. if (!resources) {
  54709. resolve();
  54710. return;
  54711. }
  54712. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  54713. objectLoader.load().then(function () {
  54714. resolve(resources);
  54715. }, reject);
  54716. }, reject);
  54717. }.bind(this));
  54718. },
  54719. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  54720. if (!this.appearance) {
  54721. return Promise.resolve(new OperatorList());
  54722. }
  54723. var data = this.data;
  54724. var appearanceDict = this.appearance.dict;
  54725. var resourcesPromise = this.loadResources([
  54726. 'ExtGState',
  54727. 'ColorSpace',
  54728. 'Pattern',
  54729. 'Shading',
  54730. 'XObject',
  54731. 'Font'
  54732. ]);
  54733. var bbox = appearanceDict.getArray('BBox') || [
  54734. 0,
  54735. 0,
  54736. 1,
  54737. 1
  54738. ];
  54739. var matrix = appearanceDict.getArray('Matrix') || [
  54740. 1,
  54741. 0,
  54742. 0,
  54743. 1,
  54744. 0,
  54745. 0
  54746. ];
  54747. var transform = getTransformMatrix(data.rect, bbox, matrix);
  54748. var self = this;
  54749. return resourcesPromise.then(function (resources) {
  54750. var opList = new OperatorList();
  54751. opList.addOp(OPS.beginAnnotation, [
  54752. data.rect,
  54753. transform,
  54754. matrix
  54755. ]);
  54756. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  54757. opList.addOp(OPS.endAnnotation, []);
  54758. self.appearance.reset();
  54759. return opList;
  54760. });
  54761. });
  54762. }
  54763. };
  54764. Annotation.appendToOperatorList = function Annotation_appendToOperatorList(annotations, opList, partialEvaluator, task, intent, renderForms) {
  54765. var annotationPromises = [];
  54766. for (var i = 0, n = annotations.length; i < n; ++i) {
  54767. if (intent === 'display' && annotations[i].viewable || intent === 'print' && annotations[i].printable) {
  54768. annotationPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderForms));
  54769. }
  54770. }
  54771. return Promise.all(annotationPromises).then(function (operatorLists) {
  54772. opList.addOp(OPS.beginAnnotations, []);
  54773. for (var i = 0, n = operatorLists.length; i < n; ++i) {
  54774. opList.addOpList(operatorLists[i]);
  54775. }
  54776. opList.addOp(OPS.endAnnotations, []);
  54777. });
  54778. };
  54779. return Annotation;
  54780. }();
  54781. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  54782. function AnnotationBorderStyle() {
  54783. this.width = 1;
  54784. this.style = AnnotationBorderStyleType.SOLID;
  54785. this.dashArray = [3];
  54786. this.horizontalCornerRadius = 0;
  54787. this.verticalCornerRadius = 0;
  54788. }
  54789. AnnotationBorderStyle.prototype = {
  54790. setWidth: function AnnotationBorderStyle_setWidth(width) {
  54791. if (width === (width | 0)) {
  54792. this.width = width;
  54793. }
  54794. },
  54795. setStyle: function AnnotationBorderStyle_setStyle(style) {
  54796. if (!style) {
  54797. return;
  54798. }
  54799. switch (style.name) {
  54800. case 'S':
  54801. this.style = AnnotationBorderStyleType.SOLID;
  54802. break;
  54803. case 'D':
  54804. this.style = AnnotationBorderStyleType.DASHED;
  54805. break;
  54806. case 'B':
  54807. this.style = AnnotationBorderStyleType.BEVELED;
  54808. break;
  54809. case 'I':
  54810. this.style = AnnotationBorderStyleType.INSET;
  54811. break;
  54812. case 'U':
  54813. this.style = AnnotationBorderStyleType.UNDERLINE;
  54814. break;
  54815. default:
  54816. break;
  54817. }
  54818. },
  54819. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  54820. if (isArray(dashArray) && dashArray.length > 0) {
  54821. var isValid = true;
  54822. var allZeros = true;
  54823. for (var i = 0, len = dashArray.length; i < len; i++) {
  54824. var element = dashArray[i];
  54825. var validNumber = +element >= 0;
  54826. if (!validNumber) {
  54827. isValid = false;
  54828. break;
  54829. } else if (element > 0) {
  54830. allZeros = false;
  54831. }
  54832. }
  54833. if (isValid && !allZeros) {
  54834. this.dashArray = dashArray;
  54835. } else {
  54836. this.width = 0;
  54837. }
  54838. } else if (dashArray) {
  54839. this.width = 0;
  54840. }
  54841. },
  54842. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  54843. if (radius === (radius | 0)) {
  54844. this.horizontalCornerRadius = radius;
  54845. }
  54846. },
  54847. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  54848. if (radius === (radius | 0)) {
  54849. this.verticalCornerRadius = radius;
  54850. }
  54851. }
  54852. };
  54853. return AnnotationBorderStyle;
  54854. }();
  54855. var WidgetAnnotation = function WidgetAnnotationClosure() {
  54856. function WidgetAnnotation(params) {
  54857. Annotation.call(this, params);
  54858. var dict = params.dict;
  54859. var data = this.data;
  54860. data.annotationType = AnnotationType.WIDGET;
  54861. data.fieldName = this._constructFieldName(dict);
  54862. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  54863. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  54864. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  54865. var fieldType = Util.getInheritableProperty(dict, 'FT');
  54866. data.fieldType = isName(fieldType) ? fieldType.name : null;
  54867. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  54868. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  54869. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  54870. data.fieldFlags = 0;
  54871. }
  54872. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  54873. if (data.fieldType === 'Sig') {
  54874. this.setFlags(AnnotationFlag.HIDDEN);
  54875. }
  54876. }
  54877. Util.inherit(WidgetAnnotation, Annotation, {
  54878. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  54879. if (!dict.has('T') && !dict.has('Parent')) {
  54880. warn('Unknown field name, falling back to empty field name.');
  54881. return '';
  54882. }
  54883. if (!dict.has('Parent')) {
  54884. return stringToPDFString(dict.get('T'));
  54885. }
  54886. var fieldName = [];
  54887. if (dict.has('T')) {
  54888. fieldName.unshift(stringToPDFString(dict.get('T')));
  54889. }
  54890. var loopDict = dict;
  54891. while (loopDict.has('Parent')) {
  54892. loopDict = loopDict.get('Parent');
  54893. if (loopDict.has('T')) {
  54894. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  54895. }
  54896. }
  54897. return fieldName.join('.');
  54898. },
  54899. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  54900. return !!(this.data.fieldFlags & flag);
  54901. }
  54902. });
  54903. return WidgetAnnotation;
  54904. }();
  54905. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  54906. function TextWidgetAnnotation(params) {
  54907. WidgetAnnotation.call(this, params);
  54908. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  54909. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  54910. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  54911. alignment = null;
  54912. }
  54913. this.data.textAlignment = alignment;
  54914. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  54915. if (!isInt(maximumLength) || maximumLength < 0) {
  54916. maximumLength = null;
  54917. }
  54918. this.data.maxLen = maximumLength;
  54919. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  54920. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  54921. }
  54922. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  54923. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  54924. var operatorList = new OperatorList();
  54925. if (renderForms) {
  54926. return Promise.resolve(operatorList);
  54927. }
  54928. if (this.appearance) {
  54929. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  54930. }
  54931. if (!this.data.defaultAppearance) {
  54932. return Promise.resolve(operatorList);
  54933. }
  54934. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  54935. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  54936. return operatorList;
  54937. });
  54938. }
  54939. });
  54940. return TextWidgetAnnotation;
  54941. }();
  54942. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  54943. function ChoiceWidgetAnnotation(params) {
  54944. WidgetAnnotation.call(this, params);
  54945. this.data.options = [];
  54946. var options = params.dict.getArray('Opt');
  54947. if (isArray(options)) {
  54948. for (var i = 0, ii = options.length; i < ii; i++) {
  54949. var option = options[i];
  54950. this.data.options[i] = {
  54951. exportValue: isArray(option) ? option[0] : option,
  54952. displayValue: isArray(option) ? option[1] : option
  54953. };
  54954. }
  54955. }
  54956. if (!isArray(this.data.fieldValue)) {
  54957. this.data.fieldValue = [this.data.fieldValue];
  54958. }
  54959. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  54960. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  54961. }
  54962. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  54963. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  54964. var operatorList = new OperatorList();
  54965. if (renderForms) {
  54966. return Promise.resolve(operatorList);
  54967. }
  54968. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  54969. }
  54970. });
  54971. return ChoiceWidgetAnnotation;
  54972. }();
  54973. var TextAnnotation = function TextAnnotationClosure() {
  54974. var DEFAULT_ICON_SIZE = 22;
  54975. function TextAnnotation(parameters) {
  54976. Annotation.call(this, parameters);
  54977. this.data.annotationType = AnnotationType.TEXT;
  54978. if (this.data.hasAppearance) {
  54979. this.data.name = 'NoIcon';
  54980. } else {
  54981. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  54982. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  54983. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  54984. }
  54985. this._preparePopup(parameters.dict);
  54986. }
  54987. Util.inherit(TextAnnotation, Annotation, {});
  54988. return TextAnnotation;
  54989. }();
  54990. var LinkAnnotation = function LinkAnnotationClosure() {
  54991. function LinkAnnotation(params) {
  54992. Annotation.call(this, params);
  54993. var data = this.data;
  54994. data.annotationType = AnnotationType.LINK;
  54995. Catalog.parseDestDictionary({
  54996. destDict: params.dict,
  54997. resultObj: data,
  54998. docBaseUrl: params.pdfManager.docBaseUrl
  54999. });
  55000. }
  55001. Util.inherit(LinkAnnotation, Annotation, {});
  55002. return LinkAnnotation;
  55003. }();
  55004. var PopupAnnotation = function PopupAnnotationClosure() {
  55005. function PopupAnnotation(parameters) {
  55006. Annotation.call(this, parameters);
  55007. this.data.annotationType = AnnotationType.POPUP;
  55008. var dict = parameters.dict;
  55009. var parentItem = dict.get('Parent');
  55010. if (!parentItem) {
  55011. warn('Popup annotation has a missing or invalid parent annotation.');
  55012. return;
  55013. }
  55014. this.data.parentId = dict.getRaw('Parent').toString();
  55015. this.data.title = stringToPDFString(parentItem.get('T') || '');
  55016. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  55017. if (!parentItem.has('C')) {
  55018. this.data.color = null;
  55019. } else {
  55020. this.setColor(parentItem.getArray('C'));
  55021. this.data.color = this.color;
  55022. }
  55023. if (!this.viewable) {
  55024. var parentFlags = parentItem.get('F');
  55025. if (this._isViewable(parentFlags)) {
  55026. this.setFlags(parentFlags);
  55027. }
  55028. }
  55029. }
  55030. Util.inherit(PopupAnnotation, Annotation, {});
  55031. return PopupAnnotation;
  55032. }();
  55033. var HighlightAnnotation = function HighlightAnnotationClosure() {
  55034. function HighlightAnnotation(parameters) {
  55035. Annotation.call(this, parameters);
  55036. this.data.annotationType = AnnotationType.HIGHLIGHT;
  55037. this._preparePopup(parameters.dict);
  55038. this.data.borderStyle.setWidth(0);
  55039. }
  55040. Util.inherit(HighlightAnnotation, Annotation, {});
  55041. return HighlightAnnotation;
  55042. }();
  55043. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  55044. function UnderlineAnnotation(parameters) {
  55045. Annotation.call(this, parameters);
  55046. this.data.annotationType = AnnotationType.UNDERLINE;
  55047. this._preparePopup(parameters.dict);
  55048. this.data.borderStyle.setWidth(0);
  55049. }
  55050. Util.inherit(UnderlineAnnotation, Annotation, {});
  55051. return UnderlineAnnotation;
  55052. }();
  55053. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  55054. function SquigglyAnnotation(parameters) {
  55055. Annotation.call(this, parameters);
  55056. this.data.annotationType = AnnotationType.SQUIGGLY;
  55057. this._preparePopup(parameters.dict);
  55058. this.data.borderStyle.setWidth(0);
  55059. }
  55060. Util.inherit(SquigglyAnnotation, Annotation, {});
  55061. return SquigglyAnnotation;
  55062. }();
  55063. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  55064. function StrikeOutAnnotation(parameters) {
  55065. Annotation.call(this, parameters);
  55066. this.data.annotationType = AnnotationType.STRIKEOUT;
  55067. this._preparePopup(parameters.dict);
  55068. this.data.borderStyle.setWidth(0);
  55069. }
  55070. Util.inherit(StrikeOutAnnotation, Annotation, {});
  55071. return StrikeOutAnnotation;
  55072. }();
  55073. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  55074. function FileAttachmentAnnotation(parameters) {
  55075. Annotation.call(this, parameters);
  55076. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  55077. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  55078. this.data.file = file.serializable;
  55079. this._preparePopup(parameters.dict);
  55080. }
  55081. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  55082. return FileAttachmentAnnotation;
  55083. }();
  55084. exports.Annotation = Annotation;
  55085. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  55086. exports.AnnotationFactory = AnnotationFactory;
  55087. }));
  55088. (function (root, factory) {
  55089. factory(root.pdfjsCoreDocument = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreObj, root.pdfjsCoreParser, root.pdfjsCoreCrypto, root.pdfjsCoreEvaluator, root.pdfjsCoreAnnotation);
  55090. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreObj, coreParser, coreCrypto, coreEvaluator, coreAnnotation) {
  55091. var MissingDataException = sharedUtil.MissingDataException;
  55092. var Util = sharedUtil.Util;
  55093. var assert = sharedUtil.assert;
  55094. var error = sharedUtil.error;
  55095. var info = sharedUtil.info;
  55096. var isArray = sharedUtil.isArray;
  55097. var isArrayBuffer = sharedUtil.isArrayBuffer;
  55098. var isNum = sharedUtil.isNum;
  55099. var isString = sharedUtil.isString;
  55100. var shadow = sharedUtil.shadow;
  55101. var stringToBytes = sharedUtil.stringToBytes;
  55102. var stringToPDFString = sharedUtil.stringToPDFString;
  55103. var warn = sharedUtil.warn;
  55104. var isSpace = sharedUtil.isSpace;
  55105. var Dict = corePrimitives.Dict;
  55106. var isDict = corePrimitives.isDict;
  55107. var isName = corePrimitives.isName;
  55108. var isStream = corePrimitives.isStream;
  55109. var NullStream = coreStream.NullStream;
  55110. var Stream = coreStream.Stream;
  55111. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  55112. var Catalog = coreObj.Catalog;
  55113. var ObjectLoader = coreObj.ObjectLoader;
  55114. var XRef = coreObj.XRef;
  55115. var Linearization = coreParser.Linearization;
  55116. var calculateMD5 = coreCrypto.calculateMD5;
  55117. var OperatorList = coreEvaluator.OperatorList;
  55118. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  55119. var Annotation = coreAnnotation.Annotation;
  55120. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  55121. var Page = function PageClosure() {
  55122. var DEFAULT_USER_UNIT = 1.0;
  55123. var LETTER_SIZE_MEDIABOX = [
  55124. 0,
  55125. 0,
  55126. 612,
  55127. 792
  55128. ];
  55129. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache) {
  55130. this.pdfManager = pdfManager;
  55131. this.pageIndex = pageIndex;
  55132. this.pageDict = pageDict;
  55133. this.xref = xref;
  55134. this.ref = ref;
  55135. this.fontCache = fontCache;
  55136. this.uniquePrefix = 'p' + this.pageIndex + '_';
  55137. this.idCounters = { obj: 0 };
  55138. this.evaluatorOptions = pdfManager.evaluatorOptions;
  55139. this.resourcesPromise = null;
  55140. }
  55141. Page.prototype = {
  55142. getPageProp: function Page_getPageProp(key) {
  55143. return this.pageDict.get(key);
  55144. },
  55145. getInheritedPageProp: function Page_getInheritedPageProp(key) {
  55146. var dict = this.pageDict, valueArray = null, loopCount = 0;
  55147. var MAX_LOOP_COUNT = 100;
  55148. while (dict) {
  55149. var value = dict.get(key);
  55150. if (value) {
  55151. if (!valueArray) {
  55152. valueArray = [];
  55153. }
  55154. valueArray.push(value);
  55155. }
  55156. if (++loopCount > MAX_LOOP_COUNT) {
  55157. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  55158. break;
  55159. }
  55160. dict = dict.get('Parent');
  55161. }
  55162. if (!valueArray) {
  55163. return Dict.empty;
  55164. }
  55165. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  55166. return valueArray[0];
  55167. }
  55168. return Dict.merge(this.xref, valueArray);
  55169. },
  55170. get content() {
  55171. return this.getPageProp('Contents');
  55172. },
  55173. get resources() {
  55174. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  55175. },
  55176. get mediaBox() {
  55177. var obj = this.getInheritedPageProp('MediaBox');
  55178. if (!isArray(obj) || obj.length !== 4) {
  55179. obj = LETTER_SIZE_MEDIABOX;
  55180. }
  55181. return shadow(this, 'mediaBox', obj);
  55182. },
  55183. get userUnit() {
  55184. var obj = this.getPageProp('UserUnit');
  55185. if (!isNum(obj) || obj <= 0) {
  55186. obj = DEFAULT_USER_UNIT;
  55187. }
  55188. return shadow(this, 'userUnit', obj);
  55189. },
  55190. get view() {
  55191. var mediaBox = this.mediaBox;
  55192. var cropBox = this.getInheritedPageProp('CropBox');
  55193. if (!isArray(cropBox) || cropBox.length !== 4) {
  55194. return shadow(this, 'view', mediaBox);
  55195. }
  55196. cropBox = Util.intersect(cropBox, mediaBox);
  55197. if (!cropBox) {
  55198. return shadow(this, 'view', mediaBox);
  55199. }
  55200. return shadow(this, 'view', cropBox);
  55201. },
  55202. get rotate() {
  55203. var rotate = this.getInheritedPageProp('Rotate') || 0;
  55204. if (rotate % 90 !== 0) {
  55205. rotate = 0;
  55206. } else if (rotate >= 360) {
  55207. rotate = rotate % 360;
  55208. } else if (rotate < 0) {
  55209. rotate = (rotate % 360 + 360) % 360;
  55210. }
  55211. return shadow(this, 'rotate', rotate);
  55212. },
  55213. getContentStream: function Page_getContentStream() {
  55214. var content = this.content;
  55215. var stream;
  55216. if (isArray(content)) {
  55217. var xref = this.xref;
  55218. var i, n = content.length;
  55219. var streams = [];
  55220. for (i = 0; i < n; ++i) {
  55221. streams.push(xref.fetchIfRef(content[i]));
  55222. }
  55223. stream = new StreamsSequenceStream(streams);
  55224. } else if (isStream(content)) {
  55225. stream = content;
  55226. } else {
  55227. stream = new NullStream();
  55228. }
  55229. return stream;
  55230. },
  55231. loadResources: function Page_loadResources(keys) {
  55232. if (!this.resourcesPromise) {
  55233. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  55234. }
  55235. return this.resourcesPromise.then(function resourceSuccess() {
  55236. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  55237. return objectLoader.load();
  55238. }.bind(this));
  55239. },
  55240. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  55241. var self = this;
  55242. var pdfManager = this.pdfManager;
  55243. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  55244. var resourcesPromise = this.loadResources([
  55245. 'ExtGState',
  55246. 'ColorSpace',
  55247. 'Pattern',
  55248. 'Shading',
  55249. 'XObject',
  55250. 'Font'
  55251. ]);
  55252. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.uniquePrefix, this.idCounters, this.fontCache, this.evaluatorOptions);
  55253. var dataPromises = Promise.all([
  55254. contentStreamPromise,
  55255. resourcesPromise
  55256. ]);
  55257. var pageListPromise = dataPromises.then(function (data) {
  55258. var contentStream = data[0];
  55259. var opList = new OperatorList(intent, handler, self.pageIndex);
  55260. handler.send('StartRenderPage', {
  55261. transparency: partialEvaluator.hasBlendModes(self.resources),
  55262. pageIndex: self.pageIndex,
  55263. intent: intent
  55264. });
  55265. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  55266. return opList;
  55267. });
  55268. });
  55269. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  55270. return Promise.all([
  55271. pageListPromise,
  55272. annotationsPromise
  55273. ]).then(function (datas) {
  55274. var pageOpList = datas[0];
  55275. var annotations = datas[1];
  55276. if (annotations.length === 0) {
  55277. pageOpList.flush(true);
  55278. return pageOpList;
  55279. }
  55280. var annotationsReadyPromise = Annotation.appendToOperatorList(annotations, pageOpList, partialEvaluator, task, intent, renderInteractiveForms);
  55281. return annotationsReadyPromise.then(function () {
  55282. pageOpList.flush(true);
  55283. return pageOpList;
  55284. });
  55285. });
  55286. },
  55287. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  55288. var handler = {
  55289. on: function nullHandlerOn() {
  55290. },
  55291. send: function nullHandlerSend() {
  55292. }
  55293. };
  55294. var self = this;
  55295. var pdfManager = this.pdfManager;
  55296. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  55297. var resourcesPromise = this.loadResources([
  55298. 'ExtGState',
  55299. 'XObject',
  55300. 'Font'
  55301. ]);
  55302. var dataPromises = Promise.all([
  55303. contentStreamPromise,
  55304. resourcesPromise
  55305. ]);
  55306. return dataPromises.then(function (data) {
  55307. var contentStream = data[0];
  55308. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.uniquePrefix, self.idCounters, self.fontCache, self.evaluatorOptions);
  55309. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  55310. });
  55311. },
  55312. getAnnotationsData: function Page_getAnnotationsData(intent) {
  55313. var annotations = this.annotations;
  55314. var annotationsData = [];
  55315. for (var i = 0, n = annotations.length; i < n; ++i) {
  55316. if (intent) {
  55317. if (!(intent === 'display' && annotations[i].viewable) && !(intent === 'print' && annotations[i].printable)) {
  55318. continue;
  55319. }
  55320. }
  55321. annotationsData.push(annotations[i].data);
  55322. }
  55323. return annotationsData;
  55324. },
  55325. get annotations() {
  55326. var annotations = [];
  55327. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  55328. var annotationFactory = new AnnotationFactory();
  55329. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  55330. var annotationRef = annotationRefs[i];
  55331. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.uniquePrefix, this.idCounters);
  55332. if (annotation) {
  55333. annotations.push(annotation);
  55334. }
  55335. }
  55336. return shadow(this, 'annotations', annotations);
  55337. }
  55338. };
  55339. return Page;
  55340. }();
  55341. var PDFDocument = function PDFDocumentClosure() {
  55342. var FINGERPRINT_FIRST_BYTES = 1024;
  55343. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  55344. function PDFDocument(pdfManager, arg, password) {
  55345. if (isStream(arg)) {
  55346. init.call(this, pdfManager, arg, password);
  55347. } else if (isArrayBuffer(arg)) {
  55348. init.call(this, pdfManager, new Stream(arg), password);
  55349. } else {
  55350. error('PDFDocument: Unknown argument type');
  55351. }
  55352. }
  55353. function init(pdfManager, stream, password) {
  55354. assert(stream.length > 0, 'stream must have data');
  55355. this.pdfManager = pdfManager;
  55356. this.stream = stream;
  55357. var xref = new XRef(this.stream, password, pdfManager);
  55358. this.xref = xref;
  55359. }
  55360. function find(stream, needle, limit, backwards) {
  55361. var pos = stream.pos;
  55362. var end = stream.end;
  55363. var strBuf = [];
  55364. if (pos + limit > end) {
  55365. limit = end - pos;
  55366. }
  55367. for (var n = 0; n < limit; ++n) {
  55368. strBuf.push(String.fromCharCode(stream.getByte()));
  55369. }
  55370. var str = strBuf.join('');
  55371. stream.pos = pos;
  55372. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  55373. if (index === -1) {
  55374. return false;
  55375. }
  55376. stream.pos += index;
  55377. return true;
  55378. }
  55379. var DocumentInfoValidators = {
  55380. get entries() {
  55381. return shadow(this, 'entries', {
  55382. Title: isString,
  55383. Author: isString,
  55384. Subject: isString,
  55385. Keywords: isString,
  55386. Creator: isString,
  55387. Producer: isString,
  55388. CreationDate: isString,
  55389. ModDate: isString,
  55390. Trapped: isName
  55391. });
  55392. }
  55393. };
  55394. PDFDocument.prototype = {
  55395. parse: function PDFDocument_parse(recoveryMode) {
  55396. this.setup(recoveryMode);
  55397. var version = this.catalog.catDict.get('Version');
  55398. if (isName(version)) {
  55399. this.pdfFormatVersion = version.name;
  55400. }
  55401. try {
  55402. this.acroForm = this.catalog.catDict.get('AcroForm');
  55403. if (this.acroForm) {
  55404. this.xfa = this.acroForm.get('XFA');
  55405. var fields = this.acroForm.get('Fields');
  55406. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  55407. this.acroForm = null;
  55408. }
  55409. }
  55410. } catch (ex) {
  55411. info('Something wrong with AcroForm entry');
  55412. this.acroForm = null;
  55413. }
  55414. },
  55415. get linearization() {
  55416. var linearization = null;
  55417. if (this.stream.length) {
  55418. try {
  55419. linearization = Linearization.create(this.stream);
  55420. } catch (err) {
  55421. if (err instanceof MissingDataException) {
  55422. throw err;
  55423. }
  55424. info(err);
  55425. }
  55426. }
  55427. return shadow(this, 'linearization', linearization);
  55428. },
  55429. get startXRef() {
  55430. var stream = this.stream;
  55431. var startXRef = 0;
  55432. var linearization = this.linearization;
  55433. if (linearization) {
  55434. stream.reset();
  55435. if (find(stream, 'endobj', 1024)) {
  55436. startXRef = stream.pos + 6;
  55437. }
  55438. } else {
  55439. var step = 1024;
  55440. var found = false, pos = stream.end;
  55441. while (!found && pos > 0) {
  55442. pos -= step - 'startxref'.length;
  55443. if (pos < 0) {
  55444. pos = 0;
  55445. }
  55446. stream.pos = pos;
  55447. found = find(stream, 'startxref', step, true);
  55448. }
  55449. if (found) {
  55450. stream.skip(9);
  55451. var ch;
  55452. do {
  55453. ch = stream.getByte();
  55454. } while (isSpace(ch));
  55455. var str = '';
  55456. while (ch >= 0x20 && ch <= 0x39) {
  55457. str += String.fromCharCode(ch);
  55458. ch = stream.getByte();
  55459. }
  55460. startXRef = parseInt(str, 10);
  55461. if (isNaN(startXRef)) {
  55462. startXRef = 0;
  55463. }
  55464. }
  55465. }
  55466. return shadow(this, 'startXRef', startXRef);
  55467. },
  55468. get mainXRefEntriesOffset() {
  55469. var mainXRefEntriesOffset = 0;
  55470. var linearization = this.linearization;
  55471. if (linearization) {
  55472. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  55473. }
  55474. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  55475. },
  55476. checkHeader: function PDFDocument_checkHeader() {
  55477. var stream = this.stream;
  55478. stream.reset();
  55479. if (find(stream, '%PDF-', 1024)) {
  55480. stream.moveStart();
  55481. var MAX_VERSION_LENGTH = 12;
  55482. var version = '', ch;
  55483. while ((ch = stream.getByte()) > 0x20) {
  55484. if (version.length >= MAX_VERSION_LENGTH) {
  55485. break;
  55486. }
  55487. version += String.fromCharCode(ch);
  55488. }
  55489. if (!this.pdfFormatVersion) {
  55490. this.pdfFormatVersion = version.substring(5);
  55491. }
  55492. return;
  55493. }
  55494. },
  55495. parseStartXRef: function PDFDocument_parseStartXRef() {
  55496. var startXRef = this.startXRef;
  55497. this.xref.setStartXRef(startXRef);
  55498. },
  55499. setup: function PDFDocument_setup(recoveryMode) {
  55500. this.xref.parse(recoveryMode);
  55501. var self = this;
  55502. var pageFactory = {
  55503. createPage: function (pageIndex, dict, ref, fontCache) {
  55504. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache);
  55505. }
  55506. };
  55507. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  55508. },
  55509. get numPages() {
  55510. var linearization = this.linearization;
  55511. var num = linearization ? linearization.numPages : this.catalog.numPages;
  55512. return shadow(this, 'numPages', num);
  55513. },
  55514. get documentInfo() {
  55515. var docInfo = {
  55516. PDFFormatVersion: this.pdfFormatVersion,
  55517. IsAcroFormPresent: !!this.acroForm,
  55518. IsXFAPresent: !!this.xfa
  55519. };
  55520. var infoDict;
  55521. try {
  55522. infoDict = this.xref.trailer.get('Info');
  55523. } catch (err) {
  55524. info('The document information dictionary is invalid.');
  55525. }
  55526. if (infoDict) {
  55527. var validEntries = DocumentInfoValidators.entries;
  55528. for (var key in validEntries) {
  55529. if (infoDict.has(key)) {
  55530. var value = infoDict.get(key);
  55531. if (validEntries[key](value)) {
  55532. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  55533. } else {
  55534. info('Bad value in document info for "' + key + '"');
  55535. }
  55536. }
  55537. }
  55538. }
  55539. return shadow(this, 'documentInfo', docInfo);
  55540. },
  55541. get fingerprint() {
  55542. var xref = this.xref, hash, fileID = '';
  55543. var idArray = xref.trailer.get('ID');
  55544. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  55545. hash = stringToBytes(idArray[0]);
  55546. } else {
  55547. if (this.stream.ensureRange) {
  55548. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  55549. }
  55550. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  55551. }
  55552. for (var i = 0, n = hash.length; i < n; i++) {
  55553. var hex = hash[i].toString(16);
  55554. fileID += hex.length === 1 ? '0' + hex : hex;
  55555. }
  55556. return shadow(this, 'fingerprint', fileID);
  55557. },
  55558. getPage: function PDFDocument_getPage(pageIndex) {
  55559. return this.catalog.getPage(pageIndex);
  55560. },
  55561. cleanup: function PDFDocument_cleanup() {
  55562. return this.catalog.cleanup();
  55563. }
  55564. };
  55565. return PDFDocument;
  55566. }();
  55567. exports.Page = Page;
  55568. exports.PDFDocument = PDFDocument;
  55569. }));
  55570. (function (root, factory) {
  55571. factory(root.pdfjsCorePdfManager = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreChunkedStream, root.pdfjsCoreDocument);
  55572. }(this, function (exports, sharedUtil, coreStream, coreChunkedStream, coreDocument) {
  55573. var warn = sharedUtil.warn;
  55574. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  55575. var shadow = sharedUtil.shadow;
  55576. var NotImplementedException = sharedUtil.NotImplementedException;
  55577. var MissingDataException = sharedUtil.MissingDataException;
  55578. var createPromiseCapability = sharedUtil.createPromiseCapability;
  55579. var Util = sharedUtil.Util;
  55580. var Stream = coreStream.Stream;
  55581. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  55582. var PDFDocument = coreDocument.PDFDocument;
  55583. var BasePdfManager = function BasePdfManagerClosure() {
  55584. function BasePdfManager() {
  55585. throw new Error('Cannot initialize BaseManagerManager');
  55586. }
  55587. BasePdfManager.prototype = {
  55588. get docId() {
  55589. return this._docId;
  55590. },
  55591. get docBaseUrl() {
  55592. var docBaseUrl = null;
  55593. if (this._docBaseUrl) {
  55594. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  55595. if (absoluteUrl) {
  55596. docBaseUrl = absoluteUrl.href;
  55597. } else {
  55598. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  55599. }
  55600. }
  55601. return shadow(this, 'docBaseUrl', docBaseUrl);
  55602. },
  55603. onLoadedStream: function BasePdfManager_onLoadedStream() {
  55604. throw new NotImplementedException();
  55605. },
  55606. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  55607. return this.ensure(this.pdfDocument, prop, args);
  55608. },
  55609. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  55610. return this.ensure(this.pdfDocument.xref, prop, args);
  55611. },
  55612. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  55613. return this.ensure(this.pdfDocument.catalog, prop, args);
  55614. },
  55615. getPage: function BasePdfManager_getPage(pageIndex) {
  55616. return this.pdfDocument.getPage(pageIndex);
  55617. },
  55618. cleanup: function BasePdfManager_cleanup() {
  55619. return this.pdfDocument.cleanup();
  55620. },
  55621. ensure: function BasePdfManager_ensure(obj, prop, args) {
  55622. return new NotImplementedException();
  55623. },
  55624. requestRange: function BasePdfManager_requestRange(begin, end) {
  55625. return new NotImplementedException();
  55626. },
  55627. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  55628. return new NotImplementedException();
  55629. },
  55630. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  55631. return new NotImplementedException();
  55632. },
  55633. updatePassword: function BasePdfManager_updatePassword(password) {
  55634. this.pdfDocument.xref.password = this.password = password;
  55635. if (this._passwordChangedCapability) {
  55636. this._passwordChangedCapability.resolve();
  55637. }
  55638. },
  55639. passwordChanged: function BasePdfManager_passwordChanged() {
  55640. this._passwordChangedCapability = createPromiseCapability();
  55641. return this._passwordChangedCapability.promise;
  55642. },
  55643. terminate: function BasePdfManager_terminate() {
  55644. return new NotImplementedException();
  55645. }
  55646. };
  55647. return BasePdfManager;
  55648. }();
  55649. var LocalPdfManager = function LocalPdfManagerClosure() {
  55650. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  55651. this._docId = docId;
  55652. this._docBaseUrl = docBaseUrl;
  55653. this.evaluatorOptions = evaluatorOptions;
  55654. var stream = new Stream(data);
  55655. this.pdfDocument = new PDFDocument(this, stream, password);
  55656. this._loadedStreamCapability = createPromiseCapability();
  55657. this._loadedStreamCapability.resolve(stream);
  55658. }
  55659. Util.inherit(LocalPdfManager, BasePdfManager, {
  55660. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  55661. return new Promise(function (resolve, reject) {
  55662. try {
  55663. var value = obj[prop];
  55664. var result;
  55665. if (typeof value === 'function') {
  55666. result = value.apply(obj, args);
  55667. } else {
  55668. result = value;
  55669. }
  55670. resolve(result);
  55671. } catch (e) {
  55672. reject(e);
  55673. }
  55674. });
  55675. },
  55676. requestRange: function LocalPdfManager_requestRange(begin, end) {
  55677. return Promise.resolve();
  55678. },
  55679. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  55680. return;
  55681. },
  55682. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  55683. return this._loadedStreamCapability.promise;
  55684. },
  55685. terminate: function LocalPdfManager_terminate() {
  55686. return;
  55687. }
  55688. });
  55689. return LocalPdfManager;
  55690. }();
  55691. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  55692. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  55693. this._docId = docId;
  55694. this._docBaseUrl = docBaseUrl;
  55695. this.msgHandler = args.msgHandler;
  55696. this.evaluatorOptions = evaluatorOptions;
  55697. var params = {
  55698. msgHandler: args.msgHandler,
  55699. url: args.url,
  55700. length: args.length,
  55701. disableAutoFetch: args.disableAutoFetch,
  55702. rangeChunkSize: args.rangeChunkSize
  55703. };
  55704. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  55705. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream(), args.password);
  55706. }
  55707. Util.inherit(NetworkPdfManager, BasePdfManager, {
  55708. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  55709. var pdfManager = this;
  55710. return new Promise(function (resolve, reject) {
  55711. function ensureHelper() {
  55712. try {
  55713. var result;
  55714. var value = obj[prop];
  55715. if (typeof value === 'function') {
  55716. result = value.apply(obj, args);
  55717. } else {
  55718. result = value;
  55719. }
  55720. resolve(result);
  55721. } catch (e) {
  55722. if (!(e instanceof MissingDataException)) {
  55723. reject(e);
  55724. return;
  55725. }
  55726. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  55727. }
  55728. }
  55729. ensureHelper();
  55730. });
  55731. },
  55732. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  55733. return this.streamManager.requestRange(begin, end);
  55734. },
  55735. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  55736. this.streamManager.requestAllChunks();
  55737. },
  55738. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  55739. this.streamManager.onReceiveData({ chunk: chunk });
  55740. },
  55741. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  55742. return this.streamManager.onLoadedStream();
  55743. },
  55744. terminate: function NetworkPdfManager_terminate() {
  55745. this.streamManager.abort();
  55746. }
  55747. });
  55748. return NetworkPdfManager;
  55749. }();
  55750. exports.LocalPdfManager = LocalPdfManager;
  55751. exports.NetworkPdfManager = NetworkPdfManager;
  55752. }));
  55753. (function (root, factory) {
  55754. factory(root.pdfjsCoreWorker = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePdfManager);
  55755. }(this, function (exports, sharedUtil, corePrimitives, corePdfManager) {
  55756. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  55757. var InvalidPDFException = sharedUtil.InvalidPDFException;
  55758. var MessageHandler = sharedUtil.MessageHandler;
  55759. var MissingPDFException = sharedUtil.MissingPDFException;
  55760. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  55761. var PasswordException = sharedUtil.PasswordException;
  55762. var PasswordResponses = sharedUtil.PasswordResponses;
  55763. var UnknownErrorException = sharedUtil.UnknownErrorException;
  55764. var XRefParseException = sharedUtil.XRefParseException;
  55765. var arrayByteLength = sharedUtil.arrayByteLength;
  55766. var arraysToBytes = sharedUtil.arraysToBytes;
  55767. var assert = sharedUtil.assert;
  55768. var createPromiseCapability = sharedUtil.createPromiseCapability;
  55769. var error = sharedUtil.error;
  55770. var info = sharedUtil.info;
  55771. var warn = sharedUtil.warn;
  55772. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  55773. var Ref = corePrimitives.Ref;
  55774. var LocalPdfManager = corePdfManager.LocalPdfManager;
  55775. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  55776. var globalScope = sharedUtil.globalScope;
  55777. var WorkerTask = function WorkerTaskClosure() {
  55778. function WorkerTask(name) {
  55779. this.name = name;
  55780. this.terminated = false;
  55781. this._capability = createPromiseCapability();
  55782. }
  55783. WorkerTask.prototype = {
  55784. get finished() {
  55785. return this._capability.promise;
  55786. },
  55787. finish: function () {
  55788. this._capability.resolve();
  55789. },
  55790. terminate: function () {
  55791. this.terminated = true;
  55792. },
  55793. ensureNotTerminated: function () {
  55794. if (this.terminated) {
  55795. throw new Error('Worker task was terminated');
  55796. }
  55797. }
  55798. };
  55799. return WorkerTask;
  55800. }();
  55801. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  55802. function PDFWorkerStream(params, msgHandler) {
  55803. this._queuedChunks = [];
  55804. var initialData = params.initialData;
  55805. if (initialData && initialData.length > 0) {
  55806. this._queuedChunks.push(initialData);
  55807. }
  55808. this._msgHandler = msgHandler;
  55809. this._isRangeSupported = !params.disableRange;
  55810. this._isStreamingSupported = !params.disableStream;
  55811. this._contentLength = params.length;
  55812. this._fullRequestReader = null;
  55813. this._rangeReaders = [];
  55814. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  55815. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  55816. }
  55817. PDFWorkerStream.prototype = {
  55818. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  55819. if (args.begin === undefined) {
  55820. if (this._fullRequestReader) {
  55821. this._fullRequestReader._enqueue(args.chunk);
  55822. } else {
  55823. this._queuedChunks.push(args.chunk);
  55824. }
  55825. } else {
  55826. var found = this._rangeReaders.some(function (rangeReader) {
  55827. if (rangeReader._begin !== args.begin) {
  55828. return false;
  55829. }
  55830. rangeReader._enqueue(args.chunk);
  55831. return true;
  55832. });
  55833. assert(found);
  55834. }
  55835. },
  55836. _onProgress: function PDFWorkerStream_onProgress(evt) {
  55837. if (this._rangeReaders.length > 0) {
  55838. var firstReader = this._rangeReaders[0];
  55839. if (firstReader.onProgress) {
  55840. firstReader.onProgress({ loaded: evt.loaded });
  55841. }
  55842. }
  55843. },
  55844. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  55845. var i = this._rangeReaders.indexOf(reader);
  55846. if (i >= 0) {
  55847. this._rangeReaders.splice(i, 1);
  55848. }
  55849. },
  55850. getFullReader: function PDFWorkerStream_getFullReader() {
  55851. assert(!this._fullRequestReader);
  55852. var queuedChunks = this._queuedChunks;
  55853. this._queuedChunks = null;
  55854. return new PDFWorkerStreamReader(this, queuedChunks);
  55855. },
  55856. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  55857. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  55858. this._msgHandler.send('RequestDataRange', {
  55859. begin: begin,
  55860. end: end
  55861. });
  55862. this._rangeReaders.push(reader);
  55863. return reader;
  55864. },
  55865. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  55866. if (this._fullRequestReader) {
  55867. this._fullRequestReader.cancel(reason);
  55868. }
  55869. var readers = this._rangeReaders.slice(0);
  55870. readers.forEach(function (rangeReader) {
  55871. rangeReader.cancel(reason);
  55872. });
  55873. }
  55874. };
  55875. function PDFWorkerStreamReader(stream, queuedChunks) {
  55876. this._stream = stream;
  55877. this._done = false;
  55878. this._queuedChunks = queuedChunks || [];
  55879. this._requests = [];
  55880. this._headersReady = Promise.resolve();
  55881. stream._fullRequestReader = this;
  55882. this.onProgress = null;
  55883. }
  55884. PDFWorkerStreamReader.prototype = {
  55885. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  55886. if (this._done) {
  55887. return;
  55888. }
  55889. if (this._requests.length > 0) {
  55890. var requestCapability = this._requests.shift();
  55891. requestCapability.resolve({
  55892. value: chunk,
  55893. done: false
  55894. });
  55895. return;
  55896. }
  55897. this._queuedChunks.push(chunk);
  55898. },
  55899. get headersReady() {
  55900. return this._headersReady;
  55901. },
  55902. get isRangeSupported() {
  55903. return this._stream._isRangeSupported;
  55904. },
  55905. get isStreamingSupported() {
  55906. return this._stream._isStreamingSupported;
  55907. },
  55908. get contentLength() {
  55909. return this._stream._contentLength;
  55910. },
  55911. read: function PDFWorkerStreamReader_read() {
  55912. if (this._queuedChunks.length > 0) {
  55913. var chunk = this._queuedChunks.shift();
  55914. return Promise.resolve({
  55915. value: chunk,
  55916. done: false
  55917. });
  55918. }
  55919. if (this._done) {
  55920. return Promise.resolve({
  55921. value: undefined,
  55922. done: true
  55923. });
  55924. }
  55925. var requestCapability = createPromiseCapability();
  55926. this._requests.push(requestCapability);
  55927. return requestCapability.promise;
  55928. },
  55929. cancel: function PDFWorkerStreamReader_cancel(reason) {
  55930. this._done = true;
  55931. this._requests.forEach(function (requestCapability) {
  55932. requestCapability.resolve({
  55933. value: undefined,
  55934. done: true
  55935. });
  55936. });
  55937. this._requests = [];
  55938. }
  55939. };
  55940. function PDFWorkerStreamRangeReader(stream, begin, end) {
  55941. this._stream = stream;
  55942. this._begin = begin;
  55943. this._end = end;
  55944. this._queuedChunk = null;
  55945. this._requests = [];
  55946. this._done = false;
  55947. this.onProgress = null;
  55948. }
  55949. PDFWorkerStreamRangeReader.prototype = {
  55950. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  55951. if (this._done) {
  55952. return;
  55953. }
  55954. if (this._requests.length === 0) {
  55955. this._queuedChunk = chunk;
  55956. } else {
  55957. var requestsCapability = this._requests.shift();
  55958. requestsCapability.resolve({
  55959. value: chunk,
  55960. done: false
  55961. });
  55962. this._requests.forEach(function (requestCapability) {
  55963. requestCapability.resolve({
  55964. value: undefined,
  55965. done: true
  55966. });
  55967. });
  55968. this._requests = [];
  55969. }
  55970. this._done = true;
  55971. this._stream._removeRangeReader(this);
  55972. },
  55973. get isStreamingSupported() {
  55974. return false;
  55975. },
  55976. read: function PDFWorkerStreamRangeReader_read() {
  55977. if (this._queuedChunk) {
  55978. return Promise.resolve({
  55979. value: this._queuedChunk,
  55980. done: false
  55981. });
  55982. }
  55983. if (this._done) {
  55984. return Promise.resolve({
  55985. value: undefined,
  55986. done: true
  55987. });
  55988. }
  55989. var requestCapability = createPromiseCapability();
  55990. this._requests.push(requestCapability);
  55991. return requestCapability.promise;
  55992. },
  55993. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  55994. this._done = true;
  55995. this._requests.forEach(function (requestCapability) {
  55996. requestCapability.resolve({
  55997. value: undefined,
  55998. done: true
  55999. });
  56000. });
  56001. this._requests = [];
  56002. this._stream._removeRangeReader(this);
  56003. }
  56004. };
  56005. return PDFWorkerStream;
  56006. }();
  56007. var PDFNetworkStream;
  56008. function setPDFNetworkStreamClass(cls) {
  56009. PDFNetworkStream = cls;
  56010. }
  56011. var WorkerMessageHandler = {
  56012. setup: function wphSetup(handler, port) {
  56013. var testMessageProcessed = false;
  56014. handler.on('test', function wphSetupTest(data) {
  56015. if (testMessageProcessed) {
  56016. return;
  56017. }
  56018. testMessageProcessed = true;
  56019. if (!(data instanceof Uint8Array)) {
  56020. handler.send('test', 'main', false);
  56021. return;
  56022. }
  56023. var supportTransfers = data[0] === 255;
  56024. handler.postMessageTransfers = supportTransfers;
  56025. var xhr = new XMLHttpRequest();
  56026. var responseExists = 'response' in xhr;
  56027. try {
  56028. var dummy = xhr.responseType;
  56029. } catch (e) {
  56030. responseExists = false;
  56031. }
  56032. if (!responseExists) {
  56033. handler.send('test', false);
  56034. return;
  56035. }
  56036. handler.send('test', {
  56037. supportTypedArray: true,
  56038. supportTransfers: supportTransfers
  56039. });
  56040. });
  56041. handler.on('configure', function wphConfigure(data) {
  56042. setVerbosityLevel(data.verbosity);
  56043. });
  56044. handler.on('GetDocRequest', function wphSetupDoc(data) {
  56045. return WorkerMessageHandler.createDocumentHandler(data, port);
  56046. });
  56047. },
  56048. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  56049. var pdfManager;
  56050. var terminated = false;
  56051. var cancelXHRs = null;
  56052. var WorkerTasks = [];
  56053. var docId = docParams.docId;
  56054. var docBaseUrl = docParams.docBaseUrl;
  56055. var workerHandlerName = docParams.docId + '_worker';
  56056. var handler = new MessageHandler(workerHandlerName, docId, port);
  56057. handler.postMessageTransfers = docParams.postMessageTransfers;
  56058. function ensureNotTerminated() {
  56059. if (terminated) {
  56060. throw new Error('Worker was terminated');
  56061. }
  56062. }
  56063. function startWorkerTask(task) {
  56064. WorkerTasks.push(task);
  56065. }
  56066. function finishWorkerTask(task) {
  56067. task.finish();
  56068. var i = WorkerTasks.indexOf(task);
  56069. WorkerTasks.splice(i, 1);
  56070. }
  56071. function loadDocument(recoveryMode) {
  56072. var loadDocumentCapability = createPromiseCapability();
  56073. var parseSuccess = function parseSuccess() {
  56074. var numPagesPromise = pdfManager.ensureDoc('numPages');
  56075. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  56076. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  56077. Promise.all([
  56078. numPagesPromise,
  56079. fingerprintPromise,
  56080. encryptedPromise
  56081. ]).then(function onDocReady(results) {
  56082. var doc = {
  56083. numPages: results[0],
  56084. fingerprint: results[1],
  56085. encrypted: !!results[2]
  56086. };
  56087. loadDocumentCapability.resolve(doc);
  56088. }, parseFailure);
  56089. };
  56090. var parseFailure = function parseFailure(e) {
  56091. loadDocumentCapability.reject(e);
  56092. };
  56093. pdfManager.ensureDoc('checkHeader', []).then(function () {
  56094. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  56095. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  56096. }, parseFailure);
  56097. }, parseFailure);
  56098. return loadDocumentCapability.promise;
  56099. }
  56100. function getPdfManager(data, evaluatorOptions) {
  56101. var pdfManagerCapability = createPromiseCapability();
  56102. var pdfManager;
  56103. var source = data.source;
  56104. if (source.data) {
  56105. try {
  56106. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  56107. pdfManagerCapability.resolve(pdfManager);
  56108. } catch (ex) {
  56109. pdfManagerCapability.reject(ex);
  56110. }
  56111. return pdfManagerCapability.promise;
  56112. }
  56113. var pdfStream;
  56114. try {
  56115. if (source.chunkedViewerLoading) {
  56116. pdfStream = new PDFWorkerStream(source, handler);
  56117. } else {
  56118. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  56119. pdfStream = new PDFNetworkStream(data);
  56120. }
  56121. } catch (ex) {
  56122. pdfManagerCapability.reject(ex);
  56123. return pdfManagerCapability.promise;
  56124. }
  56125. var fullRequest = pdfStream.getFullReader();
  56126. fullRequest.headersReady.then(function () {
  56127. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  56128. fullRequest.onProgress = function (evt) {
  56129. handler.send('DocProgress', {
  56130. loaded: evt.loaded,
  56131. total: evt.total
  56132. });
  56133. };
  56134. }
  56135. if (!fullRequest.isRangeSupported) {
  56136. return;
  56137. }
  56138. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  56139. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  56140. msgHandler: handler,
  56141. url: source.url,
  56142. password: source.password,
  56143. length: fullRequest.contentLength,
  56144. disableAutoFetch: disableAutoFetch,
  56145. rangeChunkSize: source.rangeChunkSize
  56146. }, evaluatorOptions, docBaseUrl);
  56147. pdfManagerCapability.resolve(pdfManager);
  56148. cancelXHRs = null;
  56149. }).catch(function (reason) {
  56150. pdfManagerCapability.reject(reason);
  56151. cancelXHRs = null;
  56152. });
  56153. var cachedChunks = [], loaded = 0;
  56154. var flushChunks = function () {
  56155. var pdfFile = arraysToBytes(cachedChunks);
  56156. if (source.length && pdfFile.length !== source.length) {
  56157. warn('reported HTTP length is different from actual');
  56158. }
  56159. try {
  56160. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  56161. pdfManagerCapability.resolve(pdfManager);
  56162. } catch (ex) {
  56163. pdfManagerCapability.reject(ex);
  56164. }
  56165. cachedChunks = [];
  56166. };
  56167. var readPromise = new Promise(function (resolve, reject) {
  56168. var readChunk = function (chunk) {
  56169. try {
  56170. ensureNotTerminated();
  56171. if (chunk.done) {
  56172. if (!pdfManager) {
  56173. flushChunks();
  56174. }
  56175. cancelXHRs = null;
  56176. return;
  56177. }
  56178. var data = chunk.value;
  56179. loaded += arrayByteLength(data);
  56180. if (!fullRequest.isStreamingSupported) {
  56181. handler.send('DocProgress', {
  56182. loaded: loaded,
  56183. total: Math.max(loaded, fullRequest.contentLength || 0)
  56184. });
  56185. }
  56186. if (pdfManager) {
  56187. pdfManager.sendProgressiveData(data);
  56188. } else {
  56189. cachedChunks.push(data);
  56190. }
  56191. fullRequest.read().then(readChunk, reject);
  56192. } catch (e) {
  56193. reject(e);
  56194. }
  56195. };
  56196. fullRequest.read().then(readChunk, reject);
  56197. });
  56198. readPromise.catch(function (e) {
  56199. pdfManagerCapability.reject(e);
  56200. cancelXHRs = null;
  56201. });
  56202. cancelXHRs = function () {
  56203. pdfStream.cancelAllRequests('abort');
  56204. };
  56205. return pdfManagerCapability.promise;
  56206. }
  56207. var setupDoc = function (data) {
  56208. var onSuccess = function (doc) {
  56209. ensureNotTerminated();
  56210. handler.send('GetDoc', { pdfInfo: doc });
  56211. };
  56212. var onFailure = function (e) {
  56213. if (e instanceof PasswordException) {
  56214. if (e.code === PasswordResponses.NEED_PASSWORD) {
  56215. handler.send('NeedPassword', e);
  56216. } else if (e.code === PasswordResponses.INCORRECT_PASSWORD) {
  56217. handler.send('IncorrectPassword', e);
  56218. }
  56219. } else if (e instanceof InvalidPDFException) {
  56220. handler.send('InvalidPDF', e);
  56221. } else if (e instanceof MissingPDFException) {
  56222. handler.send('MissingPDF', e);
  56223. } else if (e instanceof UnexpectedResponseException) {
  56224. handler.send('UnexpectedResponse', e);
  56225. } else {
  56226. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  56227. }
  56228. };
  56229. ensureNotTerminated();
  56230. var cMapOptions = {
  56231. url: data.cMapUrl === undefined ? null : data.cMapUrl,
  56232. packed: data.cMapPacked === true
  56233. };
  56234. var evaluatorOptions = {
  56235. forceDataSchema: data.disableCreateObjectURL,
  56236. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  56237. disableFontFace: data.disableFontFace,
  56238. cMapOptions: cMapOptions
  56239. };
  56240. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  56241. if (terminated) {
  56242. newPdfManager.terminate();
  56243. throw new Error('Worker was terminated');
  56244. }
  56245. pdfManager = newPdfManager;
  56246. handler.send('PDFManagerReady', null);
  56247. pdfManager.onLoadedStream().then(function (stream) {
  56248. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  56249. });
  56250. }).then(function pdfManagerReady() {
  56251. ensureNotTerminated();
  56252. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  56253. ensureNotTerminated();
  56254. if (!(ex instanceof XRefParseException)) {
  56255. if (ex instanceof PasswordException) {
  56256. pdfManager.passwordChanged().then(pdfManagerReady);
  56257. }
  56258. onFailure(ex);
  56259. return;
  56260. }
  56261. pdfManager.requestLoadedStream();
  56262. pdfManager.onLoadedStream().then(function () {
  56263. ensureNotTerminated();
  56264. loadDocument(true).then(onSuccess, onFailure);
  56265. });
  56266. }, onFailure);
  56267. }, onFailure);
  56268. };
  56269. handler.on('GetPage', function wphSetupGetPage(data) {
  56270. return pdfManager.getPage(data.pageIndex).then(function (page) {
  56271. var rotatePromise = pdfManager.ensure(page, 'rotate');
  56272. var refPromise = pdfManager.ensure(page, 'ref');
  56273. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  56274. var viewPromise = pdfManager.ensure(page, 'view');
  56275. return Promise.all([
  56276. rotatePromise,
  56277. refPromise,
  56278. userUnitPromise,
  56279. viewPromise
  56280. ]).then(function (results) {
  56281. return {
  56282. rotate: results[0],
  56283. ref: results[1],
  56284. userUnit: results[2],
  56285. view: results[3]
  56286. };
  56287. });
  56288. });
  56289. });
  56290. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  56291. var ref = new Ref(data.ref.num, data.ref.gen);
  56292. var catalog = pdfManager.pdfDocument.catalog;
  56293. return catalog.getPageIndex(ref);
  56294. });
  56295. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  56296. return pdfManager.ensureCatalog('destinations');
  56297. });
  56298. handler.on('GetDestination', function wphSetupGetDestination(data) {
  56299. return pdfManager.ensureCatalog('getDestination', [data.id]);
  56300. });
  56301. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  56302. return pdfManager.ensureCatalog('pageLabels');
  56303. });
  56304. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  56305. return pdfManager.ensureCatalog('attachments');
  56306. });
  56307. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  56308. return pdfManager.ensureCatalog('javaScript');
  56309. });
  56310. handler.on('GetOutline', function wphSetupGetOutline(data) {
  56311. return pdfManager.ensureCatalog('documentOutline');
  56312. });
  56313. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  56314. return Promise.all([
  56315. pdfManager.ensureDoc('documentInfo'),
  56316. pdfManager.ensureCatalog('metadata')
  56317. ]);
  56318. });
  56319. handler.on('GetData', function wphSetupGetData(data) {
  56320. pdfManager.requestLoadedStream();
  56321. return pdfManager.onLoadedStream().then(function (stream) {
  56322. return stream.bytes;
  56323. });
  56324. });
  56325. handler.on('GetStats', function wphSetupGetStats(data) {
  56326. return pdfManager.pdfDocument.xref.stats;
  56327. });
  56328. handler.on('UpdatePassword', function wphSetupUpdatePassword(data) {
  56329. pdfManager.updatePassword(data);
  56330. });
  56331. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  56332. return pdfManager.getPage(data.pageIndex).then(function (page) {
  56333. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  56334. });
  56335. });
  56336. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  56337. var pageIndex = data.pageIndex;
  56338. pdfManager.getPage(pageIndex).then(function (page) {
  56339. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  56340. startWorkerTask(task);
  56341. var pageNum = pageIndex + 1;
  56342. var start = Date.now();
  56343. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  56344. finishWorkerTask(task);
  56345. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  56346. }, function (e) {
  56347. finishWorkerTask(task);
  56348. if (task.terminated) {
  56349. return;
  56350. }
  56351. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  56352. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  56353. var wrappedException;
  56354. if (typeof e === 'string') {
  56355. wrappedException = {
  56356. message: e,
  56357. stack: minimumStackMessage
  56358. };
  56359. } else if (typeof e === 'object') {
  56360. wrappedException = {
  56361. message: e.message || e.toString(),
  56362. stack: e.stack || minimumStackMessage
  56363. };
  56364. } else {
  56365. wrappedException = {
  56366. message: 'Unknown exception type: ' + typeof e,
  56367. stack: minimumStackMessage
  56368. };
  56369. }
  56370. handler.send('PageError', {
  56371. pageNum: pageNum,
  56372. error: wrappedException,
  56373. intent: data.intent
  56374. });
  56375. });
  56376. });
  56377. }, this);
  56378. handler.on('GetTextContent', function wphExtractText(data) {
  56379. var pageIndex = data.pageIndex;
  56380. var normalizeWhitespace = data.normalizeWhitespace;
  56381. var combineTextItems = data.combineTextItems;
  56382. return pdfManager.getPage(pageIndex).then(function (page) {
  56383. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  56384. startWorkerTask(task);
  56385. var pageNum = pageIndex + 1;
  56386. var start = Date.now();
  56387. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  56388. finishWorkerTask(task);
  56389. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  56390. return textContent;
  56391. }, function (reason) {
  56392. finishWorkerTask(task);
  56393. if (task.terminated) {
  56394. return;
  56395. }
  56396. throw reason;
  56397. });
  56398. });
  56399. });
  56400. handler.on('Cleanup', function wphCleanup(data) {
  56401. return pdfManager.cleanup();
  56402. });
  56403. handler.on('Terminate', function wphTerminate(data) {
  56404. terminated = true;
  56405. if (pdfManager) {
  56406. pdfManager.terminate();
  56407. pdfManager = null;
  56408. }
  56409. if (cancelXHRs) {
  56410. cancelXHRs();
  56411. }
  56412. var waitOn = [];
  56413. WorkerTasks.forEach(function (task) {
  56414. waitOn.push(task.finished);
  56415. task.terminate();
  56416. });
  56417. return Promise.all(waitOn).then(function () {
  56418. handler.destroy();
  56419. handler = null;
  56420. });
  56421. });
  56422. handler.on('Ready', function wphReady(data) {
  56423. setupDoc(docParams);
  56424. docParams = null;
  56425. });
  56426. return workerHandlerName;
  56427. }
  56428. };
  56429. function initializeWorker() {
  56430. if (!('console' in globalScope)) {
  56431. var consoleTimer = {};
  56432. var workerConsole = {
  56433. log: function log() {
  56434. var args = Array.prototype.slice.call(arguments);
  56435. globalScope.postMessage({
  56436. targetName: 'main',
  56437. action: 'console_log',
  56438. data: args
  56439. });
  56440. },
  56441. error: function error() {
  56442. var args = Array.prototype.slice.call(arguments);
  56443. globalScope.postMessage({
  56444. targetName: 'main',
  56445. action: 'console_error',
  56446. data: args
  56447. });
  56448. throw 'pdf.js execution error';
  56449. },
  56450. time: function time(name) {
  56451. consoleTimer[name] = Date.now();
  56452. },
  56453. timeEnd: function timeEnd(name) {
  56454. var time = consoleTimer[name];
  56455. if (!time) {
  56456. error('Unknown timer name ' + name);
  56457. }
  56458. this.log('Timer:', name, Date.now() - time);
  56459. }
  56460. };
  56461. globalScope.console = workerConsole;
  56462. }
  56463. var handler = new MessageHandler('worker', 'main', self);
  56464. WorkerMessageHandler.setup(handler, self);
  56465. handler.send('ready', null);
  56466. }
  56467. if (typeof window === 'undefined' && !(typeof module !== 'undefined' && module.require)) {
  56468. initializeWorker();
  56469. }
  56470. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  56471. exports.WorkerTask = WorkerTask;
  56472. exports.WorkerMessageHandler = WorkerMessageHandler;
  56473. }));
  56474. (function (root, factory) {
  56475. factory(root.pdfjsCoreNetwork = {}, root.pdfjsSharedUtil, root.pdfjsCoreWorker);
  56476. }(this, function (exports, sharedUtil, coreWorker) {
  56477. var OK_RESPONSE = 200;
  56478. var PARTIAL_CONTENT_RESPONSE = 206;
  56479. function NetworkManager(url, args) {
  56480. this.url = url;
  56481. args = args || {};
  56482. this.isHttp = /^https?:/i.test(url);
  56483. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  56484. this.withCredentials = args.withCredentials || false;
  56485. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  56486. return new XMLHttpRequest();
  56487. };
  56488. this.currXhrId = 0;
  56489. this.pendingRequests = Object.create(null);
  56490. this.loadedRequests = Object.create(null);
  56491. }
  56492. function getArrayBuffer(xhr) {
  56493. var data = xhr.response;
  56494. if (typeof data !== 'string') {
  56495. return data;
  56496. }
  56497. var length = data.length;
  56498. var array = new Uint8Array(length);
  56499. for (var i = 0; i < length; i++) {
  56500. array[i] = data.charCodeAt(i) & 0xFF;
  56501. }
  56502. return array.buffer;
  56503. }
  56504. var supportsMozChunked = function supportsMozChunkedClosure() {
  56505. try {
  56506. var x = new XMLHttpRequest();
  56507. x.open('GET', 'https://example.com');
  56508. x.responseType = 'moz-chunked-arraybuffer';
  56509. return x.responseType === 'moz-chunked-arraybuffer';
  56510. } catch (e) {
  56511. return false;
  56512. }
  56513. }();
  56514. NetworkManager.prototype = {
  56515. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  56516. var args = {
  56517. begin: begin,
  56518. end: end
  56519. };
  56520. for (var prop in listeners) {
  56521. args[prop] = listeners[prop];
  56522. }
  56523. return this.request(args);
  56524. },
  56525. requestFull: function NetworkManager_requestFull(listeners) {
  56526. return this.request(listeners);
  56527. },
  56528. request: function NetworkManager_request(args) {
  56529. var xhr = this.getXhr();
  56530. var xhrId = this.currXhrId++;
  56531. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  56532. xhr.open('GET', this.url);
  56533. xhr.withCredentials = this.withCredentials;
  56534. for (var property in this.httpHeaders) {
  56535. var value = this.httpHeaders[property];
  56536. if (typeof value === 'undefined') {
  56537. continue;
  56538. }
  56539. xhr.setRequestHeader(property, value);
  56540. }
  56541. if (this.isHttp && 'begin' in args && 'end' in args) {
  56542. var rangeStr = args.begin + '-' + (args.end - 1);
  56543. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  56544. pendingRequest.expectedStatus = 206;
  56545. } else {
  56546. pendingRequest.expectedStatus = 200;
  56547. }
  56548. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  56549. if (useMozChunkedLoading) {
  56550. xhr.responseType = 'moz-chunked-arraybuffer';
  56551. pendingRequest.onProgressiveData = args.onProgressiveData;
  56552. pendingRequest.mozChunked = true;
  56553. } else {
  56554. xhr.responseType = 'arraybuffer';
  56555. }
  56556. if (args.onError) {
  56557. xhr.onerror = function (evt) {
  56558. args.onError(xhr.status);
  56559. };
  56560. }
  56561. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  56562. xhr.onprogress = this.onProgress.bind(this, xhrId);
  56563. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  56564. pendingRequest.onDone = args.onDone;
  56565. pendingRequest.onError = args.onError;
  56566. pendingRequest.onProgress = args.onProgress;
  56567. xhr.send(null);
  56568. return xhrId;
  56569. },
  56570. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  56571. var pendingRequest = this.pendingRequests[xhrId];
  56572. if (!pendingRequest) {
  56573. return;
  56574. }
  56575. if (pendingRequest.mozChunked) {
  56576. var chunk = getArrayBuffer(pendingRequest.xhr);
  56577. pendingRequest.onProgressiveData(chunk);
  56578. }
  56579. var onProgress = pendingRequest.onProgress;
  56580. if (onProgress) {
  56581. onProgress(evt);
  56582. }
  56583. },
  56584. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  56585. var pendingRequest = this.pendingRequests[xhrId];
  56586. if (!pendingRequest) {
  56587. return;
  56588. }
  56589. var xhr = pendingRequest.xhr;
  56590. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  56591. pendingRequest.onHeadersReceived();
  56592. delete pendingRequest.onHeadersReceived;
  56593. }
  56594. if (xhr.readyState !== 4) {
  56595. return;
  56596. }
  56597. if (!(xhrId in this.pendingRequests)) {
  56598. return;
  56599. }
  56600. delete this.pendingRequests[xhrId];
  56601. if (xhr.status === 0 && this.isHttp) {
  56602. if (pendingRequest.onError) {
  56603. pendingRequest.onError(xhr.status);
  56604. }
  56605. return;
  56606. }
  56607. var xhrStatus = xhr.status || OK_RESPONSE;
  56608. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  56609. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  56610. if (pendingRequest.onError) {
  56611. pendingRequest.onError(xhr.status);
  56612. }
  56613. return;
  56614. }
  56615. this.loadedRequests[xhrId] = true;
  56616. var chunk = getArrayBuffer(xhr);
  56617. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  56618. var rangeHeader = xhr.getResponseHeader('Content-Range');
  56619. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  56620. var begin = parseInt(matches[1], 10);
  56621. pendingRequest.onDone({
  56622. begin: begin,
  56623. chunk: chunk
  56624. });
  56625. } else if (pendingRequest.onProgressiveData) {
  56626. pendingRequest.onDone(null);
  56627. } else if (chunk) {
  56628. pendingRequest.onDone({
  56629. begin: 0,
  56630. chunk: chunk
  56631. });
  56632. } else if (pendingRequest.onError) {
  56633. pendingRequest.onError(xhr.status);
  56634. }
  56635. },
  56636. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  56637. for (var xhrId in this.pendingRequests) {
  56638. return true;
  56639. }
  56640. return false;
  56641. },
  56642. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  56643. return this.pendingRequests[xhrId].xhr;
  56644. },
  56645. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  56646. return !!this.pendingRequests[xhrId].onProgressiveData;
  56647. },
  56648. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  56649. return xhrId in this.pendingRequests;
  56650. },
  56651. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  56652. return xhrId in this.loadedRequests;
  56653. },
  56654. abortAllRequests: function NetworkManager_abortAllRequests() {
  56655. for (var xhrId in this.pendingRequests) {
  56656. this.abortRequest(xhrId | 0);
  56657. }
  56658. },
  56659. abortRequest: function NetworkManager_abortRequest(xhrId) {
  56660. var xhr = this.pendingRequests[xhrId].xhr;
  56661. delete this.pendingRequests[xhrId];
  56662. xhr.abort();
  56663. }
  56664. };
  56665. var assert = sharedUtil.assert;
  56666. var createPromiseCapability = sharedUtil.createPromiseCapability;
  56667. var isInt = sharedUtil.isInt;
  56668. var MissingPDFException = sharedUtil.MissingPDFException;
  56669. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  56670. function PDFNetworkStream(options) {
  56671. this._options = options;
  56672. var source = options.source;
  56673. this._manager = new NetworkManager(source.url, {
  56674. httpHeaders: source.httpHeaders,
  56675. withCredentials: source.withCredentials
  56676. });
  56677. this._rangeChunkSize = source.rangeChunkSize;
  56678. this._fullRequestReader = null;
  56679. this._rangeRequestReaders = [];
  56680. }
  56681. PDFNetworkStream.prototype = {
  56682. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  56683. var i = this._rangeRequestReaders.indexOf(reader);
  56684. if (i >= 0) {
  56685. this._rangeRequestReaders.splice(i, 1);
  56686. }
  56687. },
  56688. getFullReader: function PDFNetworkStream_getFullReader() {
  56689. assert(!this._fullRequestReader);
  56690. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  56691. return this._fullRequestReader;
  56692. },
  56693. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  56694. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  56695. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  56696. this._rangeRequestReaders.push(reader);
  56697. return reader;
  56698. },
  56699. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  56700. if (this._fullRequestReader) {
  56701. this._fullRequestReader.cancel(reason);
  56702. }
  56703. var readers = this._rangeRequestReaders.slice(0);
  56704. readers.forEach(function (reader) {
  56705. reader.cancel(reason);
  56706. });
  56707. }
  56708. };
  56709. function PDFNetworkStreamFullRequestReader(manager, options) {
  56710. this._manager = manager;
  56711. var source = options.source;
  56712. var args = {
  56713. onHeadersReceived: this._onHeadersReceived.bind(this),
  56714. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  56715. onDone: this._onDone.bind(this),
  56716. onError: this._onError.bind(this),
  56717. onProgress: this._onProgress.bind(this)
  56718. };
  56719. this._url = source.url;
  56720. this._fullRequestId = manager.requestFull(args);
  56721. this._headersReceivedCapability = createPromiseCapability();
  56722. this._disableRange = options.disableRange || false;
  56723. this._contentLength = source.length;
  56724. this._rangeChunkSize = source.rangeChunkSize;
  56725. if (!this._rangeChunkSize && !this._disableRange) {
  56726. this._disableRange = true;
  56727. }
  56728. this._isStreamingSupported = false;
  56729. this._isRangeSupported = false;
  56730. this._cachedChunks = [];
  56731. this._requests = [];
  56732. this._done = false;
  56733. this._storedError = undefined;
  56734. this.onProgress = null;
  56735. }
  56736. PDFNetworkStreamFullRequestReader.prototype = {
  56737. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  56738. if (this._disableRange) {
  56739. return false;
  56740. }
  56741. var networkManager = this._manager;
  56742. if (!networkManager.isHttp) {
  56743. return false;
  56744. }
  56745. var fullRequestXhrId = this._fullRequestId;
  56746. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  56747. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  56748. return false;
  56749. }
  56750. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  56751. if (contentEncoding !== 'identity') {
  56752. return false;
  56753. }
  56754. var length = fullRequestXhr.getResponseHeader('Content-Length');
  56755. length = parseInt(length, 10);
  56756. if (!isInt(length)) {
  56757. return false;
  56758. }
  56759. this._contentLength = length;
  56760. if (length <= 2 * this._rangeChunkSize) {
  56761. return false;
  56762. }
  56763. return true;
  56764. },
  56765. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  56766. if (this._validateRangeRequestCapabilities()) {
  56767. this._isRangeSupported = true;
  56768. }
  56769. var networkManager = this._manager;
  56770. var fullRequestXhrId = this._fullRequestId;
  56771. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  56772. this._isStreamingSupported = true;
  56773. } else if (this._isRangeSupported) {
  56774. networkManager.abortRequest(fullRequestXhrId);
  56775. }
  56776. this._headersReceivedCapability.resolve();
  56777. },
  56778. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  56779. if (this._requests.length > 0) {
  56780. var requestCapability = this._requests.shift();
  56781. requestCapability.resolve({
  56782. value: chunk,
  56783. done: false
  56784. });
  56785. } else {
  56786. this._cachedChunks.push(chunk);
  56787. }
  56788. },
  56789. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  56790. if (args) {
  56791. this._onProgressiveData(args.chunk);
  56792. }
  56793. this._done = true;
  56794. if (this._cachedChunks.length > 0) {
  56795. return;
  56796. }
  56797. this._requests.forEach(function (requestCapability) {
  56798. requestCapability.resolve({
  56799. value: undefined,
  56800. done: true
  56801. });
  56802. });
  56803. this._requests = [];
  56804. },
  56805. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  56806. var url = this._url;
  56807. var exception;
  56808. if (status === 404 || status === 0 && /^file:/.test(url)) {
  56809. exception = new MissingPDFException('Missing PDF "' + url + '".');
  56810. } else {
  56811. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  56812. }
  56813. this._storedError = exception;
  56814. this._headersReceivedCapability.reject(exception);
  56815. this._requests.forEach(function (requestCapability) {
  56816. requestCapability.reject(exception);
  56817. });
  56818. this._requests = [];
  56819. this._cachedChunks = [];
  56820. },
  56821. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  56822. if (this.onProgress) {
  56823. this.onProgress({
  56824. loaded: data.loaded,
  56825. total: data.lengthComputable ? data.total : this._contentLength
  56826. });
  56827. }
  56828. },
  56829. get isRangeSupported() {
  56830. return this._isRangeSupported;
  56831. },
  56832. get isStreamingSupported() {
  56833. return this._isStreamingSupported;
  56834. },
  56835. get contentLength() {
  56836. return this._contentLength;
  56837. },
  56838. get headersReady() {
  56839. return this._headersReceivedCapability.promise;
  56840. },
  56841. read: function PDFNetworkStreamFullRequestReader_read() {
  56842. if (this._storedError) {
  56843. return Promise.reject(this._storedError);
  56844. }
  56845. if (this._cachedChunks.length > 0) {
  56846. var chunk = this._cachedChunks.shift();
  56847. return Promise.resolve(chunk);
  56848. }
  56849. if (this._done) {
  56850. return Promise.resolve({
  56851. value: undefined,
  56852. done: true
  56853. });
  56854. }
  56855. var requestCapability = createPromiseCapability();
  56856. this._requests.push(requestCapability);
  56857. return requestCapability.promise;
  56858. },
  56859. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  56860. this._done = true;
  56861. this._headersReceivedCapability.reject(reason);
  56862. this._requests.forEach(function (requestCapability) {
  56863. requestCapability.resolve({
  56864. value: undefined,
  56865. done: true
  56866. });
  56867. });
  56868. this._requests = [];
  56869. if (this._manager.isPendingRequest(this._fullRequestId)) {
  56870. this._manager.abortRequest(this._fullRequestId);
  56871. }
  56872. this._fullRequestReader = null;
  56873. }
  56874. };
  56875. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  56876. this._manager = manager;
  56877. var args = {
  56878. onDone: this._onDone.bind(this),
  56879. onProgress: this._onProgress.bind(this)
  56880. };
  56881. this._requestId = manager.requestRange(begin, end, args);
  56882. this._requests = [];
  56883. this._queuedChunk = null;
  56884. this._done = false;
  56885. this.onProgress = null;
  56886. this.onClosed = null;
  56887. }
  56888. PDFNetworkStreamRangeRequestReader.prototype = {
  56889. _close: function PDFNetworkStreamRangeRequestReader_close() {
  56890. if (this.onClosed) {
  56891. this.onClosed(this);
  56892. }
  56893. },
  56894. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  56895. var chunk = data.chunk;
  56896. if (this._requests.length > 0) {
  56897. var requestCapability = this._requests.shift();
  56898. requestCapability.resolve({
  56899. value: chunk,
  56900. done: false
  56901. });
  56902. } else {
  56903. this._queuedChunk = chunk;
  56904. }
  56905. this._done = true;
  56906. this._requests.forEach(function (requestCapability) {
  56907. requestCapability.resolve({
  56908. value: undefined,
  56909. done: true
  56910. });
  56911. });
  56912. this._requests = [];
  56913. this._close();
  56914. },
  56915. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  56916. if (!this.isStreamingSupported && this.onProgress) {
  56917. this.onProgress({ loaded: evt.loaded });
  56918. }
  56919. },
  56920. get isStreamingSupported() {
  56921. return false;
  56922. },
  56923. read: function PDFNetworkStreamRangeRequestReader_read() {
  56924. if (this._queuedChunk !== null) {
  56925. var chunk = this._queuedChunk;
  56926. this._queuedChunk = null;
  56927. return Promise.resolve({
  56928. value: chunk,
  56929. done: false
  56930. });
  56931. }
  56932. if (this._done) {
  56933. return Promise.resolve({
  56934. value: undefined,
  56935. done: true
  56936. });
  56937. }
  56938. var requestCapability = createPromiseCapability();
  56939. this._requests.push(requestCapability);
  56940. return requestCapability.promise;
  56941. },
  56942. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  56943. this._done = true;
  56944. this._requests.forEach(function (requestCapability) {
  56945. requestCapability.resolve({
  56946. value: undefined,
  56947. done: true
  56948. });
  56949. });
  56950. this._requests = [];
  56951. if (this._manager.isPendingRequest(this._requestId)) {
  56952. this._manager.abortRequest(this._requestId);
  56953. }
  56954. this._close();
  56955. }
  56956. };
  56957. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  56958. exports.PDFNetworkStream = PDFNetworkStream;
  56959. exports.NetworkManager = NetworkManager;
  56960. }));
  56961. }.call(pdfjsLibs));
  56962. exports.PDFJS = pdfjsLibs.pdfjsDisplayGlobal.PDFJS;
  56963. exports.build = pdfjsLibs.pdfjsDisplayAPI.build;
  56964. exports.version = pdfjsLibs.pdfjsDisplayAPI.version;
  56965. exports.getDocument = pdfjsLibs.pdfjsDisplayAPI.getDocument;
  56966. exports.PDFDataRangeTransport = pdfjsLibs.pdfjsDisplayAPI.PDFDataRangeTransport;
  56967. exports.PDFWorker = pdfjsLibs.pdfjsDisplayAPI.PDFWorker;
  56968. exports.renderTextLayer = pdfjsLibs.pdfjsDisplayTextLayer.renderTextLayer;
  56969. exports.AnnotationLayer = pdfjsLibs.pdfjsDisplayAnnotationLayer.AnnotationLayer;
  56970. exports.CustomStyle = pdfjsLibs.pdfjsDisplayDOMUtils.CustomStyle;
  56971. exports.PasswordResponses = pdfjsLibs.pdfjsSharedUtil.PasswordResponses;
  56972. exports.InvalidPDFException = pdfjsLibs.pdfjsSharedUtil.InvalidPDFException;
  56973. exports.MissingPDFException = pdfjsLibs.pdfjsSharedUtil.MissingPDFException;
  56974. exports.SVGGraphics = pdfjsLibs.pdfjsDisplaySVG.SVGGraphics;
  56975. exports.UnexpectedResponseException = pdfjsLibs.pdfjsSharedUtil.UnexpectedResponseException;
  56976. exports.OPS = pdfjsLibs.pdfjsSharedUtil.OPS;
  56977. exports.UNSUPPORTED_FEATURES = pdfjsLibs.pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  56978. exports.isValidUrl = pdfjsLibs.pdfjsDisplayDOMUtils.isValidUrl;
  56979. exports.createValidAbsoluteUrl = pdfjsLibs.pdfjsSharedUtil.createValidAbsoluteUrl;
  56980. exports.createObjectURL = pdfjsLibs.pdfjsSharedUtil.createObjectURL;
  56981. exports.removeNullCharacters = pdfjsLibs.pdfjsSharedUtil.removeNullCharacters;
  56982. exports.shadow = pdfjsLibs.pdfjsSharedUtil.shadow;
  56983. exports.createBlob = pdfjsLibs.pdfjsSharedUtil.createBlob;
  56984. exports.getFilenameFromUrl = pdfjsLibs.pdfjsDisplayDOMUtils.getFilenameFromUrl;
  56985. exports.addLinkAttributes = pdfjsLibs.pdfjsDisplayDOMUtils.addLinkAttributes;
  56986. }));